Skip to content

Commit 64e93ba

Browse files
committed
add dev dep group to pyproject.toml, expand idm example
1 parent 86cc2a3 commit 64e93ba

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed
Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# # Input data model
22
#
3+
# TODO: flesh this out, describe prospective plan for type hints,
4+
# determine whether we want to work directly with numpy or with
5+
# e.g. xarray, etc. This will probably evolve for a while as we
6+
# rework the prototype with c/attrs
7+
#
38
# FloPy organizes input variables in components: simulations, models,
49
# packages, and subpackages.
510
#
6-
# The MODFLOW 6 data model is arranged in the following way:
7-
#
811
# ```mermaid
912
# classDiagram
1013
# Simulation *-- "1+" Package
@@ -17,29 +20,61 @@
1720
# Package *-- "1+" Variable
1821
# ```
1922
#
20-
# Components are generally mutable and variables can be manipulated at will.
23+
# Components are generally mutable: subcomponents can be added/removed and
24+
# variables can be manipulated.
2125
#
2226
# # Variable types
2327
#
24-
# Variables are generally scalars, arrays, or composite data types: list,
25-
# sum, union.
28+
# Variables are scalars, paths, arrays, or composite types: list, sum, union.
29+
#
30+
# MODFLOW 6 defines the following scalars types:
31+
#
32+
# - `keyword`
33+
# - `integer`
34+
# - `double precision`
35+
# - `string`
36+
#
37+
# And the following composites:
2638
#
27-
# The variable type structure can be summarized briefly as:
39+
# - `record`: product type
40+
# - `keystring`: union type
41+
# - `recarray`: list type
42+
#
43+
# Scalars may (and `recarray` must) have a `shape`. If a scalar has a `shape`,
44+
# its type becomes a homogeneous scalar array. A `recarray` may contain records
45+
# or unions of records as items.
46+
#
47+
# We map this typology roughly to the following in Python:
2848

2949
# +
3050
from os import PathLike
3151
from typing import (
52+
Any,
3253
Iterable,
3354
Tuple,
3455
Union,
3556
)
3657

3758
from numpy.typing import ArrayLike
59+
from pandas import DataFrame
3860

3961
Scalar = Union[bool, int, float, str]
4062
Path = PathLike
4163
Array = ArrayLike
4264
Record = Tuple[Union[Scalar, "Record"], ...]
43-
Table = Iterable["Record"]
44-
Variable = Union[Scalar, Array, Table, Record]
65+
Table = Union[Iterable[Record], DataFrame]
66+
List = Iterable[Any]
67+
Variable = Union[Scalar, Array, Record, Table, List]
4568
# -
69+
70+
# Note that:
71+
#
72+
# - Keystrings are omitted above, since a keystring simply becomes a
73+
# `Union` of records or scalars.
74+
# - List input may be regular (items all have the same record type) or
75+
# irregular (items are unions of records).
76+
# - A table is a special case of list input; since it is regular it can
77+
# be represented as a dataframe.
78+
# - While MODFLOW 6 typically formulates file path inputs as records with
79+
# 3 fields (identifying keyword, `filein`/`fileout`, and filename), FloPy
80+
# simply accepts `PathLike`.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies = [
4747
dynamic = ["version"]
4848

4949
[project.optional-dependencies]
50+
dev = ["flopy4[lint,test,build]"]
5051
lint = [
5152
"ruff"
5253
]

0 commit comments

Comments
 (0)