Skip to content

Commit

Permalink
Do not expose the schunk attribute on LazyExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Oct 19, 2024
1 parent a5ab4ac commit 93f962f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/blosc2/lazyexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,6 @@ def _open_lazyarray(array):
if isinstance(expr, blosc2.LazyExpr):
# Make the array info available for the user (only available when opened from disk)
expr.array = array
expr.schunk = array.schunk
elif isinstance(expr, np.ndarray):
# The expression was evaluated immediately
expr = blosc2.asarray(expr)
Expand Down
5 changes: 5 additions & 0 deletions tests/ndarray/test_lazyexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ def test_save():
np.testing.assert_allclose(res[:], nres, rtol=tol, atol=tol)

expr = blosc2.open(urlpath_save)
# After opening, check that a lazy expression does have an array attribute,
# but does not have a schunk one. This is by design, and because some packages
# (e.g. Caterva2), might assume that a LazyExpr does not have a schunk attribute.
assert hasattr(expr, "array") is True
assert hasattr(expr, "schunk") is False
# Check the dtype (should be upcasted to float64)
assert expr.array.dtype == np.float64
res = expr.compute()
Expand Down

0 comments on commit 93f962f

Please sign in to comment.