PyDMD / PyDMD

Python Dynamic Mode Decomposition

Home Page:https://pydmd.github.io/PyDMD/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in `test_dmd.test_predict_exact()`

sichinaga opened this issue · comments

Describe the bug
The test_predict_exact() test in the test_dmd.py file ends up comparing two empty arrays, which doesn't seem to correctly assess for accurate dmd.predict outputs when exact=True. It seems that the expected array, which is used as the ground truth, is just an empty array. This array is then compared against dmd.predict(sample_data[:, 20:40]) when sample_data is only a (400, 15) array.

To Reproduce
Below is the test_predict_exact() test, with an additional print statement in order to highlight the issue.

import numpy as np
from pytest import raises

from pydmd.dmd import DMD

sample_data = np.load("tests/test_datasets/input_sample.npy")

def test_predict_exact():
    dmd = DMD(exact=True)
    expected = np.load("tests/test_datasets/input_sample_predict_exact.npy")

    np.testing.assert_almost_equal(
        dmd.fit(sample_data).predict(sample_data[:, 20:40]), expected, decimal=6
    )
    print(expected)

test_predict_exact()

Expected behavior
dmd.predict(sample_data) and expected should be non-empty arrays so that test_predict_exact() actually tests for accurate dmd.predict outputs when exact=True.

Output
expected turns out to be an empty array.

>>> []