@@ -1684,8 +1684,8 @@ typed_hcat(::Type{T}) where {T} = Vector{T}()
1684
1684
# # cat: special cases
1685
1685
vcat (X:: T... ) where {T} = T[ X[i] for i= eachindex (X) ]
1686
1686
vcat (X:: T... ) where {T<: Number } = T[ X[i] for i= eachindex (X) ]
1687
- hcat (X:: T... ) where {T} = T[ X[j] for i = 1 : 1 , j= eachindex (X) ]
1688
- hcat (X:: T... ) where {T<: Number } = T[ X[j] for i = 1 : 1 , j= eachindex (X) ]
1687
+ hcat (X:: T... ) where {T} = T[ X[j] for _ = 1 : 1 , j= eachindex (X) ]
1688
+ hcat (X:: T... ) where {T<: Number } = T[ X[j] for _ = 1 : 1 , j= eachindex (X) ]
1689
1689
1690
1690
vcat (X:: Number... ) = hvcat_fill! (Vector {promote_typeof(X...)} (undef, length (X)), X)
1691
1691
hcat (X:: Number... ) = hvcat_fill! (Matrix {promote_typeof(X...)} (undef, 1 ,length (X)), X)
@@ -1827,7 +1827,7 @@ function cat_shape(dims, shapes::Tuple)
1827
1827
return out_shape
1828
1828
end
1829
1829
# The new way to compute the shape (more inferable than combining cat_size & cat_shape, due to Varargs + issue#36454)
1830
- cat_size_shape (dims) = ntuple (zero , Val (length (dims)))
1830
+ cat_size_shape (dims) = ntuple (Returns ( 0 ) , Val (length (dims)))
1831
1831
@inline cat_size_shape (dims, X, tail... ) = _cat_size_shape (dims, _cshp (1 , dims, (), cat_size (X)), tail... )
1832
1832
_cat_size_shape (dims, shape) = shape
1833
1833
@inline _cat_size_shape (dims, shape, X, tail... ) = _cat_size_shape (dims, _cshp (1 , dims, shape, cat_size (X)), tail... )
@@ -1881,7 +1881,7 @@ end
1881
1881
@inline cat_t (:: Type{T} , X... ; dims) where {T} = _cat_t (dims, T, X... )
1882
1882
1883
1883
# Why isn't this called `__cat!`?
1884
- __cat (A, shape, catdims, X... ) = __cat_offset! (A, shape, catdims, ntuple (zero , length (shape)), X... )
1884
+ __cat (A, shape, catdims, X... ) = __cat_offset! (A, shape, catdims, ntuple (Returns ( 0 ) , length (shape)), X... )
1885
1885
1886
1886
function __cat_offset! (A, shape, catdims, offsets, x, X... )
1887
1887
# splitting the "work" on x from X... may reduce latency (fewer costly specializations)
@@ -2388,13 +2388,13 @@ _typed_hvncat_0d_only_one() =
2388
2388
function _typed_hvncat (:: Type{T} , :: Val{N} ) where {T, N}
2389
2389
N < 0 &&
2390
2390
throw (ArgumentError (" concatenation dimension must be non-negative" ))
2391
- return Array {T, N} (undef, ntuple (x -> 0 , Val (N)))
2391
+ return Array {T, N} (undef, ntuple (Returns ( 0 ) , Val (N)))
2392
2392
end
2393
2393
2394
2394
function _typed_hvncat (T:: Type , :: Val{N} , xs:: Number... ) where N
2395
2395
N < 0 &&
2396
2396
throw (ArgumentError (" concatenation dimension must be non-negative" ))
2397
- A = cat_similar (xs[1 ], T, (ntuple (x -> 1 , Val (N - 1 ))... , length (xs)))
2397
+ A = cat_similar (xs[1 ], T, (ntuple (Returns ( 1 ) , Val (N - 1 ))... , length (xs)))
2398
2398
hvncat_fill! (A, false , xs)
2399
2399
return A
2400
2400
end
@@ -2408,7 +2408,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as::AbstractArray...) where {T, N}
2408
2408
throw (ArgumentError (" concatenation dimension must be non-negative" ))
2409
2409
for a ∈ as
2410
2410
ndims (a) <= N || all (x -> size (a, x) == 1 , (N + 1 ): ndims (a)) ||
2411
- return _typed_hvncat (T, (ntuple (x -> 1 , Val (N - 1 ))... , length (as), 1 ), false , as... )
2411
+ return _typed_hvncat (T, (ntuple (Returns ( 1 ) , Val (N - 1 ))... , length (as), 1 ), false , as... )
2412
2412
# the extra 1 is to avoid an infinite cycle
2413
2413
end
2414
2414
@@ -2423,7 +2423,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as::AbstractArray...) where {T, N}
2423
2423
end
2424
2424
end
2425
2425
2426
- A = cat_similar (as[1 ], T, (ntuple (d -> size (as[1 ], d), N - 1 )... , Ndim, ntuple (x -> 1 , nd - N)... ))
2426
+ A = cat_similar (as[1 ], T, (ntuple (d -> size (as[1 ], d), N - 1 )... , Ndim, ntuple (Returns ( 1 ) , nd - N)... ))
2427
2427
k = 1
2428
2428
for a ∈ as
2429
2429
for i ∈ eachindex (a)
@@ -2450,7 +2450,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as...) where {T, N}
2450
2450
end
2451
2451
end
2452
2452
2453
- A = Array {T, nd} (undef, ntuple (x -> 1 , Val (N - 1 ))... , Ndim, ntuple (x -> 1 , nd - N)... )
2453
+ A = Array {T, nd} (undef, ntuple (Returns ( 1 ) , Val (N - 1 ))... , Ndim, ntuple (Returns ( 1 ) , nd - N)... )
2454
2454
2455
2455
k = 1
2456
2456
for a ∈ as
@@ -2518,7 +2518,7 @@ function hvncat_fill!(A::Array, row_first::Bool, xs::Tuple)
2518
2518
dd = nrc * (d - 1 )
2519
2519
for i ∈ 1 : nr
2520
2520
Ai = dd + i
2521
- for j ∈ 1 : nc
2521
+ for _ ∈ 1 : nc
2522
2522
@inbounds A[Ai] = xs[k]
2523
2523
k += 1
2524
2524
Ai += nr
@@ -2535,7 +2535,7 @@ end
2535
2535
function _typed_hvncat (T:: Type , dims:: NTuple{N, Int} , row_first:: Bool , as... ) where {N}
2536
2536
# function barrier after calculating the max is necessary for high performance
2537
2537
nd = max (maximum (cat_ndims (a) for a ∈ as), N)
2538
- return _typed_hvncat_dims (T, (dims... , ntuple (x -> 1 , nd - N)... ), row_first, as)
2538
+ return _typed_hvncat_dims (T, (dims... , ntuple (Returns ( 1 ) , nd - N)... ), row_first, as)
2539
2539
end
2540
2540
2541
2541
function _typed_hvncat_dims (:: Type{T} , dims:: NTuple{N, Int} , row_first:: Bool , as:: Tuple ) where {T, N}
@@ -2644,7 +2644,7 @@ end
2644
2644
function _typed_hvncat (T:: Type , shape:: NTuple{N, Tuple} , row_first:: Bool , as... ) where {N}
2645
2645
# function barrier after calculating the max is necessary for high performance
2646
2646
nd = max (maximum (cat_ndims (a) for a ∈ as), N)
2647
- return _typed_hvncat_shape (T, (shape... , ntuple (x -> shape[end ], nd - N)... ), row_first, as)
2647
+ return _typed_hvncat_shape (T, (shape... , ntuple (Returns ( shape[end ]) , nd - N)... ), row_first, as)
2648
2648
end
2649
2649
2650
2650
function _typed_hvncat_shape (:: Type{T} , shape:: NTuple{N, Tuple} , row_first, as:: Tuple ) where {T, N}
@@ -2976,8 +2976,8 @@ _vec_axis(A, ax=_iterator_axes(A)) = length(ax) == 1 ? only(ax) : OneTo(prod(len
2976
2976
end
2977
2977
2978
2978
function _dim_stack! (:: Val{dims} , B:: AbstractArray , x1, xrest) where {dims}
2979
- before = ntuple (d -> Colon (), dims - 1 )
2980
- after = ntuple (d -> Colon (), ndims (B) - dims)
2979
+ before = ntuple (Returns ( Colon () ), dims - 1 )
2980
+ after = ntuple (Returns ( Colon () ), ndims (B) - dims)
2981
2981
2982
2982
i = firstindex (B, dims)
2983
2983
copyto! (view (B, before... , i, after... ), x1)
@@ -3165,8 +3165,7 @@ _sub2ind_vec(i, I1, I...) = (@inline; (I1[i], _sub2ind_vec(i, I...)...))
3165
3165
_sub2ind_vec (i) = ()
3166
3166
3167
3167
function _ind2sub (inds:: Union{DimsInteger{N},Indices{N}} , ind:: AbstractVector{<:Integer} ) where N
3168
- M = length (ind)
3169
- t = ntuple (n-> similar (ind),Val (N))
3168
+ t = ntuple (_-> similar (ind),Val (N))
3170
3169
for (i,idx) in pairs (IndexLinear (), ind)
3171
3170
sub = _ind2sub (inds, idx)
3172
3171
for j = 1 : N
0 commit comments