convert_slice_nones_to_ints

ndcube.utils.sequence.convert_slice_nones_to_ints(slice_item, target_length)[source] [edit on github]

Converts None types within a slice to the appropriate ints based on object to be sliced.

The one case where a None is left in the slice object is when the step is negative and the stop parameter is None, since this scenario cannot be represented with an int stop parameter.

Parameters
  • slice_item (slice) – Slice for which Nones should be converted.

  • target_length (int) – Length of object to which slice will be applied.

Returns

new_slice (slice) – Slice with Nones replaced with ints.