Skip to content

Commit

Permalink
Run: ruff check --select ISC001 --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Nov 11, 2024
1 parent 723145f commit d4e75c0
Show file tree
Hide file tree
Showing 64 changed files with 150 additions and 187 deletions.
4 changes: 2 additions & 2 deletions autotest/regression/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ def test004_create_tests_bcfss(function_tmpdir, example_data_path):
)
chk = riv_package.check()
summary = ".".join(chk.summary_array.desc)
assert summary == "Invalid non-numeric value 'bad value' in auxiliary " "data."
assert summary == "Invalid non-numeric value 'bad value' in auxiliary data."
# test with boundnames
riv_package.boundnames = True
riv_period_array = []
Expand All @@ -2064,7 +2064,7 @@ def test004_create_tests_bcfss(function_tmpdir, example_data_path):
riv_package.stress_period_data = riv_period
chk = riv_package.check()
summary = ".".join(chk.summary_array.desc)
assert summary == "Invalid non-numeric value 'bad value' in auxiliary " "data."
assert summary == "Invalid non-numeric value 'bad value' in auxiliary data."

# fix aux variable
riv_package.boundnames = False
Expand Down
9 changes: 6 additions & 3 deletions autotest/regression/test_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ def test_unitnums(function_tmpdir, mf2005_test_path):
assert m.load_fail is False, "failed to load all packages"

v = (m.nlay, m.nrow, m.ncol, m.nper)
assert v == (1, 7, 100, 50), (
"modflow-2005 testsfr2_tab does not have " "1 layer, 7 rows, and 100 columns"
)
assert v == (
1,
7,
100,
50,
), "modflow-2005 testsfr2_tab does not have 1 layer, 7 rows, and 100 columns"

success, buff = m.run_model(silent=False)
assert success, "base model run did not terminate successfully"
Expand Down
18 changes: 9 additions & 9 deletions autotest/test_binarygrid_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def test_mfgrddis_modelgrid(mfgrd_test_path):
maxvertex = max([max(sublist[1:]) for sublist in iverts])
assert maxvertex + 1 == nvert, f"nvert ({maxvertex + 1}) does not equal {nvert}"
verts = modelgrid.verts
assert nvert == verts.shape[0], (
f"number of vertex (x, y) pairs ({verts.shape[0]}) " f"does not equal {nvert}"
)
assert (
nvert == verts.shape[0]
), f"number of vertex (x, y) pairs ({verts.shape[0]}) does not equal {nvert}"


def test_mfgrddisv_MfGrdFile(mfgrd_test_path):
Expand Down Expand Up @@ -102,9 +102,9 @@ def test_mfgrddisv_modelgrid(mfgrd_test_path):
maxvertex = max([max(sublist[1:]) for sublist in iverts])
assert maxvertex + 1 == nvert, f"nvert ({maxvertex + 1}) does not equal {nvert}"
verts = mg.verts
assert nvert == verts.shape[0], (
f"number of vertex (x, y) pairs ({verts.shape[0]}) " f"does not equal {nvert}"
)
assert (
nvert == verts.shape[0]
), f"number of vertex (x, y) pairs ({verts.shape[0]}) does not equal {nvert}"

cellxy = np.column_stack(mg.xyzcellcenters[:2])
errmsg = f"shape of flow.disv centroids {cellxy.shape} not equal to (218, 2)."
Expand Down Expand Up @@ -156,6 +156,6 @@ def test_mfgrddisu_modelgrid(mfgrd_test_path):
maxvertex = max([max(sublist[1:]) for sublist in iverts])
assert maxvertex + 1 == nvert, f"nvert ({maxvertex + 1}) does not equal {nvert}"
verts = mg.verts
assert nvert == verts.shape[0], (
f"number of vertex (x, y) pairs ({verts.shape[0]}) " f"does not equal {nvert}"
)
assert (
nvert == verts.shape[0]
), f"number of vertex (x, y) pairs ({verts.shape[0]}) does not equal {nvert}"
12 changes: 6 additions & 6 deletions autotest/test_cbc_full3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def load_mf6(path, ws_out):
def cbc_eval_size(cbcobj, nnodes, shape3d):
cbc_pth = cbcobj.filename

assert cbcobj.nnodes == nnodes, (
f"{cbc_pth} nnodes ({cbcobj.nnodes}) " f"does not equal {nnodes}"
)
assert (
cbcobj.nnodes == nnodes
), f"{cbc_pth} nnodes ({cbcobj.nnodes}) does not equal {nnodes}"
a = np.squeeze(np.ones(cbcobj.shape, dtype=float))
b = np.squeeze(np.ones(shape3d, dtype=float))
assert a.shape == b.shape, (
f"{cbc_pth} shape {cbcobj.shape} " f"does not conform to {shape3d}"
)
assert (
a.shape == b.shape
), f"{cbc_pth} shape {cbcobj.shape} does not conform to {shape3d}"


