Universal Functions (ufuncs)¶
The following elementwise functions can be used for computing with any of NDArray, C2Array, NDField and LazyExpr.
Their result is always a LazyExpr instance, which can be evaluated (with compute
or __getitem__
) to get the actual values of the computation.
Note: The functions conj
, real
, imag
, contains
, where
are not technically ufuncs.
|
Calculate the absolute value element-wise. |
|
Compute the inverse cosine, element-wise. |
|
Compute the inverse hyperbolic cosine, element-wise. |
|
Computes the value of x1_i + x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Compute the inverse cosine, element-wise. |
|
Compute the inverse hyperbolic cosine, element-wise. |
|
Compute the inverse sine, element-wise. |
|
Compute the inverse hyperbolic sine, element-wise. |
|
Compute the inverse tangent, element-wise. |
|
Compute the element-wise arc tangent of |
|
Compute the inverse hyperbolic tangent, element-wise. |
|
Compute the inverse sine, element-wise. |
|
Compute the inverse hyperbolic sine, element-wise. |
|
Compute the inverse tangent, element-wise. |
|
Compute the element-wise arc tangent of |
|
Compute the inverse hyperbolic tangent, element-wise. |
|
Computes the value of x1_i & x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Computes the value of ~x1_i for each element x1_i of the input array x1. |
|
Shifts the bits of each element x1_i of the input array x1 to the left by appending x2_i (i.e., the respective element in the input array x2) zeros to the right of x1_i. |
|
Computes the value of x1_i | x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Shifts the bits of each element x1_i of the input array x1 to the right according to the respective element x2_i of the input array x2. |
|
Computes the value of x1_i ^ x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Rounds each element x_i of the input array x to the smallest (i.e., closest to -infinity) integer-valued number that is not smaller than x_i. |
|
Return the complex conjugate, element-wise. |
|
Composes a floating-point value with the magnitude of x1_i and the sign of x2_i for each element of the input array x1. |
|
Trigonometric cosine, element-wise. |
|
Compute the hyperbolic cosine, element-wise. |
|
Computes the value of x1_i / x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the truth value of x1_i == x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Calculate the exponential of all elements in the input array. |
|
Calculate |
|
Rounds each element x_i of the input array x to the greatest (i.e., closest to +infinity) integer-valued number that is not greater than x_i. |
|
Computes the value of x1_i // x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the truth value of x1_i > x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the truth value of x1_i >= x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the square root of the sum of squares for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Return True/False for finite values element-wise. |
|
Return True/False for infinite values element-wise. |
|
Return True/False for not-a-number values element-wise. |
|
Computes the truth value of x1_i < x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the truth value of x1_i <= x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Compute the natural logarithm, element-wise. |
|
Return the natural logarithm of one plus the input array, element-wise. |
|
Return the base 2 logarithm of the input array, element-wise. |
|
Return the base 10 logarithm of the input array, element-wise. |
|
Calculates the logarithm of the sum of exponentiations log(exp(x1) + exp(x2)) for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the value of x1_i & x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Computes the value of ~x1_i for each element x1_i of the input array x1. |
|
Computes the value of x1_i | x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Computes the value of x1_i ^ x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Computes the matrix product between two Blosc2 NDArrays. |
|
Computes the maximum value for each element x1_i of the input array x1 relative to the respective element x2_i of the input array x2. |
|
Computes the minimum value for each element x1_i of the input array x1 relative to the respective element x2_i of the input array x2. |
|
Computes the value of x1_i * x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the numerical negative of each element x_i (i.e., out_i = -x_i) of the input array x. |
|
Returns the next representable floating-point value for each element x1_i of the input array x1 in the direction of the respective element x2_i of the input array x2. |
|
Computes the truth value of x1_i != x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Computes the numerical positive of each element x_i (i.e., out_i = +x_i) of the input array x. |
|
Computes the value of x1_i**x2_i for each element x1_i of the input array x1 and x2_i of x2. |
|
Computes the value of 1/x1_i for each element x1_i of the input array x1. |
|
Returns the remainder of division for each element x1_i of the input array x1 and the respective element x2_i of the input array x2. |
|
Returns an indication of the sign of a number for each element x_i of the input array x. |
|
Determines whether the sign bit is set for each element x_i of the input array x. |
|
Compute the trigonometric sine, element-wise. |
|
Hyperbolic sine, element-wise. |
|
Return the non-negative square-root of an array, element-wise. |
|
Computes the value of x1_i**2 for each element x1_i of the input array x1. |
|
Computes the value of x1_i - x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. |
|
Compute the trigonometric tangent, element-wise. |
|
Compute the hyperbolic tangent, element-wise. |
|
Rounds each element x_i of the input array x to the closest to 0 integer-valued number. |
|
Computes the (vector) dot product of two arrays. |
- blosc2.abs(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Calculate the absolute value element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression that can be evaluated to get the absolute values.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-5, -3, 0, 2, 4]) >>> ndarray = blosc2.asarray(values) >>> result_ = blosc2.abs(ndarray) >>> result = result_[:] >>> print("Original values:", values) Original values: [-5 -3 0 2 4] >>> print("Absolute values:", result) Absolute values: [5. 3. 0. 2. 4.]
- blosc2.acos(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse cosine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arccos(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arccos:", result) Arccos: [3.14159265 2.0943951 1.57079633 1.04719755 0. ]
- blosc2.acosh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic cosine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([1, 2, 3, 4, 5]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arccosh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [1 2 3 4 5] >>> print("Arccosh:", result) Arccosh: [0. 1.3169579 1.76274717 2.06343707 2.29243167]
- blosc2.add(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i + x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.arccos(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse cosine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arccos(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arccos:", result) Arccos: [3.14159265 2.0943951 1.57079633 1.04719755 0. ]
- blosc2.arccosh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic cosine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([1, 2, 3, 4, 5]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arccosh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [1 2 3 4 5] >>> print("Arccosh:", result) Arccosh: [0. 1.3169579 1.76274717 2.06343707 2.29243167]
- blosc2.arcsin(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse sine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arcsin(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arcsin:", result) Arcsin: [-1.57079633 -0.52359878 0. 0.52359878 1.57079633]
- blosc2.arcsinh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic sine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-2, -1, 0, 1, 2]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arcsinh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-2 -1 0 1 2] >>> print("Arcsinh:", result) Arcsinh: [-1.44363548 -0.88137359 0. 0.88137359 1.44363548]
- blosc2.arctan(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse tangent of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arctan(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arctan:", result) Arctan: [-0.78539816 -0.46364761 0. 0.46364761 0.78539816]
- blosc2.arctan2(ndarr1: NDArray | NDField | C2Array, ndarr2: NDArray | NDField | C2Array, /) LazyExpr [source]¶
Compute the element-wise arc tangent of
ndarr1 / ndarr2
choosing the quadrant correctly.- Parameters:
- Returns:
out – A lazy expression representing the element-wise arc tangent of
ndarr1 / ndarr2
. The result can be evaluated.- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> y = np.array([0, 1, 0, -1, 1]) >>> x = np.array([1, 1, -1, -1, 0]) >>> ndarray_y = blosc2.asarray(y) >>> ndarray_x = blosc2.asarray(x) >>> result_lazy = blosc2.arctan2(ndarray_y, ndarray_x) >>> result = result_lazy[:] >>> print("y:", y) y: [ 0 1 0 -1 1] >>> print("x:", x) x: [ 1 1 -1 -1 0] >>> print("Arctan2(y, x):", result) Arctan2(y, x): [ 0. 0.78539816 3.14159265 -2.35619449 1.57079633]
- blosc2.arctanh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic tangent of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-0.9, -0.5, 0, 0.5, 0.9]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arctanh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-0.9 -0.5 0. 0.5 0.9] >>> print("Arctanh:", result) Arctanh: [-1.47221949 -0.54930614 0. 0.54930614 1.47221949]
- blosc2.asin(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse sine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arcsin(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arcsin:", result) Arcsin: [-1.57079633 -0.52359878 0. 0.52359878 1.57079633]
- blosc2.asinh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic sine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-2, -1, 0, 1, 2]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arcsinh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-2 -1 0 1 2] >>> print("Arcsinh:", result) Arcsinh: [-1.44363548 -0.88137359 0. 0.88137359 1.44363548]
- blosc2.atan(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse tangent of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.arctan(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-1. -0.5 0. 0.5 1. ] >>> print("Arctan:", result) Arctan: [-0.78539816 -0.46364761 0. 0.46364761 0.78539816]
- blosc2.atan2(ndarr1: NDArray | NDField | C2Array, ndarr2: NDArray | NDField | C2Array, /) LazyExpr [source]¶
Compute the element-wise arc tangent of
ndarr1 / ndarr2
choosing the quadrant correctly.- Parameters:
- Returns:
out – A lazy expression representing the element-wise arc tangent of
ndarr1 / ndarr2
. The result can be evaluated.- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> y = np.array([0, 1, 0, -1, 1]) >>> x = np.array([1, 1, -1, -1, 0]) >>> ndarray_y = blosc2.asarray(y) >>> ndarray_x = blosc2.asarray(x) >>> result_lazy = blosc2.arctan2(ndarray_y, ndarray_x) >>> result = result_lazy[:] >>> print("y:", y) y: [ 0 1 0 -1 1] >>> print("x:", x) x: [ 1 1 -1 -1 0] >>> print("Arctan2(y, x):", result) Arctan2(y, x): [ 0. 0.78539816 3.14159265 -2.35619449 1.57079633]
- blosc2.atanh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the inverse hyperbolic tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the inverse hyperbolic tangent of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-0.9, -0.5, 0, 0.5, 0.9]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.arctanh(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-0.9 -0.5 0. 0.5 0.9] >>> print("Arctanh:", result) Arctanh: [-1.47221949 -0.54930614 0. 0.54930614 1.47221949]
- blosc2.bitwise_and(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i & x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, integer or boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Integer or boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.bitwise_invert(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of ~x1_i for each element x1_i of the input array x1.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Input array, integer or boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.bitwise_left_shift(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Shifts the bits of each element x1_i of the input array x1 to the left by appending x2_i (i.e., the respective element in the input array x2) zeros to the right of x1_i.
Note: this operation is equivalent to multiplying x1 by 2**x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, integer.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, integer.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.bitwise_or(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i | x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, integer or boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, integer or boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.bitwise_right_shift(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Shifts the bits of each element x1_i of the input array x1 to the right according to the respective element x2_i of the input array x2.
Note: This operation is an arithmetic shift (i.e., sign-propagating) and thus equivalent to floor division by a power of two.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, integer.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, integer.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.bitwise_xor(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i ^ x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, integer or boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, integer or boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.ceil(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Rounds each element x_i of the input array x to the smallest (i.e., closest to -infinity) integer-valued number that is not smaller than x_i.
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.conj(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return the complex conjugate, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the complex conjugate of the input array.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([1+2j, 3-4j, -5+6j, 7-8j]) >>> ndarray = blosc2.asarray(values) >>> result_ = blosc2.conj(ndarray) >>> result = result_[:] >>> print("Original values:", values) Original values: [ 1.+2.j 3.-4.j -5.+6.j 7.-8.j] >>> print("Complex conjugates:", result) Complex conjugates: [ 1.-2.j 3.+4.j -5.-6.j 7.+8.j]
- blosc2.copysign(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Composes a floating-point value with the magnitude of x1_i and the sign of x2_i for each element of the input array x1.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. Real-valued floating point dtype.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Real-valued floating point dtype.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.cos(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Trigonometric cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array containing angles in radians.
- Returns:
out – A lazy expression representing the cosine of the input angles. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> angles = np.array([0, np.pi/6, np.pi/4, np.pi/2, np.pi]) >>> nd_array = blosc2.asarray(angles) >>> result_ = blosc2.cos(nd_array) >>> result = result_[:] >>> print("Angles in radians:", angles) Angles in radians: [0. 0.52359878 0.78539816 1.57079633 3.14159265] >>> print("Cosine of the angles:", result) Cosine of the angles: [ 1.00000000e+00 8.66025404e-01 7.07106781e-01 6.12323400e-17 -1.00000000e+00]
- blosc2.cosh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the hyperbolic cosine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the hyperbolic cosine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-2, -1, 0, 1, 2]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.cosh(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-2 -1 0 1 2] >>> print("Hyperbolic cosine:", result) Hyperbolic cosine: [3.76219569 1.54308063 1. 1.54308063 3.76219569]
- blosc2.divide(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i / x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.equal(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i == x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.exp(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Calculate the exponential of all elements in the input array.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the exponential of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([0, 1, 2, 3, 4]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.exp(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [0 1 2 3 4] >>> print("Exponential:", result) Exponential: [ 1. 2.71828183 7.3890561 20.08553692 54.59815003]
- blosc2.expm1(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Calculate
exp(ndarr) - 1
for all elements in the array.- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing
exp(ndarr) - 1
of the input array. The result can be evaluated.- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-1, -0.5, 0, 0.5, 1]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.expm1(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-1. -0.5 0. 0.5 1. ] >>> print("Expm1:", result) Expm1: [-0.63212056 -0.39346934 0. 0.64872127 1.71828183]
- blosc2.floor(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Rounds each element x_i of the input array x to the greatest (i.e., closest to +infinity) integer-valued number that is not greater than x_i.
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.floor_divide(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i // x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any real-valued data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.greater(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i > x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.greater_equal(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i >= x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.hypot(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the square root of the sum of squares for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. Real-valued floating point dtype.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Real-valued floating point dtype.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.isfinite(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return True/False for finite values element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression that can be evaluated to get the True/False array of results.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-5, -3, np.inf, 2, 4]) >>> ndarray = blosc2.asarray(values) >>> result_ = blosc2.isfinite(ndarray) >>> result = result_[:] >>> print("isfinite:", result) isfinite: [True, True, False, True, True]
- blosc2.isinf(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return True/False for infinite values element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression that can be evaluated to get the True/False array of results.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-5, -3, np.inf, 2, 4]) >>> ndarray = blosc2.asarray(values) >>> result_ = blosc2.isinf(ndarray) >>> result = result_[:] >>> print("isinf:", result) isinf: [False, False, True, False, False]
- blosc2.isnan(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return True/False for not-a-number values element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression that can be evaluated to get the True/False array of results.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-5, -3, np.nan, 2, 4]) >>> ndarray = blosc2.asarray(values) >>> result_ = blosc2.isnan(ndarray) >>> result = result_[:] >>> print("isnan:", result) isnan: [False, False, True, False, False]
- blosc2.less(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i < x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.less_equal(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i <= x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.log(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the natural logarithm, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the natural logarithm of the input array
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([1, 2, 3, 4, 5]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.log(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [1 2 3 4 5] >>> print("Logarithm (base e):", result) Logarithm (base e): [0. 0.69314718 1.09861229 1.38629436 1.60943791]
- blosc2.log1p(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return the natural logarithm of one plus the input array, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the natural logarithm of one plus the input array.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([-0.9, -0.5, 0, 0.5, 0.9]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.log1p(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [-0.9 -0.5 0. 0.5 0.9] >>> print("Log1p (log(1 + x)):", result) Log1p (log(1 + x)): [-2.30258509 -0.69314718 0. 0.40546511 0.64185389]
- blosc2.log2(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return the base 2 logarithm of the input array, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the base 2 logarithm of the input array.
- Return type:
References
- blosc2.log10(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return the base 10 logarithm of the input array, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the base 10 logarithm of the input array.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> values = np.array([1, 10, 100, 1000, 10000]) >>> ndarray = blosc2.asarray(values) >>> result_lazy = blosc2.log10(ndarray) >>> result = result_lazy[:] >>> print("Original values:", values) Original values: [ 1 10 100 1000 10000] >>> print("Logarithm (base 10):", result) Logarithm (base 10): [0. 1. 2. 3. 4.]
- blosc2.logaddexp(x1: int | float | NDArray, x2: int | float | NDArray) NDArray [source]¶
Calculates the logarithm of the sum of exponentiations log(exp(x1) + exp(x2)) for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued floating-point data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any real-valued floating-point data type.
- Returns:
out – An array containing element-wise results.
- Return type:
- blosc2.logical_and(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i & x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.logical_not(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of ~x1_i for each element x1_i of the input array x1.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Input array, boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.logical_or(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i | x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.logical_xor(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i ^ x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, boolean.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1, boolean.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.matmul(x1: NDArray | ndarray, x2: NDArray, **kwargs: Any) NDArray [source]¶
Computes the matrix product between two Blosc2 NDArrays.
- Parameters:
- Returns:
out – The matrix product of the inputs. This is a scalar only when both x1, x2 are 1-d vectors.
- Return type:
- Raises:
ValueError –
If the last dimension of
x1
is not the same size as the second-to-last dimension ofx2
.If a scalar value is passed in.
References
Examples
For 2-D arrays it is the matrix product:
>>> import numpy as np >>> import blosc2 >>> a = np.array([[1, 2], ... [3, 4]]) >>> nd_a = blosc2.asarray(a) >>> b = np.array([[2, 3], ... [2, 1]]) >>> nd_b = blosc2.asarray(b) >>> blosc2.matmul(nd_a, nd_b) array([[ 6, 5], [14, 13]])
For 2-D mixed with 1-D, the result is the usual.
>>> a = np.array([[1, 3], ... [0, 1]]) >>> nd_a = blosc2.asarray(a) >>> v = np.array([1, 2]) >>> nd_v = blosc2.asarray(v) >>> blosc2.matmul(nd_a, nd_v) array([7, 2]) >>> blosc2.matmul(nd_v, nd_a) array([1, 5])
- blosc2.maximum(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the maximum value for each element x1_i of the input array x1 relative to the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. Real-valued dtype.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Real-valued dtype.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.minimum(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the minimum value for each element x1_i of the input array x1 relative to the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. Real-valued dtype.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. Real-valued dtype.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.multiply(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i * x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.negative(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the numerical negative of each element x_i (i.e., out_i = -x_i) of the input array x.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.nextafter(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Returns the next representable floating-point value for each element x1_i of the input array x1 in the direction of the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. Real-valued floating point dtype.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1 and have same data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.not_equal(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the truth value of x1_i != x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.positive(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the numerical positive of each element x_i (i.e., out_i = +x_i) of the input array x.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.pow(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Computes the value of x1_i**x2_i for each element x1_i of the input array x1 and x2_i of x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.reciprocal(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of 1/x1_i for each element x1_i of the input array x1.
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array, floating-point data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.remainder(x1: NDArray | NDField | C2Array | LazyExpr | int | float | complex, x2: NDArray | NDField | C2Array | LazyExpr | int | float | complex) LazyExpr [source]¶
Returns the remainder of division for each element x1_i of the input array x1 and the respective element x2_i of the input array x2.
Note: This function is equivalent to the Python modulus operator x1_i % x2_i.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.sign(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Returns an indication of the sign of a number for each element x_i of the input array x.
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any numeric data type.
- Returns:
out – A LazyArray containing the element-wise results (-1, 0 or 1).
- Return type:
LazyExpr
References
- blosc2.signbit(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Determines whether the sign bit is set for each element x_i of the input array x.
The sign bit of a real-valued floating-point number x_i is set whenever x_i is either -0, less than zero, or a signed NaN (i.e., a NaN value whose sign bit is 1).
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued floating-point data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.sin(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the trigonometric sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array containing angles in radians.
- Returns:
out – A lazy expression representing the sine of the input angles. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> angles = np.array([0, np.pi/6, np.pi/4, np.pi/2, np.pi]) >>> nd_array = blosc2.asarray(angles) >>> result_ = blosc2.sin(nd_array) >>> result = result_[:] >>> print("Angles in radians:", angles) Angles in radians: [0. 0.52359878 0.78539816 1.57079633 3.14159265] >>> print("Sine of the angles:", result) Sine of the angles: [0.00000000e+00 5.00000000e-01 7.07106781e-01 1.00000000e+00 1.22464680e-16]
- blosc2.sinh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Hyperbolic sine, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the hyperbolic sine of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-2, -1, 0, 1, 2]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.sinh(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-2 -1 0 1 2] >>> print("Hyperbolic sine:", result) Hyperbolic sine: [-3.62686041 -1.17520119 0. 1.17520119 3.62686041]
- blosc2.sqrt(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Return the non-negative square-root of an array, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the square root of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> data = np.array([0, np.pi/6, np.pi/4, np.pi/2, np.pi]) >>> nd_array = blosc2.asarray(data) >>> result_ = blosc2.sqrt(nd_array) >>> result = result_[:] >>> print("Original numbers:", data) Original numbers: [ 0 1 4 9 16 25] >>> print("Square roots:", result) Square roots: [0. 1. 2. 3. 4. 5.]
- blosc2.square(x1: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i**2 for each element x1_i of the input array x1.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.subtract(x1: NDArray | NDField | C2Array | LazyExpr, x2: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Computes the value of x1_i - x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.
- Parameters:
x1¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any data type.
x2¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – Second input array. Must be compatible with x1. May have any data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.tan(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the trigonometric tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array containing angles in radians.
- Returns:
out – A lazy expression representing the tangent of the input angles. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> angles = np.array([0, np.pi/6, np.pi/4, np.pi/2, np.pi]) >>> nd_array = blosc2.asarray(angles) >>> result_ = blosc2.tan(nd_array) >>> result = result_[:] >>> print("Angles in radians:", angles) Angles in radians: [0. 0.52359878 0.78539816 1.57079633 3.14159265] >>> print("Tangent of the angles:", result) Tangent of the angles: [ 0.00000000e+00 5.77350269e-01 1.00000000e+00 1.63312394e+16 -1.22464680e-16]
- blosc2.tanh(ndarr: NDArray | NDField | C2Array | LazyExpr, /) LazyExpr [source]¶
Compute the hyperbolic tangent, element-wise.
- Parameters:
ndarr¶ (NDArray or NDField or C2Array or LazyExpr) – The input array.
- Returns:
out – A lazy expression representing the hyperbolic tangent of the input array. The result can be evaluated.
- Return type:
References
Examples
>>> import numpy as np >>> import blosc2 >>> numbers = np.array([-2, -1, 0, 1, 2]) >>> ndarray = blosc2.asarray(numbers) >>> result_lazy = blosc2.tanh(ndarray) >>> result = result_lazy[:] >>> print("Original numbers:", numbers) Original numbers: [-2 -1 0 1 2] >>> print("Hyperbolic tangent:", result) Hyperbolic tangent: [-0.96402758 -0.76159416 0. 0.76159416 0.96402758]
- blosc2.trunc(x: NDArray | NDField | C2Array | LazyExpr) LazyExpr [source]¶
Rounds each element x_i of the input array x to the closest to 0 integer-valued number.
- Parameters:
x¶ (NDArray | NDField | blosc2.C2Array | blosc2.LazyExpr) – First input array. May have any real-valued data type.
- Returns:
out – A LazyArray containing the element-wise results.
- Return type:
LazyExpr
References
- blosc2.vecdot(x1: NDArray, x2: NDArray, axis: int = -1, **kwargs) NDArray [source]¶
Computes the (vector) dot product of two arrays. Complex conjugates x1.
- Parameters:
x1¶ (blosc2.NDArray) – First input array. Must have floating-point data type.
x2¶ (blosc2.NDArray) – Second input array. Must be compatible with x1 for all non-contracted axes (via broadcasting). The size of the axis over which to compute the dot product must be the same size as the respective axis in x1. Must have a floating-point data type.
axis¶ (int) – The axis (dimension) of x1 and x2 containing the vectors for which to compute the dot product. Should be an integer on the interval [-N, -1], where N is min(x1.ndim, x2.ndim). Default: -1.
- Returns:
out – If x1 and x2 are both one-dimensional arrays, a zero-dimensional containing the dot product; otherwise, a non-zero-dimensional array containing the dot products and having rank N-1, where N is the rank (number of dimensions) of the shape determined according to broadcasting along the non-contracted axes.
- Return type: