From 80aec42751dc2f4bbad71aaa9ebf1b08c717b351 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Sun, 10 Mar 2024 07:29:42 -0400 Subject: [PATCH] test: avoid warnings from 3rd party libs (#1670) * ignore well-known python-dateutil and pandas warnings * use .item() to extract single items from numpy arrays * mark PRT voronoi tests slow (todo: refactor, speed up) * use raw docstrings if they contain backslashes --- autotest/pytest.ini | 5 ++ autotest/test_gwe_esl_analyt_sln.py | 90 ++++++++++++++--------------- autotest/test_gwe_lke_conduction.py | 2 +- autotest/test_gwe_split_analyt.py | 2 +- autotest/test_gwf_sfr_npoint01.py | 2 +- autotest/test_gwf_sto03.py | 4 +- autotest/test_prt_voronoi1.py | 1 + autotest/test_prt_voronoi2.py | 1 + 8 files changed, 57 insertions(+), 50 deletions(-) diff --git a/autotest/pytest.ini b/autotest/pytest.ini index b8e144f9f5c..f6c6634ba08 100644 --- a/autotest/pytest.ini +++ b/autotest/pytest.ini @@ -16,3 +16,8 @@ markers = lak: tests for lake package maw: tests for multi-aquifer well package parallel: test relying on a parallel (MPI+PETSc) build +filterwarnings = + # from python-dateutil, used by arrow, jupyter_client, matplotlib, pandas + ignore:datetime.datetime.utcfromtimestamp + # from pandas, see https://github.com/pandas-dev/pandas/issues/54466 + ignore:\n.*Pyarrow \ No newline at end of file diff --git a/autotest/test_gwe_esl_analyt_sln.py b/autotest/test_gwe_esl_analyt_sln.py index 38f835d139c..356c2b93c0d 100644 --- a/autotest/test_gwe_esl_analyt_sln.py +++ b/autotest/test_gwe_esl_analyt_sln.py @@ -1,51 +1,51 @@ -""" - An analytical solution provided by Carslaw & Jaeger (1947) and discussed in - accompanying Techniques & Methods report. - - Energy is added to the right hand side boundary using the energy source loading - (ESL) package. Basic model set up is below, with a slab of unit thickness - (1.0 m) that is 100 m "deep" with energy being loaded on right side. - Temperature will begin to rise on the right and propagate to the left. There are - no sinks in this first example. The titles that follow, for example - "Section 43, case x" refer to specific analytical solutions found in Carslaw & - Jaeger (1947) - - Section 43, case i: - ------------------- - - | <-------------------------- 10 m --------------------------> | - - +------------------------------------------------------------------+ - | Initial temperature = T_0 | <-- *ESL - +------------------------------------------------------------------+ - ^ * ESL: Energy Source Loading Boundary - | - No heat-flow boundary - - - Section 43, case ii: - -------------------- - - +------------------------------------------------------------------+ - | Initial temperature = 0.0 | <-- *ESL - +------------------------------------------------------------------+ - ^ - | - Specified temperature boundary, T_0 - - - Section 43, case iii: - --------------------- - +r""" +An analytical solution provided by Carslaw & Jaeger (1947) and discussed in +accompanying Techniques & Methods report. + +Energy is added to the right hand side boundary using the energy source loading +(ESL) package. Basic model set up is below, with a slab of unit thickness +(1.0 m) that is 100 m "deep" with energy being loaded on right side. +Temperature will begin to rise on the right and propagate to the left. There are +no sinks in this first example. The titles that follow, for example +"Section 43, case x" refer to specific analytical solutions found in Carslaw & +Jaeger (1947) + +Section 43, case i: +------------------- + + | <-------------------------- 10 m --------------------------> | + + +------------------------------------------------------------------+ + | Initial temperature = T_0 | <-- *ESL + +------------------------------------------------------------------+ + ^ * ESL: Energy Source Loading Boundary + | + No heat-flow boundary + + +Section 43, case ii: +-------------------- + + +------------------------------------------------------------------+ + | Initial temperature = 0.0 | <-- *ESL + +------------------------------------------------------------------+ + ^ + | + Specified temperature boundary, T_0 + + +Section 43, case iii: +--------------------- + +------------------------------------------------------------------+ CTP -> | | <- CTP = T_0 = T_0 +------------------------------------------------------------------+ - \-------------------------------------------------------------/ - | - Uniform, constant heat production throughout the slab - - - Specified temperature boundary, T_0 + \-------------------------------------------------------------/ + | + Uniform, constant heat production throughout the slab + + + Specified temperature boundary, T_0 """ diff --git a/autotest/test_gwe_lke_conduction.py b/autotest/test_gwe_lke_conduction.py index 412df9816e9..7b645fb71e4 100644 --- a/autotest/test_gwe_lke_conduction.py +++ b/autotest/test_gwe_lke_conduction.py @@ -71,7 +71,7 @@ def get_bud(fname, srchStr): def trenddetector(list_of_index, array_of_data, order=1): result = np.polyfit(list_of_index, list(array_of_data), order) slope = result[-2] - return float(slope) + return float(slope.item()) cases = ["lke-conductn", "lke-conductm", "lke-conductr"] diff --git a/autotest/test_gwe_split_analyt.py b/autotest/test_gwe_split_analyt.py index 5d8d9b16516..8b780c90399 100644 --- a/autotest/test_gwe_split_analyt.py +++ b/autotest/test_gwe_split_analyt.py @@ -1,4 +1,4 @@ -""" +r""" An analytical solution provided by Carslaw & Jaeger (1947) and discussed in accompanying Techniques & Methods report. diff --git a/autotest/test_gwf_sfr_npoint01.py b/autotest/test_gwf_sfr_npoint01.py index 7d654809633..4de3b82bcdf 100644 --- a/autotest/test_gwf_sfr_npoint01.py +++ b/autotest/test_gwf_sfr_npoint01.py @@ -33,7 +33,7 @@ "w", "v_invalid", "|/", - "\|", + r"\|", ) # spatial discretization data diff --git a/autotest/test_gwf_sto03.py b/autotest/test_gwf_sto03.py index 4e0c078ed84..19024a90708 100644 --- a/autotest/test_gwf_sto03.py +++ b/autotest/test_gwf_sto03.py @@ -194,7 +194,7 @@ def eval_hmax(fpth): bv[:] = b.get_data(totim=1.0)[obsname] sv = np.zeros(ctimes.shape, dtype=float) for i, t in enumerate(ctimes): - sv[i] = b.get_data(totim=t)[obsname] + sv[i] = b.get_data(totim=t)[obsname].item() msg = ( "maximum heads in {} exceed tolerance ".format(fpth) @@ -229,7 +229,7 @@ def check_output(idx, test): base_cmp[:] = base_obs.get_data(totim=1.0)[obsname] offset_cmp = np.zeros(cmp_times.shape, dtype=float) for i, t in enumerate(cmp_times): - offset_cmp[i] = base_obs.get_data(totim=t)[obsname] + offset_cmp[i] = base_obs.get_data(totim=t)[obsname].item() msg = ( "maximum heads exceed tolerance when offset removed " diff --git a/autotest/test_prt_voronoi1.py b/autotest/test_prt_voronoi1.py index 257be507ea5..9b3ce29ac19 100644 --- a/autotest/test_prt_voronoi1.py +++ b/autotest/test_prt_voronoi1.py @@ -402,6 +402,7 @@ def callback(mesh, value): p.show() +@pytest.mark.slow @pytest.mark.parametrize("idx, name", enumerate(cases)) def test_mf6model(idx, name, function_tmpdir, targets): if ( diff --git a/autotest/test_prt_voronoi2.py b/autotest/test_prt_voronoi2.py index cd93b532488..89ba0c666e4 100644 --- a/autotest/test_prt_voronoi2.py +++ b/autotest/test_prt_voronoi2.py @@ -421,6 +421,7 @@ def callback(mesh, value): p.show() +@pytest.mark.slow @pytest.mark.parametrize("idx, name", enumerate(cases)) def test_mf6model(idx, name, function_tmpdir, targets): test = TestFramework(