-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract common functionality from SINDy
to _BaseSINDy
#562
Conversation
This will eventually enable SSSindy.print, as well as a simpler discrete and SINDyPI class
SINDy.equations(), equations(), print_model() were written with extra generality that never ended up being used. This commit removes such generality and throws away these indirected helper functions in favor of a single method.
5182f24
to
79f43bb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #562 +/- ##
==========================================
- Coverage 95.28% 95.26% -0.02%
==========================================
Files 38 39 +1
Lines 4069 4099 +30
==========================================
+ Hits 3877 3905 +28
- Misses 192 194 +2 ☔ View full report in Codecov by Sentry. |
79f43bb
to
b7eac64
Compare
Also: * fix sphinx cross-linking error * remove unused print_model
b7eac64
to
2b3871b
Compare
Hey Alan, I put you as a reviewer in case you want an eye into this process. This is the beginning of what we talked about in the last meeting. @AHsu98, @MalachiteWind, I'm going to add you as collaborators so you can review these changes too. |
98a475a
to
0482105
Compare
This includes things like reduce() and coef_
This was thought to be easy, because in many cases jax arrays were an almost drop-in replacement for numpy arrays. However, they are far less amenable to subclassing. Why does this matter? The codebase gained a lot of readability with AxesArray allowing arrays to dynamically know what their axes meant, even after indexing changed their shape. However, extending AxesArray to dynamically subclass either numpy.ndarray or jax.Array is impossible - even a static subclass of the latter is impossible. Long term, we will need our own metadata type that carries around an array, it's type package (numpy or jax.numpy or cvxpy.numpy), its bidirectional mapping between axis index and axis meaning, and maybe even something from sympy. Short term, we should expose our general expectations for axis definitions as global constants. This is still error prone, as the constants are incorrect for arrays that have changed shape due to indexing, but will be far more readable than magic numbers.
0482105
to
22329dd
Compare
I'm going to merge it, and turn the last commit into an issue |
Begin #351
This pull request begins the abstraction of the
SINDy
class, which handles a lot of methods with special cases, to a variety of classes that reflect fundamental differences between problem formulations. Here, I pull out_BaseSINDy
, which contains basic information about the feature library, system dimension, and printing the equations.Future PRs will make Weak and discrete their own classes, modify feature libraries to be amenable to jax, numpy, and cvxpy arrays, and introduce the Single-Step SINDy class and associated optimizer/problem setup.