Skip to content

[major_surface_waters] sea_stage dispatch uses isinstance(..., float) and so mishandles an int stage #62

Description

@bdestombe

major_surface_waters.py:102:

if isinstance(sea_stage, float):
    ...  # constant-head branch
else:
    ...  # time-series branch, head="sea_stage", timeseries=sea_stage

An integer stage — chd_ghb_from_major_surface_waters(ds, gwf, sea_stage=0) — is not a float, so it falls into the time-series branch and is passed to chd.ts.initialize(timeseries=0), which is not a valid (time, stage) series. The caller gets an obscure flopy error instead of a constant 0 m head.

isinstance(sea_stage, (int, float)) or np.isscalar(sea_stage) would dispatch on what the branch actually distinguishes, namely scalar-versus-series.

Low impact today (the 09pwnmodel2 call site always passes a list), but it is a trap for any new caller. Found while writing the nhflotools test suite; deliberately not pinned by a test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions