Skip to content

Commit

Permalink
loo_error does not change reduction and approx attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ndem0 committed Apr 7, 2021
1 parent cc09fce commit 4a3a3e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ezyrb/reducedordermodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import numpy as np
import math
import copy
from scipy.spatial import Delaunay


Expand Down Expand Up @@ -74,8 +75,8 @@ def loo_error(self, norm=np.linalg.norm):
remaining_index = db_range[:]
remaining_index.remove(j)
new_db = self.database[remaining_index]
rom = type(self)(new_db, self.reduction,
self.approximation).fit()
rom = type(self)(new_db, copy.deepcopy(self.reduction),
copy.deepcopy(self.approximation)).fit()

error[j] = norm(self.database.snapshots[j] -
rom.predict(self.database.parameters[j]))
Expand Down
9 changes: 9 additions & 0 deletions tests/test_reducedordermodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ def test_loo_error(self):
np.array([421.299091, 344.571787, 48.711501, 300.490491]),
rtol=1e-4)

def test_loo_error_singular_values(self):
pod = POD()
rbf = RBF()
db = Database(param, snapshots.T)
rom = ROM(db, pod, rbf).fit()
valid_svalues = rom.reduction.singular_values
rom.loo_error()
np.testing.assert_allclose(valid_svalues, rom.reduction.singular_values)

def test_optimal_mu(self):
pod = POD()
rbf = RBF()
Expand Down

0 comments on commit 4a3a3e6

Please sign in to comment.