Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[BUG] PDE Library usage with function_library #597

Closed
Al-Ofek opened this issue Feb 4, 2025 · 1 comment
Closed

[BUG] PDE Library usage with function_library #597

Al-Ofek opened this issue Feb 4, 2025 · 1 comment

Comments

@Al-Ofek
Copy link

Al-Ofek commented Feb 4, 2025

Recently started experimenting with SINDy for PDE identification. Even while using the example code, I ran into an issue where PDELibrary does not accept the useage of function_library. Is it related to some recent changes? Defining the library functions explicitly seems to work.
Any input will be appriciated. Thanks!

Reproducing code example:

(Taken directly from the docs )

import pysindy

# basic data to illustrate the PDE Library
t = np.linspace(0, 10)
x = np.linspace(0, 10)
u = ps.AxesArray(np.ones((len(x) * len(t), 2)),{"ax_coord":1})

# Define PDE library that is quadratic in u,
# and second-order in spatial derivatives of u.
# library_functions = [lambda x: x, lambda x: x * x]
# library_function_names = [lambda x: x, lambda x: x + x]
pde_lib = ps.PDELibrary(
#     library_functions=library_functions,
    function_library=ps.PolynomialLibrary(degree=2,include_bias=False),
    derivative_order=2,
    spatial_grid=x,
).fit([u])
print("2nd order derivative library: ")
print(pde_lib.get_feature_names())

Error message:

Traceback (most recent call last):

File ~\miniconda3\envs\PhysML\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)

File \sindy_test.py:143
pde_lib = ps.PDELibrary(

TypeError: PDELibrary.init() got an unexpected keyword argument 'function_library'

PySINDy/Python version information:

pysindy - 1.7.5
Python - '3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:06:27) [MSC v.1942 64 bit (AMD64)]'

@Jacob-Stevens-Haas
Copy link
Member

You can see in the link you shared that that is for the latest commit: https://pysindy.readthedocs.io/en/latest/examples/10_PDEFIND_examples/example.html
To install that version, run pip isntall git+https://github.com/dynamicslab/pysindy

For version 1.7.5, check the stable documentation:
https://pysindy.readthedocs.io/en/stable/examples/10_PDEFIND_examples/example.html

In any interactive python session, if you have an old version of a library that doesn't have online documentation, you can check help(obj) to get the documentation for that object. In your case, that would show that PDELibrary from version 1.7.5 does not have a function_library parameter.

@dynamicslab dynamicslab locked and limited conversation to collaborators Feb 21, 2025
@Jacob-Stevens-Haas Jacob-Stevens-Haas converted this issue into discussion #604 Feb 21, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants