JuliaNLSolvers / NLSolversBase.jl

Base package for optimization and equation solver software in JuliaNLSolvers
Other
30 stars 28 forks source link

make x_of_nans work on 0-dimensional arrays #141

Open stevengj opened 3 years ago

stevengj commented 3 years ago

The x_of_nans function gives a MethodError for 0-dimensional arrays due to JuliaLang/julia#41643. A workaround is to use map(Tf, x) instead of Tf.(x).

Before this PR:

julia> x_of_nans(fill(0.0))
ERROR: MethodError: no method matching fill!(::Float64, ::Float64)
...

After this PR:

julia> x_of_nans(fill(0.0))
0-dimensional Array{Float64, 0}:
NaN

Without this PR, nlsolve fails for 0-dimensional arrays.

stevengj commented 3 years ago

Not sure which file you would want a test in?

@test isequal.(x_of_nans(fill(0.0))::Array{Float64,0}, NaN)

should suffice.

pkofod commented 3 years ago

Interesting. I wasn't even aware of zero-dimensional arrays with elements in them. Is this meant to be a non-Number "scalar" for linear algebra use, or?

Edit: I see now that this is related to the nlsovle.jl issue

stevengj commented 2 years ago

Bump.

mateuszbaran commented 2 years ago

Bump.