Skip to content

Commit f428803

Browse files
mjrenomjreno
authored andcommitted
misc cleanup
1 parent df36c20 commit f428803

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

docs/examples/array_example.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
constant = data_path / "constant.txt"
6363
external = data_path / "external.txt"
6464
shape = (1000, 100)
65-
type = "double"
65+
dtype = "double"
6666

6767
# Open and load a NumPy array representation
6868

6969
fhandle = open(internal)
70-
imfa = MFArray.load(fhandle, data_path, shape, type=type, header=False)
70+
imfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False)
7171

7272
# Get values
7373

@@ -88,7 +88,7 @@
8888
plt.colorbar()
8989

9090
fhandle = open(constant)
91-
cmfa = MFArray.load(fhandle, data_path, shape, type=type, header=False)
91+
cmfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False)
9292
cvals = cmfa.value
9393
plt.imshow(cvals[0:100])
9494
plt.colorbar()
@@ -111,7 +111,7 @@
111111
# External
112112

113113
fhandle = open(external)
114-
emfa = MFArray.load(fhandle, data_path, shape, type=type, header=False)
114+
emfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False)
115115
evals = emfa.value
116116
evals
117117

@@ -137,7 +137,7 @@
137137
fhandle = open(ilayered)
138138
shape = (3, 1000, 100)
139139
ilmfa = MFArray.load(
140-
fhandle, data_path, shape, type=type, header=False, layered=True
140+
fhandle, data_path, shape, type=dtype, header=False, layered=True
141141
)
142142
vals = ilmfa.value
143143

@@ -186,7 +186,7 @@
186186
fhandle = open(clayered)
187187
shape = (3, 1000, 100)
188188
clmfa = MFArray.load(
189-
fhandle, data_path, shape, type=type, header=False, layered=True
189+
fhandle, data_path, shape, type=dtype, header=False, layered=True
190190
)
191191

192192
clmfa._value
@@ -241,7 +241,7 @@
241241
fhandle = open(mlayered)
242242
shape = (3, 1000, 100)
243243
mlmfa = MFArray.load(
244-
fhandle, data_path, shape, type=type, header=False, layered=True
244+
fhandle, data_path, shape, type=dtype, header=False, layered=True
245245
)
246246

247247
mlmfa.how

flopy4/compound.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ def load(cls, f, **kwargs) -> "MFList":
368368
jidx = len(param_cols) - 1
369369
else:
370370
raise ValueError(
371-
"MFList param {params[k].name} has "
372-
"unsupported shape {params[k].shape}"
371+
f"MFList param {params[k].name} has "
372+
f"unsupported shape {params[k].shape}"
373373
)
374374
param_cols.append(pcols)
375375
param_types.append(params[k].type)
@@ -379,6 +379,7 @@ def load(cls, f, **kwargs) -> "MFList":
379379
maxsplit = sum(param_cols) - 1
380380
else:
381381
maxsplit = -1
382+
assert not (jidx >= 0 and maxsplit >= 0)
382383

383384
while True:
384385
pos = f.tell()
-2.37 KB
Binary file not shown.

test/test_sim.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def test_load_sim(tmp_path):
183183
assert s.tdis.params["start_date_time"] == "2041-01-01t00:00:00-05:00"
184184
assert s.tdis.params["nper"] == 31
185185
assert np.allclose(
186-
s.tdis.params["perioddata"]["perlen"],
186+
[float(f) for f in s.tdis.params["perioddata"]["perlen"]],
187187
np.array(
188188
[
189189
1.0,
@@ -259,7 +259,7 @@ def test_load_sim(tmp_path):
259259
),
260260
)
261261
assert np.allclose(
262-
s.tdis.params["perioddata"]["tsmult"],
262+
[float(f) for f in s.tdis.params["perioddata"]["tsmult"]],
263263
np.array(
264264
[
265265
1.0,
@@ -310,11 +310,11 @@ def test_load_sim(tmp_path):
310310
assert "scaling_method" in s.solvers["ims_0"].params
311311
assert "reordering_method" in s.solvers["ims_0"].params
312312
assert s.solvers["ims_0"].params["print_option"] == "summary"
313-
assert s.solvers["ims_0"].params["outer_dvclose"] == 1.00000000e-09
313+
assert float(s.solvers["ims_0"].params["outer_dvclose"]) == 1.00000000e-09
314314
assert s.solvers["ims_0"].params["outer_maximum"] == 500
315315
assert s.solvers["ims_0"].params["under_relaxation"] == "none"
316316
assert s.solvers["ims_0"].params["inner_maximum"] == 300
317-
assert s.solvers["ims_0"].params["inner_dvclose"] == 1.00000000e-09
317+
assert float(s.solvers["ims_0"].params["inner_dvclose"]) == 1.00000000e-09
318318
assert s.solvers["ims_0"].params["linear_acceleration"] == "bicgstab"
319319
assert s.solvers["ims_0"].params["relaxation_factor"] == 1.00000000
320320
assert s.solvers["ims_0"].params["scaling_method"] == "none"
@@ -358,15 +358,15 @@ def test_gwf_chd01(tmp_path):
358358
if w.returncode == 0:
359359
os.chdir(tmp_path / "gwf_chd01")
360360
subprocess.run(["mf6"])
361-
os.chdir(tmp_path / "write")
361+
os.chdir(write_dir)
362362
subprocess.run(["mf6"])
363363
diff = subprocess.run(
364364
["diff", f"./{name}.lst", f"../gwf_chd01/{name}.lst"]
365365
)
366-
if diff.stdout:
367-
print(f"\nGWF model list file difference: {diff.stdout}")
368366
if diff.stderr:
369367
print(diff.stderr)
368+
else:
369+
print(f"\nmodel lst file diffs: {diff.stdout}")
370370

371371

372372
def test_gwf_disv(tmp_path):
@@ -388,15 +388,15 @@ def test_gwf_disv(tmp_path):
388388
if w.returncode == 0:
389389
os.chdir(tmp_path / "disv01a")
390390
subprocess.run(["mf6"])
391-
os.chdir(tmp_path / "write")
391+
os.chdir(write_dir)
392392
subprocess.run(["mf6"])
393393
diff = subprocess.run(
394394
["diff", f"./{name}.lst", f"../disv01a/{name}.lst"]
395395
)
396-
if diff.stdout:
397-
print(f"\nGWF model list file difference: {diff.stdout}")
398396
if diff.stderr:
399397
print(diff.stderr)
398+
else:
399+
print(f"\nmodel lst file diffs: {diff.stdout}")
400400

401401

402402
def test_gwf_disu(tmp_path):
@@ -418,12 +418,12 @@ def test_gwf_disu(tmp_path):
418418
if w.returncode == 0:
419419
os.chdir(tmp_path / "disu01a")
420420
subprocess.run(["mf6"])
421-
os.chdir(tmp_path / "write")
421+
os.chdir(write_dir)
422422
subprocess.run(["mf6"])
423423
diff = subprocess.run(
424424
["diff", f"./{name}.lst", f"../disu01a/{name}.lst"]
425425
)
426-
if diff.stdout:
427-
print(f"\nGWF model list file difference: {diff.stdout}")
428426
if diff.stderr:
429427
print(diff.stderr)
428+
else:
429+
print(f"\nmodel lst file diffs: {diff.stdout}")

0 commit comments

Comments
 (0)