forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: is_scalar_indexer (pandas-dev#32850)
* BUG: is_scalar_indexer * update docstring * add copy=False
- Loading branch information
1 parent
065accb
commit f810831
Showing
3 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
# Tests aimed at pandas.core.indexers | ||
import numpy as np | ||
|
||
from pandas.core.indexers import length_of_indexer | ||
from pandas.core.indexers import is_scalar_indexer, length_of_indexer | ||
|
||
|
||
def test_length_of_indexer(): | ||
arr = np.zeros(4, dtype=bool) | ||
arr[0] = 1 | ||
result = length_of_indexer(arr) | ||
assert result == 1 | ||
|
||
|
||
def test_is_scalar_indexer(): | ||
indexer = (0, 1) | ||
assert is_scalar_indexer(indexer, 2) | ||
assert not is_scalar_indexer(indexer[0], 2) | ||
|
||
indexer = (np.array([2]), 1) | ||
assert is_scalar_indexer(indexer, 2) | ||
|
||
indexer = (np.array([2]), np.array([3])) | ||
assert is_scalar_indexer(indexer, 2) | ||
|
||
indexer = (np.array([2]), np.array([3, 4])) | ||
assert not is_scalar_indexer(indexer, 2) | ||
|
||
assert not is_scalar_indexer(slice(None), 1) |