Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
6fc6d39
1
Parent(s):
eddee71
Fix FeynmanProblem misuse of class method
Browse files- pysr/feynman_problems.py +26 -29
pysr/feynman_problems.py
CHANGED
@@ -70,30 +70,31 @@ class FeynmanProblem(Problem):
|
|
70 |
def __repr__(self):
|
71 |
return str(self)
|
72 |
|
73 |
-
def mk_problems(self, first=100, gen=False, dp=500, data_dir=FEYNMAN_DATASET):
|
74 |
-
"""
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
|
98 |
|
99 |
def run_on_problem(problem, verbosity=0, multiprocessing=True):
|
@@ -126,9 +127,7 @@ def do_feynman_experiments_parallel(
|
|
126 |
import multiprocessing as mp
|
127 |
from tqdm import tqdm
|
128 |
|
129 |
-
problems =
|
130 |
-
first=first, gen=True, dp=dp, data_dir=data_dir
|
131 |
-
)
|
132 |
ids = []
|
133 |
predictions = []
|
134 |
true_equations = []
|
@@ -163,9 +162,7 @@ def do_feynman_experiments(
|
|
163 |
):
|
164 |
from tqdm import tqdm
|
165 |
|
166 |
-
problems =
|
167 |
-
first=first, gen=True, dp=dp, data_dir=data_dir
|
168 |
-
)
|
169 |
ids = []
|
170 |
predictions = []
|
171 |
true_equations = []
|
|
|
70 |
def __repr__(self):
|
71 |
return str(self)
|
72 |
|
|
|
|
|
73 |
|
74 |
+
def mk_problems(first=100, gen=False, dp=500, data_dir=FEYNMAN_DATASET):
|
75 |
+
"""
|
76 |
+
|
77 |
+
first: the first "first" equations from the dataset will be made into problems
|
78 |
+
data_dir: the path pointing to the Feynman Equations csv
|
79 |
+
returns: list of FeynmanProblems
|
80 |
+
"""
|
81 |
+
ret = []
|
82 |
+
with open(data_dir) as csvfile:
|
83 |
+
ind = 0
|
84 |
+
reader = csv.DictReader(csvfile)
|
85 |
+
for i, row in enumerate(reader):
|
86 |
+
if ind > first:
|
87 |
+
break
|
88 |
+
if row["Filename"] == "":
|
89 |
+
continue
|
90 |
+
try:
|
91 |
+
p = FeynmanProblem(row, gen=gen, dp=dp)
|
92 |
+
ret.append(p)
|
93 |
+
except Exception as e:
|
94 |
+
traceback.print_exc()
|
95 |
+
print(f"FAILED ON ROW {i} with {e}")
|
96 |
+
ind += 1
|
97 |
+
return ret
|
98 |
|
99 |
|
100 |
def run_on_problem(problem, verbosity=0, multiprocessing=True):
|
|
|
127 |
import multiprocessing as mp
|
128 |
from tqdm import tqdm
|
129 |
|
130 |
+
problems = mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
|
|
|
|
131 |
ids = []
|
132 |
predictions = []
|
133 |
true_equations = []
|
|
|
162 |
):
|
163 |
from tqdm import tqdm
|
164 |
|
165 |
+
problems = mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
|
|
|
|
166 |
ids = []
|
167 |
predictions = []
|
168 |
true_equations = []
|