Skip to content

Commit 830426f

Browse files
committed
rework dfn -> toml conversion
TOML conversion as per group discussions and as prototyped in flopy3 in the Jinja PR. This is a nested structure where components have blocks, which have variables, which may be composites of other variables. Add the latest DFNs as well as the converted TOML files. The structure is still tentative and may evolve.
1 parent d1ac9ee commit 830426f

File tree

275 files changed

+44299
-8159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+44299
-8159
lines changed

docs/examples/array_example.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@
136136

137137
fhandle = open(ilayered)
138138
shape = (3, 1000, 100)
139-
ilmfa = MFArray.load(
140-
fhandle, data_path, shape, type=dtype, header=False, layered=True
141-
)
139+
ilmfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False, layered=True)
142140
vals = ilmfa.value
143141

144142
ilmfa._value # internal storage
@@ -185,9 +183,7 @@
185183

186184
fhandle = open(clayered)
187185
shape = (3, 1000, 100)
188-
clmfa = MFArray.load(
189-
fhandle, data_path, shape, type=dtype, header=False, layered=True
190-
)
186+
clmfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False, layered=True)
191187

192188
clmfa._value
193189

@@ -240,9 +236,7 @@
240236

241237
fhandle = open(mlayered)
242238
shape = (3, 1000, 100)
243-
mlmfa = MFArray.load(
244-
fhandle, data_path, shape, type=dtype, header=False, layered=True
245-
)
239+
mlmfa = MFArray.load(fhandle, data_path, shape, type=dtype, header=False, layered=True)
246240

247241
mlmfa.how
248242

docs/examples/attrs_demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,4 @@ def output_control_data_hook(value, _) -> OutputControlData:
241241
assert gwfoc.options.printhead.format == "scientific"
242242
period = gwfoc.periods[0]
243243
assert len(period) == 2
244-
assert period[0] == OutputControlData.from_tuple(
245-
("print", "budget", "steps", 1, 3, 5)
246-
)
244+
assert period[0] == OutputControlData.from_tuple(("print", "budget", "steps", 1, 3, 5))

flopy4/array.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
257257
if len(inputs) == 1:
258258
result = raw.__array_ufunc__(ufunc, method, raw, **kwargs)
259259
else:
260-
result = raw.__array_ufunc__(
261-
ufunc, method, raw, *inputs[1:], kwargs
262-
)
260+
result = raw.__array_ufunc__(ufunc, method, raw, *inputs[1:], kwargs)
263261
if not isinstance(result, np.ndarray):
264262
raise NotImplementedError(f"{str(ufunc)} has not been implemented")
265263

@@ -299,8 +297,7 @@ def value(self, value: Optional[np.ndarray]):
299297

300298
if value.shape != self.shape:
301299
raise ValueError(
302-
f"Expected array with shape {self.shape},"
303-
f"got shape {value.shape}"
300+
f"Expected array with shape {self.shape}," f"got shape {value.shape}"
304301
)
305302
self._value = value
306303

@@ -407,8 +404,7 @@ def write(self, f, **kwargs):
407404
elif self._how == MFArrayType.external:
408405
lines = (
409406
f"{PAD}" + f"{self.name.upper()}\n"
410-
f"{PAD*2}"
411-
+ f"{MFArrayType.to_string(self._how)} {self._path}\n"
407+
f"{PAD*2}" + f"{MFArrayType.to_string(self._how)} {self._path}\n"
412408
)
413409
elif self._how == MFArrayType.constant:
414410
lines = (

flopy4/block.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def __new__(cls, clsname, bases, attrs):
7979

8080
# infer block name
8181
block_name = (
82-
clsname[list(find_upper(clsname))[1] :]
83-
.replace("Block", "")
84-
.lower()
82+
clsname[list(find_upper(clsname))[1] :].replace("Block", "").lower()
8583
)
8684

8785
# collect parameters
@@ -314,9 +312,7 @@ def __repr__(self):
314312
def __eq__(self, other):
315313
if not isinstance(other, MFBlocks):
316314
raise TypeError(f"Expected MFBlocks, got {type(other)}")
317-
return OrderedDict(sorted(self.value)) == OrderedDict(
318-
sorted(other.value)
319-
)
315+
return OrderedDict(sorted(self.value)) == OrderedDict(sorted(other.value))
320316

321317
@staticmethod
322318
def assert_blocks(blocks):
@@ -329,9 +325,7 @@ def assert_blocks(blocks):
329325
elif isinstance(blocks, dict):
330326
blocks = blocks.values()
331327
not_blocks = [
332-
b
333-
for b in blocks
334-
if b is not None and not issubclass(type(b), MFBlock)
328+
b for b in blocks if b is not None and not issubclass(type(b), MFBlock)
335329
]
336330
if any(not_blocks):
337331
raise TypeError(f"Expected MFBlock subclasses, got {not_blocks}")

flopy4/compound.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def params(self) -> MFParams:
7979
@property
8080
def value(self) -> Dict[str, Any]:
8181
"""Get component names/values."""
82-
return {
83-
k: s.value for k, s in self.data.items() if s.value is not None
84-
}
82+
return {k: s.value for k, s in self.data.items() if s.value is not None}
8583

8684
@value.setter
8785
def value(self, value: Optional[Dict[str, Any]]):

0 commit comments

Comments
 (0)