Skip to content

Commit

Permalink
refactor(imports): add function to import optional packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Oct 11, 2021
1 parent 99610dd commit abe2900
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
8 changes: 2 additions & 6 deletions autotest/t005_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def test_modflow_unstructured():
lpf = flopy.mfusg.MfUsgLpf(mf)
assert isinstance(lpf, flopy.mfusg.MfUsgLpf)

wel = flopy.mfusg.MfUsgWel(
mf, stress_period_data={0: [[0, -100]]}
)
wel = flopy.mfusg.MfUsgWel(mf, stress_period_data={0: [[0, -100]]})
assert isinstance(wel, flopy.mfusg.MfUsgWel)

ghb = flopy.modflow.ModflowGhb(
Expand All @@ -44,9 +42,7 @@ def test_modflow_unstructured():
# write well file
wel.write_file()
assert os.path.isfile(os.path.join(cpth, f"{mf.name}.wel")) is True
wel2 = flopy.mfusg.MfUsgWel.load(
os.path.join(cpth, f"{mf.name}.wel"), mf
)
wel2 = flopy.mfusg.MfUsgWel.load(os.path.join(cpth, f"{mf.name}.wel"), mf)
assert wel2.stress_period_data[0] == wel.stress_period_data[0]

# write ghb file
Expand Down
4 changes: 1 addition & 3 deletions autotest/t016_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def test_usg_model():
dis = flopy.modflow.ModflowDis(mf, nlay=1, nrow=11, ncol=11)
bas = flopy.modflow.ModflowBas(mf)
lpf = flopy.mfusg.MfUsgLpf(mf)
wel = flopy.mfusg.MfUsgWel(
mf, stress_period_data={0: [[0, 5, 5, -1.0]]}
)
wel = flopy.mfusg.MfUsgWel(mf, stress_period_data={0: [[0, 5, 5, -1.0]]})
ghb = flopy.modflow.ModflowGhb(
mf,
stress_period_data={
Expand Down
18 changes: 12 additions & 6 deletions autotest/t080_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
if not os.path.exists(gridgen_ws):
os.makedirs(gridgen_ws)


def test_mfusg():

name = "dummy"
Expand Down Expand Up @@ -113,18 +114,23 @@ def test_mfusg():

# test if single node idx works
one_hds = flopy.utils.HeadUFile(head_file).get_ts(idx=300)
if one_hds[0,1] != head[0][300]:
raise AssertionError("Error head from 'get_ts' != head from 'get_data'")
if one_hds[0, 1] != head[0][300]:
raise AssertionError(
"Error head from 'get_ts' != head from 'get_data'"
)

# test if list of nodes for idx works
nodes = [300,182,65]
nodes = [300, 182, 65]

multi_hds = flopy.utils.HeadUFile(head_file).get_ts(idx=nodes)
for i, node in enumerate(nodes):
if multi_hds[0, i+1] != head[0][node]:
raise AssertionError("Error head from 'get_ts' != head from 'get_data'")
if multi_hds[0, i + 1] != head[0][node]:
raise AssertionError(
"Error head from 'get_ts' != head from 'get_data'"
)

return

if __name__ == '__main__':

if __name__ == "__main__":
test_mfusg()
4 changes: 1 addition & 3 deletions autotest/t506_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,7 @@ def test_mfusg():

# re-run with an LPF keyword specified. This would have thrown an error
# before the addition of ikcflag to mflpf.py (flopy 3.3.3 and earlier).
lpf = flopy.mfusg.MfUsgLpf(
m, novfc=True, nocvcorrection=True
)
lpf = flopy.mfusg.MfUsgLpf(m, novfc=True, nocvcorrection=True)
m.write_input()
m.run_model()

Expand Down

0 comments on commit abe2900

Please sign in to comment.