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

CLN/ENH: Provide full suite of arithmetic (and flex) methods to all NDFrame objects. #5022

Merged
merged 2 commits into from
Sep 29, 2013

Conversation

jtratner
Copy link
Contributor

There's a lot of overlap right now, this is the first step to trying to
make this cleaner.

  • Abstract all arithmetic methods into core/ops
  • Add full range of flex arithmetic methods to all NDFrame/ndarray
    PandasObjects (except for SparsePanel pow and mod, which only work for
    scalars)
  • Normalize arithmetic methods signature (see
    ops.add_special_arithmetic_methods and
    ops.add_flex_arithmetic_methods for signature).
  • Opt-in more arithmetic operations with numexpr (except for
    SparsePanel, which has to opt-out because it doesn't respond to
    shape).
  • BUG: Fix _fill_zeros call to work even if TypeError (previously
    was inconsistent).
  • Add bind method to core/common

Closes #3765.
Closes #4334.
Closes #4051.
Closes #5033.
Closes #4331.

@jtratner
Copy link
Contributor Author

This could use more work later on, but this is a nightmare to maintain in the interim, so I'd like to put it into pandas. Comments?

@@ -36,6 +36,52 @@ API changes
an alias of iteritems used to get around ``2to3``'s changes).
(:issue:`4384`, :issue:`4375`, :issue:`4372`)
- ``Series.get`` with negative indexers now returns the same as ``[]`` (:issue:`4390`)
- ``HDFStore``
Copy link
Contributor

Choose a reason for hiding this comment

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

was this a string editing? because its already there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

darn it git.

@jtratner
Copy link
Contributor Author

To be clear, basically the only changes in functionality in this PR are:

  • Series and Panel use numexpr sometimes
  • change to the signature for arithmetic methods
  • add a few more flex methods.

if len(self) != len(other):
raise AssertionError("Operands must be of the same size")
if not isinstance(other, SparseArray):
if not ((len(self) == len(other))):
Copy link
Member

Choose a reason for hiding this comment

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

can u keep my change here from the parse-exceptions PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was one place I made an explicit choice. I'm okay either way (I had this error before) - thought it was helpful to print the lengths with the exception. your call.

Copy link
Member

Choose a reason for hiding this comment

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

i'm just referring to the ugly not ((len(self) == len(other))), your error message is much better

@jtratner
Copy link
Contributor Author

@cpcloud @jreback any last fixes? Again, these are relatively minimal changes, aside from moving functions.

@cpcloud
Copy link
Member

cpcloud commented Sep 29, 2013

ok by me.

@jreback
Copy link
Contributor

jreback commented Sep 29, 2013

ok here too

* Abstract all arithmetic methods into core/ops
* Normalize arithmetic methods signature (see
  `ops.add_special_arithmetic_methods` and `ops.add_flex_arithmetic_methods`
  for signature).
* Opt-in more arithmetic operations with numexpr (except for
  SparsePanel, which has to opt-out because it doesn't respond to
  `shape`).
* BUG: Fix ``_fill_zeros`` call to work even if TypeError (previously
  was inconsistent).
* Add bind method to core/common
* Add full range of flex arithmetic methods to all NDFrame/ndarray
  PandasObjects (except for SparsePanel pow and mod, which only work for
  scalars)
* Add a set of testing methods to check that numexpr was actually used
  successfully.
* Flesh out test cases to include all arithmetic ops + test refactoring
* Disable numexpr for sparse objects (they don't work correctly right
* now)
* Sparse methods aren't moved because they are very specific to sparse
  (and aren't numexpr accelerated)
* Disable r* comparisons for now because they cause test failures
* Specifically allow radd in TimeOps for Series
* Fixup Series time rops and add a few test cases.
* Disable flex r-ops for bools (no good test cases yet...)
* TST: Remove tests for TypeErrors in pandas/computation/test_eval that
  now work after this refactor (because DataFrame now defines more r*
  methods)
Enable test cases that involve these DateOffsets with `__r*` ops
jtratner added a commit that referenced this pull request Sep 29, 2013
CLN/ENH: Provide full suite of arithmetic (and flex) methods to all NDFrame objects.
@jtratner jtratner merged commit a58bc6a into pandas-dev:master Sep 29, 2013
@jtratner jtratner deleted the arithmetic-refactor2 branch September 29, 2013 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants