MilesCranmer commited on
Commit
8e088d6
1 Parent(s): 02c9687

Run all tests with multithreading set to True

Browse files
Files changed (2) hide show
  1. pysr/sr.py +6 -2
  2. test/test.py +2 -3
pysr/sr.py CHANGED
@@ -133,7 +133,7 @@ def pysr(
133
  denoise=False,
134
  Xresampled=None,
135
  precision=32,
136
- multithreading=True,
137
  ):
138
  """Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
139
  Note: most default parameters have been tuned over several example
@@ -254,7 +254,7 @@ def pysr(
254
  :type denoise: bool
255
  :param precision: What precision to use for the data. By default this is 32 (float32), but you can select 64 or 16 as well.
256
  :type precision: int
257
- :param multithreading: Use multithreading instead of distributed
258
  :type multithreading: bool
259
  :returns: Results dataframe, giving complexity, MSE, and equations (as strings), as well as functional forms. If list, each element corresponds to a dataframe of equations for each output.
260
  :type: pd.DataFrame/list
@@ -269,6 +269,10 @@ def pysr(
269
  variable_names = []
270
  if constraints is None:
271
  constraints = {}
 
 
 
 
272
 
273
  buffer_available = "buffer" in sys.stdout.__dir__()
274
 
 
133
  denoise=False,
134
  Xresampled=None,
135
  precision=32,
136
+ multithreading=None,
137
  ):
138
  """Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
139
  Note: most default parameters have been tuned over several example
 
254
  :type denoise: bool
255
  :param precision: What precision to use for the data. By default this is 32 (float32), but you can select 64 or 16 as well.
256
  :type precision: int
257
+ :param multithreading: Use multithreading instead of distributed backend. Default is yes. Using procs=0 will turn off both.
258
  :type multithreading: bool
259
  :returns: Results dataframe, giving complexity, MSE, and equations (as strings), as well as functional forms. If list, each element corresponds to a dataframe of equations for each output.
260
  :type: pd.DataFrame/list
 
269
  variable_names = []
270
  if constraints is None:
271
  constraints = {}
272
+ if multithreading is None:
273
+ # Default is multithreading=True, unless explicitly set,
274
+ # or procs is set to 0 (serial mode).
275
+ multithreading = procs != 0
276
 
277
  buffer_available = "buffer" in sys.stdout.__dir__()
278
 
test/test.py CHANGED
@@ -13,7 +13,6 @@ class TestPipeline(unittest.TestCase):
13
  self.default_test_kwargs = dict(
14
  niterations=10,
15
  populations=4,
16
- multithreading=False,
17
  user_input=False,
18
  annealing=True,
19
  useFrequency=False,
@@ -27,10 +26,10 @@ class TestPipeline(unittest.TestCase):
27
  print(equations)
28
  self.assertLessEqual(equations.iloc[-1]["MSE"], 1e-4)
29
 
30
- def test_multithreading(self):
31
  y = self.X[:, 0]
32
  equations = pysr(
33
- self.X, y, **self.default_test_kwargs, procs=2, multithreading=True
34
  )
35
  print(equations)
36
  self.assertLessEqual(equations.iloc[-1]["MSE"], 1e-4)
 
13
  self.default_test_kwargs = dict(
14
  niterations=10,
15
  populations=4,
 
16
  user_input=False,
17
  annealing=True,
18
  useFrequency=False,
 
26
  print(equations)
27
  self.assertLessEqual(equations.iloc[-1]["MSE"], 1e-4)
28
 
29
+ def test_multiprocessing(self):
30
  y = self.X[:, 0]
31
  equations = pysr(
32
+ self.X, y, **self.default_test_kwargs, procs=2, multithreading=False
33
  )
34
  print(equations)
35
  self.assertLessEqual(equations.iloc[-1]["MSE"], 1e-4)