Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
aa16a1e
1
Parent(s):
2aa3c41
Add test for multirun
Browse files- pysr/sr.py +1 -1
- test/test.py +9 -1
pysr/sr.py
CHANGED
@@ -322,7 +322,7 @@ def _write_project_file(tmp_dir):
|
|
322 |
SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
|
323 |
|
324 |
[compat]
|
325 |
-
SymbolicRegression = "0.7.
|
326 |
julia = "1.5"
|
327 |
"""
|
328 |
|
|
|
322 |
SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
|
323 |
|
324 |
[compat]
|
325 |
+
SymbolicRegression = "0.7.1"
|
326 |
julia = "1.5"
|
327 |
"""
|
328 |
|
test/test.py
CHANGED
@@ -77,7 +77,7 @@ class TestPipeline(unittest.TestCase):
|
|
77 |
model.predict(self.X)[:, 1], self.X[:, 1] ** 2, decimal=4
|
78 |
)
|
79 |
|
80 |
-
def
|
81 |
X = np.random.randn(100, 1)
|
82 |
y = X[:, 0] + 3.0
|
83 |
regressor = PySRRegressor(
|
@@ -94,6 +94,14 @@ class TestPipeline(unittest.TestCase):
|
|
94 |
self.assertLessEqual(regressor.equations.iloc[-1]["loss"], 1e-4)
|
95 |
np.testing.assert_almost_equal(regressor.predict(X), y, decimal=1)
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# Tweak model selection:
|
98 |
regressor.set_params(model_selection="best")
|
99 |
self.assertEqual(regressor.get_params()["model_selection"], "best")
|
|
|
77 |
model.predict(self.X)[:, 1], self.X[:, 1] ** 2, decimal=4
|
78 |
)
|
79 |
|
80 |
+
def test_empty_operators_single_input_multirun(self):
|
81 |
X = np.random.randn(100, 1)
|
82 |
y = X[:, 0] + 3.0
|
83 |
regressor = PySRRegressor(
|
|
|
94 |
self.assertLessEqual(regressor.equations.iloc[-1]["loss"], 1e-4)
|
95 |
np.testing.assert_almost_equal(regressor.predict(X), y, decimal=1)
|
96 |
|
97 |
+
# Test if repeated fit works:
|
98 |
+
regressor.niterations = 0
|
99 |
+
regressor.fit(X, y)
|
100 |
+
|
101 |
+
self.assertLessEqual(regressor.equations.iloc[-1]["loss"], 1e-4)
|
102 |
+
np.testing.assert_almost_equal(regressor.predict(X), y, decimal=1)
|
103 |
+
|
104 |
+
|
105 |
# Tweak model selection:
|
106 |
regressor.set_params(model_selection="best")
|
107 |
self.assertEqual(regressor.get_params()["model_selection"], "best")
|