Skip to content

Commit c572748

Browse files
authored
Fix ambiguities in block to_indices introduced in BlockArrays v1.4 (#199)
* Fix ambiguities in block to_indices introduced in BlockArrays v1.4 * Update ContinuumArrays.jl * add coverage
1 parent 6397146 commit c572748

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ContinuumArrays"
22
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
3-
version = "0.19"
3+
version = "0.19.1"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -29,7 +29,7 @@ ContinuumArraysRecipesBaseExt = "RecipesBase"
2929
AbstractFFTs = "1.0"
3030
ArrayLayouts = "1.0"
3131
BandedMatrices = "1"
32-
BlockArrays = "1"
32+
BlockArrays = "1.4"
3333
DomainSets = "0.6, 0.7"
3434
FastTransforms = "0.15, 0.16, 0.17"
3535
FillArrays = "1.0"

src/ContinuumArrays.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupp
1111
simplifiable, _simplify, AbstractLazyLayout, AbstractPaddedLayout, simplify, Dot
1212
import LinearAlgebra: pinv, inv, dot, norm2, ldiv!, mul!
1313
import BandedMatrices: AbstractBandedLayout, _BandedMatrix
14-
import BlockArrays: block, blockindex, unblock, blockedrange, _BlockedUnitRange, _BlockArray
14+
import BlockArrays: block, blockindex, unblock, blockedrange, _BlockedUnitRange, _BlockArray, BlockIndexRange, _maybetail
1515
import FillArrays: AbstractFill, getindex_value, SquareEye
1616
import ArrayLayouts: mul, ldiv, ZerosLayout, ScalarLayout, AbstractStridedLayout, check_mul_axes, check_ldiv_axes
1717
import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclusion, SubQuasiArray,
@@ -85,9 +85,15 @@ end
8585
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{BlockIndex{1}, Vararg{Any}}) =
8686
(inds[1][I[1]], to_indices(A, _cutdim(inds, I[1]), tail(I))...)
8787
@inline to_indices(A::AbstractQuasiArray, I::Tuple{BlockRange, Vararg{Any}}) = to_indices(A, axes(A), I)
88+
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{AbstractVector{Block{1,R}}, Vararg{Any}}) where R =
89+
(unblock(A, inds, I), to_indices(A, _maybetail(inds), tail(I))...)
90+
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{BlockIndexRange{1,R}, Vararg{Any}}) where R =
91+
(unblock(A, inds, I), to_indices(A, _maybetail(inds), tail(I))...)
92+
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{AbstractVector{<:BlockIndex{1}}, Vararg{Any}}) =
93+
(inds[1][I[1]], to_indices(A, _cutdim(inds, I[1]), tail(I))...)
94+
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{AbstractVector{<:BlockIndexRange{1}}, Vararg{Any}}) =
95+
(unblock(A, inds, I), to_indices(A, _maybetail(inds), tail(I))...)
8896

89-
@inline to_indices(A::AbstractQuasiArray, inds, I::Tuple{AbstractArray{<:BlockIndex{1}}, Vararg{Any}}) =
90-
(inds[1][I[1]], to_indices(A, _cutdim(inds, I[1]), tail(I))...)
9197

9298
checkpoints(x::Number) = x
9399
checkpoints(d::AbstractInterval{T}) where T = width(d) .* SVector{3,float(T)}(0.823972,0.01,0.3273484) .+ leftendpoint(d)

test/test_basisconcat.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ import ContinuumArrays: PiecewiseBasis, VcatBasis, HvcatBasis, arguments, ApplyL
8383
@test S == S
8484

8585
@test S[0.1, 1] == [S1[0.1,1] 0; 0 0]
86-
@test S[0.1,Block(1)] == [[S1[0.1,1] 0; 0 0], [S1[0.1,2] 0; 0 0]]
8786
@test S[0.1,Block(1)[1]] == [S1[0.1,1] 0; 0 0]
87+
@test S[0.1,[Block(1)[1]]] == S[0.1,Block(1)[1:1]] == S[0.1,[Block(1)[1:1]]] == [[S1[0.1,1] 0; 0 0]]
88+
@test S[0.1,Block.(1:1)] == S[0.1,Block(1)] == S[0.1,[Block(1)]] == [[S1[0.1,1] 0; 0 0], [S1[0.1,2] 0; 0 0]]
8889
@test S[0.1,getindex.(Block(1),1:2)] == [[S1[0.1,1] 0; 0 0], [S1[0.1,2] 0; 0 0]]
8990
D = Derivative(axes(S,1))
9091
@test_broken (D*S)[0.1,1] # throws error

0 commit comments

Comments
 (0)