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)
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])
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)
def test_memview_none(self): s=PyObjectSet_from([]) self.assertEqual(count_if_pyobject(None,s), 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)
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)
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))
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)
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)
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)
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)
def test_all_empty_from_iter(self): s = PyObjectSet_from([]) a = [] result = all_pyobject_from_iter(a, s) self.assertEqual(result, True)
def test_memview_none(self): s = PyObjectSet_from([]) self.assertEqual(all_pyobject(None, s), True)
def test_all_empty(self): s = PyObjectSet_from([]) a = np.array([], dtype=np.object) result = all_pyobject(a, s) self.assertEqual(result, True)
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)
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)
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)
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)
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)
def test_isin_nones(self): s = PyObjectSet_from([2, 4, 6]) isin_pyobject(None, s, None) self.assertTrue(True)
def setup(self): t = tuple(range(1000)) self.set = PyObjectSet_from([t]) self.query = np.array(["a"] + [t] * 1000)
def pyobjectset_from_iter(bufs): PyObjectSet_from(bufs[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)
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)
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)
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)
def test_any_empty_set_from_iter(self): s = PyObjectSet_from([]) a = [1] result = any_pyobject_from_iter(a, s) self.assertEqual(result, False)
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)
def test_memview_none(self): s = PyObjectSet_from([]) self.assertEqual(any_pyobject(None, s), False)
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)