def cbc_eval_data(cbcobj, shape3d):
Expand Down
6 changes: 3 additions & 3 deletions autotest/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ def test_structured_from_gridspec(example_data_path, spc_file):
maxvertex = max([max(sublist[1:]) for sublist in iverts])
assert maxvertex + 1 == nvert, f"nvert ({maxvertex + 1}) does not equal {nvert}"
verts = modelgrid.verts
assert nvert == verts.shape[0], (
f"number of vertex (x, y) pairs ({verts.shape[0]}) " f"does not equal {nvert}"
)
assert (
nvert == verts.shape[0]
), f"number of vertex (x, y) pairs ({verts.shape[0]}) does not equal {nvert}"


@requires_pkg("shapely")
Expand Down
6 changes: 2 additions & 4 deletions autotest/test_gridgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,8 @@ def test_gridgen(function_tmpdir):
455,
384,
]
msg = (
"gridgen line intersect did not identify the correct " "cells {} <> {}".format(
nlist, nlist2
)
msg = "gridgen line intersect did not identify the correct cells {} <> {}".format(
nlist, nlist2
)
assert nlist == nlist2, msg

Expand Down
16 changes: 8 additions & 8 deletions autotest/test_lake_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ def test_lake(function_tmpdir, example_data_path):
pakdata_dict[0] == 54
), f"number of lake connections ({pakdata_dict[0]}) not equal to 54."

assert len(connectiondata) == 54, (
"number of lake connectiondata entries ({}) not equal " "to 54.".format(
len(connectiondata)
)
assert (
len(connectiondata) == 54
), "number of lake connectiondata entries ({}) not equal to 54.".format(
len(connectiondata)
)

lak_pak_data = []
Expand Down Expand Up @@ -461,10 +461,10 @@ def test_embedded_lak_ex01(function_tmpdir, example_data_path):
pakdata_dict[0] == 57
), f"number of lake connections ({pakdata_dict[0]}) not equal to 57."

