From 360e6aec5f75f12e055963a7061ead7fccbac887 Mon Sep 17 00:00:00 2001 From: Natacha Javerzat Date: Thu, 20 Apr 2023 17:28:45 +0200 Subject: [PATCH 1/2] fix matrix display --- src/matrix.jl | 8 ++++++-- test/unit/display.jl | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/matrix.jl b/src/matrix.jl index 49fd7bb..ce334be 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -120,13 +120,17 @@ function Base.show(io::IO, matrix::DynamicSparseMatrix{K,L,T}) where {K,L,T} #col major iteration pma = matrix.colmajor.pcsc.pma semaphores = matrix.colmajor.pcsc.semaphores - j = 1 + col_keys = matrix.colmajor.col_keys + @show matrix.colmajor.col_keys + @show semaphores + tmp = 0 for (index, elmt) in enumerate(pma.array) if index in semaphores - j += 1 + tmp += 1 print(io, "\n") else if !isnothing(elmt) + j = col_keys[tmp] (i, value) = elmt println(io, " [$(j), $(i)] = $(value) ") end diff --git a/test/unit/display.jl b/test/unit/display.jl index cfddb56..6c249b1 100644 --- a/test/unit/display.jl +++ b/test/unit/display.jl @@ -7,8 +7,8 @@ end function test_matrix_display() - I = [1, 2, 3, 2, 6, 7, 1, 6, 8] #rows - J = [1, 1, 1, 2, 2, 2, 3, 3, 3] #columns + I = ['a', 'a', 'a', 'b', 'b', 'c', 'd', 'd', 'd'] #rows + J = ['x', 'x', 'x', 'y', 'y', 'y', 'z', 'z', 'z'] #columns V = [20, 30, 40, 20, 40, 50, 30, 50, 70] #value matrix = DynamicSparseArrays.dynamicsparse(I, J, V) @show matrix From 87c2b892cb5776c36bfcf69b4ec0237c6f18cc19 Mon Sep 17 00:00:00 2001 From: Natacha Javerzat Date: Thu, 20 Apr 2023 17:31:17 +0200 Subject: [PATCH 2/2] mineure --- src/matrix.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/matrix.jl b/src/matrix.jl index ce334be..bb1ce8c 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -121,8 +121,6 @@ function Base.show(io::IO, matrix::DynamicSparseMatrix{K,L,T}) where {K,L,T} pma = matrix.colmajor.pcsc.pma semaphores = matrix.colmajor.pcsc.semaphores col_keys = matrix.colmajor.col_keys - @show matrix.colmajor.col_keys - @show semaphores tmp = 0 for (index, elmt) in enumerate(pma.array) if index in semaphores