Skip to content
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

Plotting does not work with eltype Union{Missing, Float32} #543

Closed
felixcremer opened this issue Sep 27, 2023 · 3 comments
Closed

Plotting does not work with eltype Union{Missing, Float32} #543

felixcremer opened this issue Sep 27, 2023 · 3 comments

Comments

@felixcremer
Copy link
Contributor

I get the following error when I am trying to plot a DimArray with an Union{Missing, Float32} eltype.
The heatmap call works as expected when I make the eltype of a Float32.
The heatmap of a with missing works in Makie so it would be nice to have this also working for the wrapped array.

This is on the current master of DimensionalData and GLMakie version 0.8.10

julia> a = Union{Missing, Float32}[rand() for i in 1:10, y in 1:10];

julia> d = DimArray(a,(X(1:10), Y(1:10)))
10×10 DimArray{Union{Missing, Float32},2} with dimensions: 
  X Sampled{Int64} 1:10 ForwardOrdered Regular Points,
  Y Sampled{Int64} 1:10 ForwardOrdered Regular Points
     1         2         3         4          5          6         7         8           9         10
  1  0.477369  0.428641  0.465037  0.493597   0.0324597  0.796627  0.881686  0.98293     0.392058   0.865828
  2  0.559411  0.240099  0.483409  0.0257237  0.622509   0.412245  0.923384  0.00561059  0.406406   0.585697
                                                                                                  
  8  0.783714  0.953642  0.871693  0.877998   0.0367308  0.911016  0.87983   0.221123    0.396509   0.81738
  9  0.225941  0.462629  0.564913  0.24756    0.596844   0.959826  0.504811  0.284073    0.488005   0.731204
 10  0.335994  0.972847  0.830129  0.8264     0.060268   0.450467  0.432994  0.897073    0.148737   0.562426

julia> heatmap(d)
(t, xs, ys) = (ContinuousSurface(), 1:10, 1:10)
typeof(parent(A1)) = Matrix{Union{Missing, Float32}}
ERROR: MethodError: no method matching convert_arguments(::ContinuousSurface, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Matrix{Union{Missing, Float32}})

Closest candidates are:
  convert_arguments(::Type{<:Combined{Makie.band}}, ::Any, ::Any, ::Any)
   @ Makie ~/.julia/packages/Makie/1hq9u/src/basic_recipes/band.jl:20
  convert_arguments(::Type{<:Combined{Makie.rangebars}}, ::Any, ::Any, ::Any)
   @ Makie ~/.julia/packages/Makie/1hq9u/src/basic_recipes/error_and_rangebars.jl:116
  convert_arguments(::Type{<:Combined{Makie.errorbars}}, ::Any, ::Any, ::Any)
   @ Makie ~/.julia/packages/Makie/1hq9u/src/basic_recipes/error_and_rangebars.jl:66
  ...

Stacktrace:
 [1] convert_arguments(t::ContinuousSurface, A::DimArray{Union{Missing, Float32}, 2, Tuple{X{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}, Y{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Tuple{}, Matrix{Union{Missing, Float32}}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata})
   @ DimensionalDataMakie ~/Documents/conferences/202310_Bozen_OEMC_GW23/dev/DimensionalData/ext/DimensionalDataMakie.jl:358
 [2] _surface2(A::DimArray{Union{Missing, Float32}, 2, Tuple{X{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}, Y{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Tuple{}, Matrix{Union{Missing, Float32}}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}, attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, replacements::Tuple{})
   @ DimensionalDataMakie ~/Documents/conferences/202310_Bozen_OEMC_GW23/dev/DimensionalData/ext/DimensionalDataMakie.jl:168
 [3] heatmap(A::DimArray{Union{Missing, Float32}, 2, Tuple{X{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}, Y{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Tuple{}, Matrix{Union{Missing, Float32}}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}; x::Nothing, y::Nothing, colorbarkw::NamedTuple{(), Tuple{}}, attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ DimensionalDataMakie ~/Documents/conferences/202310_Bozen_OEMC_GW23/dev/DimensionalData/ext/DimensionalDataMakie.jl:134
 [4] heatmap(A::DimArray{Union{Missing, Float32}, 2, Tuple{X{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}, Y{DimensionalData.Dimensions.LookupArrays.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Int64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Tuple{}, Matrix{Union{Missing, Float32}}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata})
   @ DimensionalDataMakie ~/Documents/conferences/202310_Bozen_OEMC_GW23/dev/DimensionalData/ext/DimensionalDataMakie.jl:130
 [5] top-level scope
   @ REPL[99]:1
@rafaqz
Copy link
Owner

rafaqz commented Sep 27, 2023

Weird... how does that work in base Makie then.

Ohh it shouldn't have the UnitRange axes in the call. Will fix.

@rafaqz
Copy link
Owner

rafaqz commented Sep 27, 2023

Fixed on master

@rafaqz rafaqz closed this as completed Sep 27, 2023
@felixcremer
Copy link
Contributor Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants