Open Qfl3x opened 1 year ago
This PR will break precompilation. Working on using Macros instead of the Eval (bad idea)
I think it's resolved now.
I'm going to go ahead and reopen this because I think it will be useful to have. If you get a chance to change it and write some tests for it, I'd appreciate it. If not, I can do it at some point hopefully soon.
Merging #217 (6326604) into main (59031c1) will decrease coverage by
1.70%
. Report is 1 commits behind head on main. The diff coverage is0.00%
.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
@@ Coverage Diff @@
## main #217 +/- ##
==========================================
- Coverage 72.75% 71.06% -1.70%
==========================================
Files 20 21 +1
Lines 690 698 +8
==========================================
- Hits 502 496 -6
- Misses 188 202 +14
Files Changed | Coverage Δ | |
---|---|---|
src/ComponentArrays.jl | 100.00% <ø> (ø) |
|
src/componentarray.jl | 71.12% <0.00%> (-7.78%) |
:arrow_down: |
... and 7 files with indirect coverage changes
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
:loudspeaker: Have feedback on the report? Share it here.
The whole point was to make it differentiable via ChainRules, though this isn't. A solution exists for making it work with ChainRules, however, I think focusing on #207 is best.
Last two commits added type promotion.
Ah, I see. Yeah, we might want to make this work with merge
directly then because ChainRules doesn't support differentiating through keyword arguments. We'll likely need to do something similar to your first approach, but with @generated
functions for type-stability.
I think something similar to what @vboussange did could work:
import Base
function Base.merge(ca::ComponentArray{T}, ca2::ComponentArray{T}) where T
ax = getaxes(ca)
ax2 = getaxes(ca2)
vks = valkeys(ax[1])
vks2 = valkeys(ax2[1])
_p = Vector{T}()
for vk in vks
if vk in vks2
_p = vcat(_p, ca2[vk])
else
_p = vcat(_p, ca[vk])
end
end
ComponentArray(_p, ax)
end
Though this one implies that ca2
is a subset of ca
. So I'm working on "generalizing" it a bit further. It all comes down to a "smart" Axis
merge.
The last commit has an example that might be expanded on. Though it's a bit convoluted, it does work.
Is this still necessary for getting Zygote to work with ComponentArrays sensu https://github.com/jonniedie/ComponentArrays.jl/issues/207?
Issue #186
Implemented
merge
on 2 (or more)ComponentVector
s, similar tomerge
onNamedTuple
s orDict
s. With docs.