diff --git a/tests/test_chemcomp.py b/tests/test_chemcomp.py index f71d9d8..ceb3e9d 100644 --- a/tests/test_chemcomp.py +++ b/tests/test_chemcomp.py @@ -1,5 +1,5 @@ """ -General GCMT tests +General chemcomp tests """ import numpy as np import pytest @@ -9,7 +9,7 @@ import astropy.constants as const import os -from test_chemcomp_common import all_references_testdata +from test_chemcomp_common import all_references_testdata, THRESHOLD_DISK, MAX_RTOL_DISK, MAX_RTOL_PLANET def test_compare_reference_minimal(all_references_testdata): @@ -25,7 +25,7 @@ def test_compare_reference_minimal(all_references_testdata): # planet stuff for q in ['M', "M_a", "M_c", "M_z_gas", "M_z_peb", "comp_a", "comp_c", "pebiso"]: - np.testing.assert_allclose(old[q], new[q], err_msg=f"failed on {q}") + np.testing.assert_allclose(old[q], new[q], err_msg=f"failed on {q}", rtol=MAX_RTOL_PLANET) # disk stuff data = {} @@ -42,14 +42,11 @@ def test_compare_reference_minimal(all_references_testdata): all_keys = data[out[0]].keys() - # mask out all the data at which we have infinitesimally small values - # -> numerical noise may be important there - threshold = 1e-60 for key in all_keys: old_data = data[out[0]][key] new_data = data[out[1]][key] - mask = np.where(np.logical_and(old_data > threshold, new_data > threshold)) - np.testing.assert_allclose(old_data[mask], new_data[mask], err_msg=f"failed on {key}") + mask = np.where(np.logical_and(old_data > THRESHOLD_DISK, new_data > THRESHOLD_DISK)) + np.testing.assert_allclose(old_data[mask], new_data[mask], err_msg=f"failed on {key}", rtol=MAX_RTOL_DISK) diff --git a/tests/test_chemcomp_common.py b/tests/test_chemcomp_common.py index 58151bd..74c12e8 100644 --- a/tests/test_chemcomp_common.py +++ b/tests/test_chemcomp_common.py @@ -1,9 +1,14 @@ """ Common functions for chemcomp testing """ - import pytest +# mask out all the data at which we have infinitesimally small values +# -> numerical noise may be important there +THRESHOLD_DISK = 1e-60 +MAX_RTOL_DISK = 1e-4 +MAX_RTOL_PLANET = 1e-4 + reference = { "Bert": { "path": "ci/reference.h5",