Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ GraphNeuralNetworks/docs/src/GNNGraphs
GraphNeuralNetworks/docs/src/GNNlib
tutorials/docs/build
prova.jl
pyg.ipynb
8 changes: 6 additions & 2 deletions GNNGraphs/src/gnngraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions GNNGraphs/test/gnngraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading