Skip to content

Commit 24a1371

Browse files
committed
Fix tests
1 parent 09491bd commit 24a1371

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/fillarrays/kroneckerarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const SquareEyeKronecker{T,A<:SquareEye{T},B<:AbstractMatrix{T}} = KroneckerMatr
2121
const KroneckerSquareEye{T,A<:AbstractMatrix{T},B<:SquareEye{T}} = KroneckerMatrix{T,A,B}
2222
const SquareEyeSquareEye{T,A<:SquareEye{T},B<:SquareEye{T}} = KroneckerMatrix{T,A,B}
2323

24+
_getindex(a::Eye, I1::Colon, I2::Colon) = a
25+
2426
# Like `adapt` but preserves `Eye`.
2527
_adapt(to, a::Eye) = a
2628

src/kroneckerarray.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,13 @@ function Base.getindex(a::KroneckerVector, i::Integer)
182182
return a.a[cld(i, k)] * a.b[(i - 1) % k + 1]
183183
end
184184

185-
## function Base.getindex(a::KroneckerVector, i::CartesianProduct)
186-
## return a.a[i.a] ⊗ a.b[i.b]
187-
## end
185+
# Allow customizing for `FillArrays.Eye`.
186+
_getindex(a::AbstractArray, I...) = a[I...]
188187
function Base.getindex(a::KroneckerArray{<:Any,N}, I::Vararg{CartesianProduct,N}) where {N}
189-
return a.a[map(Base.Fix2(getfield, :a), I)...] a.b[map(Base.Fix2(getfield, :b), I)...]
188+
return _getindex(arg1(a), arg1.(I)...) _getindex(arg2(a), arg2.(I)...)
190189
end
191190
function Base.getindex(a::KroneckerArray{<:Any,N}, I::Vararg{CartesianPair,N}) where {N}
192-
return a.a[map(Base.Fix2(getfield, :a), I)...] a.b[map(Base.Fix2(getfield, :b), I)...]
191+
return _getindex(arg1(a), arg1.(I)...) _getindex(arg2(a), arg2.(I)...)
193192
end
194193
# Fix ambigiuity error.
195194
Base.getindex(a::KroneckerArray{<:Any,0}) = a.a[] * a.b[]

0 commit comments

Comments
 (0)