Skip to content

Commit 7df375c

Browse files
authored
Fix typo in source code (#391)
Fixes #390
1 parent 0773db8 commit 7df375c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/sparsematrix.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,16 +641,16 @@ function copyto!(dest::AbstractMatrix, Rdest::CartesianIndices{2},
641641
return dest
642642
end
643643

644-
# Faster version for non-abstract Array and SparseMatrixCSC
644+
# Faster version for non-abstract Array and SparseMatrixCSC
645645
function Base.copyto!(A::Array{T}, S::SparseMatrixCSC{<:Number}) where {T<:Number}
646646
isempty(S) && return A
647647
length(A) < length(S) && throw(BoundsError())
648-
649-
# Zero elements that are also in S, don't change rest of A
648+
649+
# Zero elements that are also in S, don't change rest of A
650650
@inbounds for i in 1:length(S)
651651
A[i] = zero(T)
652652
end
653-
# Copy the structural nonzeros from S to A using
653+
# Copy the structural nonzeros from S to A using
654654
# the linear indices (to work when size(A)!=size(S))
655655
num_rows = size(S,1)
656656
rowval = getrowval(S)
@@ -4283,7 +4283,7 @@ function Base.swapcols!(A::AbstractSparseMatrixCSC, i, j)
42834283
function rangeexchange!(arr, irow, jrow)
42844284
if length(irow) == length(jrow)
42854285
for (a, b) in zip(irow, jrow)
4286-
@inbounds @swap(arr[i], arr[j])
4286+
@inbounds @swap(arr[a], arr[b])
42874287
end
42884288
return
42894289
end

test/issues.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,16 @@ end
789789
@test_throws MethodError sort!(x; banana=:blue); # From discussion at #335
790790
end
791791

792+
@testset "Issue #390" begin
793+
x = sparse([9 1 8
794+
0 3 72
795+
7 4 16])
796+
Base.swapcols!(x, 2, 3)
797+
@test x == sparse([9 8 1
798+
0 72 3
799+
7 16 4])
800+
end
801+
792802
end # SparseTestsBase
793803

794804
end # module

0 commit comments

Comments
 (0)