-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
float(Union{Missing, Float32}) Failing in 1.0.0, From Using quantile
In a Particular Way
#29693
Comments
The minimal example to reproduce sheds some more light on the situation: julia> using Statistics
julia> test = Array{Union{Missing, Float32},1}(undef, 2)
2-element Array{Union{Missing, Float32},1}:
missing
missing
julia> test[:] .= 2.
2-element view(::Array{Union{Missing, Float32},1}, :) with eltype Union{Missing, Float32}:
2.0f0
2.0f0
julia> quantile(test)
ERROR: MethodError: no method matching quantile(::Array{Union{Missing, Float32},1})
Closest candidates are:
quantile(::AbstractArray{T,1} where T, ::Any; sorted) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:913
quantile(::Any, ::Any; sorted) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:911
Stacktrace:
[1] top-level scope at none:0
julia> float(test[1])
2.0f0
julia> quantile(test, 0.1)
2.0
julia> quantile(test, 0.5)
2.0
julia> quantile(test, [0.1, 0.5])
ERROR: MethodError: no method matching AbstractFloat(::Type{Union{Missing, Float32}})
Closest candidates are:
AbstractFloat(::Bool) at float.jl:250
AbstractFloat(::Int8) at float.jl:251
AbstractFloat(::Int16) at float.jl:252
...
Stacktrace:
[1] float(::Type) at ./float.jl:269
|
quantile
In a Particular Way
We should define |
Sure, I can take a crack at the process given that it may be such a simple fix. Cheers |
Actually, I'm not sure if this will have undesired downstream impacts, either now or in the future--Since julia> test = Array{Union{Missing, Float32},1}(undef, 2)
2-element Array{Union{Missing, Float32},1}:
missing
missing
julia> float(test)
2-element Array{Union{Missing, Float32},1}:
missing
missing
julia> float(test[1])
missing
julia> test[:] .= 2.
2-element view(::Array{Union{Missing, Float32},1}, :) with eltype Union{Missing, Float32}:
2.0f0
2.0f0
julia> float(test)
2-element Array{Union{Missing, Float32},1}:
2.0f0
2.0f0
julia> float(test[1])
2.0f0
Will have to investigate further. |
|
@nalimilan: I just came across this issue. Are you suggesting that fixing this could be as simple as adding that method to |
Yes, probably. |
I have been trying to run
quantile
for an array ofArray{Union{Missing, Float32}}
, but that only contains valid Float32 values. I assume this should be possible, but I get the following error that seems to be related tofloat
conversion:Version:
I know that the documentation suggests
skipmissing
which must convert to a standard Array{Float}, but I assume that the above should also be possible. Would addingskipmissing
in my case add additional overhead, and is this any different from explicitly converting the withconvert(Array{Float32}, ...)
in my case?Thanks!
The text was updated successfully, but these errors were encountered: