JuliaDataCubes / JuliaDataCubes/EarthDataLab.jl

Better Error message for failed cubefromshape

Open
#240 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue Triage
Dominant language
Julia
Stars
34
Forks
14
PR merge metrics
No merged PRs in 30d

Description

When I try to make a cubefromshape on a Cube which have X and Y axes instead of "Lat" and "Lon" Axes I get the following error.
I can circumvent the problem by renaming my axes before I do the cubefromshape but I think it would be nice to give the user a hint to do that and to have a more informing errror message.

ERROR: MethodError: no method matching length(::Nothing)
Closest candidates are:
  length(::DataStructures.DiBitVector) at /home/crem_fe/.julia/packages/DataStructures/DLSxi/src/dibit_vector.jl:40
  length(::IRTools.Inner.CFG) at /home/crem_fe/.julia/packages/IRTools/aSVI5/src/passes/passes.jl:18
  length(::VSCodeServer.JSON.Parser.MemoryParserState) at /home/crem_fe/.vscode/extensions/julialang.language-julia-1.0.10/scripts/packages/JSON/src/Parser.jl:29
  ...
Stacktrace:
 [1] cubefromshape_single(::String, ::Nothing, ::Nothing; labelsym::Nothing, T::Type{T} where T, kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:52
 [2] cubefromshape(::String, ::Vararg{Any,N} where N; samplefactor::Nothing, kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:77
 [3] cubefromshape(::String, ::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}; kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:74
 [4] randinds(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Int64; seed::Int64, nsamples::Int64, wrap::Nothing, inner::Bool) at /home/crem_fe/.julia/dev/ESDLHelpers/src/shapesampling.jl:31
 [5] getsample(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Int64, ::Int64; seed::Int64, nsamples::Int64, wrap::Nothing, inner::Bool) at /home/crem_fe/.julia/dev/ESDLHelpers/src/shapesampling.jl:47
 [6] get_data(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Array{String,1}) at /home/crem_fe/Documents/papers_wip/EMDAmazonas/scripts/intro_sorted.jl:74

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Shapes.jl at cubefromshape_single on line 52 and follow the cubefromshape calls around lines 74 and 77. Reproduce the failure with a Cube whose axes are named X and Y instead of Lat and Lon. Done means the operation reports an informative error and hints that the axes can be renamed.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.