-
Notifications
You must be signed in to change notification settings - Fork 48
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
Compact print of GNNGraphs #234
Conversation
A couple of problems I noticed: # ndata and edata too indented
julia> g = rand_graph(10, 20, ndata=rand(10), edata=(e=rand(2,20),w=rand(2,20)))
GNNGraph:
num_nodes = 10
num_edges = 20
ndata:
x => 10-element Vector{Float64}
edata:
e => 2×20 Matrix{Float64}
w => 2×20 Matrix{Float64}
# error
julia> [g,g,g]
3-element Vector{GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}}:
Error showing value of type Vector{GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}}:
ERROR: BoundsError: attempt to access Tuple{Int64} at index [2]
Stacktrace:
[1] getindex(t::Tuple, i::Int64)
@ Base ./tuple.jl:29
[2] print_feature(io::IOContext{IOBuffer}, feature::NamedTuple{(:x,), Tuple{Vector{Float64}}})
@ GraphNeuralNetworks.GNNGraphs ~/.julia/dev/GraphNeuralNetworks/src/GNNGraphs/gnngraph.jl:227
[3] print_all_features(io::IOContext{IOBuffer}, feat1::NamedTuple{(:x,), Tuple{Vector{Float64}}}, feat2::NamedTuple{(:e, :w), Tuple{Matrix{Float64}, Matrix{Float64}}}, feat3::NamedTuple{(), Tuple{}})
@ GraphNeuralNetworks.GNNGraphs ~/.julia/dev/GraphNeuralNetworks/src/GNNGraphs/gnngraph.jl:245
[4] show(io::IOContext{IOBuffer}, g::GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}})
@ GraphNeuralNetworks.GNNGraphs ~/.julia/dev/GraphNeuralNetworks/src/GNNGraphs/gnngraph.jl:261
[5] sprint(f::Function, args::GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}; context::IOContext{Base.TTY}, sizehint::Int64)
@ Base ./strings/io.jl:112
[6] alignment_from_show(io::IOContext{Base.TTY}, x::GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}})
@ Base ./show.jl:2719
[7] alignment(io::IOContext{Base.TTY}, x::GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}})
@ Base ./show.jl:2738
[8] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
@ Base ./arrayshow.jl:69
[9] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
@ Base ./arrayshow.jl:207
[10] print_matrix(io::IOContext{Base.TTY}, X::Vector{GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64) (repeats 2 times)
@ Base ./arrayshow.jl:171
[11] print_array
@ ./arrayshow.jl:358 [inlined]
[12] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, X::Vector{GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}})
@ Base ./arrayshow.jl:399
[13] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:267
[14] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
[15] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:260
[16] display(d::REPL.REPLDisplay, x::Any)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:272
[17] display(x::Any)
@ Base.Multimedia ./multimedia.jl:328
[18] #invokelatest#2
@ ./essentials.jl:729 [inlined]
[19] invokelatest
@ ./essentials.jl:726 [inlined]
[20] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:296
[21] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:278
[22] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
[23] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:276
[24] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:857
[25] #invokelatest#2
@ ./essentials.jl:729 [inlined]
[26] invokelatest
@ ./essentials.jl:726 [inlined]
[27] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2510
[28] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL ~/.julia/juliaup/julia-1.8.3+0.aarch64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248
[29] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL ./task.jl:484
# this is fine
julia> [ rand_graph(10,20),
rand_graph(10,20, ndata=(a=rand(5,10),)),
rand_graph(10,20, ndata=rand(5,10), edata=rand(2,20), gdata=rand(1,1)),
rand_graph(10,20, ndata=(a=rand(5,10), b=rand(3,10)), edata=rand(2,20))]
4-element Vector{GNNGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}}:
GNNGraph(10, 20) with no data
GNNGraph(10, 20) with a: 5×10 data
GNNGraph(10, 20) with x: 5×10, e: 2×20, u: 1×1 data
GNNGraph(10, 20) with (a: 5×10, b: 3×10), e: 2×20 data |
Needs also a |
const COO_T = Tuple{T, T, V} where {T <: AbstractVector{<:Integer}, V} | ||
const ADJLIST_T = AbstractVector{T} where T <: AbstractVector{<:Integer} | ||
const COO_T = Tuple{T,T,V} where {T<:AbstractVector{<:Integer},V} | ||
const ADJLIST_T = AbstractVector{T} where {T<:AbstractVector{<:Integer}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are a lot of unrelated code formatting changes in this PR. It is fine and you can keep them, but for the future, these changes should be done in a separate PR since they make it harder to review the actual changes in the PR.
fc3bee8
to
650ccce
Compare
Implementation of the format proposed in issue #169.
Example: