Skip to content

Commit 773437c

Browse files
committed
TST: Added tests for empty partition and argpartition
1 parent 69e1fb6 commit 773437c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

numpy/core/tests/test_item_selection.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ def test_unicode_mode(self):
6868
k = b'\xc3\xa4'.decode("UTF8")
6969
assert_raises(ValueError, d.take, 5, mode=k)
7070

71+
def test_empty_partition(self):
72+
# In reference to github issue #6530
73+
a_original = np.array([0, 2, 4, 6, 8, 10])
74+
a = a_original.copy()
75+
76+
# An empty partition should be a successful no-op
77+
a.partition(np.array([], dtype=np.int16))
78+
79+
assert_array_equal(a, a_original)
80+
81+
def test_empty_argpartition(self):
82+
# In reference to github issue #6530
83+
a = np.array([0, 2, 4, 6, 8, 10])
84+
a = a.argpartition(np.array([], dtype=np.int16))
85+
86+
b = np.array([0, 1, 2, 3, 4, 5])
87+
assert_array_equal(a, b)
88+
7189

7290
if __name__ == "__main__":
7391
run_module_suite()

0 commit comments

Comments
 (0)