Skip to content

Commit

Permalink
TST: Make data-dependent test not depend upon data.
Browse files Browse the repository at this point in the history
Previously, test_complexity and test_coefficients just tested that
- required names are present in SINDy object
- when fit on some amount of data, less than 10 terms were nonzero
- These are essentially the same test, since model.complexity is just
  a wrapper around it's optimizer's complexity property

But Lorenz has 7 nonzero terms, and when I changed the data to speed up
tests, data had a few more nonzeros.
  • Loading branch information
Jacob-Stevens-Haas committed May 12, 2023
1 parent f7f48f1 commit 53a43df
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions test/test_pysindy.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,13 @@ def test_differentiate(data_lorenz, data_multiple_trajctories):
model.differentiate(x)


def test_coefficients(data_lorenz):
def test_coefficients_equals_complexity(data_lorenz):
x, t = data_lorenz
model = SINDy()
model.fit(x, t)
c = model.coefficients()
assert np.count_nonzero(c) < 10


def test_complexity(data_lorenz):
x, t = data_lorenz
model = SINDy()
model.fit(x, t)
assert model.complexity < 10
assert model.complexity == np.count_nonzero(c)
assert model.complexity < 30


def test_simulate_errors(data_lorenz):
Expand Down

0 comments on commit 53a43df

Please sign in to comment.