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

isapprox returns wrong results with nans=true #1135

Closed
gerlero opened this issue Mar 3, 2023 · 5 comments · Fixed by #1161
Closed

isapprox returns wrong results with nans=true #1135

gerlero opened this issue Mar 3, 2023 · 5 comments · Fixed by #1161

Comments

@gerlero
Copy link
Contributor

gerlero commented Mar 3, 2023

using StaticArrays # v1.5.16

v = [1.0, NaN]
s = @SVector [1.0, NaN]

# These should be false
isapprox(v, v) # OK
isapprox(v, s) # OK
isapprox(s, v) # OK
isapprox(s, s) # OK

# But these should return true
isapprox(v, v, nans=true) # OK (no StaticArrays)
isapprox(v, s, nans=true) # wrong - returns false
isapprox(s, v, nans=true) # wrong - returns false
isapprox(s, s, nans=true) # wrong - returns false
@gerlero
Copy link
Contributor Author

gerlero commented Mar 7, 2023

I could further trace the issue to this difference in the result of LinearAlgebra.norm with a StaticArray argument:

using StaticArrays
using LinearAlgebra

norm([0.0, NaN]) # NaN
norm([NaN, 0.0]) # NaN

norm(SA[0.0, NaN]) # 0.0
norm(SA[NaN, 0.0]) # NaN

@rmkn85
Copy link

rmkn85 commented May 12, 2023

Same with Inf

norm([1.0, Inf])    # Inf
norm(SA[1.0, Inf])  # NaN

@rmkn85
Copy link

rmkn85 commented May 12, 2023

The behaviour changed between v1.5.12 and v1.5.13 !!!

@rmkn85
Copy link

rmkn85 commented May 12, 2023

I think these are related:
#913
#975

@gerlero
Copy link
Contributor Author

gerlero commented May 12, 2023

@rmkn85 thanks! I'll open a PR that should solve both cases (NaN and Inf)

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

Successfully merging a pull request may close this issue.

2 participants