MilesCranmer commited on
Commit
21a0846
1 Parent(s): 494a3ba

Only give warning if raw_julia_state_ already set

Browse files
Files changed (1) hide show
  1. pysr/sr.py +6 -5
pysr/sr.py CHANGED
@@ -857,12 +857,13 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
857
  to be serialized. Note: Jax and Torch format equations are also removed
858
  from the pickled instance.
859
  """
860
- warnings.warn(
861
- "raw_julia_state_ cannot be pickled and will be removed from the "
862
- "serialized instance. This will prevent a `warm_start` fit of any "
863
- "model that is deserialized via `pickle.loads()`."
864
- )
865
  state = self.__dict__
 
 
 
 
 
 
866
  pickled_state = {
867
  key: None if key == "raw_julia_state_" else value
868
  for key, value in state.items()
 
857
  to be serialized. Note: Jax and Torch format equations are also removed
858
  from the pickled instance.
859
  """
 
 
 
 
 
860
  state = self.__dict__
861
+ if "raw_julia_state_" in state:
862
+ warnings.warn(
863
+ "raw_julia_state_ cannot be pickled and will be removed from the "
864
+ "serialized instance. This will prevent a `warm_start` fit of any "
865
+ "model that is deserialized via `pickle.load()`."
866
+ )
867
  pickled_state = {
868
  key: None if key == "raw_julia_state_" else value
869
  for key, value in state.items()