-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add IntegerArray.__arrow_array__ for custom conversion to Arrow #28368
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from distutils.version import LooseVersion | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
|
@@ -19,6 +21,13 @@ | |
from pandas.tests.extension.base import BaseOpsUtil | ||
import pandas.util.testing as tm | ||
|
||
try: | ||
import pyarrow | ||
|
||
_PYARROW_INSTALLED = True | ||
except ImportError: | ||
_PYARROW_INSTALLED = False | ||
|
||
|
||
def make_data(): | ||
return list(range(8)) + [np.nan] + list(range(10, 98)) + [np.nan] + [99, 100] | ||
|
@@ -817,6 +826,20 @@ def test_ufunc_reduce_raises(values): | |
np.add.reduce(a) | ||
|
||
|
||
@pytest.mark.skipif( | ||
not _PYARROW_INSTALLED | ||
or _PYARROW_INSTALLED | ||
and LooseVersion(pyarrow.__version__) < LooseVersion("0.14.1.dev"), | ||
reason="pyarrow >= 0.15.0 required", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a particular reason for this requiring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is to be able to test it with arrow master locally. We can also wait until final 0.15.0 is released, and then I can change this check. But in practice it gives the same. |
||
) | ||
def test_arrow_array(data): | ||
import pyarrow as pa | ||
|
||
arr = pa.array(data) | ||
expected = pa.array(list(data), type=data.dtype.name.lower(), from_pandas=True) | ||
assert arr.equals(expected) | ||
|
||
|
||
# TODO(jreback) - these need testing / are broken | ||
|
||
# shift | ||
|
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.
You should be able to replace this with
compat._optional.import_optional_dependency
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.
I've never used
compat._optional.import_optional_dependency
before, so correct if me if I am wrong: it seems that method is typically used in the code (not tests) and is meant to raise an error or return the module (so eg in functions that use an optional dependency).So I would still need to catch the error, I think? In which case I am not sure it is necessarily clearer, or deduplicating code.
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.
Ah, I see it has a
raise_on_missing=False
option. But in theory I then also need to specifyon_version='ignore'
to not have an error or warning on old pyarrow versions.But, I can maybe actually replace it with
pytest.importorskip
inside the test, which seems better suited for test cases. That should also simplify it.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.
Or, we have our own wrapper around that as
td.skip_if_no
decoratorThere 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.
OK, simplified it with
td.skip_if_no
. I was actually already using it in the other test as well .. (so I was being a bit blind :-))