Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
65159ce
1
Parent(s):
24a4349
Test jupyter notebook in test suite
Browse files- .github/workflows/CI.yml +2 -2
- .github/workflows/CI_Windows.yml +1 -0
- .github/workflows/CI_conda_forge.yml +3 -1
- .github/workflows/CI_docker.yml +1 -1
- .github/workflows/CI_docker_large_nightly.yml +1 -1
- .github/workflows/CI_large_nightly.yml +2 -2
- .github/workflows/CI_mac.yml +1 -0
- .pre-commit-config.yaml +2 -0
- pysr/test/test_nb.ipynb +537 -0
- pysr/test/test_startup.py +13 -0
.github/workflows/CI.yml
CHANGED
@@ -69,8 +69,8 @@ jobs:
|
|
69 |
- name: "Assert Julia version"
|
70 |
if: ${{ matrix.julia-version != '1'}}
|
71 |
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
|
72 |
-
- name: "Install
|
73 |
-
run: pip install coverage coveralls
|
74 |
- name: "Set up coverage for subprocesses"
|
75 |
run: echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
|
76 |
- name: "Run tests"
|
|
|
69 |
- name: "Assert Julia version"
|
70 |
if: ${{ matrix.julia-version != '1'}}
|
71 |
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
|
72 |
+
- name: "Install test dependencies"
|
73 |
+
run: pip install coverage coveralls pytest nbval
|
74 |
- name: "Set up coverage for subprocesses"
|
75 |
run: echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
|
76 |
- name: "Run tests"
|
.github/workflows/CI_Windows.yml
CHANGED
@@ -52,6 +52,7 @@ jobs:
|
|
52 |
- name: "Install PySR"
|
53 |
run: |
|
54 |
python -m pip install --upgrade pip
|
|
|
55 |
pip install .
|
56 |
python -c 'import pysr'
|
57 |
- name: "Run tests"
|
|
|
52 |
- name: "Install PySR"
|
53 |
run: |
|
54 |
python -m pip install --upgrade pip
|
55 |
+
pip install pytest nbval
|
56 |
pip install .
|
57 |
python -c 'import pysr'
|
58 |
- name: "Run tests"
|
.github/workflows/CI_conda_forge.yml
CHANGED
@@ -40,4 +40,6 @@ jobs:
|
|
40 |
run: conda activate pysr-test && conda install pysr
|
41 |
if: ${{ !matrix.use-mamba }}
|
42 |
- name: "Run tests"
|
43 |
-
run:
|
|
|
|
|
|
40 |
run: conda activate pysr-test && conda install pysr
|
41 |
if: ${{ !matrix.use-mamba }}
|
42 |
- name: "Run tests"
|
43 |
+
run: |
|
44 |
+
pip install pytest nbval
|
45 |
+
python -m pysr test main,startup
|
.github/workflows/CI_docker.yml
CHANGED
@@ -37,4 +37,4 @@ jobs:
|
|
37 |
- name: Build docker
|
38 |
run: docker build --platform=${{ matrix.arch }} -t pysr .
|
39 |
- name: Test docker
|
40 |
-
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr test main,cli,startup'
|
|
|
37 |
- name: Build docker
|
38 |
run: docker build --platform=${{ matrix.arch }} -t pysr .
|
39 |
- name: Test docker
|
40 |
+
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'pip install pytest nbval && python3 -m pysr test main,cli,startup'
|
.github/workflows/CI_docker_large_nightly.yml
CHANGED
@@ -33,4 +33,4 @@ jobs:
|
|
33 |
- name: Build docker
|
34 |
run: docker build --platform=${{ matrix.arch }} -t pysr --build-arg JLVERSION=${{ matrix.julia-version }} --build-arg PYVERSION=${{ matrix.python-version }} .
|
35 |
- name: Test docker
|
36 |
-
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr test main,cli,startup'
|
|
|
33 |
- name: Build docker
|
34 |
run: docker build --platform=${{ matrix.arch }} -t pysr --build-arg JLVERSION=${{ matrix.julia-version }} --build-arg PYVERSION=${{ matrix.python-version }} .
|
35 |
- name: Test docker
|
36 |
+
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'pip install pytest nbval && python3 -m pysr test main,cli,startup'
|
.github/workflows/CI_large_nightly.yml
CHANGED
@@ -40,11 +40,11 @@ jobs:
|
|
40 |
- name: "Install PySR"
|
41 |
run: |
|
42 |
python -m pip install --upgrade pip
|
|
|
43 |
pip install .
|
44 |
python -c 'import pysr'
|
45 |
- name: "Assert Julia version"
|
46 |
if: ${{ matrix.julia-version != '1'}}
|
47 |
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
|
48 |
- name: "Run tests"
|
49 |
-
run:
|
50 |
-
python -m pysr test main,cli,startup
|
|
|
40 |
- name: "Install PySR"
|
41 |
run: |
|
42 |
python -m pip install --upgrade pip
|
43 |
+
pip install pytest nbval
|
44 |
pip install .
|
45 |
python -c 'import pysr'
|
46 |
- name: "Assert Julia version"
|
47 |
if: ${{ matrix.julia-version != '1'}}
|
48 |
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
|
49 |
- name: "Run tests"
|
50 |
+
run: python -m pysr test main,cli,startup
|
|
.github/workflows/CI_mac.yml
CHANGED
@@ -52,6 +52,7 @@ jobs:
|
|
52 |
- name: "Install PySR"
|
53 |
run: |
|
54 |
python -m pip install --upgrade pip
|
|
|
55 |
pip install .
|
56 |
python -c 'import pysr'
|
57 |
- name: "Run tests"
|
|
|
52 |
- name: "Install PySR"
|
53 |
run: |
|
54 |
python -m pip install --upgrade pip
|
55 |
+
pip install pytest nbval
|
56 |
pip install .
|
57 |
python -c 'import pysr'
|
58 |
- name: "Run tests"
|
.pre-commit-config.yaml
CHANGED
@@ -13,11 +13,13 @@ repos:
|
|
13 |
hooks:
|
14 |
- id: black
|
15 |
- id: black-jupyter
|
|
|
16 |
# Stripping notebooks
|
17 |
- repo: https://github.com/kynan/nbstripout
|
18 |
rev: 0.6.1
|
19 |
hooks:
|
20 |
- id: nbstripout
|
|
|
21 |
# Unused imports
|
22 |
- repo: https://github.com/hadialqattan/pycln
|
23 |
rev: "v2.4.0"
|
|
|
13 |
hooks:
|
14 |
- id: black
|
15 |
- id: black-jupyter
|
16 |
+
exclude: pysr/test/test_nb.ipynb
|
17 |
# Stripping notebooks
|
18 |
- repo: https://github.com/kynan/nbstripout
|
19 |
rev: 0.6.1
|
20 |
hooks:
|
21 |
- id: nbstripout
|
22 |
+
exclude: pysr/test/test_nb.ipynb
|
23 |
# Unused imports
|
24 |
- repo: https://github.com/hadialqattan/pycln
|
25 |
rev: "v2.4.0"
|
pysr/test/test_nb.ipynb
ADDED
@@ -0,0 +1,537 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"# NBVAL_IGNORE_OUTPUT\n",
|
10 |
+
"import warnings\n",
|
11 |
+
"import numpy as np\n",
|
12 |
+
"from pysr import PySRRegressor, jl"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 2,
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [
|
20 |
+
{
|
21 |
+
"name": "stdout",
|
22 |
+
"output_type": "stream",
|
23 |
+
"text": [
|
24 |
+
"3\n"
|
25 |
+
]
|
26 |
+
}
|
27 |
+
],
|
28 |
+
"source": [
|
29 |
+
"%%julia\n",
|
30 |
+
"\n",
|
31 |
+
"# Automatically activates Julia magic\n",
|
32 |
+
"\n",
|
33 |
+
"x = 1\n",
|
34 |
+
"println(x + 2)"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 3,
|
40 |
+
"metadata": {},
|
41 |
+
"outputs": [
|
42 |
+
{
|
43 |
+
"name": "stdout",
|
44 |
+
"output_type": "stream",
|
45 |
+
"text": [
|
46 |
+
"4\n"
|
47 |
+
]
|
48 |
+
}
|
49 |
+
],
|
50 |
+
"source": [
|
51 |
+
"%julia println(x + 3)"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"execution_count": 4,
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [
|
59 |
+
{
|
60 |
+
"data": {
|
61 |
+
"text/html": [
|
62 |
+
"<style>#sk-container-id-1 {\n",
|
63 |
+
" /* Definition of color scheme common for light and dark mode */\n",
|
64 |
+
" --sklearn-color-text: black;\n",
|
65 |
+
" --sklearn-color-line: gray;\n",
|
66 |
+
" /* Definition of color scheme for unfitted estimators */\n",
|
67 |
+
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
68 |
+
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
69 |
+
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
70 |
+
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
71 |
+
" /* Definition of color scheme for fitted estimators */\n",
|
72 |
+
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
73 |
+
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
74 |
+
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
75 |
+
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
76 |
+
"\n",
|
77 |
+
" /* Specific color for light theme */\n",
|
78 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
79 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
80 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
81 |
+
" --sklearn-color-icon: #696969;\n",
|
82 |
+
"\n",
|
83 |
+
" @media (prefers-color-scheme: dark) {\n",
|
84 |
+
" /* Redefinition of color scheme for dark theme */\n",
|
85 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
86 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
87 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
88 |
+
" --sklearn-color-icon: #878787;\n",
|
89 |
+
" }\n",
|
90 |
+
"}\n",
|
91 |
+
"\n",
|
92 |
+
"#sk-container-id-1 {\n",
|
93 |
+
" color: var(--sklearn-color-text);\n",
|
94 |
+
"}\n",
|
95 |
+
"\n",
|
96 |
+
"#sk-container-id-1 pre {\n",
|
97 |
+
" padding: 0;\n",
|
98 |
+
"}\n",
|
99 |
+
"\n",
|
100 |
+
"#sk-container-id-1 input.sk-hidden--visually {\n",
|
101 |
+
" border: 0;\n",
|
102 |
+
" clip: rect(1px 1px 1px 1px);\n",
|
103 |
+
" clip: rect(1px, 1px, 1px, 1px);\n",
|
104 |
+
" height: 1px;\n",
|
105 |
+
" margin: -1px;\n",
|
106 |
+
" overflow: hidden;\n",
|
107 |
+
" padding: 0;\n",
|
108 |
+
" position: absolute;\n",
|
109 |
+
" width: 1px;\n",
|
110 |
+
"}\n",
|
111 |
+
"\n",
|
112 |
+
"#sk-container-id-1 div.sk-dashed-wrapped {\n",
|
113 |
+
" border: 1px dashed var(--sklearn-color-line);\n",
|
114 |
+
" margin: 0 0.4em 0.5em 0.4em;\n",
|
115 |
+
" box-sizing: border-box;\n",
|
116 |
+
" padding-bottom: 0.4em;\n",
|
117 |
+
" background-color: var(--sklearn-color-background);\n",
|
118 |
+
"}\n",
|
119 |
+
"\n",
|
120 |
+
"#sk-container-id-1 div.sk-container {\n",
|
121 |
+
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
122 |
+
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
123 |
+
" so we also need the `!important` here to be able to override the\n",
|
124 |
+
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
125 |
+
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
126 |
+
" display: inline-block !important;\n",
|
127 |
+
" position: relative;\n",
|
128 |
+
"}\n",
|
129 |
+
"\n",
|
130 |
+
"#sk-container-id-1 div.sk-text-repr-fallback {\n",
|
131 |
+
" display: none;\n",
|
132 |
+
"}\n",
|
133 |
+
"\n",
|
134 |
+
"div.sk-parallel-item,\n",
|
135 |
+
"div.sk-serial,\n",
|
136 |
+
"div.sk-item {\n",
|
137 |
+
" /* draw centered vertical line to link estimators */\n",
|
138 |
+
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
139 |
+
" background-size: 2px 100%;\n",
|
140 |
+
" background-repeat: no-repeat;\n",
|
141 |
+
" background-position: center center;\n",
|
142 |
+
"}\n",
|
143 |
+
"\n",
|
144 |
+
"/* Parallel-specific style estimator block */\n",
|
145 |
+
"\n",
|
146 |
+
"#sk-container-id-1 div.sk-parallel-item::after {\n",
|
147 |
+
" content: \"\";\n",
|
148 |
+
" width: 100%;\n",
|
149 |
+
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
150 |
+
" flex-grow: 1;\n",
|
151 |
+
"}\n",
|
152 |
+
"\n",
|
153 |
+
"#sk-container-id-1 div.sk-parallel {\n",
|
154 |
+
" display: flex;\n",
|
155 |
+
" align-items: stretch;\n",
|
156 |
+
" justify-content: center;\n",
|
157 |
+
" background-color: var(--sklearn-color-background);\n",
|
158 |
+
" position: relative;\n",
|
159 |
+
"}\n",
|
160 |
+
"\n",
|
161 |
+
"#sk-container-id-1 div.sk-parallel-item {\n",
|
162 |
+
" display: flex;\n",
|
163 |
+
" flex-direction: column;\n",
|
164 |
+
"}\n",
|
165 |
+
"\n",
|
166 |
+
"#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
|
167 |
+
" align-self: flex-end;\n",
|
168 |
+
" width: 50%;\n",
|
169 |
+
"}\n",
|
170 |
+
"\n",
|
171 |
+
"#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
|
172 |
+
" align-self: flex-start;\n",
|
173 |
+
" width: 50%;\n",
|
174 |
+
"}\n",
|
175 |
+
"\n",
|
176 |
+
"#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
|
177 |
+
" width: 0;\n",
|
178 |
+
"}\n",
|
179 |
+
"\n",
|
180 |
+
"/* Serial-specific style estimator block */\n",
|
181 |
+
"\n",
|
182 |
+
"#sk-container-id-1 div.sk-serial {\n",
|
183 |
+
" display: flex;\n",
|
184 |
+
" flex-direction: column;\n",
|
185 |
+
" align-items: center;\n",
|
186 |
+
" background-color: var(--sklearn-color-background);\n",
|
187 |
+
" padding-right: 1em;\n",
|
188 |
+
" padding-left: 1em;\n",
|
189 |
+
"}\n",
|
190 |
+
"\n",
|
191 |
+
"\n",
|
192 |
+
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
193 |
+
"clickable and can be expanded/collapsed.\n",
|
194 |
+
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
195 |
+
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
196 |
+
"*/\n",
|
197 |
+
"\n",
|
198 |
+
"/* Pipeline and ColumnTransformer style (default) */\n",
|
199 |
+
"\n",
|
200 |
+
"#sk-container-id-1 div.sk-toggleable {\n",
|
201 |
+
" /* Default theme specific background. It is overwritten whether we have a\n",
|
202 |
+
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
203 |
+
" background-color: var(--sklearn-color-background);\n",
|
204 |
+
"}\n",
|
205 |
+
"\n",
|
206 |
+
"/* Toggleable label */\n",
|
207 |
+
"#sk-container-id-1 label.sk-toggleable__label {\n",
|
208 |
+
" cursor: pointer;\n",
|
209 |
+
" display: block;\n",
|
210 |
+
" width: 100%;\n",
|
211 |
+
" margin-bottom: 0;\n",
|
212 |
+
" padding: 0.5em;\n",
|
213 |
+
" box-sizing: border-box;\n",
|
214 |
+
" text-align: center;\n",
|
215 |
+
"}\n",
|
216 |
+
"\n",
|
217 |
+
"#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
|
218 |
+
" /* Arrow on the left of the label */\n",
|
219 |
+
" content: \"▸\";\n",
|
220 |
+
" float: left;\n",
|
221 |
+
" margin-right: 0.25em;\n",
|
222 |
+
" color: var(--sklearn-color-icon);\n",
|
223 |
+
"}\n",
|
224 |
+
"\n",
|
225 |
+
"#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
|
226 |
+
" color: var(--sklearn-color-text);\n",
|
227 |
+
"}\n",
|
228 |
+
"\n",
|
229 |
+
"/* Toggleable content - dropdown */\n",
|
230 |
+
"\n",
|
231 |
+
"#sk-container-id-1 div.sk-toggleable__content {\n",
|
232 |
+
" max-height: 0;\n",
|
233 |
+
" max-width: 0;\n",
|
234 |
+
" overflow: hidden;\n",
|
235 |
+
" text-align: left;\n",
|
236 |
+
" /* unfitted */\n",
|
237 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
238 |
+
"}\n",
|
239 |
+
"\n",
|
240 |
+
"#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
|
241 |
+
" /* fitted */\n",
|
242 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
243 |
+
"}\n",
|
244 |
+
"\n",
|
245 |
+
"#sk-container-id-1 div.sk-toggleable__content pre {\n",
|
246 |
+
" margin: 0.2em;\n",
|
247 |
+
" border-radius: 0.25em;\n",
|
248 |
+
" color: var(--sklearn-color-text);\n",
|
249 |
+
" /* unfitted */\n",
|
250 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
251 |
+
"}\n",
|
252 |
+
"\n",
|
253 |
+
"#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
|
254 |
+
" /* unfitted */\n",
|
255 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
256 |
+
"}\n",
|
257 |
+
"\n",
|
258 |
+
"#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
259 |
+
" /* Expand drop-down */\n",
|
260 |
+
" max-height: 200px;\n",
|
261 |
+
" max-width: 100%;\n",
|
262 |
+
" overflow: auto;\n",
|
263 |
+
"}\n",
|
264 |
+
"\n",
|
265 |
+
"#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
266 |
+
" content: \"▾\";\n",
|
267 |
+
"}\n",
|
268 |
+
"\n",
|
269 |
+
"/* Pipeline/ColumnTransformer-specific style */\n",
|
270 |
+
"\n",
|
271 |
+
"#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
272 |
+
" color: var(--sklearn-color-text);\n",
|
273 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
274 |
+
"}\n",
|
275 |
+
"\n",
|
276 |
+
"#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
277 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
278 |
+
"}\n",
|
279 |
+
"\n",
|
280 |
+
"/* Estimator-specific style */\n",
|
281 |
+
"\n",
|
282 |
+
"/* Colorize estimator box */\n",
|
283 |
+
"#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
284 |
+
" /* unfitted */\n",
|
285 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
286 |
+
"}\n",
|
287 |
+
"\n",
|
288 |
+
"#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
289 |
+
" /* fitted */\n",
|
290 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
291 |
+
"}\n",
|
292 |
+
"\n",
|
293 |
+
"#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
|
294 |
+
"#sk-container-id-1 div.sk-label label {\n",
|
295 |
+
" /* The background is the default theme color */\n",
|
296 |
+
" color: var(--sklearn-color-text-on-default-background);\n",
|
297 |
+
"}\n",
|
298 |
+
"\n",
|
299 |
+
"/* On hover, darken the color of the background */\n",
|
300 |
+
"#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
|
301 |
+
" color: var(--sklearn-color-text);\n",
|
302 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
303 |
+
"}\n",
|
304 |
+
"\n",
|
305 |
+
"/* Label box, darken color on hover, fitted */\n",
|
306 |
+
"#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
307 |
+
" color: var(--sklearn-color-text);\n",
|
308 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
309 |
+
"}\n",
|
310 |
+
"\n",
|
311 |
+
"/* Estimator label */\n",
|
312 |
+
"\n",
|
313 |
+
"#sk-container-id-1 div.sk-label label {\n",
|
314 |
+
" font-family: monospace;\n",
|
315 |
+
" font-weight: bold;\n",
|
316 |
+
" display: inline-block;\n",
|
317 |
+
" line-height: 1.2em;\n",
|
318 |
+
"}\n",
|
319 |
+
"\n",
|
320 |
+
"#sk-container-id-1 div.sk-label-container {\n",
|
321 |
+
" text-align: center;\n",
|
322 |
+
"}\n",
|
323 |
+
"\n",
|
324 |
+
"/* Estimator-specific */\n",
|
325 |
+
"#sk-container-id-1 div.sk-estimator {\n",
|
326 |
+
" font-family: monospace;\n",
|
327 |
+
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
328 |
+
" border-radius: 0.25em;\n",
|
329 |
+
" box-sizing: border-box;\n",
|
330 |
+
" margin-bottom: 0.5em;\n",
|
331 |
+
" /* unfitted */\n",
|
332 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
333 |
+
"}\n",
|
334 |
+
"\n",
|
335 |
+
"#sk-container-id-1 div.sk-estimator.fitted {\n",
|
336 |
+
" /* fitted */\n",
|
337 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
338 |
+
"}\n",
|
339 |
+
"\n",
|
340 |
+
"/* on hover */\n",
|
341 |
+
"#sk-container-id-1 div.sk-estimator:hover {\n",
|
342 |
+
" /* unfitted */\n",
|
343 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
344 |
+
"}\n",
|
345 |
+
"\n",
|
346 |
+
"#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
|
347 |
+
" /* fitted */\n",
|
348 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
349 |
+
"}\n",
|
350 |
+
"\n",
|
351 |
+
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
352 |
+
"\n",
|
353 |
+
"/* Common style for \"i\" and \"?\" */\n",
|
354 |
+
"\n",
|
355 |
+
".sk-estimator-doc-link,\n",
|
356 |
+
"a:link.sk-estimator-doc-link,\n",
|
357 |
+
"a:visited.sk-estimator-doc-link {\n",
|
358 |
+
" float: right;\n",
|
359 |
+
" font-size: smaller;\n",
|
360 |
+
" line-height: 1em;\n",
|
361 |
+
" font-family: monospace;\n",
|
362 |
+
" background-color: var(--sklearn-color-background);\n",
|
363 |
+
" border-radius: 1em;\n",
|
364 |
+
" height: 1em;\n",
|
365 |
+
" width: 1em;\n",
|
366 |
+
" text-decoration: none !important;\n",
|
367 |
+
" margin-left: 1ex;\n",
|
368 |
+
" /* unfitted */\n",
|
369 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
370 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
371 |
+
"}\n",
|
372 |
+
"\n",
|
373 |
+
".sk-estimator-doc-link.fitted,\n",
|
374 |
+
"a:link.sk-estimator-doc-link.fitted,\n",
|
375 |
+
"a:visited.sk-estimator-doc-link.fitted {\n",
|
376 |
+
" /* fitted */\n",
|
377 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
378 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
379 |
+
"}\n",
|
380 |
+
"\n",
|
381 |
+
"/* On hover */\n",
|
382 |
+
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
383 |
+
".sk-estimator-doc-link:hover,\n",
|
384 |
+
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
385 |
+
".sk-estimator-doc-link:hover {\n",
|
386 |
+
" /* unfitted */\n",
|
387 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
388 |
+
" color: var(--sklearn-color-background);\n",
|
389 |
+
" text-decoration: none;\n",
|
390 |
+
"}\n",
|
391 |
+
"\n",
|
392 |
+
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
393 |
+
".sk-estimator-doc-link.fitted:hover,\n",
|
394 |
+
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
395 |
+
".sk-estimator-doc-link.fitted:hover {\n",
|
396 |
+
" /* fitted */\n",
|
397 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
398 |
+
" color: var(--sklearn-color-background);\n",
|
399 |
+
" text-decoration: none;\n",
|
400 |
+
"}\n",
|
401 |
+
"\n",
|
402 |
+
"/* Span, style for the box shown on hovering the info icon */\n",
|
403 |
+
".sk-estimator-doc-link span {\n",
|
404 |
+
" display: none;\n",
|
405 |
+
" z-index: 9999;\n",
|
406 |
+
" position: relative;\n",
|
407 |
+
" font-weight: normal;\n",
|
408 |
+
" right: .2ex;\n",
|
409 |
+
" padding: .5ex;\n",
|
410 |
+
" margin: .5ex;\n",
|
411 |
+
" width: min-content;\n",
|
412 |
+
" min-width: 20ex;\n",
|
413 |
+
" max-width: 50ex;\n",
|
414 |
+
" color: var(--sklearn-color-text);\n",
|
415 |
+
" box-shadow: 2pt 2pt 4pt #999;\n",
|
416 |
+
" /* unfitted */\n",
|
417 |
+
" background: var(--sklearn-color-unfitted-level-0);\n",
|
418 |
+
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
419 |
+
"}\n",
|
420 |
+
"\n",
|
421 |
+
".sk-estimator-doc-link.fitted span {\n",
|
422 |
+
" /* fitted */\n",
|
423 |
+
" background: var(--sklearn-color-fitted-level-0);\n",
|
424 |
+
" border: var(--sklearn-color-fitted-level-3);\n",
|
425 |
+
"}\n",
|
426 |
+
"\n",
|
427 |
+
".sk-estimator-doc-link:hover span {\n",
|
428 |
+
" display: block;\n",
|
429 |
+
"}\n",
|
430 |
+
"\n",
|
431 |
+
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
432 |
+
"\n",
|
433 |
+
"#sk-container-id-1 a.estimator_doc_link {\n",
|
434 |
+
" float: right;\n",
|
435 |
+
" font-size: 1rem;\n",
|
436 |
+
" line-height: 1em;\n",
|
437 |
+
" font-family: monospace;\n",
|
438 |
+
" background-color: var(--sklearn-color-background);\n",
|
439 |
+
" border-radius: 1rem;\n",
|
440 |
+
" height: 1rem;\n",
|
441 |
+
" width: 1rem;\n",
|
442 |
+
" text-decoration: none;\n",
|
443 |
+
" /* unfitted */\n",
|
444 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
445 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
446 |
+
"}\n",
|
447 |
+
"\n",
|
448 |
+
"#sk-container-id-1 a.estimator_doc_link.fitted {\n",
|
449 |
+
" /* fitted */\n",
|
450 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
451 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
452 |
+
"}\n",
|
453 |
+
"\n",
|
454 |
+
"/* On hover */\n",
|
455 |
+
"#sk-container-id-1 a.estimator_doc_link:hover {\n",
|
456 |
+
" /* unfitted */\n",
|
457 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
458 |
+
" color: var(--sklearn-color-background);\n",
|
459 |
+
" text-decoration: none;\n",
|
460 |
+
"}\n",
|
461 |
+
"\n",
|
462 |
+
"#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
|
463 |
+
" /* fitted */\n",
|
464 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
465 |
+
"}\n",
|
466 |
+
"</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>PySRRegressor.equations_ = None</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow \"> PySRRegressor<span class=\"sk-estimator-doc-link \">i<span>Not fitted</span></span></label><div class=\"sk-toggleable__content \"><pre>PySRRegressor.equations_ = None</pre></div> </div></div></div></div>"
|
467 |
+
],
|
468 |
+
"text/plain": [
|
469 |
+
"PySRRegressor.equations_ = None"
|
470 |
+
]
|
471 |
+
},
|
472 |
+
"execution_count": 4,
|
473 |
+
"metadata": {},
|
474 |
+
"output_type": "execute_result"
|
475 |
+
}
|
476 |
+
],
|
477 |
+
"source": [
|
478 |
+
"rstate = np.random.RandomState(0)\n",
|
479 |
+
"X = np.random.randn(10, 2)\n",
|
480 |
+
"y = np.random.randn(10)\n",
|
481 |
+
"\n",
|
482 |
+
"model = PySRRegressor(deterministic=True, multithreading=False, procs=0, random_state=0, verbosity=0, progress=False)\n",
|
483 |
+
"model"
|
484 |
+
]
|
485 |
+
},
|
486 |
+
{
|
487 |
+
"cell_type": "code",
|
488 |
+
"execution_count": 5,
|
489 |
+
"metadata": {},
|
490 |
+
"outputs": [
|
491 |
+
{
|
492 |
+
"name": "stderr",
|
493 |
+
"output_type": "stream",
|
494 |
+
"text": [
|
495 |
+
"/Users/mcranmer/PermaDocuments/SymbolicRegressionMonorepo/.venv/lib/python3.12/site-packages/pysr/sr.py:1297: UserWarning: Note: it looks like you are running in Jupyter. The progress bar will be turned off.\n",
|
496 |
+
" warnings.warn(\n"
|
497 |
+
]
|
498 |
+
},
|
499 |
+
{
|
500 |
+
"data": {
|
501 |
+
"text/plain": [
|
502 |
+
"pandas.core.frame.DataFrame"
|
503 |
+
]
|
504 |
+
},
|
505 |
+
"execution_count": 5,
|
506 |
+
"metadata": {},
|
507 |
+
"output_type": "execute_result"
|
508 |
+
}
|
509 |
+
],
|
510 |
+
"source": [
|
511 |
+
"model.fit(X, y)\n",
|
512 |
+
"type(model.equations_)"
|
513 |
+
]
|
514 |
+
}
|
515 |
+
],
|
516 |
+
"metadata": {
|
517 |
+
"kernelspec": {
|
518 |
+
"display_name": "Python 3 (ipykernel)",
|
519 |
+
"language": "python",
|
520 |
+
"name": "python3"
|
521 |
+
},
|
522 |
+
"language_info": {
|
523 |
+
"codemirror_mode": {
|
524 |
+
"name": "ipython",
|
525 |
+
"version": 3
|
526 |
+
},
|
527 |
+
"file_extension": ".py",
|
528 |
+
"mimetype": "text/x-python",
|
529 |
+
"name": "python",
|
530 |
+
"nbconvert_exporter": "python",
|
531 |
+
"pygments_lexer": "ipython3",
|
532 |
+
"version": "3.12.0"
|
533 |
+
}
|
534 |
+
},
|
535 |
+
"nbformat": 4,
|
536 |
+
"nbformat_minor": 2
|
537 |
+
}
|
pysr/test/test_startup.py
CHANGED
@@ -127,6 +127,19 @@ class TestStartup(unittest.TestCase):
|
|
127 |
)
|
128 |
self.assertIn(warning_test["msg"], result.stderr.decode())
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
def runtests():
|
132 |
suite = unittest.TestSuite()
|
|
|
127 |
)
|
128 |
self.assertIn(warning_test["msg"], result.stderr.decode())
|
129 |
|
130 |
+
def test_notebook(self):
|
131 |
+
result = subprocess.run(
|
132 |
+
[
|
133 |
+
sys.executable,
|
134 |
+
"-m",
|
135 |
+
"pytest",
|
136 |
+
"--nbval",
|
137 |
+
str(Path(__file__).parent / "test_nb.ipynb"),
|
138 |
+
],
|
139 |
+
env=os.environ,
|
140 |
+
)
|
141 |
+
self.assertEqual(result.returncode, 0)
|
142 |
+
|
143 |
|
144 |
def runtests():
|
145 |
suite = unittest.TestSuite()
|