Skip to content

Commit

Permalink
Elaborate on error message in ragged array slicing. (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinrporter authored Jun 10, 2024
1 parent 948e81a commit 1b26459
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions enspara/ra/ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,14 @@ def _convert_from_2d(iis_ragged, lengths=None, starts=None, error_check=True):
[second_dimension for n in first_dimension])
first_dimension, second_dimension = _handle_negative_indices(
first_dimension, second_dimension, lengths=lengths, starts=starts)
# Check for index error
# Check if row is too short for indexing
if lengths is not None and error_check:
if np.any(lengths[first_dimension] <= second_dimension):
raise IndexError
iis_flat = starts[first_dimension]+second_dimension
raise IndexError(("Length of dimension {} ({}) is out of "
"range for index {}")
.format(first_dimension, lengths[first_dimension],
second_dimension))
iis_flat = starts[first_dimension] + second_dimension
return (iis_flat,)


Expand Down

0 comments on commit 1b26459

Please sign in to comment.