55# This source code is licensed under a BSD-style license (found in the
66# LICENSE file in the root directory of this source tree)
77#######################################################################
8+ import warnings
9+
810import ndindex
911import numexpr as ne
1012import numpy as np
@@ -218,9 +220,39 @@ def __rpow__(self, value):
218220 def __ipow__ (self , value ):
219221 return self .update_expr (new_op = (self , "**" , value ))
220222
223+ def evaluate (self , item = None , ** kwargs ) -> blosc2 .NDArray :
224+ """Evaluate the lazy expression in self.
221225
226+ Parameters
227+ ----------
228+ item: slice, list of slices, optional
229+ If not None, only the chunks that intersect with the slices
230+ in items will be evaluated.
231+ kwargs: dict, optional
232+ Keyword arguments that are supported by the :func:`empty` constructor.
222233
223- def evaluate (self , item = None , ** kwargs ) -> blosc2 .NDArray :
234+ Returns
235+ -------
236+ :ref:`NDArray`
237+ The output array.
238+
239+ Note
240+ ----
241+
242+ This is a deprecated method. Use the new evaluation engine in Python-Blosc2 3.x.
243+ """
244+ warnings .warn (
245+ "The `evaluate` method is deprecated as of Python-Blosc2 2.7.0 and is"
246+ " actually removed in Python-Blosc2 3.x series. Use `LazyExpr.eval()` instead. "
247+ "If you are interested in computing expressions involving NDArray instances, "
248+ "please use the new, much improved, evaluation engine in Python-Blosc2 3.x series. "
249+ "For more information, please check the documentation at: <New 3.x documentation URL>" ,
250+ stacklevel = 2 ,
251+ category = DeprecationWarning ,
252+ )
253+ return self .eval (item = item , ** kwargs )
254+
255+ def eval (self , item = None , ** kwargs ) -> blosc2 .NDArray :
224256 """Evaluate the lazy expression in self.
225257
226258 Parameters
@@ -235,6 +267,11 @@ def evaluate(self, item=None, **kwargs) -> blosc2.NDArray:
235267 -------
236268 :ref:`NDArray`
237269 The output array.
270+
271+ Note
272+ ----
273+
274+ This is a deprecated method. Use the new evaluation engine in Python-Blosc2 3.x.
238275 """
239276 shape , dtype , equal_chunks , equal_blocks = validate_inputs (self .operands )
240277 nelem = np .prod (shape )
@@ -249,7 +286,7 @@ def evaluate(self, item=None, **kwargs) -> blosc2.NDArray:
249286 return out
250287
251288 def __getitem__ (self , item ):
252- ndarray = self .evaluate (item = item )
289+ ndarray = self .eval (item = item )
253290 return ndarray [item ] if item is not None else ndarray [:]
254291
255292 def __str__ (self ):
@@ -475,7 +512,7 @@ def do_slices_intersect(slice1, slice2):
475512 print (f"Elapsed time (numexpr, [:]): { time () - t0 :.3f} s" )
476513 nres = nres [sl ] if sl is not None else nres
477514 t0 = time ()
478- res = expr .evaluate (item = sl )
515+ res = expr .eval (item = sl )
479516 print (f"Elapsed time (evaluate): { time () - t0 :.3f} s" )
480517 res = res [sl ] if sl is not None else res [:]
481518 t0 = time ()
@@ -498,7 +535,7 @@ def do_slices_intersect(slice1, slice2):
498535 print (f"Elapsed time (numexpr, [:]): { time () - t0 :.3f} s" )
499536 nres = nres [sl ] if sl is not None else nres
500537 t0 = time ()
501- res = expr .evaluate (sl )
538+ res = expr .eval (sl )
502539 print (f"Elapsed time (evaluate): { time () - t0 :.3f} s" )
503540 res = res [sl ] if sl is not None else res [:]
504541 t0 = time ()
0 commit comments