Skip to content

Commit b17d41c

Browse files
committed
Try fixing tests
1 parent 65d5b1a commit b17d41c

File tree

2 files changed

+34
-30
lines changed
  • src
    • abstractblocksparsearray
    • blocksparsearrayinterface

2 files changed

+34
-30
lines changed

src/abstractblocksparsearray/map.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
using ArrayLayouts: LayoutArray
2+
using BlockArrays: AbstractBlockVector, Block
23
using LinearAlgebra: Adjoint, Transpose
34

5+
# TODO: Make this more general, independent of `AbstractBlockSparseArray`.
6+
# If the blocking of the slice doesn't match the blocking of the
7+
# parent array, reblock according to the blocking of the parent array.
8+
function reblock(
9+
a::SubArray{<:Any,<:Any,<:AbstractBlockSparseArray,<:Tuple{Vararg{AbstractUnitRange}}}
10+
)
11+
# TODO: This relies on the behavior that slicing a block sparse
12+
# array with a UnitRange inherits the blocking of the underlying
13+
# block sparse array, we might change that default behavior
14+
# so this might become something like `@blocked parent(a)[...]`.
15+
return @view parent(a)[UnitRange{Int}.(parentindices(a))...]
16+
end
17+
18+
# TODO: Make this more general, independent of `AbstractBlockSparseArray`.
19+
function reblock(
20+
a::SubArray{<:Any,<:Any,<:AbstractBlockSparseArray,<:Tuple{Vararg{NonBlockedArray}}}
21+
)
22+
return @view parent(a)[map(I -> I.array, parentindices(a))...]
23+
end
24+
25+
# TODO: Make this more general, independent of `AbstractBlockSparseArray`.
26+
function reblock(
27+
a::SubArray{
28+
<:Any,
29+
<:Any,
30+
<:AbstractBlockSparseArray,
31+
<:Tuple{Vararg{BlockIndices{<:AbstractBlockVector{<:Block{1}}}}},
32+
},
33+
)
34+
# Remove the blocking.
35+
return @view parent(a)[map(I -> Vector(I.blocks), parentindices(a))...]
36+
end
37+
438
function Base.map!(f, a_dest::AbstractArray, a_srcs::AnyAbstractBlockSparseArray...)
539
@interface interface(a_dest, a_srcs...) map!(f, a_dest, a_srcs...)
640
return a_dest

src/blocksparsearrayinterface/map.jl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,6 @@ end
8484

8585
reblock(a) = a
8686

87-
# If the blocking of the slice doesn't match the blocking of the
88-
# parent array, reblock according to the blocking of the parent array.
89-
function reblock(
90-
a::SubArray{<:Any,<:Any,<:AbstractBlockSparseArray,<:Tuple{Vararg{AbstractUnitRange}}}
91-
)
92-
# TODO: This relies on the behavior that slicing a block sparse
93-
# array with a UnitRange inherits the blocking of the underlying
94-
# block sparse array, we might change that default behavior
95-
# so this might become something like `@blocked parent(a)[...]`.
96-
return @view parent(a)[UnitRange{Int}.(parentindices(a))...]
97-
end
98-
99-
function reblock(
100-
a::SubArray{<:Any,<:Any,<:AbstractBlockSparseArray,<:Tuple{Vararg{NonBlockedArray}}}
101-
)
102-
return @view parent(a)[map(I -> I.array, parentindices(a))...]
103-
end
104-
105-
function reblock(
106-
a::SubArray{
107-
<:Any,
108-
<:Any,
109-
<:AbstractBlockSparseArray,
110-
<:Tuple{Vararg{BlockIndices{<:AbstractBlockVector{<:Block{1}}}}},
111-
},
112-
)
113-
# Remove the blocking.
114-
return @view parent(a)[map(I -> Vector(I.blocks), parentindices(a))...]
115-
end
116-
11787
# `map!` specialized to zero-dimensional inputs.
11888
function map_zero_dim! end
11989

0 commit comments

Comments
 (0)