Skip to content

Commit

Permalink
fix + test, for remotion of elements turning into a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
francescoalemanno committed Mar 6, 2020
1 parent f5392e2 commit 311bfa6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DefaultArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
@inline function setindex!(A::DefaultArray, v, i::Int)
@boundscheck checkbounds(A, i)
if v == A.default
haskey(A.elements, i) || delete!(A.elements, i)
haskey(A.elements, i) && delete!(A.elements, i)
else
A.elements[i] = v
end
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ using LinearAlgebra
@test A[4]==A[2,2]
@test all(collect(eachnondefault(A)).==[4, 3])
@test collect(eachnondefault(A,IndexCartesian())) == [CartesianIndex(2, 2), CartesianIndex(1, 2)]
l1=length(eachnondefault(A)|>collect)
A[1,2]=Inf
l2=length(eachnondefault(A)|>collect)
@test l1>l2
B=DefaultArray(Inf,(3,))
B[3]=2
@test B[3]==2
Expand Down

2 comments on commit 311bfa6

@francescoalemanno
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/10476

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 311bfa6b15627ef264c8d88f77c9e3ba7ced70b6
git push origin v1.0.0

Please sign in to comment.