224224 "Arcsinh" ,
225225 "Arccosh" ,
226226 "Arctanh" ,
227- "Round" ,
228- "Floor" ,
229- "Ceil" ,
230- "Exp" ,
231- "Log" ,
232- "Log10" ,
233- "Log2" ,
234- "Angle" ,
235- "Real" ,
236- "Imag" ,
237- "Abs" ,
238- "Conj" ,
239- "Conjugate" ,
240- "Sqrt" ,
241- "Square" ,
242- "Sign" ,
227+ # "Round",
228+ # "Floor",
229+ # "Ceil",
230+ # "Exp",
231+ # "Log",
232+ # "Log10",
233+ # "Log2",
234+ # "Angle",
235+ # "Real",
236+ # "Imag",
237+ # "Abs",
238+ # "Conj",
239+ # "Conjugate",
240+ # "Sqrt",
241+ # "Square",
242+ # "Sign",
243243]
244244
245245
@@ -290,6 +290,7 @@ def __init__(
290290 self : ElementwiseFeature ,
291291 function : Callable [[Any ], Any ],
292292 feature : Feature | None = None ,
293+ function_name : str | None = None ,
293294 ** kwargs : Any ,
294295 ):
295296 """Initialize ElementwiseFeature.
@@ -305,6 +306,8 @@ def __init__(
305306 feature: Feature | None, optional
306307 The feature whose output will be transformed. If `None`, the
307308 function is applied to the direct input.
309+ function_name: str | None, optional
310+ The name of the function, used for error messages.
308311 **kwargs: Any
309312 Additional keyword arguments passed to the `Feature` base class.
310313
@@ -314,6 +317,7 @@ def __init__(
314317
315318 # Store the function to be applied elementwise
316319 self .function = function
320+ self .function_name = function_name
317321
318322 # Add the feature dependency if provided
319323 self .feature = (
@@ -368,6 +372,9 @@ def get(
368372 if self .feature is not None :
369373 data = self .feature (** kwargs )
370374
375+ if self .function_name is not None :
376+ return getattr (xp , self .function_name )(data )
377+
371378 # Apply the function elementwise
372379 return self .function (data )
373380
@@ -376,6 +383,7 @@ def create_elementwise_class(
376383 name : str ,
377384 function : Callable [[Any ], Any ],
378385 docstring : str = "" ,
386+ function_name : str | None = None ,
379387) -> type [ElementwiseFeature ]:
380388 """Factory function to create subclasses of ElementwiseFeature.
381389
@@ -395,6 +403,8 @@ def create_elementwise_class(
395403 docstring: str, optional
396404 The docstring for the generated class. This string will be visible
397405 in IDE tooltips and Sphinx documentation.
406+ function_name: str | None, optional
407+ The name of the function, used for error messages.
398408
399409 Returns
400410 -------
@@ -464,16 +474,22 @@ def create_elementwise_class(
464474
465475 """
466476
477+
467478 class _GeneratedElementwise (ElementwiseFeature ):
468479 """Dynamically generated subclass of ElementwiseFeature."""
469480
470481 def __init__ (
471- self : _GeneratedElementwise ,
472- feature : Feature | None = None ,
482+ self : _GeneratedElementwise ,
483+ feature : Feature | None = None ,
473484 ** kwargs : Any ,
474485 ) -> None :
475- # Initialize the ElementwiseFeature with the fixed function
476- super ().__init__ (function = function , feature = feature , ** kwargs )
486+ """Initialize the ElementwiseFeature with the fixed function."""
487+ super ().__init__ (
488+ function = function ,
489+ function_name = function_name ,
490+ feature = feature ,
491+ ** kwargs ,
492+ )
477493
478494 # Set the class name to match the intended name
479495 _GeneratedElementwise .__name__ = name
@@ -483,7 +499,7 @@ def __init__(
483499
484500 # Attach the user-specified docstring to enable documentation
485501 _GeneratedElementwise .__doc__ = docstring
486-
502+
487503 # Set correct module to ensure proper Sphinx indexing and import tracing
488504 _GeneratedElementwise .__module__ = __name__
489505
@@ -493,6 +509,7 @@ def __init__(
493509Sin = create_elementwise_class (
494510 name = "Sin" ,
495511 function = xp .sin ,
512+ function_name = "sin" ,
496513 docstring = """
497514 Apply the sine function elementwise.
498515
@@ -553,6 +570,7 @@ def __init__(
553570Cos = create_elementwise_class (
554571 name = "Cos" ,
555572 function = xp .cos ,
573+ function_name = "cos" ,
556574 docstring = """
557575 Apply the cosine function elementwise.
558576
@@ -613,6 +631,7 @@ def __init__(
613631Tan = create_elementwise_class (
614632 name = "Tan" ,
615633 function = xp .tan ,
634+ function_name = "tan" ,
616635 docstring = """
617636 Apply the tangent function elementwise.
618637
@@ -673,6 +692,7 @@ def __init__(
673692Arcsin = create_elementwise_class (
674693 name = "Arcsin" ,
675694 function = xp .arcsin ,
695+ function_name = "arcsin" ,
676696 docstring = """
677697 Apply the arcsine function elementwise.
678698
@@ -736,6 +756,7 @@ def __init__(
736756Arctan = create_elementwise_class (
737757 name = "Arctan" ,
738758 function = xp .arctan ,
759+ function_name = "arctan" ,
739760 docstring = """
740761 Apply the arctangent function elementwise.
741762
@@ -796,6 +817,7 @@ def __init__(
796817Sinh = create_elementwise_class (
797818 name = "Sinh" ,
798819 function = xp .sinh ,
820+ function_name = "sinh" ,
799821 docstring = """
800822 Apply the hyperbolic sine function elementwise.
801823
@@ -857,6 +879,7 @@ def __init__(
857879Cosh = create_elementwise_class (
858880 name = "Cosh" ,
859881 function = xp .cosh ,
882+ function_name = "cosh" ,
860883 docstring = """
861884 Apply the hyperbolic cosine function elementwise.
862885
@@ -918,6 +941,7 @@ def __init__(
918941Tanh = create_elementwise_class (
919942 name = "Tanh" ,
920943 function = xp .tanh ,
944+ function_name = "tanh" ,
921945 docstring = """
922946 Apply the hyperbolic tangent function elementwise.
923947
@@ -979,6 +1003,7 @@ def __init__(
9791003Arcsinh = create_elementwise_class (
9801004 name = "Arcsinh" ,
9811005 function = xp .arcsinh ,
1006+ function_name = "arcsinh" ,
9821007 docstring = """
9831008 Apply the inverse hyperbolic sine function elementwise.
9841009
@@ -1040,6 +1065,7 @@ def __init__(
10401065Arccosh = create_elementwise_class (
10411066 name = "Arccosh" ,
10421067 function = xp .arccosh ,
1068+ function_name = "arccosh" ,
10431069 docstring = """
10441070 Apply the inverse hyperbolic cosine function elementwise.
10451071
@@ -1104,6 +1130,7 @@ def __init__(
11041130Arctanh = create_elementwise_class (
11051131 name = "Arctanh" ,
11061132 function = xp .arctanh ,
1133+ function_name = "arctanh" ,
11071134 docstring = """
11081135 Apply the inverse hyperbolic tangent function elementwise.
11091136
@@ -1168,6 +1195,7 @@ def __init__(
11681195Round = create_elementwise_class (
11691196 name = "Round" ,
11701197 function = xp .round ,
1198+ function_name = "round" ,
11711199 docstring = """
11721200 Apply the rounding function elementwise.
11731201
@@ -1464,6 +1492,7 @@ def _ceil_dispatch(
14641492Exp = create_elementwise_class (
14651493 name = "Exp" ,
14661494 function = xp .exp ,
1495+ function_name = "exp" ,
14671496 docstring = """
14681497 Apply the exponential function elementwise.
14691498
@@ -1524,6 +1553,7 @@ def _ceil_dispatch(
15241553Log = create_elementwise_class (
15251554 name = "Log" ,
15261555 function = xp .log ,
1556+ function_name = "log" ,
15271557 docstring = """
15281558 Apply the natural logarithm function elementwise.
15291559
@@ -1589,6 +1619,7 @@ def _ceil_dispatch(
15891619Log10 = create_elementwise_class (
15901620 name = "Log10" ,
15911621 function = xp .log10 ,
1622+ function_name = "log10" ,
15921623 docstring = """
15931624 Apply the base-10 logarithm function elementwise.
15941625
@@ -1652,6 +1683,7 @@ def _ceil_dispatch(
16521683Log2 = create_elementwise_class (
16531684 name = "Log2" ,
16541685 function = xp .log2 ,
1686+ function_name = "log2" ,
16551687 docstring = """
16561688 Apply the base-2 logarithm function elementwise.
16571689
@@ -1825,6 +1857,7 @@ def _angle_dispatch(
18251857Real = create_elementwise_class (
18261858 name = "Real" ,
18271859 function = xp .real ,
1860+ function_name = "real" ,
18281861 docstring = """
18291862 Apply the real-part function elementwise.
18301863
@@ -2000,6 +2033,7 @@ def _imag_dispatch(
20002033Abs = create_elementwise_class (
20012034 name = "Abs" ,
20022035 function = xp .abs ,
2036+ function_name = "abs" ,
20032037 docstring = """
20042038 Apply the absolute value function elementwise.
20052039
@@ -2055,6 +2089,7 @@ def _imag_dispatch(
20552089Conj = create_elementwise_class (
20562090 name = "Conj" ,
20572091 function = xp .conj ,
2092+ function_name = "conj" ,
20582093 docstring = """
20592094 Apply the complex conjugate function elementwise.
20602095
@@ -2119,6 +2154,7 @@ def _imag_dispatch(
21192154Sqrt = create_elementwise_class (
21202155 name = "Sqrt" ,
21212156 function = xp .sqrt ,
2157+ function_name = "sqrt" ,
21222158 docstring = """
21232159 Apply the square root function elementwise.
21242160
@@ -2182,6 +2218,7 @@ def _imag_dispatch(
21822218Square = create_elementwise_class (
21832219 name = "Square" ,
21842220 function = xp .square ,
2221+ function_name = "square" ,
21852222 docstring = """
21862223 Apply the square function elementwise.
21872224
0 commit comments