Skip to content

Commit

Permalink
Apply verbosity=0 to Pkg statements
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Feb 2, 2022
1 parent 42cb8bb commit e0e2933
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,18 @@ def _run(self, X, y, weights, variable_names):
_, term_width = subprocess.check_output(["stty", "size"]).split()

if not already_ran:
from julia import Pkg
Main.eval("using Pkg")
io = "devnull" if self.params["verbosity"] == 0 else "stderr"

Pkg.activate(f"{_escape_filename(self.julia_project)}")
Main.eval(
f'Pkg.activate("{_escape_filename(self.julia_project)}", io={io})'
)
try:
if update:
Pkg.resolve()
Pkg.instantiate()
Main.eval(f"Pkg.resolve(io={io})")
Main.eval(f"Pkg.instantiate(io={io})")
else:
Pkg.instantiate()
Main.eval(f"Pkg.instantiate(io={io})")
except RuntimeError as e:
raise ImportError(import_error_string(self.julia_project)) from e
Main.eval("using SymbolicRegression")
Expand Down
3 changes: 2 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ def test_multiprocessing(self):
print(model.equations)
self.assertLessEqual(model.equations.iloc[-1]["loss"], 1e-4)

def test_multioutput_custom_operator(self):
def test_multioutput_custom_operator_quiet(self):
y = self.X[:, [0, 1]] ** 2
model = PySRRegressor(
unary_operators=["sq(x) = x^2"],
extra_sympy_mappings={"sq": lambda x: x ** 2},
binary_operators=["plus"],
verbosity=0,
**self.default_test_kwargs,
procs=0,
)
Expand Down

0 comments on commit e0e2933

Please sign in to comment.