Skip to content

Commit

Permalink
refactor: fix long lines to resolve check E501 (MODFLOW-USGS#2061)
Browse files Browse the repository at this point in the history
This refactor resolves long line checks. See ruff check code E501 for more.
  • Loading branch information
mwtoews authored Nov 18, 2024
1 parent 9ed20ff commit a559974
Show file tree
Hide file tree
Showing 73 changed files with 310 additions and 182 deletions.
11 changes: 7 additions & 4 deletions autotest/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,19 +724,22 @@ def run(self):
shutil.rmtree(cmp_path)
if self.verbose:
print(
f"Copying simulation files from {self.workspace} to {cmp_path}"
"Copying simulation files "
f"from {self.workspace} to {cmp_path}"
)
shutil.copytree(self.workspace, cmp_path)

# run comparison simulation if libmf6 or mf6 regression
if self.compare in ["mf6_regression", "libmf6"]:
if self.compare not in self.targets:
warn(
f"Couldn't find comparison program '{self.compare}', skipping comparison"
f"Couldn't find comparison program '{self.compare}', "
"skipping comparison"
)
else:
# todo: don't hardcode workspace or assume agreement with test case
# simulation workspace, set & access simulation workspaces directly
# todo: don't hardcode workspace or assume agreement with
# test case simulation workspace, set & access simulation
# workspaces directly
workspace = self.workspace / self.compare
success, _ = self._run_sim_or_model(
workspace,
Expand Down
9 changes: 5 additions & 4 deletions autotest/prt_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,13 @@ def check_track_data(
data_csv = np.array([data_csv])

# check shape
assert (
data_bin.shape == data_csv.shape
), f"Binary and CSV track data shapes do not match: {data_bin.shape} != {data_csv.shape}"
assert data_bin.shape == data_csv.shape, (
"Binary and CSV track data shapes do not match: "
f"{data_bin.shape} != {data_csv.shape}"
)

# check each column separately to avoid TypeError:
# The DType <class 'numpy._FloatAbstractDType'> could not be promoted by <class 'numpy.dtype[void]'>
# The DType <class 'numpy._FloatAbstractDType'> could not be promoted by <class 'numpy.dtype[void]'> # noqa
for k in data_bin.dtype.names:
if k == "name":
continue
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_chf_dfw_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def make_plot(test):
)
ax.plot(answer_flow["TOTIME"], answer_flow["FLOW45"], "b-", label="SWR Gauge 4")
ax.plot(answer_flow["TOTIME"], answer_flow["FLOW56"], "g-", label="SWR Gauge 5")
# ax.plot(obsvals["time"], answer["STAGE0000000014"], marker="o", mfc="none", mec="k", lw=0., label="swr")
# ax.plot(obsvals["time"], answer["STAGE0000000014"], marker="o", mfc="none", mec="k", lw=0., label="swr") # noqa
ax.set_xscale("log")
plt.xlabel("time, in seconds")
plt.ylabel("flow, in cubic meters per second")
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_chf_dfw_swrt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def make_plot(test, mfsim):
lw=0.0,
label=f"MF6 reach {irch}",
)
# ax.plot(obsvals["time"], answer[f"STAGE00000000{irch:02d}"], "k-", label=f"SWR Reach {irch}")
# ax.plot(obsvals["time"], answer[f"STAGE00000000{irch:02d}"], "k-", label=f"SWR Reach {irch}") # noqa
ax.set_xlim(0, 30.0)
ax.set_ylim(1.2, 2.4)
plt.xlabel("time, in hours")
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_chf_dfw_swrt2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def make_plot(test, mfsim):
lw=0.0,
label=f"MF6 reach {irch}",
)
# ax.plot(obsvals["time"], answer[f"STAGE00000000{irch:02d}"], "k-", label=f"SWR Reach {irch}")
# ax.plot(obsvals["time"], answer[f"STAGE00000000{irch:02d}"], "k-", label=f"SWR Reach {irch}") # noqa
ax.set_xlim(0, 30.0)
ax.set_ylim(1.2, 2.4)
plt.xlabel("time, in hours")
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_bad_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def build_gwe_model(idx, sim, gwename, side="left"):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
rhow_mf6 = rhow[0]
if idx > 0 and side == "right":
# Set a parameter value that should trip a failure
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_cnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def build_models(idx, test):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_drycell_cnd0.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def build_models(idx, test):
filename=f"{gwename1}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe1,
save_flows=True,
Expand Down
9 changes: 6 additions & 3 deletions autotest/test_gwe_drycell_cnd1.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def isMonotonic(A):
cases = [
"drycell2-a", # 2-cell model, horizontally connected with tops and bots aligned
"drycell2-b", # 2-cell model, vertically connected
"drycell2-c", # 2-cell model, horizontally connected with staggered alignment (reduced shared cell face area)
"drycell2-c", # 2-cell model, horizontally connected with staggered alignment
# (reduced shared cell face area)
]

