Skip to content

Commit 4d30bf4

Browse files
committed
Merge branch 'main' of github.com:Blosc/python-blosc2
2 parents 7fd017e + 3bb175e commit 4d30bf4

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/blosc2/lazyexpr.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,12 @@ def __init__(self, new_op): # noqa: C901
23412341
if value2 is None:
23422342
if isinstance(value1, LazyExpr):
23432343
self.expression = value1.expression if op is None else f"{op}({value1.expression})"
2344+
# handle constructors which can give empty operands
2345+
self._dtype = (
2346+
value1.dtype
2347+
if op is None
2348+
else _numpy_eval_expr(f"{op}(o0)", {"o0": value1}, prefer_blosc=False).dtype
2349+
)
23442350
self.operands = value1.operands
23452351
else:
23462352
if np.isscalar(value1):

tests/ndarray/test_lazyexpr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,10 @@ def test_str_constructors():
13651365
a = blosc2.lazyexpr(f"b + linspace(0, 100, {np.prod(shape)}, shape={shape}, chunks={chunks})")
13661366
assert a.shape == np.broadcast_shapes(shape, b.shape)
13671367

1368+
# failed before dtype handling improved
1369+
x = blosc2.lazyexpr("linspace(-1, 1, 10, shape=(1, 10))")
1370+
lexpr = blosc2.sin(blosc2.sqrt(x**2))
1371+
13681372

13691373
@pytest.mark.parametrize(
13701374
"obj",

0 commit comments

Comments
 (0)