Skip to content

Commit e8478b2

Browse files
committed
Fix from_file when loading pkl + csv from subdir
1 parent 8d810c2 commit e8478b2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pysr/sr.py

+5
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ def from_file(
878878
assert n_features_in is None
879879
with open(pkl_filename, "rb") as f:
880880
model = pkl.load(f)
881+
# Change equation_file_ to be in the same dir as the pickle file
882+
base_dir = os.path.dirname(pkl_filename)
883+
base_equation_file = os.path.basename(model.equation_file_)
884+
model.equation_file_ = os.path.join(base_dir, base_equation_file)
885+
881886
# Update any parameters if necessary, such as
882887
# extra_sympy_mappings:
883888
model.set_params(**pysr_kwargs)

0 commit comments

Comments
 (0)