MCPcopy Create free account
hub / github.com/numpy/numpy / test_sort_flexible

Method test_sort_flexible

numpy/ma/tests/test_core.py:3591–3621  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3589 assert_equal(am, an)
3590
3591 def test_sort_flexible(self):
3592 # Test sort on structured dtype.
3593 a = array(
3594 data=[(3, 3), (3, 2), (2, 2), (2, 1), (1, 0), (1, 1), (1, 2)],
3595 mask=[(0, 0), (0, 1), (0, 0), (0, 0), (1, 0), (0, 0), (0, 0)],
3596 dtype=[('A', int), ('B', int)])
3597 mask_last = array(
3598 data=[(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (3, 2), (1, 0)],
3599 mask=[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 1), (1, 0)],
3600 dtype=[('A', int), ('B', int)])
3601 mask_first = array(
3602 data=[(1, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 2), (3, 3)],
3603 mask=[(1, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 1), (0, 0)],
3604 dtype=[('A', int), ('B', int)])
3605
3606 test = sort(a)
3607 assert_equal(test, mask_last)
3608 assert_equal(test.mask, mask_last.mask)
3609
3610 test = sort(a, endwith=False)
3611 assert_equal(test, mask_first)
3612 assert_equal(test.mask, mask_first.mask)
3613
3614 # Test sort on dtype with subarray (gh-8069)
3615 # Just check that the sort does not error, structured array subarrays
3616 # are treated as byte strings and that leads to differing behavior
3617 # depending on endianness and `endwith`.
3618 dt = np.dtype([('v', int, 2)])
3619 a = a.view(dt)
3620 test = sort(a)
3621 test = sort(a, endwith=False)
3622
3623 def test_argsort(self):
3624 # Test argsort

Callers

nothing calls this directly

Calls 5

arrayFunction · 0.90
sortFunction · 0.90
assert_equalFunction · 0.90
dtypeMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected