Skip to content

Commit

Permalink
Run frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dsantra92 committed Feb 14, 2023
1 parent af54023 commit 3d1e300
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/datasets/graphs/tudataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function TUDataset(name; dir = nothing)
@assert minimum(st) == 1
source, target = st[:, 1], st[:, 2]

graph_indicator = readdlm(joinpath(d, "$(name)_graph_indicator.txt"), Int) |> vec
graph_indicator = readdlm(joinpath(d, "$(name)_graph_indicator.txt"), Int) |> vec
if !all(sort(unique(graph_indicator)) .== 1:length(unique(graph_indicator)))
@warn "Some graph indicators are not present in graph_indicator.txt. Ordering of graph and graph labels may not be consistent. Base.getindex might produce unexpected behavior for unaltered data."
@warn "Some graph indicators are not present in graph_indicator.txt. Ordering of graph and graph labels may not be consistent. Base.getindex might produce unexpected behavior for unaltered data."
end

num_nodes = length(graph_indicator)
Expand Down
10 changes: 5 additions & 5 deletions src/datasets/misc/wine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ julia> describe(dataset.dataframe)
"""
struct Wine <: SupervisedDataset
metadata::Dict{String, Any}
features
targets
dataframe
features::Any
targets::Any
dataframe::Any
end

function Wine(; as_df = true, dir = nothing)
@assert dir === nothing "custom `dir` is not supported at the moment."
@assert dir===nothing "custom `dir` is not supported at the moment."
path = joinpath(@__DIR__, "..", "..", "..", "data", "wine.csv")
df = read_csv(path)

features = df[!, DataFrames.Not(:Wine)]
targets = df[!, [:Wine]]

metadata = Dict{String, Any}()
metadata["path"] = path
metadata["feature_names"] = names(features)
Expand Down
10 changes: 5 additions & 5 deletions test/datasets/graphs_no_ci.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ end
@test data.num_edges == 24756
@test data.num_graphs == 2149

@test data.num_nodes == sum(g->g.num_nodes, data.graphs)
@test data.num_edges == sum(g->g.num_edges, data.graphs)
@test data.num_edges == sum(g->length(g.edge_index[1]), data.graphs)
@test data.num_edges == sum(g->length(g.edge_index[2]), data.graphs)
@test data.num_nodes == sum(g -> g.num_nodes, data.graphs)
@test data.num_edges == sum(g -> g.num_edges, data.graphs)
@test data.num_edges == sum(g -> length(g.edge_index[1]), data.graphs)
@test data.num_edges == sum(g -> length(g.edge_index[2]), data.graphs)
@test data.num_graphs == length(data) == length(data.graphs)

i = rand(1:length(data))
Expand All @@ -318,7 +318,7 @@ end
@test all(1 .<= g.edge_index[2] .<= g.num_nodes)

# graph data
@test size(data.graph_data.targets) == (2800, )
@test size(data.graph_data.targets) == (2800,)

# node data
@test size(g.node_data.features) == (2, g.num_nodes)
Expand Down
46 changes: 37 additions & 9 deletions test/datasets/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,48 @@ end
n_obs = 178
n_features = 13
n_targets = 1
feature_names = ["Alcohol", "Malic.acid", "Ash", "Acl", "Mg", "Phenols", "Flavanoids", "Nonflavanoid.phenols", "Proanth", "Color.int", "Hue", "OD", "Proline"]
feature_names = [
"Alcohol",
"Malic.acid",
"Ash",
"Acl",
"Mg",
"Phenols",
"Flavanoids",
"Nonflavanoid.phenols",
"Proanth",
"Color.int",
"Hue",
"OD",
"Proline",
]
target_names = ["Wine"]

d = Wine()
test_inmemory_supervised_table_dataset(d;
n_obs, n_features, n_targets,
feature_names, target_names)
n_obs, n_features, n_targets,
feature_names, target_names)


d = Wine(as_df=false)
d = Wine(as_df = false)
test_inmemory_supervised_table_dataset(d;
n_obs, n_features, n_targets,
feature_names, target_names,
Tx=Any, Ty=Int)
n_obs, n_features, n_targets,
feature_names, target_names,
Tx = Any, Ty = Int)

@test isequal(d[1].features, [14.23, 1.71, 2.43, 15.6, 127, 2.8, 3.06, 0.28, 2.29, 5.64, 1.04, 3.92, 1065])
@test isequal(d[1].features,
[
14.23,
1.71,
2.43,
15.6,
127,
2.8,
3.06,
0.28,
2.29,
5.64,
1.04,
3.92,
1065,
])
end

0 comments on commit 3d1e300

Please sign in to comment.