MilesCranmer commited on
Commit
af8d4da
1 Parent(s): 34d37c0

Add test for high precision output

Browse files
Files changed (1) hide show
  1. test/test.py +15 -0
test/test.py CHANGED
@@ -82,6 +82,21 @@ class TestPipeline(unittest.TestCase):
82
  print(model.equations_)
83
  self.assertLessEqual(model.equations_.iloc[-1]["loss"], 1e-4)
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  def test_multioutput_custom_operator_quiet_custom_complexity(self):
86
  y = self.X[:, [0, 1]] ** 2
87
  model = PySRRegressor(
 
82
  print(model.equations_)
83
  self.assertLessEqual(model.equations_.iloc[-1]["loss"], 1e-4)
84
 
85
+ def test_high_precision_search(self):
86
+ y = 1.23456789 * self.X[:, 0]
87
+ model = PySRRegressor(
88
+ **self.default_test_kwargs,
89
+ early_stop_condition="stop_if(loss, complexity) = loss < 1e-25 && complexity == 3",
90
+ precision=64,
91
+ )
92
+ model.fit(self.X, y)
93
+ self.assertIn("1.23456789", model.equations_.iloc[-1]["equation"])
94
+
95
+ from pysr.sr import Main
96
+ # We should have that the model state is now a Float64 hof:
97
+ Main.test_state = model.raw_julia_state_
98
+ self.assertTrue(Main.eval("typeof(test_state[2]).parameters[1] == Float64"))
99
+
100
  def test_multioutput_custom_operator_quiet_custom_complexity(self):
101
  y = self.X[:, [0, 1]] ** 2
102
  model = PySRRegressor(