MCPcopy Index your code
hub / github.com/numpy/numpy / test_unique_axis

Method test_unique_axis

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

Source from the content-addressed store, hash-verified

1061 assert_array_equal(unique(inp, axis=1), unique(inp_arr, axis=1), msg)
1062
1063 def test_unique_axis(self):
1064 types = []
1065 types.extend(np.typecodes['AllInteger'])
1066 types.extend(np.typecodes['AllFloat'])
1067 types.append('datetime64[D]')
1068 types.append('timedelta64[D]')
1069 types.append([('a', int), ('b', int)])
1070 types.append([('a', int), ('b', float)])
1071
1072 for dtype in types:
1073 self._run_axis_tests(dtype)
1074
1075 msg = 'Non-bitwise-equal booleans test failed'
1076 data = np.arange(10, dtype=np.uint8).reshape(-1, 2).view(bool)
1077 result = np.array([[False, True], [True, True]], dtype=bool)
1078 assert_array_equal(unique(data, axis=0), result, msg)
1079
1080 msg = 'Negative zero equality test failed'
1081 data = np.array([[-0.0, 0.0], [0.0, -0.0], [-0.0, 0.0], [0.0, -0.0]])
1082 result = np.array([[-0.0, 0.0]])
1083 assert_array_equal(unique(data, axis=0), result, msg)
1084
1085 @pytest.mark.parametrize("axis", [0, -1])
1086 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