blosc2.jit#
- blosc2.jit(func=None, *, out=None, **kwargs)#
Prepare a function so that it can be used with the Blosc2 compute engine.
The inputs of the function can be any combination of NumPy/NDArray arrays and scalars. The function will be called with the NumPy arrays replaced by SimpleProxy objects, whereas NDArray objects will be used as is.
The returned value will be a NumPy array if all arguments are NumPy arrays or if not kwargs are provided. Else, the return value will be a NDArray created using the provided kwargs.
- Parameters:
- Return type:
wrapper
Notes
Although many NumPy functions are supported, some may not be implemented yet. If you find a function that is not supported, please open an issue.
out and kwargs parameters are not supported for all expressions (e.g. when using a reduction as the last function). In this case, you can still use the out parameter of the reduction function for some custom control over the output.
Examples
>>> import numpy as np >>> import blosc2 >>> @blosc2.jit >>> def compute_expression(a, b, c): >>> return np.sum(((a ** 3 + np.sin(a * 2)) > 2 * c) & (b > 0), axis=1) >>> a = np.arange(20, dtype=np.float32).reshape(4, 5) >>> b = np.arange(20).reshape(4, 5) >>> c = np.arange(5) >>> compute_expression(a, b, c) [5 5 5 5]