MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.4k stars 307 forks source link

image doesn't work with units #3897

Open aplavin opened 4 months ago

aplavin commented 4 months ago

Image conversion doesn't seem to work for units:

julia> image((0, 1), (1, 2), rand(5, 10))
# works

julia> image((0u"m", 1u"m"), (1u"W", 2u"W"), rand(5, 10))
ERROR: ArgumentError:     Conversion failed for Image (With conversion trait ImageLike()) with args: Tuple{Tuple{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}, Tuple{Quantity{Int64, 𝐋² 𝐌 𝐓⁻³, Unitful.FreeUnits{(W,), 𝐋² 𝐌 𝐓⁻³, nothing}}, Quantity{Int64, 𝐋² 𝐌 𝐓⁻³, Unitful.FreeUnits{(W,), 𝐋² 𝐌 𝐓⁻³, nothing}}}, Matrix{Float64}} .
    Image requires to convert to argument types Tuple{IntervalSets.ClosedInterval{<:Union{Float32, Float64}}, IntervalSets.ClosedInterval{<:Union{Float32, Float64}}, AbstractMatrix{<:Union{Float32, Float64, ColorTypes.Colorant}}}, which convert_arguments didn't succeed in.
    To fix this overload convert_arguments(P, args...) for Image or ImageLike() and return an object of type Tuple{IntervalSets.ClosedInterval{<:Union{Float32, Float64}}, IntervalSets.ClosedInterval{<:Union{Float32, Float64}}, AbstractMatrix{<:Union{Float32, Float64, ColorTypes.Colorant}}}.`
SimonDanisch commented 4 months ago

Ah hm, that's a weird interaction of image deprecating vectors for x/y and unit conversions only getting applied to vector of units. I guess we'll need to add some exceptions here. Note, this works:

image(LinRange(0u"m", 1u"m", 5), LinRange(1u"W", 2u"W", 10), rand(5, 10))