From 5c4242e8398eba369f3ae0dc4c96878f89c1d553 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Tue, 20 Oct 2020 09:34:51 +0200 Subject: [PATCH] Respect broadcasting of functions that changes the eltype This solves #51, but might defeat the purpose of why that method was introduced in the first place? --- src/broadcasting.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/broadcasting.jl b/src/broadcasting.jl index c4cbd543..220c6ef6 100644 --- a/src/broadcasting.jl +++ b/src/broadcasting.jl @@ -71,10 +71,7 @@ end # of respecting Union eltypes than the default method in Base. function Base.Broadcast.broadcasted(f, x::ComponentArray) data = getdata(x) - new_data = similar(data) - @inbounds for i in eachindex(data) - new_data[i] = f(data[i]) - end + new_data = map(f, x) return ComponentArray(new_data, getaxes(x)) end @@ -116,4 +113,4 @@ function fill_flat(Ax::VarAxes, N) axs = (axs..., ntuple(x -> FlatAxis(), N-n)...) end return axs -end \ No newline at end of file +end