Skip to content

Commit ad0a11b

Browse files
assert precision=12 within 1% of precision=15
1 parent cc79fbb commit ad0a11b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/geophires_x_tests/test_reservoir.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import annotations
22

3+
import copy
34
import os
45
import sys
56
from pathlib import Path
7+
from typing import Any
68

79
from pint.facets.plain import PlainQuantity
810

@@ -63,6 +65,22 @@ def calc_time(r: GeophiresXResult) -> float:
6365
speedup_pct = ((calc_time_15_sec - calc_time_8_sec) / calc_time_15_sec) * 100
6466
_log(f'Speedup: {speedup_pct:.2f}%')
6567

68+
def no_metadata(r: GeophiresXResult) -> dict[str, Any]:
69+
ret = copy.deepcopy(r.result)
70+
del ret['Simulation Metadata']
71+
del ret['metadata']
72+
return ret
73+
74+
result_12_nm = no_metadata(_get_result(12))
75+
result_15_nm = no_metadata(result_15)
76+
try:
77+
self.assertDictAlmostEqual(result_15_nm, result_12_nm, percent=1)
78+
except AssertionError as ae:
79+
try:
80+
self.assertDictEqual(result_15_nm, result_12_nm)
81+
except AssertionError as ae_with_dict_diff:
82+
raise ae from ae_with_dict_diff
83+
6684
# noinspection PyMethodMayBeStatic
6785
def _new_model(self, input_file=None) -> Model:
6886
stash_cwd = Path.cwd()

0 commit comments

Comments
 (0)