Skip to content

Commit 5e53555

Browse files
committed
Start fixing more slicing
1 parent 3b6cb1e commit 5e53555

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/abstractblocksparsearray/unblockedsubarray.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
using ArrayLayouts: ArrayLayouts, MemoryLayout
22
using Base.Broadcast: Broadcast, BroadcastStyle
3-
using BlockArrays: BlockArrays
3+
using BlockArrays: BlockArrays, Block, BlockIndexRange, BlockSlice
44
using TypeParameterAccessors: TypeParameterAccessors, parenttype, similartype
55

6+
const UnblockedIndices = Union{
7+
Vector{<:Integer},BlockSlice{<:Block{1}},BlockSlice{<:BlockIndexRange{1}}
8+
}
9+
610
const UnblockedSubArray{T,N} = SubArray{
7-
T,N,<:AbstractBlockSparseArray{T,N},<:Tuple{Vararg{Vector{<:Integer}}}
11+
T,N,<:AbstractBlockSparseArray{T,N},<:Tuple{Vararg{UnblockedIndices}}
812
}
913

1014
function BlockArrays.blocks(a::UnblockedSubArray)

test/test_basics.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ arrayts = (Array, JLArray)
5151
a[Block(2, 2)] = dev(randn(elt, 3, 3))
5252
@test_broken a[:, 4]
5353

54-
# TODO: Fix this and turn it into a proper test.
55-
a = dev(BlockSparseArray{elt}(undef, [2, 3], [2, 3]))
56-
a[Block(1, 1)] = dev(randn(elt, 2, 2))
57-
a[Block(2, 2)] = dev(randn(elt, 3, 3))
58-
@test_broken a[:, [2, 4]]
59-
6054
# TODO: Fix this and turn it into a proper test.
6155
a = dev(BlockSparseArray{elt}(undef, [2, 3], [2, 3]))
6256
a[Block(1, 1)] = dev(randn(elt, 2, 2))
@@ -719,6 +713,13 @@ arrayts = (Array, JLArray)
719713
I = ([3, 5], [2, 4])
720714
@test Array(a[I...]) == Array(a)[I...]
721715

716+
# TODO: Fix this and turn it into a proper test.
717+
a = dev(BlockSparseArray{elt}(undef, [2, 3], [2, 3]))
718+
a[Block(1, 1)] = dev(randn(elt, 2, 2))
719+
a[Block(2, 2)] = dev(randn(elt, 3, 3))
720+
I = (:, [2, 4])
721+
@test Array(a[I...]) == Array(a)[I...]
722+
722723
a = BlockSparseArray{elt}(undef, [2, 3], [2, 3])
723724
@views for b in [Block(1, 1), Block(2, 2)]
724725
a[b] = randn(elt, size(a[b]))

0 commit comments

Comments
 (0)