spacepy.toolbox.indsFromXrange

spacepy.toolbox.indsFromXrange(inxrange)[source]

return the start and end indices implied by a range, useful when range is zero-length

Parameters:
inxrangerange

input range object to parse

Returns:
list of int

List of start, stop indices in the range. The return value is not defined if a stride is specified or if stop is before start (but will work when stop equals start).

Examples

>>> import spacepy.toolbox as tb
>>> foo = range(23, 39)
>>> foo[0]
23
>>> tb.indsFromXrange(foo)
[23, 39]
>>> foo1 = range(23, 23)
>>> tb.indsFromXrange(foo) #indexing won't work in this case
[23, 23]