Skip to content

Commit

Permalink
Linting cython files
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaredoug committed May 18, 2024
1 parent b208e04 commit 491e221
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 28 deletions.
11 changes: 3 additions & 8 deletions searcharray/roaringish/intersect.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import numpy as np


cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t, int64_t
from searcharray.roaringish.snp_ops cimport DTYPE_t

cdef DTYPE_t ALL_BITS = 0xFFFFFFFFFFFFFFFF

Expand Down Expand Up @@ -275,9 +275,6 @@ cdef DTYPE_t _gallop_int_and_adj_drop(intersect_args_t args,
return lhs_result_ptr - &args.lhs_out[0]





def intersect(np.ndarray[DTYPE_t, ndim=1] lhs,
np.ndarray[DTYPE_t, ndim=1] rhs,
DTYPE_t mask=ALL_BITS,
Expand All @@ -297,7 +294,7 @@ def intersect(np.ndarray[DTYPE_t, ndim=1] lhs,
args.lhs = &lhs[0]
args.rhs = &rhs[0]
args.lhs_stride = lhs.strides[0] / sizeof(DTYPE_t)
args.rhs_stride = rhs.strides[0] / sizeof(DTYPE_t)
args.rhs_stride = rhs.strides[0] / sizeof(DTYPE_t)
args.lhs_len = lhs.shape[0] * lhs.strides[0] / sizeof(DTYPE_t)
args.rhs_len = rhs.shape[0] * rhs.strides[0] / sizeof(DTYPE_t)

Expand Down Expand Up @@ -355,8 +352,6 @@ def intersect_with_adjacents(np.ndarray[DTYPE_t, ndim=1] lhs,
cdef np.uint64_t[:] adj_rhs_out
cdef np.uint64_t* adj_lhs_out_begin
cdef np.uint64_t* adj_rhs_out_begin
cdef DTYPE_t lhs_out_len = 0
cdef DTYPE_t rhs_out_len = 0
cdef intersect_args_t args
cdef DTYPE_t delta = 1
cdef DTYPE_t adj_out_len = 0
Expand All @@ -373,7 +368,7 @@ def intersect_with_adjacents(np.ndarray[DTYPE_t, ndim=1] lhs,
args.lhs = &lhs[0]
args.rhs = &rhs[0]
args.lhs_stride = lhs.strides[0] / sizeof(DTYPE_t)
args.rhs_stride = rhs.strides[0] / sizeof(DTYPE_t)
args.rhs_stride = rhs.strides[0] / sizeof(DTYPE_t)
args.lhs_len = lhs.shape[0] * lhs.strides[0] / sizeof(DTYPE_t)
args.rhs_len = rhs.shape[0] * rhs.strides[0] / sizeof(DTYPE_t)

Expand Down
2 changes: 0 additions & 2 deletions searcharray/roaringish/merge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t, int64_t



cdef _merge_naive(DTYPE_t[:] lhs,
DTYPE_t[:] rhs):
cdef np.intp_t len_lhs = lhs.shape[0]
Expand Down Expand Up @@ -133,7 +132,6 @@ cdef DTYPE_t _merge_w_drop(DTYPE_t* lhs,
return result_ptr - &results[0]



def merge(np.ndarray[DTYPE_t, ndim=1] lhs,
np.ndarray[DTYPE_t, ndim=1] rhs,
bint drop_duplicates=False):
Expand Down
3 changes: 1 addition & 2 deletions searcharray/roaringish/popcount.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import numpy as np
# cimport snp_ops
# from snp_ops cimport _galloping_search, DTYPE_t, ALL_BITS
cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t, int64_t
from searcharray.roaringish.snp_ops cimport DTYPE_t


cdef extern from "stddef.h":
Expand Down Expand Up @@ -56,7 +56,6 @@ def popcount64(np.ndarray[DTYPE_t, ndim=1] arr):
cdef _popcount_reduce_at(DTYPE_t[:] ids, DTYPE_t[:] payload, double[:] output):
cdef DTYPE_t idx = 1
cdef DTYPE_t popcount_sum = __builtin_popcountll(payload[0])
cdef DTYPE_t result_idx = 1

# We already have 0, now add new values
while idx < ids.shape[0]:
Expand Down
1 change: 0 additions & 1 deletion searcharray/roaringish/roaringish_ops.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# cython: language_level=3
cimport numpy as np
import numpy as np
from enum import Enum

cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t
Expand Down
9 changes: 4 additions & 5 deletions searcharray/roaringish/search.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import numpy as np
# cimport snp_ops
# from snp_ops cimport _galloping_search, DTYPE_t, ALL_BITS
cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t, int64_t

from libc.stdlib cimport malloc, free
from searcharray.roaringish.snp_ops cimport DTYPE_t

cdef DTYPE_t ALL_BITS = 0xFFFFFFFFFFFFFFFF
cdef void _binary_search(DTYPE_t[:] array,
Expand All @@ -37,7 +35,7 @@ cdef void _binary_search(DTYPE_t[:] array,

if array[i_right] & mask < target:
idx_out[0] = i_right
return # indicate target value too large
return # indicate target value too large

while i_left + 1 < i_right:
idx_out[0] = (i_right + i_left) // 2 # midpoint
Expand All @@ -50,6 +48,7 @@ cdef void _binary_search(DTYPE_t[:] array,

idx_out[0] = i_right


# Python wrapper for binary search
def binary_search(np.ndarray[DTYPE_t, ndim=1] array,
DTYPE_t target,
Expand All @@ -61,7 +60,6 @@ def binary_search(np.ndarray[DTYPE_t, ndim=1] array,
return i, (array[i] & mask) == (target & mask)



cdef inline void _galloping_search(DTYPE_t[:] array,
DTYPE_t target,
DTYPE_t mask,
Expand Down Expand Up @@ -137,5 +135,6 @@ def galloping_search(np.ndarray[DTYPE_t, ndim=1] array,
_galloping_search(array, target, mask, &i, len)
return i, (array[i] & mask) == (target & mask)


def _u64(lst) -> np.ndarray:
return np.array(lst, dtype=np.uint64)
7 changes: 0 additions & 7 deletions searcharray/roaringish/spans.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
"""Utilities for computing spans for position aware search with slop > 0."""
cimport numpy as np
import numpy as np
from enum import Enum

cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t


# cdef extern from "stddef.h":
# Get ctz and clz
# int __builtin_ctzll(unsigned long long x)
# int __builtin_clzll(unsigned long long x)


cdef _count_spans_of_slop(DTYPE_t[:] posns, DTYPE_t slop):
# DTYPE_t mask = 0xFFFFFFFFFFFFFFFF
for posn in posns:
Expand Down
4 changes: 1 addition & 3 deletions searcharray/roaringish/unique.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import numpy as np
# cimport snp_ops
# from snp_ops cimport _galloping_search, DTYPE_t, ALL_BITS
cimport searcharray.roaringish.snp_ops
from searcharray.roaringish.snp_ops cimport DTYPE_t, int64_t
from searcharray.roaringish.snp_ops cimport DTYPE_t


cdef _scan_unique_naive(DTYPE_t[:] arr,
Expand Down Expand Up @@ -84,8 +84,6 @@ cdef _scan_unique_gallop(DTYPE_t[:] arr,
return result, result_ptr - &result[0]




cdef _scan_unique_shifted(DTYPE_t[:] arr,
DTYPE_t arr_len,
DTYPE_t rshift):
Expand Down

0 comments on commit 491e221

Please sign in to comment.