JuliaPlots / AbstractPlotting.jl

An abstract interface for plotting libraries, part of the Makie ecosystem.
http://makie.juliaplots.org/dev
MIT License
85 stars 65 forks source link

Error with `volume(::Array{Int8, 3})` #301

Closed Malpaca closed 4 years ago

Malpaca commented 4 years ago

MWE:

volume(ones(Int8, 3, 3, 3); algorithm = :absorptionrgba)

yields the error:

Error showing value of type Scene:
ERROR: MethodError: no method matching _default(::Observables.Observable{Array{Int8,3}}, ::GLMakie.GLAbstraction.Style{:default}, ::Dict{Symbol,Any})
Closest candidates are:
  _default(::GLNormalColorMesh, ::GLMakie.GLAbstraction.Style, ::Dict) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/GLVisualize/visualize/mesh.jl:49
  _default(::Union{GLMakie.GLAbstraction.GPUArray{GeometryTypes.Simplex{2,T},1}, Union{Observables.Observable{X}, X} where X<:AbstractArray{GeometryTypes.Simplex{2,T},1}}, ::GLMakie.GLAbstraction.Style, ::Dict) where T<:Point at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/GLVisualize/visualize/lines.jl:109
  _default(::Union{GLMakie.GLAbstraction.GPUArray{T,2}, Union{Observables.Observable{X}, X} where X<:AbstractArray{T,2}}, ::GLMakie.GLAbstraction.Style, ::Dict) where T<:ColorTypes.Colorant at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/GLVisualize/visualize/image_like.jl:8
  ...
Stacktrace:
 [1] default(::Any, ::Any, ::Any) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/GLVisualize/visualize_interface.jl:4
 [2] visualize(::Any, ::GLMakie.GLAbstraction.Style{:default}, ::Dict{Symbol,Any}) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/GLVisualize/visualize_interface.jl:21
 [3] (::GLMakie.var"#118#120"{Volume{...}})(::Dict{Symbol,Any}) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/drawing_primitives.jl:456
 [4] (::GLMakie.var"#58#64"{GLMakie.var"#118#120"{Volume{...}},GLMakie.Screen,Scene,Volume{...}})() at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/drawing_primitives.jl:57
 [5] get!(::GLMakie.var"#58#64"{GLMakie.var"#118#120"{Volume{...}},GLMakie.Screen,Scene,Volume{...}}, ::Dict{UInt64,GLMakie.GLAbstraction.RenderObject}, ::UInt64) at ./dict.jl:452
 [6] cached_robj!(::GLMakie.var"#118#120"{Volume{...}}, ::GLMakie.Screen, ::Scene, ::Volume{...}) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/drawing_primitives.jl:40
 [7] draw_atomic at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/drawing_primitives.jl:438 [inlined]
 [8] insert!(::GLMakie.Screen, ::Scene, ::Volume{...}) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/drawing_primitives.jl:126
 [9] insertplots!(::GLMakie.Screen, ::Scene) at /Users/malpaca/.julia/packages/GLMakie/guMpB/src/screen.jl:59

cc: @asinghvi17

asinghvi17 commented 4 years ago

Again a missing convert to Float32, I think.

asinghvi17 commented 4 years ago

It feels messy, but this is a solution:

function convert_arguments(::VolumeLike, x::RangeLike, y::RangeLike, z::RangeLike, data::AbstractArray{T, 3}) where T <: Real
    (x, y, z, Float32(data))
end

function convert_arguments(::VolumeLike, x::RangeLike, y::RangeLike, z::RangeLike, data::AbstractArray{Float32, 3})
  (x, y, z, data)
end