Makie.jl icon indicating copy to clipboard operation
Makie.jl copied to clipboard

Sometimes units are not handled

Open aplavin opened this issue 1 year ago • 1 comments

I encountered this strange inconsistency:

# works:
julia> scatter([1u"m"], [2])

# works:
julia> scatter([(1, 2)])

# doesn't work:
julia> scatter([(1u"m", 2)])
ERROR: ArgumentError:     Conversion failed for Scatter (With conversion trait PointBased()) with args: Tuple{Vector{Tuple{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, Int64}}} .
    Scatter requires to convert to argument types Tuple{AbstractVector{<:Union{Point2, Point3}}}, which convert_arguments didn't succeed in.
    To fix this overload convert_arguments(P, args...) for Scatter or PointBased() and return an object of type Tuple{AbstractVector{<:Union{Point2, Point3}}}.`

I guess it's an omission somewhere in the pipeline? The pipeline is quite involved, so not sure where exactly.

  • [x] are you running newest version (version from docs) ?
  • [x] can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • [x] What platform + GPU are you on?

aplavin avatar Jun 07 '24 00:06 aplavin

No, this is expected and discussed in the current limitation in the docs and Blogpost. Its just much more complicated to handle those cases, and there wasn't much time to implement this feature already ;)

SimonDanisch avatar Jun 07 '24 09:06 SimonDanisch

perhaps worth noting that the first "working" example does not work for DynamicQuantities.jl (but does for Unitful.jl):

julia> using DynamicQuantities, GLMakie

julia> scatter([1u"m"], [2])
ERROR: ArgumentError:     Conversion failed for Scatter (With conversion trait PointBased()) with args: Tuple{Vector{Quantity{Float64, Dimensions{FixedRational{Int32, 25200}}}}, Vector{Int64}} .
    Scatter requires to convert to argument types Tuple{AbstractVector{<:Union{Point2, Point3}}}, which convert_arguments didn't succeed in.
    To fix this overload convert_arguments(P, args...) for Scatter or PointBased() and return an object of type Tuple{AbstractVector{<:Union{Point2, Point3}}}.`

bjarthur avatar Apr 09 '25 21:04 bjarthur

Makie only claims to support Unitful, so I implicitly assumed Unitful in this issue. Probably, makes sense to handle any alternative unit packages separately?..

aplavin avatar Apr 10 '25 02:04 aplavin

Yea, have some DQ support in the works here, but still early days. The scatter([1u"m"], [2]) example should work in that PR. Feedback welcome =]

icweaver avatar Apr 10 '25 02:04 icweaver