Merge pull request #579 from asbisen/master

add tests for stack and unstack
This commit is contained in:
Mike J Innes 2019-01-29 14:30:23 +00:00 committed by GitHub
commit dd95416a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
using Flux using Flux
using Flux: throttle, jacobian, glorot_uniform, glorot_normal using Flux: throttle, jacobian, glorot_uniform, glorot_normal, stack, unstack
using StatsBase: std using StatsBase: std
using Random using Random
using Test using Test
@ -97,3 +97,11 @@ end
@test eltype(f32(f64(m))[1].W.data) == Float32 @test eltype(f32(f64(m))[1].W.data) == Float32
@test Tracker.isleaf(f32(f64(m))[1].W) @test Tracker.isleaf(f32(f64(m))[1].W)
end end
@testset "Stacking" begin
stacked_array=[ 8 9 3 5; 9 6 6 9; 9 1 7 2; 7 4 10 6 ]
unstacked_array=[[8, 9, 9, 7], [9, 6, 1, 4], [3, 6, 7, 10], [5, 9, 2, 6]]
@test unstack(stacked_array, 2) == unstacked_array
@test stack(unstacked_array, 2) == stacked_array
@test stack(unstack(stacked_array, 1), 1) == stacked_array
end