Skip to content

Commit

Permalink
test: avoid warnings from 3rd party libs (#1670)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wpbonelli authored Mar 10, 2024
1 parent 486c809 commit 80aec42
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 50 deletions.
5 changes: 5 additions & 0 deletions autotest/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
90 changes: 45 additions & 45 deletions autotest/test_gwe_esl_analyt_sln.py
Original file line number Diff line number Diff line change
@@ -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
"""

Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwe_lke_conduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwe_split_analyt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
An analytical solution provided by Carslaw & Jaeger (1947) and discussed in
accompanying Techniques & Methods report.
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_sfr_npoint01.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"w",
"v_invalid",
"|/",
"\|",
r"\|",
)

# spatial discretization data
Expand Down
4 changes: 2 additions & 2 deletions autotest/test_gwf_sto03.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down
1 change: 1 addition & 0 deletions autotest/test_prt_voronoi1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions autotest/test_prt_voronoi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 80aec42

Please sign in to comment.