From d588e1f283bb16da4ddce5bdfacc4893763390bc Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Fri, 7 Nov 2025 14:08:31 -0500 Subject: [PATCH] various * trial an approach for records containing keywords, including converter * dicts should map to record field type, not list * add minimal npf writing test --- flopy4/mf6/codec/filters.py | 4 ++-- flopy4/mf6/converter/__init__.py | 3 ++- flopy4/mf6/converter/structure.py | 4 ++++ flopy4/mf6/gwf/npf.py | 13 +++++++++---- pixi.lock | 32 +++++++++++++++---------------- test/test_mf6_codec.py | 16 ++++++++++++++++ 6 files changed, 49 insertions(+), 23 deletions(-) diff --git a/flopy4/mf6/codec/filters.py b/flopy4/mf6/codec/filters.py index 7c93dd94..fa7efddc 100644 --- a/flopy4/mf6/codec/filters.py +++ b/flopy4/mf6/codec/filters.py @@ -20,12 +20,12 @@ def field_type(value: Any) -> FieldType: return "double" if isinstance(value, str): return "string" - if isinstance(value, tuple): + if isinstance(value, (dict, tuple)): return "record" if isinstance(value, xr.DataArray): if value.dtype == "object": return "list" return "array" - if isinstance(value, (list, dict, xr.Dataset)): + if isinstance(value, (list, xr.Dataset)): return "list" raise ValueError(f"Unsupported field type: {type(value)}") diff --git a/flopy4/mf6/converter/__init__.py b/flopy4/mf6/converter/__init__.py index 7ee74a2b..c6f2bf65 100644 --- a/flopy4/mf6/converter/__init__.py +++ b/flopy4/mf6/converter/__init__.py @@ -8,7 +8,7 @@ from flopy4.mf6.component import Component from flopy4.mf6.context import Context -from flopy4.mf6.converter.structure import structure_array +from flopy4.mf6.converter.structure import structure_array, structure_keyword from flopy4.mf6.converter.unstructure import ( unstructure_component, ) @@ -19,6 +19,7 @@ "unstructure", "structure_array", "unstructure_array", + "structure_keyword", "COMPONENT_CONVERTER", ] diff --git a/flopy4/mf6/converter/structure.py b/flopy4/mf6/converter/structure.py index 2a5cbc93..68820f22 100644 --- a/flopy4/mf6/converter/structure.py +++ b/flopy4/mf6/converter/structure.py @@ -10,6 +10,10 @@ from flopy4.mf6.constants import FILL_DNODATA +def structure_keyword(value, field) -> str | None: + return field.name if value else None + + def structure_array(value, self_, field) -> NDArray: """ Convert a sparse dictionary representation of an array to a diff --git a/flopy4/mf6/gwf/npf.py b/flopy4/mf6/gwf/npf.py index a92d6981..f554f13a 100644 --- a/flopy4/mf6/gwf/npf.py +++ b/flopy4/mf6/gwf/npf.py @@ -1,12 +1,13 @@ from pathlib import Path -from typing import Optional +from typing import Literal, Optional +import attrs import numpy as np from attrs import Converter, define from numpy.typing import NDArray from xattree import xattree -from flopy4.mf6.converter import structure_array +from flopy4.mf6.converter import structure_array, structure_keyword from flopy4.mf6.package import Package from flopy4.mf6.spec import array, field, path from flopy4.utils import to_path @@ -16,8 +17,12 @@ class Npf(Package): @define(slots=False) class CvOptions: - variablecv: bool = field(default=False) - dewatered: bool = field(default=False) + variablecv: Literal["variablecv"] = attrs.field(init=False, default="variablecv") + dewatered: Literal["dewatered"] | None = attrs.field( + default=None, + # TODO: adopt this pattern for all record types in all components? + converter=Converter(structure_keyword, takes_field=True), # type: ignore + ) @define(slots=False) class RewetRecord: diff --git a/pixi.lock b/pixi.lock index b05dfa26..70be5004 100644 --- a/pixi.lock +++ b/pixi.lock @@ -104,7 +104,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/50/bd/c336448be43d40be28e71f2e0f3caf7ccb28e2755c58f4c02c065bfe3e8e/WebOb-1.8.9-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -199,7 +199,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/50/bd/c336448be43d40be28e71f2e0f3caf7ccb28e2755c58f4c02c065bfe3e8e/WebOb-1.8.9-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -297,7 +297,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/50/bd/c336448be43d40be28e71f2e0f3caf7ccb28e2755c58f4c02c065bfe3e8e/WebOb-1.8.9-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -535,7 +535,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -755,7 +755,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -977,7 +977,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -1186,7 +1186,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -1379,7 +1379,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -1573,7 +1573,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -1780,7 +1780,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -1970,7 +1970,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -2161,7 +2161,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -2367,7 +2367,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -2560,7 +2560,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -2754,7 +2754,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/3f/0e/fa3b193432cfc60c93b42f3be03365f5f909d2b3ea410295cf36df739e31/widgetsnbextension-4.0.15-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/c3/78/4d6d68555a92cb97b4c192759c4ab585c5cb23490f64d4ddf12c66a3b051/xarray-2025.10.1-py3-none-any.whl - - pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 + - pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a - pypi: https://files.pythonhosted.org/packages/5b/8f/447cc9cb57456d786204af0f450ffb920039104c5eff6626337c9f403bd1/xyzservices-2025.10.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/1a/71/9de7229515a53d1cc5705ca9c411530f711a2242f962214d9dbfe2741aa4/zarr-3.1.3-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/80/ab/11a76c1e2126084fde2639514f24e6111b789b0bfa4fc6264a8975c7e1f1/zict-3.0.0-py2.py3-none-any.whl @@ -10094,7 +10094,7 @@ packages: - types-requests ; extra == 'types' - types-setuptools ; extra == 'types' requires_python: '>=3.11' -- pypi: git+https://github.com/wpbonelli/xattree.git#ebc4d5c2593fba4cf2c3e40c5c32b52debd3e989 +- pypi: git+https://github.com/wpbonelli/xattree.git#05778bdd17bec769c5bbd5672ae06bcd242f2c6a name: xattree version: 0.1.0.dev0 requires_dist: diff --git a/test/test_mf6_codec.py b/test/test_mf6_codec.py index 55a367d7..a1cb0725 100644 --- a/test/test_mf6_codec.py +++ b/test/test_mf6_codec.py @@ -286,6 +286,22 @@ def test_dumps_drn(): pprint(loaded) +def test_dumps_npf(): + from flopy4.mf6.gwf import Dis, Gwf, Npf + + dis = Dis(nlay=2, nrow=5, ncol=5) + gwf = Gwf(dis=dis) + drn = Npf(parent=gwf, cvoptions=Npf.CvOptions(dewatered=True), k=1.0) + + dumped = dumps(COMPONENT_CONVERTER.unstructure(drn)) + print("NPF dump:") + print(dumped) + + assert "variablecv dewatered" in dumped + assert "ICELLTYPE\n CONSTANT 0" in dumped + assert "K\n CONSTANT 1.0" in dumped + + def test_dumps_chd_2(): from flopy4.mf6.gwf import Chd, Dis, Gwf