Skip to content

BUG: fix reducing numpy ufuncs for Series/Index #23314

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

Conversation

jorisvandenbossche
Copy link
Member

closes #23312

@pep8speaks
Copy link

Hello @jorisvandenbossche! Thanks for submitting the PR.

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 note

@@ -833,6 +833,15 @@ def test_ufunc_coercions(self, holder):
exp = tm.box_expected(exp, box)
tm.assert_equal(result, exp)

@pytest.mark.parametrize('holder', [pd.Int64Index, pd.UInt64Index,
Copy link
Contributor

Choose a reason for hiding this comment

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

holder -> box

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests above also use holder, so I wanted to be consistent, but can change them all

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we have settled on box a while back

def test_ufunc_reduce(self, holder):
idx = holder([1, 2, 3, 4, 5], name='x')

result = np.add.reduce(idx)
Copy link
Contributor

Choose a reason for hiding this comment

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

use paramterize over some more ops here

Copy link
Member Author

Choose a reason for hiding this comment

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

We would only be testing that those work on the underlying numpy array (which they do :)), so I don't think it is that important

Copy link
Contributor

Choose a reason for hiding this comment

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

well can't hurt to have a few more then

Copy link
Member Author

Choose a reason for hiding this comment

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

What might be more useful is with other result types, like np.logical_and.reduce

Copy link
Contributor

Choose a reason for hiding this comment

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

yes exactly

@jreback jreback added Bug Numeric Operations Arithmetic, Comparison, and Logical operations labels Oct 24, 2018
@codecov
Copy link

codecov bot commented Oct 24, 2018

Codecov Report

Merging #23314 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23314      +/-   ##
==========================================
+ Coverage   92.22%   92.22%   +<.01%     
==========================================
  Files         169      169              
  Lines       51258    51263       +5     
==========================================
+ Hits        47274    47279       +5     
  Misses       3984     3984
Flag Coverage Δ
#multiple 90.66% <100%> (ø) ⬆️
#single 42.23% <33.33%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/series.py 93.92% <100%> (ø) ⬆️
pandas/core/indexes/base.py 96.61% <100%> (ø) ⬆️
pandas/core/arrays/sparse.py 91.84% <0%> (ø) ⬆️
pandas/core/arrays/datetimes.py 97.46% <0%> (ø) ⬆️
pandas/core/dtypes/cast.py 89.28% <0%> (+0.05%) ⬆️

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 437f31c...733d027. Read the comment docs.

@jreback
Copy link
Contributor

jreback commented Dec 9, 2018

needs a rebase

@jreback
Copy link
Contributor

jreback commented May 12, 2019

@jorisvandenbossche can you merge master and update

@jreback
Copy link
Contributor

jreback commented Jun 8, 2019

can you merge master (and move notes to 0.25) / or close if going to handle in __array_ufunc__

@jreback jreback closed this Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: reducing ufuncs don't return a scalar
3 participants