Skip to content
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

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Oct 23, 2018

@pep8speaks
Copy link

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

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.

Copy link
Member Author

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!

@TomAugspurger TomAugspurger added ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite labels Oct 23, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Oct 23, 2018
@TomAugspurger
Copy link
Contributor

Looks like the fixture name box is already taken

    raise ValueError("duplicate %r" % (arg,))
E   ValueError: duplicate 'box'
--------------------- generated xml file: /tmp/single.xml ----------------------
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
============ 7 skipped, 35608 deselected, 1 error in 35.79 seconds =============

You could rename it to box_in_series perhaps.

FYI, you may want to run the tests locally for a faster feedback loop. pytest pandas/tests/extension or even just pytest pandas/tests/extension/decimal.

@charlesdong1991 charlesdong1991 force-pushed the add_base_test_for_extensionarray_setitem branch from d50715b to d92988c Compare October 24, 2018 12:34
@@ -501,6 +501,12 @@ def mock():
return pytest.importorskip("mock")


@pytest.fixture(params=[True, False])
def box_in_series(request):
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done, thanks!

@jreback
Copy link
Contributor

jreback commented Oct 26, 2018

looks good.

@TomAugspurger IIRC on Sparse you were showing a warning on setitem (for perf)? is this tested ?

@codecov
Copy link

codecov bot commented Oct 26, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@4a11eac). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #23304   +/-   ##
=========================================
  Coverage          ?   92.23%           
=========================================
  Files             ?      169           
  Lines             ?    50925           
  Branches          ?        0           
=========================================
  Hits              ?    46969           
  Misses            ?     3956           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.65% <ø> (?)
#single 42.28% <ø> (?)

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 4a11eac...009440d. Read the comment docs.

@TomAugspurger
Copy link
Contributor

SparseArray doesn't implement __setitem__ (old one didn't either, though there's an open PR to implement it).

@TomAugspurger TomAugspurger merged commit 6703ace into pandas-dev:master Oct 26, 2018
@TomAugspurger
Copy link
Contributor

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

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?

Copy link
Contributor

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.

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Oct 26, 2018 via email

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Oct 26, 2018 via email

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Oct 26, 2018 via email

thoo added a commit to thoo/pandas that referenced this pull request Oct 26, 2018
…_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)
thoo added a commit to thoo/pandas that referenced this pull request Oct 27, 2018
…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)
  ...
thoo added a commit to thoo/pandas that referenced this pull request Oct 27, 2018
…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)
  ...
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
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. Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add base test for ExtensionArray.__setitem__
5 participants