Skip to content

catch Exception currently ignored #18054

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

Conversation

jbrockmendel
Copy link
Member

From Travis log: https://travis-ci.org/pandas-dev/pandas/jobs/295371293

.ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
.................ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
.ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'

This just catches that error so we can track it down.

@jbrockmendel
Copy link
Member Author

Poking at this a bit, the main takeaway so far is that the lib.is_xyz_array funcs need attention. Every case I've tried either raises a ValueError or gives a warning about an ignored ValueError before returning False.

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)

I'm hereby handing this off to the next person in line.

@gfyoung
Copy link
Member

gfyoung commented Nov 1, 2017

I'm hereby handing this off to the next person in line.

@jbrockmendel : IIUC, I think you should create an issue for this. Then I'll close the PR.

@gfyoung gfyoung added Internals Related to non-user accessible pandas implementation Testing pandas testing functions or related to the test suite labels Nov 1, 2017
@jbrockmendel jbrockmendel deleted the bool_array_errors branch December 8, 2017 19:39
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 Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants