|
37 | 37 | import blosc2 |
38 | 38 | from blosc2 import compute_chunks_blocks |
39 | 39 | from blosc2.info import InfoReporter |
40 | | -from blosc2.ndarray import _check_allowed_dtypes, get_chunks_idx, is_inside_new_expr |
| 40 | +from blosc2.ndarray import _check_allowed_dtypes, get_chunks_idx, is_inside_new_expr, process_key |
41 | 41 |
|
42 | 42 | if not blosc2.IS_WASM: |
43 | 43 | import numexpr |
@@ -2434,23 +2434,24 @@ def _compute_expr(self, item, kwargs): # noqa: C901 |
2434 | 2434 | _globals = get_expr_globals(self.expression) |
2435 | 2435 | lazy_expr = eval(self.expression, _globals, self.operands) |
2436 | 2436 | if not isinstance(lazy_expr, blosc2.LazyExpr): |
| 2437 | + key, _ = process_key(item, self.shape) |
2437 | 2438 | # An immediate evaluation happened (e.g. all operands are numpy arrays) |
2438 | 2439 | if hasattr(self, "_where_args"): |
2439 | 2440 | # We need to apply the where() operation |
2440 | 2441 | if len(self._where_args) == 1: |
2441 | 2442 | # We have a single argument |
2442 | 2443 | where_x = self._where_args["_where_x"] |
2443 | | - return (where_x[:][lazy_expr])[item] |
| 2444 | + return (where_x[:][lazy_expr])[key] |
2444 | 2445 | if len(self._where_args) == 2: |
2445 | 2446 | # We have two arguments |
2446 | 2447 | where_x = self._where_args["_where_x"] |
2447 | 2448 | where_y = self._where_args["_where_y"] |
2448 | | - return np.where(lazy_expr, where_x, where_y)[item] |
| 2449 | + return np.where(lazy_expr, where_x, where_y)[key] |
2449 | 2450 | if hasattr(self, "_output"): |
2450 | 2451 | # This is not exactly optimized, but it works for now |
2451 | | - self._output[:] = lazy_expr[item] |
| 2452 | + self._output[:] = lazy_expr[key] |
2452 | 2453 | return self._output |
2453 | | - return lazy_expr[item] |
| 2454 | + return lazy_expr[key] |
2454 | 2455 |
|
2455 | 2456 | return chunked_eval(lazy_expr.expression, lazy_expr.operands, item, **kwargs) |
2456 | 2457 |
|
|
0 commit comments