Skip to content

Commit 5102a7f

Browse files
committed
Test cat methods
1 parent f442b35 commit 5102a7f

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

test/basic.jl

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,100 @@ end
210210
end
211211

212212
@testset "concatenation" begin
213+
@testset "0-dim" begin
214+
x = fill(true)
215+
x_concrete = Reactant.to_rarray(x)
216+
217+
# NOTE [,,,] is a call to `vect`, not `*cat`
218+
# f = Reactant.compile((x_concrete,)) do x
219+
# return [x, x, x]
220+
# end
221+
# @test f(x_concrete) ≈ ones(3)
222+
223+
# vcat
224+
f = Reactant.compile((x_concrete,)) do x
225+
return [x; x; x]
226+
end
227+
@test f(x_concrete) == ones(Bool, 3)
228+
229+
# hcat
230+
f = Reactant.compile((x_concrete,)) do x
231+
return [x x x]
232+
end
233+
@test f(x_concrete) == ones(Bool, 1, 3)
234+
235+
# hvcat
236+
f = Reactant.compile((x_concrete,)) do x
237+
return [x x x; x x x]
238+
end
239+
@test f(x_concrete) == ones(Bool, 2, 3)
240+
241+
# typed_vcat
242+
f = Reactant.compile((x_concrete,)) do x
243+
return Int[x; x; x]
244+
end
245+
@test f(x_concrete) == ones(Int, 3)
246+
247+
# typed_hcat
248+
f = Reactant.compile((x_concrete,)) do x
249+
return Int[x; x; x]
250+
end
251+
@test f(x_concrete) == ones(Int, 1, 3)
252+
253+
# typed_hvcat
254+
f = Reactant.compile((x_concrete,)) do x
255+
return Int[x x x; x x x]
256+
end
257+
@test f(x_concrete) == ones(Int, 2, 3)
258+
end
259+
260+
@testset "1-dim" begin
261+
x = ones(Bool, 2)
262+
x_concrete = Reactant.to_rarray(x)
263+
264+
# NOTE [,,,] is a call to `vect`, not `*cat`
265+
# f = Reactant.compile((x_concrete,)) do x
266+
# return [x, x, x]
267+
# end
268+
# @test f(x_concrete) ≈ ones(3)
269+
270+
# vcat
271+
f = Reactant.compile((x_concrete,)) do x
272+
return [x; x; x]
273+
end
274+
@test f(x_concrete) == ones(Bool, 6)
275+
276+
# hcat
277+
f = Reactant.compile((x_concrete,)) do x
278+
return [x x x]
279+
end
280+
@test f(x_concrete) == ones(Bool, 2, 3)
281+
282+
# hvcat
283+
f = Reactant.compile((x_concrete,)) do x
284+
return [x x x; x x x]
285+
end
286+
@test f(x_concrete) == ones(Bool, 4, 3)
287+
288+
# typed_vcat
289+
f = Reactant.compile((x_concrete,)) do x
290+
return Int[x; x; x]
291+
end
292+
@test f(x_concrete) == ones(Int, 6)
293+
294+
# typed_hcat
295+
f = Reactant.compile((x_concrete,)) do x
296+
return Int[x; x; x]
297+
end
298+
@test f(x_concrete) == ones(Int, 2, 3)
299+
300+
# typed_hvcat
301+
f = Reactant.compile((x_concrete,)) do x
302+
return Int[x x x; x x x]
303+
end
304+
@test f(x_concrete) == ones(Int, 4, 3)
305+
end
306+
213307
x = ones(2, 4, 3)
214308
x_concrete = Reactant.to_rarray(x)
215309

0 commit comments

Comments
 (0)