-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/TST: PeriodArray.__setitem__ with slice and list-like value #23991
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
BUG/TST: PeriodArray.__setitem__ with slice and list-like value #23991
Conversation
Hello @charlesdong1991! Thanks for submitting the PR.
|
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.
A few things
- The tests should be written as base extension tests, see http://pandas-docs.github.io/pandas-docs-travis/extending.html#testing-extension-arrays. These can go in tests/extension/base/setitem.py::BaseSetitemTests.
- Extension Arrays define a
data
fixture. You don't need to define one. - Once you've written the test,
pytest pandas/tests/extension/test_period.py::TestSetitem
should fail, because of the bug from the original issue.
Great, your test has successfully raised the original bug: https://travis-ci.org/pandas-dev/pandas/jobs/461252693#L2863 So now you'll need to make the changes to |
thank you very much @TomAugspurger ! this time it should work! |
HI, @TomAugspurger , ehh, this Flaky error appears again... Is it because my changes didn't pass the hinting test? |
Codecov Report
@@ Coverage Diff @@
## master #23991 +/- ##
===========================================
- Coverage 92.31% 42.44% -49.87%
===========================================
Files 161 161
Lines 51513 51562 +49
===========================================
- Hits 47554 21888 -25666
- Misses 3959 29674 +25715
Continue to review full report at Codecov.
|
@@ -147,7 +148,16 @@ class TestReshaping(BasePeriodTests, base.BaseReshapingTests): | |||
|
|||
|
|||
class TestSetitem(BasePeriodTests, base.BaseSetitemTests): | |||
pass | |||
|
|||
def test_setitem_slice_mismatch_length_raises(self, data): |
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.
Ahh, just noticed. This should be on the base class BaseSetitemTests. Then all the subclasses will be tested, including period.
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.
Same for the other test.
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.
ahh, i see, yeah, makes sense!! thx!
@@ -8,6 +8,7 @@ | |||
import pandas as pd | |||
from pandas.core.arrays import PeriodArray | |||
from pandas.tests.extension import base | |||
import pandas.util.testing as tm |
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.
Probably delete this
@@ -147,6 +148,7 @@ class TestReshaping(BasePeriodTests, base.BaseReshapingTests): | |||
|
|||
|
|||
class TestSetitem(BasePeriodTests, base.BaseSetitemTests): | |||
|
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.
And this.
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.
needs a whatsnew entry
thanks @charlesdong1991 |
git diff upstream/master -u -- "*.py" | flake8 --diff