-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
[BLD] Fix remaining compile-time warnings #21940
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
Conversation
hmm, seems to be failing. but also there are many more checks, e.g. in windows.pyx (e.g. the error which @chris-b1 is working on ). is there a reason not to fix those too? |
further I think adding a lint.sh check might make sense here (to avoid adding these back thru time). IOW we should have 1 and only 1 way to compare nans in cython, sure documentation helps...b.ut |
Yep, will try to track this down...
Yah, I declared initial victory and opened the PR once I got to zero-warnings in py27 on OSX.
Not sure how this would work, but worth a shot. Seems like there might be a compiler flag to set in setup.py to turn warnings into errors.
This doesn't get rid of all the |
ok, maybe we have 2 nicely named functions thens? |
Codecov Report
@@ Coverage Diff @@
## master #21940 +/- ##
=======================================
Coverage 91.96% 91.96%
=======================================
Files 166 166
Lines 50329 50329
=======================================
Hits 46287 46287
Misses 4042 4042
Continue to review full report at Codecov.
|
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.
lgtm. minor comments.
@@ -389,7 +389,11 @@ cdef class {{name}}HashTable(HashTable): | |||
for i in range(n): | |||
val = values[i] | |||
|
|||
{{if dtype == 'float64'}} |
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.
maybe .startswith
@@ -271,7 +271,12 @@ def ismember_{{dtype}}({{scalar}}[:] arr, {{scalar}}[:] values, bint hasnans=0): | |||
if k != table.n_buckets: | |||
result[i] = 1 | |||
else: | |||
{{if dtype == 'float64'}} |
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.
same
@@ -28,6 +28,15 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt | |||
#define PyInt_AsLong PyLong_AsLong | |||
#endif | |||
|
|||
// Silence "implicit declaration of function" warnings |
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.
shouldn't these be in the .h?
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.
No, that would make them public. This particular fix will be superseded by #21962 anyway.
is there any perf diff? (maybe just test some groupby asvs) |
@jbrockmendel - assuming you're not on Windows, could you try this benchmark? # equality check
In [28]: %timeit isnan_inline(a)
21.6 ms ± 1.26 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
# from numpy -> from math.h
In [29]: %timeit isnan_crt(a)
45.2 ms ± 279 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) Using the math.h isnan ends up being a fair bit slower on Windows b/c the call can't be inlined - I'm going to guess they are about the same for you? |
OSX, py3.7:
Ubuntu, py2.7:
Pretty indistinguishable on these platforms. Which implementation do you suggest we go with? See also: cython/cython#550 |
No perceptible change on Linux.
|
Probably need to be something like this to pick the most efficient. #if defined(_MSC_VER)
#define pd_isnan(x) ((x) != (x))
#else
#define pd_isnan(x) npy_isnan(x)
#endif |
Are you confident that is the "correct" answer? If so I'll change it and we're done. Otherwise, I'm inclined to close this PR as not being worth the hassle. |
I'm pretty sure (hah), that's right, but might agree with your instinct to leave this alone. |
OK. I'm going to close this, some of the warnings will be fixed by #21962, and I'll follow up with a PR to fix the casting-comparison warnings. |
With the exception of Numpy-Deprecated-API-1.7 warnings that any cython code produces, this fixes all remaining compiler warnings (... on py27, there's still a whole mess of them in py37).
Based on a little bit of profiling it looked like
npy_isnan(x)
gives a 40% perf improvement overx != x
. But profiling is hard, so who knows. In the comment where npy_nan is imported there is a link to a discussion about it.