Skip to content

Commit

Permalink
all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloLucibello committed Apr 16, 2022
1 parent 5999557 commit 4bdb90d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/datasets_text/udenglish.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ function Base.getproperty(::Type{UD_English}, s::Symbol)
return testdata
elseif s === :devdata
@warn "UD_English.devdata() is deprecated, use `UD_English(split=:dev)[]` instead." maxlog=2
function testdata(; dir=nothing)
function devdata(; dir=nothing)
UD_English(; split=:dev, dir)[]
end
return testdata
return devdata
else
return getfield(UD_English, s)
end
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions test/datasets_text/deprecated_text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

end

# @testset "UD_English" begin
# x = UD_English.traindata()
# x = UD_English.devdata()
# x = UD_English.testdata()
# end
@testset "UD_English" begin
x = UD_English.traindata()
x = UD_English.devdata()
x = UD_English.testdata()
end

@testset "SMS Spam Collection" begin
X = SMSSpamCollection.features()
Expand Down
13 changes: 12 additions & 1 deletion test/datasets_text/text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ end
test_supervised_array_dataset(d;
n_obs, n_targets, n_features,
Tx, Ty)
end
end

@testset "UD_English" begin
n_features = ()
Tx = Vector{Vector{String}}
for (n_obs, split) in [(12543, :train), (2077, :test), (2001, :dev)]
d = UD_English(split)

test_unsupervised_array_dataset(d;
n_obs, n_features, Tx)
end
end
37 changes: 19 additions & 18 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Test
using MLDatasets
using MLDatasets: SupervisedDataset, AbstractDataset
using MLDatasets: SupervisedDataset, UnsupervisedDataset, AbstractDataset
using FileIO
using DataDeps
using DataFrames, CSV, Tables
Expand All @@ -18,24 +18,25 @@ include("test_utils.jl")

# we comment out deprecated test
dataset_tests = [
#### misc
# "datasets_misc/datasets_misc.jl",
# # "datasets_misc/deprecated_misc.jl",
# #### vision
# "datasets_vision/emnist.jl",
# "datasets_vision/fashion_mnist.jl",
# "datasets_vision/mnist.jl",
# # "datasets_vision/deprecated_fashion_mnist.jl",
# # "datasets_vision/deprecated_mnist.jl",
# #### graphs
# "datasets_graph/deprecated_citeseer.jl",
# "datasets_graph/deprecated_cora.jl",
# "datasets_graph/deprecated_pubmed.jl",
# "datasets_graph/deprecated_tudataset.jl",
# "datasets_graph/deprecated_polblogs.jl",
# #### text
### misc
"datasets_misc/misc.jl",
# "datasets_misc/deprecated_misc.jl",
#### vision
"datasets_vision/emnist.jl",
"datasets_vision/fashion_mnist.jl",
"datasets_vision/mnist.jl",
# "datasets_vision/deprecated_fashion_mnist.jl",
# "datasets_vision/deprecated_mnist.jl",
#### graphs
"datasets_graph/deprecated_citeseer.jl",
"datasets_graph/deprecated_cora.jl",
"datasets_graph/deprecated_pubmed.jl",
"datasets_graph/deprecated_tudataset.jl",
"datasets_graph/deprecated_polblogs.jl",
"datasets_graph/deprecated_karateclub.jl",
#### text
"datasets_text/text.jl",
"datasets_text/deprecated_text.jl",
# "datasets_text/deprecated_text.jl",
]

no_ci_dataset_tests = [
Expand Down
5 changes: 3 additions & 2 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ end

function test_unsupervised_array_dataset(d::D;
n_obs, n_features,
Tx=Any, Ty=Any,
Tx=Any,
conv2img=false) where {D<:UnsupervisedDataset}

n_features = n_features === nothing ? () : n_features
if n_features isa Int
@assert n_features != 0 "use n_features = () if you don't want features dimensions"
Nx == 2
Expand All @@ -147,7 +148,7 @@ function test_unsupervised_array_dataset(d::D;
@test isequal(d[idx], getobs(d.features, idx))
@test isequal(d[idx], getobs(d, idx))
idxs = rand(1:n_obs, 2)
@test isequal(d[idxs], getobs(d.features, idxs)
@test isequal(d[idxs], getobs(d.features, idxs))
@test isequal(d[idxs], getobs(d, idxs))

if conv2img
Expand Down

0 comments on commit 4bdb90d

Please sign in to comment.