Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
version = "0.10.35"
version = "0.10.36"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down
15 changes: 7 additions & 8 deletions src/blocksparsearrayinterface/blocksparsearrayinterface.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ArrayLayouts: ArrayLayouts
using BlockArrays: BlockArrays, AbstractBlockVector, Block, BlockIndex, BlockRange,
BlockSlice, BlockVector, BlockedUnitRange, BlockedVector, block, blockcheckbounds,
blockisequal, blocklength, blocklengths, blocks, findblockindex
BlockSlice, BlockVector, BlockedUnitRange, BlockedVector, BlocksView, block,
blockcheckbounds, blockisequal, blocklength, blocklengths, blocks, findblockindex
using FunctionImplementations: FunctionImplementations, permuteddims, zero!
using LinearAlgebra: Adjoint, Transpose
using SparseArraysBase: AbstractSparseArrayImplementationStyle, eachstoredindex,
Expand Down Expand Up @@ -75,13 +75,13 @@ julia> length(blocks(BlockedVector{Float64}(randn(0))))
1
```
=#
function blocktype(a::AbstractArray)
if isempty(blocks(a))
error("`blocktype` can't be determined if `isempty(blocks(a))`.")
end
return mapreduce(typeof, promote_type, blocks(a))
eltype_inferred(a::AbstractArray{T}) where {T} = T
function eltype_inferred(a::BlocksView{<:Any, N}) where {N}
return Base.promote_op(getindex, typeof(a), ntuple(Returns(Int), Val(N))...)
end

blocktype(a::AbstractArray) = eltype_inferred(blocks(a))

using BlockArrays: BlockArray
blockstype(::Type{<:BlockArray{<:Any, <:Any, B}}) where {B} = B
blockstype(a::BlockArray) = blockstype(typeof(a))
Expand Down Expand Up @@ -526,5 +526,4 @@ function blocks_blocksparse(
return @view blocks(parent(a))[map(to_blocks_indices, parentindices(a))...]
end

using BlockArrays: BlocksView
SparseArraysBase.storedlength(a::BlocksView) = length(a)
5 changes: 2 additions & 3 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ arrayts = (Array, JLArray)
@test (@constinferred blockstype(a)) <: BlockArrays.BlocksView{elt, 2}
# TODO: This is difficult to determine just from type information.
@test_broken blockstype(typeof(a)) <: BlockArrays.BlocksView{elt, 2}
@test (@constinferred blocktype(a)) <: SubArray{elt, 2, arrayt{elt, 2}}
# TODO: This is difficult to determine just from type information.
@test_broken blocktype(typeof(a)) <: SubArray{elt, 2, arrayt{elt, 2}}
@test blocktype(a) <: AbstractMatrix{elt}
@test_broken blocktype(typeof(a)) <: AbstractMatrix{elt}

# sparsemortar
for ax in (
Expand Down
Loading