-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: Verify operators with IntegerArray and list-likes (22606) #35987
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 7 commits
60982b4
71d3011
02dcea9
f657d21
bc7be38
04706e1
4ef23fc
7770147
73a95c5
f5fba51
0afc206
99685e5
09c38b5
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import pytest | ||
|
||
import pandas as pd | ||
from pandas import Index, Series, Timedelta, TimedeltaIndex | ||
from pandas import Index, Series, Timedelta, TimedeltaIndex, array | ||
import pandas._testing as tm | ||
from pandas.core import ops | ||
|
||
|
@@ -1297,3 +1297,26 @@ def test_dataframe_div_silenced(): | |
) | ||
with tm.assert_produces_warning(None): | ||
pdf1.div(pdf2, fill_value=0) | ||
|
||
|
||
@pytest.fixture(params=[Index, Series, tm.to_array]) | ||
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. i would put this near the top 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. Done |
||
def box_pandas_1d_array(request): | ||
""" | ||
Fixture to test behavior for Index, Series and tm.to_array classes | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, expected", [([0, 1, 2], [0, 2, 4])], | ||
) | ||
def test_integer_array_add_list_like(box_pandas_1d_array, box_1d_array, data, expected): | ||
# GH22606 Verify operators with IntegerArray and list-likes | ||
|
||
arr = array(data, dtype="Int64") | ||
container = box_pandas_1d_array(arr) | ||
left = container + box_1d_array(data) | ||
right = box_1d_array(data) + container | ||
|
||
assert left.tolist() == expected | ||
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. does this also check that the interior elements are the same e.g. that they are python ints and NOT np.int64 for example? cc @jbrockmendel 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. This does not check if interior elements are the same. Think this can be solved by performing comparison on Converted output to |
||
assert right.tolist() == expected |
Uh oh!
There was an error while loading. Please reload this page.