예제 #1
0
 def test_mask(self):
     for a, b in ([], []), ([1], []), ([1, 2],
                                       [2,
                                        1]), ([], [1]), ([1], [2]), ([1, 2],
                                                                     [3,
                                                                      1]):
         self.assertEqual(
             numeric.sorted_index(numpy.array(a, int), b,
                                  missing='mask').tolist(),
             [a.index(v) for v in b if v in a])
예제 #2
0
 def test_int(self):
     for a, b in ([], []), ([1], []), ([1, 2],
                                       [2,
                                        1]), ([], [1]), ([1], [2]), ([1, 2],
                                                                     [3,
                                                                      1]):
         self.assertEqual(
             numeric.sorted_index(numpy.array(a, int), b,
                                  missing=-1).tolist(),
             [a.index(v) if v in a else -1 for v in b])
예제 #3
0
 def test_invalid(self):
   with self.assertRaises(ValueError):
     numeric.sorted_index(numpy.array([1], int), [1], missing='foo')
예제 #4
0
 def test_None_exception(self):
   for a, b in ([], [1]), ([1], [2]), ([1,2], [3,1]):
     with self.assertRaises(ValueError):
       numeric.sorted_index(numpy.array(a, int), b)
예제 #5
0
 def test_None(self):
   for a, b in ([], []), ([1], []), ([1,2], [2,1]):
     self.assertEqual(numeric.sorted_index(numpy.array(a, int), b).tolist(), [a.index(v) for v in b if v in a])
예제 #6
0
 def test_invalid(self):
   with self.assertRaises(ValueError):
     numeric.sorted_index(numpy.array([1], int), [1], missing='foo')
예제 #7
0
 def test_mask(self):
   for a, b in ([], []), ([1], []), ([1,2], [2,1]), ([], [1]), ([1], [2]), ([1,2], [3,1]):
     self.assertEqual(numeric.sorted_index(numpy.array(a, int), b, missing='mask').tolist(), [a.index(v) for v in b if v in a])
예제 #8
0
 def test_int(self):
   for a, b in ([], []), ([1], []), ([1,2], [2,1]), ([], [1]), ([1], [2]), ([1,2], [3,1]):
     self.assertEqual(numeric.sorted_index(numpy.array(a, int), b, missing=-1).tolist(), [a.index(v) if v in a else -1 for v in b])
예제 #9
0
 def test_None_exception(self):
   for a, b in ([], [1]), ([1], [2]), ([1,2], [3,1]):
     with self.assertRaises(ValueError):
       numeric.sorted_index(numpy.array(a, int), b)
예제 #10
0
 def test_None(self):
   for a, b in ([], []), ([1], []), ([1,2], [2,1]):
     self.assertEqual(numeric.sorted_index(numpy.array(a, int), b).tolist(), [a.index(v) for v in b if v in a])