Skip to content

Commit

Permalink
Adds perturbation to test reference
Browse files Browse the repository at this point in the history
Removes issue with noise at machine precision for well-converged cases
  • Loading branch information
holm10 committed Dec 6, 2023
1 parent b8a7a17 commit a248a6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pytests/templates/tests/test_uedge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

class TestClass:

def perturb_solution(self, file, perturbation=1e-2):
from h5py import File
from numpy.random import uniform
bbb = file['bbb']
for var in ['nis', 'ups', 'tes', 'tis', 'ngs', 'tgs', 'phis']:
bbb[var][...] *= uniform(low=perturbation, high=perturbation, size = bbb[var].shape)

def test_reference(self, epsilon=1e-8):
from h5py import File
from uedge import bbb, com
Expand Down Expand Up @@ -177,6 +184,7 @@ def setdata(var, value):
# Write data used to construct tests to save
casesetup = {}
with File('solution.h5', 'a') as f:
self.perturb_solution(f)
try:
group = f.create_group('pytests')
except:
Expand Down

0 comments on commit a248a6d

Please sign in to comment.