|
1 | 1 | def test_integration_pysr():
|
2 |
| - "Integration tests for PySR" |
3 |
| - import os |
4 |
| - import platform |
5 |
| - import subprocess |
6 |
| - import sys |
7 |
| - import tempfile |
| 2 | + "Simple PySR search" |
| 3 | + import pysr |
| 4 | + import numpy as np |
8 | 5 |
|
9 |
| - with tempfile.TemporaryDirectory() as tempdir: |
10 |
| - subprocess.run([sys.executable, "-m", "virtualenv", tempdir], check=True) |
| 6 | + rng = np.random.RandomState(0) |
| 7 | + X = rng.randn(100, 5) |
| 8 | + y = np.cos(X[:, 0] * 2.1 - 0.5) + X[:, 1] * 0.7 |
| 9 | + model = pysr.PySRRegressor( |
| 10 | + niterations=30, |
| 11 | + unary_operators=["cos"], |
| 12 | + binary_operators=["*", "+", "-"], |
| 13 | + early_stop_condition=1e-5, |
| 14 | + ) |
| 15 | + model.fit(X, y) |
| 16 | + assert model.equations_.iloc[-1]["loss"] < 1e-5 |
11 | 17 |
|
12 |
| - virtualenv_path = os.path.join( |
13 |
| - tempdir, "Scripts" if platform.system() == "Windows" else "bin" |
14 |
| - ) |
15 |
| - virtualenv_executable = os.path.join(virtualenv_path, "python") |
16 |
| - |
17 |
| - assert os.path.exists(virtualenv_executable) |
18 |
| - |
19 |
| - # Install this package |
20 |
| - subprocess.run([virtualenv_executable, "-m", "pip", "install", "."], check=True) |
21 |
| - # Install PySR with no requirement on JuliaCall |
22 |
| - subprocess.run( |
23 |
| - [virtualenv_executable, "-m", "pip", "install", "--no-deps", "pysr"], |
24 |
| - check=True, |
25 |
| - ) |
26 |
| - # Install PySR test requirements |
27 |
| - subprocess.run( |
28 |
| - [ |
29 |
| - virtualenv_executable, |
30 |
| - "-m", |
31 |
| - "pip", |
32 |
| - "install", |
33 |
| - "sympy", |
34 |
| - "pandas", |
35 |
| - "scikit_learn", |
36 |
| - "click", |
37 |
| - "setuptools", |
38 |
| - "pytest", |
39 |
| - ], |
40 |
| - check=True, |
41 |
| - ) |
42 |
| - # Run PySR main test suite |
43 |
| - subprocess.run( |
44 |
| - [virtualenv_executable, "-m", "pysr", "test", "main"], check=True |
45 |
| - ) |
0 commit comments