-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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 convenience functions nans, infs, nans_like, infs_like #2875
Conversation
Hmm, this is creating something of a proliferation of different functions. I think the usual way to do this is to just write
but obviously that is substantially less efficient than the multi-line version you suggested (it creates and initializes two separate arrays). Maybe we should add |
I think that this is unnecessary. Adding
|
That can't be the idiomatic way, b/c
So I think right now the I guess I'm +0.5, maybe even +1, on np.filled/np.filled_like. On Sat, Jan 5, 2013 at 9:00 PM, Eric Moore notifications@github.com wrote:
|
Touche. That said, my point stands. Using a multiply to fill an array is a terrible idea. Even if the better way takes two lines rather than one.
Given this I think filled/filled_like are an okay idea. |
I agree, filled and filled_like are the best option. Give me some days and I will implement those two functions as part of this PR. |
|
I see tests for |
Yes, I forgot about that because I couldn't find tests for |
I'm not finding any tests for the basic ones/zeros functionality either. (And it's possible that we're both just missing them, but a little On Sun, Jan 13, 2013 at 6:34 PM, Johannes Schönberger <
|
Added test cases. |
|
I don't have a running Python 3 environment here, so I skip all string/unicode comparisons. Maybe someone else can have a look into this. Maybe this is a bug? |
The difference is: Python 2.7:
Python 3.2:
The second difference does not really matter much I believe, 'S0' is not really a sensible type anyway. But the first one is an inconsistency between the two and I believe as such a bug in python 3 string handling. |
Maybe someone with more knowledge regarding the specifics of Python 3 string handling can have another look at this and tell what he/she thinks? |
Has someone had time to look into this yet? If not I'll tackle this in the coming days. |
In Python3.3:
So the problem looks to be only with 3.2. Now that we are not supporting Python < 2.6 the |
@seberg Looks like you thought this was good apart from the errors. |
Rebased on current master and fixed the Python 3 test cases. Tell me if there is anything else you need me to do. |
Don't know what's going on with the Travis bot notification here, all the tests seem to have passed. The new functions need to be mentioned in |
|
||
Please refer to the documentation for `zeros` for further details. | ||
|
||
Other parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just copy the documentation from zeros
, no point in sending people around the 'see blah' loop. I think the main justification for that practice was keeping things in sync but I don't think the documentation gets updated that often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also do it for ones
, … etc.?
@charris Doc strings updated with separate parameter description and short example sections. |
I guess all remaining tasks should be addressed now. Please, check if the release notes are appropriate? |
Looks good to me, but one more subtle API question: should the default dtype for |
That's actually a good question. On the one hand I'm +1 on changing it to |
I checked the behavior of the current implementation and it is already the case that |
I like The docs currently say that You have a merge conflict that needs resolving. |
Doc string updated and rebased on current state of master branch. |
/ping |
Needs a rebase, |
@charris Rebased on current master. |
/ping |
@njsmith Is this ready? |
Sigh. The code looks great to me and I like the API. But I just went back and looked at the mailing list discussion: We're going to have a mess if we just declare this done and merge it as is, because now that I remind myself, the general opinion in that thread seems to have been:
My personal opinion is that this argument is completely wrong. Making np.ma's API clean is not as important as making numpy proper's API clean, esp. since np.ma already is already inconsistent with the word 'fill' being used for totally different things. So we can just live with the inconsistency between But, just ignoring the discussion and merging anyway will do more harm than good, even if everyone does eventually agree the PR is totally awesome... I guess there's not really anything we can do except send another email and re-open the debate. Sigh. |
If naming is an issue, how about |
I think that suggestion did come up in the last thread, though I don't New thread: On Wed, Jun 12, 2013 at 2:42 PM, Johannes Schönberger <
|
Nevertheless, I can bring up this topic on the mailing list again. |
Might be better to wait a day or so to see if the current 'filled' names go On Wed, Jun 12, 2013 at 2:50 PM, Johannes Schönberger <
|
@njsmith Sorry, it is hard for me as an outside person to follow the discussion, but we do not seem to approach any consensus as far as I can see, do we? ;-) |
@ahojnnes - Phew. At long last, it looks like people are all okay with (Sorry this has been such a hassle. Thanks for sticking with it so far!) |
@njsmith No problem. Now, we only need Travis to be happy with the changes... ;-) |
Add convenience functions nans, infs, nans_like, infs_like
I find myself often in the situation where I type the long version of this:
Please let me know if you find this useful as well and I will add test cases for those functions.