Skip to content

Commit e927178

Browse files
authored
reduced_indices for Tuple{Vararg{SOneTo}} (#1027)
1 parent 8ca11f8 commit e927178

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/SOneTo.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ end
7474

7575
Base.promote_rule(a::Type{Base.OneTo{T}}, ::Type{SOneTo{n}}) where {T,n} =
7676
Base.OneTo{promote_type(T, Int)}
77+
78+
function Base.reduced_indices(inds::Tuple{SOneTo,Vararg{SOneTo}}, d::Int)
79+
Base.reduced_indices(map(Base.OneTo, inds), d)
80+
end

test/abstractarray.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ using StaticArrays, Test, LinearAlgebra
234234
@test (@inferred f(v, i)) == length(v[i])
235235
end
236236
end
237+
238+
@testset "reduced_indices" begin
239+
s = SArray{Tuple{2,2,2},Int,3,8}((1,2,3,4,5,6,7,8))
240+
a = Array(s)
241+
for i in 1:ndims(s)
242+
rs = @inferred Base.reduced_indices(axes(s), i)
243+
@test rs == Base.reduced_indices(axes(a), i)
244+
end
245+
end
237246
end
238247

239248
@testset "permutedims" begin

0 commit comments

Comments
 (0)