Skip to content

waterRegimeCode special case for code 'z' compares against ' z' (leading space) — dead branch, ValueError for group_9 soils (SALCAphosphor.py:105) #6

Description

@mklarmann

Hi team — a leading-space typo in waterRegimeCode that turns a special case into dead code and raises for group_9 soils.

In SALCAphosphorus/SALCAphosphor.py, when soil_waterRegime == 'group_9', watRegSel = ['z']. The intended special case is:

103      ...}.get(watRegSel[0])
104
105      if watRegSel[0] == ' z':
106          waterRegCode = 'z'
107      else:
108          ind = searchintervals(bound, soil_depth_cm)
109          waterRegCode = watRegSel[len(bound)-ind]

Line 105 compares against ' z' (leading space), so it is never True for watRegSel[0] == 'z'. The bound dict (lines 96-103) has no 'z' key, so .get('z') returns None, execution falls into the else, and searchintervals(None, soil_depth_cm) calls np.searchsorted(None, ...)ValueError.

Why it's a bug: any group_9 soil hits the dead branch and crashes instead of returning water-regime code 'z'.

One-line fix:

if watRegSel[0] == 'z':

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions