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
Differentiation of Multidimensional Arrays in SINDyDerivative #476
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #476 +/- ##
==========================================
+ Coverage 94.40% 94.42% +0.01%
==========================================
Files 38 38
Lines 4060 4069 +9
==========================================
+ Hits 3833 3842 +9
Misses 227 227 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks Yash! Don't worry about code coverage, this looks like it passes CI. I just want to make the test a little bit more robust.
def test_multidimensional_differentiation(): | ||
X = np.random.random(size=(10, 100, 2)) | ||
t = np.arange(0, 10, 0.1) | ||
|
||
X_dot = SINDyDerivative(kind="kalman", axis=-2)._differentiate(X, t) | ||
|
||
assert X_dot.shape == X.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure we differentiate the correct axis, rather than just verifying that it runs without error. E.g.:
- create a short arange of ints
- tile it /repeat it to make it 3D, so that x[i,i,:] is the original arange
- differentiate it (use something like finite difference, so that we know the expected result)
- test that every slice is what we expect (ones)
Change the name to test_nd_diff_sindy_derivative()
to reflect that we're only testing one class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also worth checking whether this preserves AxesArray
types. If not, we can perhaps add an override for np.moveaxis
This PR addresses the issue and lets SINDyDerivative handle arrays with more dimensions than 2.