diff --git a/.docs/Notebooks/export_vtk_tutorial.py b/.docs/Notebooks/export_vtk_tutorial.py index 9ccc2c083..e701e69cb 100644 --- a/.docs/Notebooks/export_vtk_tutorial.py +++ b/.docs/Notebooks/export_vtk_tutorial.py @@ -216,13 +216,7 @@ ## add recharge to the VTK object recharge = ml.rch.rech.transient_2ds -vtkobj.add_transient_array( - recharge, - "recharge", - masked_values=[ - 0, - ], -) +vtkobj.add_transient_array(recharge, "recharge", masked_values=[0]) ## write vtk files vtkobj.write(output_dir / "tr_array_example" / "recharge.vtu") @@ -242,12 +236,7 @@ ## add well fluxes to the VTK object spd = ml.wel.stress_period_data -vtkobj.add_transient_list( - spd, - masked_values=[ - 0, - ], -) +vtkobj.add_transient_list(spd, masked_values=[0]) ## write vtk files vtkobj.write(output_dir / "tr_list_example" / "wel_flux.vtu") @@ -412,17 +401,7 @@ def run_vertex_grid_example(ws): xmax = 12 * delr ymin = 8 * delc ymax = 13 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) rf1shp = os.path.join(gridgen_ws, "rf1") @@ -430,17 +409,7 @@ def run_vertex_grid_example(ws): xmax = 11 * delr ymin = 9 * delc ymax = 12 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) rf2shp = os.path.join(gridgen_ws, "rf2") @@ -448,17 +417,7 @@ def run_vertex_grid_example(ws): xmax = 10 * delr ymin = 10 * delc ymax = 11 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) g.build(verbose=False) diff --git a/.docs/Notebooks/get_transmissivities_example.py b/.docs/Notebooks/get_transmissivities_example.py index 85519393a..be2faefb3 100644 --- a/.docs/Notebooks/get_transmissivities_example.py +++ b/.docs/Notebooks/get_transmissivities_example.py @@ -106,11 +106,7 @@ plt.plot(heads[0], label="piezometric surface", color="b", linestyle=":") for iw in range(len(sctop)): ax.fill_between( - [iw - 0.25, iw + 0.25], - scbot[iw], - sctop[iw], - facecolor="None", - edgecolor="k", + [iw - 0.25, iw + 0.25], scbot[iw], sctop[iw], facecolor="None", edgecolor="k" ) ax.legend(loc=2) diff --git a/.docs/Notebooks/grid_intersection_example.py b/.docs/Notebooks/grid_intersection_example.py index 65a468979..74218c315 100644 --- a/.docs/Notebooks/grid_intersection_example.py +++ b/.docs/Notebooks/grid_intersection_example.py @@ -44,13 +44,7 @@ import matplotlib.pyplot as plt import numpy as np import shapely -from shapely.geometry import ( - LineString, - MultiLineString, - MultiPoint, - Point, - Polygon, -) +from shapely.geometry import LineString, MultiLineString, MultiPoint, Point, Polygon import flopy import flopy.discretization as fgrid @@ -110,15 +104,7 @@ # Polygon to intersect with: p = Polygon( - shell=[ - (15, 15), - (20, 50), - (35, 80.0), - (80, 50), - (80, 40), - (40, 5), - (15, 12), - ], + shell=[(15, 15), (20, 50), (35, 80.0), (80, 50), (80, 40), (40, 5), (15, 12)], holes=[[(25, 25), (25, 45), (45, 45), (45, 25)]], ) @@ -261,12 +247,7 @@ # MultiPoint to intersect with mp = MultiPoint( - points=[ - Point(50.0, 0.0), - Point(45.0, 45.0), - Point(10.0, 10.0), - Point(150.0, 100.0), - ] + points=[Point(50.0, 0.0), Point(45.0, 45.0), Point(10.0, 10.0), Point(150.0, 100.0)] ) # For points and linestrings there is a keyword argument `return_all_intersections` which will return multiple intersection results for points or (parts of) linestrings on cell boundaries. As an example, the difference is shown with the MultiPoint intersection. Note the number of red "+" symbols indicating the centroids of intersected cells, in the bottom left case, there are 4 results because the point lies exactly on the intersection between 4 grid cells. diff --git a/.docs/Notebooks/groundwater2023_watershed_example.py b/.docs/Notebooks/groundwater2023_watershed_example.py index 35d845917..3b9c804dc 100644 --- a/.docs/Notebooks/groundwater2023_watershed_example.py +++ b/.docs/Notebooks/groundwater2023_watershed_example.py @@ -233,14 +233,7 @@ def set_idomain(grid, boundary): pmv = flopy.plot.PlotMapView(modelgrid=struct_grid) ax.set_aspect("equal") pmv.plot_array(top_sg) -pmv.plot_array( - intersection_sg, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_sg, masked_values=[0], alpha=0.2, cmap="Reds_r") pmv.plot_grid(lw=0.25, color="0.5") cg = pmv.contour_array(top_sg, levels=levels, linewidths=0.3, colors="0.75") pmv.plot_inactive() @@ -314,14 +307,7 @@ def set_idomain(grid, boundary): pmv = flopy.plot.PlotMapView(modelgrid=struct_vrc_grid) ax.set_aspect("equal") pmv.plot_array(top_sg_vrc) -pmv.plot_array( - intersection_sg_vrc, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_sg_vrc, masked_values=[0], alpha=0.2, cmap="Reds_r") cg = pmv.contour_array(top_sg_vrc, levels=levels, linewidths=0.3, colors="0.75") pmv.plot_inactive() @@ -437,14 +423,7 @@ def set_idomain(grid, boundary): pmv = flopy.plot.PlotMapView(modelgrid=struct_gridp, extent=extent) pmv.plot_inactive() pmv.plot_array(top_ngp, vmin=vmin, vmax=vmax) -pmv.plot_array( - intersection_nested_grid[0], - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_nested_grid[0], masked_values=[0], alpha=0.2, cmap="Reds_r") cgp = pmv.contour_array(top_ngp, levels=levels, linewidths=0.3, colors="0.75") pmv.plot_inactive(zorder=100) ax.set_aspect("equal") @@ -453,12 +432,7 @@ def set_idomain(grid, boundary): # pmvc.plot_grid() pmvc.plot_array(top_ngc, vmin=vmin, vmax=vmax) pmvc.plot_array( - intersection_nested_grid[1], - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", + intersection_nested_grid[1], masked_values=[0], alpha=0.2, cmap="Reds_r" ) cgc = pmvc.contour_array(top_ngc, levels=levels, linewidths=0.3, colors="0.75") @@ -532,14 +506,7 @@ def set_idomain(grid, boundary): ax = fig.add_subplot() pmv = flopy.plot.PlotMapView(modelgrid=quadtree_grid) pmv.plot_array(top_qg, ec="0.75") -pmv.plot_array( - intersection_qg, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_qg, masked_values=[0], alpha=0.2, cmap="Reds_r") cg = pmv.contour_array(top_qg, levels=levels, linewidths=0.3, colors="white") pmv.plot_inactive(zorder=100) ax.set_aspect("equal") @@ -615,14 +582,7 @@ def set_idomain(grid, boundary): pmv = flopy.plot.PlotMapView(modelgrid=triangular_grid) pmv.plot_array(top_tg, ec="0.75") -pmv.plot_array( - intersection_tg, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_tg, masked_values=[0], alpha=0.2, cmap="Reds_r") cg = pmv.contour_array(top_tg, levels=levels, linewidths=0.3, colors="white") ax.clabel(cg, cg.levels, inline=True, fmt="%1.0f", fontsize=10) @@ -670,14 +630,7 @@ def set_idomain(grid, boundary): pmv = flopy.plot.PlotMapView(modelgrid=voronoi_grid) ax.set_aspect("equal") pmv.plot_array(top_vg) -pmv.plot_array( - intersection_vg, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", -) +pmv.plot_array(intersection_vg, masked_values=[0], alpha=0.2, cmap="Reds_r") pmv.plot_inactive() ax.plot(bp[:, 0], bp[:, 1], "k-") for sg in sgs: @@ -789,29 +742,10 @@ def set_idomain(grid, boundary): ax.set_ylim(0, 1) ax.set_axis_off() - ax.axhline( - xy0[0], - color="black", - lw=2, - label="Basin boundary", - ) - ax.axhline( - xy0[0], - **river_dict, - label="River", - ) - ax.axhline( - xy0[0], - color=contour_color, - lw=0.5, - ls="--", - label="Elevation contour", - ) - ax.axhline( - xy0[0], - label="Grid refinement area", - **refinement_dict, - ) + ax.axhline(xy0[0], color="black", lw=2, label="Basin boundary") + ax.axhline(xy0[0], **river_dict, label="River") + ax.axhline(xy0[0], color=contour_color, lw=0.5, ls="--", label="Elevation contour") + ax.axhline(xy0[0], label="Grid refinement area", **refinement_dict) ax.axhline( xy0[0], marker="s", @@ -844,23 +778,10 @@ def set_idomain(grid, boundary): ax.set_xlim(0, 1) ax.set_ylim(0, 1) ax.set_axis_off() - cax = ax.inset_axes( - cbar_axis, - ) + cax = ax.inset_axes(cbar_axis) # cax.set_axisbelow(False) - cbar = plt.colorbar( - v, - orientation="vertical", - cax=cax, - ticks=[25, 50, 75, 100], - ) - cbar.ax.tick_params( - labelsize=5, - labelcolor="black", - color="black", - length=9, - pad=2, - ) + cbar = plt.colorbar(v, orientation="vertical", cax=cax, ticks=[25, 50, 75, 100]) + cbar.ax.tick_params(labelsize=5, labelcolor="black", color="black", length=9, pad=2) cbar.ax.set_title("Elevation (m)", pad=2.5, loc="center", fontdict=font_dict) # - @@ -971,11 +892,7 @@ def set_idomain(grid, boundary): ax.set_axis_off() ax.axhline(xy0[0], **river_dict, label="River") - ax.axhline( - xy0[0], - label="Grid refinement area", - **refinement_dict, - ) + ax.axhline(xy0[0], label="Grid refinement area", **refinement_dict) ax.axhline( xy0[0], marker="s", diff --git a/.docs/Notebooks/groundwater_paper_uspb_example.py b/.docs/Notebooks/groundwater_paper_uspb_example.py index a4cd8d1f8..ac3af280e 100644 --- a/.docs/Notebooks/groundwater_paper_uspb_example.py +++ b/.docs/Notebooks/groundwater_paper_uspb_example.py @@ -42,11 +42,7 @@ os.makedirs(ws) fn = os.path.join( - "..", - "groundwater_paper", - "uspb", - "results", - "USPB_capture_fraction_04_01.dat", + "..", "groundwater_paper", "uspb", "results", "USPB_capture_fraction_04_01.dat" ) cf = np.loadtxt(fn) print(cf.shape) @@ -86,11 +82,7 @@ label="Maximum active model extent", ) plt.plot( - [-10000, 0], - [-10000, 0], - color="purple", - lw=0.75, - label="STR reaches (all layers)", + [-10000, 0], [-10000, 0], color="purple", lw=0.75, label="STR reaches (all layers)" ) leg = plt.legend(loc="upper left", numpoints=1, prop={"size": 6}) leg.draw_frame(False) @@ -200,11 +192,7 @@ # - fn = os.path.join( - "..", - "groundwater_paper", - "uspb", - "results", - "USPB_capture_fraction_04_10.dat", + "..", "groundwater_paper", "uspb", "results", "USPB_capture_fraction_04_10.dat" ) cf = np.loadtxt(fn) cf2 = scipy.ndimage.zoom(cf, 4, order=0) diff --git a/.docs/Notebooks/load_swr_binary_data_example.py b/.docs/Notebooks/load_swr_binary_data_example.py index cd07ff088..d7313d121 100644 --- a/.docs/Notebooks/load_swr_binary_data_example.py +++ b/.docs/Notebooks/load_swr_binary_data_example.py @@ -182,10 +182,7 @@ stage = np.extract(iprof, s["stage"]) xs = flopy.plot.PlotCrossSection(model=ml, line={"Row": 0}) xs.plot_fill_between( - stage.reshape(1, 1, 12), - colors=["none", "blue"], - ax=ax, - edgecolors="none", + stage.reshape(1, 1, 12), colors=["none", "blue"], ax=ax, edgecolors="none" ) linecollection = xs.plot_grid(ax=ax, zorder=10) ax.fill_between( diff --git a/.docs/Notebooks/mf6_complex_model_example.py b/.docs/Notebooks/mf6_complex_model_example.py index 01bdc9b3e..15d280600 100644 --- a/.docs/Notebooks/mf6_complex_model_example.py +++ b/.docs/Notebooks/mf6_complex_model_example.py @@ -45,14 +45,7 @@ model_name = "advgw_tidal" workspace = os.path.join(temp_dir.name, model_name) -data_pth = os.path.join( - "..", - "..", - "examples", - "data", - "mf6", - "test005_advgw_tidal", -) +data_pth = os.path.join("..", "..", "examples", "data", "mf6", "test005_advgw_tidal") assert os.path.isdir(data_pth) # + @@ -158,30 +151,18 @@ # well package # test empty with aux vars, bound names, and time series period_two = flopy.mf6.ModflowGwfwel.stress_period_data.empty( - gwf, - maxbound=3, - aux_vars=["var1", "var2", "var3"], - boundnames=True, - timeseries=True, + gwf, maxbound=3, aux_vars=["var1", "var2", "var3"], boundnames=True, timeseries=True ) period_two[0][0] = ((0, 11, 2), -50.0, -1, -2, -3, None) period_two[0][1] = ((2, 4, 7), "well_1_rate", 1, 2, 3, "well_1") period_two[0][2] = ((2, 3, 2), "well_2_rate", 4, 5, 6, "well_2") period_three = flopy.mf6.ModflowGwfwel.stress_period_data.empty( - gwf, - maxbound=2, - aux_vars=["var1", "var2", "var3"], - boundnames=True, - timeseries=True, + gwf, maxbound=2, aux_vars=["var1", "var2", "var3"], boundnames=True, timeseries=True ) period_three[0][0] = ((2, 3, 2), "well_2_rate", 1, 2, 3, "well_2") period_three[0][1] = ((2, 4, 7), "well_1_rate", 4, 5, 6, "well_1") period_four = flopy.mf6.ModflowGwfwel.stress_period_data.empty( - gwf, - maxbound=5, - aux_vars=["var1", "var2", "var3"], - boundnames=True, - timeseries=True, + gwf, maxbound=5, aux_vars=["var1", "var2", "var3"], boundnames=True, timeseries=True ) period_four[0][0] = ((2, 4, 7), "well_1_rate", 1, 2, 3, "well_1") period_four[0][1] = ((2, 3, 2), "well_2_rate", 4, 5, 6, "well_2") @@ -373,15 +354,7 @@ ("rv2-upper", "RIV", "riv2_upper"), ("rv-2-7-4", "RIV", (0, 6, 3)), ("rv2-8-5", "RIV", (0, 6, 4)), - ( - "rv-2-9-6", - "RIV", - ( - 0, - 5, - 5, - ), - ), + ("rv-2-9-6", "RIV", (0, 5, 5)), ], "riv_flowsA.csv": [ ("riv1-3-1", "RIV", (0, 2, 0)), diff --git a/.docs/Notebooks/mf6_data_tutorial03.py b/.docs/Notebooks/mf6_data_tutorial03.py index 359696489..a4ec2ebef 100644 --- a/.docs/Notebooks/mf6_data_tutorial03.py +++ b/.docs/Notebooks/mf6_data_tutorial03.py @@ -240,20 +240,17 @@ print( "{} is using {} interpolation".format( - ghb.ts[0].filename, - ghb.ts[0].interpolation_methodrecord.get_data()[0][0], + ghb.ts[0].filename, ghb.ts[0].interpolation_methodrecord.get_data()[0][0] ) ) print( "{} is using {} interpolation".format( - ghb.ts[1].filename, - ghb.ts[1].interpolation_methodrecord.get_data()[0][0], + ghb.ts[1].filename, ghb.ts[1].interpolation_methodrecord.get_data()[0][0] ) ) print( "{} is using {} interpolation".format( - ghb.ts[2].filename, - ghb.ts[2].interpolation_methodrecord.get_data()[0][0], + ghb.ts[2].filename, ghb.ts[2].interpolation_methodrecord.get_data()[0][0] ) ) diff --git a/.docs/Notebooks/mf6_data_tutorial08.py b/.docs/Notebooks/mf6_data_tutorial08.py index 678347c56..6d36db95e 100644 --- a/.docs/Notebooks/mf6_data_tutorial08.py +++ b/.docs/Notebooks/mf6_data_tutorial08.py @@ -243,10 +243,7 @@ # These options can also be turned off when loading an existing simulation # or creating a new simulation by setting lazy_io to True. -sim2 = flopy.mf6.MFSimulation.load( - sim_ws=workspace, - lazy_io=True, -) +sim2 = flopy.mf6.MFSimulation.load(sim_ws=workspace, lazy_io=True) sim3 = flopy.mf6.MFSimulation(lazy_io=True) diff --git a/.docs/Notebooks/mf6_data_tutorial10.py b/.docs/Notebooks/mf6_data_tutorial10.py index f1e50dfe5..4a74df676 100644 --- a/.docs/Notebooks/mf6_data_tutorial10.py +++ b/.docs/Notebooks/mf6_data_tutorial10.py @@ -567,20 +567,17 @@ # retreive information from each time series print( "{} is using {} interpolation".format( - ghb.ts[0].filename, - ghb.ts[0].interpolation_methodrecord.get_data()[0][0], + ghb.ts[0].filename, ghb.ts[0].interpolation_methodrecord.get_data()[0][0] ) ) print( "{} is using {} interpolation".format( - ghb.ts[1].filename, - ghb.ts[1].interpolation_methodrecord.get_data()[0][0], + ghb.ts[1].filename, ghb.ts[1].interpolation_methodrecord.get_data()[0][0] ) ) print( "{} is using {} interpolation".format( - ghb.ts[2].filename, - ghb.ts[2].interpolation_methodrecord.get_data()[0][0], + ghb.ts[2].filename, ghb.ts[2].interpolation_methodrecord.get_data()[0][0] ) ) diff --git a/.docs/Notebooks/mf6_lgr_tutorial01.py b/.docs/Notebooks/mf6_lgr_tutorial01.py index 1e4f3d168..b30608c78 100644 --- a/.docs/Notebooks/mf6_lgr_tutorial01.py +++ b/.docs/Notebooks/mf6_lgr_tutorial01.py @@ -551,10 +551,7 @@ # + # load and store the head arrays from the parent and child models head = [gwfp.output.head().get_data(), gwfc.output.head().get_data()] -conc = [ - gwtp.output.concentration().get_data(), - gwtc.output.concentration().get_data(), -] +conc = [gwtp.output.concentration().get_data(), gwtc.output.concentration().get_data()] # load and store the specific discharge results for the parent and child models bud = gwfp.output.budget() diff --git a/.docs/Notebooks/mf6_parallel_model_splitting_example.py b/.docs/Notebooks/mf6_parallel_model_splitting_example.py index 2e90eac30..7895f6bcf 100644 --- a/.docs/Notebooks/mf6_parallel_model_splitting_example.py +++ b/.docs/Notebooks/mf6_parallel_model_splitting_example.py @@ -328,14 +328,7 @@ def string2geom(geostring, conversion=None): pmv = flopy.plot.PlotMapView(modelgrid=modelgrid) ax.set_aspect("equal") pmv.plot_array(modelgrid.top) - pmv.plot_array( - intersection_rg, - masked_values=[ - 0, - ], - alpha=0.2, - cmap="Reds_r", - ) + pmv.plot_array(intersection_rg, masked_values=[0], alpha=0.2, cmap="Reds_r") pmv.plot_inactive() ax.plot(bp[:, 0], bp[:, 1], "r-") for seg in segs: @@ -513,11 +506,7 @@ def string2geom(geostring, conversion=None): pmv = flopy.plot.PlotMapView(modelgrid=gwf.modelgrid, ax=ax) h = pmv.plot_array(heads, vmin=hmin, vmax=hmax) c = pmv.contour_array( - water_table, - levels=contours, - colors="white", - linewidths=0.75, - linestyles=":", + water_table, levels=contours, colors="white", linewidths=0.75, linestyles=":" ) plt.clabel(c, fontsize=8) pmv.plot_inactive() @@ -633,11 +622,7 @@ def string2geom(geostring, conversion=None): h = pmv.plot_array(hv[idx], vmin=vmin, vmax=vmax) if levels is not None: c = pmv.contour_array( - hv[idx], - levels=levels, - colors="white", - linewidths=0.75, - linestyles=":", + hv[idx], levels=levels, colors="white", linewidths=0.75, linestyles=":" ) plt.clabel(c, fontsize=8) pmv.plot_inactive() @@ -716,11 +701,7 @@ def string2geom(geostring, conversion=None): h = pmv.plot_array(hv[idx], vmin=vmin, vmax=vmax) if levels is not None: c = pmv.contour_array( - hv[idx], - levels=levels, - colors="white", - linewidths=0.75, - linestyles=":", + hv[idx], levels=levels, colors="white", linewidths=0.75, linestyles=":" ) plt.clabel(c, fontsize=8) pmv.plot_inactive() diff --git a/.docs/Notebooks/mf6_support_example.py b/.docs/Notebooks/mf6_support_example.py index c2c6cb7ae..6f8cd97d8 100644 --- a/.docs/Notebooks/mf6_support_example.py +++ b/.docs/Notebooks/mf6_support_example.py @@ -174,18 +174,7 @@ ] k_template = flopy.mf6.ModflowGwfnpf.k.empty(model, True, layer_storage_types, 100.0) # change the value of the second layer to 50.0 -k_template[0]["data"] = [ - 65.0, - 60.0, - 55.0, - 50.0, - 45.0, - 40.0, - 35.0, - 30.0, - 25.0, - 20.0, -] +k_template[0]["data"] = [65.0, 60.0, 55.0, 50.0, 45.0, 40.0, 35.0, 30.0, 25.0, 20.0] k_template[0]["factor"] = 1.5 print(k_template) # create npf package using the k template to define k diff --git a/.docs/Notebooks/mf6_tutorial01.py b/.docs/Notebooks/mf6_tutorial01.py index e399c1e44..718ed3bdd 100644 --- a/.docs/Notebooks/mf6_tutorial01.py +++ b/.docs/Notebooks/mf6_tutorial01.py @@ -126,11 +126,7 @@ # ### Create the node property flow (`NPF`) Package -npf = flopy.mf6.ModflowGwfnpf( - gwf, - icelltype=1, - k=k, -) +npf = flopy.mf6.ModflowGwfnpf(gwf, icelltype=1, k=k) # ### Create the constant head (`CHD`) Package # @@ -147,10 +143,7 @@ if row_col != 0 and row_col != N - 1: chd_rec.append(((layer, 0, row_col), h1)) chd_rec.append(((layer, N - 1, row_col), h1)) -chd = flopy.mf6.ModflowGwfchd( - gwf, - stress_period_data=chd_rec, -) +chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chd_rec) # The `CHD` Package stored the constant heads in a structured array, # also called a `numpy.recarray`. We can get a pointer to the recarray @@ -165,10 +158,7 @@ # Add a well in model layer 10. wel_rec = [(Nlay - 1, int(N / 4), int(N / 4), q)] -wel = flopy.mf6.ModflowGwfwel( - gwf, - stress_period_data=wel_rec, -) +wel = flopy.mf6.ModflowGwfwel(gwf, stress_period_data=wel_rec) # ### Create the output control (`OC`) Package # @@ -263,11 +253,7 @@ pa = modelmap.plot_array(h, vmin=vmin, vmax=vmax) quadmesh = modelmap.plot_bc("CHD") linecollection = modelmap.plot_grid(lw=0.5, color="0.5") -contours = modelmap.contour_array( - h, - levels=contour_intervals, - colors="black", -) +contours = modelmap.contour_array(h, levels=contour_intervals, colors="black") ax.clabel(contours, fmt="%2.1f") cb = plt.colorbar(pa, shrink=0.5, ax=ax) # second subplot @@ -277,11 +263,7 @@ linecollection = modelmap.plot_grid(lw=0.5, color="0.5") pa = modelmap.plot_array(h, vmin=vmin, vmax=vmax) quadmesh = modelmap.plot_bc("CHD") -contours = modelmap.contour_array( - h, - levels=contour_intervals, - colors="black", -) +contours = modelmap.contour_array(h, levels=contour_intervals, colors="black") ax.clabel(contours, fmt="%2.1f") cb = plt.colorbar(pa, shrink=0.5, ax=ax) @@ -292,19 +274,11 @@ fig, ax = plt.subplots(1, 1, figsize=(9, 3), constrained_layout=True) # first subplot ax.set_title("Row 25") -modelmap = flopy.plot.PlotCrossSection( - model=gwf, - ax=ax, - line={"row": int(N / 4)}, -) +modelmap = flopy.plot.PlotCrossSection(model=gwf, ax=ax, line={"row": int(N / 4)}) pa = modelmap.plot_array(h, vmin=vmin, vmax=vmax) quadmesh = modelmap.plot_bc("CHD") linecollection = modelmap.plot_grid(lw=0.5, color="0.5") -contours = modelmap.contour_array( - h, - levels=contour_intervals, - colors="black", -) +contours = modelmap.contour_array(h, levels=contour_intervals, colors="black") ax.clabel(contours, fmt="%2.1f") cb = plt.colorbar(pa, shrink=0.5, ax=ax) @@ -335,11 +309,7 @@ pa = modelmap.plot_array(residual) quadmesh = modelmap.plot_bc("CHD") linecollection = modelmap.plot_grid(lw=0.5, color="0.5") -contours = modelmap.contour_array( - h, - levels=contour_intervals, - colors="black", -) +contours = modelmap.contour_array(h, levels=contour_intervals, colors="black") ax.clabel(contours, fmt="%2.1f") plt.colorbar(pa, shrink=0.5) diff --git a/.docs/Notebooks/mfusg_conduit_examples.py b/.docs/Notebooks/mfusg_conduit_examples.py index b0741a7d4..d8e86a928 100644 --- a/.docs/Notebooks/mfusg_conduit_examples.py +++ b/.docs/Notebooks/mfusg_conduit_examples.py @@ -594,55 +594,19 @@ # + fig = plt.figure(figsize=(8, 11), dpi=150) ax1 = fig.add_subplot(211) -ax1.plot( - simtimes, - flow_case1[::2,]["q"], - label="Case A", -) -ax1.plot( - simtimes, - flow_case2[::2,]["q"], - label="Case B", -) -ax1.plot( - simtimes, - flow_case3[::2,]["q"], - dashes=[6, 2], - label="Case C", -) -ax1.plot( - simtimes, - flow_case4[::2,]["q"], - dashes=[6, 2], - label="Case D", -) +ax1.plot(simtimes, flow_case1[::2,]["q"], label="Case A") +ax1.plot(simtimes, flow_case2[::2,]["q"], label="Case B") +ax1.plot(simtimes, flow_case3[::2,]["q"], dashes=[6, 2], label="Case C") +ax1.plot(simtimes, flow_case4[::2,]["q"], dashes=[6, 2], label="Case D") ax1.set_xlabel("Time, in days") ax1.set_ylabel("Layer 1 flow to well") ax1.legend() ax2 = fig.add_subplot(212) -ax2.plot( - simtimes, - flow_case1[1::2,]["q"], - label="Case A", -) -ax2.plot( - simtimes, - flow_case2[1::2,]["q"], - label="Case B", -) -ax2.plot( - simtimes, - flow_case3[1::2,]["q"], - dashes=[6, 2], - label="Case C", -) -ax2.plot( - simtimes, - flow_case4[1::2,]["q"], - dashes=[6, 2], - label="Case D", -) +ax2.plot(simtimes, flow_case1[1::2,]["q"], label="Case A") +ax2.plot(simtimes, flow_case2[1::2,]["q"], label="Case B") +ax2.plot(simtimes, flow_case3[1::2,]["q"], dashes=[6, 2], label="Case C") +ax2.plot(simtimes, flow_case4[1::2,]["q"], dashes=[6, 2], label="Case D") ax2.set_xlabel("Time, in days") ax2.set_ylabel("Layer 2 flow to well") ax2.legend() diff --git a/.docs/Notebooks/mfusg_freyberg_example.py b/.docs/Notebooks/mfusg_freyberg_example.py index e4ad7797f..aa39d9bf9 100644 --- a/.docs/Notebooks/mfusg_freyberg_example.py +++ b/.docs/Notebooks/mfusg_freyberg_example.py @@ -144,21 +144,13 @@ ax = fig.add_subplot(1, len(lines), i + 1) ax.set_title(f"Freyberg head cross-section (line {i})") xsect = flopy.plot.PlotCrossSection( - modelgrid=mfgrid, - ax=ax, - line={"line": lines[i]}, - geographic_coords=True, + modelgrid=mfgrid, ax=ax, line={"line": lines[i]}, geographic_coords=True ) xsect.plot_array(head, head=head, alpha=0.4) xsect.plot_ibound(ibound=ibound, head=head) xsect.plot_inactive(ibound=ibound) contours = xsect.contour_array( - head, - masked_values=[999.0], - head=head, - levels=levels, - alpha=1.0, - colors="blue", + head, masked_values=[999.0], head=head, levels=levels, alpha=1.0, colors="blue" ) plt.clabel(contours, fmt="%.0f", colors="blue", fontsize=12) xsect.plot_grid(alpha=0.2) @@ -180,11 +172,7 @@ xsect = flopy.plot.PlotCrossSection( modelgrid=mfgrid, ax=ax, line={"line": line}, geographic_coords=True ) - cmap = xsect.plot_array( - head2, - masked_values=[-999.99], - alpha=0.4, - ) + cmap = xsect.plot_array(head2, masked_values=[-999.99], alpha=0.4) contours = xsect.contour_array(head2, levels=levels, alpha=1.0, colors="blue") xsect.plot_inactive(ibound=ibound, color_noflow=(0.8, 0.8, 0.8)) xsect.plot_grid(alpha=0.2) @@ -197,12 +185,7 @@ xsect = flopy.plot.PlotCrossSection( modelgrid=mfgrid, ax=ax, line={"line": line}, geographic_coords=True ) - cmap = xsect.plot_array( - head, - masked_values=[-999.99], - head=head, - alpha=0.4, - ) + cmap = xsect.plot_array(head, masked_values=[-999.99], head=head, alpha=0.4) contours = xsect.contour_array( head, head=head, levels=levels, alpha=1.0, colors="blue" ) @@ -217,12 +200,7 @@ xsect = flopy.plot.PlotCrossSection( modelgrid=mfgrid, ax=ax, line={"line": line}, geographic_coords=True ) - cmap = xsect.plot_array( - head2, - masked_values=[-999.99], - head=head2, - alpha=0.4, - ) + cmap = xsect.plot_array(head2, masked_values=[-999.99], head=head2, alpha=0.4) contours = xsect.contour_array( head2, head=head2, levels=levels, alpha=1.0, colors="blue" ) diff --git a/.docs/Notebooks/modelgrid_examples.py b/.docs/Notebooks/modelgrid_examples.py index acba38b8b..f8bffc09a 100644 --- a/.docs/Notebooks/modelgrid_examples.py +++ b/.docs/Notebooks/modelgrid_examples.py @@ -653,9 +653,7 @@ def load_iverts(fname): label="Grid cell centers", ms=4, ) -plt.legend( - loc=0, -) +plt.legend(loc=0) plt.title("modelgrid cell vertices and centers") # + diff --git a/.docs/Notebooks/modpath7_create_simulation_example.py b/.docs/Notebooks/modpath7_create_simulation_example.py index 9a779d0b8..7fd621bcc 100644 --- a/.docs/Notebooks/modpath7_create_simulation_example.py +++ b/.docs/Notebooks/modpath7_create_simulation_example.py @@ -327,12 +327,7 @@ def get_nodes(locs): mm = flopy.plot.PlotMapView(model=gwf, ax=ax) mm.plot_grid(lw=0.5) mm.plot_pathline( - pwb, - layer="all", - colors="blue", - lw=0.5, - linestyle=":", - label="captured by wells", + pwb, layer="all", colors="blue", lw=0.5, linestyle=":", label="captured by wells" ) mm.plot_endpoint(ewb, direction="ending") # , colorbar=True, shrink=0.5); @@ -342,12 +337,7 @@ def get_nodes(locs): mm = flopy.plot.PlotMapView(model=gwf, ax=ax) mm.plot_grid(lw=0.5) mm.plot_pathline( - prb, - layer="all", - colors="green", - lw=0.5, - linestyle=":", - label="captured by rivers", + prb, layer="all", colors="green", lw=0.5, linestyle=":", label="captured by rivers" ) plt.tight_layout() diff --git a/.docs/Notebooks/mt3d-usgs_example.py b/.docs/Notebooks/mt3d-usgs_example.py index 8ab2167fb..00da7ad06 100644 --- a/.docs/Notebooks/mt3d-usgs_example.py +++ b/.docs/Notebooks/mt3d-usgs_example.py @@ -676,37 +676,17 @@ def set_sizeyaxis(a, fmt, sz): ax.plot(ts5_Otis[:, 0], ts5_Otis[:, 1], "c-", linewidth=1.0) ax.plot( - (ts1_mt3d[:, 0]) / 3600, - ts1_mt3d[:, 1], - "kD", - markersize=2.0, - mfc="none", - mec="k", + (ts1_mt3d[:, 0]) / 3600, ts1_mt3d[:, 1], "kD", markersize=2.0, mfc="none", mec="k" ) ax.plot( - (ts2_mt3d[:, 0]) / 3600, - ts2_mt3d[:, 1], - "b*", - markersize=3.0, - mfc="none", - mec="b", + (ts2_mt3d[:, 0]) / 3600, ts2_mt3d[:, 1], "b*", markersize=3.0, mfc="none", mec="b" ) ax.plot((ts3_mt3d[:, 0]) / 3600, ts3_mt3d[:, 1], "r+", markersize=3.0) ax.plot( - (ts4_mt3d[:, 0]) / 3600, - ts4_mt3d[:, 1], - "g^", - markersize=2.0, - mfc="none", - mec="g", + (ts4_mt3d[:, 0]) / 3600, ts4_mt3d[:, 1], "g^", markersize=2.0, mfc="none", mec="g" ) ax.plot( - (ts5_mt3d[:, 0]) / 3600, - ts5_mt3d[:, 1], - "co", - markersize=2.0, - mfc="none", - mec="c", + (ts5_mt3d[:, 0]) / 3600, ts5_mt3d[:, 1], "co", markersize=2.0, mfc="none", mec="c" ) # customize plot diff --git a/.docs/Notebooks/mt3dms_sft_lkt_uzt_tutorial.py b/.docs/Notebooks/mt3dms_sft_lkt_uzt_tutorial.py index 88e29dd25..85448762a 100644 --- a/.docs/Notebooks/mt3dms_sft_lkt_uzt_tutorial.py +++ b/.docs/Notebooks/mt3dms_sft_lkt_uzt_tutorial.py @@ -139,13 +139,7 @@ # Bottom of layer 1 elevation also determined from use of GUI and stored locally bt1_pth = os.path.join( - "..", - "..", - "examples", - "data", - "mt3d_example_sft_lkt_uzt", - "dis_arrays", - "bot1.txt", + "..", "..", "examples", "data", "mt3d_example_sft_lkt_uzt", "dis_arrays", "bot1.txt" ) bot1Elv = np.loadtxt(bt1_pth) @@ -295,34 +289,16 @@ sp = [] for k in [0, 1, 2]: # These indices need to be adjusted for 0-based moronicism - for i in [ - 0, - 299, - ]: # These indices need to be adjusted for 0-based silliness - for j in np.arange( - 0, 300, 1 - ): # These indices need to be adjusted for 0-based foolishness - # Skipping cells not satisfying the conditions below + for i in [0, 299]: # These indices need to be adjusted for 0-based silliness + # These indices need to be adjusted for 0-based foolishness + # Skipping cells not satisfying the conditions below + for j in np.arange(0, 300, 1): if (i == 1 and (j < 27 or j > 31)) or (i == 299 and (j < 26 or j > 31)): if i % 2 == 0: - sp.append( - [ - k, - i, - j, - elev_stpt_row1 - (elev_slp * (j - 1)), - 11.3636, - ] - ) + sp.append([k, i, j, elev_stpt_row1 - (elev_slp * (j - 1)), 11.3636]) else: sp.append( - [ - k, - i, - j, - elev_stpt_row300 - (elev_slp * (j - 1)), - 11.3636, - ] + [k, i, j, elev_stpt_row300 - (elev_slp * (j - 1)), 11.3636] ) @@ -586,22 +562,10 @@ # + fname_drnElv = os.path.join( - "..", - "..", - "examples", - "data", - "mt3d_example_sft_lkt_uzt", - "drn_arrays", - "elv.txt", + "..", "..", "examples", "data", "mt3d_example_sft_lkt_uzt", "drn_arrays", "elv.txt" ) fname_drnCond = os.path.join( - "..", - "..", - "examples", - "data", - "mt3d_example_sft_lkt_uzt", - "drn_arrays", - "cond.txt", + "..", "..", "examples", "data", "mt3d_example_sft_lkt_uzt", "drn_arrays", "cond.txt" ) drnElv = np.loadtxt(fname_drnElv) diff --git a/.docs/Notebooks/nwt_option_blocks_tutorial.py b/.docs/Notebooks/nwt_option_blocks_tutorial.py index e3440cc1e..3e92a416b 100644 --- a/.docs/Notebooks/nwt_option_blocks_tutorial.py +++ b/.docs/Notebooks/nwt_option_blocks_tutorial.py @@ -189,10 +189,7 @@ # + wel3 = flopy.modflow.ModflowWel( - ml, - stress_period_data=wel.stress_period_data, - options=options, - unitnumber=99, + ml, stress_period_data=wel.stress_period_data, options=options, unitnumber=99 ) wel3.write_file(os.path.join(model_ws, wel_name)) diff --git a/.docs/Notebooks/plot_cross_section_example.py b/.docs/Notebooks/plot_cross_section_example.py index f80b20632..1799b2e81 100644 --- a/.docs/Notebooks/plot_cross_section_example.py +++ b/.docs/Notebooks/plot_cross_section_example.py @@ -549,17 +549,7 @@ def run_vertex_grid_example(ws): xmax = 12 * delr ymin = 8 * delc ymax = 13 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) rf1shp = os.path.join(gridgen_ws, "rf1") @@ -567,17 +557,7 @@ def run_vertex_grid_example(ws): xmax = 11 * delr ymin = 9 * delc ymax = 12 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) rf2shp = os.path.join(gridgen_ws, "rf2") @@ -585,17 +565,7 @@ def run_vertex_grid_example(ws): xmax = 10 * delr ymin = 10 * delc ymax = 11 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) g.build(verbose=False) @@ -676,10 +646,7 @@ def run_vertex_grid_example(ws): # welspd = flopy.mf6.ModflowGwfwel.stress_period_data.empty(gwf, maxbound=1, aux_vars=['iface']) welspd = [[(2, icpl), -150000, 0] for icpl in welcells["nodenumber"]] wel = flopy.mf6.ModflowGwfwel( - gwf, - print_input=True, - auxiliary=[("iface",)], - stress_period_data=welspd, + gwf, print_input=True, auxiliary=[("iface",)], stress_period_data=welspd ) # rch @@ -1122,10 +1089,7 @@ def build_mf6gwf(sim_folder): pname="CHD-1", ) flopy.mf6.ModflowGwfrch( - gwf, - stress_period_data=rchspd, - auxiliary=["concentration"], - pname="RCH-1", + gwf, stress_period_data=rchspd, auxiliary=["concentration"], pname="RCH-1" ) head_filerecord = f"{name}.hds" @@ -1217,10 +1181,7 @@ def build_mf6gwt(sim_folder): saverecord=saverecord, printrecord=[ ("CONCENTRATION", "LAST"), - ( - "BUDGET", - "ALL", - ), + ("BUDGET", "ALL"), ], ) obs_data = { diff --git a/.docs/Notebooks/plot_map_view_example.py b/.docs/Notebooks/plot_map_view_example.py index 950f75272..78e3cb961 100644 --- a/.docs/Notebooks/plot_map_view_example.py +++ b/.docs/Notebooks/plot_map_view_example.py @@ -529,9 +529,7 @@ # lets extract some shapes from our shapefiles shp = os.path.join(loadpth, "gis", "bedrock_outcrop_hole_rotate14") with shapefile.Reader(shp) as r: - polygon_w_hole = [ - r.shape(0), - ] + polygon_w_hole = [r.shape(0)] shp = os.path.join(loadpth, "gis", "cross_section_rotate14") with shapefile.Reader(shp) as r: @@ -735,17 +733,7 @@ def run_vertex_grid_example(ws): xmax = 12 * delr ymin = 8 * delc ymax = 13 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) rf1shp = os.path.join(gridgen_ws, "rf1") @@ -753,17 +741,7 @@ def run_vertex_grid_example(ws): xmax = 11 * delr ymin = 9 * delc ymax = 12 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) rf2shp = os.path.join(gridgen_ws, "rf2") @@ -771,17 +749,7 @@ def run_vertex_grid_example(ws): xmax = 10 * delr ymin = 10 * delc ymax = 11 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) g.build(verbose=False) diff --git a/.docs/Notebooks/raster_intersection_example.py b/.docs/Notebooks/raster_intersection_example.py index 2f6c09da8..f1ec37007 100644 --- a/.docs/Notebooks/raster_intersection_example.py +++ b/.docs/Notebooks/raster_intersection_example.py @@ -180,10 +180,7 @@ t0 = time.time() dem_data = rio.resample_to_grid( - ml.modelgrid, - band=rio.bands[0], - method="median", - extrapolate_edges=True, + ml.modelgrid, band=rio.bands[0], method="median", extrapolate_edges=True ) resample_time = time.time() - t0 @@ -254,11 +251,7 @@ pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) ax = pmv.plot_array( - dem_data, - masked_values=rio.nodatavals, - cmap="viridis", - vmin=vmin, - vmax=vmax, + dem_data, masked_values=rio.nodatavals, cmap="viridis", vmin=vmin, vmax=vmax ) plt.title(f"Resample time, nearest neighbor: {resample_time:.3f} sec") plt.colorbar(ax, shrink=0.7) @@ -276,22 +269,14 @@ pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) ax = pmv.plot_array( - dem_data, - masked_values=rio.nodatavals, - cmap="viridis", - vmin=vmin, - vmax=vmax, + dem_data, masked_values=rio.nodatavals, cmap="viridis", vmin=vmin, vmax=vmax ) plt.title(f"Resample time, bi-linear: {resample_time:.3f} sec") plt.colorbar(ax, shrink=0.7) # + t0 = time.time() -dem_data = rio.resample_to_grid( - mg_unstruct, - band=rio.bands[0], - method="median", -) +dem_data = rio.resample_to_grid(mg_unstruct, band=rio.bands[0], method="median") resample_time = time.time() - t0 @@ -302,11 +287,7 @@ pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) ax = pmv.plot_array( - dem_data, - masked_values=rio.nodatavals, - cmap="viridis", - vmin=vmin, - vmax=vmax, + dem_data, masked_values=rio.nodatavals, cmap="viridis", vmin=vmin, vmax=vmax ) plt.title(f"Resample time, median: {resample_time:.3f} sec") plt.colorbar(ax, shrink=0.7) @@ -429,11 +410,7 @@ pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) ax = pmv.plot_array( - dem_data, - masked_values=rio.nodatavals, - cmap="viridis", - vmin=vmin, - vmax=vmax, + dem_data, masked_values=rio.nodatavals, cmap="viridis", vmin=vmin, vmax=vmax ) plt.plot(shape.T[0], shape.T[1], "r-") plt.title(f"Resample time, nearest neighbor: {resample_time:.3f} sec") @@ -452,11 +429,7 @@ pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) ax = pmv.plot_array( - dem_data, - masked_values=rio.nodatavals, - cmap="viridis", - vmin=vmin, - vmax=vmax, + dem_data, masked_values=rio.nodatavals, cmap="viridis", vmin=vmin, vmax=vmax ) plt.plot(shape.T[0], shape.T[1], "r-") plt.title(f"Resample time, bi-linear: {resample_time:.3f} sec") @@ -531,15 +504,7 @@ ax = fig.add_subplot(1, 1, 1, aspect="equal") pmv = flopy.plot.PlotMapView(modelgrid=mg_unstruct, ax=ax) -ax = pmv.plot_array( - top, - masked_values=[ - 3500, - ], - cmap="viridis", - vmin=vmin, - vmax=vmax, -) +ax = pmv.plot_array(top, masked_values=[3500], cmap="viridis", vmin=vmin, vmax=vmax) ib = pmv.plot_ibound(ibound) pmv.plot_grid(linewidth=0.3) plt.plot(shape[0], shape[1], "r-") diff --git a/.docs/Notebooks/swi2package_example1.py b/.docs/Notebooks/swi2package_example1.py index 6e6745d1f..791aba248 100644 --- a/.docs/Notebooks/swi2package_example1.py +++ b/.docs/Notebooks/swi2package_example1.py @@ -162,12 +162,7 @@ plt.figure(figsize=(16, 6)) # define x-values of xcells and plot interface x = np.arange(0, ncol * delr, delr) + delr / 2.0 -label = [ - "SWI2", - "_", - "_", - "_", -] # labels with an underscore are not added to legend +label = ["SWI2", "_", "_", "_"] # labels with an underscore are not added to legend for i in range(4): zt = np.ma.masked_outside(zeta[i, 0, 0, :], -39.99999, -0.00001) plt.plot(x, zt, "r-", lw=1, zorder=10, label=label[i]) @@ -210,11 +205,7 @@ label = ["SWI2", "_", "_", "_"] for k in range(zeta.shape[0]): modelxsect.plot_surface( - zeta[k, :, :, :], - masked_values=[0, -40.0], - color="red", - lw=1, - label=label[k], + zeta[k, :, :, :], masked_values=[0, -40.0], color="red", lw=1, label=label[k] ) linecollection = modelxsect.plot_grid() ax.set_title("ModelCrossSection.plot_surface()") diff --git a/.docs/Notebooks/swi2package_example2.py b/.docs/Notebooks/swi2package_example2.py index 7a8ac4dee..c1b505d1a 100644 --- a/.docs/Notebooks/swi2package_example2.py +++ b/.docs/Notebooks/swi2package_example2.py @@ -382,15 +382,7 @@ ) # plot initial conditions ax = axes[0] -ax.text( - -0.075, - 1.05, - "A", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "A", transform=ax.transAxes, va="center", ha="center", size="8") # text(.975, .1, '(a)', transform = ax.transAxes, va = 'center', ha = 'center') ax.plot([110, 150], [0, -40], "k") ax.plot([150, 190], [0, -40], "k") @@ -403,15 +395,7 @@ ax.set_ylabel("Elevation, in meters") # plot stratified swi2 and seawat results ax = axes[1] -ax.text( - -0.075, - 1.05, - "B", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "B", transform=ax.transAxes, va="center", ha="center", size="8") # zp = zeta[0, 0, :] p = (zp < 0.0) & (zp > -40.0) @@ -443,15 +427,7 @@ ax.set_ylabel("Elevation, in meters") # plot vd model ax = axes[2] -ax.text( - -0.075, - 1.05, - "C", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "C", transform=ax.transAxes, va="center", ha="center", size="8") dr = zeta[0, 0, :] ax.plot(x, dr, "b", linewidth=1.5, drawstyle="steps-mid") dr = zeta2[0, 0, :] @@ -462,18 +438,10 @@ ax.plot(x, dr, "r", linewidth=0.75, drawstyle="steps-mid") # fake figures ax.plot( - [-100.0, -100], - [-100.0, -100], - "b", - linewidth=1.5, - label="SWI2 stratified option", + [-100.0, -100], [-100.0, -100], "b", linewidth=1.5, label="SWI2 stratified option" ) ax.plot( - [-100.0, -100], - [-100.0, -100], - "r", - linewidth=0.75, - label="SWI2 continuous option", + [-100.0, -100], [-100.0, -100], "r", linewidth=0.75, label="SWI2 continuous option" ) # legend leg = ax.legend(loc="lower left", numpoints=1) diff --git a/.docs/Notebooks/swi2package_example3.py b/.docs/Notebooks/swi2package_example3.py index 3063c6d96..49428d2e1 100644 --- a/.docs/Notebooks/swi2package_example3.py +++ b/.docs/Notebooks/swi2package_example3.py @@ -224,15 +224,7 @@ def LegBar(ax, x0, y0, t0, dx, dy, dt, cc): ) ax = fig.add_subplot(311) -ax.text( - -0.075, - 1.05, - "A", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "A", transform=ax.transAxes, va="center", ha="center", size="8") # confining unit ax.fill( [-600, 3400, 3400, -600], @@ -258,15 +250,7 @@ def LegBar(ax, x0, y0, t0, dx, dy, dt, cc): ax.set_xlim(-250.0, 2500.0) ax = fig.add_subplot(312) -ax.text( - -0.075, - 1.05, - "B", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "B", transform=ax.transAxes, va="center", ha="center", size="8") # confining unit ax.fill( [-600, 3400, 3400, -600], @@ -287,15 +271,7 @@ def LegBar(ax, x0, y0, t0, dx, dy, dt, cc): ax.set_xlim(-250.0, 2500.0) ax = fig.add_subplot(313) -ax.text( - -0.075, - 1.05, - "C", - transform=ax.transAxes, - va="center", - ha="center", - size="8", -) +ax.text(-0.075, 1.05, "C", transform=ax.transAxes, va="center", ha="center", size="8") # confining unit ax.fill( [-600, 3400, 3400, -600], diff --git a/.docs/Notebooks/swi2package_example4.py b/.docs/Notebooks/swi2package_example4.py index 3aa9c426d..b9c973a98 100644 --- a/.docs/Notebooks/swi2package_example4.py +++ b/.docs/Notebooks/swi2package_example4.py @@ -385,22 +385,10 @@ ax.set_xlabel("Horizontal distance, in meters") ax.set_ylabel("Elevation, in meters") ax.text( - 0.025, - 0.55, - "Layer 1", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.55, "Layer 1", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( - 0.025, - 0.45, - "Layer 2", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.45, "Layer 2", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( 0.975, @@ -443,22 +431,10 @@ ax.set_xlabel("Horizontal distance, in meters") ax.set_ylabel("Elevation, in meters") ax.text( - 0.025, - 0.55, - "Layer 1", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.55, "Layer 1", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( - 0.025, - 0.45, - "Layer 2", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.45, "Layer 2", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( 0.975, @@ -501,22 +477,10 @@ ax.set_xlabel("Horizontal distance, in meters") ax.set_ylabel("Elevation, in meters") ax.text( - 0.025, - 0.55, - "Layer 1", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.55, "Layer 1", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( - 0.025, - 0.45, - "Layer 2", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.45, "Layer 2", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( 0.975, @@ -541,14 +505,7 @@ tz2[i] = zobs["layer2_001"][i + 999] if zobs2["layer2_001"][i + 999] < 20.0 - 0.1: tz3[i] = zobs2["layer2_001"][i + 999] -ax.plot( - t, - tz2, - linestyle="solid", - color="r", - linewidth=0.75, - label="Freshwater well", -) +ax.plot(t, tz2, linestyle="solid", color="r", linewidth=0.75, label="Freshwater well") ax.plot( t, tz3, @@ -564,22 +521,10 @@ ax.set_xlabel("Time, in years") ax.set_ylabel("Elevation, in meters") ax.text( - 0.025, - 0.55, - "Layer 1", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.55, "Layer 1", transform=ax.transAxes, va="center", ha="left", size="7" ) ax.text( - 0.025, - 0.45, - "Layer 2", - transform=ax.transAxes, - va="center", - ha="left", - size="7", + 0.025, 0.45, "Layer 2", transform=ax.transAxes, va="center", ha="left", size="7" ) # - diff --git a/.docs/Notebooks/swi2package_example5.py b/.docs/Notebooks/swi2package_example5.py index 36e0ca4c5..2a54f70f4 100644 --- a/.docs/Notebooks/swi2package_example5.py +++ b/.docs/Notebooks/swi2package_example5.py @@ -492,24 +492,10 @@ # withdrawal and recovery titles ax = axes.flatten()[0] ax.text( - 0.0, - 1.03, - "Withdrawal", - transform=ax.transAxes, - va="bottom", - ha="left", - size="8", + 0.0, 1.03, "Withdrawal", transform=ax.transAxes, va="bottom", ha="left", size="8" ) ax = axes.flatten()[1] -ax.text( - 0.0, - 1.03, - "Recovery", - transform=ax.transAxes, - va="bottom", - ha="left", - size="8", -) +ax.text(0.0, 1.03, "Recovery", transform=ax.transAxes, va="bottom", ha="left", size="8") # dummy items for legend ax = axes.flatten()[2] ax.plot( @@ -604,11 +590,7 @@ zorder=30, ) cc = ax.contourf( - X, - Z, - conc[itime, :, :], - levels=[0.0, 1.75, 33.250], - colors=["w", "0.75", "w"], + X, Z, conc[itime, :, :], levels=[0.0, 1.75, 33.250], colors=["w", "0.75", "w"] ) # set graph limits ax.set_xlim(0, 500) @@ -637,15 +619,7 @@ ctxt = f"{iyr} years" else: ctxt = f"{iyr} year" - ax.text( - 0.95, - 0.925, - ctxt, - transform=ax.transAxes, - va="top", - ha="right", - size="8", - ) + ax.text(0.95, 0.925, ctxt, transform=ax.transAxes, va="top", ha="right", size="8") plt.show() # - diff --git a/.docs/Notebooks/uzf_example.py b/.docs/Notebooks/uzf_example.py index ba4f9ce36..a64362f99 100644 --- a/.docs/Notebooks/uzf_example.py +++ b/.docs/Notebooks/uzf_example.py @@ -310,8 +310,7 @@ if avail: df3 = pd.DataFrame( - data, - columns=["layer", "time", "head", "uzthick", "depth", "watercontent"], + data, columns=["layer", "time", "head", "uzthick", "depth", "watercontent"] ) df3.head(41) diff --git a/.docs/Notebooks/vtk_pathlines_example.py b/.docs/Notebooks/vtk_pathlines_example.py index e22e7485a..603afd494 100644 --- a/.docs/Notebooks/vtk_pathlines_example.py +++ b/.docs/Notebooks/vtk_pathlines_example.py @@ -261,11 +261,7 @@ def fill_zone_1(): start_labels.append(f"Particle {pid}") p.add_point_labels( - label_coords, - start_labels, - font_size=10, - point_size=15, - point_color="black", + label_coords, start_labels, font_size=10, point_size=15, point_color="black" ) # zoom in and show the plot diff --git a/.docs/Notebooks/zonebudget_example.py b/.docs/Notebooks/zonebudget_example.py index fc57d9bc3..ecb179255 100644 --- a/.docs/Notebooks/zonebudget_example.py +++ b/.docs/Notebooks/zonebudget_example.py @@ -268,12 +268,7 @@ def volumetric_budget_bar_plot(values_in, values_out, labels, **kwargs): vertical_alignment = "bottom" horizontal_alignment = "center" ax.text( - x, - y, - label, - ha=horizontal_alignment, - va=vertical_alignment, - rotation=90, + x, y, label, ha=horizontal_alignment, va=vertical_alignment, rotation=90 ) for i, rect in enumerate(rects_out): @@ -284,12 +279,7 @@ def volumetric_budget_bar_plot(values_in, values_out, labels, **kwargs): vertical_alignment = "top" horizontal_alignment = "center" ax.text( - x, - y, - label, - ha=horizontal_alignment, - va=vertical_alignment, - rotation=90, + x, y, label, ha=horizontal_alignment, va=vertical_alignment, rotation=90 ) # horizontal line indicating zero diff --git a/.docs/create_rstfiles.py b/.docs/create_rstfiles.py index 8eb6af103..fc37bdfcc 100644 --- a/.docs/create_rstfiles.py +++ b/.docs/create_rstfiles.py @@ -90,10 +90,7 @@ def create_examples_rst(): "flopy": {"title": "Other FloPy features", "files": []}, "mf6": {"title": "MODFLOW 6 examples", "files": []}, "mfusg": {"title": "MODFLOW USG examples", "files": []}, - "mf2005": { - "title": "MODFLOW-2005/MODFLOW-NWT examples", - "files": [], - }, + "mf2005": {"title": "MODFLOW-2005/MODFLOW-NWT examples", "files": []}, "modpath": {"title": "MODPATH examples", "files": []}, "mt3d": {"title": "MT3D and SEAWAT examples", "files": []}, "2016gw-paper": { diff --git a/.docs/groundwater_paper/scripts/uspb_capture.py b/.docs/groundwater_paper/scripts/uspb_capture.py index e078ea993..8830e68a5 100644 --- a/.docs/groundwater_paper/scripts/uspb_capture.py +++ b/.docs/groundwater_paper/scripts/uspb_capture.py @@ -159,9 +159,6 @@ def cf_model(model, k, i, j, base, Q=-100): if not os.path.exists(res_pth): os.makedirs(res_pth) for idx in range(10): - fn = os.path.join( - res_pth, - f"USPB_capture_fraction_{nstep:02d}_{idx + 1:02d}.dat", - ) + fn = os.path.join(res_pth, f"USPB_capture_fraction_{nstep:02d}_{idx + 1:02d}.dat") print(f"saving capture fraction data to...{os.path.basename(fn)}") np.savetxt(fn, cf_array[idx, :, :], delimiter=" ") diff --git a/.docs/groundwater_paper/scripts/uspb_capture_par.py b/.docs/groundwater_paper/scripts/uspb_capture_par.py index 08249409d..8f90ddccd 100644 --- a/.docs/groundwater_paper/scripts/uspb_capture_par.py +++ b/.docs/groundwater_paper/scripts/uspb_capture_par.py @@ -242,11 +242,7 @@ def doit(): ncol2 = ncol // nstep # open summary file - fs = open( - os.path.join("data", "uspb", f"uspb_capture_{nstep}.out"), - "w", - 0, - ) + fs = open(os.path.join("data", "uspb", f"uspb_capture_{nstep}.out"), "w", 0) # write some summary information fs.write(f"Problem size: {nrow} rows and {ncol} columns.\n") @@ -323,8 +319,7 @@ def doit(): os.makedirs(res_pth) for idx in range(10): fn = os.path.join( - res_pth, - f"USPB_capture_fraction_{nstep:02d}_{idx + 1:02d}.dat", + res_pth, f"USPB_capture_fraction_{nstep:02d}_{idx + 1:02d}.dat" ) sys.stdout.write(f"saving capture fraction data to...{os.path.basename(fn)}\n") np.savetxt(fn, cf_array[idx, :, :], delimiter=" ") diff --git a/autotest/regression/test_mf6.py b/autotest/regression/test_mf6.py index 8c1ac4a54..4c7a9fb7d 100644 --- a/autotest/regression/test_mf6.py +++ b/autotest/regression/test_mf6.py @@ -549,22 +549,7 @@ def test_np001(function_tmpdir, example_data_path): ic_array = ic_data.get_data() assert array_util.array_comp( ic_array, - [ - [ - [ - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - ] - ] - ], + [[[100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]]], ) # make folder to save simulation @@ -881,18 +866,7 @@ def test_np002(function_tmpdir, example_data_path): top = { "filename": "top data.txt", "factor": 1.0, - "data": [ - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - ], + "data": [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0], } botm = {"filename": "botm.txt", "factor": 1.0} dis_package = ModflowGwfdis( @@ -911,18 +885,7 @@ def test_np002(function_tmpdir, example_data_path): assert sim.simulation_data.max_columns_of_data == 22 sim.simulation_data.max_columns_of_data = dis_package.ncol.get_data() - ic_vals = [ - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - ] + ic_vals = [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0] ic_package = ModflowGwfic(model, strt=ic_vals, filename=f"{model_name}.ic") ic_package.strt.store_as_external_file("initial_heads.txt") npf_package = ModflowGwfnpf(model, save_flows=True, icelltype=1, k=100.0) @@ -1165,13 +1128,7 @@ def test021_twri(function_tmpdir, example_data_path): header_data=header, ) f.close() - top = { - "factor": 1.0, - "filename": fname, - "data": None, - "binary": True, - "iprn": 1, - } + top = {"factor": 1.0, "filename": fname, "data": None, "binary": True, "iprn": 1} dis_package = ModflowGwfdis( model, @@ -1186,12 +1143,7 @@ def test021_twri(function_tmpdir, example_data_path): ) strt = [ {"filename": "strt.txt", "factor": 1.0, "data": 0.0}, - { - "filename": "strt2.bin", - "factor": 1.0, - "data": 1.0, - "binary": "True", - }, + {"filename": "strt2.bin", "factor": 1.0, "data": 1.0, "binary": "True"}, 2.0, ] ic_package = ModflowGwfic(model, strt=strt, filename=f"{model_name}.ic") @@ -1631,15 +1583,7 @@ def test005_create_tests_advgw_tidal(function_tmpdir, example_data_path): ("rv2-upper", "RIV", "riv2_upper"), ("rv-2-7-4", "RIV", (0, 6, 3)), ("rv2-8-5", "RIV", (0, 6, 4)), - ( - "rv-2-9-6", - "RIV", - ( - 0, - 5, - 5, - ), - ), + ("rv-2-9-6", "RIV", (0, 5, 5)), ], "riv_flowsA.csv": [ ("riv1-3-1", "RIV", (0, 2, 0)), @@ -2765,11 +2709,7 @@ def test006_create_tests_2models_gnc(function_tmpdir, example_data_path): ) sim.remove_package(exg_package.package_type) - exg_data = { - "filename": "exg_data.txt", - "data": exgrecarray, - "binary": True, - } + exg_data = {"filename": "exg_data.txt", "data": exgrecarray, "binary": True} exg_package = ModflowGwfgwf( sim, print_input=True, @@ -3482,9 +3422,7 @@ def test_create_tests_transport(function_tmpdir, example_data_path): sim.run_simulation() # inspect cells - cell_list = [ - (0, 0, 0), - ] + cell_list = [(0, 0, 0)] out_file = function_tmpdir / "inspect_transport_gwf.csv" gwf.inspect_cells(cell_list, output_file_path=out_file) out_file = function_tmpdir / "inspect_transport_gwt.csv" @@ -4103,10 +4041,7 @@ def test006_gwf3(function_tmpdir, example_data_path): assert success, f"simulation {sim.name} rerun(3) did not run" # get expected results - budget_obj = CellBudgetFile( - expected_cbc_file_b, - precision="double", - ) + budget_obj = CellBudgetFile(expected_cbc_file_b, precision="double") budget_fjf_valid = np.array( budget_obj.get_data(text=" FLOW JA FACE", full3D=True) ) @@ -4501,12 +4436,7 @@ def test001e_uzf_3lay(function_tmpdir, example_data_path): sim.remove_package(ims) ims = ModflowIms(sim, print_option="SUMMARY", complexity="COMPLEX") - sim.register_ims_package( - ims, - [ - "GwF_1", - ], - ) + sim.register_ims_package(ims, ["GwF_1"]) sim.write_simulation() success, buff = sim.run_simulation() diff --git a/autotest/regression/test_modflow.py b/autotest/regression/test_modflow.py index 69e7aede2..9fee80b69 100644 --- a/autotest/regression/test_modflow.py +++ b/autotest/regression/test_modflow.py @@ -383,9 +383,8 @@ def test_mf2005_lake(function_tmpdir, namfile, mf2005_test_path): # rewrite files model_ws2 = join(ws, "external") - m.change_model_ws( - model_ws2, reset_external=True - ) # l1b2k_bath won't run without this + # l1b2k_bath won't run without this + m.change_model_ws(model_ws2, reset_external=True) m.write_input() success, buff = m.run_model() diff --git a/autotest/regression/test_swi2.py b/autotest/regression/test_swi2.py index b0043b302..496940282 100644 --- a/autotest/regression/test_swi2.py +++ b/autotest/regression/test_swi2.py @@ -35,9 +35,8 @@ def test_mf2005swi2(function_tmpdir, swi_path, namfile): # rewrite files model_ws2 = os.path.join(ws, "flopy") - m.change_model_ws( - model_ws2, reset_external=True - ) # l1b2k_bath won't run without this + # l1b2k_bath won't run without this + m.change_model_ws(model_ws2, reset_external=True) m.write_input() success, buff = m.run_model() diff --git a/autotest/test_binaryfile.py b/autotest/test_binaryfile.py index b61bd94f7..ce993439c 100644 --- a/autotest/test_binaryfile.py +++ b/autotest/test_binaryfile.py @@ -761,9 +761,7 @@ def test_read_mf6_2sp(mf6_gwf_2sp_st_tr): @pytest.mark.parametrize("compact", [True, False]) def test_read_mf2005_freyberg(example_data_path, function_tmpdir, compact): - m = flopy.modflow.Modflow.load( - example_data_path / "freyberg" / "freyberg.nam", - ) + m = flopy.modflow.Modflow.load(example_data_path / "freyberg" / "freyberg.nam") m.change_model_ws(function_tmpdir) oc = m.get_package("OC") oc.compact = compact diff --git a/autotest/test_cellbudgetfile.py b/autotest/test_cellbudgetfile.py index 6a2bc4257..dafff15bd 100644 --- a/autotest/test_cellbudgetfile.py +++ b/autotest/test_cellbudgetfile.py @@ -350,13 +350,7 @@ def test_budgetfile_detect_precision_single(path): @pytest.mark.parametrize( "path", - [ - _example_data_path - / "mf6" - / "test006_gwf3" - / "expected_output" - / "flow_adj.cbc", - ], + [_example_data_path / "mf6" / "test006_gwf3" / "expected_output" / "flow_adj.cbc"], ) def test_budgetfile_detect_precision_double(path): file = CellBudgetFile(path, precision="auto") diff --git a/autotest/test_copy.py b/autotest/test_copy.py index db8afb4b2..af4c4e1e2 100644 --- a/autotest/test_copy.py +++ b/autotest/test_copy.py @@ -79,14 +79,7 @@ def package_is_copy(pk1, pk2): """ for k, v in pk1.__dict__.items(): v2 = pk2.__dict__[k] - if v2 is v and type(v) not in [ - bool, - str, - type(None), - float, - int, - tuple, - ]: + if v2 is v and type(v) not in [bool, str, type(None), float, int, tuple]: # Deep copy doesn't work for ModflowUtltas if not inspect.isclass(v): return False @@ -181,14 +174,7 @@ def list_is_copy(mflist1, mflist2): if k not in data2: return False v2 = data2[k] - if v2 is v and type(v) not in [ - bool, - str, - type(None), - float, - int, - tuple, - ]: + if v2 is v and type(v) not in [bool, str, type(None), float, int, tuple]: return False if v is None and v2 is None: continue diff --git a/autotest/test_export.py b/autotest/test_export.py index 4f40a5824..336a99732 100644 --- a/autotest/test_export.py +++ b/autotest/test_export.py @@ -7,11 +7,7 @@ import numpy as np import pytest from flaky import flaky -from modflow_devtools.markers import ( - excludes_platform, - requires_exe, - requires_pkg, -) +from modflow_devtools.markers import excludes_platform, requires_exe, requires_pkg from modflow_devtools.misc import has_pkg import flopy @@ -97,25 +93,8 @@ def disu_sim(name, tmpdir, missing_arrays=False): xmax = 12 * delr ymin = 8 * delc ymax = 13 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] - g.add_refinement_features( - rfpoly, - "polygon", - 2, - [ - 0, - ], - ) + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] + g.add_refinement_features(rfpoly, "polygon", 2, [0]) g.build(verbose=False) gridprops = g.get_gridprops_disu6() @@ -187,11 +166,7 @@ def test_output_helper_shapefile_export(pathlike, function_tmpdir, example_data_ else: outpath = os.path.join(function_tmpdir, "test.shp") flopy.export.utils.output_helper( - outpath, - ml, - {"HDS": head, "cbc": cbc}, - mflay=1, - kper=10, + outpath, ml, {"HDS": head, "cbc": cbc}, mflay=1, kper=10 ) @@ -632,10 +607,7 @@ def test_array3d_export_structured(function_tmpdir): ncol = int((xur - xll) / spacing) nrow = int((yur - yll) / spacing) sim = flopy.mf6.MFSimulation("sim", sim_ws=function_tmpdir) - gwf = flopy.mf6.ModflowGwf( - sim, - modelname="array3d_export_unstructured", - ) + gwf = flopy.mf6.ModflowGwf(sim, modelname="array3d_export_unstructured") flopy.mf6.ModflowGwfdis( gwf, nlay=3, @@ -1878,12 +1850,7 @@ def test_vtk_export_disu1_grid(function_tmpdir, example_data_path): ) outfile = function_tmpdir / "disu_grid.vtu" - vtkobj = Vtk( - modelgrid=modelgrid, - vertical_exageration=2, - binary=True, - smooth=False, - ) + vtkobj = Vtk(modelgrid=modelgrid, vertical_exageration=2, binary=True, smooth=False) vtkobj.add_array(modelgrid.top, "top") vtkobj.add_array(modelgrid.botm, "botm") vtkobj.write(outfile) @@ -1959,12 +1926,7 @@ def test_vtk_export_disu2_grid(function_tmpdir, example_data_path): ) outfile = function_tmpdir / "disu_grid.vtu" - vtkobj = Vtk( - modelgrid=modelgrid, - vertical_exageration=2, - binary=True, - smooth=False, - ) + vtkobj = Vtk(modelgrid=modelgrid, vertical_exageration=2, binary=True, smooth=False) vtkobj.add_array(modelgrid.top, "top") vtkobj.add_array(modelgrid.botm, "botm") vtkobj.write(outfile) diff --git a/autotest/test_generate_classes.py b/autotest/test_generate_classes.py index bd6acde13..c1de3bc70 100644 --- a/autotest/test_generate_classes.py +++ b/autotest/test_generate_classes.py @@ -150,10 +150,7 @@ def get_mtime(f): modified_files = [ mod_files[i] for i, (before, after) in enumerate( - zip( - mod_file_times, - [get_mtime(f) for f in mod_files], - ) + zip(mod_file_times, [get_mtime(f) for f in mod_files]) ) if after > 0 and after > before ] diff --git a/autotest/test_geospatial_util.py b/autotest/test_geospatial_util.py index aa69493ef..decbcf370 100644 --- a/autotest/test_geospatial_util.py +++ b/autotest/test_geospatial_util.py @@ -147,10 +147,7 @@ def multilinestring(): def test_import_geospatial_utils(): - from flopy.utils.geospatial_utils import ( - GeoSpatialCollection, - GeoSpatialUtil, - ) + from flopy.utils.geospatial_utils import GeoSpatialCollection, GeoSpatialUtil @requires_pkg("pyshp", "shapely", name_map={"pyshp": "shapefile"}) diff --git a/autotest/test_get_modflow.py b/autotest/test_get_modflow.py index 830d2da8b..2ec79d5e4 100644 --- a/autotest/test_get_modflow.py +++ b/autotest/test_get_modflow.py @@ -28,9 +28,7 @@ "python": Path(sys.prefix) / ("Scripts" if system() == "Windows" else "bin"), "home": Path.home() / ".local" / "bin", } -owner_options = [ - "MODFLOW-USGS", -] +owner_options = ["MODFLOW-USGS"] repo_options = { "executables": [ "crt", @@ -250,13 +248,7 @@ def test_script_valid_options(function_tmpdir, downloads_dir): def test_script(function_tmpdir, owner, repo, downloads_dir): bindir = str(function_tmpdir) stdout, stderr, returncode = run_get_modflow_script( - bindir, - "--owner", - owner, - "--repo", - repo, - "--downloads-dir", - downloads_dir, + bindir, "--owner", owner, "--repo", repo, "--downloads-dir", downloads_dir ) if rate_limit_msg in stderr: pytest.skip(f"GitHub {rate_limit_msg}") diff --git a/autotest/test_grid.py b/autotest/test_grid.py index d38df29b7..c57ca2125 100644 --- a/autotest/test_grid.py +++ b/autotest/test_grid.py @@ -379,12 +379,8 @@ def test_unstructured_xyz_intersect(example_data_path): ncpl = np.array(3 * [len(iverts)]) nnodes = np.sum(ncpl) - top = np.ones( - (nnodes), - ) - botm = np.ones( - (nnodes), - ) + top = np.ones((nnodes)) + botm = np.ones((nnodes)) # set top and botm elevations i0 = 0 @@ -443,8 +439,8 @@ def test_structured_from_gridspec(example_data_path, spc_file): 0, # xmin 8000 * np.sin(theta) + 8000 * np.cos(theta), # xmax 8000 * np.sin(theta) * np.tan(theta / 2), # ymin - 8000 + 8000 * np.sin(theta), - ) # ymax + 8000 + 8000 * np.sin(theta), # ymax + ) errmsg = f"extents {extents} of {fn} does not equal {rotated_extents}" assert all( np.isclose(x, x0) for x, x0 in zip(modelgrid.extent, rotated_extents) @@ -550,14 +546,7 @@ def unstructured_from_gridspec_driver(example_data_path, gsf_file): # check nodes expected_nodes = [ - ( - int(s[0]), - float(s[1]), - float(s[2]), - float(s[3]), - int(s[4]), - int(s[5]), - ) + (int(s[0]), float(s[1]), float(s[2]), float(s[3]), int(s[4]), int(s[5])) for s in split[(3 + nverts) : -1] ] for i, en in enumerate(expected_nodes): @@ -1156,11 +1145,7 @@ def test_voronoi_grid(request, function_tmpdir, grid_info): ax = fig.add_subplot() ax.set_aspect("equal") grid.plot(ax=ax) - ax.plot( - grid.xcellcenters[invalid_cells], - grid.ycellcenters[invalid_cells], - "ro", - ) + ax.plot(grid.xcellcenters[invalid_cells], grid.ycellcenters[invalid_cells], "ro") plt.savefig(function_tmpdir / f"{name}.png") assert ncpl == gridprops["ncpl"] or almost_right @@ -1407,12 +1392,7 @@ def test_unstructured_iverts_cleanup(): iac, ja = [], [] for cell, neigh in neighbors.items(): iac.append(len(neigh) + 1) - ja.extend( - [ - cell, - ] - + neigh - ) + ja.extend([cell] + neigh) # build iverts and verts without using shared vertices verts, iverts = [], [] diff --git a/autotest/test_grid_cases.py b/autotest/test_grid_cases.py index 4d7b75cbe..7e6298153 100644 --- a/autotest/test_grid_cases.py +++ b/autotest/test_grid_cases.py @@ -38,18 +38,8 @@ def structured_cbd_small(): laycbd = np.array([1, 2, 0], dtype=int) ncb = np.count_nonzero(laycbd) dx = dy = 150 - delc = np.array( - [ - dy, - ] - * nrow - ) - delr = np.array( - [ - dx, - ] - * ncol - ) + delc = np.array([dy] * nrow) + delr = np.array([dx] * ncol) top = np.ones((15, 15)) botm = np.ones((nlay + ncb, nrow, ncol)) elevations = np.array([-10, -20, -40, -50, -70])[:, np.newaxis] @@ -139,20 +129,8 @@ def unstructured_small(): [4, 5, 8, 7], [6, 7, 10, 9], ] - xcenters = [ - 0.5, - 1.5, - 0.5, - 1.5, - 0.5, - ] - ycenters = [ - 2.5, - 2.5, - 1.5, - 1.5, - 0.5, - ] + xcenters = [0.5, 1.5, 0.5, 1.5, 0.5] + ycenters = [2.5, 2.5, 1.5, 1.5, 0.5] idomain = np.ones((nlay, 5), dtype=int) top = np.ones((nlay, 5), dtype=float) top[0, :] = 10.0 diff --git a/autotest/test_gridgen.py b/autotest/test_gridgen.py index 549322c03..eb3fc4bdd 100644 --- a/autotest/test_gridgen.py +++ b/autotest/test_gridgen.py @@ -74,16 +74,10 @@ def test_add_active_domain(function_tmpdir, grid_type): "ad0", ]: print( - "Testing add_active_domain() for", - grid_type, - "grid with features", - feature, + "Testing add_active_domain() for", grid_type, "grid with features", feature ) gridgen = Gridgen(bgrid, model_ws=function_tmpdir) - gridgen.add_active_domain( - feature, - range(bgrid.nlay), - ) + gridgen.add_active_domain(feature, range(bgrid.nlay)) gridgen.build() grid = ( VertexGrid(**gridgen.get_gridprops_vertexgrid()) @@ -122,12 +116,7 @@ def test_add_refinement_feature(function_tmpdir, grid_type): features, ) gridgen = Gridgen(bgrid, model_ws=function_tmpdir) - gridgen.add_refinement_features( - features, - "polygon", - 1, - range(bgrid.nlay), - ) + gridgen.add_refinement_features(features, "polygon", 1, range(bgrid.nlay)) gridgen.build() grid = ( VertexGrid(**gridgen.get_gridprops_vertexgrid()) @@ -380,11 +369,7 @@ def test_mf6disu(sim_disu_diff_layers): pmv.plot_array(head.flatten(), cmap="jet", vmin=vmin, vmax=vmax) pmv.plot_grid(colors="k", alpha=0.1) pmv.contour_array( - head, - levels=[0.2, 0.4, 0.6, 0.8], - linewidths=3.0, - vmin=vmin, - vmax=vmax, + head, levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0, vmin=vmin, vmax=vmax ) ax.set_title(f"Layer {ilay + 1}") pmv.plot_vector(spdis["qx"], spdis["qy"], color="white") @@ -659,17 +644,7 @@ def test_gridgen(function_tmpdir): xmax = 12 * delr ymin = 8 * delc ymax = 13 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) g6.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) gu.add_refinement_features(rfpoly, "polygon", 1, range(nlay)) @@ -679,17 +654,7 @@ def test_gridgen(function_tmpdir): xmax = 11 * delr ymin = 9 * delc ymax = 12 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) g6.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) gu.add_refinement_features(rfpoly, "polygon", 2, range(nlay)) @@ -699,17 +664,7 @@ def test_gridgen(function_tmpdir): xmax = 10 * delr ymin = 10 * delc ymax = 11 * delc - rfpoly = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + rfpoly = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] g.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) g6.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) gu.add_refinement_features(rfpoly, "polygon", 3, range(nlay)) @@ -719,17 +674,7 @@ def test_gridgen(function_tmpdir): xmax = 18 * delr ymin = 0 * delc ymax = 18 * delc - adpoly2 = [ - [ - [ - (xmin, ymin), - (xmax, ymin), - (xmax, ymax), - (xmin, ymax), - (xmin, ymin), - ] - ] - ] + adpoly2 = [[[(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax), (xmin, ymin)]]] gu.add_active_domain(adpoly2, layers=[1]) adpoly1_3 = [[[(0.0, 0.0), (Lx, 0.0), (Lx, Ly), (0.0, Ly), (0.0, 0.0)]]] gu.add_active_domain(adpoly1_3, layers=[0, 2]) diff --git a/autotest/test_gridintersect.py b/autotest/test_gridintersect.py index 1bc26acc8..15ec8b494 100644 --- a/autotest/test_gridintersect.py +++ b/autotest/test_gridintersect.py @@ -427,10 +427,7 @@ def test_rect_grid_multilinestring_in_one_cell(): ix = GridIntersect(gr, method="structured") result = ix.intersect( MultiLineString( - [ - LineString([(1.0, 1), (9.0, 1.0)]), - LineString([(1.0, 9.0), (9.0, 9.0)]), - ] + [LineString([(1.0, 1), (9.0, 1.0)]), LineString([(1.0, 9.0), (9.0, 9.0)])] ) ) assert len(result) == 1 @@ -555,10 +552,7 @@ def test_rect_grid_multilinestring_in_one_cell_shapely(rtree): ix = GridIntersect(gr, method="vertex", rtree=rtree) result = ix.intersect( MultiLineString( - [ - LineString([(1.0, 1), (9.0, 1.0)]), - LineString([(1.0, 9.0), (9.0, 9.0)]), - ] + [LineString([(1.0, 1), (9.0, 1.0)]), LineString([(1.0, 9.0), (9.0, 9.0)])] ) ) assert len(result) == 1 @@ -708,10 +702,7 @@ def test_tri_grid_multilinestring_in_one_cell(rtree): ix = GridIntersect(gr, rtree=rtree) result = ix.intersect( MultiLineString( - [ - LineString([(1.0, 1), (9.0, 1.0)]), - LineString([(2.0, 2.0), (9.0, 2.0)]), - ] + [LineString([(1.0, 1), (9.0, 1.0)]), LineString([(2.0, 2.0), (9.0, 2.0)])] ) ) assert len(result) == 1 @@ -831,14 +822,7 @@ def test_rect_grid_polygon_running_along_boundary(): ix = GridIntersect(gr, method="structured") result = ix.intersect( Polygon( - [ - (5.0, 5.0), - (5.0, 10.0), - (9.0, 10.0), - (9.0, 15.0), - (1.0, 15.0), - (1.0, 5.0), - ] + [(5.0, 5.0), (5.0, 10.0), (9.0, 10.0), (9.0, 15.0), (1.0, 15.0), (1.0, 5.0)] ) ) @@ -1060,14 +1044,7 @@ def test_rect_grid_polygon_running_along_boundary_shapely(): ix = GridIntersect(gr, method="vertex") result = ix.intersect( Polygon( - [ - (5.0, 5.0), - (5.0, 10.0), - (9.0, 10.0), - (9.0, 15.0), - (1.0, 15.0), - (1.0, 5.0), - ] + [(5.0, 5.0), (5.0, 10.0), (9.0, 10.0), (9.0, 15.0), (1.0, 15.0), (1.0, 5.0)] ) ) @@ -1128,14 +1105,7 @@ def test_rect_grid_polygon_in_edge_in_cell(rtree): gr = get_rect_grid() ix = GridIntersect(gr, method="vertex", rtree=rtree) p = Polygon( - [ - (0.0, 5.0), - (3.0, 0.0), - (7.0, 0.0), - (10.0, 5.0), - (10.0, -1.0), - (0.0, -1.0), - ] + [(0.0, 5.0), (3.0, 0.0), (7.0, 0.0), (10.0, 5.0), (10.0, -1.0), (0.0, -1.0)] ) result = ix.intersect(p) assert len(result) == 1 diff --git a/autotest/test_headufile.py b/autotest/test_headufile.py index d2017d5b7..e8dd08942 100644 --- a/autotest/test_headufile.py +++ b/autotest/test_headufile.py @@ -5,13 +5,7 @@ from flopy.discretization import UnstructuredGrid from flopy.mfusg import MfUsg, MfUsgDisU, MfUsgLpf, MfUsgSms -from flopy.modflow import ( - Modflow, - ModflowBas, - ModflowChd, - ModflowDis, - ModflowOc, -) +from flopy.modflow import Modflow, ModflowBas, ModflowChd, ModflowDis, ModflowOc from flopy.utils import HeadUFile from flopy.utils.gridgen import Gridgen from flopy.utils.gridutil import get_lni diff --git a/autotest/test_lake_connections.py b/autotest/test_lake_connections.py index fc63833f5..f74de60af 100644 --- a/autotest/test_lake_connections.py +++ b/autotest/test_lake_connections.py @@ -158,24 +158,12 @@ def test_base_run(function_tmpdir, example_data_path): # export bottom, water levels, and k11 as ascii raster files # for interpolation in test_lake() bot = gwf.dis.botm.array.squeeze() - export_ascii_grid( - gwf.modelgrid, - function_tmpdir / "bot.asc", - bot, - ) + export_ascii_grid(gwf.modelgrid, function_tmpdir / "bot.asc", bot) top = gwf.output.head().get_data().squeeze() + 2.0 top = np.where(gwf.dis.idomain.array.squeeze() < 1.0, 0.0, top) - export_ascii_grid( - gwf.modelgrid, - function_tmpdir / "top.asc", - top, - ) + export_ascii_grid(gwf.modelgrid, function_tmpdir / "top.asc", top) k11 = gwf.npf.k.array.squeeze() - export_ascii_grid( - gwf.modelgrid, - function_tmpdir / "k11.asc", - k11, - ) + export_ascii_grid(gwf.modelgrid, function_tmpdir / "k11.asc", k11) @requires_exe("mf6") @@ -322,13 +310,7 @@ def test_embedded_lak_ex01(function_tmpdir, example_data_path): ) delc = delr top = 500.0 - botm = ( - 107.0, - 97.0, - 87.0, - 77.0, - 67.0, - ) + botm = (107.0, 97.0, 87.0, 77.0, 67.0) lake_map = np.ones(shape3d, dtype=np.int32) * -1 lake_map[0, 6:11, 6:11] = 0 lake_map[1, 7:10, 7:10] = 0 @@ -337,13 +319,7 @@ def test_embedded_lak_ex01(function_tmpdir, example_data_path): strt = 115.0 k11 = 30 - k33 = ( - 1179.0, - 30.0, - 30.0, - 30.0, - 30.0, - ) + k33 = (1179.0, 30.0, 30.0, 30.0, 30.0) mpath = example_data_path / "mf2005_test" ml = Modflow.load( @@ -561,19 +537,9 @@ def test_embedded_lak_prudic(example_data_path): # compare connectiondata for idx, (cd, cdbase) in enumerate(zip(connectiondata, cdata)): - for jdx in ( - 0, - 1, - 2, - 3, - 7, - 8, - ): + for jdx in (0, 1, 2, 3, 7, 8): match = True - if jdx not in ( - 7, - 8, - ): + if jdx not in (7, 8): if cd[jdx] != cdbase[jdx]: match = False else: diff --git a/autotest/test_lgrutil.py b/autotest/test_lgrutil.py index 67d7a5325..e064fc4d8 100644 --- a/autotest/test_lgrutil.py +++ b/autotest/test_lgrutil.py @@ -74,16 +74,7 @@ def test_lgrutil(): errmsg = f"{ans1} /= {exchange_data[0]}" assert exchange_data[0] == ans1, errmsg - ans2 = [ - (2, 3, 3), - (1, 8, 8), - 0, - 50.0, - 50, - 1111.1111111111113, - 180.0, - 100.0, - ] + ans2 = [(2, 3, 3), (1, 8, 8), 0, 50.0, 50, 1111.1111111111113, 180.0, 100.0] errmsg = f"{ans2} /= {exchange_data[-1]}" assert exchange_data[-1] == ans2, errmsg @@ -91,10 +82,7 @@ def test_lgrutil(): assert len(exchange_data) == 72 + 81, errmsg # list of parent cells connected to a child cell - assert lgr.get_parent_connections(0, 0, 0) == [ - ((0, 1, 0), -1), - ((0, 0, 1), 2), - ] + assert lgr.get_parent_connections(0, 0, 0) == [((0, 1, 0), -1), ((0, 0, 1), 2)] assert lgr.get_parent_connections(1, 8, 8) == [ ((1, 3, 4), 1), ((1, 4, 3), -2), diff --git a/autotest/test_listbudget.py b/autotest/test_listbudget.py index ffaa73561..aa6a586f6 100644 --- a/autotest/test_listbudget.py +++ b/autotest/test_listbudget.py @@ -7,12 +7,7 @@ from modflow_devtools.markers import requires_pkg from modflow_devtools.misc import has_pkg -from flopy.utils import ( - Mf6ListBudget, - MfListBudget, - MfusgListBudget, - MtListBudget, -) +from flopy.utils import Mf6ListBudget, MfListBudget, MfusgListBudget, MtListBudget def test_mflistfile(example_data_path): @@ -80,14 +75,7 @@ def test_mf6listfile(example_data_path): assert os.path.exists(list_file) mflist = Mf6ListBudget(list_file) names = mflist.get_record_names() - for item in [ - "RCH_IN", - "RCH2_IN", - "RCH3_IN", - "RCH_OUT", - "RCH2_OUT", - "RCH3_OUT", - ]: + for item in ["RCH_IN", "RCH2_IN", "RCH3_IN", "RCH_OUT", "RCH2_OUT", "RCH3_OUT"]: assert item in names, f"{item} not found in names" assert len(names) == 26 inc = mflist.get_incremental() diff --git a/autotest/test_mf6.py b/autotest/test_mf6.py index 5afd033e6..9a1a43b6d 100644 --- a/autotest/test_mf6.py +++ b/autotest/test_mf6.py @@ -72,13 +72,7 @@ mfims, mftdis, ) -from flopy.utils import ( - CellBudgetFile, - HeadFile, - Mf6ListBudget, - Mf6Obs, - ZoneBudget6, -) +from flopy.utils import CellBudgetFile, HeadFile, Mf6ListBudget, Mf6Obs, ZoneBudget6 from flopy.utils.observationfile import CsvFile from flopy.utils.triangle import Triangle from flopy.utils.voronoi import VoronoiGrid @@ -314,15 +308,13 @@ def test_load_sim_when_namefile_uses_rel_paths(function_tmpdir, example_data_pat if sep == "win": l = to_win_sep( l.replace( - pattern, - "../" + workspace.name + "/" + model_name + ".", + pattern, "../" + workspace.name + "/" + model_name + "." ) ) else: l = to_posix_sep( l.replace( - pattern, - "../" + workspace.name + "/" + model_name + ".", + pattern, "../" + workspace.name + "/" + model_name + "." ) ) f.write(l) @@ -361,15 +353,13 @@ def test_write_simulation_always_writes_posix_path_separators( if sep == "win": l = to_win_sep( l.replace( - pattern, - "../" + workspace.name + "/" + model_name + ".", + pattern, "../" + workspace.name + "/" + model_name + "." ) ) else: l = to_posix_sep( l.replace( - pattern, - "../" + workspace.name + "/" + model_name + ".", + pattern, "../" + workspace.name + "/" + model_name + "." ) ) f.write(l) @@ -1130,18 +1120,7 @@ def test_create_and_run_model(function_tmpdir, use_paths): ) ic_package = mfgwfic.ModflowGwfic( model, - strt=[ - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - ], + strt=[100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0], filename=f"{model_name}.ic", ) npf_package = mfgwfnpf.ModflowGwfnpf(model, save_flows=True, icelltype=1, k=100.0) diff --git a/autotest/test_mnw.py b/autotest/test_mnw.py index 244c2c1f8..bb7c3adb6 100644 --- a/autotest/test_mnw.py +++ b/autotest/test_mnw.py @@ -103,57 +103,9 @@ def test_make_package(function_tmpdir, dataframe): # make the package from the tables (ztop, zbotm format) node_data = np.array( [ - ( - 0, - 1, - 1, - 9.5, - 7.1, - "well1", - "skin", - -1, - 0, - 0, - 0, - 1.0, - 2.0, - 5.0, - 6.2, - ), - ( - 1, - 1, - 1, - 7.1, - 5.1, - "well1", - "skin", - -1, - 0, - 0, - 0, - 0.5, - 2.0, - 5.0, - 6.2, - ), - ( - 2, - 3, - 3, - 9.1, - 3.7, - "well2", - "skin", - -1, - 0, - 0, - 0, - 1.0, - 2.0, - 5.0, - 4.1, - ), + (0, 1, 1, 9.5, 7.1, "well1", "skin", -1, 0, 0, 0, 1.0, 2.0, 5.0, 6.2), + (1, 1, 1, 7.1, 5.1, "well1", "skin", -1, 0, 0, 0, 0.5, 2.0, 5.0, 6.2), + (2, 3, 3, 9.1, 3.7, "well2", "skin", -1, 0, 0, 0, 1.0, 2.0, 5.0, 4.1), ], dtype=[ ("index", " 1): if model.verbose: diff --git a/flopy/mfusg/mfusgcln.py b/flopy/mfusg/mfusgcln.py index cd4cacd07..a193039b3 100644 --- a/flopy/mfusg/mfusgcln.py +++ b/flopy/mfusg/mfusgcln.py @@ -355,9 +355,8 @@ def _define_cln_networks(self, model): # Node number provided for each segment to simulate CLN networks elif self.iclnnds > 0: self.nclnnds = self.iclnnds - self.nodeno = ( - np.asarray(set(self.clncon), dtype=object) + 1 - ) # can be jagged + # can be jagged + self.nodeno = np.asarray(set(self.clncon), dtype=object) + 1 else: raise Exception("mfcln: Node number = 0") @@ -467,18 +466,12 @@ def write_file(self, f=None, check=False): if self.nconduityp > 0: np.savetxt( - f_cln, - self.cln_circ, - fmt=fmt_string(self.cln_circ), - delimiter="", + f_cln, self.cln_circ, fmt=fmt_string(self.cln_circ), delimiter="" ) if self.nrectyp > 0: np.savetxt( - f_cln, - self.cln_rect, - fmt=fmt_string(self.cln_rect), - delimiter="", + f_cln, self.cln_rect, fmt=fmt_string(self.cln_rect), delimiter="" ) f_cln.write(self.ibound.get_file_entry()) @@ -581,14 +574,9 @@ def load(cls, f, model, pak_type="cln", ext_unit_dict=None, **kwargs): ) = cls._load_items_0_1(f, model) # Items 3, or 4/5/6 - ( - nndcln, - clncon, - nja_cln, - iac_cln, - ja_cln, - nclnnds, - ) = cls._load_items_3to6(f, model, ncln, iclnnds, ext_unit_dict) + (nndcln, clncon, nja_cln, iac_cln, ja_cln, nclnnds) = cls._load_items_3to6( + f, model, ncln, iclnnds, ext_unit_dict + ) if model.verbose: print(" Reading node_prop...") @@ -630,10 +618,9 @@ def load(cls, f, model, pak_type="cln", ext_unit_dict=None, **kwargs): funcs = [abs] + [int] * 3 + [abs] * 2 for idx, (item, func) in enumerate(zip(file_unit_items, funcs)): if item > 0: - ( - unitnumber[idx + 1], - filenames[idx + 1], - ) = model.get_ext_dict_attr(ext_unit_dict, unit=func(item)) + (unitnumber[idx + 1], filenames[idx + 1]) = model.get_ext_dict_attr( + ext_unit_dict, unit=func(item) + ) model.add_pop_key_list(func(item)) # create dis object instance @@ -685,16 +672,9 @@ def _load_items_0_1(f_obj, model): line_text = line.strip().split() line_text[:8] = [int(item) for item in line_text[:8]] - ( - ncln, - iclnnds, - iclncb, - iclnhd, - iclndd, - iclnib, - nclngwc, - nconduityp, - ) = line_text[:8] + (ncln, iclnnds, iclncb, iclnhd, iclndd, iclnib, nclngwc, nconduityp) = ( + line_text[:8] + ) # Options keywords nrectyp = 0 diff --git a/flopy/mfusg/mfusgdisu.py b/flopy/mfusg/mfusgdisu.py index 0c284387d..617cfff98 100644 --- a/flopy/mfusg/mfusgdisu.py +++ b/flopy/mfusg/mfusgdisu.py @@ -331,12 +331,7 @@ def __init__( if iac is None: raise Exception("iac must be provided") self.iac = Util2d( - model, - (self.nodes,), - np.int32, - iac, - name="iac", - locat=self.unit_number[0], + model, (self.nodes,), np.int32, iac, name="iac", locat=self.unit_number[0] ) assert self.iac.array.sum() == njag, "The sum of iac must equal njag." if ja is None: @@ -345,12 +340,7 @@ def __init__( # convert from zero-based to one-based ja += 1 self.ja = Util2d( - model, - (self.njag,), - np.int32, - ja, - name="ja", - locat=self.unit_number[0], + model, (self.njag,), np.int32, ja, name="ja", locat=self.unit_number[0] ) self.ivc = None if self.ivsd == 1: @@ -373,20 +363,10 @@ def __init__( if cl2 is None: raise Exception("idsymrd is 1 but cl2 was not specified.") self.cl1 = Util2d( - model, - (njags,), - np.float32, - cl1, - name="cl1", - locat=self.unit_number[0], + model, (njags,), np.float32, cl1, name="cl1", locat=self.unit_number[0] ) self.cl2 = Util2d( - model, - (njags,), - np.float32, - cl2, - name="cl2", - locat=self.unit_number[0], + model, (njags,), np.float32, cl2, name="cl2", locat=self.unit_number[0] ) if idsymrd == 0: @@ -409,12 +389,7 @@ def __init__( elif idsymrd == 0: n = self.njag self.fahl = Util2d( - model, - (n,), - np.float32, - fahl, - name="fahl", - locat=self.unit_number[0], + model, (n,), np.float32, fahl, name="fahl", locat=self.unit_number[0] ) # Stress period information diff --git a/flopy/mfusg/mfusggnc.py b/flopy/mfusg/mfusggnc.py index 743ec7add..2114e46db 100644 --- a/flopy/mfusg/mfusggnc.py +++ b/flopy/mfusg/mfusggnc.py @@ -195,12 +195,7 @@ def write_file(self, f=None, check=False): @staticmethod def get_default_dtype(numalphaj, iflalphan): """Returns default GNC dtypes.""" - dtype = np.dtype( - [ - ("NodeN", int), - ("NodeM", int), - ] - ).descr + dtype = np.dtype([("NodeN", int), ("NodeM", int)]).descr for idx in range(numalphaj): dtype.append((f"Node{idx:d}", " 0: f_nam.write( "{:14s} {:5d} {}\n".format( - self.glo.name[0], - self.glo.unit_number[0], - self.glo.file_name[0], + self.glo.name[0], self.glo.unit_number[0], self.glo.file_name[0] ) ) f_nam.write( "{:14s} {:5d} {}\n".format( - self.lst.name[0], - self.lst.unit_number[0], - self.lst.file_name[0], + self.lst.name[0], self.lst.unit_number[0], self.lst.file_name[0] ) ) f_nam.write(str(self.get_name_file_entries())) @@ -831,9 +827,7 @@ def load( ) else: item.package.load( - item.filehandle, - ml, - ext_unit_dict=ext_unit_dict, + item.filehandle, ml, ext_unit_dict=ext_unit_dict ) files_successfully_loaded.append(item.filename) if ml.verbose: @@ -854,9 +848,7 @@ def load( ) else: item.package.load( - item.filehandle, - ml, - ext_unit_dict=ext_unit_dict, + item.filehandle, ml, ext_unit_dict=ext_unit_dict ) files_successfully_loaded.append(item.filename) if ml.verbose: diff --git a/flopy/modflow/mfag.py b/flopy/modflow/mfag.py index 9ff97a627..5e7b16e9d 100644 --- a/flopy/modflow/mfag.py +++ b/flopy/modflow/mfag.py @@ -498,8 +498,7 @@ def write_file(self, check=False): else: foo.write( "{:d} {:f}\n".format( - rec[f"segid{i}"], - rec[f"fracsup{i}"], + rec[f"segid{i}"], rec[f"fracsup{i}"] ) ) @@ -563,21 +562,10 @@ def get_default_dtype(maxells=0, block="well"): dtype : (list, tuple) """ if block == "well": - dtype = [ - ("k", int), - ("i", int), - ("j", int), - ("flux", float), - ] + dtype = [("k", int), ("i", int), ("j", int), ("flux", float)] elif block == "tabfile_well": - dtype = [ - ("unit", int), - ("tabval", int), - ("k", int), - ("i", int), - ("j", int), - ] + dtype = [("unit", int), ("tabval", int), ("k", int), ("i", int), ("j", int)] elif block == "time series": dtype = [("keyword", object), ("id", int), ("unit", int)] diff --git a/flopy/modflow/mfbas.py b/flopy/modflow/mfbas.py index 859669678..9332af262 100644 --- a/flopy/modflow/mfbas.py +++ b/flopy/modflow/mfbas.py @@ -223,11 +223,7 @@ def write_file(self, check=True): """ # allows turning off package checks when writing files at model level if check: - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) # Open file for writing f_bas = open(self.fn_path, "w") # First line: heading @@ -383,9 +379,5 @@ def load(cls, f, model, ext_unit_dict=None, check=True, **kwargs): filenames=filenames, ) if check: - bas.check( - f=f"{bas.name[0]}.chk", - verbose=bas.parent.verbose, - level=0, - ) + bas.check(f=f"{bas.name[0]}.chk", verbose=bas.parent.verbose, level=0) return bas diff --git a/flopy/modflow/mfbcf.py b/flopy/modflow/mfbcf.py index 606031440..714bd88e3 100644 --- a/flopy/modflow/mfbcf.py +++ b/flopy/modflow/mfbcf.py @@ -145,12 +145,7 @@ def __init__( locat=self.unit_number[0], ) self.laycon = Util2d( - model, - (nlay,), - np.int32, - laycon, - name="laycon", - locat=self.unit_number[0], + model, (nlay,), np.int32, laycon, name="laycon", locat=self.unit_number[0] ) self.trpy = Util2d( model, diff --git a/flopy/modflow/mfbct.py b/flopy/modflow/mfbct.py index dbd511521..d85bea493 100644 --- a/flopy/modflow/mfbct.py +++ b/flopy/modflow/mfbct.py @@ -60,13 +60,7 @@ def __init__( self.diffnc = diffnc self.izod = izod self.ifod = ifod - self.icbund = Util3d( - model, - (nlay, nrow, ncol), - np.float32, - icbund, - "icbund", - ) + self.icbund = Util3d(model, (nlay, nrow, ncol), np.float32, icbund, "icbund") self.porosity = Util3d( model, (nlay, nrow, ncol), np.float32, porosity, "porosity" ) @@ -74,13 +68,7 @@ def __init__( self.dlv = Util3d(model, (nlay, nrow, ncol), np.float32, dlv, "dlv") self.dth = Util3d(model, (nlay, nrow, ncol), np.float32, dth, "dth") self.dtv = Util3d(model, (nlay, nrow, ncol), np.float32, dth, "dtv") - self.sconc = Util3d( - model, - (nlay, nrow, ncol), - np.float32, - sconc, - "sconc", - ) + self.sconc = Util3d(model, (nlay, nrow, ncol), np.float32, sconc, "sconc") self.parent.add_package(self) return diff --git a/flopy/modflow/mfdis.py b/flopy/modflow/mfdis.py index cb1c10317..b2bae6bc8 100644 --- a/flopy/modflow/mfdis.py +++ b/flopy/modflow/mfdis.py @@ -601,11 +601,7 @@ def write_file(self, check=True): """ if check: # allows turning off package checks when writing files at model level - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) # Open file for writing f_dis = open(self.fn_path, "w") # Item 0: heading @@ -613,12 +609,7 @@ def write_file(self, check=True): # Item 1: NLAY, NROW, NCOL, NPER, ITMUNI, LENUNI f_dis.write( "{:10d}{:10d}{:10d}{:10d}{:10d}{:10d}\n".format( - self.nlay, - self.nrow, - self.ncol, - self.nper, - self.itmuni, - self.lenuni, + self.nlay, self.nrow, self.ncol, self.nper, self.itmuni, self.lenuni ) ) # Item 2: LAYCBD @@ -685,10 +676,7 @@ def check(self, f=None, verbose=True, level=1, checktype=None): thickness = np.ma.array(thickness, mask=non_finite) chk.values( - thickness, - active & (thickness <= 0), - "zero or negative thickness", - "Error", + thickness, active & (thickness <= 0), "zero or negative thickness", "Error" ) thin_cells = (thickness < chk.thin_cell_threshold) & (thickness > 0) chk.values( @@ -877,11 +865,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): filenames=filenames, ) if check: - dis.check( - f=f"{dis.name[0]}.chk", - verbose=dis.parent.verbose, - level=0, - ) + dis.check(f=f"{dis.name[0]}.chk", verbose=dis.parent.verbose, level=0) # return dis object instance return dis diff --git a/flopy/modflow/mfdrn.py b/flopy/modflow/mfdrn.py index b99e4b77c..0dbaca691 100644 --- a/flopy/modflow/mfdrn.py +++ b/flopy/modflow/mfdrn.py @@ -224,11 +224,7 @@ def write_file(self, check=True): """ if check: # allows turning off package checks when writing files at model level - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) f_drn = open(self.fn_path, "w") f_drn.write(f"{self.heading}\n") line = f"{self.stress_period_data.mxact:10d}{self.ipakcb:10d}" diff --git a/flopy/modflow/mfdrt.py b/flopy/modflow/mfdrt.py index 9638d5ccd..0bc3b39d2 100644 --- a/flopy/modflow/mfdrt.py +++ b/flopy/modflow/mfdrt.py @@ -214,11 +214,7 @@ def write_file(self, check=True): """ if check: # allows turning off package checks when writing files at model level - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) f_drn = open(self.fn_path, "w") f_drn.write(f"{self.heading}\n") line = f"{self.stress_period_data.mxact:10d}{self.ipakcb:10d}{0:10d}{0:10d}" diff --git a/flopy/modflow/mfevt.py b/flopy/modflow/mfevt.py index 7e469422f..2398d9686 100644 --- a/flopy/modflow/mfevt.py +++ b/flopy/modflow/mfevt.py @@ -174,11 +174,7 @@ def write_file(self, f=None): for kper, u2d in self.ievt.transient_2ds.items(): ievt[kper] = u2d.array + 1 ievt = Transient2d( - self.parent, - self.ievt.shape, - self.ievt.dtype, - ievt, - self.ievt.name, + self.parent, self.ievt.shape, self.ievt.dtype, ievt, self.ievt.name ) if not self.parent.structured: mxndevt = np.max( @@ -323,12 +319,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None): if model.verbose: print(f" loading evtr stress period {iper + 1:3d}...") t = Util2d.load( - f, - model, - u2d_shape, - np.float32, - "evtr", - ext_unit_dict, + f, model, u2d_shape, np.float32, "evtr", ext_unit_dict ) else: parm_dict = {} diff --git a/flopy/modflow/mfghb.py b/flopy/modflow/mfghb.py index af0ab4102..75108f977 100644 --- a/flopy/modflow/mfghb.py +++ b/flopy/modflow/mfghb.py @@ -178,11 +178,7 @@ def write_file(self, check=True): """ if check: # allows turning off package checks when writing files at model level - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) f_ghb = open(self.fn_path, "w") f_ghb.write(f"{self.heading}\n") f_ghb.write(f"{self.stress_period_data.mxact:10d}{self.ipakcb:10d}") diff --git a/flopy/modflow/mflak.py b/flopy/modflow/mflak.py index dd686441a..e6bb4d0b7 100644 --- a/flopy/modflow/mflak.py +++ b/flopy/modflow/mflak.py @@ -742,12 +742,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None): print(f" reading lak dataset 6 - for stress period {iper + 1}") name = f"BDLKNC_StressPeriod_{iper}" bdlknc = Util3d.load( - f, - model, - (nlay, nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nlay, nrow, ncol), np.float32, name, ext_unit_dict ) lake_loc[iper] = lakarr diff --git a/flopy/modflow/mflpf.py b/flopy/modflow/mflpf.py index 9c0412bd3..7473cdcfc 100644 --- a/flopy/modflow/mflpf.py +++ b/flopy/modflow/mflpf.py @@ -349,11 +349,7 @@ def write_file(self, check=True, f=None): """ # allows turning off package checks when writing files at model level if check: - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) # get model information nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper @@ -372,11 +368,7 @@ def write_file(self, check=True, f=None): if self.parent.version == "mfusg" and not self.parent.structured: f.write( "{:10d}{:10.6G}{:10d}{:10d} {:s}\n".format( - self.ipakcb, - self.hdry, - self.nplpf, - self.ikcflag, - self.options, + self.ipakcb, self.hdry, self.nplpf, self.ikcflag, self.options ) ) else: @@ -580,12 +572,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading hani layer {k + 1:3d}...") if "hani" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "hani", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "hani", ext_unit_dict ) else: line = f.readline() @@ -634,12 +621,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading sy layer {k + 1:3d}...") if "sy" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "sy", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "sy", ext_unit_dict ) else: line = f.readline() @@ -654,12 +636,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading vkcb layer {k + 1:3d}...") if "vkcb" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "vkcb", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "vkcb", ext_unit_dict ) else: line = f.readline() @@ -721,11 +698,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): filenames=filenames, ) if check: - lpf.check( - f=f"{lpf.name[0]}.chk", - verbose=lpf.parent.verbose, - level=0, - ) + lpf.check(f=f"{lpf.name[0]}.chk", verbose=lpf.parent.verbose, level=0) return lpf @staticmethod diff --git a/flopy/modflow/mfmlt.py b/flopy/modflow/mfmlt.py index 69413dffc..b2fce78af 100644 --- a/flopy/modflow/mfmlt.py +++ b/flopy/modflow/mfmlt.py @@ -204,10 +204,7 @@ def load(cls, f, model, nrow=None, ncol=None, ext_unit_dict=None): ) return cls( - model, - mult_dict=mult_dict, - unitnumber=unitnumber, - filenames=filenames, + model, mult_dict=mult_dict, unitnumber=unitnumber, filenames=filenames ) @staticmethod diff --git a/flopy/modflow/mfmnw1.py b/flopy/modflow/mfmnw1.py index 2b543db50..f16e90191 100644 --- a/flopy/modflow/mfmnw1.py +++ b/flopy/modflow/mfmnw1.py @@ -107,11 +107,7 @@ def __init__( # call base package constructor super().__init__( - model, - extension, - self._ftype(), - unitnumber, - filenames=filenames[0], + model, extension, self._ftype(), unitnumber, filenames=filenames[0] ) self.url = "mnw.html" @@ -187,9 +183,8 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): structured = model.structured if nper is None: nrow, ncol, nlay, nper = model.get_nrow_ncol_nlay_nper() - nper = ( - 1 if nper == 0 else nper - ) # otherwise iterations from 0, nper won't run + nper = 1 if nper == 0 else nper + # otherwise iterations from 0, nper won't run openfile = not hasattr(f, "read") if openfile: @@ -277,13 +272,7 @@ def write_file(self): # -Section 1 - MXMNW ipakcb IWELPT NOMOITER REF:kspref f.write( "%10i%10i%10i%10i REF = %s\n" - % ( - self.mxmnw, - self.ipakcb, - self.iwelpt, - self.nomoiter, - self.kspref, - ) + % (self.mxmnw, self.ipakcb, self.iwelpt, self.nomoiter, self.kspref) ) # -Section 2 - LOSSTYPE {PLossMNW} diff --git a/flopy/modflow/mfmnw2.py b/flopy/modflow/mfmnw2.py index 091b9d4d6..c65bc4d0c 100644 --- a/flopy/modflow/mfmnw2.py +++ b/flopy/modflow/mfmnw2.py @@ -606,14 +606,7 @@ def get_item2_names(mnw2obj=None, node_data=None): names += ["k"] if nnodes < 0: names += ["ztop", "zbotm"] - names += [ - "wellid", - "losstype", - "pumploc", - "qlimit", - "ppflag", - "pumpcap", - ] + names += ["wellid", "losstype", "pumploc", "qlimit", "ppflag", "pumpcap"] if losstype.lower() == "thiem": names += ["rw"] elif losstype.lower() == "skin": @@ -765,11 +758,7 @@ def _write_2(self, f_mnw, float_format=" {:15.7E}", indent=12): fmt = indent + "{} {:.0f} {:.0f} {:.0f} {:.0f}\n" f_mnw.write( fmt.format( - self.losstype, - self.pumploc, - self.qlimit, - self.ppflag, - self.pumpcap, + self.losstype, self.pumploc, self.qlimit, self.ppflag, self.pumpcap ) ) @@ -1014,9 +1003,8 @@ def __init__( self.url = "mnw2.html" self.nper = self.parent.nrow_ncol_nlay_nper[-1] - self.nper = ( - 1 if self.nper == 0 else self.nper - ) # otherwise iterations from 0, nper won't run + self.nper = 1 if self.nper == 0 else self.nper + # otherwise iterations from 0, nper won't run self.structured = self.parent.structured # Dataset 0 @@ -1300,9 +1288,8 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): structured = model.structured if nper is None: nrow, ncol, nlay, nper = model.get_nrow_ncol_nlay_nper() - nper = ( - 1 if nper == 0 else nper - ) # otherwise iterations from 0, nper won't run + nper = 1 if nper == 0 else nper + # otherwise iterations from 0, nper won't run openfile = not hasattr(f, "read") if openfile: @@ -1355,16 +1342,7 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): kij = [ndw.k[0], ndw.i[0], ndw.j[0]] current_4[i] = tuple( kij - + [ - wellid, - qdes, - capmult, - cprime, - hlim, - qcut, - qfrcmn, - qfrcmx, - ] + + [wellid, qdes, capmult, cprime, hlim, qcut, qfrcmn, qfrcmx] + xyz ) # update well stress period data table @@ -1458,9 +1436,7 @@ def check(self, f=None, verbose=True, level=1, checktype=None): if np.any(invalid_itmp): for v in np.array(self.itmp)[invalid_itmp]: chk._add_to_summary( - type="Error", - value=v, - desc="Itmp value greater than MNWMAX", + type="Error", value=v, desc="Itmp value greater than MNWMAX" ) chk.summarize() diff --git a/flopy/modflow/mfpbc.py b/flopy/modflow/mfpbc.py index 3fed2841a..bcbef1dd1 100644 --- a/flopy/modflow/mfpbc.py +++ b/flopy/modflow/mfpbc.py @@ -40,10 +40,7 @@ def __init__( "or layer_row_column_data." ) - ( - self.mxactp, - self.layer_row_column_data, - ) = self.assign_layer_row_column_data( + (self.mxactp, self.layer_row_column_data) = self.assign_layer_row_column_data( layer_row_column_data, 5, zerobase=zerobase ) # misuse of this function - zerobase needs to be False diff --git a/flopy/modflow/mfpval.py b/flopy/modflow/mfpval.py index 9d17b1eb3..019ad6b5a 100644 --- a/flopy/modflow/mfpval.py +++ b/flopy/modflow/mfpval.py @@ -192,10 +192,7 @@ def load(cls, f, model, ext_unit_dict=None): ) return cls( - model, - pval_dict=pval_dict, - unitnumber=unitnumber, - filenames=filenames, + model, pval_dict=pval_dict, unitnumber=unitnumber, filenames=filenames ) @staticmethod diff --git a/flopy/modflow/mfrch.py b/flopy/modflow/mfrch.py index 080850756..4cb12054e 100644 --- a/flopy/modflow/mfrch.py +++ b/flopy/modflow/mfrch.py @@ -199,11 +199,7 @@ def check( # (ugly, would be nice to put this else where in a general function) if self.parent.dis.laycbd.sum() != 0: thickness = np.empty( - ( - self.parent.dis.nlay, - self.parent.dis.nrow, - self.parent.dis.ncol, - ), + (self.parent.dis.nlay, self.parent.dis.nrow, self.parent.dis.ncol), dtype=float, ) l = 0 @@ -288,11 +284,7 @@ def write_file(self, check=True, f=None): """ # allows turning off package checks when writing files at model level if check: - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper # Open file for writing if f is not None: @@ -307,11 +299,7 @@ def write_file(self, check=True, f=None): for kper, u2d in self.irch.transient_2ds.items(): irch[kper] = u2d.array + 1 irch = Transient2d( - self.parent, - self.irch.shape, - self.irch.dtype, - irch, - self.irch.name, + self.parent, self.irch.shape, self.irch.dtype, irch, self.irch.name ) if not self.parent.structured: mxndrch = np.max( @@ -440,12 +428,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None, check=True): if model.verbose: print(f" loading rech stress period {iper + 1:3d}...") t = Util2d.load( - f, - model, - u2d_shape, - np.float32, - "rech", - ext_unit_dict, + f, model, u2d_shape, np.float32, "rech", ext_unit_dict ) else: parm_dict = {} @@ -505,11 +488,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None, check=True): filenames=filenames, ) if check: - rch.check( - f=f"{rch.name[0]}.chk", - verbose=rch.parent.verbose, - level=0, - ) + rch.check(f=f"{rch.name[0]}.chk", verbose=rch.parent.verbose, level=0) return rch @staticmethod diff --git a/flopy/modflow/mfriv.py b/flopy/modflow/mfriv.py index f8b80ed1b..b9e9a7873 100644 --- a/flopy/modflow/mfriv.py +++ b/flopy/modflow/mfriv.py @@ -294,11 +294,7 @@ def write_file(self, check=True): """ # allows turning off package checks when writing files at model level if check: - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) f_riv = open(self.fn_path, "w") f_riv.write(f"{self.heading}\n") line = f"{self.stress_period_data.mxact:10d}{self.ipakcb:10d}" diff --git a/flopy/modflow/mfsfr2.py b/flopy/modflow/mfsfr2.py index 685461db7..c3f6e546d 100644 --- a/flopy/modflow/mfsfr2.py +++ b/flopy/modflow/mfsfr2.py @@ -355,10 +355,7 @@ def __init__( if fname is None: fname = f"{model.name}.sfr.{ext}" model.add_output_file( - abs(istcb2), - fname=fname, - binflag=binflag, - package=self._ftype(), + abs(istcb2), fname=fname, binflag=binflag, package=self._ftype() ) else: istcb2 = 0 @@ -769,9 +766,8 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): structured = model.structured if nper is None: nper = model.nper - nper = ( - 1 if nper == 0 else nper - ) # otherwise iterations from 0, nper won't run + nper = 1 if nper == 0 else nper + # otherwise iterations from 0, nper won't run openfile = not hasattr(f, "read") if openfile: @@ -859,9 +855,8 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): # initialize full reach_data array with all possible columns reach_data = ModflowSfr2.get_empty_reach_data(len(lines)) for n in names: - reach_data[n] = tmp[ - n - ] # not sure if there's a way to assign multiple columns + # not sure if there's a way to assign multiple columns + reach_data[n] = tmp[n] # zero-based convention inds = ["k", "i", "j"] if structured else ["node"] @@ -928,7 +923,7 @@ def load(cls, f, model, nper=None, gwt=False, nsol=1, ext_unit_dict=None): # dataset 6d description suggests that this line isn't read for # isfropt > 1 but description of icalc suggest that icalc=2 # (8-point channel) can be used with any isfropt - if i == 0 or nstrm > 0 and not reachinput or isfropt <= 1: + if i == 0 or (nstrm > 0 and not reachinput) or isfropt <= 1: dataset_6d = [] for _ in range(2): dataset_6d.append(_get_dataset(f.readline(), [0.0] * 8)) @@ -1292,9 +1287,8 @@ def get_upsegs(self): for o in np.unique(segment_data.outseg) } - outsegs = [ - k for k in list(upsegs.keys()) if k > 0 - ] # exclude 0, which is the outlet designator + # exclude 0, which is the outlet designator + outsegs = [k for k in list(upsegs.keys()) if k > 0] # for each outseg key, for each upseg, check for more upsegs, # append until headwaters has been reached @@ -1611,9 +1605,8 @@ def _write_1c(self, f_sfr): ) ) if self.reachinput: - self.nstrm = abs( - self.nstrm - ) # see explanation for dataset 1c in online guide + # see explanation for dataset 1c in online guide + self.nstrm = abs(self.nstrm) f_sfr.write(f"{self.isfropt:.0f} ") if self.isfropt > 1: f_sfr.write(f"{self.nstrail:.0f} {self.isuzn:.0f} {self.nsfrsets:.0f} ") @@ -1635,10 +1628,7 @@ def _write_reach_data(self, f_sfr): # decide which columns to write columns = _get_item2_names( - self.nstrm, - self.reachinput, - self.isfropt, - structured=self.parent.structured, + self.nstrm, self.reachinput, self.isfropt, structured=self.parent.structured ) # --make copy of data for multiple calls @@ -1858,8 +1848,7 @@ def write_file(self, filename=None): # or isfropt <= 1: if ( i == 0 - or self.nstrm > 0 - and not self.reachinput + or (self.nstrm > 0 and not self.reachinput) or self.isfropt <= 1 ): for k in range(2): @@ -1938,11 +1927,7 @@ def export_linkages(self, f, **kwargs): # append connection lengths for filtering in GIS rd = recfunctions.append_fields( - rd, - names=["length"], - data=[lengths], - usemask=False, - asrecarray=True, + rd, names=["length"], data=[lengths], usemask=False, asrecarray=True ) recarray2shp(rd, geoms, f, **kwargs) @@ -2334,8 +2319,7 @@ def routing(self): txt += " ".join(map(str, segments_with_breaks)) + "\n" else: fpath = os.path.join( - self.sfr.parent._model_ws, - "reach_connection_gaps.chk.csv", + self.sfr.parent._model_ws, "reach_connection_gaps.chk.csv" ) with open(fpath, "w") as fp: fp.write(",".join(rd.dtype.names) + "\n") @@ -2530,10 +2514,7 @@ def elevations(self, min_strtop=-10, max_strtop=15000): # enforce consecutive increasing segment numbers (for indexing) segment_data.sort(order="nseg") t = _check_numbers( - len(segment_data), - segment_data.nseg, - level=1, - datatype="Segment", + len(segment_data), segment_data.nseg, level=1, datatype="Segment" ) if len(t) > 0: txt += "Elevation check requires consecutive segment numbering." @@ -2573,13 +2554,7 @@ def elevations(self, min_strtop=-10, max_strtop=15000): txt += self._boolean_compare( non_outlets_seg_data[ - [ - "nseg", - "outseg", - "elevdn", - "outseg_elevup", - "d_elev2", - ] + ["nseg", "outseg", "elevdn", "outseg_elevup", "d_elev2"] ], col1="d_elev2", col2=np.zeros(len(non_outlets_seg_data)), @@ -2606,9 +2581,10 @@ def elevations(self, min_strtop=-10, max_strtop=15000): if self.verbose: print(headertxt.strip()) passed = False - if ( - self.sfr.nstrm < 0 or self.sfr.reachinput and self.sfr.isfropt in [1, 2, 3] - ): # see SFR input instructions + if self.sfr.nstrm < 0 or ( + self.sfr.reachinput and self.sfr.isfropt in [1, 2, 3] + ): + # see SFR input instructions # compute outreaches if they aren't there already if np.diff(self.sfr.reach_data.outreach).max() == 0: self.sfr.set_outreaches() @@ -2628,13 +2604,12 @@ def elevations(self, min_strtop=-10, max_strtop=15000): ] ) - reach_data = ( - self.sfr.reach_data - ) # inconsistent with other checks that work with + # inconsistent with other checks that work with # reach_data attribute of check class. Want to have get_outreaches # as a method of sfr class (for other uses). Not sure if other # check methods should also copy reach_data directly from # SFR package instance for consistency. + reach_data = self.sfr.reach_data rd = recfunctions.append_fields( rd, @@ -2685,9 +2660,10 @@ def elevations(self, min_strtop=-10, max_strtop=15000): return passed = False warning = True - if ( - self.sfr.nstrm < 0 or self.sfr.reachinput and self.sfr.isfropt in [1, 2, 3] - ): # see SFR input instructions + if self.sfr.nstrm < 0 or ( + self.sfr.reachinput and self.sfr.isfropt in [1, 2, 3] + ): + # see SFR input instructions reach_data = np.array(self.reach_data) i, j, k = reach_data["i"], reach_data["j"], reach_data["k"] @@ -2727,11 +2703,7 @@ def elevations(self, min_strtop=-10, max_strtop=15000): # check streambed elevations in relation to model top tops = self.sfr.parent.dis.top.array[i, j] reach_data = recfunctions.append_fields( - reach_data, - names="modeltop", - data=tops, - usemask=False, - asrecarray=False, + reach_data, names="modeltop", data=tops, usemask=False, asrecarray=False ) txt += self._boolean_compare( @@ -2792,10 +2764,7 @@ def elevations(self, min_strtop=-10, max_strtop=15000): # enforce consecutive increasing segment numbers (for indexing) segment_data.sort(order="nseg") t = _check_numbers( - len(segment_data), - segment_data.nseg, - level=1, - datatype="Segment", + len(segment_data), segment_data.nseg, level=1, datatype="Segment" ) if len(t) > 0: raise Exception( @@ -2825,16 +2794,7 @@ def elevations(self, min_strtop=-10, max_strtop=15000): txt += self._boolean_compare( segment_ends[ - [ - "k", - "i", - "j", - "iseg", - "strtop", - "modeltop", - "diff", - "reachID", - ] + ["k", "i", "j", "iseg", "strtop", "modeltop", "diff", "reachID"] ].copy(), col1=np.zeros(len(segment_ends)), col2="diff", @@ -2995,9 +2955,8 @@ def _get_duplicates(a): method https://stackoverflow.com/q/11528078/ """ s = np.sort(a, axis=None) - equal_to_previous_item = np.append( - s[1:] == s[:-1], False - ) # maintain same dimension for boolean array + # maintain same dimension for boolean array + equal_to_previous_item = np.append(s[1:] == s[:-1], False) return np.unique(s[equal_to_previous_item]) diff --git a/flopy/modflow/mfsip.py b/flopy/modflow/mfsip.py index 096a0c7a5..ba2c30f4b 100644 --- a/flopy/modflow/mfsip.py +++ b/flopy/modflow/mfsip.py @@ -148,11 +148,7 @@ def write_file(self): f.write(f"{self.mxiter:10d}{self.nparm:10d}\n") f.write( "{:10.3f}{:10.3g}{:10d}{:10.3f}{:10d}\n".format( - self.accl, - self.hclose, - self.ipcalc, - self.wseed, - self.iprsip, + self.accl, self.hclose, self.ipcalc, self.wseed, self.iprsip ) ) f.close() diff --git a/flopy/modflow/mfstr.py b/flopy/modflow/mfstr.py index f0878c551..214028ca5 100644 --- a/flopy/modflow/mfstr.py +++ b/flopy/modflow/mfstr.py @@ -833,10 +833,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None): if model.verbose: print(" reading str dataset 6") current, current_seg = ModflowStr.get_empty( - itmp, - nss, - aux_names=aux_names, - structured=model.structured, + itmp, nss, aux_names=aux_names, structured=model.structured ) for ibnd in range(itmp): line = f.readline() diff --git a/flopy/modflow/mfsub.py b/flopy/modflow/mfsub.py index b7b68dec0..158d4cee3 100644 --- a/flopy/modflow/mfsub.py +++ b/flopy/modflow/mfsub.py @@ -259,10 +259,7 @@ def __init__( if idsave is not None: model.add_output_file( - idsave, - fname=filenames[2], - extension="rst", - package=self._ftype(), + idsave, fname=filenames[2], extension="rst", package=self._ftype() ) else: idsave = 0 @@ -652,48 +649,28 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading sub dataset 5 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"hc layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"hc layer {kk}", ext_unit_dict ) hc[k] = t # sfe if model.verbose: print(f" loading sub dataset 6 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"sfe layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"sfe layer {kk}", ext_unit_dict ) sfe[k] = t # sfv if model.verbose: print(f" loading sub dataset 7 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"sfv layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"sfv layer {kk}", ext_unit_dict ) sfv[k] = t # com if model.verbose: print(f" loading sub dataset 8 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"com layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"com layer {kk}", ext_unit_dict ) com[k] = t @@ -737,12 +714,7 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading sub dataset 11 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"dhc layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"dhc layer {kk}", ext_unit_dict ) dhc[k] = t # dcom @@ -761,24 +733,14 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading sub dataset 13 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"dz layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"dz layer {kk}", ext_unit_dict ) dz[k] = t # nz if model.verbose: print(f" loading sub dataset 14 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.int32, - f"nz layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.int32, f"nz layer {kk}", ext_unit_dict ) nz[k] = t diff --git a/flopy/modflow/mfswi2.py b/flopy/modflow/mfswi2.py index 86c4ce19f..92a9a66ec 100644 --- a/flopy/modflow/mfswi2.py +++ b/flopy/modflow/mfswi2.py @@ -234,10 +234,7 @@ def __init__( # update external file information with zeta output, if necessary if iswizt is not None: model.add_output_file( - iswizt, - fname=filenames[1], - extension="zta", - package=self._ftype(), + iswizt, fname=filenames[1], extension="zta", package=self._ftype() ) else: iswizt = 0 @@ -359,11 +356,7 @@ def __init__( for i in range(self.nsrf): self.zeta.append( Util3d( - model, - (nlay, nrow, ncol), - np.float32, - zeta[i], - name=f"zeta_{i + 1}", + model, (nlay, nrow, ncol), np.float32, zeta[i], name=f"zeta_{i + 1}" ) ) self.ssz = Util3d(model, (nlay, nrow, ncol), np.float32, ssz, name="ssz") @@ -645,12 +638,7 @@ def load(cls, f, model, ext_unit_dict=None): ctxt = f"zeta_surf{n + 1:02d}" zeta.append( Util3d.load( - f, - model, - (nlay, nrow, ncol), - np.float32, - ctxt, - ext_unit_dict, + f, model, (nlay, nrow, ncol), np.float32, ctxt, ext_unit_dict ) ) diff --git a/flopy/modflow/mfswt.py b/flopy/modflow/mfswt.py index 19ebd6107..06bb287d9 100644 --- a/flopy/modflow/mfswt.py +++ b/flopy/modflow/mfswt.py @@ -631,18 +631,7 @@ def load(cls, f, model, ext_unit_dict=None): print(" loading swt dataset 3") line = f.readline() t = line.strip().split() - ( - iizcfl, - izcfm, - iglfl, - iglfm, - iestfl, - iestfm, - ipcsfl, - ipcsfm, - istfl, - istfm, - ) = ( + (iizcfl, izcfm, iglfl, iglfm, iestfl, iestfm, ipcsfl, ipcsfm, istfl, istfm) = ( int(t[0]), int(t[1]), int(t[2]), @@ -691,12 +680,7 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading swt dataset 7 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"thick layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"thick layer {kk}", ext_unit_dict ) thick[k] = t if icrcc != 0: @@ -704,24 +688,14 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading swt dataset 8 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"sse layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"sse layer {kk}", ext_unit_dict ) sse[k] = t # ssv if model.verbose: print(f" loading swt dataset 9 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"sse layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"sse layer {kk}", ext_unit_dict ) ssv[k] = t else: @@ -729,48 +703,28 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(f" loading swt dataset 10 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"cr layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"cr layer {kk}", ext_unit_dict ) cr[k] = t # cc if model.verbose: print(f" loading swt dataset 11 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"cc layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"cc layer {kk}", ext_unit_dict ) cc[k] = t # void if model.verbose: print(f" loading swt dataset 12 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"void layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"void layer {kk}", ext_unit_dict ) void[k] = t # sub if model.verbose: print(f" loading swt dataset 13 for layer {kk}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - f"sub layer {kk}", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, f"sub layer {kk}", ext_unit_dict ) sub[k] = t diff --git a/flopy/modflow/mfupw.py b/flopy/modflow/mfupw.py index 85a40821d..3722b1f9a 100644 --- a/flopy/modflow/mfupw.py +++ b/flopy/modflow/mfupw.py @@ -274,11 +274,7 @@ def write_file(self, check=True, f=None): """ # allows turning off package checks when writing files at model level if check: - self.check( - f=f"{self.name[0]}.chk", - verbose=self.parent.verbose, - level=1, - ) + self.check(f=f"{self.name[0]}.chk", verbose=self.parent.verbose, level=1) nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper if f is not None: f_upw = f @@ -383,12 +379,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): if model.verbose: print(" loading ipakcb, HDRY, NPUPW, IPHDRY...") t = line_parse(line) - ipakcb, hdry, npupw, iphdry = ( - int(t[0]), - float(t[1]), - int(t[2]), - int(t[3]), - ) + ipakcb, hdry, npupw, iphdry = (int(t[0]), float(t[1]), int(t[2]), int(t[3])) # options noparcheck = False @@ -465,12 +456,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading hani layer {k + 1:3d}...") if "hani" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "hani", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "hani", ext_unit_dict ) else: line = f.readline() @@ -516,12 +502,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading sy layer {k + 1:3d}...") if "sy" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "sy", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "sy", ext_unit_dict ) else: line = f.readline() @@ -536,12 +517,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): print(f" loading vkcb layer {k + 1:3d}...") if "vkcb" not in par_types: t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "vkcb", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "vkcb", ext_unit_dict ) else: line = f.readline() @@ -586,11 +562,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True): filenames=filenames, ) if check: - upw.check( - f=f"{upw.name[0]}.chk", - verbose=upw.parent.verbose, - level=0, - ) + upw.check(f=f"{upw.name[0]}.chk", verbose=upw.parent.verbose, level=0) # return upw object return upw diff --git a/flopy/modflow/mfzon.py b/flopy/modflow/mfzon.py index 7d63e2184..b55b397d1 100644 --- a/flopy/modflow/mfzon.py +++ b/flopy/modflow/mfzon.py @@ -196,10 +196,7 @@ def load(cls, f, model, nrow=None, ncol=None, ext_unit_dict=None): ) return cls( - model, - zone_dict=zone_dict, - unitnumber=unitnumber, - filenames=filenames, + model, zone_dict=zone_dict, unitnumber=unitnumber, filenames=filenames ) @staticmethod diff --git a/flopy/modflowlgr/mflgr.py b/flopy/modflowlgr/mflgr.py index 790ed197b..5f3dff655 100644 --- a/flopy/modflowlgr/mflgr.py +++ b/flopy/modflowlgr/mflgr.py @@ -359,9 +359,7 @@ def write_name_file(self): # dataset 12 line = "{} {} {}".format( - child_data.nplbeg + 1, - child_data.nprbeg + 1, - child_data.npcbeg + 1, + child_data.nplbeg + 1, child_data.nprbeg + 1, child_data.npcbeg + 1 ) comment = f"data set 12 - child {idx + 1} nplbeg, nprbeg, npcbeg" line = self._padline(line, comment=comment) @@ -369,9 +367,7 @@ def write_name_file(self): # dataset 13 line = "{} {} {}".format( - child_data.nplend + 1, - child_data.nprend + 1, - child_data.npcend + 1, + child_data.nplend + 1, child_data.nprend + 1, child_data.npcend + 1 ) comment = f"data set 13 - child {idx + 1} nplend, nprend, npcend" line = self._padline(line, comment=comment) @@ -611,20 +607,12 @@ def load( # dataset 12 line = f.readline() t = line.split() - nplbeg, nprbeg, npcbeg = ( - int(t[0]) - 1, - int(t[1]) - 1, - int(t[2]) - 1, - ) + nplbeg, nprbeg, npcbeg = (int(t[0]) - 1, int(t[1]) - 1, int(t[2]) - 1) # dataset 13 line = f.readline() t = line.split() - nplend, nprend, npcend = ( - int(t[0]) - 1, - int(t[1]) - 1, - int(t[2]) - 1, - ) + nplend, nprend, npcend = (int(t[0]) - 1, int(t[1]) - 1, int(t[2]) - 1) # dataset 14 line = f.readline() diff --git a/flopy/modpath/mp6.py b/flopy/modpath/mp6.py index a21e06216..33f70d193 100644 --- a/flopy/modpath/mp6.py +++ b/flopy/modpath/mp6.py @@ -163,12 +163,7 @@ def __init__( while line[0] == "#": line = f.readline() nlay, nrow, ncol, nper, itmuni, lennuni = line.split() - self.nrow_ncol_nlay_nper = ( - int(nrow), - int(ncol), - int(nlay), - int(nper), - ) + self.nrow_ncol_nlay_nper = (int(nrow), int(ncol), int(nlay), int(nper)) # set the rest of the attributes self.__sim = None @@ -405,12 +400,7 @@ def append_node(ifaces_well, wellid, node_number, k, i, j): k, i, j = nd.k[0], nd.i[0], nd.j[0] if len(nd) == 1: append_node( - side_faces + [top_face, botm_face], - wellid, - 0, - k, - i, - j, + side_faces + [top_face, botm_face], wellid, 0, k, i, j ) else: append_node(side_faces + [top_face], wellid, 0, k, i, j) @@ -418,12 +408,7 @@ def append_node(ifaces_well, wellid, node_number, k, i, j): k, i, j = nd.k[n], nd.i[n], nd.j[n] if n == len(nd) - 1: append_node( - side_faces + [botm_face], - wellid, - n, - k, - i, - j, + side_faces + [botm_face], wellid, n, k, i, j ) else: append_node(side_faces, wellid, n, k, i, j) diff --git a/flopy/modpath/mp6sim.py b/flopy/modpath/mp6sim.py index 361fdb14d..8ef2895b4 100644 --- a/flopy/modpath/mp6sim.py +++ b/flopy/modpath/mp6sim.py @@ -274,21 +274,13 @@ def write_file(self): ) # item 14 if ReleaseOption == 2: - ( - ReleasePeriodLength, - ReleaseEventCount, - ) = self.release_times[i] + (ReleasePeriodLength, ReleaseEventCount) = self.release_times[i] f_sim.write(f"{ReleasePeriodLength:f} {ReleaseEventCount}\n") # item 15 if GridCellRegionOption == 1: - ( - MinLayer, - MinRow, - MinColumn, - MaxLayer, - MaxRow, - MaxColumn, - ) = self.group_region[i] + (MinLayer, MinRow, MinColumn, MaxLayer, MaxRow, MaxColumn) = ( + self.group_region[i] + ) f_sim.write( "{:d} {:d} {:d} {:d} {:d} {:d}\n".format( MinLayer + 1, @@ -312,26 +304,18 @@ def write_file(self): f_sim.write(f"{self.face_ct[i]}\n") # item 20 for j in range(self.face_ct[i]): - ( - IFace, - ParticleRowCount, - ParticleColumnCount, - ) = self.ifaces[i][j] + IFace, ParticleRowCount, ParticleColumnCount = self.ifaces[i][j] f_sim.write( f"{IFace} {ParticleRowCount} {ParticleColumnCount}\n" ) # item 21 elif PlacementOption == 2: - ( - ParticleLayerCount, - ParticleRowCount, - ParticleColumnCount, - ) = self.particle_cell_cnt[i] + (ParticleLayerCount, ParticleRowCount, ParticleColumnCount) = ( + self.particle_cell_cnt[i] + ) f_sim.write( "{:d} {:d} {:d} \n".format( - ParticleLayerCount, - ParticleRowCount, - ParticleColumnCount, + ParticleLayerCount, ParticleRowCount, ParticleColumnCount ) ) diff --git a/flopy/modpath/mp7.py b/flopy/modpath/mp7.py index 07bfa354a..67fda5a1a 100644 --- a/flopy/modpath/mp7.py +++ b/flopy/modpath/mp7.py @@ -137,20 +137,14 @@ def __init__( ) else: if dis.package_name.lower() == "dis": - nlay, nrow, ncol = ( - dis.nlay.array, - dis.nrow.array, - dis.ncol.array, - ) + nlay, nrow, ncol = (dis.nlay.array, dis.nrow.array, dis.ncol.array) shape = (nlay, nrow, ncol) elif dis.package_name.lower() == "disv": nlay, ncpl = dis.nlay.array, dis.ncpl.array shape = (nlay, ncpl) elif dis.package_name.lower() == "disu": nodes = dis.nodes.array - shape = tuple( - nodes, - ) + shape = tuple(nodes) else: raise TypeError( "DIS, DISV, or DISU packages must be " diff --git a/flopy/modpath/mp7particledata.py b/flopy/modpath/mp7particledata.py index 698513f88..a191315c9 100644 --- a/flopy/modpath/mp7particledata.py +++ b/flopy/modpath/mp7particledata.py @@ -350,12 +350,7 @@ def write(self, f=None): d = np.recarray.copy(self.particledata.to_records(index=False)) lnames = [name.lower() for name in d.dtype.names] # Add one to the kij and node indices - for idx in ( - "k", - "i", - "j", - "node", - ): + for idx in ("k", "i", "j", "node"): if idx in lnames: d[idx] += 1 # Add one to the particle id if required @@ -772,26 +767,14 @@ def write(self, f=None): # item 5 fmt = " {} {} {}\n" line = fmt.format( - self.columncelldivisions, - self.rowcelldivisions, - self.layercelldivisions, + self.columncelldivisions, self.rowcelldivisions, self.layercelldivisions ) f.write(line) Extent = namedtuple( "Extent", - [ - "minx", - "maxx", - "miny", - "maxy", - "minz", - "maxz", - "xspan", - "yspan", - "zspan", - ], + ["minx", "maxx", "miny", "maxy", "minz", "maxz", "xspan", "yspan", "zspan"], ) diff --git a/flopy/modpath/mp7particlegroup.py b/flopy/modpath/mp7particlegroup.py index 1b1ff820e..37df44646 100644 --- a/flopy/modpath/mp7particlegroup.py +++ b/flopy/modpath/mp7particlegroup.py @@ -142,9 +142,7 @@ def write(self, fp=None, ws="."): # item 29 fp.write( "{} {} {}\n".format( - self.releasetimecount, - self.releasetimes[0], - self.releaseinterval, + self.releasetimecount, self.releasetimes[0], self.releaseinterval ) ) elif self.releaseoption == 3: diff --git a/flopy/modpath/mp7sim.py b/flopy/modpath/mp7sim.py index 3a5e883fd..3df35c139 100644 --- a/flopy/modpath/mp7sim.py +++ b/flopy/modpath/mp7sim.py @@ -520,12 +520,7 @@ def __init__( if zones is None: raise ValueError("zones must be specified if zonedataoption='on'.") self.zones = Util3d( - model, - shape3d, - np.int32, - zones, - name="zones", - locat=self.unit_number[0], + model, shape3d, np.int32, zones, name="zones", locat=self.unit_number[0] ) # retardationfactoroption @@ -553,11 +548,7 @@ def __init__( particlegroups = [ParticleGroup()] elif isinstance( particlegroups, - ( - ParticleGroup, - ParticleGroupLRCTemplate, - ParticleGroupNodeTemplate, - ), + (ParticleGroup, ParticleGroupLRCTemplate, ParticleGroupNodeTemplate), ): particlegroups = [particlegroups] self.particlegroups = particlegroups diff --git a/flopy/mt3d/mt.py b/flopy/mt3d/mt.py index 522a6190c..acaf90e12 100644 --- a/flopy/mt3d/mt.py +++ b/flopy/mt3d/mt.py @@ -382,9 +382,7 @@ def write_name_file(self): f_nam.write(f"{self.heading}\n") f_nam.write( "{:14s} {:5d} {}\n".format( - self.lst.name[0], - self.lst.unit_number[0], - self.lst.file_name[0], + self.lst.name[0], self.lst.unit_number[0], self.lst.file_name[0] ) ) if self.ftlfilename is not None: @@ -589,9 +587,7 @@ def load( if forgive: try: pck = item.package.load( - item.filehandle, - mt, - ext_unit_dict=ext_unit_dict, + item.filehandle, mt, ext_unit_dict=ext_unit_dict ) files_successfully_loaded.append(item.filename) if mt.verbose: diff --git a/flopy/mt3d/mtadv.py b/flopy/mt3d/mtadv.py index a4704f1f1..1d961139f 100644 --- a/flopy/mt3d/mtadv.py +++ b/flopy/mt3d/mtadv.py @@ -239,14 +239,7 @@ def write_file(self): if (self.mixelm == 1) or (self.mixelm == 3): f_adv.write( "%10.4e%10i%10i%10i%10i%10i\n" - % ( - self.dceps, - self.nplane, - self.npl, - self.nph, - self.npmin, - self.npmax, - ) + % (self.dceps, self.nplane, self.npl, self.nph, self.npmin, self.npmax) ) if (self.mixelm == 2) or (self.mixelm == 3): f_adv.write("%10i%10i%10i\n" % (self.interp, self.nlsink, self.npsink)) diff --git a/flopy/mt3d/mtbtn.py b/flopy/mt3d/mtbtn.py index 3a302c366..f74a62342 100644 --- a/flopy/mt3d/mtbtn.py +++ b/flopy/mt3d/mtbtn.py @@ -322,12 +322,7 @@ def __init__( ) self.ssflag = ssflag self.dt0 = Util2d( - model, - (self.nper,), - np.float32, - dt0, - name="dt0", - array_free_format=False, + model, (self.nper,), np.float32, dt0, name="dt0", array_free_format=False ) self.mxstrn = Util2d(model, (self.nper,), np.int32, mxstrn, name="mxstrn") self.ttsmult = Util2d(model, (self.nper,), np.float32, ttsmult, name="ttmult") @@ -692,12 +687,7 @@ def write_file(self): # A3 f_btn.write( "{:10d}{:10d}{:10d}{:10d}{:10d}{:10d}\n".format( - self.nlay, - self.nrow, - self.ncol, - self.nper, - self.ncomp, - self.mcomp, + self.nlay, self.nrow, self.ncol, self.nper, self.ncomp, self.mcomp ) ) @@ -789,9 +779,7 @@ def write_file(self): for i in range(nobs): f_btn.write( "{:10d}{:10d}{:10d}\n".format( - self.obs[i, 0] + 1, - self.obs[i, 1] + 1, - self.obs[i, 2] + 1, + self.obs[i, 0] + 1, self.obs[i, 1] + 1, self.obs[i, 2] + 1 ) ) @@ -811,10 +799,7 @@ def write_file(self): f_btn.write(s) f_btn.write( "{:10.4G}{:10d}{:10.4G}{:10.4G}\n".format( - self.dt0[t], - self.mxstrn[t], - self.ttsmult[t], - self.ttsmax[t], + self.dt0[t], self.mxstrn[t], self.ttsmult[t], self.ttsmax[t] ) ) f_btn.close() @@ -881,9 +866,8 @@ def load(cls, f, model, ext_unit_dict=None): NoWetDryPrint = False OmitDryBud = False AltWTSorb = False - if ( - m_arr[0].strip().isdigit() is not True - ): # If m_arr[0] is not a digit, it is a keyword + if m_arr[0].strip().isdigit() is not True: + # If m_arr[0] is not a digit, it is a keyword if model.verbose: print(f" loading optional keywords: {line.strip()}") for i in range(0, len(m_arr)): @@ -957,13 +941,7 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(" loading DELR...") delr = Util2d.load( - f, - model, - (ncol,), - np.float32, - "delr", - ext_unit_dict, - array_format="mt3d", + f, model, (ncol,), np.float32, "delr", ext_unit_dict, array_format="mt3d" ) if model.verbose: print(f" DELR {delr}") @@ -971,13 +949,7 @@ def load(cls, f, model, ext_unit_dict=None): if model.verbose: print(" loading DELC...") delc = Util2d.load( - f, - model, - (nrow,), - np.float32, - "delc", - ext_unit_dict, - array_format="mt3d", + f, model, (nrow,), np.float32, "delc", ext_unit_dict, array_format="mt3d" ) if model.verbose: print(f" DELC {delc}") diff --git a/flopy/mt3d/mtcts.py b/flopy/mt3d/mtcts.py index 6e2eba045..33cbb0503 100644 --- a/flopy/mt3d/mtcts.py +++ b/flopy/mt3d/mtcts.py @@ -140,9 +140,7 @@ class Mt3dCts(Package): """ - def __init__( - self, - ): + def __init__(self): raise NotImplementedError() @classmethod diff --git a/flopy/mt3d/mtsft.py b/flopy/mt3d/mtsft.py index 87ba2106d..2bebd4aa8 100644 --- a/flopy/mt3d/mtsft.py +++ b/flopy/mt3d/mtsft.py @@ -382,11 +382,7 @@ def write_file(self): # Item 1 f.write( "{:10d}{:10d}{:10d}{:10d}{:10d}".format( - self.nsfinit, - self.mxsfbc, - self.icbcsf, - self.ioutobs, - self.ietsfr, + self.nsfinit, self.mxsfbc, self.icbcsf, self.ioutobs, self.ietsfr ) + 30 * " " + "# nsfinit, mxsfbc, icbcsf, ioutobs, ietsfr\n" diff --git a/flopy/mt3d/mtssm.py b/flopy/mt3d/mtssm.py index e0af06e1a..d92e40c48 100644 --- a/flopy/mt3d/mtssm.py +++ b/flopy/mt3d/mtssm.py @@ -205,9 +205,8 @@ def __init__( for i, label in enumerate(SsmLabels): mfpack = mf.get_package(label) ssmpack = SsmPackage(label, mfpack, (i < 6)) - self.__SsmPackages.append( - ssmpack - ) # First 6 need T/F flag in file line 1 + # First 6 need T/F flag in file line 1 + self.__SsmPackages.append(ssmpack) if dtype is not None: self.dtype = dtype @@ -218,10 +217,7 @@ def __init__( self.stress_period_data = None else: self.stress_period_data = MfList( - self, - model=model, - data=stress_period_data, - list_free_format=False, + self, model=model, data=stress_period_data, list_free_format=False ) if mxss is None and mf is None: diff --git a/flopy/mt3d/mtuzt.py b/flopy/mt3d/mtuzt.py index 568d0d242..d363c0b1b 100644 --- a/flopy/mt3d/mtuzt.py +++ b/flopy/mt3d/mtuzt.py @@ -516,12 +516,7 @@ def load( for icomp in range(2, ncomp + 1): name = f"cuzet{icomp}" t2d = Transient2d( - model, - (nrow, ncol), - np.float32, - 0.0, - name=name, - locat=0, + model, (nrow, ncol), np.float32, 0.0, name=name, locat=0 ) kwargs[name] = {0: t2d} @@ -535,12 +530,7 @@ def load( for icomp in range(2, ncomp + 1): name = f"cgwet{icomp}" t2d = Transient2d( - model, - (nrow, ncol), - np.float32, - 0.0, - name=name, - locat=0, + model, (nrow, ncol), np.float32, 0.0, name=name, locat=0 ) kwargs[name] = {0: t2d} elif iet == 0: @@ -573,12 +563,7 @@ def load( if model.verbose: print(f" loading {name}...") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nrow, ncol), np.float32, name, ext_unit_dict ) cuzinficomp = kwargs[name] cuzinficomp[iper] = t @@ -613,12 +598,7 @@ def load( if model.verbose: print(f" Reading CUZET array for kper {iper + 1:5d}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "cuzet", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "cuzet", ext_unit_dict ) cuzet[iper] = t @@ -629,12 +609,7 @@ def load( if model.verbose: print(f" loading {name}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nrow, ncol), np.float32, name, ext_unit_dict ) cuzeticomp = kwargs[name] cuzeticomp[iper] = t @@ -667,12 +642,7 @@ def load( if incuzet >= 0: print(f" Reading CGWET array for kper {iper + 1:5d}") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - "cgwet", - ext_unit_dict, + f, model, (nrow, ncol), np.float32, "cgwet", ext_unit_dict ) cgwet[iper] = t @@ -683,12 +653,7 @@ def load( if model.verbose: print(f" loading {name}...") t = Util2d.load( - f, - model, - (nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nrow, ncol), np.float32, name, ext_unit_dict ) cgweticomp = kwargs[name] cgweticomp[iper] = t diff --git a/flopy/pakbase.py b/flopy/pakbase.py index 1f04bf83d..127596c93 100644 --- a/flopy/pakbase.py +++ b/flopy/pakbase.py @@ -259,11 +259,7 @@ def _check_flowp(self, f=None, verbose=True, level=1, checktype=None): for l in range(vka.shape[0]): vka[l] *= hk[l] if self.layvka.array[l] != 0 else 1 self._check_thresholds( - chk, - vka, - active, - chk.property_threshold_values["vka"], - vka_param, + chk, vka, active, chk.property_threshold_values["vka"], vka_param ) for kp, name in kparams.items(): @@ -380,7 +376,7 @@ def _check_storage(self, chk, storage_coeff): [ ( True - if l > 0 or l < 0 and "THICKSTRT" in self.options + if l > 0 or (l < 0 and "THICKSTRT" in self.options) else False ) for l in self.laytyp @@ -743,7 +739,7 @@ def _confined_layer_check(self, chk): if option.lower() == "thickstrt": thickstrt = True for i, l in enumerate(self.laytyp.array.tolist()): - if l == 0 or l < 0 and thickstrt: + if l == 0 or (l < 0 and thickstrt): confined = True continue if confined and l > 0: @@ -1075,12 +1071,7 @@ def load( itmp_cln, aux_names=aux_names, structured=False ) current_cln = ulstrd( - f, - itmp_cln, - current_cln, - model, - sfac_columns, - ext_unit_dict, + f, itmp_cln, current_cln, model, sfac_columns, ext_unit_dict ) current_cln["node"] -= 1 bnd_output_cln = np.recarray.copy(current_cln) @@ -1198,11 +1189,7 @@ def load( filenames=filenames, ) if check: - pak.check( - f=f"{pak.name[0]}.chk", - verbose=pak.parent.verbose, - level=0, - ) + pak.check(f=f"{pak.name[0]}.chk", verbose=pak.parent.verbose, level=0) return pak def set_cbc_output_file(self, ipakcb, model, fname): diff --git a/flopy/pest/templatewriter.py b/flopy/pest/templatewriter.py index a0a6fcf20..7b8e6f19e 100644 --- a/flopy/pest/templatewriter.py +++ b/flopy/pest/templatewriter.py @@ -85,9 +85,8 @@ def write_template(self): # Write the file paktpl.heading = "ptf ~\n" + paktpl.heading paktpl.fn_path += ".tpl" - paktpl.write_file( - check=False - ) # for now, turn off checks for template files + # for now, turn off checks for template files + paktpl.write_file(check=False) # Destroy the template version of the package paktpl = None diff --git a/flopy/plot/__init__.py b/flopy/plot/__init__.py index c5a61d12c..cebcc751c 100644 --- a/flopy/plot/__init__.py +++ b/flopy/plot/__init__.py @@ -23,10 +23,5 @@ from .crosssection import PlotCrossSection from .map import PlotMapView -from .plotutil import ( - PlotUtilities, - SwiConcentration, - plot_shapefile, - shapefile_extents, -) +from .plotutil import PlotUtilities, SwiConcentration, plot_shapefile, shapefile_extents from .styles import styles diff --git a/flopy/plot/crosssection.py b/flopy/plot/crosssection.py index 14d8c3fb9..2480fa647 100644 --- a/flopy/plot/crosssection.py +++ b/flopy/plot/crosssection.py @@ -215,11 +215,7 @@ def __init__( xp = [t[0] for t in pt] yp = [t[1] for t in pt] xp, yp = geometry.transform( - xp, - yp, - self.mg.xoffset, - self.mg.yoffset, - self.mg.angrot_radians, + xp, yp, self.mg.xoffset, self.mg.yoffset, self.mg.angrot_radians ) xypts[nn] = list(zip(xp, yp)) @@ -288,24 +284,11 @@ def __init__( def _is_valid(line): shapely_geo = import_optional_dependency("shapely.geometry") - if isinstance( - line, - ( - list, - tuple, - np.ndarray, - ), - ): + if isinstance(line, (list, tuple, np.ndarray)): a = np.array(line) if (len(a.shape) < 2 or a.shape[0] < 2) or a.shape[1] != 2: return False - elif not isinstance( - line, - ( - geometry.LineString, - shapely_geo.LineString, - ), - ): + elif not isinstance(line, (geometry.LineString, shapely_geo.LineString)): return False return True @@ -589,13 +572,10 @@ def contour_array(self, a, masked_values=None, head=None, **kwargs): xcenters = self.xcenters plotarray = np.array([a[cell] for cell in sorted(self.projpts)]) - ( - plotarray, - xcenters, - zcenters, - mplcontour, - ) = self.mg.cross_section_set_contour_arrays( - plotarray, xcenters, head, self.elev, self.projpts + (plotarray, xcenters, zcenters, mplcontour) = ( + self.mg.cross_section_set_contour_arrays( + plotarray, xcenters, head, self.elev, self.projpts + ) ) if not mplcontour: @@ -771,12 +751,7 @@ def plot_ibound( norm = matplotlib.colors.BoundaryNorm(bounds, cmap.N) # mask active cells patches = self.plot_array( - plotarray, - masked_values=[0], - head=head, - cmap=cmap, - norm=norm, - **kwargs, + plotarray, masked_values=[0], head=head, cmap=cmap, norm=norm, **kwargs ) return patches @@ -908,12 +883,7 @@ def plot_bc(self, name=None, package=None, kper=0, color=None, head=None, **kwar bounds = [0, 1, 2] norm = matplotlib.colors.BoundaryNorm(bounds, cmap.N) patches = self.plot_array( - plotarray, - masked_values=[0], - head=head, - cmap=cmap, - norm=norm, - **kwargs, + plotarray, masked_values=[0], head=head, cmap=cmap, norm=norm, **kwargs ) return patches diff --git a/flopy/plot/map.py b/flopy/plot/map.py index 00e39bde4..f27208eb5 100644 --- a/flopy/plot/map.py +++ b/flopy/plot/map.py @@ -1032,11 +1032,7 @@ def plot_endpoint( # transform data! x0r, y0r = geometry.transform( - tep[xp], - tep[yp], - self.mg.xoffset, - self.mg.yoffset, - self.mg.angrot_radians, + tep[xp], tep[yp], self.mg.xoffset, self.mg.yoffset, self.mg.angrot_radians ) # build array to plot arr = np.vstack((x0r, y0r)).T diff --git a/flopy/plot/plotutil.py b/flopy/plot/plotutil.py index c5f7158a2..7771bc59d 100644 --- a/flopy/plot/plotutil.py +++ b/flopy/plot/plotutil.py @@ -356,10 +356,7 @@ def _plot_package_helper(package, **kwargs): if defaults["key"] is None: names = [ "{} {} location stress period {} layer {}".format( - model_name, - package.name[0], - defaults["kper"] + 1, - k + 1, + model_name, package.name[0], defaults["kper"] + 1, k + 1 ) for k in range(package.parent.modelgrid.nlay) ] @@ -623,11 +620,7 @@ def _plot_mflist_helper( else: names = [ "{}{} {} stress period: {} layer: {}".format( - model_name, - mflist.package.name[0], - key, - kper + 1, - k + 1, + model_name, mflist.package.name[0], key, kper + 1, k + 1 ) for k in range(mflist.model.modelgrid.nlay) ] @@ -1278,11 +1271,7 @@ def _plot_bc_helper( pmv = PlotMapView(ax=axes[idx], model=model, layer=k) fig = plt.figure(num=fignum[idx]) pmv.plot_bc( - ftype=ftype, - package=package, - kper=kper, - ax=axes[idx], - color=color, + ftype=ftype, package=package, kper=kper, ax=axes[idx], color=color ) if defaults["grid"]: @@ -2371,9 +2360,7 @@ def intersect_modpath_with_crosssection( xp, yp, zp = "x0", "y0", "z0" if not isinstance(recarrays, list): - recarrays = [ - recarrays, - ] + recarrays = [recarrays] if projection == "x": v_opp = yvertices diff --git a/flopy/plot/styles.py b/flopy/plot/styles.py index 25ffdc0cf..0b27ce999 100644 --- a/flopy/plot/styles.py +++ b/flopy/plot/styles.py @@ -112,13 +112,7 @@ def heading( return text = ax.text( - x, - y, - text, - va="bottom", - ha="left", - fontdict=font, - transform=ax.transAxes, + x, y, text, va="bottom", ha="left", fontdict=font, transform=ax.transAxes ) return text @@ -308,14 +302,7 @@ def add_text( font = styles.__set_fontspec(bold=bold, italic=italic, fontsize=fontsize) text_obj = ax.text( - x, - y, - text, - va=va, - ha=ha, - fontdict=font, - transform=transform, - **kwargs, + x, y, text, va=va, ha=ha, fontdict=font, transform=transform, **kwargs ) return text_obj diff --git a/flopy/seawat/swt.py b/flopy/seawat/swt.py index 80835e522..f2de3c938 100644 --- a/flopy/seawat/swt.py +++ b/flopy/seawat/swt.py @@ -317,17 +317,13 @@ def write_name_file(self): if self.glo.unit_number[0] > 0: f_nam.write( "{:14s} {:5d} {}\n".format( - self.glo.name[0], - self.glo.unit_number[0], - self.glo.file_name[0], + self.glo.name[0], self.glo.unit_number[0], self.glo.file_name[0] ) ) # Write list file entry f_nam.write( "{:14s} {:5d} {}\n".format( - self.lst.name[0], - self.lst.unit_number[0], - self.lst.file_name[0], + self.lst.name[0], self.lst.unit_number[0], self.lst.file_name[0] ) ) diff --git a/flopy/seawat/swtvdf.py b/flopy/seawat/swtvdf.py index 2ea71dfa1..8b890d110 100644 --- a/flopy/seawat/swtvdf.py +++ b/flopy/seawat/swtvdf.py @@ -472,12 +472,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None): if indense > 0: name = f"DENSE_StressPeriod_{iper}" t = Util3d.load( - f, - model, - (nlay, nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nlay, nrow, ncol), np.float32, name, ext_unit_dict ) if indense == 2: t = t.array diff --git a/flopy/seawat/swtvsc.py b/flopy/seawat/swtvsc.py index 3afe619f8..fc9afc5fa 100644 --- a/flopy/seawat/swtvsc.py +++ b/flopy/seawat/swtvsc.py @@ -430,12 +430,7 @@ def load(cls, f, model, nper=None, ext_unit_dict=None): if invisc > 0: name = f"VISC_StressPeriod_{iper}" t = Util3d.load( - f, - model, - (nlay, nrow, ncol), - np.float32, - name, - ext_unit_dict, + f, model, (nlay, nrow, ncol), np.float32, name, ext_unit_dict ) if invisc == 2: t = t.array diff --git a/flopy/utils/__init__.py b/flopy/utils/__init__.py index 87e0b6e5c..acce927a4 100644 --- a/flopy/utils/__init__.py +++ b/flopy/utils/__init__.py @@ -23,13 +23,7 @@ from .utl_import import import_optional_dependency # isort:skip from . import get_modflow as get_modflow_module -from .binaryfile import ( - BinaryHeader, - CellBudgetFile, - HeadFile, - HeadUFile, - UcnFile, -) +from .binaryfile import BinaryHeader, CellBudgetFile, HeadFile, HeadUFile, UcnFile from .check import check from .flopy_io import read_fixed_var, write_fixed_var from .formattedfile import FormattedHeadFile @@ -53,13 +47,7 @@ from .recarray_utils import create_empty_recarray, ra_slice, recarray from .reference import TemporalReference from .sfroutputfile import SfrFile -from .swroutputfile import ( - SwrBudget, - SwrExchange, - SwrFlow, - SwrStage, - SwrStructure, -) +from .swroutputfile import SwrBudget, SwrExchange, SwrFlow, SwrStage, SwrStructure from .util_array import Transient2d, Transient3d, Util2d, Util3d, read1d from .util_list import MfList from .utils_def import FlopyBinaryData, totim_to_datetime diff --git a/flopy/utils/binaryfile.py b/flopy/utils/binaryfile.py index 10918b369..4aa31260d 100644 --- a/flopy/utils/binaryfile.py +++ b/flopy/utils/binaryfile.py @@ -89,18 +89,7 @@ def write_budget( ndim2 = 1 ndim3 = -1 h = np.array( - ( - kstp, - kper, - text, - ndim1, - ndim2, - ndim3, - imeth, - delt, - pertim, - totim, - ), + (kstp, kper, text, ndim1, ndim2, ndim3, imeth, delt, pertim, totim), dtype=dt, ) h.tofile(fbin) @@ -111,18 +100,7 @@ def write_budget( ndim2 = 1 ndim3 = -1 h = np.array( - ( - kstp, - kper, - text, - ndim1, - ndim2, - ndim3, - imeth, - delt, - pertim, - totim, - ), + (kstp, kper, text, ndim1, ndim2, ndim3, imeth, delt, pertim, totim), dtype=dt, ) h.tofile(fbin) @@ -2324,14 +2302,7 @@ def reverse(self, filename: Optional[os.PathLike] = None): h.tofile(f) if header["imeth"] == 6: # Write additional header information to the backward budget file - h = header[ - [ - "modelnam", - "paknam", - "modelnam2", - "paknam2", - ] - ] + h = header[["modelnam", "paknam", "modelnam2", "paknam2"]] h = np.array(h, dtype=dt2) h.tofile(f) # Load data diff --git a/flopy/utils/check.py b/flopy/utils/check.py index 47443b49d..7d9801a48 100644 --- a/flopy/utils/check.py +++ b/flopy/utils/check.py @@ -232,10 +232,7 @@ def _boolean_compare( # currently failed_info[cols] results in a warning. Not sure # how to do this properly with a recarray. failed_info = recfunctions.append_fields( - failed_info[cols].copy(), - names="diff", - data=diff, - asrecarray=True, + failed_info[cols].copy(), names="diff", data=diff, asrecarray=True ) failed_info.sort(order="diff", axis=0) if not sort_ascending: @@ -322,10 +319,7 @@ def _stress_period_data_inactivecells(self, stress_period_data): if np.any(ibnd == 0): sa = self._list_spd_check_violations( - stress_period_data, - ibnd == 0, - error_name=msg, - error_type="Warning", + stress_period_data, ibnd == 0, error_name=msg, error_type="Warning" ) self.summary_array = np.append(self.summary_array, sa).view(np.recarray) self.remove_passed(f"{msg}s") @@ -670,9 +664,9 @@ def get_neighbors(self, a): tmp[1:-1, 0:-2, 1:-1].ravel(), # i-1 tmp[1:-1, 2:, 1:-1].ravel(), # i+1 tmp[1:-1, 1:-1, :-2].ravel(), # j-1 - tmp[1:-1, 1:-1, 2:].ravel(), + tmp[1:-1, 1:-1, 2:].ravel(), # j+1 ] - ) # j+1 + ) return neighbors.reshape(6, nk, ni, nj) else: if "DISU" in self.model.get_package_list(): diff --git a/flopy/utils/datafile.py b/flopy/utils/datafile.py index f5a52049a..91037258b 100644 --- a/flopy/utils/datafile.py +++ b/flopy/utils/datafile.py @@ -221,9 +221,7 @@ def __init__(self, filename: Union[str, os.PathLike], precision, verbose, **kwar if self.mg is None: self.mg = StructuredGrid( delc=np.ones((self.nrow,)), - delr=np.ones( - self.ncol, - ), + delr=np.ones(self.ncol), nlay=self.nlay, xoff=0.0, yoff=0.0, diff --git a/flopy/utils/geometry.py b/flopy/utils/geometry.py index 0b3d6ec07..3c58bf534 100644 --- a/flopy/utils/geometry.py +++ b/flopy/utils/geometry.py @@ -77,16 +77,10 @@ def __geo_interface__(self): } elif self.__type == "LineString": - geo_interface = { - "coordinates": tuple(self.coords), - "type": self.__type, - } + geo_interface = {"coordinates": tuple(self.coords), "type": self.__type} elif self.__type == "Point": - geo_interface = { - "coordinates": tuple(self.coords), - "type": self.__type, - } + geo_interface = {"coordinates": tuple(self.coords), "type": self.__type} return geo_interface @@ -351,10 +345,7 @@ def __init__(self, exterior, interiors=None): z information is only stored if it was entered. """ super().__init__( - self.type, - coordinates=None, - exterior=exterior, - interiors=interiors, + self.type, coordinates=None, exterior=exterior, interiors=interiors ) def __eq__(self, other): diff --git a/flopy/utils/gridgen.py b/flopy/utils/gridgen.py index 59cfa51ce..badd18155 100644 --- a/flopy/utils/gridgen.py +++ b/flopy/utils/gridgen.py @@ -72,12 +72,7 @@ def features_to_shapefile(features, featuretype, filename: Union[str, os.PathLik features = GeoSpatialCollection(features, featuretype).flopy_geometry - if featuretype.lower() not in [ - "point", - "line", - "linestring", - "polygon", - ]: + if featuretype.lower() not in ["point", "line", "linestring", "polygon"]: raise ValueError(f"Unrecognized feature type: {featuretype}") if featuretype.lower() in ("line", "linestring"): @@ -493,11 +488,7 @@ def build(self, verbose=False): qtgfname = os.path.join(self.model_ws, "quadtreegrid.dfn") if os.path.isfile(qtgfname): os.remove(qtgfname) - cmds = [ - self.exe_name, - "quadtreebuilder", - "_gridgen_build.dfn", - ] + cmds = [self.exe_name, "quadtreebuilder", "_gridgen_build.dfn"] buff = subprocess.check_output(cmds, cwd=self.model_ws) if verbose: print(buff) @@ -580,11 +571,7 @@ def export(self, verbose=False): assert os.path.isfile(fname), f"Could not create export dfn file: {fname}" # Export shapefiles - cmds = [ - self.exe_name, - "grid_to_shapefile_poly", - "_gridgen_export.dfn", - ] + cmds = [self.exe_name, "grid_to_shapefile_poly", "_gridgen_export.dfn"] buff = [] try: buff = subprocess.check_output(cmds, cwd=self.model_ws) @@ -593,16 +580,9 @@ def export(self, verbose=False): fn = os.path.join(self.model_ws, "qtgrid.shp") assert os.path.isfile(fn) except: - print( - "Error. Failed to export polygon shapefile of grid", - buff, - ) + print("Error. Failed to export polygon shapefile of grid", buff) - cmds = [ - self.exe_name, - "grid_to_shapefile_point", - "_gridgen_export.dfn", - ] + cmds = [self.exe_name, "grid_to_shapefile_point", "_gridgen_export.dfn"] buff = [] try: buff = subprocess.check_output(cmds, cwd=self.model_ws) @@ -611,17 +591,10 @@ def export(self, verbose=False): fn = os.path.join(self.model_ws, "qtgrid_pt.shp") assert os.path.isfile(fn) except: - print( - "Error. Failed to export polygon shapefile of grid", - buff, - ) + print("Error. Failed to export polygon shapefile of grid", buff) # Export the usg data - cmds = [ - self.exe_name, - "grid_to_usgdata", - "_gridgen_export.dfn", - ] + cmds = [self.exe_name, "grid_to_usgdata", "_gridgen_export.dfn"] buff = [] try: buff = subprocess.check_output(cmds, cwd=self.model_ws) @@ -644,11 +617,7 @@ def export(self, verbose=False): except: print("Error. Failed to export vtk file", buff) - cmds = [ - self.exe_name, - "grid_to_vtk_sv", - "_gridgen_export.dfn", - ] + cmds = [self.exe_name, "grid_to_vtk_sv", "_gridgen_export.dfn"] buff = [] try: buff = subprocess.check_output(cmds, cwd=self.model_ws) @@ -657,10 +626,7 @@ def export(self, verbose=False): fn = os.path.join(self.model_ws, "qtg_sv.vtu") assert os.path.isfile(fn) except: - print( - "Error. Failed to export shared vertex vtk file", - buff, - ) + print("Error. Failed to export shared vertex vtk file", buff) def plot( self, @@ -1666,11 +1632,7 @@ def intersect(self, features, featuretype, layer): # Load the intersection results as a recarray, convert nodenumber # to zero-based and return result = np.genfromtxt( - fn, - dtype=None, - names=True, - delimiter=",", - usecols=tuple(range(ncol)), + fn, dtype=None, names=True, delimiter=",", usecols=tuple(range(ncol)) ) result = np.atleast_1d(result) result = result.view(np.recarray) diff --git a/flopy/utils/gridintersect.py b/flopy/utils/gridintersect.py index 812a8ce16..a29488448 100644 --- a/flopy/utils/gridintersect.py +++ b/flopy/utils/gridintersect.py @@ -652,9 +652,7 @@ def parse_polygons_in_geom_collection(gc): mask_gc = geomtype_ids[~mask_empty & mask_type] == 7 ixresult[mask_gc] = np.apply_along_axis( - parse_polygons_in_geom_collection, - axis=0, - arr=ixresult[mask_gc], + parse_polygons_in_geom_collection, axis=0, arr=ixresult[mask_gc] ) # check centroids @@ -959,9 +957,7 @@ def _intersect_linestring_structured( ix, self.mfgrid.angrot, origin=(0.0, 0.0) ) ix_realworld = affinity_loc.translate( - ix_realworld, - self.mfgrid.xoffset, - self.mfgrid.yoffset, + ix_realworld, self.mfgrid.xoffset, self.mfgrid.yoffset ) ixs_realworld.append(ix_realworld) else: @@ -970,13 +966,10 @@ def _intersect_linestring_structured( vertices += v_realworld ixshapes += ixs_realworld else: # linestring is fully within grid - ( - nodelist, - lengths, - vertices, - ixshapes, - ) = self._get_nodes_intersecting_linestring( - lineclip, return_all_intersections=return_all_intersections + (nodelist, lengths, vertices, ixshapes) = ( + self._get_nodes_intersecting_linestring( + lineclip, return_all_intersections=return_all_intersections + ) ) # if necessary, transform coordinates back to real # world coordinates @@ -1149,13 +1142,10 @@ def _get_nodes_intersecting_linestring( n = 0 while True: (i, j) = nodelist[n] - ( - node, - length, - verts, - ixshape, - ) = self._check_adjacent_cells_intersecting_line( - linestring, (i, j), nodelist + (node, length, verts, ixshape) = ( + self._check_adjacent_cells_intersecting_line( + linestring, (i, j), nodelist + ) ) for inode, ilength, ivert, ix in zip(node, length, verts, ixshape): @@ -1504,10 +1494,7 @@ def _intersect_polygon_structured( cell_coords = [ (self.mfgrid.xyedges[0][j], self.mfgrid.xyedges[1][i]), (self.mfgrid.xyedges[0][j + 1], self.mfgrid.xyedges[1][i]), - ( - self.mfgrid.xyedges[0][j + 1], - self.mfgrid.xyedges[1][i + 1], - ), + (self.mfgrid.xyedges[0][j + 1], self.mfgrid.xyedges[1][i + 1]), (self.mfgrid.xyedges[0][j], self.mfgrid.xyedges[1][i + 1]), ] else: @@ -1559,9 +1546,7 @@ def _intersect_polygon_structured( intersect, self.mfgrid.angrot, origin=(0.0, 0.0) ) intersect_realworld = affinity_loc.translate( - intersect_realworld, - self.mfgrid.xoffset, - self.mfgrid.yoffset, + intersect_realworld, self.mfgrid.xoffset, self.mfgrid.yoffset ) else: v_realworld = intersect.__geo_interface__["coordinates"] diff --git a/flopy/utils/lgrutil.py b/flopy/utils/lgrutil.py index b2edf951d..b40736eae 100644 --- a/flopy/utils/lgrutil.py +++ b/flopy/utils/lgrutil.py @@ -262,12 +262,7 @@ def get_top_botm(self): dz = (top - bot) / self.ncppl[kp] for _ in range(self.ncppl[kp]): botm[kc, icrowstart:icrowend, iccolstart:iccolend] = ( - botm[ - kc - 1, - icrowstart:icrowend, - iccolstart:iccolend, - ] - - dz + botm[kc - 1, icrowstart:icrowend, iccolstart:iccolend] - dz ) kc += 1 return botm[0], botm[1:] @@ -508,14 +503,7 @@ def get_exchange_data(self, angldegx=False, cdist=False): y2 = float(yp[ip, jp]) cd = np.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) - exg = [ - (kp, ip, jp), - (kc, ic, jc), - ihc, - cl1, - cl2, - hwva, - ] + exg = [(kp, ip, jp), (kc, ic, jc), ihc, cl1, cl2, hwva] if angldegx: exg.append(float(angle)) if cdist: @@ -570,16 +558,7 @@ def child(self): xorigin = self.xll yorigin = self.yll simple_regular_grid = SimpleRegularGrid( - nlayc, - nrowc, - ncolc, - delrc, - delcc, - topc, - botmc, - idomainc, - xorigin, - yorigin, + nlayc, nrowc, ncolc, delrc, delcc, topc, botmc, idomainc, xorigin, yorigin ) return simple_regular_grid diff --git a/flopy/utils/mflistfile.py b/flopy/utils/mflistfile.py index add18381e..f15fee32c 100644 --- a/flopy/utils/mflistfile.py +++ b/flopy/utils/mflistfile.py @@ -488,9 +488,7 @@ def get_dataframes(self, start_datetime="1-1-1970", diff=False): if start_datetime is not None: try: totim = totim_to_datetime( - totim, - start=pd.to_datetime(start_datetime), - timeunit=self.timeunit, + totim, start=pd.to_datetime(start_datetime), timeunit=self.timeunit ) except: pass # if totim can't be cast to pd.datetime return in native units @@ -633,10 +631,7 @@ def _get_index(self, maxentries): ts, sp = get_ts_sp(line) except: print( - "unable to cast ts,sp on line number", - l_count, - " line: ", - line, + "unable to cast ts,sp on line number", l_count, " line: ", line ) break @@ -787,20 +782,12 @@ def _get_sp(self, ts, sp, seekpoint): return self.null_entries if flux is None: print( - "error casting in flux for", - entry, - " to float in ts,sp", - ts, - sp, + "error casting in flux for", entry, " to float in ts,sp", ts, sp ) return self.null_entries if cumu is None: print( - "error casting in cumu for", - entry, - " to float in ts,sp", - ts, - sp, + "error casting in cumu for", entry, " to float in ts,sp", ts, sp ) return self.null_entries if entry.endswith(tag.upper()): diff --git a/flopy/utils/modpathfile.py b/flopy/utils/modpathfile.py index efc5772e1..6fbb930d2 100644 --- a/flopy/utils/modpathfile.py +++ b/flopy/utils/modpathfile.py @@ -20,13 +20,9 @@ class ModpathFile(ParticleTrackFile): def __init__(self, filename: Union[str, os.PathLike], verbose: bool = False): super().__init__(filename, verbose) self.output_type = self.__class__.__name__.lower().replace("file", "") - ( - self.modpath, - self.compact, - self.skiprows, - self.version, - self.direction, - ) = self.parse(filename, self.output_type) + (self.modpath, self.compact, self.skiprows, self.version, self.direction) = ( + self.parse(filename, self.output_type) + ) @staticmethod def parse( @@ -271,13 +267,7 @@ def _load(self) -> tuple[np.dtype, np.ndarray]: nrows += pathlinecount # read in the particle data d = np.loadtxt(itertools.islice(f, 0, pathlinecount), dtype=dtyper) - key = ( - idx, - sequencenumber, - group, - particleid, - pathlinecount, - ) + key = (idx, sequencenumber, group, particleid, pathlinecount) particle_pathlines[key] = d.copy() idx += 1 diff --git a/flopy/utils/parse_version.py b/flopy/utils/parse_version.py index dfa7c37e5..da85abc1e 100644 --- a/flopy/utils/parse_version.py +++ b/flopy/utils/parse_version.py @@ -16,11 +16,11 @@ from typing import Callable, SupportsInt, Union __all__ = [ - "parse", - "Version", - "LegacyVersion", - "InvalidVersion", "VERSION_PATTERN", + "InvalidVersion", + "LegacyVersion", + "Version", + "parse", ] @@ -349,8 +349,7 @@ def __init__(self, version: str) -> None: release=tuple(int(i) for i in match.group("release").split(".")), pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")), post=_parse_letter_version( - match.group("post_l"), - match.group("post_n1") or match.group("post_n2"), + match.group("post_l"), match.group("post_n1") or match.group("post_n2") ), dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")), local=_parse_local_version(match.group("local")), diff --git a/flopy/utils/postprocessing.py b/flopy/utils/postprocessing.py index 922455bbb..3e7728357 100644 --- a/flopy/utils/postprocessing.py +++ b/flopy/utils/postprocessing.py @@ -586,16 +586,13 @@ def get_specific_discharge( if vectors[ix].shape == modelgrid.shape: tqx = np.zeros( - (modelgrid.nlay, modelgrid.nrow, modelgrid.ncol + 1), - dtype=np.float32, + (modelgrid.nlay, modelgrid.nrow, modelgrid.ncol + 1), dtype=np.float32 ) tqy = np.zeros( - (modelgrid.nlay, modelgrid.nrow + 1, modelgrid.ncol), - dtype=np.float32, + (modelgrid.nlay, modelgrid.nrow + 1, modelgrid.ncol), dtype=np.float32 ) tqz = np.zeros( - (modelgrid.nlay + 1, modelgrid.nrow, modelgrid.ncol), - dtype=np.float32, + (modelgrid.nlay + 1, modelgrid.nrow, modelgrid.ncol), dtype=np.float32 ) if vectors[0] is not None: tqx[:, :, 1:] = vectors[0] diff --git a/flopy/utils/rasters.py b/flopy/utils/rasters.py index 4d7bedf54..ee7da72b7 100644 --- a/flopy/utils/rasters.py +++ b/flopy/utils/rasters.py @@ -253,11 +253,7 @@ def __transform(self, dst_crs, inplace): """ import rasterio from rasterio.io import MemoryFile - from rasterio.warp import ( - Resampling, - calculate_default_transform, - reproject, - ) + from rasterio.warp import Resampling, calculate_default_transform, reproject height = self._meta["height"] width = self._meta["width"] @@ -536,12 +532,7 @@ def resample_to_grid( arr = arr.flatten() # step 3: use griddata interpolation to snap to grid - data = griddata( - (rxc, ryc), - arr, - (xc, yc), - method=method, - ) + data = griddata((rxc, ryc), arr, (xc, yc), method=method) elif method in ("median", "mean", "min", "max", "mode"): # these methods are slow and could use speed ups @@ -589,12 +580,7 @@ def resample_to_grid( ryc = ryc[idx] arr = arr[idx] - extrapolate = griddata( - (rxc, ryc), - arr, - (xc, yc), - method="nearest", - ) + extrapolate = griddata((rxc, ryc), arr, (xc, yc), method="nearest") data = np.where(np.isnan(data), extrapolate, data) # step 4: return grid to user in shape provided @@ -696,12 +682,7 @@ def crop(self, polygon, invert=False): self._meta["width"] = crp_mask.shape[1] transform = self._meta["transform"] self._meta["transform"] = self._affine.Affine( - transform[0], - transform[1], - xmin, - transform[3], - transform[4], - ymax, + transform[0], transform[1], xmin, transform[3], transform[4], ymax ) self.__xcenters = None self.__ycenters = None @@ -1011,12 +992,7 @@ def plot(self, ax=None, contour=False, **kwargs): from rasterio.plot import show if self._dataset is not None: - ax = show( - self._dataset, - ax=ax, - contour=contour, - **kwargs, - ) + ax = show(self._dataset, ax=ax, contour=contour, **kwargs) else: d0 = len(self.__arr_dict) diff --git a/flopy/utils/triangle.py b/flopy/utils/triangle.py index 822999b55..aa93bbd82 100644 --- a/flopy/utils/triangle.py +++ b/flopy/utils/triangle.py @@ -255,11 +255,7 @@ def plot( pc = pmv.plot_grid(facecolor=facecolor, edgecolor=edgecolor, **kwargs) else: pc = pmv.plot_array( - a, - masked_values=masked_values, - cmap=cmap, - edgecolor=edgecolor, - **kwargs, + a, masked_values=masked_values, cmap=cmap, edgecolor=edgecolor, **kwargs ) return pc diff --git a/flopy/utils/util_array.py b/flopy/utils/util_array.py index 35312a834..41c0e4410 100644 --- a/flopy/utils/util_array.py +++ b/flopy/utils/util_array.py @@ -581,8 +581,7 @@ def __init__( for k in range(shape[0]): self.ext_filename_base.append( os.path.join( - model.external_path, - self.name_base[k].replace(" ", "_"), + model.external_path, self.name_base[k].replace(" ", "_") ) ) else: @@ -606,9 +605,7 @@ def __setattr__(self, key, value): elif hasattr(self, "util_2ds") and key == "fmtin": for u2d in self.util_2ds: u2d.format = ArrayFormat( - u2d, - fortran=value, - array_free_format=self.array_free_format, + u2d, fortran=value, array_free_format=self.array_free_format ) super().__setattr__("fmtin", value) elif hasattr(self, "util_2ds") and key == "how": @@ -1555,8 +1552,7 @@ def __setitem__(self, key, value): @property def array(self): arr = np.zeros( - (self._model.nper, 1, self.shape[0], self.shape[1]), - dtype=self._dtype, + (self._model.nper, 1, self.shape[0], self.shape[1]), dtype=self._dtype ) for kper in range(self._model.nper): u2d = self[kper] @@ -1843,12 +1839,7 @@ def __init__( self.ext_filename = ext_filename self._ext_filename = self._name.replace(" ", "_") + ".ref" - self._acceptable_hows = [ - "constant", - "internal", - "external", - "openclose", - ] + self._acceptable_hows = ["constant", "internal", "external", "openclose"] if how is not None: how = how.lower() @@ -1978,9 +1969,7 @@ def export(self, f, **kwargs): def set_fmtin(self, fmtin): self._format = ArrayFormat( - self, - fortran=fmtin, - array_free_format=self.format.array_free_format, + self, fortran=fmtin, array_free_format=self.format.array_free_format ) def get_value(self): @@ -2220,11 +2209,7 @@ def get_external_cr(self): self._model.add_external(self.model_file_path, locat, self.format.binary) if self.format.array_free_format: cr = "EXTERNAL {:>30d} {:15} {:>10s} {:2.0f} {:<30s}\n".format( - locat, - self.cnstnt_str, - self.format.fortran, - self.iprn, - self._name, + locat, self.cnstnt_str, self.format.fortran, self.iprn, self._name ) return cr else: @@ -2279,10 +2264,7 @@ def get_file_entry(self, how=None): if self.vtype != str: if self.format.binary: self.write_bin( - self.shape, - self.python_file_path, - self._array, - bintype="head", + self.shape, self.python_file_path, self._array, bintype="head" ) else: self.write_txt( @@ -2548,10 +2530,7 @@ def write_txt(shape, file_out, data, fortran_format="(FREE)", python_format=None file_out = open(file_out, "w") file_out.write( Util2d.array2string( - shape, - data, - fortran_format=fortran_format, - python_format=python_format, + shape, data, fortran_format=fortran_format, python_format=python_format ) ) @@ -2572,22 +2551,16 @@ def array2string(shape, data, fortran_format="(FREE)", python_format=None): ncol = shape[0] data = np.atleast_2d(data) if python_format is None: - ( - column_length, - fmt, - width, - decimal, - ) = ArrayFormat.decode_fortran_descriptor(fortran_format) + (column_length, fmt, width, decimal) = ( + ArrayFormat.decode_fortran_descriptor(fortran_format) + ) if decimal is None: output_fmt = f"{{0:{width}d}}" else: output_fmt = f"{{0:{width}.{decimal}{fmt}}}" else: try: - column_length, output_fmt = ( - int(python_format[0]), - python_format[1], - ) + column_length, output_fmt = (int(python_format[0]), python_format[1]) except: raise Exception( "Util2d.write_txt: \nunable to parse " diff --git a/flopy/utils/util_list.py b/flopy/utils/util_list.py index 60c223a3e..8593e5e79 100644 --- a/flopy/utils/util_list.py +++ b/flopy/utils/util_list.py @@ -482,14 +482,7 @@ def get_dataframe(self, squeeze=False): df = df.reset_index() df.loc[:, "node"] = df.loc[:, "i"] * self._model.ncol + df.loc[:, "j"] - df = df.loc[ - :, - names - + [ - "node", - ] - + [v for v in varnames if not v == "node"], - ] + df = df.loc[:, names + ["node"] + [v for v in varnames if not v == "node"]] return df def add_record(self, kper, index, values): @@ -1040,8 +1033,7 @@ def to_array(self, kper=0, mask=False): cnt = np.zeros((self._model.nlay * self._model.ncpl,), dtype=float) else: cnt = np.zeros( - (self._model.nlay, self._model.nrow, self._model.ncol), - dtype=float, + (self._model.nlay, self._model.nrow, self._model.ncol), dtype=float ) for rec in sarr: if unstructured: diff --git a/flopy/utils/zonbud.py b/flopy/utils/zonbud.py index 733f05e23..871046594 100644 --- a/flopy/utils/zonbud.py +++ b/flopy/utils/zonbud.py @@ -255,10 +255,7 @@ def _compute_budget(self, kstpkper=None, totim=None): C-----FLOW. STORE CONSTANT-HEAD LOCATIONS IN ICH ARRAY. """ chd = self.cbc.get_data( - text="CONSTANT HEAD", - full3D=True, - kstpkper=kstpkper, - totim=totim, + text="CONSTANT HEAD", full3D=True, kstpkper=kstpkper, totim=totim )[0] ich[np.ma.where(chd != 0.0)] = 1 if "FLOW RIGHT FACE" in self.record_names: @@ -366,10 +363,7 @@ def _initialize_budget_recordarray(self, kstpkper=None, totim=None): for recname in self.ssst_record_names: if recname != "STORAGE": recordarray = self._add_empty_record( - recordarray, - "FROM_" + "_".join(recname.split()), - kstpkper, - totim, + recordarray, "FROM_" + "_".join(recname.split()), kstpkper, totim ) for z, n in self._zonenamedict.items(): @@ -393,10 +387,7 @@ def _initialize_budget_recordarray(self, kstpkper=None, totim=None): for recname in self.ssst_record_names: if recname != "STORAGE": recordarray = self._add_empty_record( - recordarray, - "TO_" + "_".join(recname.split()), - kstpkper, - totim, + recordarray, "TO_" + "_".join(recname.split()), kstpkper, totim ) for z, n in self._zonenamedict.items(): @@ -2274,9 +2265,7 @@ def _recarray_to_dataframe( df = pd.DataFrame().from_records(recarray) if start_datetime is not None and "totim" in list(df): totim = totim_to_datetime( - df.totim, - start=pd.to_datetime(start_datetime), - timeunit=timeunit, + df.totim, start=pd.to_datetime(start_datetime), timeunit=timeunit ) df["datetime"] = totim if pivot: @@ -2976,13 +2965,7 @@ def dataframe_to_netcdf_fmt(df, zone_array, flux=True): data[col] = np.zeros((totim.size, zones.size), dtype=float) for i, time in enumerate(totim): - tdf = df.loc[ - df.totim.isin( - [ - time, - ] - ) - ] + tdf = df.loc[df.totim.isin([time])] tdf = tdf.sort_values(by=["zone"]) for col in df.columns: diff --git a/scripts/process_benchmarks.py b/scripts/process_benchmarks.py index 89cc76b3a..c78175333 100644 --- a/scripts/process_benchmarks.py +++ b/scripts/process_benchmarks.py @@ -34,10 +34,7 @@ def get_benchmarks(paths): for benchmark in bmarks: num_benchmarks += 1 fullname = benchmark["fullname"] - included = [ - "min", - "mean", - ] + included = ["min", "mean"] for stat, value in benchmark["stats"].items(): if stat not in included: continue @@ -90,12 +87,7 @@ def matplotlib_plot(stats): psub = ssub[ssub["python"] == python] color = colors[python] ax.scatter(psub["time"], psub["value"], color=color, marker=marker) - ax.plot( - psub["time"], - psub["value"], - linestyle="dotted", - color=color, - ) + ax.plot(psub["time"], psub["value"], linestyle="dotted", color=color) # configure legend patches = [] diff --git a/scripts/update_version.py b/scripts/update_version.py index ba3e73ebe..c30164efa 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -146,11 +146,7 @@ def update_citation_cff(timestamp: datetime, version: Version): # write CITATION.cff with open(fpth, "w") as f: yaml.safe_dump( - citation, - f, - allow_unicode=True, - default_flow_style=False, - sort_keys=False, + citation, f, allow_unicode=True, default_flow_style=False, sort_keys=False ) print(f"Updated {fpth} to version {version}")