Context
Found during a review of extract_discharge. The parameter is public, documented as doing something, and has
never done it. Present on main; documented as inert rather than changed, because fixing it alters behaviour and
deserves its own decision.
Problem / Current Behaviour
Catchment.extract_discharge dispatches like this:
if not frame_work_1:
... # per-gauge extraction
elif frame_work_1 or only_outlet:
... # basin-wide sum
The elif is reached only when frame_work_1 is already True, so only_outlet can never change which branch
runs. extract_discharge(only_outlet=True) behaves exactly like extract_discharge().
The docstring says "True to extract discharge only at the outlet cell", so a caller has no way to discover that
the flag does nothing short of reading the dispatch.
Affected locations
| File |
Symbol |
Notes |
src/hapi/catchment.py |
Catchment.extract_discharge |
the elif frame_work_1 or only_outlet dispatch |
src/hapi/calibration.py |
Calibration.extract_discharge |
override; accepts and ignores the same flag |
Steps to Reproduce
model.extract_discharge(only_outlet=True)
# identical result to model.extract_discharge() -- the flag selects nothing
Proposed Solution
Decide between three, none of which is obviously right:
- Make it work — give
only_outlet its own branch, independent of frame_work_1. Changes behaviour for
anyone passing it today, though since it currently does nothing, nobody can be relying on it working.
- Remove it — drop the parameter from both signatures. Cleanest, but breaks any call site passing it by
keyword.
- Keep documenting it as inert — the current state, chosen to avoid a behaviour change inside an unrelated
refactor.
Whichever is chosen, the Calibration override should follow.
Out of Scope
- The MAXBAS guard in the same method, which is separate and working.
Effort Estimate
Size: XS
Rationale: a few lines either way; the cost is the decision, not the change.
Definition of Done
Context
Found during a review of
extract_discharge. The parameter is public, documented as doing something, and hasnever done it. Present on
main; documented as inert rather than changed, because fixing it alters behaviour anddeserves its own decision.
Problem / Current Behaviour
Catchment.extract_dischargedispatches like this:The
elifis reached only whenframe_work_1is alreadyTrue, soonly_outletcan never change which branchruns.
extract_discharge(only_outlet=True)behaves exactly likeextract_discharge().The docstring says "True to extract discharge only at the outlet cell", so a caller has no way to discover that
the flag does nothing short of reading the dispatch.
Affected locations
src/hapi/catchment.pyCatchment.extract_dischargeelif frame_work_1 or only_outletdispatchsrc/hapi/calibration.pyCalibration.extract_dischargeSteps to Reproduce
Proposed Solution
Decide between three, none of which is obviously right:
only_outletits own branch, independent offrame_work_1. Changes behaviour foranyone passing it today, though since it currently does nothing, nobody can be relying on it working.
keyword.
refactor.
Whichever is chosen, the
Calibrationoverride should follow.Out of Scope
Effort Estimate
Size:
XSRationale: a few lines either way; the cost is the decision, not the change.
Definition of Done
only_outleteither selects the outlet-cell path, or is gone from both signatures