Skip to content

Commit 99d7c04

Browse files
authored
[SparseArraysBase] Delete unnecessary using statements (#1598)
* [SparseArraysBase] Delete unnecessary using statements * [NDTensors] Bump to v0.3.74
1 parent d9b4f51 commit 99d7c04

File tree

6 files changed

+25
-33
lines changed

6 files changed

+25
-33
lines changed

src/abstractsparsearray/base.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
using ..SparseArraysBase: SparseArraysBase
2-
31
# Base
42
function Base.:(==)(a1::AnyAbstractSparseArray, a2::AnyAbstractSparseArray)
5-
return SparseArraysBase.sparse_isequal(a1, a2)
3+
return sparse_isequal(a1, a2)
64
end
75

86
function Base.reshape(a::AnyAbstractSparseArray, dims::Tuple{Vararg{Int}})
9-
return SparseArraysBase.sparse_reshape(a, dims)
7+
return sparse_reshape(a, dims)
108
end
119

1210
function Base.zero(a::AnyAbstractSparseArray)
13-
return SparseArraysBase.sparse_zero(a)
11+
return sparse_zero(a)
1412
end
1513

1614
function Base.one(a::AnyAbstractSparseArray)
17-
return SparseArraysBase.sparse_one(a)
15+
return sparse_one(a)
1816
end
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
using ..SparseArraysBase: SparseArraysBase
2-
31
Base.size(a::AbstractSparseArray) = error("Not implemented")
42

53
function Base.similar(a::AbstractSparseArray, elt::Type, dims::Tuple{Vararg{Int}})
64
return error("Not implemented")
75
end
86

97
function Base.getindex(a::AbstractSparseArray, I...)
10-
return SparseArraysBase.sparse_getindex(a, I...)
8+
return sparse_getindex(a, I...)
119
end
1210

1311
# Fixes ambiguity error with `ArrayLayouts`.
1412
function Base.getindex(a::AbstractSparseMatrix, I1::AbstractVector, I2::AbstractVector)
15-
return SparseArraysBase.sparse_getindex(a, I1, I2)
13+
return sparse_getindex(a, I1, I2)
1614
end
1715

1816
# Fixes ambiguity error with `ArrayLayouts`.
1917
function Base.getindex(
2018
a::AbstractSparseMatrix, I1::AbstractUnitRange, I2::AbstractUnitRange
2119
)
22-
return SparseArraysBase.sparse_getindex(a, I1, I2)
20+
return sparse_getindex(a, I1, I2)
2321
end
2422

2523
function Base.isassigned(a::AbstractSparseArray, I::Integer...)
26-
return SparseArraysBase.sparse_isassigned(a, I...)
24+
return sparse_isassigned(a, I...)
2725
end
2826

2927
function Base.setindex!(a::AbstractSparseArray, I...)
30-
return SparseArraysBase.sparse_setindex!(a, I...)
28+
return sparse_setindex!(a, I...)
3129
end
3230

3331
function Base.fill!(a::AbstractSparseArray, value)
34-
return SparseArraysBase.sparse_fill!(a, value)
32+
return sparse_fill!(a, value)
3533
end

src/abstractsparsearray/sparsearrayinterface.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using Dictionaries: set!
2-
using ..SparseArraysBase: SparseArraysBase
32

4-
SparseArraysBase.sparse_storage(::AbstractSparseArray) = error("Not implemented")
3+
sparse_storage(::AbstractSparseArray) = error("Not implemented")
54

6-
function SparseArraysBase.index_to_storage_index(
5+
function index_to_storage_index(
76
a::AbstractSparseArray{<:Any,N}, I::CartesianIndex{N}
87
) where {N}
9-
!isassigned(SparseArraysBase.sparse_storage(a), I) && return nothing
8+
!isassigned(sparse_storage(a), I) && return nothing
109
return I
1110
end
1211

13-
function SparseArraysBase.setindex_notstored!(
12+
function setindex_notstored!(
1413
a::AbstractSparseArray{<:Any,N}, value, I::CartesianIndex{N}
1514
) where {N}
1615
iszero(value) && return a
@@ -20,7 +19,7 @@ end
2019
# TODO: Make this into a generic definition of all `AbstractArray`?
2120
# TODO: Check if this is efficient, or determine if this mapping should
2221
# be performed in `storage_index_to_index` and/or `index_to_storage_index`.
23-
function SparseArraysBase.sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSparseArray})
22+
function sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSparseArray})
2423
parent_storage = sparse_storage(parent(a))
2524
all_sliced_storage_indices = map(keys(parent_storage)) do I
2625
return map_index(a.indices, I)
@@ -31,7 +30,7 @@ function SparseArraysBase.sparse_storage(a::SubArray{<:Any,<:Any,<:AbstractSpars
3130
end
3231

3332
# TODO: Make this into a generic definition of all `AbstractArray`?
34-
function SparseArraysBase.stored_indices(
33+
function stored_indices(
3534
a::AnyPermutedDimsArray{<:Any,<:Any,<:Any,<:Any,<:AbstractSparseArray}
3635
)
3736
return Iterators.map(
@@ -40,7 +39,7 @@ function SparseArraysBase.stored_indices(
4039
end
4140

4241
# TODO: Make this into a generic definition of all `AbstractArray`?
43-
function SparseArraysBase.sparse_storage(
42+
function sparse_storage(
4443
a::AnyPermutedDimsArray{<:Any,<:Any,<:Any,<:Any,<:AbstractSparseArray}
4544
)
4645
return sparse_storage(parent(a))

src/sparsearraydok/arraylayouts.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using ArrayLayouts: ArrayLayouts, MemoryLayout, MulAdd
2-
using ..SparseArraysBase: AbstractSparseLayout, SparseLayout
32

43
ArrayLayouts.MemoryLayout(::Type{<:SparseArrayDOK}) = SparseLayout()
54

src/sparsearraydok/defaults.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Dictionaries: Dictionary
2-
using ..SparseArraysBase: Zero
32

43
default_zero() = Zero()
54
default_data(type::Type, ndims::Int) = Dictionary{default_keytype(ndims),type}()

src/sparsearraydok/sparsearraydok.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Accessors: @set
22
using Dictionaries: Dictionary, set!
33
using MacroTools: @capture
4-
using ..SparseArraysBase: SparseArraysBase, AbstractSparseArray, getindex_zero_function
54

65
# TODO: Parametrize by `data`?
76
struct SparseArrayDOK{T,N,Zero} <: AbstractSparseArray{T,N}
@@ -81,15 +80,15 @@ end
8180
# Base `AbstractArray` interface
8281
Base.size(a::SparseArrayDOK) = a.dims[]
8382

84-
SparseArraysBase.getindex_zero_function(a::SparseArrayDOK) = a.zero
85-
function SparseArraysBase.set_getindex_zero_function(a::SparseArrayDOK, f)
83+
getindex_zero_function(a::SparseArrayDOK) = a.zero
84+
function set_getindex_zero_function(a::SparseArrayDOK, f)
8685
return @set a.zero = f
8786
end
8887

89-
function SparseArraysBase.setindex_notstored!(
88+
function setindex_notstored!(
9089
a::SparseArrayDOK{<:Any,N}, value, I::CartesianIndex{N}
9190
) where {N}
92-
set!(SparseArraysBase.sparse_storage(a), I, value)
91+
set!(sparse_storage(a), I, value)
9392
return a
9493
end
9594

@@ -98,18 +97,18 @@ function Base.similar(a::SparseArrayDOK, elt::Type, dims::Tuple{Vararg{Int}})
9897
end
9998

10099
# `SparseArraysBase` interface
101-
SparseArraysBase.sparse_storage(a::SparseArrayDOK) = a.data
100+
sparse_storage(a::SparseArrayDOK) = a.data
102101

103-
function SparseArraysBase.dropall!(a::SparseArrayDOK)
104-
return empty!(SparseArraysBase.sparse_storage(a))
102+
function dropall!(a::SparseArrayDOK)
103+
return empty!(sparse_storage(a))
105104
end
106105

107106
SparseArrayDOK(a::AbstractArray) = SparseArrayDOK{eltype(a)}(a)
108107

109108
SparseArrayDOK{T}(a::AbstractArray) where {T} = SparseArrayDOK{T,ndims(a)}(a)
110109

111110
function SparseArrayDOK{T,N}(a::AbstractArray) where {T,N}
112-
return SparseArraysBase.sparse_convert(SparseArrayDOK{T,N}, a)
111+
return sparse_convert(SparseArrayDOK{T,N}, a)
113112
end
114113

115114
function Base.resize!(a::SparseArrayDOK{<:Any,N}, new_size::NTuple{N,Integer}) where {N}

0 commit comments

Comments
 (0)