From ee8d599b2ca919c9d18c0c8446e0be43e54af834 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Tue, 15 Oct 2024 19:03:49 -0400 Subject: [PATCH] docs/comments --- flopy/mf6/utils/codegen/dfn.py | 17 +++++++++++------ flopy/mf6/utils/codegen/templates/init.py.jinja | 6 +----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/flopy/mf6/utils/codegen/dfn.py b/flopy/mf6/utils/codegen/dfn.py index 00561b7df..cbf527e84 100644 --- a/flopy/mf6/utils/codegen/dfn.py +++ b/flopy/mf6/utils/codegen/dfn.py @@ -110,10 +110,15 @@ def __init__( @staticmethod def _load(f, common: Optional[dict] = None) -> Tuple[OMD, List[str]]: """ - Internal use only. Loads the DFN as an ordered multi-dictionary, and + Internal use only. Loads the DFN as an ordered multi-dictionary* and a list of string metadata. This is later parsed into more structured form. We also store the original representation for now so it can be used by the shim. + + *The point of the OMD is to handle duplicate variable names; the only + case of this right now is 'auxiliary' which can appear in the options + block and again as a keyword in a record in a package data variable. + """ var = dict() vars = list() @@ -211,12 +216,12 @@ def _map(spec: Dict[str, Any]) -> Var: Notes ----- This involves expanding nested type hierarchies, mapping - types to roughly equivalent Python primitives/composites, - and other shaping. + types to roughly equivalent Python primitives/composites. + The composite inflation step will not be necessary after + DFNs move to a structured format. - The rules for optional variable defaults are as follows: - If a `default_value` is not provided, keywords are `False` - by default, everything else is `None`. + If a variable does not have a `default` attribute, it will + default to `False` if it is a keyword, otherwise to `None`. Any filepath variable whose name functions as a foreign key for another context will be given a pointer to the context. diff --git a/flopy/mf6/utils/codegen/templates/init.py.jinja b/flopy/mf6/utils/codegen/templates/init.py.jinja index 9ed03e647..b49ea5323 100644 --- a/flopy/mf6/utils/codegen/templates/init.py.jinja +++ b/flopy/mf6/utils/codegen/templates/init.py.jinja @@ -1,11 +1,7 @@ def __init__( self, {%- for var in vars.values() if var.init_param %} - {%- if var.default is defined %} - {{ var.name }}={{ var.default }}, - {%- else %} - {{ var.name }}, - {%- endif -%} + {{ var.name }}{%- if var.default is defined %}={{ var.default }}{%- endif -%}, {%- endfor %} **kwargs, ):