Skip to content

Commit

Permalink
CLN(identity_library): update docs and bring back some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
himkwtn committed Jul 30, 2024
1 parent 89de387 commit ec05488
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
25 changes: 2 additions & 23 deletions pysindy/feature_library/polynomial_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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),
Expand Down

0 comments on commit ec05488

Please sign in to comment.