MilesCranmer commited on
Commit
15105ad
1 Parent(s): 27fac96

Add error for deterministic setting

Browse files
Files changed (1) hide show
  1. pysr/sr.py +11 -0
pysr/sr.py CHANGED
@@ -965,6 +965,17 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
965
  elif self.maxsize < 7:
966
  raise ValueError("PySR requires a maxsize of at least 7")
967
 
 
 
 
 
 
 
 
 
 
 
 
968
  # NotImplementedError - Values that could be supported at a later time
969
  if self.optimizer_algorithm not in VALID_OPTIMIZER_ALGORITHMS:
970
  raise NotImplementedError(
 
965
  elif self.maxsize < 7:
966
  raise ValueError("PySR requires a maxsize of at least 7")
967
 
968
+ if self.deterministic:
969
+ if not (
970
+ self.multithreading in [False, None]
971
+ and self.procs == 0
972
+ and self.random_state != None
973
+ ):
974
+ raise ValueError(
975
+ "To ensure deterministic searches, you must set `random_state` to a seed, "
976
+ "`multithreading` to `False` or `None`, and `procs` to `0`."
977
+ )
978
+
979
  # NotImplementedError - Values that could be supported at a later time
980
  if self.optimizer_algorithm not in VALID_OPTIMIZER_ALGORITHMS:
981
  raise NotImplementedError(