Skip to content

Commit cdd8788

Browse files
committed
add test for fit_econ method to ensure consistency with fit method results
1 parent cee0025 commit cdd8788

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_bopdmd.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,22 @@ def test_getter_errors():
641641

642642
with raises(ValueError):
643643
_ = bopdmd.amplitudes_std
644+
645+
646+
def test_fit_econ():
647+
"""
648+
Test that the fit_econ method gives the same results as the fit method.
649+
"""
650+
svd_rank = 2
651+
bopdmd = BOPDMD(svd_rank=svd_rank, use_proj=True)
652+
bopdmd.fit(Z, t)
653+
654+
U, s, V = np.linalg.svd(Z)
655+
U = U[:, :svd_rank]
656+
s = s[:svd_rank]
657+
V = V[:svd_rank, :]
658+
bopdmd_econ = BOPDMD(svd_rank=svd_rank, use_proj=True, proj_basis=U)
659+
bopdmd_econ.fit_econ(s, V, t)
660+
661+
np.testing.assert_allclose(bopdmd_econ.eigs, bopdmd.eigs)
662+
np.testing.assert_allclose(bopdmd_econ.modes, bopdmd.modes)

0 commit comments

Comments
 (0)