Skip to content

Commit 7701310

Browse files
committed
Allow control of file loading verbosity
1 parent c52d151 commit 7701310

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pysr/sr.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ def from_file(
903903
feature_names_in=None,
904904
selection_mask=None,
905905
nout=1,
906+
verbosity=1,
906907
**pysr_kwargs,
907908
):
908909
"""
@@ -932,6 +933,8 @@ def from_file(
932933
Number of outputs of the model.
933934
Not needed if loading from a pickle file.
934935
Default is `1`.
936+
verbosity : int
937+
What verbosity level to use. 0 means minimal print statements.
935938
**pysr_kwargs : dict
936939
Any other keyword arguments to initialize the PySRRegressor object.
937940
These will overwrite those stored in the pickle file.
@@ -946,9 +949,11 @@ def from_file(
946949
pkl_filename = _csv_filename_to_pkl_filename(equation_file)
947950

948951
# Try to load model from <equation_file>.pkl
949-
print(f"Checking if {pkl_filename} exists...")
952+
if verbosity > 0:
953+
print(f"Checking if {pkl_filename} exists...")
950954
if os.path.exists(pkl_filename):
951-
print(f"Loading model from {pkl_filename}")
955+
if verbosity > 0:
956+
print(f"Loading model from {pkl_filename}")
952957
assert binary_operators is None
953958
assert unary_operators is None
954959
assert n_features_in is None
@@ -968,10 +973,11 @@ def from_file(
968973
return model
969974

970975
# Else, we re-create it.
971-
print(
972-
f"{pkl_filename} does not exist, "
973-
"so we must create the model from scratch."
974-
)
976+
if verbosity > 0:
977+
print(
978+
f"{pkl_filename} does not exist, "
979+
"so we must create the model from scratch."
980+
)
975981
assert binary_operators is not None or unary_operators is not None
976982
assert n_features_in is not None
977983

0 commit comments

Comments
 (0)