Skip to content

BLD: fix some build warnings #29271

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 5 commits into from
Oct 30, 2019
Merged
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
81 changes: 41 additions & 40 deletions pandas/_libs/algos_common_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,55 @@ ctypedef fused out_t:
def diff_2d(ndarray[diff_t, ndim=2] arr,
ndarray[out_t, ndim=2] out,
Py_ssize_t periods, int axis):
cdef:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all you did was move this and not change conditions below but lmk if I am misreading

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cdef here got moved up a few lines and the meat of the function got indented with an else: to avoid unreachable-code warnings

Py_ssize_t i, j, sx, sy

# Disable for unsupported dtype combinations,
# see https://github.com/cython/cython/issues/2646
if out_t is float32_t:
if not (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t):
raise NotImplementedError
if (out_t is float32_t
and not (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t)):
raise NotImplementedError
elif (out_t is float64_t
and (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t)):
raise NotImplementedError
else:
if (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t):
raise NotImplementedError

cdef:
Py_ssize_t i, j, sx, sy

sx, sy = (<object>arr).shape
if arr.flags.f_contiguous:
if axis == 0:
if periods >= 0:
start, stop = periods, sx
# We put this inside an indented else block to avoid cython build
# warnings about unreachable code
sx, sy = (<object>arr).shape
if arr.flags.f_contiguous:
if axis == 0:
if periods >= 0:
start, stop = periods, sx
else:
start, stop = 0, sx + periods
for j in range(sy):
for i in range(start, stop):
out[i, j] = arr[i, j] - arr[i - periods, j]
else:
start, stop = 0, sx + periods
for j in range(sy):
for i in range(start, stop):
out[i, j] = arr[i, j] - arr[i - periods, j]
if periods >= 0:
start, stop = periods, sy
else:
start, stop = 0, sy + periods
for j in range(start, stop):
for i in range(sx):
out[i, j] = arr[i, j] - arr[i, j - periods]
else:
if periods >= 0:
start, stop = periods, sy
if axis == 0:
if periods >= 0:
start, stop = periods, sx
else:
start, stop = 0, sx + periods
for i in range(start, stop):
for j in range(sy):
out[i, j] = arr[i, j] - arr[i - periods, j]
else:
start, stop = 0, sy + periods
for j in range(start, stop):
if periods >= 0:
start, stop = periods, sy
else:
start, stop = 0, sy + periods
for i in range(sx):
out[i, j] = arr[i, j] - arr[i, j - periods]
else:
if axis == 0:
if periods >= 0:
start, stop = periods, sx
else:
start, stop = 0, sx + periods
for i in range(start, stop):
for j in range(sy):
out[i, j] = arr[i, j] - arr[i - periods, j]
else:
if periods >= 0:
start, stop = periods, sy
else:
start, stop = 0, sy + periods
for i in range(sx):
for j in range(start, stop):
out[i, j] = arr[i, j] - arr[i, j - periods]
for j in range(start, stop):
out[i, j] = arr[i, j] - arr[i, j - periods]


# ----------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ cdef inline bint _treat_as_na(rank_t val, bint is_datetimelike) nogil:

elif rank_t is int64_t:
return is_datetimelike and val == NPY_NAT
elif rank_t is uint64_t:
# There is no NA value for uint64
return False
else:
return val != val

Expand Down Expand Up @@ -1278,7 +1281,8 @@ def group_max(groupby_t[:, :] out,
if groupby_t is uint64_t:
runtime_error = True
break
out[i, j] = nan_val
else:
out[i, j] = nan_val
else:
out[i, j] = maxx[i, j]

Expand Down Expand Up @@ -1349,7 +1353,8 @@ def group_min(groupby_t[:, :] out,
if groupby_t is uint64_t:
runtime_error = True
break
out[i, j] = nan_val
else:
out[i, j] = nan_val
else:
out[i, j] = minx[i, j]

Expand Down
3 changes: 2 additions & 1 deletion pandas/io/msgpack/_packer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ cdef class Packer:
continue
else:
raise TypeError("can't serialize {thing!r}".format(thing=o))
return ret
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really? cython doesn't understand the else here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its clang giving a "code will never be executed" warning

return ret

cpdef pack(self, object obj):
cdef int ret
Expand Down