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

Method test_unique_axis

numpy/lib/tests/test_arraysetops.py:808–828  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

806 assert_array_equal(unique(inp, axis=1), unique(inp_arr, axis=1), msg)
807
808 def test_unique_axis(self):
809 types = []
810 types.extend(np.typecodes['AllInteger'])
811 types.extend(np.typecodes['AllFloat'])
812 types.append('datetime64[D]')
813 types.append('timedelta64[D]')
814 types.append([('a', int), ('b', int)])
815 types.append([('a', int), ('b', float)])
816
817 for dtype in types:
818 self._run_axis_tests(dtype)
819
820 msg = 'Non-bitwise-equal booleans test failed'
821 data = np.arange(10, dtype=np.uint8).reshape(-1, 2).view(bool)
822 result = np.array([[False, True], [True, True]], dtype=bool)
823 assert_array_equal(unique(data, axis=0), result, msg)
824
825 msg = 'Negative zero equality test failed'
826 data = np.array([[-0.0, 0.0], [0.0, -0.0], [-0.0, 0.0], [0.0, -0.0]])
827 result = np.array([[-0.0, 0.0]])
828 assert_array_equal(unique(data, axis=0), result, msg)
829
830 @pytest.mark.parametrize("axis", [0, -1])
831 def test_unique_1d_with_axis(self, axis):

Callers

nothing calls this directly

Calls 5

_run_axis_testsMethod · 0.95
assert_array_equalFunction · 0.90
uniqueFunction · 0.90
reshapeMethod · 0.80
viewMethod · 0.45

Tested by

no test coverage detected