Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
d974a2c
1
Parent(s):
f2e0980
Compatible filenames
Browse files- pysr/feynman_problems.py +7 -4
- pysr/sr.py +1 -1
pysr/feynman_problems.py
CHANGED
@@ -2,6 +2,10 @@ import numpy as np
|
|
2 |
import csv
|
3 |
import traceback
|
4 |
from .sr import pysr, best
|
|
|
|
|
|
|
|
|
5 |
|
6 |
class Problem:
|
7 |
"""
|
@@ -59,7 +63,7 @@ class FeynmanProblem(Problem):
|
|
59 |
def __repr__(self):
|
60 |
return str(self)
|
61 |
|
62 |
-
def mk_problems(first=100, gen=False, dp=500, data_dir=
|
63 |
"""
|
64 |
|
65 |
first: the first "first" equations from the dataset will be made into problems
|
@@ -97,8 +101,7 @@ def run_on_problem(problem, verbosity=0, multiprocessing=True):
|
|
97 |
others['equations'] = equations
|
98 |
return str(best(equations)), problem.form, others
|
99 |
|
100 |
-
|
101 |
-
def do_feynman_experiments_parallel(first=100, verbosity=0, dp=500, output_file_path="experiments/FeynmanExperiment.csv", data_dir="datasets/FeynmanEquations.csv"):
|
102 |
import multiprocessing as mp
|
103 |
from tqdm import tqdm
|
104 |
problems = FeynmanProblem.mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
@@ -126,7 +129,7 @@ def do_feynman_experiments_parallel(first=100, verbosity=0, dp=500, output_file_
|
|
126 |
writer.writerow([ids[i], predictions[i], true_equations[i], time_takens[i]])
|
127 |
return
|
128 |
|
129 |
-
def do_feynman_experiments(first=100, verbosity=0, dp=500, output_file_path="
|
130 |
from tqdm import tqdm
|
131 |
|
132 |
problems = FeynmanProblem.mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
|
|
2 |
import csv
|
3 |
import traceback
|
4 |
from .sr import pysr, best
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
PKG_DIR = Path(__file__).parents[1]
|
8 |
+
FEYNMAN_DATASET = PKG_DIR / "datasets" / "FeynmanEquations.csv"
|
9 |
|
10 |
class Problem:
|
11 |
"""
|
|
|
63 |
def __repr__(self):
|
64 |
return str(self)
|
65 |
|
66 |
+
def mk_problems(first=100, gen=False, dp=500, data_dir=FEYNMAN_DATASET):
|
67 |
"""
|
68 |
|
69 |
first: the first "first" equations from the dataset will be made into problems
|
|
|
101 |
others['equations'] = equations
|
102 |
return str(best(equations)), problem.form, others
|
103 |
|
104 |
+
def do_feynman_experiments_parallel(first=100, verbosity=0, dp=500, output_file_path="FeynmanExperiment.csv", data_dir=FEYNMAN_DATASET):
|
|
|
105 |
import multiprocessing as mp
|
106 |
from tqdm import tqdm
|
107 |
problems = FeynmanProblem.mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
|
|
129 |
writer.writerow([ids[i], predictions[i], true_equations[i], time_takens[i]])
|
130 |
return
|
131 |
|
132 |
+
def do_feynman_experiments(first=100, verbosity=0, dp=500, output_file_path="FeynmanExperiment.csv", data_dir=FEYNMAN_DATASET):
|
133 |
from tqdm import tqdm
|
134 |
|
135 |
problems = FeynmanProblem.mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
pysr/sr.py
CHANGED
@@ -312,7 +312,7 @@ def _final_pysr_process(julia_optimization, runfile_filename, timeout, **kwargs)
|
|
312 |
command = [f'timeout', f'{timeout}'] + command
|
313 |
_cmd_runner(command, **kwargs)
|
314 |
|
315 |
-
def _cmd_runner(command):
|
316 |
if kwargs['verbosity'] > 0:
|
317 |
print("Running on", ' '.join(command))
|
318 |
process = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=-1)
|
|
|
312 |
command = [f'timeout', f'{timeout}'] + command
|
313 |
_cmd_runner(command, **kwargs)
|
314 |
|
315 |
+
def _cmd_runner(command, **kwargs):
|
316 |
if kwargs['verbosity'] > 0:
|
317 |
print("Running on", ' '.join(command))
|
318 |
process = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=-1)
|