Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yb6599
Copy link
Contributor

@yb6599 yb6599 commented Feb 21, 2024

This PR addresses the issue and lets SINDyDerivative handle arrays with more dimensions than 2.

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (a0e36dd) 94.40% compared to head (f4b8be7) 94.42%.

Files Patch % Lines
pysindy/differentiation/sindy_derivative.py 92.30% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Jacob-Stevens-Haas Jacob-Stevens-Haas left a 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.

Comment on lines +423 to +429
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
Copy link
Collaborator

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.

Copy link
Collaborator

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

@Jacob-Stevens-Haas Jacob-Stevens-Haas linked an issue Feb 29, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] SINDyDerivative does not handle PDEs
2 participants