diff --git a/.gitignore b/.gitignore index d7d1ab579..3b60b63b8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ GraphNeuralNetworks/docs/src/GNNGraphs GraphNeuralNetworks/docs/src/GNNlib tutorials/docs/build prova.jl +pyg.ipynb diff --git a/GNNGraphs/src/gnngraph.jl b/GNNGraphs/src/gnngraph.jl index 9934229f7..d7391f3c8 100644 --- a/GNNGraphs/src/gnngraph.jl +++ b/GNNGraphs/src/gnngraph.jl @@ -230,16 +230,20 @@ function Base.copy(g::GNNGraph; deep = false) end end +feature_summary(x::AbstractArray) = "$(dims2string(size(x)))" +feature_summary(x::AbstractString) = "string($(length(x)))" +feature_summary(x::T) where T = "$T" + function print_feature(io::IO, feature) if !isempty(feature) if length(keys(feature)) == 1 k = first(keys(feature)) v = first(values(feature)) - print(io, "$(k): $(dims2string(size(v)))") + print(io, "$(k): $(feature_summary(v))") else print(io, "(") for (i, (k, v)) in enumerate(pairs(feature)) - print(io, "$k: $(dims2string(size(v)))") + print(io, "$k: $(feature_summary(v))") if i == length(feature) print(io, ")") else diff --git a/GNNGraphs/test/gnngraph.jl b/GNNGraphs/test/gnngraph.jl index 0c15e6cff..abe9518cb 100644 --- a/GNNGraphs/test/gnngraph.jl +++ b/GNNGraphs/test/gnngraph.jl @@ -344,6 +344,13 @@ end @test g1 !== g2 end +@testset "show" begin + # no throw when global data is not an array + g = rand_graph(10, 20, gdata = "ciao") + @test sprint(show, g) == "GNNGraph(10, 20) with u: string(4) data" + @test sprint(show, MIME("text/plain"), g) == "GNNGraph:\n num_nodes: 10\n num_edges: 20\n gdata:\n u = 4-codeunit String" +end + ## Cannot test this because DataStore is not an ordered collection ## Uncomment when/if it will be based on OrderedDict # @testset "show" begin