Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ComponentArrays"
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
version = "0.15.27"
version = "0.15.28"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
7 changes: 7 additions & 0 deletions src/componentarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ function ComponentArray(data, ax::AbstractAxis...)
return LazyArray(ComponentArray(x, axs...) for x in part_data)
end

# This code-path is hit for empty NamedTuples. We force a Float32 eltype here if
# length(data) == 0
function ComponentArray(data::Vector{Any}, axes::Tuple{FlatAxis})
length(data) == 0 && return ComponentArray(Float32[], axes)
return ComponentArray{Any,1,typeof(data),typeof(axes)}(data, axes)
end

function Adapt.adapt_structure(to, x::ComponentArray)
data = Adapt.adapt(to, getdata(x))
return ComponentArray(data, getaxes(x))
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,10 @@ end
@test_throws ArgumentError axpby!(2, x, 3, y)
end

@testset "Empty NamedTuple" begin
@test ComponentArray(NamedTuple()) isa ComponentVector{Float32}
end

@testset "Functors" begin
for carray in (ca, ca_Float32, ca_MVector, ca_SVector, ca_composed, ca2, caa)
θ, re = Functors.functor(carray)
Expand Down
Loading