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

Method test_find_duplicates

numpy/lib/tests/test_recfunctions.py:171–202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

169 assert_equal(test, {})
170
171 def test_find_duplicates(self):
172 # Test find_duplicates
173 a = ma.array([(2, (2., 'B')), (1, (2., 'B')), (2, (2., 'B')),
174 (1, (1., 'B')), (2, (2., 'B')), (2, (2., 'C'))],
175 mask=[(0, (0, 0)), (0, (0, 0)), (0, (0, 0)),
176 (0, (0, 0)), (1, (0, 0)), (0, (1, 0))],
177 dtype=[('A', int), ('B', [('BA', float), ('BB', '|S1')])])
178
179 test = find_duplicates(a, ignoremask=False, return_index=True)
180 control = [0, 2]
181 assert_equal(sorted(test[-1]), control)
182 assert_equal(test[0], a[test[-1]])
183
184 test = find_duplicates(a, key='A', return_index=True)
185 control = [0, 1, 2, 3, 5]
186 assert_equal(sorted(test[-1]), control)
187 assert_equal(test[0], a[test[-1]])
188
189 test = find_duplicates(a, key='B', return_index=True)
190 control = [0, 1, 2, 4]
191 assert_equal(sorted(test[-1]), control)
192 assert_equal(test[0], a[test[-1]])
193
194 test = find_duplicates(a, key='BA', return_index=True)
195 control = [0, 1, 2, 4]
196 assert_equal(sorted(test[-1]), control)
197 assert_equal(test[0], a[test[-1]])
198
199 test = find_duplicates(a, key='BB', return_index=True)
200 control = [0, 1, 2, 3, 4]
201 assert_equal(sorted(test[-1]), control)
202 assert_equal(test[0], a[test[-1]])
203
204 def test_find_duplicates_ignoremask(self):
205 # Test the ignoremask option of find_duplicates

Callers

nothing calls this directly

Calls 2

find_duplicatesFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected