Skip to content

ERR: lib.is_xyz_array errors, some ignored #18064

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

Closed
jbrockmendel opened this issue Nov 1, 2017 · 1 comment · Fixed by #18252
Closed

ERR: lib.is_xyz_array errors, some ignored #18064

jbrockmendel opened this issue Nov 1, 2017 · 1 comment · Fixed by #18252
Labels
Compat pandas objects compatability with Numpy or Python functions Testing pandas testing functions or related to the test suite
Milestone

Comments

@jbrockmendel
Copy link
Member

See #18054

In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: from pandas._libs import lib
In [4]: values = np.array([2, 1, 1, 2], dtype=np.int64)    # The relevant arg in TestMergeCategorical.test_other_columns
In [5]: lib.is_bool_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
Out[5]: False

In [7]: lib.is_bool_array(values.astype(bool))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Does not understand character buffer dtype format string ('?')
Exception ValueError: "Does not understand character buffer dtype format string ('?')" in 'pandas._libs.lib.is_bool_array' ignored
Out[7]: False

In [8]: lib.is_datetime_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-a5b7fc4b6701> in <module>()
----> 1 lib.is_datetime_array(values)

pandas/_libs/src/inference.pyx in pandas._libs.lib.is_datetime_array()

ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'

In [9]: lib.is_datetime_array(values.astype('datetime64[ns]'))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-0c109014e134> in <module>()
----> 1 lib.is_datetime_array(values.astype('datetime64[ns]'))

pandas/_libs/src/inference.pyx in pandas._libs.lib.is_datetime_array()

ValueError: cannot include dtype 'M' in a buffer

In [11]: lib.is_integer_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_integer_array' ignored
Out[11]: False

In [14]: lib.is_bytes_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bytes_array' ignored
Out[14]: False

In [15]: lib.is_bytes_array(values.astype(bytes))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got a string
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got a string" in 'pandas._libs.lib.is_bytes_array' ignored
Out[15]: False

The closest thing to good news is that most of these functions are not used very much (at least not outside of inference.pyx, where maybe they behave better because of [mumble]). Four of them are explicitly tested in tests.dtypes.test_inference (is_datetime_array, is_datetime64_array, is_timdelta_array, is_timedelta64_array). Other than that, its just two uses of is_bool_array (core.common, core.internals) and one of is_datetime_array (in core.indexes.base)

@gfyoung gfyoung added the Testing pandas testing functions or related to the test suite label Nov 1, 2017
@jreback jreback changed the title lib.is_xyz_array errors, some ignored ERR: lib.is_xyz_array errors, some ignored Nov 2, 2017
@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Nov 2, 2017
@jreback
Copy link
Contributor

jreback commented Nov 2, 2017

this fixes

(pandas) bash-3.2$ git diff
diff --git a/pandas/_libs/src/inference.pyx b/pandas/_libs/src/inference.pyx
index 5d550148b..7dcb94b14 100644
--- a/pandas/_libs/src/inference.pyx
+++ b/pandas/_libs/src/inference.pyx
@@ -612,7 +612,7 @@ cdef class Validator:
         self.dtype = dtype
         self.skipna = skipna
 
-    cdef bint validate(self, object[:] values) except -1:
+    cdef bint validate(self, ndarray values) except -1:
         if not self.n:
             return False
 
@@ -628,7 +628,7 @@ cdef class Validator:
 
     @cython.wraparound(False)
     @cython.boundscheck(False)
-    cdef bint _validate(self, object[:] values) except -1:
+    cdef bint _validate(self, ndarray values) except -1:
         cdef:
             Py_ssize_t i
             Py_ssize_t n = self.n
@@ -641,7 +641,7 @@ cdef class Validator:
 
     @cython.wraparound(False)
     @cython.boundscheck(False)
-    cdef bint _validate_skipna(self, object[:] values) except -1:
+    cdef bint _validate_skipna(self, ndarray values) except -1:
         cdef:
             Py_ssize_t i
             Py_ssize_t n = self.n

@jreback jreback added this to the 0.21.1 milestone Nov 2, 2017
jreback added a commit to jreback/pandas that referenced this issue Nov 12, 2017
jreback added a commit to jreback/pandas that referenced this issue Nov 12, 2017
@jreback jreback modified the milestones: 0.21.1, 0.22.0 Nov 12, 2017
jreback added a commit to jreback/pandas that referenced this issue Nov 13, 2017
jreback added a commit to jreback/pandas that referenced this issue Nov 13, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this issue Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants