@@ -1005,6 +1005,25 @@ def item(self) -> float | bool | complex | int:
10051005 """
10061006 return self [()].item ()
10071007
1008+ def where (self , value1 = None , value2 = None ):
1009+ """
1010+ Select ``value1`` or ``value2`` values based on ``True``/``False`` for ``self``.
1011+
1012+ Parameters
1013+ ----------
1014+ value1: array_like, optional
1015+ The value to select when element of ``self`` is True.
1016+ value2: array_like, optional
1017+ The value to select when element of ``self`` is False.
1018+
1019+ Returns
1020+ -------
1021+ out: LazyExpr
1022+ A new expression with the where condition applied.
1023+ """
1024+ expr = blosc2 .LazyExpr ._new_expr ("o0" , {"o0" : self }, guess = False ).where (value1 , value2 )
1025+ return expr .compute ()
1026+
10081027 @is_documented_by (sum )
10091028 def sum (self , axis = None , dtype = None , keepdims = False , ** kwargs ):
10101029 expr = blosc2 .LazyExpr (new_op = (self , None , None ))
@@ -2673,6 +2692,9 @@ def arcsin(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> bl
26732692 return blosc2 .LazyExpr (new_op = (ndarr , "arcsin" , None ))
26742693
26752694
2695+ asin = arcsin # alias
2696+
2697+
26762698def arccos (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
26772699 """
26782700 Compute the inverse cosine, element-wise.
@@ -2708,6 +2730,9 @@ def arccos(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> bl
27082730 return blosc2 .LazyExpr (new_op = (ndarr , "arccos" , None ))
27092731
27102732
2733+ acos = arccos # alias
2734+
2735+
27112736def arctan (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
27122737 """
27132738 Compute the inverse tangent, element-wise.
@@ -2743,6 +2768,9 @@ def arctan(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> bl
27432768 return blosc2 .LazyExpr (new_op = (ndarr , "arctan" , None ))
27442769
27452770
2771+ atan = arctan # alias
2772+
2773+
27462774def arctan2 (
27472775 ndarr1 : NDArray | NDField | blosc2 .C2Array , ndarr2 : NDArray | NDField | blosc2 .C2Array , /
27482776) -> blosc2 .LazyExpr :
@@ -2786,6 +2814,9 @@ def arctan2(
27862814 return blosc2 .LazyExpr (new_op = (ndarr1 , "arctan2" , ndarr2 ))
27872815
27882816
2817+ atan2 = arctan2 # alias
2818+
2819+
27892820def arcsinh (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
27902821 """
27912822 Compute the inverse hyperbolic sine, element-wise.
@@ -2821,6 +2852,9 @@ def arcsinh(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> b
28212852 return blosc2 .LazyExpr (new_op = (ndarr , "arcsinh" , None ))
28222853
28232854
2855+ asinh = arcsinh # alias
2856+
2857+
28242858def arccosh (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
28252859 """
28262860 Compute the inverse hyperbolic cosine, element-wise.
@@ -2856,6 +2890,9 @@ def arccosh(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> b
28562890 return blosc2 .LazyExpr (new_op = (ndarr , "arccosh" , None ))
28572891
28582892
2893+ acosh = arccosh # alias
2894+
2895+
28592896def arctanh (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
28602897 """
28612898 Compute the inverse hyperbolic tangent, element-wise.
@@ -2891,6 +2928,9 @@ def arctanh(ndarr: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr, /) -> b
28912928 return blosc2 .LazyExpr (new_op = (ndarr , "arctanh" , None ))
28922929
28932930
2931+ atanh = arctanh # alias
2932+
2933+
28942934def exp (ndarr : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr , / ) -> blosc2 .LazyExpr :
28952935 """
28962936 Calculate the exponential of all elements in the input array.
@@ -3387,8 +3427,36 @@ def multiply(
33873427 return x1 * x2
33883428
33893429
3430+ def add (
3431+ x1 : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr ,
3432+ x2 : NDArray | NDField | blosc2 .C2Array | blosc2 .LazyExpr ,
3433+ ) -> blosc2 .LazyExpr :
3434+ """
3435+ Computes the value of x1_i + x2_i for each element x1_i of the input array x1
3436+ with the respective element x2_i of the input array x2.
3437+
3438+ Parameters
3439+ -----------
3440+ x1: NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr
3441+ First input array. May have any data type.
3442+
3443+ x2:NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr
3444+ Second input array. Must be compatible with x1. May have any data type.
3445+
3446+ Returns
3447+ -------
3448+ out LazyExpr
3449+ A LazyArray containing the element-wise results.
3450+
3451+ References
3452+ ----------
3453+ `np.add <https://numpy.org/doc/stable/reference/generated/numpy.add.html#numpy.add>`_
3454+ """
3455+ return x1 + x2
3456+
3457+
33903458def where (
3391- condition : blosc2 .LazyExpr ,
3459+ condition : blosc2 .LazyExpr | NDArray ,
33923460 x : NDArray | NDField | np .ndarray | int | float | complex | bool | str | bytes | None = None ,
33933461 y : NDArray | NDField | np .ndarray | int | float | complex | bool | str | bytes | None = None ,
33943462) -> blosc2 .LazyExpr :
@@ -4301,7 +4369,6 @@ def asarray(
43014369 >>> # Create a NDArray from a NumPy array
43024370 >>> nda = blosc2.asarray(a)
43034371 """
4304-
43054372 # Convert scalars to numpy array
43064373 casting = kwargs .pop ("casting" , "unsafe" )
43074374 if casting != "unsafe" :
0 commit comments