Skip to content

Commit 291cae2

Browse files
author
ShaharNaveh
committed
Fix docs for indexers.py
1 parent 65e4ff4 commit 291cae2

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

ci/code_checks.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
166166
pytest -q --doctest-modules pandas/core/generic.py
167167
RET=$(($RET + $?)) ; echo $MSG "DONE"
168168

169+
MSG='Doctests indexers.py' ; echo $MSG
170+
pytest -q --doctest-modules pandas/core/indexers.py
171+
RET=$(($RET + $?)) ; echo $MSG "DONE"
172+
169173
MSG='Doctests nanops.py' ; echo $MSG
170174
pytest -q --doctest-modules pandas/core/nanops.py
171175
RET=$(($RET + $?)) ; echo $MSG "DONE"

pandas/core/indexers.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,21 @@ def validate_indices(indices: np.ndarray, n: int) -> None:
209209
210210
Examples
211211
--------
212-
>>> validate_indices([1, 2], 3)
213-
# OK
214-
>>> validate_indices([1, -2], 3)
215-
ValueError
216-
>>> validate_indices([1, 2, 3], 3)
217-
IndexError
218-
>>> validate_indices([-1, -1], 0)
219-
# OK
220-
>>> validate_indices([0, 1], 0)
221-
IndexError
212+
>>> validate_indices(np.ndarray([1, 2]), 3) # OK
213+
214+
>>> validate_indices(np.ndarray([1, -2]), 3)
215+
Traceback (most recent call last):
216+
...
217+
ValueError: negative dimensions are not allowed
218+
219+
>>> validate_indices(np.ndarray([1, 2, 3]), 3) # OK
220+
221+
>>> validate_indices(np.ndarray([-1, -1]), 0)
222+
Traceback (most recent call last):
223+
...
224+
ValueError: negative dimensions are not allowed
225+
226+
>>> validate_indices(np.ndarray([0, 1]), 0) # OK
222227
"""
223228
if len(indices):
224229
min_idx = indices.min()

0 commit comments

Comments
 (0)