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

Add more nan functions #2

Closed
ufechner7 opened this issue Aug 14, 2015 · 9 comments
Closed

Add more nan functions #2

ufechner7 opened this issue Aug 14, 2015 · 9 comments

Comments

@ufechner7
Copy link

As discussed in JuliaLang/julia#12563 (comment) ,
it would be useful to have a Julia equivalent of the following numpy functions:

nanargmax nanargmin nanmax nanmin
nansum nanmean nanstd nanvar

These functions calculate the maximum etc of an array of values, ignoring any NaN's
(instead of promoting them, what Julia will do shortly, probably in the 0.4 release).

Please comment, if this is the right package to add these functions!

@mlubin
Copy link
Collaborator

mlubin commented Aug 14, 2015

Yes, this package would be a reasonable home for those functions. The nan prefix isn't needed, I'd prefer NaNMath.argmax, NaNMath.argmin, etc. in order to be consistent with the current functions. (I don't want to call nanlog and nanasin.)

@tkelman
Copy link

tkelman commented Aug 14, 2015

I guess the current use cases of NaNMath would just have to be careful about which replacements they make from this package. Ignore-nans vs return-nan-instead-of-throwing are slightly different use cases, so it's mainly the package naming that made this seem worth suggesting.

@mlubin
Copy link
Collaborator

mlubin commented Aug 14, 2015

Are there any cases where ignore-nans and return-nan-instead-of-throwing are in conflict/ambiguous?

@tkelman
Copy link

tkelman commented Aug 14, 2015

Not that I can think of so far.

@ufechner7
Copy link
Author

Thanks for the feedback!
If nobody objects, I would start to implement the following functions, ignoring NaN values in the argument:

maximum
minimum
mean
sum
std
var

Does someone know the equivalent of the numpy functions argmax and argmin in Julia?

@ufechner7
Copy link
Author

I created a pull request to implement the function sum:
#3
Depending on the feedback, I will continue to add the other functions, too.

@tkelman
Copy link

tkelman commented Aug 16, 2015

Does someone know the equivalent of the numpy functions argmax and argmin in Julia?

indmax and indmin, I believe

@ufechner7
Copy link
Author

I created another pull request with the rest of the functions:
#5
I did not implement indmax and indmin yet, because currently Base.indmax and Base.indmin ignore NaN values already. This might change in the future.

@ufechner7
Copy link
Author

This is done in release 0.1.0 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants