Skip to content

Commit

Permalink
Minor bug fixes to memory saving in _pod_space and edits in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polettiRomain committed Jul 17, 2024
1 parent e3518c4 commit 30e7eb5
Showing 5 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions modulo_vki/core/_pod_space.py
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
R1 = (i - 1) * dim_col
R2 = i * dim_col

if (b == tot_blocks_row) and (N_S - dim_row * N_PARTITIONS > 0): # Change here !!!
if (b == tot_blocks_row) and (N_S - dim_row * N_PARTITIONS > 0): # Change here
C1 = C2
C2 = C1 + (N_S - dim_row * N_PARTITIONS)
else:
@@ -173,7 +173,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
else:
for j in range(R1, R2):
jj = j - R1
Phi_P = dps[:, jj] / Sigma_P[jj]
Phi_P = dps[:, jj] / Sigma_P[j] # Change here
np.savez(FOLDER_OUT + f"/phi_{j + 1}", phi_p=Phi_P)

Phi_P_M = np.zeros((N_S, R))
2 changes: 0 additions & 2 deletions modulo_vki/test/core/test_k_matrix.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,5 @@ def test_dotProduct_memorySavingOn(self):
K_test = np.load(self.FOLDER_OUT + '/correlation_matrix/k_matrix.npz')['K']
self.assertListEqual(K_test.tolist(), self.K.tolist())



if __name__ == "__main__":
unittest.main(verbosity=2)
3 changes: 0 additions & 3 deletions modulo_vki/test/core/test_pod_space.py
Original file line number Diff line number Diff line change
@@ -104,8 +104,5 @@ def test_phi_pod(self):

np.testing.assert_allclose(Phi_P_mat,Phi_P_memorySaving ,rtol=self.rtol, atol=self.atol)




if __name__ == "__main__":
unittest.main(verbosity=2)
3 changes: 1 addition & 2 deletions modulo_vki/test/utils/test_read_db.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ def tearDown(self):
shutil.rmtree("MODULO_tmp")

def test_meanComputation(self):
"""Test if mean is computed correctly & susbstracted from D"""
"""Test if mean is computed correctly & substracted from D"""
N_PARTITIONS = 1
FOLDER_OUT = './MODULO_tmp'
MR = True
@@ -92,6 +92,5 @@ def test_split(self):
D_MR = (self.D_orig - np.ones(np.shape(self.D)) * self.D_MEAN.reshape(-1, 1))
np.testing.assert_allclose(D_rec,D_MR ,rtol=self.rtol, atol=self.atol)


if __name__ == "__main__":
unittest.main(verbosity=2)
8 changes: 0 additions & 8 deletions modulo_vki/test/utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -36,14 +36,6 @@ def test_eighs(self):
np.testing.assert_allclose(Sigma_P, self.sqrteigenValues[:-1],rtol=1e-4, atol=1e-4)
#np.testing.assert_allclose(Psi_P[:-1], self.eigenVetors[:-1],rtol=1e-4, atol=1e-4) # check only the first sqrt eigen value since the others are nan


def test_eighs(self):
""" Test the eigen values computed by eigsh"""
n_modes = 2
eig_solver = self.eig_solvers[2]
Psi_P, Sigma_P = switch_eigs(self.A, n_modes, eig_solver)
self.assertAlmostEqual(Sigma_P.tolist()[0], self.sqrteigenValues[0])

def test_unknownEigh(self):
"""Test if an exception is raised with an unknown eigen value solver"""
with self.assertRaises(ValueError):

0 comments on commit 30e7eb5

Please sign in to comment.