Skip to content

Commit 1a9c871

Browse files
cstjeandlfivefifty
authored andcommitted
Fix issue: copy should not copy the fill's element (#64)
1 parent 156b41b commit 1a9c871

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/FillArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ convert(::Type{AbstractFill}, F::AbstractFill) = F
7575
convert(::Type{AbstractFill{T}}, F::AbstractFill) where T = convert(AbstractArray{T}, F)
7676
convert(::Type{AbstractFill{T,N}}, F::AbstractFill) where {T,N} = convert(AbstractArray{T,N}, F)
7777

78-
copy(F::Fill) = Fill(copy(F.value), F.axes)
78+
copy(F::Fill) = Fill(F.value, F.axes)
7979

8080
""" Throws an error if `arr` does not contain one and only one unique value. """
8181
function unique_value(arr::AbstractArray)

test/runtests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ import FillArrays: AbstractFill, RectDiagonal
137137
@test copy(x) x
138138
x = Fill([1.,2.],10)
139139
@test copy(x) == x
140-
@test copy(x) !== x
140+
@test copy(x) === x # because isbits(x)
141141
@test copy(x) isa Fill
142+
@test copy(Fill(:a, 4)) == fill(:a, 4) # FillArrays#63
142143
end
143144

144145
@testset "vec" begin
@@ -694,4 +695,4 @@ end
694695
@test Ones(5)' isa Adjoint # Vectors still need special dot product
695696
@test Fill([1+im 2; 3 4; 5 6], 2,3)' == Fill([1+im 2; 3 4; 5 6]', 3,2)
696697
@test transpose(Fill([1+im 2; 3 4; 5 6], 2,3)) == Fill(transpose([1+im 2; 3 4; 5 6]), 3,2)
697-
end
698+
end

0 commit comments

Comments
 (0)