Skip to content

Commit

Permalink
Treat arctan2 as a binary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Oct 17, 2024
1 parent b2f8f74 commit c45ce44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/blosc2/lazyexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,12 @@ def _parse_expression(expression):
right = stack.pop()
op = stack.pop()
left = stack.pop()
stack.append((left, op, right))
if left == "arctan2":
# Special case for arctan2. We will treat it as regular binary operation.
# Also, sometimes the operand ends with a comma, so we strip it.
stack.append((op.strip(","), left, right))
else:
stack.append((left, op, right))
elif char in "() ":
if operand:
stack.append(operand)
Expand Down Expand Up @@ -1500,7 +1505,7 @@ def __init__(self, new_op):
self.expression = f"{op}(o0, {value2})"
elif np.isscalar(value1):
self.operands = {"o0": value2}
self.expression = f"{op}({value1} , o0)"
self.expression = f"{op}({value1}, o0)"
else:
self.operands = {"o0": value1, "o1": value2}
self.expression = f"{op}(o0, o1)"
Expand Down Expand Up @@ -1950,7 +1955,6 @@ def save(self, **kwargs):
)
if value.schunk.urlpath is None:
raise ValueError("To save a LazyArray, all operands must be stored on disk/network")
raise ValueError("To save a LazyArray, all operands must be stored on disk/network")
operands[key] = value.schunk.urlpath
# Check that the expression is valid
# ne.validate(self.expression, locals=operands)
Expand Down

0 comments on commit c45ce44

Please sign in to comment.