File: cyunique.pyx

package info (click to toggle)
python-cykhash 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,240 kB
  • sloc: python: 3,954; sh: 90; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 508 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cimport numpy as np
import numpy as np

from cykhash.khashsets cimport Int64Set, Int64SetIterator

def unique_int64(np.int64_t[::1] data):
    cdef np.ndarray[dtype=np.int64_t] res
    cdef Int64Set s=Int64Set(len(data))
    cdef Int64SetIterator it
    cdef Py_ssize_t i
    cdef int cnt=0
    for i in range(len(data)):
        s.add(data[i])
    res=np.empty(s.table.size, dtype=np.int64)
    it = s.get_iter()
    for i in range(s.table.size):
        res[cnt]=it.next()
        cnt+=1
    return res