Skip to content

BUG: Matched Round Signature with NumPy's #12603

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

Closed
wants to merge 1 commit into from

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Mar 12, 2016

Closes #12600 by re-accepting the out parameter as a **kwargs argument. Also removes the out parameter from the signature for DataFrame.round and replaces it with **kwargs like its Series counterpart. Furthermore, since out is a parameter that is not supported in pandas, checks that out is None and throws an error if it isn't.

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Mar 13, 2016
@jreback
Copy link
Contributor

jreback commented Mar 14, 2016

@gfyoung when we deal with this issue. can you do a search on current numpy as see what functions _wrap_it is called for? then let's setup a test in pandas for the same. (could be another issue/PR)

@gfyoung
Copy link
Member Author

gfyoung commented Mar 14, 2016

Yep, sounds good to me as a follow-up PR.

@@ -4486,6 +4487,8 @@ def _series_round(s, decimals):
return s.round(decimals)
return s

validate_args(args, min_length=0, max_length=1)

Copy link
Member Author

Choose a reason for hiding this comment

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

@jreback : Copy over from #12413 --> add check to see if out != None

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

@gfyoung
Copy link
Member Author

gfyoung commented Mar 16, 2016

@jreback: Any updates on this PR? I've been running tests and diff-ing locally to make sure that Travis should be happy once I remove the [ci skip] tag in my commit message.

@@ -4420,7 +4421,7 @@ def merge(self, right, how='inner', on=None, left_on=None, right_on=None,
right_index=right_index, sort=sort, suffixes=suffixes,
copy=copy, indicator=indicator)

def round(self, decimals=0, out=None):
def round(self, decimals=0, *args):
Copy link
Contributor

Choose a reason for hiding this comment

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

are these passed by position or kw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, numpy passes them in as positional in fromnumeric.py, so if we want to hide out, it needs to reside in an *args parameter and NOT a **kwargs one.

@jreback
Copy link
Contributor

jreback commented Mar 16, 2016

i c you have removed dependene on #12413 great

@gfyoung gfyoung force-pushed the round_out_compat branch 2 times, most recently from 8d6f8d0 to 6f88946 Compare March 17, 2016 12:21
@gfyoung
Copy link
Member Author

gfyoung commented Mar 17, 2016

Added the validator for out, and Travis is passing. Should be good to merge then.





Copy link
Contributor

Choose a reason for hiding this comment

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

dont' touch my whitespace!! this is on purpose

Copy link
Member Author

Choose a reason for hiding this comment

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

My bad. Fixed.

@gfyoung gfyoung force-pushed the round_out_compat branch 2 times, most recently from 7304b46 to aad613b Compare March 17, 2016 15:31
length=length,
max_length=max_length)))

# See gh-12600; this is to allow compatibility with NumPy,
Copy link
Contributor

Choose a reason for hiding this comment

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

this is wrong. it should only be triggered if you <= max_length and >= min_length args, then it should check if any are not None.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I think it's already being triggered when that's the case. Otherwise, some sort of ValueError is thrown.
  2. Are you saying that the check should be if all values in the tuple *args are None?

Copy link
Contributor

Choose a reason for hiding this comment

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

the ideas is that when we use this validator function it will allow extra args (according to min/max lens), but they all must be None, just a bit more general.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see. Done.

@jreback
Copy link
Contributor

jreback commented Mar 17, 2016

ok, looks good.

ping when green (on your travis run is fine).

@gfyoung
Copy link
Member Author

gfyoung commented Mar 17, 2016

@jreback : Travis has finally given the green light. Ready to merge if there's nothing else to change.

@jreback
Copy link
Contributor

jreback commented Mar 17, 2016

ok, looks good. will merge in a bit.

@jreback jreback closed this in 6e64787 Mar 17, 2016
@jreback
Copy link
Contributor

jreback commented Mar 17, 2016

thanks @gfyoung for the patience!

@gfyoung gfyoung deleted the round_out_compat branch March 17, 2016 23:15
@gfyoung
Copy link
Member Author

gfyoung commented Mar 17, 2016

@jreback : No worries. Better to get it right the first time. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants