Commit 77b5ce0
committed
fix(transforms): make _to_int_list ROI coercion correct and type-safe
The prior _to_int_list used issequenceiterable, which broke in three ways
once the missing import was restored and the code actually ran:
- str/bytes were no longer rejected (issequenceiterable("10") is False, so
"10" coerced to the scalar [10] instead of raising, silently building
wrong slices);
- mypy could not narrow the union through issequenceiterable, so the
iterate/scalar branches failed type checking.
Rewrite the helper to reject str/bytes explicitly, then coerce via the
existing ensure_tuple helper, which handles scalars, sequences, tensors and
ndarrays uniformly and is mypy-clean. Likewise return the crop slices via
ensure_tuple so compute_slices matches its declared tuple[slice] return
type. Behaviour is covered by test_compute_slices_broadcast.
Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>1 parent 8e975a1 commit 77b5ce0
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
348 | | - | |
349 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| |||
0 commit comments