-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Add base test for extensionarray setitem #23300 #23304
Add base test for extensionarray setitem #23300 #23304
Conversation
Hello @charlesdong1991! Thanks for submitting the PR.
|
def test_setitem_scalar(self, data, setter): | ||
arr = pd.Series(data) | ||
setter = getattr(arr, setter) | ||
def test_setitem_scalar(self, data, box, setter): |
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.
I think this will not work, since loc
and iloc
are only available on Series.
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.
changed.
thanks for the quick feedback!
Looks like the fixture name
You could rename it to FYI, you may want to run the tests locally for a faster feedback loop. |
d50715b
to
d92988c
Compare
pandas/conftest.py
Outdated
@@ -501,6 +501,12 @@ def mock(): | |||
return pytest.importorskip("mock") | |||
|
|||
|
|||
@pytest.fixture(params=[True, False]) | |||
def box_in_series(request): |
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.
put this in the extension conftest
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.
done, thanks!
looks good. @TomAugspurger IIRC on Sparse you were showing a warning on setitem (for perf)? is this tested ? |
Codecov Report
@@ Coverage Diff @@
## master #23304 +/- ##
=========================================
Coverage ? 92.23%
=========================================
Files ? 169
Lines ? 50925
Branches ? 0
=========================================
Hits ? 46969
Misses ? 3956
Partials ? 0
Continue to review full report at Codecov.
|
SparseArray doesn't implement |
Thanks @charlesdong1991! |
@@ -32,22 +34,25 @@ def test_setitem_sequence_mismatched_length_raises(self, data, as_array): | |||
xpr = 'cannot set using a {} indexer with a different length' | |||
with tm.assert_raises_regex(ValueError, xpr.format('list-like')): | |||
ser[[0, 1]] = value | |||
assert ser._values[[0, 1]] == value |
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.
@TomAugspurger how will this assert be reached if the previous line raises an error?
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.
Ah, sorry I missed that.
ah, sorry, i see, thanks for pointing it out... can PR be reopened?
Tom Augspurger <notifications@github.com> 于2018年10月26日周五 下午1:11写道:
… ***@***.**** commented on this pull request.
------------------------------
In pandas/tests/extension/base/setitem.py
<#23304 (comment)>:
> @@ -32,22 +34,25 @@ def test_setitem_sequence_mismatched_length_raises(self, data, as_array):
xpr = 'cannot set using a {} indexer with a different length'
with tm.assert_raises_regex(ValueError, xpr.format('list-like')):
ser[[0, 1]] = value
+ assert ser._values[[0, 1]] == value
Ah, sorry I missed that.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23304 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI1yOGQ5uaG34l6w7Z-FoUOuyL5dF4yHks5uou3ggaJpZM4X2dmH>
.
|
No worries. I made a new PR to fix it.
…On Fri, Oct 26, 2018 at 7:11 AM Kaiqi Dong ***@***.***> wrote:
ah, sorry, i see, thanks for pointing it out... can PR be reopened?
Tom Augspurger ***@***.***> 于2018年10月26日周五 下午1:11写道:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In pandas/tests/extension/base/setitem.py
> <#23304 (comment)>:
>
> > @@ -32,22 +34,25 @@ def
test_setitem_sequence_mismatched_length_raises(self, data, as_array):
> xpr = 'cannot set using a {} indexer with a different length'
> with tm.assert_raises_regex(ValueError, xpr.format('list-like')):
> ser[[0, 1]] = value
> + assert ser._values[[0, 1]] == value
>
> Ah, sorry I missed that.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#23304 (comment)>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AI1yOGQ5uaG34l6w7Z-FoUOuyL5dF4yHks5uou3ggaJpZM4X2dmH
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23304 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIuddzCfKW5Ial4NgWdsKkwH38W2Vks5uovvxgaJpZM4X2dmH>
.
|
thanks! and appreciate a lot for your patience, guidance and kindness.
it's my first time to try to contribute to such big open source project,
and still feel excited and looking forward to doing more...
wish i could make less trouble for all of you in next PR... ^^
Tom Augspurger <notifications@github.com> 于2018年10月26日周五 下午2:13写道:
… No worries. I made a new PR to fix it.
On Fri, Oct 26, 2018 at 7:11 AM Kaiqi Dong ***@***.***>
wrote:
> ah, sorry, i see, thanks for pointing it out... can PR be reopened?
>
> Tom Augspurger ***@***.***> 于2018年10月26日周五 下午1:11写道:
>
> > ***@***.**** commented on this pull request.
> > ------------------------------
> >
> > In pandas/tests/extension/base/setitem.py
> > <#23304 (comment)
>:
> >
> > > @@ -32,22 +34,25 @@ def
> test_setitem_sequence_mismatched_length_raises(self, data, as_array):
> > xpr = 'cannot set using a {} indexer with a different length'
> > with tm.assert_raises_regex(ValueError, xpr.format('list-like')):
> > ser[[0, 1]] = value
> > + assert ser._values[[0, 1]] == value
> >
> > Ah, sorry I missed that.
> >
> > —
> > You are receiving this because you were mentioned.
> > Reply to this email directly, view it on GitHub
> > <#23304 (comment)
>,
> > or mute the thread
> > <
>
https://github.com/notifications/unsubscribe-auth/AI1yOGQ5uaG34l6w7Z-FoUOuyL5dF4yHks5uou3ggaJpZM4X2dmH
> >
> > .
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#23304 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/ABQHIuddzCfKW5Ial4NgWdsKkwH38W2Vks5uovvxgaJpZM4X2dmH
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23304 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI1yOIQjwLFzgvsCtCJPlXGfAaEHXTspks5uovxYgaJpZM4X2dmH>
.
|
…_pr2 * repo_org/master: DOC: Add docstring validations for "See Also" section (pandas-dev#23143) TST: Fix test assertion (pandas-dev#23357) BUG: Handle Period in combine (pandas-dev#23350) REF: SparseArray imports (pandas-dev#23329) CI: Migrate some CircleCI jobs to Azure (pandas-dev#22992) DOC: update the is_month_start/is_month_end docstring (pandas-dev#23051) Partialy fix issue pandas-dev#23334 - isort pandas/core/groupby directory (pandas-dev#23341) TST: Add base test for extensionarray setitem pandas-dev#23300 (pandas-dev#23304) API: Add sparse Acessor (pandas-dev#23183) PERF: speed up CategoricalIndex.get_loc (pandas-dev#23235)
…ndas * repo_org/master: (23 commits) DOC: Add docstring validations for "See Also" section (pandas-dev#23143) TST: Fix test assertion (pandas-dev#23357) BUG: Handle Period in combine (pandas-dev#23350) REF: SparseArray imports (pandas-dev#23329) CI: Migrate some CircleCI jobs to Azure (pandas-dev#22992) DOC: update the is_month_start/is_month_end docstring (pandas-dev#23051) Partialy fix issue pandas-dev#23334 - isort pandas/core/groupby directory (pandas-dev#23341) TST: Add base test for extensionarray setitem pandas-dev#23300 (pandas-dev#23304) API: Add sparse Acessor (pandas-dev#23183) PERF: speed up CategoricalIndex.get_loc (pandas-dev#23235) fix and test incorrect case in delta_to_nanoseconds (pandas-dev#23302) BUG: Handle Datetimelike data in DataFrame.combine (pandas-dev#23317) TST: re-enable gbq tests (pandas-dev#23303) Switched references of App veyor to azure pipelines in the contributing CI section (pandas-dev#23311) isort imports-io (pandas-dev#23332) DOC: Added a Multi Index example for the Series.sum method (pandas-dev#23279) REF: Make PeriodArray an ExtensionArray (pandas-dev#22862) DOC: Added Examples for Series max (pandas-dev#23298) API/ENH: tz_localize handling of nonexistent times: rename keyword + add shift option (pandas-dev#22644) BUG: Let MultiIndex.set_levels accept any iterable (pandas-dev#23273) (pandas-dev#23291) ...
…xamples * repo_org/master: (83 commits) DOC: Add docstring validations for "See Also" section (pandas-dev#23143) TST: Fix test assertion (pandas-dev#23357) BUG: Handle Period in combine (pandas-dev#23350) REF: SparseArray imports (pandas-dev#23329) CI: Migrate some CircleCI jobs to Azure (pandas-dev#22992) DOC: update the is_month_start/is_month_end docstring (pandas-dev#23051) Partialy fix issue pandas-dev#23334 - isort pandas/core/groupby directory (pandas-dev#23341) TST: Add base test for extensionarray setitem pandas-dev#23300 (pandas-dev#23304) API: Add sparse Acessor (pandas-dev#23183) PERF: speed up CategoricalIndex.get_loc (pandas-dev#23235) fix and test incorrect case in delta_to_nanoseconds (pandas-dev#23302) BUG: Handle Datetimelike data in DataFrame.combine (pandas-dev#23317) TST: re-enable gbq tests (pandas-dev#23303) Switched references of App veyor to azure pipelines in the contributing CI section (pandas-dev#23311) isort imports-io (pandas-dev#23332) DOC: Added a Multi Index example for the Series.sum method (pandas-dev#23279) REF: Make PeriodArray an ExtensionArray (pandas-dev#22862) DOC: Added Examples for Series max (pandas-dev#23298) API/ENH: tz_localize handling of nonexistent times: rename keyword + add shift option (pandas-dev#22644) BUG: Let MultiIndex.set_levels accept any iterable (pandas-dev#23273) (pandas-dev#23291) ...
git diff upstream/master -u -- "*.py" | flake8 --diff