Skip to content

Commit 429078b

Browse files
jbrockmendeljreback
authored andcommitted
BLD: fix build warnings (#26757)
1 parent 487e4c2 commit 429078b

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

pandas/_libs/join.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def left_outer_join(const int64_t[:] left, const int64_t[:] right,
119119
right_indexer = _get_result_indexer(right_sorter, right_indexer)
120120

121121
if not sort: # if not asked to sort, revert to original order
122-
if len(left) == len(left_indexer):
122+
# cast to avoid build warning GH#26757
123+
if <Py_ssize_t>len(left) == len(left_indexer):
123124
# no multiple matches for any row on the left
124125
# this is a short-cut to avoid groupsort_indexer
125126
# otherwise, the `else` path also works in this case

pandas/_libs/ops.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def vec_compare(object[:] left, object[:] right, object op):
122122
ndarray[uint8_t, cast=True] result
123123
int flag
124124

125-
if n != len(right):
125+
if n != <Py_ssize_t>len(right):
126126
raise ValueError('Arrays were different lengths: {n} vs {nright}'
127127
.format(n=n, nright=len(right)))
128128

@@ -223,7 +223,7 @@ def vec_binop(object[:] left, object[:] right, object op):
223223
Py_ssize_t i, n = len(left)
224224
object[:] result
225225

226-
if n != len(right):
226+
if n != <Py_ssize_t>len(right):
227227
raise ValueError('Arrays were different lengths: {n} vs {nright}'
228228
.format(n=n, nright=len(right)))
229229

pandas/_libs/tslibs/parsing.pyx

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from io import StringIO
88
from libc.string cimport strchr
99

1010
import cython
11+
from cython import Py_ssize_t
1112

1213
from cpython cimport PyObject_Str, PyUnicode_Join
1314

@@ -607,7 +608,8 @@ def try_parse_date_and_time(object[:] dates, object[:] times,
607608
object[:] result
608609

609610
n = len(dates)
610-
if len(times) != n:
611+
# Cast to avoid build warning see GH#26757
612+
if <Py_ssize_t>len(times) != n:
611613
raise ValueError('Length of dates and times must be equal')
612614
result = np.empty(n, dtype='O')
613615

@@ -643,7 +645,8 @@ def try_parse_year_month_day(object[:] years, object[:] months,
643645
object[:] result
644646

645647
n = len(years)
646-
if len(months) != n or len(days) != n:
648+
# Cast to avoid build warning see GH#26757
649+
if <Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n:
647650
raise ValueError('Length of years/months/days must all be equal')
648651
result = np.empty(n, dtype='O')
649652

@@ -668,8 +671,10 @@ def try_parse_datetime_components(object[:] years,
668671
double micros
669672

670673
n = len(years)
671-
if (len(months) != n or len(days) != n or len(hours) != n or
672-
len(minutes) != n or len(seconds) != n):
674+
# Cast to avoid build warning see GH#26757
675+
if (<Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n or
676+
<Py_ssize_t>len(hours) != n or <Py_ssize_t>len(minutes) != n or
677+
<Py_ssize_t>len(seconds) != n):
673678
raise ValueError('Length of all datetime components must be equal')
674679
result = np.empty(n, dtype='O')
675680

pandas/_libs/window.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ def ewmcov(float64_t[:] input_x, float64_t[:] input_y,
18271827
Py_ssize_t i, nobs
18281828
ndarray[float64_t] output
18291829

1830-
if len(input_y) != N:
1830+
if <Py_ssize_t>len(input_y) != N:
18311831
raise ValueError("arrays are of different lengths "
18321832
"({N} and {len_y})".format(N=N, len_y=len(input_y)))
18331833

pandas/io/sas/sas.pyx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# cython: profile=False
22
# cython: boundscheck=False, initializedcheck=False
3+
from cython import Py_ssize_t
34

45
import numpy as np
56
import pandas.io.sas.sas_constants as const
@@ -18,8 +19,9 @@ cdef const uint8_t[:] rle_decompress(int result_length,
1819
cdef:
1920
uint8_t control_byte, x
2021
uint8_t[:] result = np.zeros(result_length, np.uint8)
21-
int rpos = 0, ipos = 0, length = len(inbuff)
22+
int rpos = 0
2223
int i, nbytes, end_of_first_byte
24+
Py_ssize_t ipos = 0, length = len(inbuff)
2325

2426
while ipos < length:
2527
control_byte = inbuff[ipos] & 0xF0
@@ -123,12 +125,13 @@ cdef const uint8_t[:] rdc_decompress(int result_length,
123125
cdef:
124126
uint8_t cmd
125127
uint16_t ctrl_bits, ctrl_mask = 0, ofs, cnt
126-
int ipos = 0, rpos = 0, k
128+
int rpos = 0, k
127129
uint8_t[:] outbuff = np.zeros(result_length, dtype=np.uint8)
130+
Py_ssize_t ipos = 0, length = len(inbuff)
128131

129132
ii = -1
130133

131-
while ipos < len(inbuff):
134+
while ipos < length:
132135
ii += 1
133136
ctrl_mask = ctrl_mask >> 1
134137
if ctrl_mask == 0:

0 commit comments

Comments
 (0)