Skip to content

Commit 0a133c9

Browse files
committed
Merge branch 'master' into fix-cluster-manager
2 parents d0593b1 + 0f448b5 commit 0a133c9

13 files changed

+421
-107
lines changed

.github/workflows/CI_conda_forge.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,12 @@ jobs:
1616
timeout-minutes: 60
1717
defaults:
1818
run:
19-
shell: bash -l {0}
19+
shell: bash -el {0}
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: ['3.10', '3.11', '3.12']
24-
os: ['ubuntu-latest']
25-
use-mamba: [true, false]
26-
include:
27-
- python-version: '3.10'
28-
os: 'windows-latest'
29-
use-mamba: true
30-
- python-version: '3.12'
31-
os: 'windows-latest'
32-
use-mamba: true
33-
- python-version: '3.10'
34-
os: 'macos-latest'
35-
use-mamba: true
36-
- python-version: '3.12'
37-
os: 'macos-latest'
38-
use-mamba: true
23+
python-version: ['3.10', '3']
24+
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
3925

4026
steps:
4127
- name: "Set up Conda"
@@ -46,13 +32,14 @@ jobs:
4632
auto-activate-base: true
4733
python-version: ${{ matrix.python-version }}
4834
activate-environment: pysr-test
49-
- name: "Install pysr with mamba"
50-
run: conda activate pysr-test && mamba install pysr
51-
if: ${{ matrix.use-mamba }}
52-
- name: "Install pysr with conda"
53-
run: conda activate pysr-test && conda install pysr
54-
if: ${{ !matrix.use-mamba }}
35+
- name: "Install pysr"
36+
run: |
37+
conda install -y pysr
38+
python -c "import pysr"
39+
echo "Finished."
5540
- name: "Run tests"
5641
run: |
42+
echo "Running tests"
5743
pip install pytest nbval
5844
python -m pysr test main,startup
45+
echo "Finished."

.github/workflows/update_backend_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
major, minor, patch, *dev = pyproject_data["project"]["version"].split(".")
2121
pyproject_data["project"]["version"] = f"{major}.{minor}.{int(patch)+1}"
2222

23-
juliapkg_data["packages"]["SymbolicRegression"]["version"] = f"={new_backend_version}"
23+
juliapkg_data["packages"]["SymbolicRegression"]["version"] = f"~{new_backend_version}"
2424

2525
with open(pyproject_toml, "w") as toml_file:
2626
toml_file.write(tomlkit.dumps(pyproject_data))

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ repos:
99
- id: check-added-large-files
1010
# General formatting
1111
- repo: https://github.com/psf/black
12-
rev: 24.10.0
12+
rev: 25.1.0
1313
hooks:
1414
- id: black
1515
- id: black-jupyter
1616
exclude: pysr/test/test_nb.ipynb
1717
# Stripping notebooks
1818
- repo: https://github.com/kynan/nbstripout
19-
rev: 0.8.0
19+
rev: 0.8.1
2020
hooks:
2121
- id: nbstripout
2222
exclude: pysr/test/test_nb.ipynb
2323
# Unused imports
2424
- repo: https://github.com/hadialqattan/pycln
25-
rev: "v2.4.0"
25+
rev: "v2.5.0"
2626
hooks:
2727
- id: pycln
2828
# Sorted imports
2929
- repo: https://github.com/PyCQA/isort
30-
rev: "5.13.2"
30+
rev: "6.0.0"
3131
hooks:
3232
- id: isort
3333
additional_dependencies: [toml]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If you've finished a project with PySR, please submit a PR to showcase your work
2727
- [Why PySR?](#why-pysr)
2828
- [Installation](#installation)
2929
- [Quickstart](#quickstart)
30-
- [→ Documentation](https://ai.damtp.cam.ac.uk/PySR)
30+
- [→ Documentation](https://ai.damtp.cam.ac.uk/pysr)
3131
- [Contributors](#contributors-)
3232

3333
<div align="center">

docs/examples.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,9 @@ y = np.sin(X[:, 0] + X[:, 1]) + X[:, 2]**2
546546

547547
# Define template: we want sin(f(x1, x2)) + g(x3)
548548
template = TemplateExpressionSpec(
549-
function_symbols=["f", "g"],
550-
combine="((; f, g), (x1, x2, x3)) -> sin(f(x1, x2)) + g(x3)",
549+
expressions=["f", "g"],
550+
variable_names=["x1", "x2", "x3"],
551+
combine="sin(f(x1, x2)) + g(x3)",
551552
)
552553

553554
model = PySRRegressor(
@@ -559,15 +560,23 @@ model = PySRRegressor(
559560
model.fit(X, y)
560561
```
561562

562-
You can also use no argument-functions for learning constants, like:
563+
You can also use parameters in your template expressions, which will be optimized during the search:
563564

564565
```python
565566
template = TemplateExpressionSpec(
566-
function_symbols=["a", "f"],
567-
combine="((; a, f), (x, y)) -> a() * sin(f(x, y))",
567+
expressions=["f", "g"],
568+
variable_names=["x1", "x2", "x3"],
569+
parameters={"p1": 2, "p2": 1}, # p1 has length 2, p2 has length 1
570+
combine="p1[1] * sin(f(x1, x2)) + p1[2] * g(x3) + p2[1]",
568571
)
569572
```
570573

574+
This will learn an equation of the form:
575+
576+
$$ y = \alpha_1 \sin(f(x_1, x_2)) + \alpha_2 g(x_3) + \beta $$
577+
578+
where $\alpha_1, \alpha_2$ are stored in `p1` and $\beta$ is stored in `p2`. The parameters will be optimized during the search.
579+
571580
### Parametric Expressions
572581

573582
When your data has categories with shared equation structure but different parameters,
@@ -609,6 +618,20 @@ model.fit(X, y, category=category)
609618

610619
See [Expression Specifications](/api/#expression-specifications) for more details.
611620

621+
You can also use `TemplateExpressionSpec` in the same way, passing
622+
the category as a column of `X`:
623+
624+
```python
625+
spec = TemplateExpressionSpec(
626+
expressions=["f", "g"],
627+
variable_names=["x1", "x2", "class"],
628+
combine="p1[class] * sin(f(x1, x2)) + p2[class]",
629+
)
630+
```
631+
632+
this column will automatically be converted to integers.
633+
634+
612635
## 12. Using TensorBoard for Logging
613636

614637
You can use TensorBoard to visualize the search progress, as well as

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pysr"
7-
version = "1.3.1"
7+
version = "1.5.0"
88
authors = [
99
{name = "Miles Cranmer", email = "[email protected]"},
1010
]
@@ -22,7 +22,7 @@ dependencies = [
2222
"pandas>=0.21.0,<3.0.0",
2323
"numpy>=1.13.0,<3.0.0",
2424
"scikit_learn>=1.0.0,<2.0.0",
25-
"juliacall==0.9.23",
25+
"juliacall==0.9.24",
2626
"click>=7.0.0,<9.0.0",
2727
"setuptools>=50.0.0",
2828
]

pysr/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import logging
12
import os
23

4+
pysr_logger = logging.getLogger("pysr")
5+
pysr_logger.setLevel(logging.INFO)
6+
handler = logging.StreamHandler()
7+
handler.setLevel(logging.INFO)
8+
pysr_logger.addHandler(handler)
9+
310
if os.environ.get("PYSR_USE_BEARTYPE", "0") == "1":
411
from beartype.claw import beartype_this_package
512

0 commit comments

Comments
 (0)