File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 11"""PEtab math to sympy conversion."""
22
3+ import numpy as np
34import sympy as sp
45from antlr4 import CommonTokenStream , InputStream
56from antlr4 .error .ErrorListener import ErrorListener
@@ -25,9 +26,9 @@ def sympify_petab(expr: str | int | float) -> sp.Expr | sp.Basic:
2526 The sympy expression corresponding to `expr`.
2627 Boolean values are converted to numeric values.
2728 """
28- if isinstance (expr , int ):
29+ if isinstance (expr , int ) or isinstance ( expr , np . integer ) :
2930 return sp .Integer (expr )
30- if isinstance (expr , float ):
31+ if isinstance (expr , float ) or isinstance ( expr , np . floating ) :
3132 return sp .Float (expr )
3233
3334 # Set error listeners
Original file line number Diff line number Diff line change 1111from petab .math import sympify_petab
1212
1313
14+ def test_sympify_numpy ():
15+ assert sympify_petab (np .float64 (1.0 )) == sp .Float (1.0 )
16+
17+
1418def test_parse_simple ():
1519 """Test simple numeric expressions."""
1620 assert float (sympify_petab ("1 + 2" )) == 3
You can’t perform that action at this time.
0 commit comments