Skip to content

TST: expand tests for ExtensionArray setitem with nullable arrays #31741

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

Merged
merged 9 commits into from
Feb 13, 2020

Conversation

jorisvandenbossche
Copy link
Member

Follow-up on #31484 to add some more test cases (eg also test the validation done in the check_array_indexer (wrong length, missing values), as well for nullable integer arrays), similarly to the tests I added for __getitem__.

cc @charlesdong1991

@jorisvandenbossche jorisvandenbossche added Testing pandas testing functions or related to the test suite Indexing Related to indexing on series/frames, not to indexes themselves ExtensionArray Extending pandas with custom dtypes or arrays. labels Feb 6, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1 milestone Feb 6, 2020
Copy link
Member

@charlesdong1991 charlesdong1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!! Thanks for adding tests for it! @jorisvandenbossche

if box_in_series:
data = pd.Series(data)

with pytest.raises(IndexError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if an error message should be matched here and below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added part of the message

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comment, pls rebase as I think we merged something that might impact this (or maybe its open still, the string setitem change).

@pytest.mark.parametrize(
"idx",
[[0, 1, 2], pd.array([0, 1, 2], dtype="Int64"), np.array([0, 1, 2])],
ids=["list", "integer-array", "numpy-array"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labels should be: extension-integer-array, numpy-integer-array to be more informative

@@ -93,6 +93,90 @@ def test_setitem_iloc_scalar_multiple_homogoneous(self, data):
df.iloc[10, 1] = data[1]
assert df.loc[10, "B"] == data[1]

@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about adding a new class here; these are specifically for setitem_mask (could be a followon)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about adding a new class here; these are specifically for setitem_mask (could be a followon)

In general, changing names is annoying for downstream consumers of those tests (this are the base extension tests), so not worth here I think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I don't buy your argument, these are experimental features where we actually to expand test coverage. its going to happen (but ok for now)

@jbrockmendel
Copy link
Member

needs rebase

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -93,6 +93,90 @@ def test_setitem_iloc_scalar_multiple_homogoneous(self, data):
df.iloc[10, 1] = data[1]
assert df.loc[10, "B"] == data[1]

@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I don't buy your argument, these are experimental features where we actually to expand test coverage. its going to happen (but ok for now)

@TomAugspurger TomAugspurger merged commit 95b0e14 into pandas-dev:master Feb 13, 2020
@jorisvandenbossche jorisvandenbossche deleted the setitem-tests branch February 13, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants