|
1 |
| -@test LearnBase.Minimizable <: Any |
2 |
| -@test LearnBase.Transformation <: Any |
3 |
| -@test LearnBase.StochasticTransformation <: LearnBase.Transformation |
| 1 | +@testset "Other" begin |
| 2 | + @test LearnBase.Minimizable <: Any |
| 3 | + @test LearnBase.Transformation <: Any |
| 4 | + @test LearnBase.StochasticTransformation <: LearnBase.Transformation |
4 | 5 |
|
5 |
| -@test typeof(LearnBase.transform) <: Function |
6 |
| -@test typeof(LearnBase.transform!) <: Function |
7 |
| -@test typeof(LearnBase.getobs) <: Function |
8 |
| -@test typeof(LearnBase.getobs!) <: Function |
9 |
| -@test typeof(LearnBase.learn) <: Function |
10 |
| -@test typeof(LearnBase.learn!) <: Function |
11 |
| -@test typeof(LearnBase.update) <: Function |
12 |
| -@test typeof(LearnBase.update!) <: Function |
| 6 | + @test typeof(LearnBase.transform) <: Function |
| 7 | + @test typeof(LearnBase.transform!) <: Function |
| 8 | + @test typeof(LearnBase.getobs) <: Function |
| 9 | + @test typeof(LearnBase.getobs!) <: Function |
| 10 | + @test typeof(LearnBase.learn) <: Function |
| 11 | + @test typeof(LearnBase.learn!) <: Function |
| 12 | + @test typeof(LearnBase.update) <: Function |
| 13 | + @test typeof(LearnBase.update!) <: Function |
13 | 14 |
|
14 |
| -@test typeof(LearnBase.grad) <: Function |
15 |
| -@test typeof(LearnBase.grad!) <: Function |
| 15 | + @test typeof(LearnBase.grad) <: Function |
| 16 | + @test typeof(LearnBase.grad!) <: Function |
| 17 | + @test typeof(LearnBase.prox) <: Function |
| 18 | + @test typeof(LearnBase.prox!) <: Function |
16 | 19 |
|
17 |
| -@test typeof(LearnBase.datasubset) <: Function |
| 20 | + @test typeof(LearnBase.datasubset) <: Function |
18 | 21 |
|
19 |
| -@test typeof(LearnBase.targets) <: Function |
20 |
| -@test typeof(LearnBase.gettarget) <: Function |
21 |
| -@test typeof(LearnBase.gettargets) <: Function |
| 22 | + @test typeof(LearnBase.targets) <: Function |
| 23 | + @test typeof(LearnBase.gettarget) <: Function |
| 24 | + @test typeof(LearnBase.gettargets) <: Function |
22 | 25 |
|
23 |
| -@test LearnBase.DataView <: AbstractVector |
24 |
| -@test LearnBase.DataView <: LearnBase.AbstractDataIterator |
25 |
| -@test LearnBase.DataView{Int} <: AbstractVector{Int} |
26 |
| -@test LearnBase.DataView{Int,Vector{Int}} <: LearnBase.AbstractDataIterator{Int,Vector{Int}} |
27 |
| -@test LearnBase.AbstractObsView <: LearnBase.DataView |
28 |
| -@test LearnBase.AbstractObsView <: LearnBase.AbstractObsIterator |
29 |
| -@test LearnBase.AbstractObsView{Int,Vector{Int}} <: LearnBase.DataView{Int,Vector{Int}} |
30 |
| -@test LearnBase.AbstractObsView{Int,Vector{Int}} <: LearnBase.AbstractObsIterator{Int,Vector{Int}} |
31 |
| -@test LearnBase.AbstractBatchView <: LearnBase.DataView |
32 |
| -@test LearnBase.AbstractBatchView <: LearnBase.AbstractBatchIterator |
33 |
| -@test LearnBase.AbstractBatchView{Int,Vector{Int}} <: LearnBase.DataView{Int,Vector{Int}} |
34 |
| -@test LearnBase.AbstractBatchView{Int,Vector{Int}} <: LearnBase.AbstractBatchIterator{Int,Vector{Int}} |
| 26 | + @test LearnBase.DataView <: AbstractVector |
| 27 | + @test LearnBase.DataView <: LearnBase.AbstractDataIterator |
| 28 | + @test LearnBase.DataView{Int} <: AbstractVector{Int} |
| 29 | + @test LearnBase.DataView{Int,Vector{Int}} <: LearnBase.AbstractDataIterator{Int,Vector{Int}} |
| 30 | + @test LearnBase.AbstractObsView <: LearnBase.DataView |
| 31 | + @test LearnBase.AbstractObsView <: LearnBase.AbstractObsIterator |
| 32 | + @test LearnBase.AbstractObsView{Int,Vector{Int}} <: LearnBase.DataView{Int,Vector{Int}} |
| 33 | + @test LearnBase.AbstractObsView{Int,Vector{Int}} <: LearnBase.AbstractObsIterator{Int,Vector{Int}} |
| 34 | + @test LearnBase.AbstractBatchView <: LearnBase.DataView |
| 35 | + @test LearnBase.AbstractBatchView <: LearnBase.AbstractBatchIterator |
| 36 | + @test LearnBase.AbstractBatchView{Int,Vector{Int}} <: LearnBase.DataView{Int,Vector{Int}} |
| 37 | + @test LearnBase.AbstractBatchView{Int,Vector{Int}} <: LearnBase.AbstractBatchIterator{Int,Vector{Int}} |
35 | 38 |
|
36 |
| -@test LearnBase.DataIterator <: LearnBase.AbstractDataIterator |
37 |
| -@test LearnBase.DataIterator{Int,Vector{Int}} <: LearnBase.AbstractDataIterator{Int,Vector{Int}} |
38 |
| -@test LearnBase.ObsIterator <: LearnBase.DataIterator |
39 |
| -@test LearnBase.ObsIterator <: LearnBase.AbstractObsIterator |
40 |
| -@test LearnBase.ObsIterator{Int,Vector{Int}} <: LearnBase.DataIterator{Int,Vector{Int}} |
41 |
| -@test LearnBase.ObsIterator{Int,Vector{Int}} <: LearnBase.AbstractObsIterator{Int,Vector{Int}} |
42 |
| -@test LearnBase.BatchIterator <: LearnBase.DataIterator |
43 |
| -@test LearnBase.BatchIterator <: LearnBase.AbstractBatchIterator |
44 |
| -@test LearnBase.BatchIterator{Int,Vector{Int}} <: LearnBase.DataIterator{Int,Vector{Int}} |
45 |
| -@test LearnBase.BatchIterator{Int,Vector{Int}} <: LearnBase.AbstractBatchIterator{Int,Vector{Int}} |
| 39 | + @test LearnBase.DataIterator <: LearnBase.AbstractDataIterator |
| 40 | + @test LearnBase.DataIterator{Int,Vector{Int}} <: LearnBase.AbstractDataIterator{Int,Vector{Int}} |
| 41 | + @test LearnBase.ObsIterator <: LearnBase.DataIterator |
| 42 | + @test LearnBase.ObsIterator <: LearnBase.AbstractObsIterator |
| 43 | + @test LearnBase.ObsIterator{Int,Vector{Int}} <: LearnBase.DataIterator{Int,Vector{Int}} |
| 44 | + @test LearnBase.ObsIterator{Int,Vector{Int}} <: LearnBase.AbstractObsIterator{Int,Vector{Int}} |
| 45 | + @test LearnBase.BatchIterator <: LearnBase.DataIterator |
| 46 | + @test LearnBase.BatchIterator <: LearnBase.AbstractBatchIterator |
| 47 | + @test LearnBase.BatchIterator{Int,Vector{Int}} <: LearnBase.DataIterator{Int,Vector{Int}} |
| 48 | + @test LearnBase.BatchIterator{Int,Vector{Int}} <: LearnBase.AbstractBatchIterator{Int,Vector{Int}} |
46 | 49 |
|
47 |
| -@test LearnBase.ObsDim.Constant <: LearnBase.ObsDimension |
48 |
| -@test LearnBase.ObsDim.First <: LearnBase.ObsDimension |
49 |
| -@test LearnBase.ObsDim.Last <: LearnBase.ObsDimension |
50 |
| -@test LearnBase.ObsDim.Undefined <: LearnBase.ObsDimension |
51 |
| -@test typeof(LearnBase.ObsDim.Constant(2)) <: LearnBase.ObsDim.Constant{2} |
| 50 | + @test LearnBase.ObsDim.Constant <: LearnBase.ObsDimension |
| 51 | + @test LearnBase.ObsDim.First <: LearnBase.ObsDimension |
| 52 | + @test LearnBase.ObsDim.Last <: LearnBase.ObsDimension |
| 53 | + @test LearnBase.ObsDim.Undefined <: LearnBase.ObsDimension |
| 54 | + @test typeof(LearnBase.ObsDim.Constant(2)) <: LearnBase.ObsDim.Constant{2} |
52 | 55 |
|
53 |
| -# IntervalSet |
54 |
| -let s = LearnBase.IntervalSet(-1,1) |
55 |
| - @test typeof(s) == LearnBase.IntervalSet{Int} |
56 |
| - @test typeof(s) <: AbstractSet |
57 |
| - for x in (-1,0,0.5,1,1.0) |
58 |
| - @test x in s |
| 56 | + # IntervalSet |
| 57 | + let s = LearnBase.IntervalSet(-1,1) |
| 58 | + @test typeof(s) == LearnBase.IntervalSet{Int} |
| 59 | + @test typeof(s) <: AbstractSet |
| 60 | + for x in (-1,0,0.5,1,1.0) |
| 61 | + @test x in s |
| 62 | + end |
| 63 | + for x in (-1-1e-10, 1+1e-10, -Inf, Inf, 2, NaN) |
| 64 | + @test !(x in s) |
| 65 | + end |
| 66 | + for i=1:10 |
| 67 | + x = rand(s) |
| 68 | + @test typeof(x) == Float64 |
| 69 | + @test x in s |
| 70 | + end |
| 71 | + xs = rand(s, 10) |
| 72 | + @test typeof(xs) == Vector{Float64} |
| 73 | + for x in xs |
| 74 | + @test typeof(x) == Float64 |
| 75 | + @test x in s |
| 76 | + end |
| 77 | + @test LearnBase.randtype(s) == Float64 |
| 78 | + # @show s LearnBase.randtype(s) |
59 | 79 | end
|
60 |
| - for x in (-1-1e-10, 1+1e-10, -Inf, Inf, 2, NaN) |
61 |
| - @test !(x in s) |
| 80 | + let s = LearnBase.IntervalSet(-1,1.0) |
| 81 | + @test typeof(s) == LearnBase.IntervalSet{Float64} |
| 82 | + @test typeof(s) <: AbstractSet |
| 83 | + @test 1 in s |
| 84 | + # @show s LearnBase.randtype(s) |
| 85 | + @test length(s) == 1 |
62 | 86 | end
|
63 |
| - for i=1:10 |
64 |
| - x = rand(s) |
65 |
| - @test typeof(x) == Float64 |
66 |
| - @test x in s |
67 |
| - end |
68 |
| - xs = rand(s, 10) |
69 |
| - @test typeof(xs) == Vector{Float64} |
70 |
| - for x in xs |
71 |
| - @test typeof(x) == Float64 |
72 |
| - @test x in s |
73 |
| - end |
74 |
| - @test LearnBase.randtype(s) == Float64 |
75 |
| - # @show s LearnBase.randtype(s) |
76 |
| -end |
77 |
| -let s = LearnBase.IntervalSet(-1,1.0) |
78 |
| - @test typeof(s) == LearnBase.IntervalSet{Float64} |
79 |
| - @test typeof(s) <: AbstractSet |
80 |
| - @test 1 in s |
81 |
| - # @show s LearnBase.randtype(s) |
82 |
| - @test length(s) == 1 |
83 |
| -end |
84 | 87 |
|
85 |
| -# IntervalSet{Vector} |
86 |
| -let s = LearnBase.IntervalSet([-1.,0.], [1.,1.]) |
87 |
| - @test typeof(s) == LearnBase.IntervalSet{Vector{Float64}} |
88 |
| - @test typeof(s) <: AbstractSet |
89 |
| - @test LearnBase.randtype(s) == Vector{Float64} |
90 |
| - @test typeof(rand(s)) == Vector{Float64} |
91 |
| - @test rand(s) in s |
92 |
| - @test [-1, 0] in s |
93 |
| - @test !([-1.5,0] in s) |
94 |
| - @test !([0,2] in s) |
95 |
| - @test length(s) == 2 |
96 |
| -end |
97 |
| - |
98 |
| -# DiscreteSet |
99 |
| -let s = LearnBase.DiscreteSet([-1,1]) |
100 |
| - @test typeof(s) == LearnBase.DiscreteSet{Vector{Int}} |
101 |
| - @test typeof(s) <: AbstractSet |
102 |
| - for x in (-1, 1, -1.0, 1.0) |
103 |
| - @test x in s |
104 |
| - end |
105 |
| - for x in (0, Inf, -Inf, NaN) |
106 |
| - @test !(x in s) |
| 88 | + # IntervalSet{Vector} |
| 89 | + let s = LearnBase.IntervalSet([-1.,0.], [1.,1.]) |
| 90 | + @test typeof(s) == LearnBase.IntervalSet{Vector{Float64}} |
| 91 | + @test typeof(s) <: AbstractSet |
| 92 | + @test LearnBase.randtype(s) == Vector{Float64} |
| 93 | + @test typeof(rand(s)) == Vector{Float64} |
| 94 | + @test rand(s) in s |
| 95 | + @test [-1, 0] in s |
| 96 | + @test !([-1.5,0] in s) |
| 97 | + @test !([0,2] in s) |
| 98 | + @test length(s) == 2 |
107 | 99 | end
|
108 |
| - for i=1:10 |
109 |
| - x = rand(s) |
110 |
| - @test typeof(x) == Int |
111 |
| - @test x in s |
112 |
| - end |
113 |
| - xs = rand(s, 10) |
114 |
| - @test typeof(xs) == Vector{Int} |
115 |
| - for x in xs |
116 |
| - @test typeof(x) == Int |
117 |
| - @test x in s |
118 |
| - end |
119 |
| - @test LearnBase.randtype(s) == Int |
120 |
| - @test length(s) == 2 |
121 |
| - @test s[1] == -1 |
122 |
| -end |
123 |
| -let s = LearnBase.DiscreteSet([-1,1.0]) |
124 |
| - @test typeof(s) == LearnBase.DiscreteSet{Vector{Float64}} |
125 |
| - @test typeof(s) <: AbstractSet |
126 |
| - @test typeof(rand(s)) == Float64 |
127 |
| - @test typeof(rand(s, 2)) == Vector{Float64} |
128 |
| -end |
129 | 100 |
|
130 |
| -# TupleSet |
131 |
| -let s = LearnBase.TupleSet(LearnBase.IntervalSet(0,1), LearnBase.DiscreteSet([0,1])) |
132 |
| - @test typeof(s) == LearnBase.TupleSet{Tuple{LearnBase.IntervalSet{Int}, LearnBase.DiscreteSet{Vector{Int}}}} |
133 |
| - @test typeof(s) <: AbstractSet |
134 |
| - for x in ([0,0], [0.0,0.0], [0.5,1.0]) |
135 |
| - @test x in s |
| 101 | + # DiscreteSet |
| 102 | + let s = LearnBase.DiscreteSet([-1,1]) |
| 103 | + @test typeof(s) == LearnBase.DiscreteSet{Vector{Int}} |
| 104 | + @test typeof(s) <: AbstractSet |
| 105 | + for x in (-1, 1, -1.0, 1.0) |
| 106 | + @test x in s |
| 107 | + end |
| 108 | + for x in (0, Inf, -Inf, NaN) |
| 109 | + @test !(x in s) |
| 110 | + end |
| 111 | + for i=1:10 |
| 112 | + x = rand(s) |
| 113 | + @test typeof(x) == Int |
| 114 | + @test x in s |
| 115 | + end |
| 116 | + xs = rand(s, 10) |
| 117 | + @test typeof(xs) == Vector{Int} |
| 118 | + for x in xs |
| 119 | + @test typeof(x) == Int |
| 120 | + @test x in s |
| 121 | + end |
| 122 | + @test LearnBase.randtype(s) == Int |
| 123 | + @test length(s) == 2 |
| 124 | + @test s[1] == -1 |
136 | 125 | end
|
137 |
| - for x in ([0,0.5], [-1,0]) |
138 |
| - @test !(x in s) |
| 126 | + let s = LearnBase.DiscreteSet([-1,1.0]) |
| 127 | + @test typeof(s) == LearnBase.DiscreteSet{Vector{Float64}} |
| 128 | + @test typeof(s) <: AbstractSet |
| 129 | + @test typeof(rand(s)) == Float64 |
| 130 | + @test typeof(rand(s, 2)) == Vector{Float64} |
139 | 131 | end
|
140 |
| - @test typeof(rand(s)) == Vector{Float64} |
141 |
| - @test typeof(rand(s, 2)) == Vector{Vector{Float64}} |
142 |
| - @test typeof(rand(s, Tuple)) == Tuple{Float64,Int} |
143 |
| - @test typeof(rand(s, Tuple, 2)) == Vector{Tuple{Float64,Int}} |
144 |
| - @test LearnBase.randtype(s) == Vector{Float64} |
145 | 132 |
|
146 |
| - tot = 0 |
147 |
| - for (i,x) in enumerate(s) |
148 |
| - @test x == s.sets[i] |
149 |
| - tot += length(x) |
150 |
| - end |
151 |
| - @test length(s) == tot |
152 |
| -end |
| 133 | + # TupleSet |
| 134 | + let s = LearnBase.TupleSet(LearnBase.IntervalSet(0,1), LearnBase.DiscreteSet([0,1])) |
| 135 | + @test typeof(s) == LearnBase.TupleSet{Tuple{LearnBase.IntervalSet{Int}, LearnBase.DiscreteSet{Vector{Int}}}} |
| 136 | + @test typeof(s) <: AbstractSet |
| 137 | + for x in ([0,0], [0.0,0.0], [0.5,1.0]) |
| 138 | + @test x in s |
| 139 | + end |
| 140 | + for x in ([0,0.5], [-1,0]) |
| 141 | + @test !(x in s) |
| 142 | + end |
| 143 | + @test typeof(rand(s)) == Vector{Float64} |
| 144 | + @test typeof(rand(s, 2)) == Vector{Vector{Float64}} |
| 145 | + @test typeof(rand(s, Tuple)) == Tuple{Float64,Int} |
| 146 | + @test typeof(rand(s, Tuple, 2)) == Vector{Tuple{Float64,Int}} |
| 147 | + @test LearnBase.randtype(s) == Vector{Float64} |
153 | 148 |
|
154 |
| -# arrays of sets |
155 |
| -let s = [LearnBase.IntervalSet(0,1), LearnBase.DiscreteSet([0,1])] |
156 |
| - @test typeof(s) == Vector{AbstractSet} |
157 |
| - for x in ([0,0], [0.0,0.0], [0.5,1.0]) |
158 |
| - @test x in s |
| 149 | + tot = 0 |
| 150 | + for (i,x) in enumerate(s) |
| 151 | + @test x == s.sets[i] |
| 152 | + tot += length(x) |
| 153 | + end |
| 154 | + @test length(s) == tot |
159 | 155 | end
|
160 |
| - for x in ([0,0.5], [-1,0]) |
161 |
| - @test !(x in s) |
| 156 | + |
| 157 | + # arrays of sets |
| 158 | + let s = [LearnBase.IntervalSet(0,1), LearnBase.DiscreteSet([0,1])] |
| 159 | + @test typeof(s) == Vector{AbstractSet} |
| 160 | + for x in ([0,0], [0.0,0.0], [0.5,1.0]) |
| 161 | + @test x in s |
| 162 | + end |
| 163 | + for x in ([0,0.5], [-1,0]) |
| 164 | + @test !(x in s) |
| 165 | + end |
| 166 | + @test typeof(rand(s)) == Vector{Float64} |
| 167 | + @test typeof(rand(s, 2)) == Vector{Vector{Float64}} |
162 | 168 | end
|
163 |
| - @test typeof(rand(s)) == Vector{Float64} |
164 |
| - @test typeof(rand(s, 2)) == Vector{Vector{Float64}} |
165 | 169 | end
|
0 commit comments