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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pysindy/feature_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from .custom_library import CustomLibrary
from .fourier_library import FourierLibrary
from .generalized_library import GeneralizedLibrary
from .identity_library import IdentityLibrary
from .parameterized_library import ParameterizedLibrary
from .pde_library import PDELibrary
from .polynomial_library import IdentityLibrary
from .polynomial_library import PolynomialLibrary
from .sindy_pi_library import SINDyPILibrary
from .weak_pde_library import WeakPDELibrary
Expand Down
101 changes: 0 additions & 101 deletions pysindy/feature_library/identity_library.py

This file was deleted.

9 changes: 9 additions & 0 deletions pysindy/feature_library/polynomial_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,12 @@ def n_poly_features(
else:
n_feat += comb(n_in_feat + deg - 1, deg)
return n_feat


def IdentityLibrary():
"""
Generate an identity library which maps all input features to
themselves. An alias for creating a degree-1 polynomial library
with no constant term.
"""
return PolynomialLibrary(degree=1, include_bias=False)
5 changes: 0 additions & 5 deletions test/test_feature_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def test_sindypi_library_bad_params(params):
@pytest.mark.parametrize(
"library",
[
IdentityLibrary(),
PolynomialLibrary(),
PolynomialLibrary(include_bias=False),
FourierLibrary(),
Expand All @@ -246,7 +245,6 @@ def test_fit_transform(data_lorenz, library):
@pytest.mark.parametrize(
"library",
[
IdentityLibrary(),
PolynomialLibrary(),
PolynomialLibrary(include_bias=False),
FourierLibrary(),
Expand All @@ -269,7 +267,6 @@ def test_change_in_data_shape(data_lorenz, library):
@pytest.mark.parametrize(
"library, shape",
[
(IdentityLibrary(), 3),
(PolynomialLibrary(include_bias=False), 9),
(PolynomialLibrary(), 10),
(IdentityLibrary() + PolynomialLibrary(), 13),
himkwtn marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -292,7 +289,6 @@ def test_output_shape(data_lorenz, library, shape):
@pytest.mark.parametrize(
"library",
[
IdentityLibrary(),
PolynomialLibrary(),
PolynomialLibrary(include_bias=False),
FourierLibrary(),
Expand Down Expand Up @@ -410,7 +406,6 @@ def test_tensored(data_lorenz):
@pytest.mark.parametrize(
"library",
[
IdentityLibrary(),
PolynomialLibrary(),
FourierLibrary(),
PolynomialLibrary() + FourierLibrary(),
Expand Down
Loading