-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642b01a
commit 518315c
Showing
3 changed files
with
325 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,38 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
# A set of Base EA tests that are know to not work for | ||
# the object-dtype PandasArray holding nested data. | ||
skips = { | ||
'TestCasting.test_astype_str', | ||
'TestConstructors.test_array_from_scalars', | ||
# tuple isn't instance of np.object | ||
'TestGetitem.test_getitem_scalar', | ||
# Can't pass tuples to _from_sequence | ||
'TestGetitem.test_take_series', | ||
# np.array shape inference | ||
'TestInterface.test_array_interface', | ||
# Can't construct expected. | ||
'TestMethods.test_unique', | ||
'TestMethods.test_combine_add', | ||
'TestMethods.test_shift_fill_value', | ||
'TestMethods.test_where_series', | ||
'TestMethods.test_repeat', | ||
# Can't hash ndarray[tuple] | ||
'TestMethods.test_hash_pandas_object_works', | ||
# Can't construct expected. | ||
'TestReshaping.test_merge', | ||
'TestReshaping.test_merge_on_extension_array', | ||
'TestReshaping.test_merge_on_extension_array_duplicates', | ||
|
||
# ndarray setting | ||
'TestSetitem.test_setitem_scalar_series', | ||
'TestSetitem.test_setitem_sequence', | ||
'TestSetitem.test_setitem_sequence_mismatched_length_raises', | ||
'TestSetitem.test_setitem_sequence_broadcasts', | ||
'TestSetitem.test_setitem_sequence_broadcasts', | ||
'TestSetitem.test_setitem_loc_scalar_mixed', | ||
'TestSetitem.test_setitem_iloc_scalar_mixed', | ||
'TestSetitem.test_setitem_loc_scalar_multiple_homogoneous', | ||
'TestSetitem.test_setitem_iloc_scalar_multiple_homogoneous', | ||
'TestSetitem.test_setitem_mask_broadcast', | ||
'TestSetitem.test_setitem_scalar_key_sequence_raise', | ||
|
||
# parsing differs. | ||
'TestParsing.test_EA_types', | ||
} | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
skip = pytest.mark.skip(reason="Skipping for nested data.") | ||
for item in items: | ||
# TODO: See if pytest has a better way to resolve the *value* | ||
# supplied to a fixture. Right now .keywords gets things | ||
# like 'object' or 'data-object'. | ||
parts = item.name.split("[") | ||
qualname = item.parent.obj.__class__.__name__ + '.' + item.obj.__name__ | ||
if (len(parts) > 1 and 'object' in item.name.split('[')[1] | ||
and qualname in skips): | ||
item.add_marker(skip) | ||
from pandas.core.arrays.numpy_ import PandasArray | ||
|
||
|
||
@pytest.fixture | ||
def allow_in_pandas(monkeypatch): | ||
""" | ||
A monkeypatch to tells pandas to let us in. | ||
By default, passing a PandasArray to an index / series / frame | ||
constructor will unbox that PandasArray to an ndarray, and treat | ||
it as a non-EA column. We don't want people using EAs without | ||
reason. | ||
The mechanism for this is a check against ABCPandasArray | ||
in each constructor. | ||
But, for testing, we need to allow them in pandas. So we patch | ||
the _typ of PandasArray, so that we evade the ABCPandasArray | ||
check. | ||
""" | ||
with monkeypatch.context() as m: | ||
m.setattr(PandasArray, '_typ', 'extension') | ||
yield | ||
|
||
|
||
@pytest.fixture | ||
def na_value(): | ||
return np.nan | ||
|
||
|
||
@pytest.fixture | ||
def na_cmp(): | ||
def cmp(a, b): | ||
return np.isnan(a) and np.isnan(b) | ||
return cmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.