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

ENH: #455 Make IdentityLibrary a subclass of Polynomial Library #533

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
CLN(identity_library): update docs and bring back some test cases
himkwtn committed Jul 30, 2024
commit ec05488a505ea83055c7cae19c13ace44b52cadf
25 changes: 2 additions & 23 deletions pysindy/feature_library/polynomial_library.py
Original file line number Diff line number Diff line change
@@ -287,28 +287,7 @@ def n_poly_features(
def IdentityLibrary():
"""
Generate an identity library which maps all input features to
themselves.

Attributes
----------
n_features_in_ : int
The total number of input features.

n_output_features_ : int
The total number of output features. The number of output features
is equal to the number of input features.

Examples
--------
>>> import numpy as np
>>> from pysindy.feature_library import IdentityLibrary
>>> x = np.array([[0,-1],[0.5,-1.5],[1.,-2.]])
>>> lib = IdentityLibrary().fit(x)
>>> lib.transform(x)
array([[ 0. , -1. ],
[ 0.5, -1.5],
[ 1. , -2. ]])
>>> lib.get_feature_names()
['x0', 'x1']
themselves. An alias for creating a degree-1 polynomial library
with no constant term.
"""
return PolynomialLibrary(degree=1, include_bias=False)
3 changes: 3 additions & 0 deletions test/test_feature_library.py
Original file line number Diff line number Diff line change
@@ -227,6 +227,7 @@ def test_sindypi_library_bad_params(params):
PolynomialLibrary(),
PolynomialLibrary(include_bias=False),
FourierLibrary(),
IdentityLibrary() + PolynomialLibrary(),
pytest.lazy_fixture("custom_library"),
pytest.lazy_fixture("custom_library_bias"),
pytest.lazy_fixture("generalized_library"),
@@ -247,6 +248,7 @@ def test_fit_transform(data_lorenz, library):
PolynomialLibrary(),
PolynomialLibrary(include_bias=False),
FourierLibrary(),
IdentityLibrary() + PolynomialLibrary(),
pytest.lazy_fixture("custom_library"),
pytest.lazy_fixture("custom_library_bias"),
pytest.lazy_fixture("generalized_library"),
@@ -267,6 +269,7 @@ def test_change_in_data_shape(data_lorenz, library):
[
(PolynomialLibrary(include_bias=False), 9),
(PolynomialLibrary(), 10),
(IdentityLibrary() + PolynomialLibrary(), 13),
(FourierLibrary(), 6),
(pytest.lazy_fixture("custom_library_bias"), 13),
(pytest.lazy_fixture("custom_library"), 12),