Spaces:
Sleeping
Sleeping
Merge pull request #497 from MilesCranmer/fix-older-python
Browse filesInstall `typing_extensions` for compatibility with Python 3.7
- .github/workflows/CI.yml +29 -9
- .github/workflows/CI_Windows.yml +2 -2
- .github/workflows/CI_docker_large_nightly.yml +1 -1
- .github/workflows/CI_mac.yml +2 -2
- .github/workflows/docker_deploy.yml +2 -2
- Dockerfile +2 -2
- pysr/export_latex.py +1 -1
- pysr/sr.py +6 -1
- requirements.txt +1 -0
- setup.py +1 -1
.github/workflows/CI.yml
CHANGED
|
@@ -29,9 +29,15 @@ jobs:
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
-
julia-version: ['1
|
| 33 |
-
python-version: ['3.
|
| 34 |
os: [ubuntu-latest]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
steps:
|
| 37 |
- uses: actions/checkout@v3
|
|
@@ -63,18 +69,22 @@ jobs:
|
|
| 63 |
coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test cli
|
| 64 |
- name: "Install JAX"
|
| 65 |
run: pip install jax jaxlib # (optional import)
|
|
|
|
| 66 |
- name: "Run JAX tests"
|
| 67 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test jax
|
|
|
|
| 68 |
- name: "Install Torch"
|
| 69 |
run: pip install torch # (optional import)
|
|
|
|
| 70 |
- name: "Run Torch tests"
|
| 71 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test torch
|
|
|
|
| 72 |
- name: "Run custom env tests"
|
| 73 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test env
|
| 74 |
- name: "Coveralls"
|
| 75 |
env:
|
| 76 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 77 |
-
COVERALLS_FLAG_NAME: test-${{ matrix.
|
| 78 |
COVERALLS_PARALLEL: true
|
| 79 |
run: coveralls --service=github
|
| 80 |
|
|
@@ -94,7 +104,7 @@ jobs:
|
|
| 94 |
shell: bash -l {0}
|
| 95 |
strategy:
|
| 96 |
matrix:
|
| 97 |
-
python-version: ['3.
|
| 98 |
os: ['ubuntu-latest']
|
| 99 |
|
| 100 |
steps:
|
|
@@ -152,7 +162,10 @@ jobs:
|
|
| 152 |
shell: bash -l {0}
|
| 153 |
strategy:
|
| 154 |
matrix:
|
| 155 |
-
python-version:
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
steps:
|
| 158 |
- uses: actions/checkout@v3
|
|
@@ -164,8 +177,15 @@ jobs:
|
|
| 164 |
- name: "Install PySR and all dependencies"
|
| 165 |
run: |
|
| 166 |
python -m pip install --upgrade pip
|
| 167 |
-
pip install -r requirements.txt
|
| 168 |
-
pip install mypy
|
| 169 |
-
python
|
|
|
|
|
|
|
|
|
|
| 170 |
- name: "Run mypy"
|
| 171 |
-
run: mypy --install-types --non-interactive pysr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
+
julia-version: ['1']
|
| 33 |
+
python-version: ['3.11']
|
| 34 |
os: [ubuntu-latest]
|
| 35 |
+
test-id: [main]
|
| 36 |
+
include:
|
| 37 |
+
- julia-version: '1.6'
|
| 38 |
+
python-version: '3.7'
|
| 39 |
+
os: ubuntu-latest
|
| 40 |
+
test-id: include
|
| 41 |
|
| 42 |
steps:
|
| 43 |
- uses: actions/checkout@v3
|
|
|
|
| 69 |
coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test cli
|
| 70 |
- name: "Install JAX"
|
| 71 |
run: pip install jax jaxlib # (optional import)
|
| 72 |
+
if: ${{ matrix.test-id == 'main' }}
|
| 73 |
- name: "Run JAX tests"
|
| 74 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test jax
|
| 75 |
+
if: ${{ matrix.test-id == 'main' }}
|
| 76 |
- name: "Install Torch"
|
| 77 |
run: pip install torch # (optional import)
|
| 78 |
+
if: ${{ matrix.test-id == 'main' }}
|
| 79 |
- name: "Run Torch tests"
|
| 80 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test torch
|
| 81 |
+
if: ${{ matrix.test-id == 'main' }}
|
| 82 |
- name: "Run custom env tests"
|
| 83 |
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test env
|
| 84 |
- name: "Coveralls"
|
| 85 |
env:
|
| 86 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 87 |
+
COVERALLS_FLAG_NAME: test-${{ matrix.julia-version }}-${{ matrix.python-version }}
|
| 88 |
COVERALLS_PARALLEL: true
|
| 89 |
run: coveralls --service=github
|
| 90 |
|
|
|
|
| 104 |
shell: bash -l {0}
|
| 105 |
strategy:
|
| 106 |
matrix:
|
| 107 |
+
python-version: ['3.11']
|
| 108 |
os: ['ubuntu-latest']
|
| 109 |
|
| 110 |
steps:
|
|
|
|
| 162 |
shell: bash -l {0}
|
| 163 |
strategy:
|
| 164 |
matrix:
|
| 165 |
+
python-version:
|
| 166 |
+
- '3.11'
|
| 167 |
+
- '3.7'
|
| 168 |
+
os: ['ubuntu-latest']
|
| 169 |
|
| 170 |
steps:
|
| 171 |
- uses: actions/checkout@v3
|
|
|
|
| 177 |
- name: "Install PySR and all dependencies"
|
| 178 |
run: |
|
| 179 |
python -m pip install --upgrade pip
|
| 180 |
+
python -m pip install -r requirements.txt
|
| 181 |
+
python -m pip install mypy
|
| 182 |
+
python -m pip install .
|
| 183 |
+
- name: "Install additional dependencies"
|
| 184 |
+
run: python -m pip install jax jaxlib torch
|
| 185 |
+
if: ${{ matrix.python-version != '3.7' }}
|
| 186 |
- name: "Run mypy"
|
| 187 |
+
run: python -m mypy --install-types --non-interactive pysr
|
| 188 |
+
if: ${{ matrix.python-version != '3.7' }}
|
| 189 |
+
- name: "Run compatible mypy"
|
| 190 |
+
run: python -m mypy --ignore-missing-imports pysr
|
| 191 |
+
if: ${{ matrix.python-version == '3.7' }}
|
.github/workflows/CI_Windows.yml
CHANGED
|
@@ -29,8 +29,8 @@ jobs:
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
-
julia-version: ['1
|
| 33 |
-
python-version: ['3.
|
| 34 |
os: [windows-latest]
|
| 35 |
|
| 36 |
steps:
|
|
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
+
julia-version: ['1']
|
| 33 |
+
python-version: ['3.11']
|
| 34 |
os: [windows-latest]
|
| 35 |
|
| 36 |
steps:
|
.github/workflows/CI_docker_large_nightly.yml
CHANGED
|
@@ -18,7 +18,7 @@ jobs:
|
|
| 18 |
strategy:
|
| 19 |
fail-fast: false
|
| 20 |
matrix:
|
| 21 |
-
julia-version: ['1.6', '1
|
| 22 |
python-version: ['3.10']
|
| 23 |
os: [ubuntu-latest]
|
| 24 |
arch: ['linux/amd64', 'linux/arm64']
|
|
|
|
| 18 |
strategy:
|
| 19 |
fail-fast: false
|
| 20 |
matrix:
|
| 21 |
+
julia-version: ['1.6', '1']
|
| 22 |
python-version: ['3.10']
|
| 23 |
os: [ubuntu-latest]
|
| 24 |
arch: ['linux/amd64', 'linux/arm64']
|
.github/workflows/CI_mac.yml
CHANGED
|
@@ -29,8 +29,8 @@ jobs:
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
-
julia-version: ['1
|
| 33 |
-
python-version: ['3.
|
| 34 |
os: [macos-latest]
|
| 35 |
|
| 36 |
steps:
|
|
|
|
| 29 |
shell: bash
|
| 30 |
strategy:
|
| 31 |
matrix:
|
| 32 |
+
julia-version: ['1']
|
| 33 |
+
python-version: ['3.11']
|
| 34 |
os: [macos-latest]
|
| 35 |
|
| 36 |
steps:
|
.github/workflows/docker_deploy.yml
CHANGED
|
@@ -18,8 +18,8 @@ jobs:
|
|
| 18 |
matrix:
|
| 19 |
os: [ubuntu-latest]
|
| 20 |
arch: [linux/amd64]
|
| 21 |
-
python-version: [3.
|
| 22 |
-
julia-version: [1.
|
| 23 |
steps:
|
| 24 |
- name: Checkout
|
| 25 |
uses: actions/checkout@v3
|
|
|
|
| 18 |
matrix:
|
| 19 |
os: [ubuntu-latest]
|
| 20 |
arch: [linux/amd64]
|
| 21 |
+
python-version: [3.11.6]
|
| 22 |
+
julia-version: [1.9.4]
|
| 23 |
steps:
|
| 24 |
- name: Checkout
|
| 25 |
uses: actions/checkout@v3
|
Dockerfile
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# This builds a dockerfile containing a working copy of PySR
|
| 2 |
# with all pre-requisites installed.
|
| 3 |
|
| 4 |
-
ARG JLVERSION=1.9.
|
| 5 |
-
ARG PYVERSION=3.
|
| 6 |
ARG BASE_IMAGE=bullseye
|
| 7 |
|
| 8 |
FROM julia:${JLVERSION}-${BASE_IMAGE} AS jl
|
|
|
|
| 1 |
# This builds a dockerfile containing a working copy of PySR
|
| 2 |
# with all pre-requisites installed.
|
| 3 |
|
| 4 |
+
ARG JLVERSION=1.9.4
|
| 5 |
+
ARG PYVERSION=3.11.6
|
| 6 |
ARG BASE_IMAGE=bullseye
|
| 7 |
|
| 8 |
FROM julia:${JLVERSION}-${BASE_IMAGE} AS jl
|
pysr/export_latex.py
CHANGED
|
@@ -23,7 +23,7 @@ def sympy2latex(expr, prec=3, full_prec=True, **settings) -> str:
|
|
| 23 |
"""Convert sympy expression to LaTeX with custom precision."""
|
| 24 |
settings["full_prec"] = full_prec
|
| 25 |
printer = PreciseLatexPrinter(settings=settings, prec=prec)
|
| 26 |
-
return printer.doprint(expr)
|
| 27 |
|
| 28 |
|
| 29 |
def generate_table_environment(
|
|
|
|
| 23 |
"""Convert sympy expression to LaTeX with custom precision."""
|
| 24 |
settings["full_prec"] = full_prec
|
| 25 |
printer = PreciseLatexPrinter(settings=settings, prec=prec)
|
| 26 |
+
return str(printer.doprint(expr))
|
| 27 |
|
| 28 |
|
| 29 |
def generate_table_environment(
|
pysr/sr.py
CHANGED
|
@@ -11,7 +11,12 @@ from datetime import datetime
|
|
| 11 |
from io import StringIO
|
| 12 |
from multiprocessing import cpu_count
|
| 13 |
from pathlib import Path
|
| 14 |
-
from typing import Callable, Dict, List,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
import numpy as np
|
| 17 |
import pandas as pd
|
|
|
|
| 11 |
from io import StringIO
|
| 12 |
from multiprocessing import cpu_count
|
| 13 |
from pathlib import Path
|
| 14 |
+
from typing import Callable, Dict, List, Optional, Tuple, Union
|
| 15 |
+
|
| 16 |
+
if sys.version_info >= (3, 8):
|
| 17 |
+
from typing import Literal
|
| 18 |
+
else:
|
| 19 |
+
from typing_extensions import Literal
|
| 20 |
|
| 21 |
import numpy as np
|
| 22 |
import pandas as pd
|
requirements.txt
CHANGED
|
@@ -5,3 +5,4 @@ scikit_learn>=1.0.0
|
|
| 5 |
julia>=0.6.0
|
| 6 |
click>=7.0.0
|
| 7 |
setuptools>=50.0.0
|
|
|
|
|
|
| 5 |
julia>=0.6.0
|
| 6 |
click>=7.0.0
|
| 7 |
setuptools>=50.0.0
|
| 8 |
+
typing_extensions>=4.0.0,<5.0.0; python_version < "3.8"
|
setup.py
CHANGED
|
@@ -26,5 +26,5 @@ setuptools.setup(
|
|
| 26 |
"Programming Language :: Python :: 3",
|
| 27 |
"Operating System :: OS Independent",
|
| 28 |
],
|
| 29 |
-
python_requires=">=3.
|
| 30 |
)
|
|
|
|
| 26 |
"Programming Language :: Python :: 3",
|
| 27 |
"Operating System :: OS Independent",
|
| 28 |
],
|
| 29 |
+
python_requires=">=3.7",
|
| 30 |
)
|