Skip to content

Commit

Permalink
Merge branch 'master' into new-multidocs
Browse files Browse the repository at this point in the history
  • Loading branch information
aurorarossi committed Oct 26, 2024
2 parents 3247938 + 9d9e8d0 commit d68f529
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GNNGraphs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GNNGraphs"
uuid = "aed8fd31-079b-4b5a-b342-a13352159b8c"
authors = ["Carlo Lucibello and contributors"]
version = "1.2.0"
version = "1.2.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
14 changes: 8 additions & 6 deletions GNNGraphs/docs/src/temporalgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ GNNGraph:
```

## Data Features

Node, edge, and graph features can be added at construction time or later using:
A temporal graph can stode global feautre for the entire time series in the `tgdata` filed.
Also, each snapshot can store node, edge, and graph features in the `ndata`, `edata`, and `gdata` fields, respectively.

```jldoctest
julia> snapshots = [rand_graph(10,20; ndata = rand(3,10)), rand_graph(10,14; ndata = rand(4,10)), rand_graph(10,22; ndata = rand(5,10))]; # node features at construction time
julia> tg = TemporalSnapshotsGNNGraph(snapshots);
julia> tg.tgdata.y = rand(3,1); # graph features after construction
julia> tg.tgdata.y = rand(3,1); # add global features after construction
julia> tg
TemporalSnapshotsGNNGraph:
Expand All @@ -109,7 +109,7 @@ TemporalSnapshotsGNNGraph:
tgdata:
y = 3×1 Matrix{Float64}
julia> tg.ndata # vector of Datastore for node features
julia> tg.ndata # vector of DataStore containing node features for each snapshot
3-element Vector{DataStore}:
DataStore(10) with 1 element:
x = 3×10 Matrix{Float64}
Expand All @@ -118,8 +118,10 @@ julia> tg.ndata # vector of Datastore for node features
DataStore(10) with 1 element:
x = 5×10 Matrix{Float64}
julia> typeof(tg.ndata.x) # vector containing the x feature of each snapshot
Vector{Matrix{Float64}}
julia> [ds.x for ds in tg.ndata]; # vector containing the x feature of each snapshot
julia> [g.x for g in tg.snapshots]; # same vector as above, now accessing
# the x feature directly from the snapshots
```

## Graph convolutions on TemporalSnapshotsGNNGraph
Expand Down
2 changes: 2 additions & 0 deletions GNNGraphs/src/GNNGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,6 @@ include("gatherscatter.jl")
include("mldatasets.jl")
export mldataset2gnngraph

include("deprecations.jl")

end #module
10 changes: 1 addition & 9 deletions GNNGraphs/src/datastore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,7 @@ function Base.getproperty(ds::DataStore, s::Symbol)
end
end

function Base.getproperty(vds::Vector{DataStore}, s::Symbol)
if s === :_n
return [getn(ds) for ds in vds]
elseif s === :_data
return [getdata(ds) for ds in vds]
else
return [getdata(ds)[s] for ds in vds]
end
end


function Base.setproperty!(ds::DataStore, s::Symbol, x)
@assert s != :_n "cannot set _n directly"
Expand Down
13 changes: 13 additions & 0 deletions GNNGraphs/src/deprecations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Deprecated in V0.6

function Base.getproperty(vds::Vector{DataStore}, s::Symbol)
if s (:ref, :size) # these are arrays fields in V0.11
return getfield(vds, s)
elseif s === :_n
return [getn(ds) for ds in vds]
elseif s === :_data
return [getdata(ds) for ds in vds]
else
return [getdata(ds)[s] for ds in vds]
end
end
8 changes: 3 additions & 5 deletions GNNGraphs/test/datastore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ end
@test_throws DimensionMismatch ds.z=rand(12)
ds.z = [1:10;]
@test ds.z == [1:10;]
vec = [DataStore(10, (:x => x,)), DataStore(10, (:x => x, :y => rand(2, 10)))]
@test vec.x == [x, x]
@test_throws KeyError vec.z
@test vec._n == [10, 10]
@test vec._data == [Dict(:x => x), Dict(:x => x, :y => vec[2].y)]

# issue #504, where vector creation failed
@test fill(DataStore(), 3) isa Vector
end

@testset "setindex!" begin
Expand Down

0 comments on commit d68f529

Please sign in to comment.