Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SparseArrayInterface] [BlockSparseArrays] Rename wrapper type unions #1584

Merged
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 NDTensors/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NDTensors"
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
authors = ["Matthew Fishman <[email protected]>"]
version = "0.3.65"
version = "0.3.66"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using BlockArrays: BlockLayout
using ..SparseArrayInterface: SparseLayout
using ..TypeParameterAccessors: parenttype, similartype

function ArrayLayouts.MemoryLayout(arraytype::Type{<:BlockSparseArrayLike})
function ArrayLayouts.MemoryLayout(arraytype::Type{<:AnyAbstractBlockSparseArray})
outer_layout = typeof(MemoryLayout(blockstype(arraytype)))
inner_layout = typeof(MemoryLayout(blocktype(arraytype)))
return BlockLayout{outer_layout,inner_layout}()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BlockArrays: AbstractBlockedUnitRange, BlockSlice
using Base.Broadcast: Broadcast

function Broadcast.BroadcastStyle(arraytype::Type{<:BlockSparseArrayLike})
function Broadcast.BroadcastStyle(arraytype::Type{<:AnyAbstractBlockSparseArray})
return BlockSparseArrayStyle{ndims(arraytype)}()
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TODO: Change to `AnyAbstractBlockSparseArray`.
function Base.cat(as::BlockSparseArrayLike...; dims)
function Base.cat(as::AnyAbstractBlockSparseArray...; dims)
# TODO: Use `sparse_cat` instead, currently
# that erroneously allocates too many blocks that are
# zero and shouldn't be stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,27 @@ end
# function SparseArrayInterface.sparse_mapreduce(::BlockSparseArrayStyle, f, a_dest::AbstractArray, a_srcs::Vararg{AbstractArray})
# end

function Base.map!(f, a_dest::AbstractArray, a_srcs::Vararg{BlockSparseArrayLike})
function Base.map!(f, a_dest::AbstractArray, a_srcs::Vararg{AnyAbstractBlockSparseArray})
sparse_map!(f, a_dest, a_srcs...)
return a_dest
end

function Base.map(f, as::Vararg{BlockSparseArrayLike})
function Base.map(f, as::Vararg{AnyAbstractBlockSparseArray})
return f.(as...)
end

function Base.copy!(a_dest::AbstractArray, a_src::BlockSparseArrayLike)
function Base.copy!(a_dest::AbstractArray, a_src::AnyAbstractBlockSparseArray)
sparse_copy!(a_dest, a_src)
return a_dest
end

function Base.copyto!(a_dest::AbstractArray, a_src::BlockSparseArrayLike)
function Base.copyto!(a_dest::AbstractArray, a_src::AnyAbstractBlockSparseArray)
sparse_copyto!(a_dest, a_src)
return a_dest
end

# Fix ambiguity error
function Base.copyto!(a_dest::LayoutArray, a_src::BlockSparseArrayLike)
function Base.copyto!(a_dest::LayoutArray, a_src::AnyAbstractBlockSparseArray)
sparse_copyto!(a_dest, a_src)
return a_dest
end
Expand All @@ -131,21 +131,21 @@ function Base.copyto!(
return a_dest
end

function Base.permutedims!(a_dest, a_src::BlockSparseArrayLike, perm)
function Base.permutedims!(a_dest, a_src::AnyAbstractBlockSparseArray, perm)
sparse_permutedims!(a_dest, a_src, perm)
return a_dest
end

function Base.mapreduce(f, op, as::Vararg{BlockSparseArrayLike}; kwargs...)
function Base.mapreduce(f, op, as::Vararg{AnyAbstractBlockSparseArray}; kwargs...)
return sparse_mapreduce(f, op, as...; kwargs...)
end

# TODO: Why isn't this calling `mapreduce` already?
function Base.iszero(a::BlockSparseArrayLike)
function Base.iszero(a::AnyAbstractBlockSparseArray)
return sparse_iszero(blocks(a))
end

# TODO: Why isn't this calling `mapreduce` already?
function Base.isreal(a::BlockSparseArrayLike)
function Base.isreal(a::AnyAbstractBlockSparseArray)
return sparse_isreal(blocks(a))
end
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ function SparseArrayInterface.sparse_storage(a::AbstractBlockSparseArray)
return BlockSparseStorage(a)
end

function SparseArrayInterface.nstored(a::BlockSparseArrayLike)
function SparseArrayInterface.nstored(a::AnyAbstractBlockSparseArray)
return sum(nstored, sparse_storage(blocks(a)); init=zero(Int))
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ end

# Override the default definition of `BlockArrays.blocksize`,
# which is incorrect for certain slices.
function BlockArrays.blocksize(a::SubArray{<:Any,<:Any,<:BlockSparseArrayLike})
function BlockArrays.blocksize(a::SubArray{<:Any,<:Any,<:AnyAbstractBlockSparseArray})
return blocklength.(axes(a))
end
function BlockArrays.blocksize(a::SubArray{<:Any,<:Any,<:BlockSparseArrayLike}, i::Int)
function BlockArrays.blocksize(
a::SubArray{<:Any,<:Any,<:AnyAbstractBlockSparseArray}, i::Int
)
# TODO: Maybe use `blocklength(axes(a, i))` which would be a bit faster.
return blocksize(a)[i]
end
Expand All @@ -33,22 +35,22 @@ end
# which don't handle subslices of blocks properly.
function Base.view(
a::SubArray{
<:Any,N,<:BlockSparseArrayLike,<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
<:Any,N,<:AnyAbstractBlockSparseArray,<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
},
I::Block{N},
) where {N}
return blocksparse_view(a, I)
end
function Base.view(
a::SubArray{
<:Any,N,<:BlockSparseArrayLike,<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
<:Any,N,<:AnyAbstractBlockSparseArray,<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
},
I::Vararg{Block{1},N},
) where {N}
return blocksparse_view(a, I...)
end
function Base.view(
V::SubArray{<:Any,1,<:BlockSparseArrayLike,<:Tuple{BlockSlice{<:BlockRange{1}}}},
V::SubArray{<:Any,1,<:AnyAbstractBlockSparseArray,<:Tuple{BlockSlice{<:BlockRange{1}}}},
I::Block{1},
)
return blocksparse_view(a, I)
Expand Down Expand Up @@ -154,7 +156,7 @@ function BlockArrays.viewblock(
return viewblock(a, to_tuple(block)...)
end

# Fixes ambiguity error with `BlockSparseArrayLike` definition.
# Fixes ambiguity error with `AnyAbstractBlockSparseArray` definition.
function Base.view(
a::SubArray{
T,N,<:AbstractBlockSparseArray{T,N},<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
Expand All @@ -163,7 +165,7 @@ function Base.view(
) where {T,N}
return viewblock(a, block)
end
# Fixes ambiguity error with `BlockSparseArrayLike` definition.
# Fixes ambiguity error with `AnyAbstractBlockSparseArray` definition.
function Base.view(
a::SubArray{
T,N,<:AbstractBlockSparseArray{T,N},<:Tuple{Vararg{BlockSlice{<:BlockRange{1}},N}}
Expand Down
Loading
Loading