Skip to content

Commit 3e80a9b

Browse files
committed
Update
1 parent 451acef commit 3e80a9b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

sr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,9 @@ def fit(self, X, y, variable_names = []):
15921592
binary_operators, self.maxfev, self.epsloss, self.fixed_cst_value,
15931593
self.discrete_param_values, self.brute_force_limit)
15941594
opt_exprs[str(exprs[-1].opt_expr)] = exprs[-1].loss
1595+
1596+
if (self.verbose):
1597+
print("Extra start symbolic expression", exprs[-1].sym_expr, exprs[-1].opt_expr, exprs[-1].loss)
15951598

15961599
if (self.callback):
15971600
self.callback(exprs[-1], y)

tests/test_ode-strogatz.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def file_data(url):
8282
y = np.array(y, dtype = np.float64)
8383

8484
return label, x, y
85-
"""
85+
8686
def test_d_bacres1():
8787
label, x, y = file_data("https://raw.githubusercontent.com/lacava/ode-strogatz/master/d_bacres1.txt")
8888

@@ -102,8 +102,6 @@ def test_d_bacres1():
102102
binary_operators = {"*": (operator.mul, operator.mul),
103103
"+": (operator.add, operator.add),
104104
"/": (operator.truediv, operator.truediv)},
105-
#extra_start_sym_expr = [sympy.sympify("_1235/(_1228*x**2 + _1230*x + _1233) + _1239*x/(_1236*x**2 + _1237*x + _1238) + _1244*y/(_1240*x**2 + _1241*x + _1242) + _1248*x*y/(_1245*x**2 + _1246*x + _1247) + _1251")],
106-
discrete_param_values = ["(-2, 2)", 20],
107105
operator_depth = {"/": 1, "*": 2, "+": 2},
108106
#callback = callback,
109107
#monothread = True,
@@ -113,9 +111,8 @@ def test_d_bacres1():
113111
model.fit([x, y], label, ["x", "y"])
114112

115113
assert(len(model.bestExpressions) == 1)
116-
assert(sympy.expand(model.bestExpressions[0][0]) == sympy.expand(sympy.simplify(sympy.sympify("20 -x - (2*x*y/(2+1*x**2))"))))
117-
"""
118-
"""
114+
assert(sr.expr_eq(sympy.expand(model.bestExpressions[0][0]), sympy.expand(sympy.simplify(sympy.sympify("20 -x - (*x*y/(1+0.5*x**2))")))))
115+
119116
def test_d_bacres2():
120117
label, x, y = file_data("https://raw.githubusercontent.com/lacava/ode-strogatz/master/d_bacres2.txt")
121118

@@ -135,7 +132,6 @@ def test_d_bacres2():
135132
binary_operators = {"*": (operator.mul, operator.mul),
136133
"+": (operator.add, operator.add),
137134
"/": (operator.truediv, operator.truediv)},
138-
discrete_param_values = ["(-2, 2)", 10],
139135
operator_depth = {"/": 1, "*": 2, "+": 2},
140136
#callback = callback,
141137
#monothread = True,
@@ -146,7 +142,7 @@ def test_d_bacres2():
146142

147143
assert(len(model.bestExpressions) == 1)
148144
assert(sr.expr_eq(sympy.expand(model.bestExpressions[0][0]), sympy.expand(sympy.simplify(sympy.sympify("10 - (x*y/(1+0.5*x**2))")))))
149-
"""
145+
150146
def test_d_barmag1():
151147
label, x, y = file_data("https://raw.githubusercontent.com/lacava/ode-strogatz/master/d_barmag1.txt")
152148

0 commit comments

Comments
 (0)