Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Merge branch 'master' of github.com:MilesCranmer/PySR
Browse files- benchmarks/hyperparamopt.py +1 -1
- pysr/sr.py +2 -2
- test/test.py +3 -3
- test/test_torch.py +1 -1
benchmarks/hyperparamopt.py
CHANGED
@@ -178,7 +178,7 @@ while True:
|
|
178 |
max_evals=n + len(trials.trials),
|
179 |
trials=trials,
|
180 |
verbose=1,
|
181 |
-
rstate=np.random.RandomState(np.random.randint(1, 10
|
182 |
)
|
183 |
except hyperopt.exceptions.AllTrialsFailed:
|
184 |
continue
|
|
|
178 |
max_evals=n + len(trials.trials),
|
179 |
trials=trials,
|
180 |
verbose=1,
|
181 |
+
rstate=np.random.RandomState(np.random.randint(1, 10**6)),
|
182 |
)
|
183 |
except hyperopt.exceptions.AllTrialsFailed:
|
184 |
continue
|
pysr/sr.py
CHANGED
@@ -78,8 +78,8 @@ sympy_mappings = {
|
|
78 |
"div": lambda x, y: x / y,
|
79 |
"mult": lambda x, y: x * y,
|
80 |
"sqrt_abs": lambda x: sympy.sqrt(abs(x)),
|
81 |
-
"square": lambda x: x
|
82 |
-
"cube": lambda x: x
|
83 |
"plus": lambda x, y: x + y,
|
84 |
"sub": lambda x, y: x - y,
|
85 |
"neg": lambda x: -x,
|
|
|
78 |
"div": lambda x, y: x / y,
|
79 |
"mult": lambda x, y: x * y,
|
80 |
"sqrt_abs": lambda x: sympy.sqrt(abs(x)),
|
81 |
+
"square": lambda x: x**2,
|
82 |
+
"cube": lambda x: x**3,
|
83 |
"plus": lambda x, y: x + y,
|
84 |
"sub": lambda x, y: x - y,
|
85 |
"neg": lambda x: -x,
|
test/test.py
CHANGED
@@ -40,7 +40,7 @@ class TestPipeline(unittest.TestCase):
|
|
40 |
y = self.X[:, [0, 1]] ** 2
|
41 |
model = PySRRegressor(
|
42 |
unary_operators=["sq(x) = x^2"],
|
43 |
-
extra_sympy_mappings={"sq": lambda x: x
|
44 |
binary_operators=["plus"],
|
45 |
verbosity=0,
|
46 |
**self.default_test_kwargs,
|
@@ -65,7 +65,7 @@ class TestPipeline(unittest.TestCase):
|
|
65 |
model = PySRRegressor(
|
66 |
unary_operators=["sq(x) = x^2"],
|
67 |
binary_operators=["plus"],
|
68 |
-
extra_sympy_mappings={"sq": lambda x: x
|
69 |
**self.default_test_kwargs,
|
70 |
procs=0,
|
71 |
temp_equation_file=True,
|
@@ -121,7 +121,7 @@ class TestPipeline(unittest.TestCase):
|
|
121 |
# Test that passing a single operator works:
|
122 |
unary_operators="sq(x) = x^2",
|
123 |
binary_operators="plus",
|
124 |
-
extra_sympy_mappings={"sq": lambda x: x
|
125 |
**self.default_test_kwargs,
|
126 |
procs=0,
|
127 |
denoise=True,
|
|
|
40 |
y = self.X[:, [0, 1]] ** 2
|
41 |
model = PySRRegressor(
|
42 |
unary_operators=["sq(x) = x^2"],
|
43 |
+
extra_sympy_mappings={"sq": lambda x: x**2},
|
44 |
binary_operators=["plus"],
|
45 |
verbosity=0,
|
46 |
**self.default_test_kwargs,
|
|
|
65 |
model = PySRRegressor(
|
66 |
unary_operators=["sq(x) = x^2"],
|
67 |
binary_operators=["plus"],
|
68 |
+
extra_sympy_mappings={"sq": lambda x: x**2},
|
69 |
**self.default_test_kwargs,
|
70 |
procs=0,
|
71 |
temp_equation_file=True,
|
|
|
121 |
# Test that passing a single operator works:
|
122 |
unary_operators="sq(x) = x^2",
|
123 |
binary_operators="plus",
|
124 |
+
extra_sympy_mappings={"sq": lambda x: x**2},
|
125 |
**self.default_test_kwargs,
|
126 |
procs=0,
|
127 |
denoise=True,
|
test/test_torch.py
CHANGED
@@ -58,7 +58,7 @@ class TestTorch(unittest.TestCase):
|
|
58 |
|
59 |
def test_mod_mapping(self):
|
60 |
x, y, z = sympy.symbols("x y z")
|
61 |
-
expression = x
|
62 |
|
63 |
module = sympy2torch(expression, [x, y, z])
|
64 |
|
|
|
58 |
|
59 |
def test_mod_mapping(self):
|
60 |
x, y, z = sympy.symbols("x y z")
|
61 |
+
expression = x**2 + sympy.atanh(sympy.Mod(y + 1, 2) - 1) * 3.2 * z
|
62 |
|
63 |
module = sympy2torch(expression, [x, y, z])
|
64 |
|