From d8dfd0601b657e6eccd3efc9b09bd1e14514650a Mon Sep 17 00:00:00 2001 From: Gui Castelao Date: Mon, 17 Jun 2024 10:02:05 -0600 Subject: [PATCH 1/2] Allow some tolerance in test comparison Note that the default is relative tol = 1e-5 & absolute tol = 1e-8. I'm also considering NaNs as equal values. --- tests/forward_pass/test_forward_pass.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/forward_pass/test_forward_pass.py b/tests/forward_pass/test_forward_pass.py index 2f3b32ae0..ff58131f7 100644 --- a/tests/forward_pass/test_forward_pass.py +++ b/tests/forward_pass/test_forward_pass.py @@ -173,8 +173,9 @@ def test_fwp_single_ts_vs_multi_ts_input_files(): with xr.open_dataset(sf) as s_res, xr.open_dataset(mf) as m_res: for feat in model.meta['hr_out_features']: - assert np.array_equal(s_res[feat].values, - m_res[feat].values) + assert np.allclose(s_res[feat].values, + m_res[feat].values, + equal_nan=True) def test_fwp_spatial_only(): From 11f05475fb7b7cce15bd8d6d90e521b2eec00b98 Mon Sep 17 00:00:00 2001 From: Gui Castelao Date: Mon, 17 Jun 2024 11:20:10 -0600 Subject: [PATCH 2/2] Removing nan_equal As suggested by @grantbuster since it was not supposed to have any NaN. --- tests/forward_pass/test_forward_pass.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/forward_pass/test_forward_pass.py b/tests/forward_pass/test_forward_pass.py index ff58131f7..adbe5532f 100644 --- a/tests/forward_pass/test_forward_pass.py +++ b/tests/forward_pass/test_forward_pass.py @@ -174,8 +174,7 @@ def test_fwp_single_ts_vs_multi_ts_input_files(): with xr.open_dataset(sf) as s_res, xr.open_dataset(mf) as m_res: for feat in model.meta['hr_out_features']: assert np.allclose(s_res[feat].values, - m_res[feat].values, - equal_nan=True) + m_res[feat].values) def test_fwp_spatial_only():