Repository navigation
This release stops pip install pykoopman from installing the test, documentation and notebook tools that 1.2.0 to 1.2.2 listed as runtime requirements. Among them were pytest 7.4.4, which held back pytest in every environment that had pykoopman, and notebook 7.0.4, which is affected by published security advisories. The release also fixes two problems in RadialBasisFunction. With include_state=True, inverse did not always return the retained state coordinates, and the polyharmonic kernel gave NaN for a sample lying on a center. The first fix can change results when the lifted training data are exactly or numerically rank deficient, as described below.
Tools moved out of the runtime requirements (#81)
- pykoopman 1.2.2 required pytest <= 7.4.4, pytest-cov, pytest-lazy-fixture, flake8-builtins-unleashed, setuptools_scm, setuptools_scm_git_archive, Jupyter, notebook <= 7.0.4, Sphinx <= 7.0.0 with nbsphinx, sphinx-codeautolink, sphinxcontrib-apidoc and sphinx_rtd_theme, and pre-commit, as well as torchvision and torchaudio, which pykoopman does not import. These requirements are removed. The other 11 runtime requirements are unchanged, including the numpy, scipy, scikit-learn, torch and lightning pins and the
setuptools < 82cap from 1.2.2. - A new environment therefore no longer receives notebook 7.0.4 or JupyterLab, and pytest is no longer held at 7.4.4. The advisories GHSA-mqcg-5x36-vfcg and GHSA-rch3-82jr-f9w9 affect notebook 7.0.0 to 7.5.5 and JupyterLab 4.5.6 and older, and are fixed in notebook 7.5.6 and JupyterLab 4.5.7. Older advisories also affect notebook 7.0.4.
- The test, documentation and notebook tools are available as extras again. In 1.1.0 they were all in a single
devextra.pykoopman[test]installs pytest >= 9.0.3, pytest-cov and pytest-lazy-fixtures.pykoopman[docs]installs the Sphinx stack used bydocs/, with IPython and ipywidgets for the notebook pages.pykoopman[dev]combines both and adds Jupyter, notebook >= 7.5.6 and pre-commit. The packages flake8-builtins-unleashed, setuptools_scm and setuptools_scm_git_archive are no longer listed in any extra, and pytest-lazy-fixtures replaces pytest-lazy-fixture. - The tutorial notebooks need Jupyter, which pykoopman no longer installs:
pip install jupyter.
Upgrading an existing environment
pip install -U pykoopmandoes not uninstall packages that an earlier release required, so an upgraded environment keeps notebook 7.0.4, pytest 7.4.4 and the other tools. Runpip install -U notebookto get notebook and JupyterLab releases with the fixes, since notebook 7.5.6 and later require a fixed JupyterLab. If you uninstall the tools instead, includejupyterlab, which was installed as a dependency of jupyter and notebook.- If you then upgrade pytest to 8 or newer, also run
pip uninstall pytest-lazy-fixture. That plugin is loaded automatically and breaks test collection on pytest 8 and newer. pykoopman's own test suite has moved to pytest-lazy-fixtures and disables the old plugin.
RadialBasisFunction.inverse returns the retained state (#79, fixes #78)
- With
include_state=True, the default, the first features of the lift are the state coordinates themselves, butinverseused a measurement matrix fitted by least squares to the lifted training data. When those data are rank deficient, the fitted matrix need not recover the coordinates of a lifted state outside their span. This happens, for instance, when the training states satisfy an exact linear relation such asx1 = x2in #78, when there are fewer samples than lifted features, or when the lifted features are numerically dependent, as can happen with many Gaussian centers even when the samples far outnumber the features. In the example from #78, the states[0, 1]and[2, -1]both came back as[0.5, 0.5]. - The measurement matrix is now the identity on the retained coordinates and zero on the RBF features, as for the other observables that keep the state. With
include_state=Falsethe least squares fit is kept. The matrix is set byfit, so a model fitted with an earlier release and saved with pickle or joblib keeps the old matrix, and gives the earlier results until it is fitted again. - Results can change when the lifted training data are rank deficient.
RadialBasisFunction.inversecan then return different values for new states. The same holds forpredict,simulate,CandWofKoopmanandKoopmanContinuous, and for the inverse of a concatenation in which aRadialBasisFunctionis the first observable that keeps the state, such asRadialBasisFunction() + Polynomial(). In our checks with 8 sample pairs or 9-sample trajectories and 12 lifted features, the predictions of DMDc and EDMDc models fitted on separatexandychanged by up to 0.13 for states of order 1, andCchanged for these models and for EDMDc fitted on a single trajectory. In these checks, the EDMD, KDMD andPyDMDRegressormodels, and the predictions of every model fitted on a single trajectory, changed only by rounding errors of at most 1.4e-9. With 30 Gaussian centers on 500 one-dimensional samples, where the lift is numerically rank deficient,Cof an EDMDc model fitted on separatexandychanged by 0.04 and its predictions by 2e-5. The Koopman matrix did not change in any of these checks. - With full rank lifted training data, the least squares matrix of 1.2.2 equals the new one up to rounding errors, which grow with the condition number of the lifted training data. In the three tutorials that use
RadialBasisFunction(EDMD with RBF, and EDMDc for the Van der Pol and the chaotic Duffing oscillators), thesimulateoutput,CandWagree with 1.2.2 to within 6e-14. With the default Gaussian kernel on 500 one-dimensional samples, where that condition number is about 1e11,CandWdiffered by up to 5e-7. - Reported and fixed by AryanRG.
Polyharmonic RBF on a center (#82)
- With
rbf_type="polyharmonic"andpolyharmonic_coeff > 0(the default is 1.0), a sample lying exactly on a center produced NaN, because r^k log r was evaluated as 0 times-inf. Such entries now take the limit value 0, as the thinplate kernel already did. - In 1.2.2,
fitthen raisedLinAlgError: SVD did not converge in Linear Least Squareswhenever a training sample lay on a center, for either value ofinclude_state, andtransformandinversereturned NaN for new samples on a center. Withcenters=None,fitplaces the smallest and largest center of each feature at the ends of the data range, so on one-dimensional data a training sample always lies on a center, and aKoopmanmodel with this kernel could not be fitted. - With
polyharmonic_coeff = 0the kernel is log r, which has no finite value at r = 0, and such entries remain-inf.
Other changes
- A new
.zenodo.jsonsets the creators of the Zenodo record made for each release to the five authors of the v1.1.0 record, with their ORCID iDs. Without it, Zenodo listed GitHub contributors (#77).
Tests and documentation
- Regression tests for the RBF inverse with retained state, for all five kernels (#79), and for the polyharmonic kernel on a center (#82).
test/test_package.pyfails if tools return to the runtime requirements or if the extras lose the test or documentation tools (#81).- The test suite uses pytest-lazy-fixtures and runs on pytest 9. CI installs
.[test]and runs the suite once with coverage, and Read the Docs installs thedocsextra (#81). - README: the Jupyter requirement of the tutorials,
pip install -e ".[dev]"and the uv commands for contributors, and the correctedpre-commit run -a -v(#81).
Full Changelog: v1.2.2...v1.2.3