Skip to content

Commit 678b953

Browse files
committed
Merge pull request #18 from Machine-Learning-Dynamical-Systems/refactor
Version 2.0.0.rc1 Closes #16
2 parents ca71864 + b09c891 commit 678b953

File tree

184 files changed

+23871
-16603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+23871
-16603
lines changed

.github/workflows/CI.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
types: [opened, reopened, synchronize]
11+
schedule:
12+
# Weekly tests run on main by default:
13+
# Scheduled workflows run on the latest commit on the default or base branch.
14+
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
15+
- cron: "0 2 * * 1"
16+
workflow_dispatch:
17+
18+
jobs:
19+
test:
20+
name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, macos-latest, windows-latest]
25+
python-version: ["3.10", "3.11", "3.12", "3.13"]
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Additional info about the build
31+
shell: bash
32+
run: |
33+
uname -a
34+
df -h
35+
ulimit -a
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v6
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install the project
43+
run: uv sync --locked --all-extras --all-groups
44+
45+
- name: Run tests
46+
# For example, using `pytest`
47+
run: uv run pytest --color=yes tests/

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Publish"
2+
3+
on:
4+
push:
5+
tags:
6+
# Publish on any tag starting with a `v`, e.g., v0.1.0
7+
- v*
8+
9+
jobs:
10+
run:
11+
runs-on: ubuntu-latest
12+
environment:
13+
name: pypi
14+
permissions:
15+
id-token: write
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v6
22+
- name: Install Python 3.13
23+
run: uv python install 3.13
24+
- name: Build
25+
run: uv build
26+
- name: Publish
27+
run: uv publish

.github/workflows/tests.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ share/python-wheels/
2626
.installed.cfg
2727
*.egg
2828
MANIFEST
29+
__legacy/
2930

3031
# PyInstaller
3132
# Usually these files are written by a python script from a template

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

.readthedocs.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
version: 2
22

3-
build:
4-
os: ubuntu-22.04
5-
tools:
6-
python: "3.11"
7-
83
sphinx:
94
configuration: docs/conf.py
105

11-
python:
12-
install:
13-
- requirements: docs/requirements.txt
6+
build:
7+
os: ubuntu-24.04
8+
tools:
9+
python: "3.13"
10+
jobs:
11+
pre_create_environment:
12+
- asdf plugin add uv
13+
- asdf install uv latest
14+
- asdf global uv latest
15+
create_environment:
16+
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
17+
install:
18+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --locked --all-extras --all-groups

CONTIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Release Process (Maintainers Only)
2+
3+
We use [Semantic Versioning](https://semver.org/). Releases are automated via the `release.sh` script found in the root directory.
4+
5+
Ensure your git status is clean and you are on `main`, then run:
6+
7+
```bash
8+
# Usage: ./release.sh <patch|minor|major|alpha|beta|stable>
9+
./release.sh patch
10+
```

README.md

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,69 @@
1-
<p align = "left">
2-
<img src="logo.svg" alt="SVG Image" style="width:50%;"/>
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="logo-dark.png">
4+
<source media="(prefers-color-scheme: light)" srcset="logo-light.png">
5+
<img alt="kooplearn logo" width="60%" src="logo-light.png">
6+
</picture>
37
</p>
48

5-
# Learn Koopman and Transfer operators for Dynamical Systems and Stochastic Processes
9+
<a href="https://kooplearn.readthedocs.io/latest/"><img alt="Static Badge" src="https://img.shields.io/badge/Documentation-informational"></a>
10+
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Machine-Learning-Dynamical-Systems/kooplearn/CI.yml)
11+
![GitHub License](https://img.shields.io/github/license/Machine-Learning-Dynamical-Systems/kooplearn)
612

7-
`kooplearn` is a Python library designed for learning Koopman or Transfer operators associated with dynamical systems. Given a _nonlinear_ dynamical system $x_{t + 1} = S(x_{t})$, the **Koopman operator** provides a _global linearization_ of the dynamics by mapping it to a suitable space of observables $\mathcal{F}$. An observable is any (scalar) function of the state. The Koopman operator $\mathsf{K}$ is defined as $$(\mathsf{K}f)(x_{t}) = f(x_{t + 1}) := f \circ S (x_t) \qquad f \in \mathcal{F}.$$
8-
Similarly, given a stochastic process $X:= \{ X_{s} \colon s \in \mathbb{N}\}$, its **Transfer operator* returns the expected value of any observable forward in time. The Transfer operator $\mathsf{T}$ is defined as $$(\mathsf{T}f)(x) := \mathbb{E}\left[f(X_{t + 1}) \mid X_{t} = x \right] \qquad f \in \mathcal{F}.$$
913

10-
`kooplearn` provides a suite of algorithms for model training and analysis, enabling users to perform forecasting, spectral decomposition, and modal decomposition based on the learned operator.
14+
`kooplearn` is a Python library to learn evolution operators — also known as _Koopman_ or _Transfer_ operators — from data. `kooplearn` models can:
1115

12-
Please note that `kooplearn` is currently under active development, and while we are continuously adding new features and improvements, some parts of the library might still be a work in progress.
16+
1. Predict the evolution of states *and* observables.
17+
2. Estimate the eigenvalues and eigenfunctions of the learned evolution operators.
18+
3. Compute the [dynamic mode decomposition](https://en.wikipedia.org/wiki/Dynamic_mode_decomposition) of states *and* observables.
19+
4. Learn neural-network representations $x_t \mapsto \varphi(x_t)$ for evolution operators.
1320

14-
## Features
21+
## Why Choosing `kooplearn`?
22+
23+
1. It is easy to use and strictly adheres to the [scikit-learn API](https://scikit-learn.org/stable/api/index.html).
24+
2. **Kernel estimators** are state-of-the-art:
25+
26+
* `kooplearn` implements the *Reduced Rank Regressor* from [Kostic et al. 2022](https://arxiv.org/abs/2205.14027), which is [provably better](https://arxiv.org/abs/2302.02004) than the classical [kernel DMD](https://arxiv.org/abs/1411.2260) in estimating eigenvalues and eigenfunctions.
27+
* It also implements [Nyström estimators](https://arxiv.org/abs/2306.04520) and randomized estimators [randomized](https://arxiv.org/abs/2312.17348) for blazingly fast kernel learning.
28+
3. Includes representation-learning losses (implemented both in Pytorch and JAX) to train neural-network Koopman embeddings.
29+
4. Offers a collection of datasets for benchmarking evolution-operator learning algorithms.
1530

16-
- Implement different algorithms to learn Koopman or transfer operators for dynamical systems.
17-
- Perform forecasting using the learned operators.
18-
- Conduct spectral decomposition of the learned operator.
19-
- Perform modal decomposition for further analysis.
20-
2131
## Installation
22-
To install the core version of `kooplearn`, without optional dependencies, run
32+
33+
To install the core version of `kooplearn`:
34+
35+
### **pip**
36+
2337
```bash
24-
pip install kooplearn
38+
pip install kooplearn
2539
```
26-
To install the full version of `kooplearn`, including Neural-Network models, and the dahsboard, run
40+
41+
### **uv**
42+
2743
```bash
28-
pip install "kooplearn[full]"
44+
uv add kooplearn
2945
```
30-
To install the development version of `kooplearn`, run
46+
47+
To enable neural-network representations using `kooplearn.torch` or `kooplearn.jax`:
48+
49+
### **pip**
50+
3151
```bash
32-
pip install --upgrade git+https://github.com/Machine-Learning-Dynamical-Systems/kooplearn.git
52+
# Torch
53+
pip install "kooplearn[torch]"
54+
# JAX
55+
pip install "kooplearn[jax]"
3356
```
57+
58+
### **uv**
59+
60+
```bash
61+
# Torch
62+
uv add "kooplearn[torch]"
63+
# JAX
64+
uv add "kooplearn[jax]"
65+
```
66+
3467
## Contributing
3568

3669
We welcome contributions from the community! If you're interested in contributing to `kooplearn`, please follow these steps:

0 commit comments

Comments
 (0)