I have a type DataRow
. It’s goal is to act like a row of a DataFrame
, but standing on its own.
- It’s one dimensional
- It’s indexable
- It iterates through values
- It stores values in a Vector{Any} internally
I’m trying to extend in-place broadcasting, via this link.
If r
is a DataRow
with two elements, I would like
r .= [3, 4]
to update the values of r
. I’ve implemented
Base.BroadcastStyle(::Type{<:DataRow}) = Broadcast.Style{DataRow}()
function copyto!(dest::DataRow, bc::Broadcasted{Broadcast.DefaultArrayStyle{1}})
println("success")
nothing
end
This feels like the method to implement, but I haven’t yet been able to hit this method
julia> r .= [1, 2]
ERROR: MethodError: no method matching copyto!(::DataRow, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(identity),Tuple{Array{Int64,1}}})
Overall I’m pretty lost about how to implement broadcasting. Any help is appreciated, particularly if someone could point me to a good implementation in some package that I can copy
3 posts - 2 participants