Skip to content

Commit 6e65672

Browse files
committed
Fix isstored with trailing singletons, vector show
1 parent 248dd87 commit 6e65672

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/abstractsparsearray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ using LinearAlgebra: LinearAlgebra
2828
@derive AnyAbstractSparseArray AbstractArrayOps
2929

3030
function Base.replace_in_print_matrix(
31-
A::AnyAbstractSparseArray{<:Any,2}, i::Integer, j::Integer, s::AbstractString
31+
a::AnyAbstractSparseVecOrMat, i::Integer, j::Integer, s::AbstractString
3232
)
33-
return isstored(A, CartesianIndex(i, j)) ? s : Base.replace_with_centered_mark(s)
33+
return isstored(a, i, j) ? s : Base.replace_with_centered_mark(s)
3434
end
3535

3636
# Special-purpose constructors

src/abstractsparsearrayinterface.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ end
3434

3535
# Minimal interface for `SparseArrayInterface`.
3636
# Fallbacks for dense/non-sparse arrays.
37-
@interface ::AbstractArrayInterface isstored(a::AbstractArray, I::Int...) = true
37+
@interface ::AbstractArrayInterface function isstored(
38+
a::AbstractArray{<:Any,N}, I::Vararg{Int,N}
39+
) where {N}
40+
@boundscheck checkbounds(a, I...)
41+
return true
42+
end
43+
@interface ::AbstractArrayInterface function isstored(a::AbstractArray, I::Int...)
44+
@boundscheck checkbounds(a, I...)
45+
I′ = ntuple(i -> I[i], ndims(a))
46+
return isstored(a, I′...)
47+
end
3848
@interface ::AbstractArrayInterface eachstoredindex(a::AbstractArray) = eachindex(a)
3949
@interface ::AbstractArrayInterface getstoredindex(a::AbstractArray, I::Int...) =
4050
getindex(a, I...)

src/sparsearraydok.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ storage(a::SparseArrayDOK) = a.storage
7373
Base.size(a::SparseArrayDOK) = a.size
7474

7575
storedvalues(a::SparseArrayDOK) = values(storage(a))
76-
function isstored(a::SparseArrayDOK, I::Int...)
76+
function isstored(a::SparseArrayDOK{<:Any,N}, I::Vararg{Int,N}) where {N}
7777
return CartesianIndex(I) in keys(storage(a))
7878
end
7979
function eachstoredindex(a::SparseArrayDOK)

0 commit comments

Comments
 (0)