Skip to content

Commit

Permalink
ENH: #455 Make IdentityLibrary a factory for Polynomial Library (#533)
Browse files Browse the repository at this point in the history
* CLN(identity_library): move identity library to factory function
* CLN(identity_library): remove test cases
  • Loading branch information
himkwtn authored Jul 30, 2024
1 parent 90464db commit 476b59f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 107 deletions.
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),
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

0 comments on commit 476b59f

Please sign in to comment.