Skip to content

Commit

Permalink
test(framework): misc cleanup (#1528)
Browse files Browse the repository at this point in the history
* mention support for mf6-mf6 comparisons
* simplify parametrize arg, don't wrap with list
* consistent build_models() and check_output()
  • Loading branch information
wpbonelli authored Dec 28, 2023
1 parent da2fe92 commit 2ae4129
Show file tree
Hide file tree
Showing 206 changed files with 238 additions and 801 deletions.
1 change: 1 addition & 0 deletions autotest/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class TestFramework:
Defines a MODFLOW 6 test and its lifecycle, with configurable
hooks to evaluate results or run other models for comparison:
- MODFLOW 6 (directly or via API)
- MODFLOW-2005
- MODFLOW-NWT
- MODFLOW-USG
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_ats01.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ def check_output(idx, test):
assert v == 10.0, f"Last time should be 10. Found {v}"


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_ats02.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ def check_output(idx, test):
), "layer 1 should be dry for this period"


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_ats03.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ def check_output(idx, test):
assert np.allclose(answer, result), msg


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_ats_lak01.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ def check_output(idx, test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_auxvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ def check_output(idx, test):
assert np.allclose(r["AUX2"], auxvar2)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_auxvars02.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ def check_output(idx, test):
assert np.allclose(r[aname], a)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_boundname01.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ def check_output(idx, test):
assert np.array_equal(obs0, obs1), "observations are not identical"


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_buy_lak01.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ def check_output(idx, test):
# assert False


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_buy_lak02.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def check_output(idx, test):
# todo: add a better check of the lake concentrations


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, targets, function_tmpdir):
framework = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_buy_maw01.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,7 @@ def check_output(idx, test):
assert np.allclose(qmaw, -qgwf), msg


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_buy_sfr01.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def check_output(idx, test):
), f"reach {n} flow {qcalc} not equal {qsim}"


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_chd01.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def check_output(idx, test):
), "simulated head do not match with known solution."


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_chd02.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_output(idx, test):
), "simulated head does not match with known solution."


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_db01_nr.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_csub_dbgeo01.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
12 changes: 4 additions & 8 deletions autotest/test_gwf_csub_distypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def build_well_data(modelgrid):
return {1: well_spd}


def build_models(idx, test, gridgen):
def build_models(idx, test):
gridgen = try_get_target(test.targets, "gridgen")
return build_mf6(idx, test.workspace, gridgen), None


Expand Down Expand Up @@ -422,18 +423,13 @@ def check_output(idx, test):
)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
gridgen = try_get_target(targets, "gridgen")
test = TestFramework(
name=name,
workspace=function_tmpdir,
build=lambda t: build_models(idx, t, gridgen),
build=lambda t: build_models(idx, t),
check=lambda t: check_output(idx, t),
targets=targets,
verbose=False,
)
test.run()
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_inelastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ def check_output(idx, test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_ndb01_nr.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_csub_sk01.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sk02.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sk03.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,7 @@ def check_output(idx, test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sk04_nr.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ def check_output(idx, test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sub01.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ def cbc_compare(test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_csub_sub01_adjmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def cbc_compare(test):
print(" " + msg)


@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sub01_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,7 @@ def cbc_compare(test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sub01_pch.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,7 @@ def cbc_compare(test):
print(" " + msg)


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sub02.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ def build_models(idx, test):
return sim, mc


@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_sub03.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,7 @@ def check_output(idx, test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_subwt01.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,7 @@ def cbc_compare(test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_subwt02.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,7 @@ def cbc_compare(test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_subwt03.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,7 @@ def cbc_compare(test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
5 changes: 1 addition & 4 deletions autotest/test_gwf_csub_wc01.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,7 @@ def cbc_compare(test):


@pytest.mark.slow
@pytest.mark.parametrize(
"idx, name",
list(enumerate(cases)),
)
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_csub_wtgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def cbc_compare(test):


@pytest.mark.slow
@pytest.mark.parametrize("idx, name", list(enumerate(cases)))
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
Expand Down
Loading

0 comments on commit 2ae4129

Please sign in to comment.