Commit c107fc9
fix(waterdata): materialize numpy/Series numeric params instead of str()-ing them (#308)
A numeric (_NO_NORMALIZE_PARAMS) param — water_year, year, month, day,
thresholds, … — passed as a numpy array or pandas Series fell into the
`args[k] = v` passthrough in _get_args without being materialized to a list.
Downstream, the GET comma-join and the chunker both test `list`/`tuple`, so an
ndarray/Series was neither comma-joined nor chunked: e.g.
get_peaks(water_year=np.array([2020, 2021])) produced
`water_year=%5B2020+2021%5D` (the array's repr) instead of
`water_year=2020,2021`, which the API rejects with HTTP 400. Plain lists
already worked.
Split the branch so _NO_NORMALIZE_PARAMS values keep their element types (no
string-normalization) but a non-string iterable is still materialized to a
list of native Python scalars — `.tolist()` for numpy/pandas, `list()` for
generators and other iterables — so the values comma-join in the URL, chunk,
and stay JSON-serializable (no numpy reprs in args).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 316af70 commit c107fc9
2 files changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2024 | 2024 | | |
2025 | 2025 | | |
2026 | 2026 | | |
2027 | | - | |
2028 | | - | |
| 2027 | + | |
| 2028 | + | |
2029 | 2029 | | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
2030 | 2039 | | |
2031 | 2040 | | |
2032 | 2041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
297 | 319 | | |
298 | 320 | | |
299 | 321 | | |
| |||
0 commit comments