diff --git a/NDTensors/Project.toml b/NDTensors/Project.toml index 2d2bc68d1c..0cfccfe138 100644 --- a/NDTensors/Project.toml +++ b/NDTensors/Project.toml @@ -1,7 +1,7 @@ name = "NDTensors" uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" authors = ["Matthew Fishman "] -version = "0.3.72" +version = "0.3.73" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" diff --git a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/base.jl b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/base.jl index eeedcf9518..0ea8265ed6 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/base.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/base.jl @@ -1,18 +1,16 @@ -using ..SparseArraysBase: SparseArraysBase - # Base function Base.:(==)(a1::AnyAbstractSparseArray, a2::AnyAbstractSparseArray) - return SparseArraysBase.sparse_isequal(a1, a2) + return sparse_isequal(a1, a2) end function Base.reshape(a::AnyAbstractSparseArray, dims::Tuple{Vararg{Int}}) - return SparseArraysBase.sparse_reshape(a, dims) + return sparse_reshape(a, dims) end function Base.zero(a::AnyAbstractSparseArray) - return SparseArraysBase.sparse_zero(a) + return sparse_zero(a) end function Base.one(a::AnyAbstractSparseArray) - return SparseArraysBase.sparse_one(a) + return sparse_one(a) end diff --git a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/baseinterface.jl b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/baseinterface.jl index f4488f984e..ba16da704d 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/baseinterface.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/baseinterface.jl @@ -1,5 +1,3 @@ -using ..SparseArraysBase: SparseArraysBase - Base.size(a::AbstractSparseArray) = error("Not implemented") function Base.similar(a::AbstractSparseArray, elt::Type, dims::Tuple{Vararg{Int}}) @@ -7,29 +5,29 @@ function Base.similar(a::AbstractSparseArray, elt::Type, dims::Tuple{Vararg{Int} end function Base.getindex(a::AbstractSparseArray, I...) - return SparseArraysBase.sparse_getindex(a, I...) + return sparse_getindex(a, I...) end # Fixes ambiguity error with `ArrayLayouts`. function Base.getindex(a::AbstractSparseMatrix, I1::AbstractVector, I2::AbstractVector) - return SparseArraysBase.sparse_getindex(a, I1, I2) + return sparse_getindex(a, I1, I2) end # Fixes ambiguity error with `ArrayLayouts`. function Base.getindex( a::AbstractSparseMatrix, I1::AbstractUnitRange, I2::AbstractUnitRange ) - return SparseArraysBase.sparse_getindex(a, I1, I2) + return sparse_getindex(a, I1, I2) end function Base.isassigned(a::AbstractSparseArray, I::Integer...) - return SparseArraysBase.sparse_isassigned(a, I...) + return sparse_isassigned(a, I...) end function Base.setindex!(a::AbstractSparseArray, I...) - return SparseArraysBase.sparse_setindex!(a, I...) + return sparse_setindex!(a, I...) end function Base.fill!(a::AbstractSparseArray, value) - return SparseArraysBase.sparse_fill!(a, value) + return sparse_fill!(a, value) end diff --git a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/sparsearrayinterface.jl b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/sparsearrayinterface.jl index a628d4cec1..8b86d1be12 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/sparsearrayinterface.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/abstractsparsearray/sparsearrayinterface.jl @@ -1,16 +1,15 @@ using Dictionaries: set! -using ..SparseArraysBase: SparseArraysBase -SparseArraysBase.sparse_storage(::AbstractSparseArray) = error("Not implemented") +sparse_storage(::AbstractSparseArray) = error("Not implemented") -function SparseArraysBase.index_to_storage_index( +function index_to_storage_index( a::AbstractSparseArray{<:Any,N}, I::CartesianIndex{N} ) where {N} - !isassigned(SparseArraysBase.sparse_storage(a), I) && return nothing + !isassigned(sparse_storage(a), I) && return nothing return I end -function SparseArraysBase.setindex_notstored!( +function setindex_notstored!( a::AbstractSparseArray{<:Any,N}, value, I::CartesianIndex{N} ) where {N} iszero(value) && return a @@ -20,7 +19,7 @@ end # TODO: Make this into a generic definition of all `AbstractArray`? # TODO: Check if this is efficient, or determine if this mapping should # be performed in `storage_index_to_index` and/or `index_to_storage_index`. -function SparseArraysBase.sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSparseArray}) +function sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSparseArray}) parent_storage = sparse_storage(parent(a)) all_sliced_storage_indices = map(keys(parent_storage)) do I return map_index(a.indices, I) @@ -31,7 +30,7 @@ function SparseArraysBase.sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSpars end # TODO: Make this into a generic definition of all `AbstractArray`? -function SparseArraysBase.stored_indices( +function stored_indices( a::AnyPermutedDimsArray{<:Any,<:Any,<:Any,<:Any,<:AbstractSparseArray} ) return Iterators.map( @@ -40,7 +39,7 @@ function SparseArraysBase.stored_indices( end # TODO: Make this into a generic definition of all `AbstractArray`? -function SparseArraysBase.sparse_storage( +function sparse_storage( a::AnyPermutedDimsArray{<:Any,<:Any,<:Any,<:Any,<:AbstractSparseArray} ) return sparse_storage(parent(a)) diff --git a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/arraylayouts.jl b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/arraylayouts.jl index 609220ac4f..fc2740d377 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/arraylayouts.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/arraylayouts.jl @@ -1,5 +1,4 @@ using ArrayLayouts: ArrayLayouts, MemoryLayout, MulAdd -using ..SparseArraysBase: AbstractSparseLayout, SparseLayout ArrayLayouts.MemoryLayout(::Type{<:SparseArrayDOK}) = SparseLayout() diff --git a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/defaults.jl b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/defaults.jl index 0b4fce5e55..1dc674b8b2 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/defaults.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/defaults.jl @@ -1,5 +1,4 @@ using Dictionaries: Dictionary -using ..SparseArraysBase: Zero default_zero() = Zero() default_data(type::Type, ndims::Int) = Dictionary{default_keytype(ndims),type}() diff --git a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/sparsearraydok.jl b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/sparsearraydok.jl index a5425212aa..95a5b14017 100644 --- a/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/sparsearraydok.jl +++ b/NDTensors/src/lib/SparseArraysBase/src/sparsearraydok/sparsearraydok.jl @@ -1,7 +1,6 @@ using Accessors: @set using Dictionaries: Dictionary, set! using MacroTools: @capture -using ..SparseArraysBase: SparseArraysBase, AbstractSparseArray, getindex_zero_function # TODO: Parametrize by `data`? struct SparseArrayDOK{T,N,Zero} <: AbstractSparseArray{T,N} @@ -81,15 +80,15 @@ end # Base `AbstractArray` interface Base.size(a::SparseArrayDOK) = a.dims[] -SparseArraysBase.getindex_zero_function(a::SparseArrayDOK) = a.zero -function SparseArraysBase.set_getindex_zero_function(a::SparseArrayDOK, f) +getindex_zero_function(a::SparseArrayDOK) = a.zero +function set_getindex_zero_function(a::SparseArrayDOK, f) return @set a.zero = f end -function SparseArraysBase.setindex_notstored!( +function setindex_notstored!( a::SparseArrayDOK{<:Any,N}, value, I::CartesianIndex{N} ) where {N} - set!(SparseArraysBase.sparse_storage(a), I, value) + set!(sparse_storage(a), I, value) return a end @@ -98,10 +97,10 @@ function Base.similar(a::SparseArrayDOK, elt::Type, dims::Tuple{Vararg{Int}}) end # `SparseArraysBase` interface -SparseArraysBase.sparse_storage(a::SparseArrayDOK) = a.data +sparse_storage(a::SparseArrayDOK) = a.data -function SparseArraysBase.dropall!(a::SparseArrayDOK) - return empty!(SparseArraysBase.sparse_storage(a)) +function dropall!(a::SparseArrayDOK) + return empty!(sparse_storage(a)) end SparseArrayDOK(a::AbstractArray) = SparseArrayDOK{eltype(a)}(a) @@ -109,7 +108,7 @@ SparseArrayDOK(a::AbstractArray) = SparseArrayDOK{eltype(a)}(a) SparseArrayDOK{T}(a::AbstractArray) where {T} = SparseArrayDOK{T,ndims(a)}(a) function SparseArrayDOK{T,N}(a::AbstractArray) where {T,N} - return SparseArraysBase.sparse_convert(SparseArrayDOK{T,N}, a) + return sparse_convert(SparseArrayDOK{T,N}, a) end function Base.resize!(a::SparseArrayDOK{<:Any,N}, new_size::NTuple{N,Integer}) where {N}