dynamicslab / pysindy

A package for the sparse identification of nonlinear dynamical systems from data
https://pysindy.readthedocs.io/en/latest/
Other
1.36k stars 304 forks source link

Make `IdentityLibrary` a subclass of `PolynomialLibrary` #455

Open Jacob-Stevens-Haas opened 5 months ago

Jacob-Stevens-Haas commented 5 months ago

Doesn't add any features or applicability, but cuts out ~100 lines of code. But as I work with the library a lot, I really appreciate less to navigate through. As a slight bonus, it makes type compatibility clearer as we slowly add annotations.

An IdentityLibrary is just a degree 1 PolynomialLibrary with no bias term.

This should just call super().__init__() with the proper terms (degree, etc). Then the class should be moved to optimizers/base.py

Or it can simply become a factory function for calling PoynomialLibrary with the correct arguments. It seems like the main factor is type safety. Would love to have this discussion if anyone's interested, but I don't trust myself to think it through properly if I'm just discussing it with myself.