- Notifications
You must be signed in to change notification settings - Fork362
Bug fix - to handle "u: list of array-like, shape (n_samples, n_co…#605
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ol_features)" input - I'll elaborate more in the PR comment section
giopapanas commentedMar 19, 2025
Thank you@YaadR , for your fix here. I raised this issue:#611, do you think it relates to your bug fix? In brief, when I do a toy experiment and run model.fit() with X of 1D, then the model.fit runs fine. However, as I explain in the discussion in the link above, the model gives me an error when I load a multi-dimensional X. Btw, do you know if I need to input [x_dot] and [u_train] data myself? I think PySINDy is by default loading [x_dot] and [u_train], if you specify the differentiation method and the library to use? Thank you in advance. |
YaadR commentedMar 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi@giopapanas , to my understanding#611 is not sourced from the same bug. |
Jacob-Stevens-Haas commentedApr 4, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey, thanks for your PR@YaadR - sorry for the delay. I've verified that this still exists on Let's talk about your code. I've shrunk it down to a alternative MWE (minimal, working example): importnumpyasnpimportpysindyaspsx1=np.arange(10).reshape((-1,1))x2=np.arange(11).reshape((-1,1))x= [x1,x2]u1=np.arange(10)u2=np.arange(11)u= [np.arange(10),np.arange(11)]model=ps.SINDy()# No error: single trajectory, u is flatmodel.fit(x=x[0],t=1.0,u=u[0])# No error: u has flat trajectories, but all are the same lengthmodel.fit(x=[x1,x1],t=1.0,u=[u1,u1])# Error: u has flat trajectories, but not the same lengthmodel.fit(x=x,t=1.0,u=u) This is the form we prefer to receive examples in, as the process of reducing the example is likely to show you the problem. Here it is obvious: But you've noticed the docstring: If you're still interested in the PR, and for that I'd be grateful, you're welcome to find a way to fix what I described as the bug. I'd recommend starting by writing a test. (BTW: Code formatting in github allows you to specify the language in order to get syntax highlighting, by typing "```python". I've added that to your comment.) |
Uh oh!
There was an error while loading.Please reload this page.
Bug fix - to handle "u: list of array-like, shape (n_samples, n_control_features)" input - I'll elaborate more in the PR comment section
Generally there is an option to give the model.fit() ' list of array-like, shape' as documented. when this is done for X_train data requires all the associated data to be in a sequence (list) form as well, e.g. [t_train], [x_dot] and [u_train] - the problem that arises with u_train is that there is a reshape part in the code that does it poorly as well as a section that called for X_train.shape - an numpy.array() feature that doesn't exist in python 'list' type. both fixes allows the code to run correct and smoothly, and does not effect other library features.
In the code x_train_1 and x_trian_2 are of different lengths, to demonstrate the use of python 'list' specifically and not numpy.array() which constrained to 'symmetric' matrix shape only
The code that reproduces the problem
The problem:
