Skip to content

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

Merged
merged 6 commits into from
Nov 17, 2023
Merged

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Nov 17, 2023

@jbrockmendel
Copy link
Member

E TypeError: issubclass() arg 1 must be a class matches what i got locally from the same approach

@WillAyd
Copy link
Member Author

WillAyd commented Nov 17, 2023

Ah ok. I guess this makes it so dtype is not a Python object, so probably need to change that check around

@mroeschke mroeschke added the Internals Related to non-user accessible pandas implementation label Nov 17, 2023
@@ -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
Copy link
Member

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?

Copy link
Contributor

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)

@@ -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)
Copy link
Contributor

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.

@mroeschke mroeschke added this to the 2.2 milestone Nov 17, 2023
@mroeschke mroeschke merged commit c95e943 into pandas-dev:main Nov 17, 2023
@mroeschke
Copy link
Member

Thanks @WillAyd

@jbrockmendel
Copy link
Member

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants