Skip to content

Expand the number of expressions that can be saved #508

@FrancescAlted

Description

@FrancescAlted

Now, expressions can be saved only if they consist of a complex expression, but not a simple one (e.g. a single function). The next script shows the issue:

import blosc2
import numpy as np

N = 10
shape_a = (N, N, N)
matrix_numpy = np.ones(N ** 3).reshape(shape_a)
matrix_a = blosc2.asarray(matrix_numpy, urlpath="a.b2nd", mode="w")
matrix_b = blosc2.asarray(matrix_numpy, urlpath="b.b2nd", mode="w")

# Create a lazy expression object
sexpr = "matrix_a.sum() + matrix_b"  # this works
# sexpr = "sum(matrix_a)"  # this does not
# sexpr = "tensordot(matrix_a, matrix_b, axes=((0, 1), (0, 1)))"  # this does not
lexpr=blosc2.lazyexpr(sexpr,
                      operands={"matrix_a": matrix_a, "matrix_b": matrix_b})
lexpr.save("persistent_expr.b2nd")

lexpr2 = blosc2.open("persistent_expr.b2nd", mode="r")
print(lexpr2[:])

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions