-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
remove ctypedef class from lib.pyx #56018
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
|
Ah ok. I guess this makes it so dtype is not a Python object, so probably need to change that check around |
pandas/_libs/lib.pyx
Outdated
@@ -1961,7 +1945,7 @@ cdef class BytesValidator(Validator): | |||
return isinstance(value, bytes) | |||
|
|||
cdef bint is_array_typed(self) except -1: | |||
return issubclass(self.dtype.type, np.bytes_) | |||
return self.dtype.type == cnp.NPY_BYTE or self.dtype.type == cnp.NPY_UBYTE |
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.
cc @seberg is this the right way to check for bytes?
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, its NPY_STRING
(string is NPY_UNICODE
, leftover from python 2)
pandas/_libs/lib.pyx
Outdated
@@ -1944,7 +1928,7 @@ cdef class StringValidator(Validator): | |||
return isinstance(value, str) | |||
|
|||
cdef bint is_array_typed(self) except -1: | |||
return issubclass(self.dtype.type, np.str_) | |||
return cnp.PyDataType_ISSTRING(self.dtype) |
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.
So this is also wrong, ISSTRING
checks for bytes (NPY_STRING) OR unicode. You want == NPY_UNICODE
here if you use this.
Thanks @WillAyd |
nice! |
@jbrockmendel