Skip to content

Commit

Permalink
Merge branch 'master' into axesarray-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Jan 13, 2024
2 parents bb1c73d + 638e4bb commit 0bd7182
Show file tree
Hide file tree
Showing 273 changed files with 12,200 additions and 7,589 deletions.
4 changes: 0 additions & 4 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ import-order-style = smarkets
statistics = True
count = True
verbose = 1
# format = [%(code)s] %(text)s @ %(path)s:%(row)d:%(col)d

[codespell]
ignore-words-list = pres,nd
25 changes: 14 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
Linting:
Expand All @@ -11,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.9"
- name: Linting
run: |
pip install pre-commit
Expand All @@ -23,7 +29,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -33,28 +39,25 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements-dev.txt
pip install sympy # needed for notebook 9, but not required for pysindy
pip install --upgrade pip
pip install .[dev,miosr,cvxpy]
- name: Build the docs
# Not exactly how RTD does it, but close.
run: |
sudo apt-get update -y
sudo apt-get install pandoc
pip install .[docs]
cd docs
python -m sphinx -T -E -W -b html -d _build/doctrees . _build/html
cd ..
- name: Test with pytest
run: |
pytest test --cov=pysindy --cov-report=xml
coverage run --source=pysindy -m pytest test -m "not slow" && coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
- name: Execute feature notebook with papermill
run: |
pip install papermill
cd examples
papermill --report-mode 1_feature_overview.ipynb out.json
- uses: actions/cache@v3
with:
path: ~/.cache/pip
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install dependencies
run: pip install wheel
python-version: "3.9"
- name: Install Build
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py sdist bdist_wheel
run: python -m build .
- name: Upload package
uses: pypa/[email protected]
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ dist
*.egg-info
commit-msg
todo
poetry.lock

# profiling
prof/

