Skip to content

Commit 58b2316

Browse files
fix doctests (#586)
1 parent b96376c commit 58b2316

File tree

19 files changed

+93
-82
lines changed

19 files changed

+93
-82
lines changed

GNNGraphs/docs/make.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Pkg.instantiate()
66
using Documenter
77
using DocumenterInterLinks
88
using GNNGraphs
9-
using MLUtils # this is needed by setdocmeta!
109
import Graphs
1110
using Graphs: induced_subgraph
1211

12+
ENV["DATADEPS_ALWAYS_ACCEPT"] = true # for MLDatasets
1313

1414
DocMeta.setdocmeta!(GNNGraphs, :DocTestSetup, :(using GNNGraphs, MLUtils); recursive = true)
1515

@@ -25,7 +25,6 @@ mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/ma
2525

2626
makedocs(;
2727
modules = [GNNGraphs],
28-
doctest = false, # TODO enable doctest
2928
format = Documenter.HTML(; mathengine,
3029
prettyurls = get(ENV, "CI", nothing) == "true",
3130
assets = [],

GNNGraphs/docs/src/api/heterograph.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ Modules = [GNNGraphs]
3838
Pages = ["gnnheterograph/generate.jl"]
3939
Private = false
4040
```
41+
å

GNNGraphs/docs/src/guides/heterograph.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,28 @@ julia> g.etypes # edge types
8888

8989
Node, edge, and graph features can be added at construction time or later using:
9090
```jldoctest hetero
91-
# equivalent to g.ndata[:user][:x] = ...
92-
julia> g[:user].x = rand(Float32, 64, 3);
91+
julia> g[:user].x = rand(Float32, 64, 3); # equivalent to g.ndata[:user][:x] = ...
9392
9493
julia> g[:movie].z = rand(Float32, 64, 13);
9594
96-
# equivalent to g.edata[(:user, :rate, :movie)][:e] = ...
97-
julia> g[:user, :rate, :movie].e = rand(Float32, 64, 4);
95+
julia> g[:user, :rate, :movie].e = rand(Float32, 64, 4); # equivalent to g.edata[(:user, :rate, :movie)][:e] = ...
9896
9997
julia> g
10098
GNNHeteroGraph:
10199
num_nodes: Dict(:movie => 13, :user => 3)
102100
num_edges: Dict((:user, :rate, :movie) => 4)
103101
ndata:
104-
:movie => DataStore(z = [64×13 Matrix{Float32}])
105-
:user => DataStore(x = [64×3 Matrix{Float32}])
102+
:movie => DataStore(z = [64×13 Matrix{Float32}])
103+
:user => DataStore(x = [64×3 Matrix{Float32}])
106104
edata:
107-
(:user, :rate, :movie) => DataStore(e = [64×4 Matrix{Float32}])
105+
(:user, :rate, :movie) => DataStore(e = [64×4 Matrix{Float32}])
108106
```
109107

110108
## Batching
111109
Similarly to graphs, also heterographs can be batched together.
112110
```jldoctest hetero
111+
julia> using MLUtils
112+
113113
julia> gs = [rand_bipartite_heterograph((5, 10), 20) for _ in 1:32];
114114
115115
julia> MLUtils.batch(gs)

GNNGraphs/docs/src/guides/temporalgraph.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ Snapshots in a temporal graph can be accessed using indexing:
6565
julia> snapshots = [rand_graph(10, 20), rand_graph(10, 14), rand_graph(10, 22)];
6666
6767
julia> tg = TemporalSnapshotsGNNGraph(snapshots)
68+
TemporalSnapshotsGNNGraph:
69+
num_nodes: [10, 10, 10]
70+
num_edges: [20, 14, 22]
71+
num_snapshots: 3
6872
6973
julia> tg[1] # first snapshot
7074
GNNGraph:
@@ -169,7 +173,7 @@ TemporalSnapshotsGNNGraph:
169173
num_edges: [20, 14, 22]
170174
num_snapshots: 3
171175
tgdata:
172-
y = 3×1 Matrix{Float32}
176+
y = 3×1 Matrix{Float32}
173177
174178
julia> tg.ndata # vector of DataStore containing node features for each snapshot
175179
3-element Vector{DataStore}:

GNNGraphs/src/gnnheterograph/gnnheterograph.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,18 @@ function Base.show(io::IO, ::MIME"text/plain", g::GNNHeteroGraph)
198198
print(io, "\n ndata:")
199199
for k in sort(collect(keys(g.ndata)))
200200
isempty(g.ndata[k]) && continue
201-
print(io, "\n\t", _str(k), " => $(shortsummary(g.ndata[k]))")
201+
print(io, "\n ", _str(k), " => $(shortsummary(g.ndata[k]))")
202202
end
203203
end
204204
if !isempty(g.edata) && !all(isempty, values(g.edata))
205205
print(io, "\n edata:")
206206
for k in sort(collect(keys(g.edata)))
207207
isempty(g.edata[k]) && continue
208-
print(io, "\n\t$k => $(shortsummary(g.edata[k]))")
208+
print(io, "\n $k => $(shortsummary(g.edata[k]))")
209209
end
210210
end
211211
if !isempty(g.gdata)
212-
print(io, "\n gdata:\n\t")
212+
print(io, "\n gdata:\n ")
213213
shortsummary(io, g.gdata)
214214
end
215215
end

GNNGraphs/src/mldatasets.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ GNNGraph:
1515
num_nodes: 2708
1616
num_edges: 10556
1717
ndata:
18-
val_mask = 2708-element BitVector
19-
targets = 2708-element Vector{Int64}
20-
test_mask = 2708-element BitVector
21-
features = 1433×2708 Matrix{Float32}
22-
train_mask = 2708-element BitVector
18+
val_mask = 2708-element BitVector
19+
targets = 2708-element Vector{Int64}
20+
test_mask = 2708-element BitVector
21+
features = 1433×2708 Matrix{Float32}
22+
train_mask = 2708-element BitVector
2323
```
2424
"""
2525
function mldataset2gnngraph(dataset::D) where {D}

GNNGraphs/src/transform.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,14 @@ GNNGraph:
459459
num_nodes: 4
460460
num_edges: 5
461461
edata:
462-
e = 5-element Vector{Float64}
462+
e = 5-element Vector{Float64}
463463
464464
julia> g2 = to_bidirected(g)
465465
GNNGraph:
466466
num_nodes: 4
467467
num_edges: 7
468468
edata:
469-
e = 7-element Vector{Float64}
469+
e = 7-element Vector{Float64}
470470
471471
julia> edge_index(g2)
472472
([1, 2, 2, 3, 3, 4, 4], [2, 1, 3, 2, 4, 3, 4])
@@ -644,22 +644,22 @@ GNNGraph:
644644
num_nodes: 4
645645
num_edges: 4
646646
ndata:
647-
x = 3×4 Matrix{Float32}
647+
x = 3×4 Matrix{Float32}
648648
649649
julia> g2 = rand_graph(5, 4, ndata=zeros(Float32, 3, 5))
650650
GNNGraph:
651651
num_nodes: 5
652652
num_edges: 4
653653
ndata:
654-
x = 3×5 Matrix{Float32}
654+
x = 3×5 Matrix{Float32}
655655
656656
julia> g12 = MLUtils.batch([g1, g2])
657657
GNNGraph:
658658
num_nodes: 9
659659
num_edges: 8
660660
num_graphs: 2
661661
ndata:
662-
x = 3×9 Matrix{Float32}
662+
x = 3×9 Matrix{Float32}
663663
664664
julia> g12.ndata.x
665665
3×9 Matrix{Float32}:

GNNLux/docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1111
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
1212
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
1313
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
14+
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
1415
OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f"
1516
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
1617
TSne = "24678dba-d5e9-5843-a4c6-250288b04835"

GNNLux/docs/make.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ using GNNLux
1212
using Lux, GNNGraphs, GNNlib, Graphs
1313
using DocumenterInterLinks
1414

15+
ENV["DATADEPS_ALWAYS_ACCEPT"] = true # for MLDatasets
16+
17+
DocMeta.setdocmeta!(GNNGraphs, :DocTestSetup, :(using GNNGraphs, MLUtils); recursive = true)
18+
DocMeta.setdocmeta!(GNNlib, :DocTestSetup, :(using GNNlib); recursive = true)
1519
DocMeta.setdocmeta!(GNNLux, :DocTestSetup, :(using GNNLux); recursive = true)
1620

1721
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
@@ -37,7 +41,6 @@ cp(joinpath(@__DIR__, "../../GNNlib/docs/src"),
3741

3842
makedocs(;
3943
modules = [GNNLux, GNNGraphs, GNNlib],
40-
doctest = false, # TODO: enable doctest
4144
plugins = [interlinks],
4245
format = Documenter.HTML(; mathengine,
4346
prettyurls = get(ENV, "CI", nothing) == "true",
@@ -82,7 +85,7 @@ makedocs(;
8285
"Layers" => [
8386
"Basic layers" => "api/basic.md",
8487
"Convolutional layers" => "api/conv.md",
85-
# "Pooling layers" => "api/pool.md",
88+
"Pooling layers" => "api/pool.md",
8689
"Temporal Convolutional layers" => "api/temporalconv.md",
8790
# "Hetero Convolutional layers" => "api/heteroconv.md",
8891
]

GNNLux/docs/src/api/pool.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ CollapsedDocStrings = true
55

66
# Pooling Layers
77

8-
## Index
9-
10-
```@index
11-
Order = [:type, :function]
12-
Pages = ["pool.md"]
13-
```
14-
158
```@autodocs
169
Modules = [GNNLux]
1710
Pages = ["layers/pool.jl"]

0 commit comments

Comments
 (0)