Skip to content

BLD: fix build warnings #26757

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

Merged
merged 8 commits into from
Jun 12, 2019
3 changes: 2 additions & 1 deletion pandas/_libs/join.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def left_outer_join(const int64_t[:] left, const int64_t[:] right,
right_indexer = _get_result_indexer(right_sorter, right_indexer)

if not sort: # if not asked to sort, revert to original order
if len(left) == len(left_indexer):
# cast to avoid build warning GH#26757
if <Py_ssize_t>len(left) == len(left_indexer):
# no multiple matches for any row on the left
# this is a short-cut to avoid groupsort_indexer
# otherwise, the `else` path also works in this case
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/ops.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def vec_compare(object[:] left, object[:] right, object op):
ndarray[uint8_t, cast=True] result
int flag

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

Expand Down Expand Up @@ -220,7 +220,7 @@ def vec_binop(object[:] left, object[:] right, object op):
result : ndarray[object]
"""
cdef:
Py_ssize_t i, n = len(left)
size_t i, n = len(left)
object[:] result

if n != len(right):
Expand Down
13 changes: 9 additions & 4 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from io import StringIO
from libc.string cimport strchr

import cython
from cython import size_t, Py_ssize_t

from cpython cimport PyObject_Str, PyUnicode_Join

Expand Down Expand Up @@ -607,7 +608,8 @@ def try_parse_date_and_time(object[:] dates, object[:] times,
object[:] result

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

Expand Down Expand Up @@ -643,7 +645,8 @@ def try_parse_year_month_day(object[:] years, object[:] months,
object[:] result

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

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

n = len(years)
if (len(months) != n or len(days) != n or len(hours) != n or
len(minutes) != n or len(seconds) != n):
# Cast to avoid build warning see GH#26757
if (<Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n or
<Py_ssize_t>len(hours) != n or <Py_ssize_t>len(minutes) != n or
<Py_ssize_t>len(seconds) != n):
raise ValueError('Length of all datetime components must be equal')
result = np.empty(n, dtype='O')

Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/window.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ def ewmcov(float64_t[:] input_x, float64_t[:] input_y,
Py_ssize_t i, nobs
ndarray[float64_t] output

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

Expand Down
9 changes: 6 additions & 3 deletions pandas/io/sas/sas.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# cython: profile=False
# cython: boundscheck=False, initializedcheck=False
from cython import Py_ssize_t

import numpy as np
import pandas.io.sas.sas_constants as const
Expand All @@ -18,8 +19,9 @@ cdef const uint8_t[:] rle_decompress(int result_length,
cdef:
uint8_t control_byte, x
uint8_t[:] result = np.zeros(result_length, np.uint8)
int rpos = 0, ipos = 0, length = len(inbuff)
int rpos = 0
int i, nbytes, end_of_first_byte
Py_ssize_t ipos = 0, length = len(inbuff)

while ipos < length:
control_byte = inbuff[ipos] & 0xF0
Expand Down Expand Up @@ -123,12 +125,13 @@ cdef const uint8_t[:] rdc_decompress(int result_length,
cdef:
uint8_t cmd
uint16_t ctrl_bits, ctrl_mask = 0, ofs, cnt
int ipos = 0, rpos = 0, k
int rpos = 0, k
uint8_t[:] outbuff = np.zeros(result_length, dtype=np.uint8)
Py_ssize_t ipos = 0, length = len(inbuff)

ii = -1

while ipos < len(inbuff):
while ipos < length:
ii += 1
ctrl_mask = ctrl_mask >> 1
if ctrl_mask == 0:
Expand Down