# Environments
.env
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
rev: 5.0.4
hooks:
- id: flake8
args: ["--config=setup.cfg"]
args: ["--config=.flake8"]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
Expand All @@ -34,11 +34,12 @@ repos:
hooks:
- id: sphinx-lint
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.4
hooks:
- id: codespell
types_or: [python, rst, markdown]
args: ["-L hist"]
additional_dependencies: [tomli]
args: ["--toml", "pyproject.toml"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand Down
14 changes: 12 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ version: 2
sphinx:
configuration: docs/conf.py

build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python:
version: 3.8
install:
- requirements: requirements-dev.txt
- method: pip
path: .
extra_requirements:
- docs
- cvxpy
- miosr
- dev
70 changes: 53 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The approximation problem to be solved can then be compactly written as
Each row of this matrix equation corresponds to one coordinate function of ``f(x)``.
SINDy employs sparse regression techniques to find a solution ``Xi`` with sparse column vectors.
For a more in-depth look at the mathematical foundations of SINDy, please see our `introduction to SINDy <https://pysindy.readthedocs.io/en/latest/examples/2_introduction_to_sindy.html>`__.
For a more in-depth look at the mathematical foundations of SINDy, please see our `introduction to SINDy <https://pysindy.readthedocs.io/en/latest/examples/2_introduction_to_sindy/example.html>`__.

Relation to PySINDy
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -93,7 +93,7 @@ which prints the following
x' = -2.000 x
y' = 1.000 y
PySINDy provides numerous other features not shown here. We recommend the `feature overview <https://pysindy.readthedocs.io/en/latest/examples/1_feature_overview.html>`__ section of the documentation for a more exhaustive summary of additional features.
PySINDy provides numerous other features not shown here. We recommend the `feature overview <https://pysindy.readthedocs.io/en/latest/examples/1_feature_overview/example.html>`__ section of the documentation for a more exhaustive summary of additional features.

Installation
------------
Expand Down Expand Up @@ -121,23 +121,41 @@ Then, to install the package, run
pip install .
If you do not have pip you can instead use
If you do not have root access, you should add the ``--user`` option to the above lines.

Caveats
^^^^^^^

To run the unit tests, or example notebooks, you should install the dev-dependencies with:

.. code-block:: bash
python setup.py install
pip install pysindy[dev]
If you do not have root access, you should add the ``--user`` option to the above lines.
or if you are installing from a local copy

Caveats
^^^^^^^
If you would like to use the ``SINDy-PI`` optimizer, the ``Trapping SINDy`` optimizer (TrappingSR3), or the other SR3 optimizations with inequality constraints, you will also need to install the cvxpy package, e.g. with ``pip install cvxpy``.
.. code-block:: bash
pip install .[dev]
To build a local copy of the documentation, you should install the docs-dependencies with:

.. code-block:: bash
pip install pysindy[docs]
If you are looking to use convex optimization provided by `cvxpy <https://github.com/cvxpy/cvxpy>`__, then you have to install

To run the unit tests, example notebooks, or build a local copy of the documentation, you should install the additional dependencies in ``requirements-dev.txt``
.. code-block:: bash
pip install pysindy[cvxpy]
to utilize Mixed-Integer Optimized Sparse Regression (MIOSR) via `GurobiPy <https://pypi.org/project/gurobipy/>`__, you
require

.. code-block:: bash
pip install -r requirements-dev.txt
pip install pysindy[miosr]
Documentation
Expand Down Expand Up @@ -178,33 +196,51 @@ You can optimize your notebook for testing by checking ``__name__``. When our t
Contributing code
^^^^^^^^^^^^^^^^^
We welcome contributions to PySINDy. To contribute a new feature please submit a pull request. To get started we recommend installing the packages in ``requirements-dev.txt`` via
We welcome contributions to PySINDy. To contribute a new feature please submit a pull request. To get started we recommend installing an editable ``dev`` version from a local clone via

.. code-block:: bash
pip install -r requirements-dev.txt
pip install -e .[dev]
This will allow you to run unit tests and automatically format your code. To be accepted your code should conform to PEP8 and pass all unit tests. Code can be tested by invoking

.. code-block:: bash
pytest
We recommend using ``pre-commit`` to format your code. Once you have staged changes to commit
We recommend using ``pre-commit`` to format your code. The easiest approach is to install pre-commit via

.. code-block:: bash
pre-commit install
After which pre-commit will automatically check all future commits. Once you have staged changes to commit

.. code-block:: bash
git add path/to/changed/file.py
you can run the following to automatically reformat your staged code
Pre-commit will then automatically run all checks against your committed code. If you want to trigger this manually, you can run the following to automatically reformat your staged code

.. code-block:: bash
pre-commit
Note that you will then need to re-stage any changes ``pre-commit`` made to your code.

Building documentation requires [pandoc](https://pandoc.org/installing.html) as a separate install. Once installed, run
Building documentation requires the ``docs`` dependencies, which can be installed with either

.. code-block:: bash
pip install pysindy[docs]
or with

.. code-block:: bash
pip install .[docs]
for a local clone of the repository. Once installed, run

.. code-block:: bash
Expand Down Expand Up @@ -343,8 +379,8 @@ Thanks to the members of the community who have contributed to PySINDy!
| `andgoldschmidt <https://github.com/andgoldschmidt>`_ | `derivative <https://derivative.readthedocs.io/en/latest/>`_ package for numerical differentiation `#85 <https://github.com/dynamicslab/pysindy/pull/85>`_ |
+-------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. |BuildCI| image:: https://github.com/dynamicslab/pysindy/workflows/Build%20CI/badge.svg
:target: https://github.com/dynamicslab/pysindy/actions?query=workflow%3A%22Build+CI%22
.. |BuildCI| image:: https://github.com/dynamicslab/pysindy/actions/workflows/main.yml/badge.svg
:target: https://github.com/dynamicslab/pysindy/actions/workflows/main.yml?query=branch%3Amaster

.. |RTD| image:: https://readthedocs.org/projects/pysindy/badge/?version=latest
:target: https://pysindy.readthedocs.io/en/latest/?badge=latest
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
html_sourcelink_suffix = ""

intersphinx_mapping = {
"derivative": ("https://derivative.readthedocs.io/en/latest/", None)
"derivative": ("https://derivative.readthedocs.io/en/latest/", None),
"sklearn": ("https://scikit-learn.org/stable/", None),
}

# -- Extensions to the Napoleon GoogleDocstring class ---------------------
Expand Down
617 changes: 330 additions & 287 deletions examples/12_weakform_SINDy_examples.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/17_parameterized_pattern_formation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pdf
data
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NMX= 1000, NPR= 1, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 0
EPSL= 1e-05, EPSU = 1e-05, EPSS = 1e-05
DS = 0.001, DSMIN=1e-10, DSMAX= 1e-2, IADS= 1
NPAR = 15, THL = {}, THU = {2:0,3:0,4:0}
UZR = {1: [-1,0.1,2.5,5,7.5,10.0]}
UZR = {1: [-1,-0.5,0.15,2.5,5,7.5,10.0]}
RL0=-5.0
RL1=10.1
A1=0.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ NMX= 1000, NPR= 1, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 0
EPSL= 1e-05, EPSU = 1e-05, EPSS = 1e-05
DS = 0.001, DSMIN=1e-10, DSMAX= 1e-2, IADS= 1
NPAR = 15, THL = {}, THU = {2:0,3:0,4:0}
UZR = {1: [-1,0.1,2.5,5,7.5,10.0]}
UZR = {1: [-1,-0.5,0.15,2.5,5,7.5,10.0]}
RL0=-5.0
RL1=1.0
RL1=3.0
A1=0.8
IEQUIB = 0
IREV = [1,0,1,0]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NDIM= 4, IPS = 4, IRS = 0, ILP = 1
ICP = [1,11,2,3,4]
PAR={1:-1,11:6.283185307179586}
NTST= 35, NCOL= 4, IAD = 1, ISP = 1, ISW = 1, IPLT= 0, NBC= 4, NINT= 0
NMX= 1000, NPR= 1, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 0
NMX= 10000, NPR= 1, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 0
EPSL= 1e-07, EPSU = 1e-07, EPSS = 1e-05
DS = 1e-6, DSMIN=1e-20, DSMAX= 1e-2, IADS= 1
NPAR = 4, THL = {}, THU = {2:0,3:0,4:0}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NDIM= 4, IPS = 1, IRS = 0, ILP = 1
ICP = [1,11,2,3,4]
NTST= 35, NCOL= 4, IAD = 1, ISP = 2, ISW = 1, IPLT= 0, NBC= 0, NINT= 0
NMX= 1000, NPR= 20, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 1
NMX= 1000, NPR= 20, MXBF= 0, IID = 2, ITMX= 10, ITNW= 7, NWTN= 3, JAC= 0
EPSL= 1e-07, EPSU = 1e-07, EPSS = 1e-05
DS = 0.01, DSMIN=0.0001, DSMAX= 0.05, IADS= 1
NPAR = 15, THL = {}, THU = {2:0,3:0,4:0}
Expand Down
28 changes: 11 additions & 17 deletions examples/17_parameterized_pattern_formation/data/auto/even.auto
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import numpy as np
import os

even=run('snaking_E',c='cycle_even')
sols=[]
pars=[]
for i in range(len(even[0])):
u=even(i+1)['U(1)']
t=even(i+1)['t']
e=even(i+1)['PAR(1)']
r=even(i+1)['PAR(2)']
b=even(i+1)['PAR(3)']
c=even(i+1)['PAR(4)']
T=even(i+1)['PAR(11)']
norm=even(i+1)['L2-NORM']
sols=sols+[np.vstack([t,u]).T]
pars=pars+[[e,r,b,c,T,norm]]
for j in [2,3,4,5]:
even=run('snaking_E'+str(j),c='cycle_even')
sols=[]
pars=[]
for i in range(len(even[0])):
print(i, len(even[0]), end='\r')
sols=sols+[np.concatenate([even(i+1).indepvararray.reshape(1,-1),even(i+1).coordarray[:1]]).T]
pars=pars+[np.concatenate([np.array(even(i+1).PAR.values())[[0,1,2,3,4,5,6,7,8,10]],[(np.sum(np.diff(even(i+1).indepvararray)[:,np.newaxis].T*np.abs(even(i+1).coordarray[0,:-1])**2))**0.5]])]

np.save('even_sols.npy',sols)
np.save('even_pars.npy',pars)
cl()
np.save('even'+str(j)+'_sols.npy',sols)
np.save('even'+str(j)+'_pars.npy',pars)
cl()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0bd7182

Please sign in to comment.