Beispiel #1
0
 def test_pyobject_isin(self):
     s = PyObjectSet_from([2, 4, 6])
     a = np.array(range(0, 7), dtype=np.object)
     result = array.array('B', [False] * 7)
     isin_pyobject(a, s, result)
     expected = array.array('B',
                            [False, False, True, False, True, False, True])
     self.assertTrue(expected == result)
Beispiel #2
0
 def test_isin_result_longer(self):
     s = PyObjectSet_from([2, 4, 6])
     a = np.array(range(0, 7), dtype=np.object)
     result = array.array('B', [False] * 8)
     with pytest.raises(ValueError) as context:
         isin_pyobject(a, s, result)
     self.assertEqual("Different sizes for query(7) and result(8)",
                      context.value.args[0])
Beispiel #3
0
 def test_pyobject_isin(self):
     try:
         import numpy as np
     except:
         return  # well what should I do?
     s = PyObjectSet_from([2, 4, 6])
     a = np.array(range(0, 7), dtype=np.object)
     result = array.array('B', [False] * 7)
     isin_pyobject(a, s, result)
     expected = array.array('B',
                            [False, False, True, False, True, False, True])
     self.assertTrue(expected == result)
Beispiel #4
0
 def test_memview_none(self):
     s=PyObjectSet_from([])
     self.assertEqual(count_if_pyobject(None,s), 0)
Beispiel #5
0
 def test_count_if_empty_set_from_iter(self):
     s=PyObjectSet_from([])
     a=[1]
     result=count_if_pyobject_from_iter(a,s)
     self.assertEqual(result, 0)
Beispiel #6
0
 def test_any_empty_set(self):
     s = PyObjectSet_from([])
     a = np.array([1], dtype=np.object)
     result = any_pyobject(a, s)
     self.assertEqual(result, False)
Beispiel #7
0
 def test_noniter_from_iter(self):
     s = PyObjectSet_from([])
     a = 1
     with pytest.raises(TypeError) as context:
         any_pyobject_from_iter(a, s)
     self.assertTrue("object is not iterable" in str(context.value))
Beispiel #8
0
 def test_any_no(self):
     s = PyObjectSet_from([2, 4, 666])
     a = np.array([1, 3, 333] * 6, dtype=np.object)
     result = any_pyobject(a, s)
     self.assertEqual(result, False)
Beispiel #9
0
 def test_any_last_yes(self):
     s = PyObjectSet_from([2, 4, 666])
     a = np.array([1, 3, 333] * 6 + [2], dtype=np.object)
     result = any_pyobject(a, s)
     self.assertEqual(result, True)
Beispiel #10
0
 def test_count_if_all(self):
     s=PyObjectSet_from([2,4,666])
     a=np.array([2,4,666]*6, dtype=np.object)
     result=count_if_pyobject(a,s)
     self.assertEqual(result, 18)
Beispiel #11
0
 def setup(self):
     N = 100_000
     self.set = PyObjectSet_from(x << 32 for x in range(N))
     np.random.seed(42)
     self.query = np.random.randint(0, N, N).astype(np.object)
Beispiel #12
0
 def test_all_empty_from_iter(self):
     s = PyObjectSet_from([])
     a = []
     result = all_pyobject_from_iter(a, s)
     self.assertEqual(result, True)
Beispiel #13
0
 def test_memview_none(self):
     s = PyObjectSet_from([])
     self.assertEqual(all_pyobject(None, s), True)
Beispiel #14
0
 def test_all_empty(self):
     s = PyObjectSet_from([])
     a = np.array([], dtype=np.object)
     result = all_pyobject(a, s)
     self.assertEqual(result, True)
Beispiel #15
0
 def test_all_last_no_from_iter(self):
     s = PyObjectSet_from([2, 4, 666])
     a = [2, 4, 666] * 6 + [3]
     result = all_pyobject_from_iter(a, s)
     self.assertEqual(result, False)
Beispiel #16
0
 def test_all_last_no(self):
     s = PyObjectSet_from([2, 4, 666])
     a = np.array([2, 4, 666] * 6 + [3], dtype=np.object)
     result = all_pyobject(a, s)
     self.assertEqual(result, False)
Beispiel #17
0
 def test_all_from_iter(self):
     s = PyObjectSet_from([2, 4, 666])
     a = [2, 4, 666] * 6
     result = all_pyobject_from_iter(a, s)
     self.assertEqual(result, True)
Beispiel #18
0
 def test_all_yes(self):
     s = PyObjectSet_from([2, 4, 666])
     a = np.array([2, 4, 666] * 6, dtype=np.object)
     result = all_pyobject(a, s)
     self.assertEqual(result, True)
Beispiel #19
0
 def test_count_if_all_from_iter(self):
     s=PyObjectSet_from([2,4,666])
     a=[2,4,666]*6
     result=count_if_pyobject_from_iter(a,s)
     self.assertEqual(result, 18)
Beispiel #20
0
 def test_isin_nones(self):
     s = PyObjectSet_from([2, 4, 6])
     isin_pyobject(None, s, None)
     self.assertTrue(True)
Beispiel #21
0
 def setup(self):
     t = tuple(range(1000))
     self.set = PyObjectSet_from([t])
     self.query = np.array(["a"] + [t] * 1000)
Beispiel #22
0
def pyobjectset_from_iter(bufs):
    PyObjectSet_from(bufs[0])
Beispiel #23
0
 def test_any_no_from_iter(self):
     s = PyObjectSet_from([2, 4, 666])
     a = [1, 3, 333] * 6
     result = any_pyobject_from_iter(a, s)
     self.assertEqual(result, False)
Beispiel #24
0
 def test_count_if_but_last(self):
     s=PyObjectSet_from([2,4,666])
     a=np.array([2,4,666]*6+[2, 1], dtype=np.object)
     result=count_if_pyobject(a,s)
     self.assertEqual(result, 19)
Beispiel #25
0
 def test_any_last_yes_from_iter(self):
     s = PyObjectSet_from([2, 4, 666])
     a = [1, 3, 333] * 6 + [2]
     result = any_pyobject_from_iter(a, s)
     self.assertEqual(result, True)
Beispiel #26
0
 def test_count_if_butlast_from_iter(self):
     s=PyObjectSet_from([2,4,666, "str"])
     a=[2,4,666,"str"]*6+[2,1]
     result=count_if_pyobject_from_iter(a,s)
     self.assertEqual(result, 25)
Beispiel #27
0
 def test_any_empty_set_from_iter(self):
     s = PyObjectSet_from([])
     a = [1]
     result = any_pyobject_from_iter(a, s)
     self.assertEqual(result, False)
Beispiel #28
0
 def test_count_if_empty_set(self):
     s=PyObjectSet_from([])
     a=np.array([1], dtype=np.object)
     result=count_if_pyobject(a,s)
     self.assertEqual(result, 0)
Beispiel #29
0
 def test_memview_none(self):
     s = PyObjectSet_from([])
     self.assertEqual(any_pyobject(None, s), False)
Beispiel #30
0
 def test_none_from_iter(self):
     s=PyObjectSet_from([2,4,666])
     a=[1,3,333]*6
     result=none_pyobject_from_iter(a,s)
     self.assertEqual(result, True)