NamedVecs.jl - Is this a good idea?

The Julia ecosystem is reaching a size where, if something seems like a good idea, there’s probably a package for it. And conversely, if there is no package, then there’s probably a reason why such a package is not a good idea. So I think I should ask before I end up wasting my time…

I’m writing a package that would let me combine a bunch of different-size arrays into a vector, so that this vector can be passed to general linear-algebra code. But at the same time, I can access those arrays like the fields of a NamedTuple. (Machine-learning packages do something like this, but as far as I know, there’s no way to get the collection of parameters as an AbstractVector.)

(The example in the readme uses DifferentialEquations.jl, but I actually want to use it in some modelling/optimization code that I am developing separately. I want to get rid of a lot of boilerplate code that passes sizes around.)

I’ve got a proof-of concept working, but before I spend any more time on this, I thought I should ask if anybody knows about an existing package that already has this functionality?

Or is there some major drawback to this approach that I haven’t thought of?

1 Like

Have not looked in depth here but isn’t this what StructArrays.jl does?

I’d usually suggest this one.


That seems to be exactly what I need. Thanks!

StructArrays.jl seems to be for a slightly different use case, but also worth knowing about. Thanks.