Skip to content

Commit

Permalink
decrement should always return a vector (#241)
Browse files Browse the repository at this point in the history
* decremenet should always return a vector

* fix performance

* fix performance issue
  • Loading branch information
SobhanMP authored Sep 6, 2022
1 parent dfcc48a commit d88be9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/SparseArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ function decrement!(A::AbstractArray{T}) where T<:Integer
for i in eachindex(A); A[i] -= oneunit(T) end
A
end
decrement(A::AbstractArray{<:Integer}) = decrement!(copy(A))

decrement(A::AbstractArray) = let y = Array(A)
y .= y .- oneunit(eltype(A))
end

include("readonly.jl")
include("abstractsparse.jl")
Expand Down
2 changes: 0 additions & 2 deletions src/readonly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ Base.copy(x::ReadOnly) = ReadOnly(copy(parent(x)))
(==)(x::ReadOnly, y::ReadOnly) = parent(x) == parent(y)

Base.dataids(::ReadOnly) = tuple()
# Convert from 1-based to 0-based indices
decrement(A::ReadOnly) = decrement!(copy(parent(A)))

0 comments on commit d88be9f

Please sign in to comment.