From 3e404e36c3cdf68fc24e9212e763ddb8e360d4bb Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 21 Nov 2023 14:46:56 +0100 Subject: [PATCH] Change tolerances in aelo_test.py test_CCA --- openquake/engine/tests/aelo_test.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/openquake/engine/tests/aelo_test.py b/openquake/engine/tests/aelo_test.py index 888e597a14a5..90eebc5db515 100644 --- a/openquake/engine/tests/aelo_test.py +++ b/openquake/engine/tests/aelo_test.py @@ -1,18 +1,18 @@ # -*- coding: utf-8 -*- # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# +# # Copyright (C) 2023, GEM Foundation -# +# # OpenQuake is free software: you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # OpenQuake is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. -# +# # You should have received a copy of the GNU Affero General Public License # along with OpenQuake. If not, see . @@ -36,10 +36,10 @@ SITES = ['far -90.071 16.60'.split(), 'close -85.071 10.606'.split()] EXPECTED = [[0.30846, 0.63827, 0.727454], [0.73277, 1.76939, 1.22298]] ASCE7 = ['0.75315', '0.34598', '0.50000', '0.50000', '1.76939', '0.95831', - '0.80947', '1.50000', '1.50000', 'Very High', '1.22298', '0.95013', - '0.48816', '0.60000', '0.60000', 'Very High'] + '0.80947', '1.50000', '1.50000', 'Very High', '1.22298', '0.95013', + '0.48816', '0.60000', '0.60000', 'Very High'] ASCE41 = [1.5, 1.43082, 1.43082, 0.83393, 0.83393, 1., 0.6, - 0.9865, 0.6, 0.4, 0.56995, 0.4 ] + 0.9865, 0.6, 0.4, 0.56995, 0.4] def test_CCA(): @@ -54,18 +54,22 @@ def test_CCA(): if rtgmpy: [fname] = export(('rtgm', 'csv'), calc.datastore) df = pandas.read_csv(fname, skiprows=1) - aac(df.RTGM, expected, atol=1E-6) + aac(df.RTGM, expected, atol=5E-5) if rtgmpy: # check asce7 exporter [fname] = export(('asce7', 'csv'), calc.datastore) df = pandas.read_csv(fname, skiprows=1) - numpy.testing.assert_equal(df.value.to_numpy(), ASCE7) + for got, exp in zip(df.value.to_numpy(), ASCE7): + try: + aac(float(got), float(exp), rtol=1E-2) + except ValueError: + numpy.testing.assert_equal(got, exp) # check asce41 exporter [fname] = export(('asce41', 'csv'), calc.datastore) df = pandas.read_csv(fname, skiprows=1) - aac(df.value, ASCE41) + aac(df.value, ASCE41, atol=5E-5) # run mag_dst_eps_sig exporter [fname] = export(('mag_dst_eps_sig', 'csv'), calc.datastore) @@ -73,7 +77,7 @@ def test_CCA(): def test_JPN(): - # test with mutex sources + # test with mutex sources job_ini = os.path.join(MOSAIC_DIR, 'JPN/in/job_vs30.ini') dic = dict(lon=139, lat=36, site='JPN-site', vs30='760') with logs.init('job', job_ini) as log: