Skip to content

Commit 01ffb20

Browse files
committed
Fix show method and prepare for 0.4.0
1 parent 85d879e commit 01ffb20

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseMatricesCSR"
22
uuid = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
33
authors = ["Víctor Sande <[email protected]>"]
4-
version = "0.3.1"
4+
version = "0.4.0"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/SparseMatrixCSR.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ end
4848
show(io::IO, S::SparseMatrixCSR) = show(convert(IOContext, io), S::SparseMatrixCSR)
4949
#show(io::IOContext, S::SparseMatrixCSR) = dump(S)
5050

51-
function Base.show(io::IOContext, S::SparseMatrixCSR)
51+
function show(io::IOContext, S::SparseMatrixCSR{Bi}) where{Bi}
5252
nnz(S) == 0 && return show(io, MIME("text/plain"), S)
5353

5454
ioc = IOContext(io, :compact => true)
5555
function _format_line(r, col, padr, padc)
56-
print(ioc, "\n [", rpad(S.colval[r], padr), ", ", lpad(col, padc), "] = ")
56+
print(ioc, "\n [", rpad(col, padr), ", ", lpad(S.colval[r], padc), "] = ")
5757
if isassigned(S.nzval, Int(r))
5858
show(ioc, S.nzval[r])
5959
else
@@ -75,17 +75,17 @@ function Base.show(io::IOContext, S::SparseMatrixCSR)
7575

7676
rows = displaysize(io)[1] - 4 # -4 from [Prompt, header, newline after elements, new prompt]
7777
if !get(io, :limit, false) || rows >= nnz(S) # Will the whole matrix fit when printed?
78-
cols = _get_cols(1, nnz(S))
78+
cols = _get_cols(Bi, nnz(S)+S.offset)
7979
padr, padc = ndigits.((maximum(S.colval[1:nnz(S)]), cols[end]))
80-
_format_line.(1:nnz(S), cols, padr, padc)
80+
_format_line.(1:nnz(S), cols.+S.offset, padr, padc)
8181
else
8282
if rows <= 2
8383
print(io, "\n \u22ee")
8484
return
8585
end
8686
s1, e1 = 1, div(rows - 1, 2) # -1 accounts for \vdots
8787
s2, e2 = nnz(S) - (rows - 1 - e1) + 1, nnz(S)
88-
cols1, cols2 = _get_cols(s1, e1), _get_cols(s2, e2)
88+
cols1, cols2 = _get_cols(s1+S.offset, e1+S.offset), _get_cols(s2+S.offset, e2+S.offset)
8989
padr = ndigits(max(maximum(S.colval[s1:e1]), maximum(S.colval[s2:e2])))
9090
padc = ndigits(cols2[end])
9191
_format_line.(s1:e1, cols1, padr, padc)

0 commit comments

Comments
 (0)