-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Clean Up C Warnings #31935
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
Clean Up C Warnings #31935
Changes from 4 commits
71bfa61
d17eae8
e2d8682
b169ac1
381feae
b4acaea
644055b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from cpython.buffer import PyBuffer_IsContiguous | ||
import cython | ||
from cython import Py_ssize_t | ||
|
||
|
@@ -32,6 +33,7 @@ cdef float64_t NaN = <float64_t>np.NaN | |
|
||
cdef int64_t NPY_NAT = get_nat() | ||
|
||
|
||
tiebreakers = { | ||
'average': TIEBREAK_AVERAGE, | ||
'min': TIEBREAK_MIN, | ||
|
@@ -1173,12 +1175,12 @@ ctypedef fused out_t: | |
|
||
@cython.boundscheck(False) | ||
@cython.wraparound(False) | ||
def diff_2d(ndarray[diff_t, ndim=2] arr, | ||
ndarray[out_t, ndim=2] out, | ||
def diff_2d(diff_t[:, :] arr, | ||
out_t[:, :] out, | ||
Py_ssize_t periods, int axis): | ||
cdef: | ||
Py_ssize_t i, j, sx, sy, start, stop | ||
bint f_contig = arr.flags.f_contiguous | ||
bint f_contig = PyBuffer_IsContiguous(arr, 'F') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neat. probably not worth the effort on our end, but itd be nice if cython automatically made this optimization There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh didn't look too much into the subsequent code; think could be cleaned up? |
||
|
||
# Disable for unsupported dtype combinations, | ||
# see https://github.com/cython/cython/issues/2646 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import cython | |
from libc.stdlib cimport malloc, free | ||
|
||
import numpy as np | ||
from numpy cimport uint8_t, uint32_t, uint64_t, import_array | ||
from numpy cimport ndarray, uint8_t, uint32_t, uint64_t, import_array | ||
import_array() | ||
|
||
from pandas._libs.util cimport is_nan | ||
|
@@ -15,7 +15,7 @@ DEF dROUNDS = 4 | |
|
||
|
||
@cython.boundscheck(False) | ||
def hash_object_array(object[:] arr, object key, object encoding='utf8'): | ||
def hash_object_array(ndarray[object] arr, object key, object encoding='utf8'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the impression that memory views used in tandem with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that makes sense. this would also raise ATM if we were to pass a read-only ndarray[object], so a worthwhile change |
||
""" | ||
Parameters | ||
---------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ cdef: | |
cdef inline int int_max(int a, int b): return a if a >= b else b | ||
cdef inline int int_min(int a, int b): return a if a <= b else b | ||
|
||
cdef inline bint is_monotonic_start_end_bounds( | ||
cdef bint is_monotonic_start_end_bounds( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, why can't this also be in-line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the cause of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a highly optimized path if u can show this doesn’t have any perf regressions then ok |
||
ndarray[int64_t, ndim=1] start, ndarray[int64_t, ndim=1] end | ||
): | ||
return is_monotonic(start, False)[0] and is_monotonic(end, False)[0] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm tried but seems to crash the compiler. Traceback below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, possibly a cython issue