assert len(connectiondata) == 57, (
"number of lake connectiondata entries ({}) not equal " "to 57.".format(
len(connectiondata)
)
assert (
len(connectiondata) == 57
), "number of lake connectiondata entries ({}) not equal to 57.".format(
len(connectiondata)
)

lak_pak_data = []
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_model_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ def build_gwt_model(sim, gwtname, rch_package):

X_split = mfs.reconstruct_array(array_dict)

err_msg = f"Outputs from {name} and split model " f"are not within tolerance"
err_msg = f"Outputs from {name} and split model are not within tolerance"
X_split[idomain == 0] = np.nan
X[idomain == 0] = np.nan
if name == "gwf":
Expand Down
4 changes: 2 additions & 2 deletions autotest/test_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ def test_multilayerhob_pr_multiline():
problem_hob = [
"2 4 7",
"1 1",
"A19E1_1 -2 140 91 1 1 -0.28321 -0.05389" " 69 1 1 1 # A19E1 8/13/1975",
"A19E1_1 -2 140 91 1 1 -0.28321 -0.05389 69 1 1 1 # A19E1 8/13/1975",
"3 0.954",
"4 0.046",
"A19E1_2 -2 140 91 1 1 -0.28321 -0.05389" " 72 1 1 1 # A19E1 10/9/1975",
"A19E1_2 -2 140 91 1 1 -0.28321 -0.05389 72 1 1 1 # A19E1 10/9/1975",
"3 0.954",
"4 0.046",
]
Expand Down
4 changes: 1 addition & 3 deletions autotest/test_usg.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ def test_usg_model(function_tmpdir):

@requires_exe("mfusg")
def test_usg_load_01B(function_tmpdir, mfusg_01A_nestedgrid_nognc_model_path):
print(
"testing 1-layer unstructured mfusg model " "loading: 01A_nestedgrid_nognc.nam"
)
print("testing 1-layer unstructured mfusg model loading: 01A_nestedgrid_nognc.nam")

fname = mfusg_01A_nestedgrid_nognc_model_path / "flow.nam"
assert os.path.isfile(fname), f"nam file not found {fname}"
Expand Down
2 changes: 1 addition & 1 deletion flopy/discretization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def zcellcenters(self):
@property
def xyzcellcenters(self):
raise NotImplementedError(
"must define get_cellcenters in child " "class to use this base class"
"must define get_cellcenters in child class to use this base class"
)

@property
Expand Down
4 changes: 2 additions & 2 deletions flopy/export/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def mflist_export(f: Union[str, os.PathLike, NetCdf], mfl, **kwargs):
"""
if not isinstance(mfl, (DataListInterface, DataInterface)):
err = "mflist_helper only helps instances that support " "DataListInterface"
err = "mflist_helper only helps instances that support DataListInterface"
raise AssertionError(err)

modelgrid = mfl.model.modelgrid
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def transient2d_export(f: Union[str, os.PathLike], t2d, fmt=None, **kwargs):
"""

if not isinstance(t2d, DataInterface):
err = "transient2d_helper only helps instances that support " "DataInterface"
err = "transient2d_helper only helps instances that support DataInterface"
raise AssertionError(err)

min_valid = kwargs.get("min_valid", -1.0e9)
Expand Down
2 changes: 1 addition & 1 deletion flopy/export/vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ def add_cell_budget(self, cbc, text=None, kstpkper=None, masked_values=None):
if array.size < self.nnodes:
if array.size < self.ncpl:
raise AssertionError(
"Array size must be equal to " "either ncpl or nnodes"
"Array size must be equal to either ncpl or nnodes"
)

array = np.zeros(self.nnodes) * np.nan
Expand Down
4 changes: 2 additions & 2 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ def set_output_attribute(
break
else:
raise TypeError(
"either fname or unit must be passed " "to set_output_attribute()"
"either fname or unit must be passed to set_output_attribute()"
)
if attr is not None:
if idx is not None:
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def get_output_attribute(
break
else:
raise TypeError(
"either fname or unit must be passed " "to set_output_attribute()"
"either fname or unit must be passed to set_output_attribute()"
)
v = None
if attr is not None:
Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/coordinates/modelgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def get_idomain(self):
return self._simulation_data.mfdata[
(self._model_name, "disv2d", "griddata", "idomain")
].get_data()
except_str = "ERROR: Grid type {} for model {} not " "recognized.".format(
except_str = "ERROR: Grid type {} for model {} not recognized.".format(
self._grid_type, self._model_name
)
print(except_str)
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mfdataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def store_as_external_file(
>= VerbosityLevel.verbose.value
):
print(
"Storing {} layer {} to external file {}.." ".".format(
"Storing {} layer {} to external file {}...".format(
self.structure.name,
current_layer[0] + 1,
file_path,
Expand Down Expand Up @@ -622,7 +622,7 @@ def store_internal(
>= VerbosityLevel.verbose.value
):
print(
"Storing {} layer {} internally.." ".".format(
"Storing {} layer {} internally...".format(
self.structure.name,
current_layer[0] + 1,
)
Expand Down
8 changes: 3 additions & 5 deletions flopy/mf6/data/mfdatalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def store_as_external_file(
>= VerbosityLevel.verbose.value
):
print(
"Storing {} to external file {}.." ".".format(
"Storing {} to external file {}...".format(
self.structure.name, external_file_path
)
)
Expand Down Expand Up @@ -1167,7 +1167,7 @@ def _get_file_entry_record(
self.structure.get_model(),
self.structure.get_package(),
self._path,
"converting data " "to a string",
"converting data to a string",
self.structure.name,
inspect.stack()[0][3],
type_,
Expand Down Expand Up @@ -1809,9 +1809,7 @@ def _set_data_record(
super().set_data(data, autofill)
else:
if is_record:
comment = (
"Set record method requires that data_record is a " "dictionary."
)
comment = "Set record method requires that data_record is a dictionary."
type_, value_, traceback_ = sys.exc_info()
raise MFDataException(
self.structure.get_model(),
Expand Down
6 changes: 2 additions & 4 deletions flopy/mf6/data/mfdataplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ def store_as_external_file(
>= VerbosityLevel.verbose.value
):
print(
"Storing {} to external file {}.." ".".format(
"Storing {} to external file {}...".format(
self.structure.name, external_file_path
)
)
Expand Down Expand Up @@ -2271,9 +2271,7 @@ def _set_data_record(
super().set_data(data_record, autofill)
else:
if is_record:
comment = (
"Set record method requires that data_record is a " "dictionary."
)
comment = "Set record method requires that data_record is a dictionary."
type_, value_, traceback_ = sys.exc_info()
raise MFDataException(
self.structure.get_model(),
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mfdatascalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def set_data(self, data):
except Exception as ex:
type_, value_, traceback_ = sys.exc_info()
comment = (
f'Could not convert data "{data}" to type ' f'"{self._data_type}".'
f'Could not convert data "{data}" to type "{self._data_type}".'
)
raise MFDataException(
self.structure.get_model(),
Expand Down Expand Up @@ -293,7 +293,7 @@ def add_one(self):
ex,
)
else:
message = "{} of type {} does not support add one " "operation.".format(
message = "{} of type {} does not support add one operation.".format(
self._data_name, self.structure.get_datum_type()
)
type_, value_, traceback_ = sys.exc_info()
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mffileaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _get_next_data_line(self, file_handle):
while not end_of_file:
line = file_handle.readline()
if line == "":
message = "More data expected when reading {} from file " "{}".format(
message = "More data expected when reading {} from file {}".format(
self.structure.name, file_handle.name
)
type_, value_, traceback_ = sys.exc_info()
Expand Down Expand Up @@ -1656,7 +1656,7 @@ def load_list_line(
struct.get_model(),
struct.get_package(),
struct.path,
"loading data list from " "package file",
"loading data list from package file",
struct.name,
inspect.stack()[0][3],
type_,
Expand Down
4 changes: 1 addition & 3 deletions flopy/mf6/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,9 +1164,7 @@ def inspect_cells(
fd.write(f"Results from {package_name}\n")
for search_output in matches:
# write header line with data name
fd.write(
f",Results from " f"{search_output.path_to_data[-1]}\n"
)
fd.write(f",Results from {search_output.path_to_data[-1]}\n")
# write data header
if search_output.transient:
if search_output.output:
Expand Down
Loading

0 comments on commit d4e75c0

Please sign in to comment.