Skip to content

Commit

Permalink
Added "round" operator in the Sympy mappings (#474)
Browse files Browse the repository at this point in the history
Enabling a workaround to avoid the following type error:

`raise TypeError("Cannot round symbolic expression")`

while using `round` as a unary operator.

This issue was raised in #269 the the PR contains the exact solution put forth in the subsequent discussion
  • Loading branch information
tanweer-mahdi committed Nov 27, 2023
1 parent 2e51033 commit ce15648
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pysr/export_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"gamma": sympy.gamma,
"max": lambda x, y: sympy.Piecewise((y, x < y), (x, True)),
"min": lambda x, y: sympy.Piecewise((x, x < y), (y, True)),
"round": lambda x: sympy.ceiling(x - 0.5),
}


Expand Down

0 comments on commit ce15648

Please sign in to comment.