@@ -288,7 +288,7 @@ def sort(self, order: str | list[str] | None = None) -> blosc2.LazyArray:
288
288
@abstractmethod
289
289
def compute (self , item : slice | list [slice ] | None = None , ** kwargs : Any ) -> blosc2 .NDArray :
290
290
"""
291
- Return an :ref:`NDArray` containing the evaluation of the :ref:`LazyArray`.
291
+ Return a :ref:`NDArray` containing the evaluation of the :ref:`LazyArray`.
292
292
293
293
Parameters
294
294
----------
@@ -337,9 +337,9 @@ def compute(self, item: slice | list[slice] | None = None, **kwargs: Any) -> blo
337
337
pass
338
338
339
339
@abstractmethod
340
- def __getitem__ (self , item : int | slice | Sequence [slice ]) -> blosc2 . NDArray :
340
+ def __getitem__ (self , item : int | slice | Sequence [slice ]) -> np . ndarray :
341
341
"""
342
- Return a NumPy .ndarray containing the evaluation of the :ref:`LazyArray`.
342
+ Return a numpy .ndarray containing the evaluation of the :ref:`LazyArray`.
343
343
344
344
Parameters
345
345
----------
@@ -392,7 +392,7 @@ def save(self, **kwargs: Any) -> None:
392
392
393
393
Notes
394
394
-----
395
- * All the operands of the LazyArray must be Python scalars, :ref:`NDArray`, :ref:`C2Array` or :ref:`Proxy` .
395
+ * All the operands of the LazyArray must be Python scalars, or :ref:`blosc2.Array` objects .
396
396
* If an operand is a :ref:`Proxy`, keep in mind that Python-Blosc2 will only be able to reopen it as such
397
397
if its source is a :ref:`SChunk`, :ref:`NDArray` or a :ref:`C2Array` (see :func:`blosc2.open` notes
398
398
section for more info).
@@ -507,14 +507,12 @@ def convert_inputs(inputs):
507
507
return []
508
508
inputs_ = []
509
509
for obj in inputs :
510
- if not isinstance (
511
- obj , np .ndarray | blosc2 .NDArray | blosc2 .NDField | blosc2 .C2Array
512
- ) and not np .isscalar (obj ):
510
+ if not isinstance (obj , blosc2 .Array ) and not np .isscalar (obj ):
513
511
try :
514
512
obj = np .asarray (obj )
515
513
except Exception :
516
514
print (
517
- "Inputs not being np.ndarray, NDArray, NDField, C2Array or Python scalar objects"
515
+ "Inputs not being np.ndarray, Array or Python scalar objects"
518
516
" should be convertible to np.ndarray."
519
517
)
520
518
raise
@@ -687,9 +685,9 @@ def visit_Call(self, node):
687
685
688
686
def conserve_functions ( # noqa: C901
689
687
expression : str ,
690
- operands_old : dict [str , blosc2 .NDArray | blosc2 . LazyExpr ],
691
- operands_new : dict [str , blosc2 .NDArray | blosc2 . LazyExpr ],
692
- ) -> tuple [str , dict [str , blosc2 .NDArray ]]:
688
+ operands_old : dict [str , blosc2 .Array ],
689
+ operands_new : dict [str , blosc2 .Array ],
690
+ ) -> tuple [str , dict [str , blosc2 .Array ]]:
693
691
"""
694
692
Given an expression in string form, return its operands.
695
693
@@ -2029,7 +2027,7 @@ def chunked_eval( # noqa: C901
2029
2027
_getitem: bool, optional
2030
2028
Indicates whether the expression is being evaluated for a getitem operation.
2031
2029
Default is False.
2032
- _output: NDArray or np.ndarray , optional
2030
+ _output: blosc2.Array , optional
2033
2031
The output array to store the result.
2034
2032
_ne_args: dict, optional
2035
2033
Additional arguments to be passed to `numexpr.evaluate()` function.
@@ -3252,7 +3250,7 @@ def info(self):
3252
3250
def info_items (self ):
3253
3251
inputs = {}
3254
3252
for key , value in self .inputs_dict .items ():
3255
- if isinstance (value , np . ndarray | blosc2 .NDArray | blosc2 . C2Array ):
3253
+ if isinstance (value , blosc2 .Array ):
3256
3254
inputs [key ] = f"<{ value .__class__ .__name__ } > { value .shape } { value .dtype } "
3257
3255
else :
3258
3256
inputs [key ] = str (value )
@@ -3378,7 +3376,7 @@ def save(self, **kwargs):
3378
3376
3379
3377
def lazyudf (
3380
3378
func : Callable [[tuple , np .ndarray , tuple [int ]], None ],
3381
- inputs : tuple | list | None ,
3379
+ inputs : Sequence [ Any ] | None ,
3382
3380
dtype : np .dtype ,
3383
3381
shape : tuple | list | None = None ,
3384
3382
chunked_eval : bool = True ,
@@ -3396,11 +3394,11 @@ def lazyudf(
3396
3394
in :paramref:`inputs`.
3397
3395
- `output`: The buffer to be filled as a multidimensional numpy.ndarray.
3398
3396
- `offset`: The multidimensional offset corresponding to the start of the block being computed.
3399
- inputs: tuple or list or None
3400
- The sequence of inputs. Supported inputs are:
3401
- NumPy.ndarray, :ref:`NDArray`, :ref:`NDField`, :ref:`C2Array`.
3402
- Any other object is supported too, and will be passed as is to the user-defined function.
3403
- If not needed, this can be empty, but `shape` must be provided.
3397
+ inputs: Sequence[Any] or None
3398
+ The sequence of inputs. Besides objects compliant with the blosc2.Array protocol,
3399
+ any other object is supported too, and it will be passed as-is to the
3400
+ user-defined function. If not needed, this can be empty, but `shape` must
3401
+ be provided.
3404
3402
dtype: np.dtype
3405
3403
The resulting ndarray dtype in NumPy format.
3406
3404
shape: tuple, optional
@@ -3482,9 +3480,9 @@ def seek_operands(names, local_dict=None, global_dict=None, _frame_depth: int =
3482
3480
3483
3481
3484
3482
def lazyexpr (
3485
- expression : str | bytes | LazyExpr | blosc2 .NDArray ,
3483
+ expression : str | bytes | LazyArray | blosc2 .NDArray ,
3486
3484
operands : dict | None = None ,
3487
- out : blosc2 .NDArray | np . ndarray = None ,
3485
+ out : blosc2 .Array = None ,
3488
3486
where : tuple | list | None = None ,
3489
3487
local_dict : dict | None = None ,
3490
3488
global_dict : dict | None = None ,
@@ -3496,15 +3494,15 @@ def lazyexpr(
3496
3494
3497
3495
Parameters
3498
3496
----------
3499
- expression: str or bytes or LazyExpr
3500
- The expression to evaluate. This can be any valid expression that can be
3501
- ingested by numexpr . If a LazyExpr is passed, the expression will be
3497
+ expression: str or bytes or LazyExpr or NDArray
3498
+ The expression to evaluate. This can be any valid expression that numexpr
3499
+ can ingest . If a LazyExpr is passed, the expression will be
3502
3500
updated with the new operands.
3503
- operands: dict
3504
- The dictionary with operands. Supported values are NumPy.ndarray ,
3505
- Python scalars, :ref:`NDArray`, :ref:`NDField` or :ref:`C2Array` instances .
3501
+ operands: dict[blosc2.Array], optional
3502
+ The dictionary with operands. Supported values are Python scalars ,
3503
+ or any instance that is blosc2.Array compliant .
3506
3504
If None, the operands will be seeked in the local and global dictionaries.
3507
- out: NDArray or np.ndarray , optional
3505
+ out: blosc2.Array , optional
3508
3506
The output array where the result will be stored. If not provided,
3509
3507
a new NumPy array will be created and returned.
3510
3508
where: tuple, list, optional
@@ -3633,9 +3631,9 @@ def evaluate(
3633
3631
ex : str ,
3634
3632
local_dict : dict | None = None ,
3635
3633
global_dict : dict | None = None ,
3636
- out : np . ndarray | blosc2 .NDArray = None ,
3634
+ out : blosc2 .Array = None ,
3637
3635
** kwargs : Any ,
3638
- ) -> np . ndarray | blosc2 .NDArray :
3636
+ ) -> blosc2 .Array :
3639
3637
"""
3640
3638
Evaluate a string expression using the Blosc2 compute engine.
3641
3639
@@ -3659,15 +3657,15 @@ def evaluate(
3659
3657
global_dict: dict, optional
3660
3658
The global dictionary to use when looking for operands in the expression.
3661
3659
If not provided, the global dictionary of the caller will be used.
3662
- out: NDArray or np.ndarray , optional
3660
+ out: blosc2.Array , optional
3663
3661
The output array where the result will be stored. If not provided,
3664
3662
a new NumPy array will be created and returned.
3665
3663
kwargs: Any, optional
3666
3664
Additional arguments to be passed to `numexpr.evaluate()` function.
3667
3665
3668
3666
Returns
3669
3667
-------
3670
- out: NumPy or NDArray
3668
+ out: blosc2.Array
3671
3669
The result of the expression evaluation. If out is provided, the result
3672
3670
will be stored in out and returned at the same time.
3673
3671
0 commit comments