8000 Backport 6553 by charris · Pull Request #6573 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Backport 6553 #6573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
Prev Previous commit
Next Next commit
TST: Added tests for empty partition and argpartition
  • Loading branch information
yashmehrotra authored and charris committed Oct 27, 2015
commit 9d0c2473445e14513f7ffb9531b37b7102f02a42
18 changes: 18 additions & 0 deletions numpy/core/tests/test_item_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ def test_unicode_mode(self):
k = b'\xc3\xa4'.decode("UTF8")
assert_raises(ValueError, d.take, 5, mode=k)

def test_empty_partition(self):
# In reference to github issue #6530
a_original = np.array([0, 2, 4, 6, 8, 10])
a = a_original.copy()

# An empty partition should be a successful no-op
a.partition(np.array([], dtype=np.int16))

assert_array_equal(a, a_original)

def test_empty_argpartition(self):
# In reference to github issue #6530
a = np.array([0, 2, 4, 6, 8, 10])
a = a.argpartition(np.array([], dtype=np.int16))

b = np.array([0, 1, 2, 3, 4, 5])
assert_array_equal(a, b)


if __name__ == "__main__":
run_module_suite()
0