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

[DOC] WeakPDELibrary.transform does not produce output in shape specified by documentation. #442

Open georgemilosh opened 6 months ago

georgemilosh commented 6 months ago

So basically it is just doc string for class WeakPDELibrary(BaseFeatureLibrary): that seems to be inconsistent with the current setup. It says that lib.transform(x) would generate array of the same shape as the inpux x, but it is actually the sampled shape of x (which is governed by K). Also if I run this example with x that is 3 by 2 the command takes forever, so I changed it a bit:

Reproducing code example:

import numpy as np
from pysindy.feature_library import WeakPDELibrary

t = np.arange(0, 10, .5)
x = np.random.randint(0,3,(t.shape[0],2))
functions = [lambda x : np.exp(x), lambda x,y : np.sin(x+y)]
lib = WeakPDELibrary(library_functions=functions,spatiotemporal_grid=t,K=50).fit(x)
lib.transform(x).shape

So there is no error but it would help if more up to date doc strings and examples were provided.

PySINDy/Python version information:

0.1.dev1618+g694c904.d20231219 3.8.18 | packaged by conda-forge | (default, Oct 10 2023, 15:44:36) 
[GCC 12.3.0]