Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
python-version: '3.12'
os: ubuntu-latest
test-id: include
- julia-version: '1'
python-version: '3.8'
os: ubuntu-latest
test-id: include

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
description = "Simple and efficient symbolic regression"
readme = {file = "README.md", content-type = "text/markdown"}
license = {file = "LICENSE"}
requires-python = ">=3.10"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
Expand Down Expand Up @@ -39,7 +39,7 @@ dev = [
"mypy>=1,<2",
"nbval>=0.11,<0.12",
"pandas-stubs",
"pre-commit>=3.7,<5",
"pre-commit>=3.0,<5",
"pytest-cov>=5,<7",
"pytest>=8,<9",
"tensorboard>=2,<3",
Expand Down
2 changes: 2 additions & 0 deletions pysr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import os

Expand Down
2 changes: 2 additions & 0 deletions pysr/denoising.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Functions for denoising data during preprocessing."""

from __future__ import annotations

from typing import cast

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions pysr/export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import copy
from collections.abc import Callable

Expand Down
2 changes: 2 additions & 0 deletions pysr/export_latex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Functions to help export PySR equations to LaTeX."""

from __future__ import annotations

import pandas as pd
import sympy # type: ignore
from sympy.printing.latex import LatexPrinter # type: ignore
Expand Down
2 changes: 2 additions & 0 deletions pysr/export_numpy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Code for exporting discovered expressions to numpy"""

from __future__ import annotations

import warnings

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions pysr/export_sympy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Define utilities to export to sympy"""

from __future__ import annotations

from collections.abc import Callable

import sympy # type: ignore
Expand Down
9 changes: 8 additions & 1 deletion pysr/expression_specs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import copy
from abc import ABC, abstractmethod
from textwrap import dedent
from typing import TYPE_CHECKING, Any, NewType, TypeAlias, overload
from typing import TYPE_CHECKING, Any, NewType, overload

import numpy as np
import pandas as pd
Expand All @@ -10,6 +12,11 @@
from .julia_helpers import jl_array
from .julia_import import AnyValue, SymbolicRegression, jl

try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias

# For type checking purposes
if TYPE_CHECKING:
from .sr import PySRRegressor # pragma: no cover
Expand Down
2 changes: 2 additions & 0 deletions pysr/feature_selection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Functions for doing feature selection during preprocessing."""

from __future__ import annotations

import logging
from typing import cast

Expand Down
2 changes: 2 additions & 0 deletions pysr/julia_extensions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""This file installs and loads extensions for SymbolicRegression."""

from __future__ import annotations

from typing import Literal

from .julia_import import Pkg, jl
Expand Down
2 changes: 2 additions & 0 deletions pysr/julia_registry_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Utilities for managing Julia registry preferences during package operations."""

from __future__ import annotations

import os
import warnings
from collections.abc import Callable
Expand Down
2 changes: 2 additions & 0 deletions pysr/logger_specs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any
Expand Down
12 changes: 7 additions & 5 deletions pysr/sr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Define the PySRRegressor scikit-learn interface."""

from __future__ import annotations

import copy
import logging
import os
Expand All @@ -13,7 +15,7 @@
from io import StringIO
from multiprocessing import cpu_count
from pathlib import Path
from typing import Any, Literal, cast
from typing import Any, List, Literal, Tuple, Union, cast

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -94,7 +96,7 @@ def _process_constraints(
)
constraints[op] = (-1, -1)

constraint_tuple = cast(tuple[int, int], constraints[op])
constraint_tuple = cast(Tuple[int, int], constraints[op])
if op in ["plus", "sub", "+", "-"]:
if constraint_tuple[0] != constraint_tuple[1]:
raise NotImplementedError(
Expand Down Expand Up @@ -1313,7 +1315,7 @@ def julia_options_(self):
def julia_state_(self):
"""The deserialized state."""
return cast(
tuple[VectorValue, AnyValue] | None,
Union[Tuple[VectorValue, AnyValue], None],
jl_deserialize(self.julia_state_stream_),
)

Expand Down Expand Up @@ -1640,7 +1642,7 @@ def _validate_data_X_y(self, X: Any, y: Any) -> tuple[ndarray, ndarray]:
raw_out = self._validate_data(X=X, y=y, reset=True, multi_output=True) # type: ignore
else:
raw_out = validate_data(self, X=X, y=y, reset=True, multi_output=True) # type: ignore
return cast(tuple[ndarray, ndarray], raw_out)
return cast(Tuple[ndarray, ndarray], raw_out)

def _validate_data_X(self, X: Any) -> ndarray:
if OLD_SKLEARN:
Expand Down Expand Up @@ -2629,7 +2631,7 @@ def get_hof(self, search_output=None) -> pd.DataFrame | list[pd.DataFrame]:

_validate_export_mappings(self.extra_jax_mappings, self.extra_torch_mappings)

equation_file_contents = cast(list[pd.DataFrame], self.equation_file_contents_)
equation_file_contents = cast(List[pd.DataFrame], self.equation_file_contents_)

ret_outputs = [
pd.concat(
Expand Down
6 changes: 3 additions & 3 deletions pysr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import inspect
import re
from pathlib import Path
from typing import Any, TypeVar
from typing import Any, List, TypeVar, Union

from numpy import ndarray
from sklearn.utils.validation import _check_feature_names_in # type: ignore

T = TypeVar("T", bound=Any)

ArrayLike = ndarray | list[T]
PathLike = str | Path
ArrayLike = Union[ndarray, List[T]]
PathLike = Union[str, Path]


_regexp_im = re.compile(r"\b(\d+\.\d+)im\b")
Expand Down
Loading