Skip to content

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

Merged
merged 14 commits into from
Dec 2, 2018

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Nov 29, 2018

@pep8speaks
Copy link

Hello @charlesdong1991! Thanks for submitting the PR.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

A few things

  1. 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.
  2. Extension Arrays define a data fixture. You don't need to define one.
  3. Once you've written the test, pytest pandas/tests/extension/test_period.py::TestSetitem should fail, because of the bug from the original issue.

@TomAugspurger TomAugspurger added Testing pandas testing functions or related to the test suite Period Period data type labels Nov 29, 2018
@TomAugspurger
Copy link
Contributor

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 PeriodArray.__setitem__ to fix the bug. Make sense?

@charlesdong1991
Copy link
Member Author

thank you very much @TomAugspurger ! this time it should work!

@charlesdong1991 charlesdong1991 changed the title pytest for slice type in setitem BUG/TST: PeriodArray.__setitem__ with slice and list-like value Nov 29, 2018
@TomAugspurger
Copy link
Contributor

@charlesdong1991
Copy link
Member Author

HI, @TomAugspurger , ehh, this Flaky error appears again... Is it because my changes didn't pass the hinting test?

@codecov
Copy link

codecov bot commented Nov 30, 2018

Codecov Report

Merging #23991 into master will decrease coverage by 49.86%.
The diff coverage is 0%.

Impacted file tree graph

@@             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
Flag Coverage Δ
#multiple ?
#single 42.44% <0%> (+0.02%) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/period.py 37.02% <0%> (-61.42%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/core/categorical.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-97.64%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-95.46%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.17%) ⬇️
pandas/io/sas/sas_xport.py 0% <0%> (-90.24%) ⬇️
... and 120 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43b2dab...6c9702e. Read the comment docs.

@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Dec 1, 2018
@@ -147,7 +148,16 @@ class TestReshaping(BasePeriodTests, base.BaseReshapingTests):


class TestSetitem(BasePeriodTests, base.BaseSetitemTests):
pass

def test_setitem_slice_mismatch_length_raises(self, data):
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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):

Copy link
Contributor

Choose a reason for hiding this comment

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

And this.

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.

needs a whatsnew entry

@jreback jreback merged commit d967aef into pandas-dev:master Dec 2, 2018
@jreback
Copy link
Contributor

jreback commented Dec 2, 2018

thanks @charlesdong1991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG/TST: PeriodArray.__setitem__ with slice and list-like value fails
4 participants