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

norm(Float64[0,NaN]) == 0 #236

Closed
stevengj opened this issue Aug 11, 2015 · 5 comments · Fixed by JuliaLang/julia#12563
Closed

norm(Float64[0,NaN]) == 0 #236

stevengj opened this issue Aug 11, 2015 · 5 comments · Fixed by JuliaLang/julia#12563
Labels
bug Something isn't working

Comments

@stevengj
Copy link
Member

norm(Float64[0,NaN]) == norm(Float64[0,NaN],2) == norm(Float64[0,NaN],Inf) == 0, whereas I would expect NaN in this case. The L1 norm gives NaN.

Seems to affect both Julia 0.3 and 0.4-dev.

@stevengj
Copy link
Member Author

The basic problem is that max(0.0, NaN) == 0, when it should probably give NaN? Actually, the way max is written, it looks like this was somewhat intentional?? See JuliaLang/julia#10736.

@lbenet and @timholy, can you comment on the desired semantics of max here?

@StefanKarpinski
Copy link
Member

I would strongly encourage making max and min over NaN produce NaN.

@simonster
Copy link
Member

See also JuliaLang/julia#7866

@StefanKarpinski
Copy link
Member

In fact, this very example is a pretty strong argument for why it should be NaN rather than 0.0.

@lbenet
Copy link

lbenet commented Aug 11, 2015

@stevengj Indeed, in JuliaLang/julia#10736 max(0.0, NaN) == 0 was intentionally coded to mimic the results obtained in v0.3.
(I think this discussion is continuing in JuliaLang/julia#7866).

stevengj referenced this issue in JuliaLang/julia Aug 11, 2015
fix #12552 (norm should return NaN for NaN inputs)
stevengj referenced this issue in JuliaLang/julia Oct 20, 2015
stevengj referenced this issue in JuliaLang/julia Oct 20, 2015
…(NaN))

(cherry picked from commit e7e614d)
ref #12564

Fix test syntax to pass on 0.3
@KristofferC KristofferC transferred this issue from JuliaLang/julia Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants