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: SparseArray numeric ops misc fixes #12910

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@sinhrks
Member

sinhrks commented Apr 17, 2016

  • no existing issue
  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

Fixed following 3 issues occurred on the current master.

1. addition ignores rhs fill_value

pd.SparseArray([1., 1.]) + pd.SparseArray([1., 0.], fill_value=0.)
# [2.0, nan]
# Fill: nan
# IntIndex
# Indices: array([0], dtype=int32)

Expected:
# [2.0, 1.0]

2. mod raises AttributeError

pd.SparseArray([1, 1]) % pd.SparseArray([1, np.nan])
# AttributeError: 'module' object has no attribute 'sparse_nanmod'

3. pow outputs incorrect result wiht 1.0 ** np.nan

pd.SparseArray([1., 1.]) ** pd.SparseArray([1., np.nan])
# [1.0, nan]
# Fill: nan
# IntIndex
# Indices: array([0], dtype=int32)

Expected:
# [1.0, 1.0]

# NumPy result
np.array([1., 1.]) ** np.array([1, np.nan])
# array([ 1.,  1.])

@sinhrks sinhrks added this to the 0.18.1 milestone Apr 17, 2016

@sinhrks sinhrks changed the title from BUG: SparseArray misc fixes to BUG: SparseArray numeric ops misc fixes Apr 17, 2016

@jreback

View changes

Show outdated Hide outdated pandas/sparse/array.py Outdated
@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Apr 17, 2016

Contributor

whoosh you blew away lots of code. must have been work-arounds built in there for maybe an old cython or something. Just want to be sure (since tests were removed) everything still working (as may not be testing some of the numeric ops as much, though did see you added some tests)

Contributor

jreback commented Apr 17, 2016

whoosh you blew away lots of code. must have been work-arounds built in there for maybe an old cython or something. Just want to be sure (since tests were removed) everything still working (as may not be testing some of the numeric ops as much, though did see you added some tests)

@sinhrks

This comment has been minimized.

Show comment
Hide comment
@sinhrks

sinhrks Apr 17, 2016

Member

The removed test calls _nan funcs which is no longer exists, and remaining logic is tested with _op_tests below. I'm willing to add more tests if you have anything.

Member

sinhrks commented Apr 17, 2016

The removed test calls _nan funcs which is no longer exists, and remaining logic is tested with _op_tests below. I'm willing to add more tests if you have anything.

@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Apr 18, 2016

Contributor

thanks!

Contributor

jreback commented Apr 18, 2016

thanks!

@jreback jreback closed this in 3cc4198 Apr 18, 2016

@sinhrks sinhrks deleted the sinhrks:sparse_ops branch Apr 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment