File tree 1 file changed +24
-2
lines changed
1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1985,9 +1985,31 @@ def get_indexer(_i, _idx):
1985
1985
1986
1986
1987
1987
def maybe_convert_indices (indices , n ):
1988
- """ if we have negative indicies, translate to postive here
1989
- if have indicies that are out-of-bounds, raise an IndexError
1990
1988
"""
1989
+ Attempt to convert indices into valid, positive indices.
1990
+
1991
+ If we have negative indices, translate to positive here.
1992
+ If we have indices that are out-of-bounds, raise an IndexError.
1993
+
1994
+ Parameters
1995
+ ----------
1996
+ indices : array-like
1997
+ The array of indices that we are to convert.
1998
+ n : int
1999
+ The number of elements in the array that we are indexing.
2000
+
2001
+ Returns
2002
+ -------
2003
+ valid_indices : array-like
2004
+ An array-like of positive indices that correspond to the ones
2005
+ that were passed in initially to this function.
2006
+
2007
+ Raises
2008
+ ------
2009
+ IndexError : one of the converted indices either exceeded the number
2010
+ of elements (specified by `n`) OR was still negative.
2011
+ """
2012
+
1991
2013
if isinstance (indices , list ):
1992
2014
indices = np .array (indices )
1993
2015
if len (indices ) == 0 :
You can’t perform that action at this time.
0 commit comments