conn_types = (
Expand Down Expand Up @@ -324,7 +325,8 @@ def build_models(idx, test):
filename=f"{gwename1}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe1,
save_flows=True,
Expand Down Expand Up @@ -449,7 +451,8 @@ def check_output(idx, test):
assert isMonotonic(np.diff(conc1[12:, 0, 0, 0])), msg3
assert isMonotonic(np.diff(conc1[12:, idxl, idxr, idxc])), msg2

# Ensure that the equilibrated temperature is half the starting difference between the cells
# Ensure that the equilibrated temperature is half the starting difference
# between the cells
msg4 = (
"The final equilibrated cell temperature does not split the "
"difference of the starting temperature"
Expand Down
14 changes: 9 additions & 5 deletions autotest/test_gwe_drycell_cnd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
| |
| |
+-------+
"""
""" # noqa

# Imports

Expand Down Expand Up @@ -107,7 +107,8 @@ def isMonotonic(A):
iconvert = 1 # All cells are convertible

bot_r1 = np.zeros(ncol).tolist()
# This is the head solution for row 1, so round up to ensure neighboring cells remain dry
# This is the head solution for row 1, so round up to
# ensure neighboring cells remain dry
r2 = [
6.99850,
6.78111,
Expand Down Expand Up @@ -172,7 +173,8 @@ def isMonotonic(A):
ghb_temp = 4.0
ghb_conc_warmup = 30.0
ghb_temp_warmup = 30.0
# left boundary: cellid, elv, cond, conc, temp; right bnd: cellid, elv, cond, conc, temp
# left boundary: cellid, elv, cond, conc, temp
# right boundary: cellid, elv, cond, conc, temp
ghbspd = {
# Steady state stress period
0: [
Expand Down Expand Up @@ -361,7 +363,8 @@ def build_models(idx, test):
filename=f"{gwtname}.dsp",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGwtmst(
gwt,
porosity=prsity,
Expand Down Expand Up @@ -473,7 +476,8 @@ def build_models(idx, test):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_drycell_cnd4.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ def add_gwe_model(sim, gwename):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_esl01.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ def build_models(idx, test):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_esl02.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def build_models(idx, test):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand Down
9 changes: 5 additions & 4 deletions autotest/test_gwe_esl_analyt_sln.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
Specified temperature boundary, T_0
"""
""" # noqa

import math
import os
Expand Down Expand Up @@ -339,7 +339,8 @@ def build_models(idx, test, ener_input):
)

# Constant temperature
# Note: Implementation of the CTP boundary depends on which analytical sln is in view
# Note: Implementation of the CTP boundary depends on which analytical sln
# is in view
# See notes at top of script regarding scenarios
if idx > 0:
if idx == 1:
Expand Down Expand Up @@ -502,7 +503,7 @@ def check_output(idx, test, ener_input):
assert np.allclose(
analytical_temps, sim_temps[sp, 0, 0, :], atol=0.005
), "simulated solution is whacked"
# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution")
# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution") # noqa
# plt.plot(cell_centroids, sim_temps[sp, 0, 0, :], "b--", label="GWE")
# plt.axhline(0.0, color='black')
# plt.legend()
Expand Down Expand Up @@ -533,7 +534,7 @@ def check_output(idx, test, ener_input):
analytical_temps, sim_temps[sp, 0, 0, :], atol=atol
), "simulated solution is whacked"

# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution")
# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution") # noqa
# plt.plot(cell_centroids, sim_temps[sp, 0, 0, :], "b--", label="GWE")
# plt.axhline(0.0, color='black')
# plt.legend()
Expand Down
7 changes: 4 additions & 3 deletions autotest/test_gwe_split_analyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Specified temperature boundary, T_0
"""
""" # noqa

import math
import os
Expand Down Expand Up @@ -275,7 +275,8 @@ def get_gwe_model(idx, sim, gwename, gwepath, ener_input, side="right"):
)

# Constant temperature goes on the left side of the left model
# Note: Implementation of the CTP boundary depends on which analytical sln is in view
# Note: Implementation of the CTP boundary depends on which analytical sln
# is in view
# See notes at top of script regarding scenarios
if side == "left":
if idx > 0:
Expand Down Expand Up @@ -577,7 +578,7 @@ def check_output(idx, test):
assert np.allclose(
analytical_temps, sim_temps[sp, 0, 0, :], atol=0.005
), "simulated solution is whacked"
# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution")
# plt.plot(cell_centroids, analytical_temps, "r-", label="Analytical Solution") # noqa
# plt.plot(cell_centroids, sim_temps[sp, 0, 0, :], "b--", label="GWE")
# plt.axhline(0.0, color='black')
# plt.legend()
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_stallman.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def build_models(idx, test):
filename=f"{gwename}.dsp",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
porosity=porosity,
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_gwe_uze00.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ def check_output(idx, test):
assert np.allclose(analytical_sln[10, 38:], temps[10, 0, 0, 38:]), msg0
# Compare day 50. For layer 84 and below, the defaults of allclose should work
assert np.allclose(analytical_sln[50, 83:], temps[50, 0, 0, 83:]), msg0
# Compare day 100, fits are generally good, but do not pass allclose default settings
# Compare day 100, fits are generally good,
# but do not pass allclose default settings

# Ensure that the differences in the 1st day fall within established bounds
msg1 = (
Expand Down
11 changes: 7 additions & 4 deletions autotest/test_gwe_vs_gwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
tdis_rc = []
tdis_rc.append((perlen, nstp, 1.0))

# ### Functions to build, write, and run models and plot MT3DMS Example 10 Problem results
## Functions to build, write, and run models and plot MT3DMS Example 10 Problem results
#
# MODFLOW 6 flopy simulation object (sim) is returned if building the model

Expand Down Expand Up @@ -201,7 +201,8 @@ def build_models(idx, test):
filename=f"{gwfname}.npf",
)

# Instantiating MODFLOW 6 storage package (steady flow conditions, so no actual storage, using to print values in .lst file)
# Instantiating MODFLOW 6 storage package (steady flow conditions,
# so no actual storage, using to print values in .lst file)
flopy.mf6.ModflowGwfsto(gwf, ss=0, sy=0, pname="STO-1", filename=f"{gwfname}.sto")

# Instantiating MODFLOW 6 initial conditions package for flow model
Expand Down Expand Up @@ -307,7 +308,8 @@ def build_models(idx, test):
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 heat transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 heat transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
porosity=prsity,
Expand Down Expand Up @@ -412,7 +414,8 @@ def build_models(idx, test):
filename=f"{gwtname}.dsp",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGwtmst(
gwt,
porosity=prsity,
Expand Down
12 changes: 8 additions & 4 deletions autotest/test_gwegwe_exchng_with_comp2gwt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Two-Dimensional Heat Transport (GWE) in a Radial Flow Field with Comparison to a MODFLOW 6 GWT model
Two-Dimensional Heat Transport (GWE) in a Radial Flow Field with Comparison
to a MODFLOW 6 GWT model
The purpose of this script is to test the new heat transport model developed
for MODFLOW 6. To that end, this problem uses the setup of the fifth MT3DMS
Expand Down Expand Up @@ -493,7 +494,8 @@ def add_energy(sim):
filename="gwesolver.ims",
)

# Set the advection scheme, it is needed by both gwe model instantiation and gwegwe exchange
# Set the advection scheme, it is needed by both gwe model instantiation
# and gwegwe exchange
if mixelm >= 0:
scheme = "UPSTREAM"
elif mixelm == -1:
Expand Down Expand Up @@ -702,7 +704,8 @@ def add_transport(sim):
filename="gwtsolver.ims",
)

# Set the advection scheme, it is needed by both gwe model instantiation and gwegwe exchange
# Set the advection scheme, it is needed by both gwe model instantiation
# and gwegwe exchange
if mixelm >= 0:
scheme = "UPSTREAM"
elif mixelm == -1:
Expand Down Expand Up @@ -933,7 +936,8 @@ def check_output(idx, test):
elif idomain_ll[k, i, j] > 0:
stitched_temps[i, j] = temp_ll[tm, k, i, j]

# Stitch together the "concentrations" (which represent temperatures) from the upper-right and lower-left models
# Stitch together the "concentrations" (which represent temperatures)
# from the upper-right and lower-left models
tm = k = 0
stitched_conc = np.zeros((nrow, ncol))
for i in np.arange(nrow):
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_ats_lak01.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ def compare_listbudget_and_budgetcsv(listfile, budcsvfile, verbose, check, atol)
allclose = np.allclose(
budcsvcum[name2][1:], budlstcum[name1], atol=atol
)
msg = f"{name2} is same: {allclose}. Min diff: {mindiff} Max diff {maxdiff}"
msg = (
f"{name2} is same: {allclose}. "
f"Min diff: {mindiff} Max diff {maxdiff}"
)
if verbose:
print(msg)
allclose_list.append((allclose, name1, mindiff, maxdiff, msg))
Expand Down
Loading

0 comments on commit a559974

Please sign in to comment.