Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Dec 11, 2024
1 parent 2ac5277 commit bc615ea
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 94 deletions.
3 changes: 2 additions & 1 deletion src/BlockArraysExtensions/BlockArraysExtensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ function view!(a::AbstractArray{<:Any,N}, index::Vararg{BlockIndexRange{1},N}) w
end

using MacroTools: @capture
using SparseArraysBase: is_getindex_expr
is_getindex_expr(expr::Expr) = (expr.head === :ref)
is_getindex_expr(x) = false
macro view!(expr)
if !is_getindex_expr(expr)
error("@view must be used with getindex syntax (as `@view! a[i,j,...]`)")
Expand Down
4 changes: 2 additions & 2 deletions src/abstractblocksparsearray/sparsearrayinterface.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BlockArrays: Block
using SparseArraysBase: SparseArraysBase, sparse_storage, eachstoredindex, storedlength
using SparseArraysBase: SparseArraysBase, eachstoredindex, storedlength, storedvalues

# Structure storing the block sparse storage
struct BlockSparseStorage{Arr<:AbstractBlockSparseArray}
Expand Down Expand Up @@ -35,5 +35,5 @@ end
## end

function SparseArraysBase.storedlength(a::AnyAbstractBlockSparseArray)
return sum(storedlength, sparse_storage(blocks(a)); init=zero(Int))
return sum(storedlength, storedvalues(blocks(a)); init=zero(Int))
end
2 changes: 1 addition & 1 deletion src/blocksparsearrayinterface/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function map_stored_blocks(f, a::AbstractArray)
# TODO: `block_stored_indices` should output `Indices` storing
# the stored Blocks, not a `Dictionary` from cartesian indices
# to Blocks.
bs = collect(block_stored_indices(a))
bs = collect(block_eachstoredindex(a))
ds = map(b -> f(@view(a[b])), bs)
# We manually specify the block type using `Base.promote_op`
# since `a[b]` may not be inferrable. For example, if `blocktype(a)`
Expand Down
Loading

0 comments on commit bc615ea

Please sign in to comment.