Ejemplo n.º 1
0
    def test_create_set_from_buffer(self):
        import numpy as np
        from cykhash import Int64Set_from_buffer
        a = np.arange(42, dtype=np.int64)
        my_set = Int64Set_from_buffer(a)  # no reallocation will be needed
        assert 41 in my_set and 42 not in my_set

        self.assertTrue(True)
Ejemplo n.º 2
0
    def test_is_in(self):
        import numpy as np
        from cykhash import Int64Set_from_buffer, isin_int64
        a = np.arange(42, dtype=np.int64)
        lookup = Int64Set_from_buffer(a)

        b = np.arange(84, dtype=np.int64)
        result = np.empty(b.size, dtype=np.bool)

        isin_int64(b, lookup, result)
        assert np.sum(result.astype(np.int)) == 42

        self.assertTrue(True)
Ejemplo n.º 3
0
    def test_quick_tutorial_1(self):
        import numpy as np 
        a = np.arange(42, dtype=np.int64)
        b = np.arange(84, dtype=np.int64)
        result = np.empty(b.size, dtype=np.bool)

        # actually usage
        from cykhash import Int64Set_from_buffer, isin_int64

        lookup = Int64Set_from_buffer(a) # create a hashset
        isin_int64(b, lookup, result)    # running time O(b.size)
        isin_int64(b, lookup, result)    # lookup is reused and not recreated

        self.assertTrue(True)
Ejemplo n.º 4
0
def int64set_from_buffer(bufs):
    Int64Set_from_buffer(bufs[1])