Skip to content

Commit 118ef79

Browse files
authored
Make zero work correctly for ComponentVector{Bool} (#213)
1 parent 904dbc5 commit 118ef79

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ComponentArrays"
22
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
33
authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
4-
version = "0.13.13"
4+
version = "0.13.14"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/similar_convert_copy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ _similar(x::Type, dims) = ComponentArray(similar(x, length.(_array_axis.(dims)))
2222
_similar(x, T, dims) = ComponentArray(similar(getdata(x), T, length.(_array_axis.(dims))), _component_axis.(dims)...)
2323

2424

25-
Base.zero(x::ComponentArray) = zero.(x)
25+
Base.zero(x::ComponentArray) = ComponentArray(zero(getdata(x)), getaxes(x)...)
2626

2727
## FIXME: waiting on similar(::Type{<:ComponentArray})
2828
# Base.zeros(CA::Type{<:ComponentArray}) = (similar(CA) .= 0)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ end
368368
@test similar(ca, 5) isa typeof(getdata(ca))
369369
@test similar(ca, Float32, 5) isa typeof(getdata(ca_Float32))
370370
@test similar(cmat, 5, 5) isa typeof(getdata(cmat))
371+
372+
# Issue #206
373+
x = ComponentArray(a = false, b = true)
374+
@test typeof(x) == typeof(zero(x))
371375
end
372376

373377
@testset "Copy" begin

0 commit comments

Comments
 (0)