MilesCranmer commited on
Commit
e0e2933
1 Parent(s): 42cb8bb

Apply verbosity=0 to Pkg statements

Browse files
Files changed (2) hide show
  1. pysr/sr.py +8 -5
  2. test/test.py +2 -1
pysr/sr.py CHANGED
@@ -1039,15 +1039,18 @@ class PySRRegressor(BaseEstimator, RegressorMixin):
1039
  _, term_width = subprocess.check_output(["stty", "size"]).split()
1040
 
1041
  if not already_ran:
1042
- from julia import Pkg
 
1043
 
1044
- Pkg.activate(f"{_escape_filename(self.julia_project)}")
 
 
1045
  try:
1046
  if update:
1047
- Pkg.resolve()
1048
- Pkg.instantiate()
1049
  else:
1050
- Pkg.instantiate()
1051
  except RuntimeError as e:
1052
  raise ImportError(import_error_string(self.julia_project)) from e
1053
  Main.eval("using SymbolicRegression")
 
1039
  _, term_width = subprocess.check_output(["stty", "size"]).split()
1040
 
1041
  if not already_ran:
1042
+ Main.eval("using Pkg")
1043
+ io = "devnull" if self.params["verbosity"] == 0 else "stderr"
1044
 
1045
+ Main.eval(
1046
+ f'Pkg.activate("{_escape_filename(self.julia_project)}", io={io})'
1047
+ )
1048
  try:
1049
  if update:
1050
+ Main.eval(f"Pkg.resolve(io={io})")
1051
+ Main.eval(f"Pkg.instantiate(io={io})")
1052
  else:
1053
+ Main.eval(f"Pkg.instantiate(io={io})")
1054
  except RuntimeError as e:
1055
  raise ImportError(import_error_string(self.julia_project)) from e
1056
  Main.eval("using SymbolicRegression")
test/test.py CHANGED
@@ -34,12 +34,13 @@ class TestPipeline(unittest.TestCase):
34
  print(model.equations)
35
  self.assertLessEqual(model.equations.iloc[-1]["loss"], 1e-4)
36
 
37
- def test_multioutput_custom_operator(self):
38
  y = self.X[:, [0, 1]] ** 2
39
  model = PySRRegressor(
40
  unary_operators=["sq(x) = x^2"],
41
  extra_sympy_mappings={"sq": lambda x: x ** 2},
42
  binary_operators=["plus"],
 
43
  **self.default_test_kwargs,
44
  procs=0,
45
  )
 
34
  print(model.equations)
35
  self.assertLessEqual(model.equations.iloc[-1]["loss"], 1e-4)
36
 
37
+ def test_multioutput_custom_operator_quiet(self):
38
  y = self.X[:, [0, 1]] ** 2
39
  model = PySRRegressor(
40
  unary_operators=["sq(x) = x^2"],
41
  extra_sympy_mappings={"sq": lambda x: x ** 2},
42
  binary_operators=["plus"],
43
+ verbosity=0,
44
  **self.default_test_kwargs,
45
  procs=0,
46
  )