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

Can't show a DimSlices object #646

Closed
felixcremer opened this issue Feb 23, 2024 · 4 comments
Closed

Can't show a DimSlices object #646

felixcremer opened this issue Feb 23, 2024 · 4 comments

Comments

@felixcremer
Copy link
Contributor

I am trying to debug @lazarusA groupby example for YAXArray and I found that I can't show a DimSlices object:

using YAXArrays, DimensionalData
using NetCDF
using Downloads
using Dates
using Statistics

url_path = "https://github.com/pydata/xarray-data/raw/master/rasm.nc"
filename = Downloads.download(url_path, "rasm.nc")
ds = Cube(filename)

#ds = Cube("/Users/lalonso/Documents/YAXArrays.jl/docs/rasm.nc")

g_ds = groupby(ds, Ti => season(; start=December))

julia> g_ds.data
╭─────────────────────────────────╮
│ 4-element DimSlices{YAXArray,1} │
├─────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────── dims ┐
   Ti [[4, 5, 6, 16, 17, 18, 28, 29, 30], [7, 8, 9, 19, 20, 21, 31, 32, 33], [10, 11, 12, 22, 23, 24, 34, 35, 36], [1, 2, 3, 13, 14, 15, 25, 26, 27]]
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Error showing value of type DimensionalData.DimSlices{YAXArray{Float64, 3, DiskArrays.SubDiskArray{Float64, 3, YAXArrayBase.NetCDFVariable{Float64, 3}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Vector{Int64}}, false}, Tuple{Dim{: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}}, Dim{: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}}, Ti{DimensionalData.Dimensions.LookupArrays.Sampled{CFTime.DateTimeNoLeap, SubArray{CFTime.DateTimeNoLeap, 1, Vector{CFTime.DateTimeNoLeap}, Tuple{Vector{Int64}}, false}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Irregular{Tuple{CFTime.DateTimeNoLeap, CFTime.DateTimeNoLeap}}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Dict{String, Any}}, 1, Tuple{Ti{Vector{Vector{Int64}}}}, YAXArray{Float64, 3, YAXArrayBase.NetCDFVariable{Float64, 3}, Tuple{Dim{: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}}, Dim{: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}}, Ti{DimensionalData.Dimensions.LookupArrays.Sampled{CFTime.DateTimeNoLeap, Vector{CFTime.DateTimeNoLeap}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Irregular{Tuple{Nothing, Nothing}}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.NoMetadata}}}, Dict{String, Any}}}:
ERROR: MethodError: no method matching rebuild(::Vector{Int64}, ::Int64)

Closest candidates are:
  rebuild(::At, ::Any)
   @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/LookupArrays/selector.jl:118
  rebuild(::DimensionalData.Dimensions.LookupArrays.Selector, ::Any)
   @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/LookupArrays/selector.jl:38
  rebuild(::AbstractDimArray, ::Any, ::Tuple, ::Any, ::Any)
   @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/array.jl:78
  ...

Stacktrace:
  [1] (::DimensionalData.var"#92#94")(d::Vector{Int64})
    @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/dimindices.jl:294
  [2] iterate
    @ ./generator.jl:47 [inlined]
  [3] collect
    @ ./array.jl:834 [inlined]
  [4] map
    @ ./abstractarray.jl:3313 [inlined]
  [5] DimensionalData.DimSlices(x::YAXArray{…}, dims::Ti{…}; drop::Bool)
    @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/dimindices.jl:294
  [6] DimSlices
    @ ~/Documents/GeoZarr.jl/dev/DimensionalData/src/dimindices.jl:292 [inlined]
  [7] setproperties_object
    @ ~/.julia/packages/ConstructionBase/JFKjZ/src/ConstructionBase.jl:217 [inlined]
  [8] setproperties
    @ ~/.julia/packages/ConstructionBase/JFKjZ/src/ConstructionBase.jl:131 [inlined]
  [9] rebuild
    @ ~/Documents/GeoZarr.jl/dev/DimensionalData/src/LookupArrays/LookupArrays.jl:56 [inlined]
 [10] getindex
    @ ~/Documents/GeoZarr.jl/dev/DimensionalData/src/dimindices.jl:18 [inlined]
 [11] _print_matrix(io::IOContext{…}, A::DimensionalData.DimSlices{…}, lookups::Tuple{…})
    @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/show.jl:251
 [12] print_matrix
    @ ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/show.jl:235 [inlined]
 [13] print_array
    @ ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/show.jl:193 [inlined]
 [14] show_after(io::IOContext{…}, mime::MIME{…}, A::DimensionalData.DimSlices{…})
    @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/show.jl:78
 [15] show(io::IOContext{…}, mime::MIME{…}, A::DimensionalData.DimSlices{…})
    @ DimensionalData ~/Documents/GeoZarr.jl/dev/DimensionalData/src/array/show.jl:17
 [16] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:273
 [17] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
 [18] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:259
 [19] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:278
 [20] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [21] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [22] invokelatest
    @ ./essentials.jl:889 [inlined]
 [23] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:315
 [24] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284
 [25] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
 [26] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:282
 [27] (::REPL.var"#do_respond#80"{})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911
 [28] (::VSCodeServer.var"#101#104"{REPL.var"#do_respond#80"{}})(mi::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/repl.jl:122
 [29] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [30] invokelatest
    @ ./essentials.jl:889 [inlined]
 [31] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656
 [32] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
 [33] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.
@rafaqz
Copy link
Owner

rafaqz commented Feb 23, 2024

On main ? Guess it needs its own show_after

@felixcremer
Copy link
Contributor Author

Yes, that is on main.

@rafaqz
Copy link
Owner

rafaqz commented Feb 29, 2024

Fixed

@rafaqz rafaqz closed this as completed Feb 29, 2024
@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