Skip to content

Commit

Permalink
TST: Added test for unionize_coeff_matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Nov 22, 2024
1 parent e3e378a commit bae3e92
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import numpy as np
import pysindy as ps
import pytest

from gen_experiments.typing import NestedDict
from gen_experiments.utils import unionize_coeff_matrices


def test_flatten_nested_dict():
Expand All @@ -19,3 +22,16 @@ def test_flatten_nested_bad_dict():
with pytest.raises(TypeError, match="Only string keys allowed"):
deep = NestedDict(a={1: 1})
deep.flatten()


def test_unionize_coeff_matrices():
# lib = ps.PolynomialLibrary().fit(np.array([[1, 1]]))
model = ps.SINDy(feature_names=["x", "y"])
data = np.arange(10)
data = np.vstack((data, data)).T
model.fit(data, 0.1)
coeff_true = [{"y": -1, "zorp_x": 0.1}, {"x": 1, "zorp_y": 0.1}]
true, est, feats = unionize_coeff_matrices(model, coeff_true)
assert len(feats) == true.shape[1]
assert len(feats) == est.shape[1]
assert est.shape == true.shape

0 comments on commit bae3e92

Please sign in to comment.