From 6486430f83c2b4cf4c80a4ed50eae21ca86acbd7 Mon Sep 17 00:00:00 2001 From: Proyag Date: Thu, 6 Sep 2018 19:07:03 +0200 Subject: [PATCH 1/2] fixed indices to axes in batchindex function --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index c53f78642c..0ca38d1445 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -24,7 +24,7 @@ julia> chunk(1:10, 3) """ chunk(xs, n) = collect(Iterators.partition(xs, ceil(Int, length(xs)/n))) -batchindex(xs, i) = (reverse(Base.tail(reverse(indices(xs))))..., i) +batchindex(xs, i) = (reverse(Base.tail(reverse(axes(xs))))..., i) """ frequencies(xs) From f2e0c9a75a53aa4cdc8ed1d6dce12782200a929e Mon Sep 17 00:00:00 2001 From: Proyag Date: Thu, 6 Sep 2018 20:15:29 +0200 Subject: [PATCH 2/2] fix batch to handle Array{Int,1} input --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index 0ca38d1445..6a970f0b8d 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -66,7 +66,7 @@ julia> batch([[1,2,3],[4,5,6]]) function batch(xs) data = first(xs) isa AbstractArray ? similar(first(xs), size(first(xs))..., length(xs)) : - Vector{eltype(xs)}(length(xs)) + Vector{eltype(xs)}(undef, length(xs)) for (i, x) in enumerate(xs) data[batchindex(data, i)...] = x end