Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Merge pull request #57 from MilesCranmer/deepsource-fix-29cea666
Browse files- benchmarks/hyperparamopt.py +2 -2
- pysr/sr.py +6 -6
benchmarks/hyperparamopt.py
CHANGED
@@ -60,7 +60,7 @@ def run_trial(args):
|
|
60 |
"X[:, 0] * np.sin(2*np.pi * (X[:, 1] * X[:, 2] - X[:, 3] / X[:, 4])) + 3.0",
|
61 |
]
|
62 |
|
63 |
-
print(
|
64 |
try:
|
65 |
local_trials = []
|
66 |
for i in range(len(eval_str)):
|
@@ -87,7 +87,7 @@ def run_trial(args):
|
|
87 |
print(f"Test {i} trial {j} with", str(args), f"got {local_trials[-1]}")
|
88 |
|
89 |
except ValueError:
|
90 |
-
print(
|
91 |
return {"status": "ok", "loss": np.inf} # or 'fail' if nan loss
|
92 |
loss = np.average(local_trials)
|
93 |
print(f"Finished with {loss}", str(args))
|
|
|
60 |
"X[:, 0] * np.sin(2*np.pi * (X[:, 1] * X[:, 2] - X[:, 3] / X[:, 4])) + 3.0",
|
61 |
]
|
62 |
|
63 |
+
print("Starting", str(args))
|
64 |
try:
|
65 |
local_trials = []
|
66 |
for i in range(len(eval_str)):
|
|
|
87 |
print(f"Test {i} trial {j} with", str(args), f"got {local_trials[-1]}")
|
88 |
|
89 |
except ValueError:
|
90 |
+
print("Broken", str(args))
|
91 |
return {"status": "ok", "loss": np.inf} # or 'fail' if nan loss
|
92 |
loss = np.average(local_trials)
|
93 |
print(f"Finished with {loss}", str(args))
|
pysr/sr.py
CHANGED
@@ -392,7 +392,7 @@ def pysr(
|
|
392 |
kwargs = {**_set_paths(tempdir), **kwargs}
|
393 |
|
394 |
if temp_equation_file:
|
395 |
-
equation_file = kwargs["tmpdir"] /
|
396 |
elif equation_file is None:
|
397 |
date_time = datetime.now().strftime("%Y-%m-%d_%H%M%S.%f")[:-3]
|
398 |
equation_file = "hall_of_fame_" + date_time + ".csv"
|
@@ -446,12 +446,12 @@ def _set_globals(X, **kwargs):
|
|
446 |
|
447 |
def _final_pysr_process(julia_optimization, runfile_filename, timeout, **kwargs):
|
448 |
command = [
|
449 |
-
|
450 |
f"-O{julia_optimization:d}",
|
451 |
str(runfile_filename),
|
452 |
]
|
453 |
if timeout is not None:
|
454 |
-
command = [
|
455 |
_cmd_runner(command, **kwargs)
|
456 |
|
457 |
|
@@ -515,8 +515,8 @@ def _create_julia_files(
|
|
515 |
print(f'Pkg.activate("{_escape_filename(julia_project)}")', file=f)
|
516 |
if need_install:
|
517 |
print(f"Pkg.instantiate()", file=f)
|
518 |
-
print(
|
519 |
-
print(
|
520 |
elif update:
|
521 |
print(f"Pkg.update()", file=f)
|
522 |
print(f"using SymbolicRegression", file=f)
|
@@ -798,7 +798,7 @@ def _set_paths(tempdir):
|
|
798 |
tmpdir = Path(tempfile.mkdtemp(dir=tempdir))
|
799 |
hyperparam_filename = tmpdir / f"hyperparams.jl"
|
800 |
dataset_filename = tmpdir / f"dataset.jl"
|
801 |
-
runfile_filename = tmpdir /
|
802 |
X_filename = tmpdir / "X.csv"
|
803 |
y_filename = tmpdir / "y.csv"
|
804 |
weights_filename = tmpdir / "weights.csv"
|
|
|
392 |
kwargs = {**_set_paths(tempdir), **kwargs}
|
393 |
|
394 |
if temp_equation_file:
|
395 |
+
equation_file = kwargs["tmpdir"] / "hall_of_fame.csv"
|
396 |
elif equation_file is None:
|
397 |
date_time = datetime.now().strftime("%Y-%m-%d_%H%M%S.%f")[:-3]
|
398 |
equation_file = "hall_of_fame_" + date_time + ".csv"
|
|
|
446 |
|
447 |
def _final_pysr_process(julia_optimization, runfile_filename, timeout, **kwargs):
|
448 |
command = [
|
449 |
+
"julia",
|
450 |
f"-O{julia_optimization:d}",
|
451 |
str(runfile_filename),
|
452 |
]
|
453 |
if timeout is not None:
|
454 |
+
command = ["timeout", f"{timeout}"] + command
|
455 |
_cmd_runner(command, **kwargs)
|
456 |
|
457 |
|
|
|
515 |
print(f'Pkg.activate("{_escape_filename(julia_project)}")', file=f)
|
516 |
if need_install:
|
517 |
print(f"Pkg.instantiate()", file=f)
|
518 |
+
print("Pkg.update()", file=f)
|
519 |
+
print("Pkg.precompile()", file=f)
|
520 |
elif update:
|
521 |
print(f"Pkg.update()", file=f)
|
522 |
print(f"using SymbolicRegression", file=f)
|
|
|
798 |
tmpdir = Path(tempfile.mkdtemp(dir=tempdir))
|
799 |
hyperparam_filename = tmpdir / f"hyperparams.jl"
|
800 |
dataset_filename = tmpdir / f"dataset.jl"
|
801 |
+
runfile_filename = tmpdir / "runfile.jl"
|
802 |
X_filename = tmpdir / "X.csv"
|
803 |
y_filename = tmpdir / "y.csv"
|
804 |
weights_filename = tmpdir / "weights.csv"
|