Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install typing_extensions for compatibility with Python 3.7 #497

Merged
merged 12 commits into from
Dec 31, 2023
38 changes: 29 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ jobs:
shell: bash
strategy:
matrix:
julia-version: ['1.9']
python-version: ['3.10']
julia-version: ['1']
python-version: ['3.11']
os: [ubuntu-latest]
test-id: [main]
include:
- julia-version: '1.6'
python-version: '3.7'
os: ubuntu-latest
test-id: include

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -63,18 +69,22 @@ jobs:
coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test cli
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run JAX tests"
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test jax
if: ${{ matrix.test-id == 'main' }}
- name: "Install Torch"
run: pip install torch # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run Torch tests"
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test torch
if: ${{ matrix.test-id == 'main' }}
- name: "Run custom env tests"
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test env
- name: "Coveralls"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: test-${{ matrix.test-name }}
COVERALLS_FLAG_NAME: test-${{ matrix.julia-version }}-${{ matrix.python-version }}
COVERALLS_PARALLEL: true
run: coveralls --service=github

Expand All @@ -94,7 +104,7 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ['3.9']
python-version: ['3.11']
os: ['ubuntu-latest']

steps:
Expand Down Expand Up @@ -152,7 +162,10 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ['3.10']
python-version:
- '3.11'
- '3.7'
os: ['ubuntu-latest']

steps:
- uses: actions/checkout@v3
Expand All @@ -164,8 +177,15 @@ jobs:
- name: "Install PySR and all dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install mypy jax jaxlib torch
python setup.py install
python -m pip install -r requirements.txt
python -m pip install mypy
python -m pip install .
- name: "Install additional dependencies"
run: python -m pip install jax jaxlib torch
if: ${{ matrix.python-version != '3.7' }}
- name: "Run mypy"
run: mypy --install-types --non-interactive pysr
run: python -m mypy --install-types --non-interactive pysr
if: ${{ matrix.python-version != '3.7' }}
- name: "Run compatible mypy"
run: python -m mypy --ignore-missing-imports pysr
if: ${{ matrix.python-version == '3.7' }}
4 changes: 2 additions & 2 deletions .github/workflows/CI_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
shell: bash
strategy:
matrix:
julia-version: ['1.9']
python-version: ['3.10']
julia-version: ['1']
python-version: ['3.11']
os: [windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI_docker_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.6', '1.9']
julia-version: ['1.6', '1']
python-version: ['3.10']
os: [ubuntu-latest]
arch: ['linux/amd64', 'linux/arm64']
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CI_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
shell: bash
strategy:
matrix:
julia-version: ['1.9']
python-version: ['3.10']
julia-version: ['1']
python-version: ['3.11']
os: [macos-latest]

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
matrix:
os: [ubuntu-latest]
arch: [linux/amd64]
python-version: [3.10.8]
julia-version: [1.8.2]
python-version: [3.11.6]
julia-version: [1.9.4]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This builds a dockerfile containing a working copy of PySR
# with all pre-requisites installed.

ARG JLVERSION=1.9.1
ARG PYVERSION=3.10.11
ARG JLVERSION=1.9.4
ARG PYVERSION=3.11.6
ARG BASE_IMAGE=bullseye

FROM julia:${JLVERSION}-${BASE_IMAGE} AS jl
Expand Down
2 changes: 1 addition & 1 deletion pysr/export_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def sympy2latex(expr, prec=3, full_prec=True, **settings) -> str:
"""Convert sympy expression to LaTeX with custom precision."""
settings["full_prec"] = full_prec
printer = PreciseLatexPrinter(settings=settings, prec=prec)
return printer.doprint(expr)
return str(printer.doprint(expr))


def generate_table_environment(
Expand Down
7 changes: 6 additions & 1 deletion pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from io import StringIO
from multiprocessing import cpu_count
from pathlib import Path
from typing import Callable, Dict, List, Literal, Optional, Tuple, Union
from typing import Callable, Dict, List, Optional, Tuple, Union

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ scikit_learn>=1.0.0
julia>=0.6.0
click>=7.0.0
setuptools>=50.0.0
typing_extensions>=4.0.0,<5.0.0; python_version < "3.8"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires=">=3.8",
python_requires=">=3.7",
)
Loading