-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
STY: Boolean values for bint variables #33009
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
STY: Boolean values for bint variables #33009
Conversation
@@ -692,7 +692,7 @@ def clean_index_list(obj: list): | |||
@cython.boundscheck(False) | |||
@cython.wraparound(False) | |||
def generate_bins_dt64(ndarray[int64_t] values, const int64_t[:] binner, |
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.
can values here be `const int64_t[:]``
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, cython raises errors
[1/1] Cythonizing pandas/_libs/lib.pyx
Error compiling Cython file:
------------------------------------------------------------
...
int64_t l_bin, r_bin, nat_count
bint right_closed = closed == 'right'
nat_count = 0
if hasnans:
mask = values == NPY_NAT
^
------------------------------------------------------------
pandas/_libs/lib.pyx:707:22: Invalid types for '==' (const int64_t[:], int64_t)
warning: pandas/_libs/lib.pyx:709:24: Index should be typed for more efficient access
Error compiling Cython file:
------------------------------------------------------------
...
nat_count = 0
if hasnans:
mask = values == NPY_NAT
nat_count = np.sum(mask)
values = values[~mask]
^
------------------------------------------------------------
pandas/_libs/lib.pyx:709:23: Cannot convert 'int64_t' to memoryviewslice
Traceback (most recent call last):
File "setup.py", line 791, in <module>
setup_package()
File "setup.py", line 761, in setup_package
ext_modules=maybe_cythonize(extensions, compiler_directives=directives),
File "setup.py", line 534, in maybe_cythonize
return cythonize(extensions, *args, **kwargs)
File "/home/bummy/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1102, in cythonize
cythonize_one(*args)
File "/home/bummy/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1225, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pandas/_libs/lib.pyx
Same comment as #33008 - a lot of the Cython stuff is performance critical so really want to be sure |
can you just verify that the same code is generated here as well, otherwise lgtm. |
@jreback I checked and the generated C code, is identical. (Only diff is in the comments) |
thanks @MomIsBestFriend I suppose if we had a code check to catch this would be great, but might not be so easy to check |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff