Skip to content

Commit d65bcc0

Browse files
authored
Merge pull request #139 from JuliaArrays/staticarrayviewstrides
Fix strides for view of a StaticArray.
2 parents 82eae65 + 70519b9 commit d65bcc0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "3.1.7"
3+
version = "3.1.8"
44

55
[deps]
66
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"

src/ArrayInterface.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ function __init__()
926926
end
927927
return t
928928
end
929+
@inline strides(B::StaticArrays.SizedArray{S,T,M,N,A}) where {S,T,M,N,A<:SubArray} = strides(B.data)
929930
if StaticArrays.SizedArray{Tuple{8,8},Float64,2,2} isa UnionAll
930931
parent_type(::Type{<:StaticArrays.SizedArray{S,T,M,N,A}}) where {S,T,M,N,A} = A
931932
else

test/runtests.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ using ArrayInterface: StaticInt, True, False
55
import ArrayInterface: has_sparsestruct, findstructralnz, fast_scalar_indexing, lu_instance, device, contiguous_axis, contiguous_batch_size, stride_rank, dense_dims, static
66
@test ArrayInterface.ismutable(rand(3))
77

8-
using Aqua
9-
Aqua.test_all(ArrayInterface)
8+
if VERSION v"1.6"
9+
using Aqua
10+
Aqua.test_all(ArrayInterface)
11+
end
1012

1113
using StaticArrays
1214
x = @SVector [1,2,3]
@@ -460,6 +462,10 @@ using OffsetArrays
460462

461463
@test @inferred(ArrayInterface.indices(OffsetArray(view(PermutedDimsArray(A, (3,1,2)), 1, :, 2:4)', 3, -173),1)) === Base.Slice(ArrayInterface.OptionallyStaticUnitRange(4,6))
462464
@test @inferred(ArrayInterface.indices(OffsetArray(view(PermutedDimsArray(A, (3,1,2)), 1, :, 2:4)', 3, -173),2)) === Base.Slice(ArrayInterface.OptionallyStaticUnitRange(-172,-170))
465+
466+
Am = @MMatrix rand(2,10);
467+
@test @inferred(ArrayInterface.strides(view(Am,1,:))) === (StaticInt(2),)
468+
463469
end
464470

465471
@testset "Static-Dynamic Size, Strides, and Offsets" begin

0 commit comments

Comments
 (0)