jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
287 stars 34 forks source link

Change Adjoints to be ComponentArrays #170

Open nrontsis opened 1 year ago

nrontsis commented 1 year ago

This PR aims to avoid issues like:

using ComponentArrays
A = ComponentMatrix(ones(2, 2), Axis(:a, :b), FlatAxis())
A[:b, :] # works
A'[:, :b] # fails!

by wrapping adjoint operations in the underlying data of the ComponentArray structure.

By not having to care about adjoints of ComponentArray, we arguably also reduce overall cognitive load.

nrontsis commented 1 year ago

@jonniedie sorry for the broken tests, these are passing now in my machine.

YichengDWu commented 1 year ago

Why not just overload getindex for the adjoint?

nrontsis commented 1 year ago

Why not just overload getindex for the adjoint?

nrontsis commented 1 year ago

Thanks a lot for the review @jonniedie!

I am happy to add any tests you feel sensible. However I think some of the old tests were actually incorrect, as I argue in this thread. Can you reply to this thread with what you think on my argument?