Skip to content

Commit

Permalink
replace_in_print_matrix for OneElement vector (#246)
Browse files Browse the repository at this point in the history
* replace_in_print_matrix for OneElement vector

* Bump version to v1.1.0
  • Loading branch information
jishnub authored May 24, 2023
1 parent 427e8d3 commit 594b4b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.0.2"
version = "1.1.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
3 changes: 3 additions & 0 deletions src/oneelement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function Base.getindex(A::OneElement{T,N}, kj::Vararg{Int,N}) where {T,N}
ifelse(kj == A.ind, A.val, zero(T))
end

Base.replace_in_print_matrix(o::OneElementVector, k::Integer, j::Integer, s::AbstractString) =
o.ind == (k,) ? s : Base.replace_with_centered_mark(s)

Base.replace_in_print_matrix(o::OneElementMatrix, k::Integer, j::Integer, s::AbstractString) =
o.ind == (k,j) ? s : Base.replace_with_centered_mark(s)

Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,8 @@ end
@test e₁ == [0,1,0,0,0]
@test_throws BoundsError e₁[6]

@test stringmime("text/plain", e₁) == "5-element OneElement{$Int, 1, Tuple{$Int}, Tuple{Base.OneTo{$Int}}}:\n\n 1\n\n\n"

e₁ = OneElement{Float64}(2, 5)
@test e₁ == [0,1,0,0,0]

Expand Down

0 comments on commit 594b4b3

Please sign in to comment.