Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_plot_modes_3(self):
dmd = CDMD()
snapshots = [snap.reshape(20, 20) for snap in sample_data.T]
dmd.fit(X=snapshots)
dmd.plot_modes_2D()
plt.close()
def test_shape(self):
dmd = CDMD(svd_rank=-1)
dmd.fit(X=[d for d in sample_data.T])
assert dmd.modes.shape[1] == sample_data.shape[1] - 1
def test_cdmd_matrix_sample(self):
dmd = CDMD(compression_matrix='sample')
dmd.fit(X=sample_data)
error_norm = np.linalg.norm(dmd.reconstructed_data - sample_data, 1)
assert error_norm < 1e-10
def test_dmd_time_3(self):
dmd = CDMD()
dmd.fit(X=sample_data)
dmd.dmd_time['t0'] = 8
dmd.dmd_time['tend'] = 11
expected_data = sample_data[:, 8:12]
np.testing.assert_allclose(dmd.reconstructed_data, expected_data)
def test_cdmd_matrix_uniform(self):
dmd = CDMD(compression_matrix='uniform')
dmd.fit(X=sample_data)
error_norm = np.linalg.norm(dmd.reconstructed_data - sample_data, 1)
assert error_norm < 1e-10
def test_cdmd_matrix_sparse(self):
dmd = CDMD(compression_matrix='sparse')
dmd.fit(X=sample_data)
error_norm = np.linalg.norm(dmd.reconstructed_data - sample_data, 1)
assert error_norm < 1e-10
def test_plot_modes_1(self):
dmd = CDMD()
dmd.fit(X=sample_data)
with self.assertRaises(ValueError):
dmd.plot_modes_2D()
def test_plot_modes_4(self):
dmd = CDMD()
snapshots = [snap.reshape(20, 20) for snap in sample_data.T]
dmd.fit(X=snapshots)
dmd.plot_modes_2D(index_mode=1)
plt.close()
def test_reconstructed_data(self):
dmd = CDMD()
dmd.fit(X=sample_data)
dmd_data = dmd.reconstructed_data
np.testing.assert_allclose(dmd_data, sample_data)
def test_dmd_time_2(self):
dmd = CDMD()
dmd.fit(X=sample_data)
dmd.dmd_time['t0'] = 10
dmd.dmd_time['tend'] = 14
expected_data = sample_data[:, -5:]
np.testing.assert_allclose(dmd.reconstructed_data, expected_data)