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

Method test_find_duplicates

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

Source from the content-addressed store, hash-verified

177 assert_equal(test, {})
178
179 def test_find_duplicates(self):
180 # Test find_duplicates
181 a = ma.array([(2, (2., 'B')), (1, (2., 'B')), (2, (2., 'B')),
182 (1, (1., 'B')), (2, (2., 'B')), (2, (2., 'C'))],
183 mask=[(0, (0, 0)), (0, (0, 0)), (0, (0, 0)),
184 (0, (0, 0)), (1, (0, 0)), (0, (1, 0))],
185 dtype=[('A', int), ('B', [('BA', float), ('BB', '|S1')])])
186
187 test = find_duplicates(a, ignoremask=False, return_index=True)
188 control = [0, 2]
189 assert_equal(sorted(test[-1]), control)
190 assert_equal(test[0], a[test[-1]])
191
192 test = find_duplicates(a, key='A', return_index=True)
193 control = [0, 1, 2, 3, 5]
194 assert_equal(sorted(test[-1]), control)
195 assert_equal(test[0], a[test[-1]])
196
197 test = find_duplicates(a, key='B', return_index=True)
198 control = [0, 1, 2, 4]
199 assert_equal(sorted(test[-1]), control)
200 assert_equal(test[0], a[test[-1]])
201
202 test = find_duplicates(a, key='BA', return_index=True)
203 control = [0, 1, 2, 4]
204 assert_equal(sorted(test[-1]), control)
205 assert_equal(test[0], a[test[-1]])
206
207 test = find_duplicates(a, key='BB', return_index=True)
208 control = [0, 1, 2, 3, 4]
209 assert_equal(sorted(test[-1]), control)
210 assert_equal(test[0], a[test[-1]])
211
212 def test_find_duplicates_ignoremask(self):
213 # 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