Skip to content

Commit d8d2b73

Browse files
authored
Minimize ambiguities for similar (#67)
1 parent 457a392 commit d8d2b73

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
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.7.1"
4+
version = "0.7.2"
55

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

src/abstractsparsearray.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ end
2727
function Base.similar(a::AnyAbstractSparseArray, ax::Tuple)
2828
return similar(a, Unstored(unstoredsimilar(unstored(a), ax)))
2929
end
30-
function Base.similar(a::AnyAbstractSparseArray, T::Type, ax::Tuple)
30+
31+
function similar_sparsearray(a::AbstractArray, T::Type, ax::Tuple)
3132
return similar(a, Unstored(unstoredsimilar(unstored(a), T, ax)))
3233
end
33-
# Fix ambiguity error.
34-
function Base.similar(a::AnyAbstractSparseArray, T::Type, ax::Tuple{Int,Vararg{Int}})
35-
return similar(a, Unstored(unstoredsimilar(unstored(a), T, ax)))
34+
function Base.similar(a::AnyAbstractSparseArray, T::Type, ax::Tuple{Vararg{Int}})
35+
return similar_sparsearray(a, T, ax)
36+
end
37+
function Base.similar(
38+
a::AnyAbstractSparseArray, T::Type, ax::Tuple{Integer,Vararg{Integer}}
39+
)
40+
return similar_sparsearray(a, T, ax)
3641
end
37-
# Fix ambiguity error.
3842
function Base.similar(
3943
a::AnyAbstractSparseArray,
4044
T::Type,
4145
ax::Tuple{Union{Integer,Base.OneTo},Vararg{Union{Integer,Base.OneTo}}},
4246
)
43-
return similar(a, Unstored(unstoredsimilar(unstored(a), T, ax)))
47+
return similar_sparsearray(a, T, ax)
4448
end
4549

4650
using DerivableInterfaces: @derive

0 commit comments

Comments
 (0)