Skip to content

BLD: Fix sparse warnings #13942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pandas/src/sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ cdef class IntIndex(SparseIndex):
return IntIndex(self.length, new_indices)

@cython.wraparound(False)
cpdef int lookup(self, Py_ssize_t index):
cpdef int32_t lookup(self, Py_ssize_t index):
"""
Return the internal location if value exists on given index.
Return -1 otherwise.
"""
cdef:
Py_ssize_t res
int32_t res
ndarray[int32_t, ndim=1] inds

inds = self.indices
Expand Down Expand Up @@ -290,7 +290,7 @@ cdef class BlockIndex(SparseIndex):
----------
"""
cdef readonly:
Py_ssize_t nblocks, npoints, length
int32_t nblocks, npoints, length
ndarray blocs, blengths

cdef:
Expand All @@ -308,7 +308,7 @@ cdef class BlockIndex(SparseIndex):
self.lenbuf = <int32_t*> self.blengths.data

self.length = length
self.nblocks = len(self.blocs)
self.nblocks = np.int32(len(self.blocs))
self.npoints = self.blengths.sum()

# self.block_start = blocs
Expand Down Expand Up @@ -381,7 +381,7 @@ cdef class BlockIndex(SparseIndex):

def to_int_index(self):
cdef:
Py_ssize_t i = 0, j, b
int32_t i = 0, j, b
int32_t offset
ndarray[int32_t, ndim=1] indices

Expand Down Expand Up @@ -498,7 +498,7 @@ cdef class BlockIndex(SparseIndex):
"""
return BlockUnion(self, y.to_block_index()).result

cpdef int lookup(self, Py_ssize_t index):
cpdef Py_ssize_t lookup(self, Py_ssize_t index):
"""
Return the internal location if value exists on given index.
Return -1 otherwise.
Expand Down
56 changes: 28 additions & 28 deletions pandas/src/sparse_op_helper.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cdef inline tuple block_op_add_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -282,7 +282,7 @@ cdef inline tuple block_op_add_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -477,7 +477,7 @@ cdef inline tuple block_op_sub_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -672,7 +672,7 @@ cdef inline tuple block_op_sub_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -867,7 +867,7 @@ cdef inline tuple block_op_mul_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -1062,7 +1062,7 @@ cdef inline tuple block_op_mul_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -1257,7 +1257,7 @@ cdef inline tuple block_op_div_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -1452,7 +1452,7 @@ cdef inline tuple block_op_div_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -1647,7 +1647,7 @@ cdef inline tuple block_op_mod_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -1842,7 +1842,7 @@ cdef inline tuple block_op_mod_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -2037,7 +2037,7 @@ cdef inline tuple block_op_truediv_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -2232,7 +2232,7 @@ cdef inline tuple block_op_truediv_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -2427,7 +2427,7 @@ cdef inline tuple block_op_floordiv_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -2622,7 +2622,7 @@ cdef inline tuple block_op_floordiv_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -2817,7 +2817,7 @@ cdef inline tuple block_op_pow_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3012,7 +3012,7 @@ cdef inline tuple block_op_pow_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3207,7 +3207,7 @@ cdef inline tuple block_op_eq_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3402,7 +3402,7 @@ cdef inline tuple block_op_eq_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3597,7 +3597,7 @@ cdef inline tuple block_op_ne_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3792,7 +3792,7 @@ cdef inline tuple block_op_ne_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -3987,7 +3987,7 @@ cdef inline tuple block_op_lt_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -4182,7 +4182,7 @@ cdef inline tuple block_op_lt_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -4377,7 +4377,7 @@ cdef inline tuple block_op_gt_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -4572,7 +4572,7 @@ cdef inline tuple block_op_gt_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -4767,7 +4767,7 @@ cdef inline tuple block_op_le_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -4962,7 +4962,7 @@ cdef inline tuple block_op_le_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -5157,7 +5157,7 @@ cdef inline tuple block_op_ge_float64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down Expand Up @@ -5352,7 +5352,7 @@ cdef inline tuple block_op_ge_int64(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down
2 changes: 1 addition & 1 deletion pandas/src/sparse_op_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ cdef inline tuple block_op_{{opname}}_{{dtype}}(ndarray x_,
cdef:
BlockIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xbp = 0, ybp = 0 # block positions
int32_t xbp = 0, ybp = 0 # block positions
int32_t xloc, yloc
Py_ssize_t xblock = 0, yblock = 0 # block numbers

Expand Down