Spaces:
Running
Running
Commit
·
5edf565
1
Parent(s):
d42f10b
Include test for changed options
Browse files- pysr/test/test.py +18 -0
pysr/test/test.py
CHANGED
|
@@ -12,6 +12,7 @@ import pickle as pkl
|
|
| 12 |
import tempfile
|
| 13 |
from pathlib import Path
|
| 14 |
|
|
|
|
| 15 |
from .. import PySRRegressor
|
| 16 |
from ..sr import (
|
| 17 |
run_feature_selection,
|
|
@@ -566,6 +567,23 @@ class TestMiscellaneous(unittest.TestCase):
|
|
| 566 |
with self.assertRaises(ValueError):
|
| 567 |
model.fit(X, y)
|
| 568 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
def test_extra_sympy_mappings_undefined(self):
|
| 570 |
"""extra_sympy_mappings=None errors for custom operators"""
|
| 571 |
model = PySRRegressor(unary_operators=["square2(x) = x^2"])
|
|
|
|
| 12 |
import tempfile
|
| 13 |
from pathlib import Path
|
| 14 |
|
| 15 |
+
from .. import julia_helpers
|
| 16 |
from .. import PySRRegressor
|
| 17 |
from ..sr import (
|
| 18 |
run_feature_selection,
|
|
|
|
| 567 |
with self.assertRaises(ValueError):
|
| 568 |
model.fit(X, y)
|
| 569 |
|
| 570 |
+
def test_changed_options_warning(self):
|
| 571 |
+
"""Check that a warning is given if Julia options are changed."""
|
| 572 |
+
if julia_helpers.julia_kwargs_at_initialization is None:
|
| 573 |
+
julia_helpers.init_julia(julia_kwargs={"threads": 2, "optimize": 3})
|
| 574 |
+
|
| 575 |
+
cur_init = julia_helpers.julia_kwargs_at_initialization
|
| 576 |
+
|
| 577 |
+
threads_to_change = cur_init["threads"] + 1
|
| 578 |
+
with warnings.catch_warnings():
|
| 579 |
+
warnings.simplefilter("error")
|
| 580 |
+
with self.assertRaises(Exception) as context:
|
| 581 |
+
julia_helpers.init_julia(
|
| 582 |
+
julia_kwargs={"threads": threads_to_change, "optimize": 3}
|
| 583 |
+
)
|
| 584 |
+
self.assertIn("Julia has already started", str(context.exception))
|
| 585 |
+
self.assertIn("threads", str(context.exception))
|
| 586 |
+
|
| 587 |
def test_extra_sympy_mappings_undefined(self):
|
| 588 |
"""extra_sympy_mappings=None errors for custom operators"""
|
| 589 |
model = PySRRegressor(unary_operators=["square2(x) = x^2"])
|