# \#componentarrays

**URL:** https://discourse.julialang.org/tag/componentarrays/702.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [ComponentArray and generation of JumpSet](https://discourse.julialang.org/t/componentarray-and-generation-of-jumpset/127875)

<div class="topic-metadata">

**Author:** [@paolo-mgi](https://discourse.julialang.org/u/paolo-mgi)\
**Replies:** 2\
**Last updated:** [April 21, 2025, 10:53am UTC](https://discourse.julialang.org/t/componentarray-and-generation-of-jumpset/127875 "2025-04-21T10:53:10Z")

</div>

Hello, I wish to integrate a system of jump differential equations with JumpProblem. Variables in the system behave differently and I discrimiate between them using ComponentArray. The problem requires the definition of…

---

## [No method error (reshape) when solving ODE with ComponentArrays.jl](https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342)

<div class="topic-metadata">

**Author:** [@Wen-Wei\_Tseng](https://discourse.julialang.org/u/Wen-Wei_Tseng)\
**Replies:** 1\
**Last updated:** [March 1, 2025, 2:44pm UTC](https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342 "2025-03-01T14:44:56Z")

</div>

Hi, I was using ComponentArrays.jl to solve the ODE problem in the README and got an error. using ComponentArrays using OrdinaryDiffEq using SimpleUnPack: @unpack tspan = (0.0, 20.0) function lorenz!(D, u, p, t; f=0.0…

---

## [Problem with ForwardDiff and a custom vector type in OrdinaryDiffEq](https://discourse.julialang.org/t/problem-with-forwarddiff-and-a-custom-vector-type-in-ordinarydiffeq/116260)

<div class="topic-metadata">

**Author:** [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Replies:** 5\
**Last updated:** [June 26, 2024, 8:07pm UTC](https://discourse.julialang.org/t/problem-with-forwarddiff-and-a-custom-vector-type-in-ordinarydiffeq/116260 "2024-06-26T20:07:58Z")

</div>

I have an ODE system tracking the densities of a number of species. If certain criteria are fulfilled I add more species to the system and run the new slightly bigger ODE system, and repeat this process until certain oth…

---

## [Problem with static\_unpack](https://discourse.julialang.org/t/problem-with-static-unpack/115320)

<div class="topic-metadata">

**Author:** [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Replies:** 2\
**Last updated:** [June 8, 2024, 7:15am UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320 "2024-06-08T07:15:15Z")

</div>

Dearests, I found that the very first example for the macro at-static\_unpack of ComponentArrays is not working julia\> x = ComponentArray(a=5, b=\[4, 1\], c = \[1 2; 3 4\], d=(e=2, f=\[6, 30.0\])) ComponentVector{Float64}(a =…

---

## [Bug at solve method for Universall Differential Equations?](https://discourse.julialang.org/t/bug-at-solve-method-for-universall-differential-equations/114566)

<div class="topic-metadata">

**Author:** [@Alergy](https://discourse.julialang.org/u/Alergy)\
**Replies:** 1\
**Last updated:** [May 22, 2024, 2:07pm UTC](https://discourse.julialang.org/t/bug-at-solve-method-for-universall-differential-equations/114566 "2024-05-22T14:07:41Z")

</div>

I am trying to somewhat emulate the Universal Differential Equations tutorial, with a little twist. What I want to do is to learn the parameters of both a Differential Equation AND a Neural Network. Here is the only cod…

---

## [ArraysOfArrays with named fields](https://discourse.julialang.org/t/arraysofarrays-with-named-fields/110281)

<div class="topic-metadata">

**Author:** [@sijo](https://discourse.julialang.org/u/sijo)\
**Replies:** 7\
**Last updated:** [February 19, 2024, 4:38pm UTC](https://discourse.julialang.org/t/arraysofarrays-with-named-fields/110281 "2024-02-19T16:38:15Z")

</div>

Let’s say I have a vector a = \[x1, x2, x3, q1, q2, q3, q4\]. What’s a nice way to use it in algorithms that expect a flat vector like that, but at the same time have a nice interface like a.x, a.q to extract \[x1, x2, x3\] …

---

## [Accessing a ComponentArray's fields in a type-stable manner](https://discourse.julialang.org/t/accessing-a-componentarrays-fields-in-a-type-stable-manner/103832)

<div class="topic-metadata">

**Author:** [@Bizzi](https://discourse.julialang.org/u/Bizzi)\
**Replies:** 2\
**Last updated:** [October 31, 2023, 3:53am UTC](https://discourse.julialang.org/t/accessing-a-componentarrays-fields-in-a-type-stable-manner/103832 "2023-10-31T03:53:15Z")

</div>

I’m struggling with iterating over the named fields of a ComponentArray in a compiler-friendly way. Take the following MWE, emulating some Neural Network: I create the nested structure layers, containing some weight …

---

## [Type-inference fails then succeeds for exact same function](https://discourse.julialang.org/t/type-inference-fails-then-succeeds-for-exact-same-function/105384)

<div class="topic-metadata">

**Author:** [@Bizzi](https://discourse.julialang.org/u/Bizzi)\
**Replies:** 2\
**Last updated:** [October 25, 2023, 5:19pm UTC](https://discourse.julialang.org/t/type-inference-fails-then-succeeds-for-exact-same-function/105384 "2023-10-25T17:19:41Z")

</div>

I’ve been facing multiple issues with type-inference, specially when using ComponentArrays. In particular, it may succeed or fail, apparently at random, for the same function, in the same program. What could be causing t…

---

## [Flux Restructure for ComponentArrays.jl unreasonably slow](https://discourse.julialang.org/t/flux-restructure-for-componentarrays-jl-unreasonably-slow/97849)

<div class="topic-metadata">

**Author:** [@glatteis](https://discourse.julialang.org/u/glatteis)\
**Replies:** 2\
**Last updated:** [April 24, 2023, 12:56pm UTC](https://discourse.julialang.org/t/flux-restructure-for-componentarrays-jl-unreasonably-slow/97849 "2023-04-24T12:56:18Z")

</div>

In some situations, you have to restructure a lot if you use Flux and want to run your batches as seperate solves, not as one big solve, for instance using an EnsembleProblem. You have to use something like a ComponentAr…

---

## [Posing constraints on component array optimizations](https://discourse.julialang.org/t/posing-constraints-on-component-array-optimizations/90007)

<div class="topic-metadata">

**Author:** [@RuoyuWang72](https://discourse.julialang.org/u/RuoyuWang72)\
**Replies:** 0\
**Last updated:** [November 9, 2022, 8:33pm UTC](https://discourse.julialang.org/t/posing-constraints-on-component-array-optimizations/90007 "2022-11-09T20:33:06Z")

</div>

I have a component array p I want to optimize, p.ps\_τ and p.ps\_J are parameters of neural nets, and p.ps\_F1 and p.ps\_F2 are two floats (I followed this example: Simultaneous Fitting of Multiple Neural Networks ) The con…

---

## [ComponentArrays vs LabelledArrays](https://discourse.julialang.org/t/componentarrays-vs-labelledarrays/67464)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [October 26, 2022, 3:41pm UTC](https://discourse.julialang.org/t/componentarrays-vs-labelledarrays/67464 "2022-10-26T15:41:38Z")

</div>

I’ve been a user of ComponentArrays.jl for a while. Just recently discovered LabelledArrays.jl. They strike as very similar. Are there any fundamental differences between them? Just as example, this is the kind of use f…

---

## [Splat ComponentArray into keyword arguments](https://discourse.julialang.org/t/splat-componentarray-into-keyword-arguments/75003)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [January 21, 2022, 9:03pm UTC](https://discourse.julialang.org/t/splat-componentarray-into-keyword-arguments/75003 "2022-01-21T21:03:53Z")

</div>

Hi all, I have a situation in which “splatting” a ComponentArray into keyword arguments would be useful. Unfortunately, it is not currently possible. I was wondering whether it would be possible in principle? Could I ad…

---

## [How to programatically construct a ComponentArray or NamedTuple?](https://discourse.julialang.org/t/how-to-programatically-construct-a-componentarray-or-namedtuple/70937)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [November 11, 2021, 3:22pm UTC](https://discourse.julialang.org/t/how-to-programatically-construct-a-componentarray-or-namedtuple/70937 "2021-11-11T15:22:48Z")

</div>

As the title says, how can I programatically construct a ComponentArray or NamedTuple from a vector of strings (or symbols) and a vector of numbers? from this n = \["a", "b", "c"\] x = \[1, 2, 3\] I want to get this ca =…

---

## [How to best program this function with cases?](https://discourse.julialang.org/t/how-to-best-program-this-function-with-cases/68703)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 6\
**Last updated:** [October 2, 2021, 7:37pm UTC](https://discourse.julialang.org/t/how-to-best-program-this-function-with-cases/68703 "2021-10-02T19:37:09Z")

</div>

I have this function that depends on cases i. I programmed it this way, but I am wondering if there is a better way of achieving the same result and with better performance. using ComponentArrays θ = ComponentArray(one…

---

## [ComponentArrays.jl crashes Julia in VSCode but not in REPL](https://discourse.julialang.org/t/componentarrays-jl-crashes-julia-in-vscode-but-not-in-repl/54667)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 0\
**Last updated:** [February 5, 2021, 2:55am UTC](https://discourse.julialang.org/t/componentarrays-jl-crashes-julia-in-vscode-but-not-in-repl/54667 "2021-02-05T02:55:20Z")

</div>

The following code crashes Julia in VSCode, but the REPL can run it with no problem. using ComponentArrays szE = 2 szG = 2 szA = 9 szK = 5 szT = 44 szB = 2 szZ = 2 costdata = Array{Float64}(undef, szT) wwdata = Array{…

---

## [Best practices with ComponentArrays.jl](https://discourse.julialang.org/t/best-practices-with-componentarrays-jl/66064)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 1\
**Last updated:** [August 19, 2021, 7:26pm UTC](https://discourse.julialang.org/t/best-practices-with-componentarrays-jl/66064 "2021-08-19T19:26:05Z")

</div>

Suppose I have a model M with parameters θ that are arranged in a ComponentArray. Model M has several components M1 to M2 that each take a subset of components of θ. I’m wondering what’s better, balancing performance and…

---

## [Obtain multiple components from a ComponentArray](https://discourse.julialang.org/t/obtain-multiple-components-from-a-componentarray/62315)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 2\
**Last updated:** [June 3, 2021, 3:58am UTC](https://discourse.julialang.org/t/obtain-multiple-components-from-a-componentarray/62315 "2021-06-03T03:58:22Z")

</div>

Is there a way to obtain multiple components from a ComponentArray? something like using ComponentArrays ca = ComponentArray(x1 = \[1, 2\], x2 = \[10, 20\], x3 = \[100, 200\]) ca\[:x1, :x3\] # would return (ca.x1, ca.x2)

---

## [Question about program design with ComponentArrays](https://discourse.julialang.org/t/question-about-program-design-with-componentarrays/58732)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [April 8, 2021, 11:42am UTC](https://discourse.julialang.org/t/question-about-program-design-with-componentarrays/58732 "2021-04-08T11:42:25Z")

</div>

I’m retaking a program I did some time ago, trying to speed it up. I am using ComponentArrays because it is very easy to organize data and parameters with it. Consider this: using ComponentArrays using Parameters: @unpa…

---

## [ComponentArrays.jl with NLopt.jl](https://discourse.julialang.org/t/componentarrays-jl-with-nlopt-jl/57482)

<div class="topic-metadata">

**Author:** [@avonmoll](https://discourse.julialang.org/u/avonmoll)\
**Replies:** 3\
**Last updated:** [March 24, 2021, 2:08pm UTC](https://discourse.julialang.org/t/componentarrays-jl-with-nlopt-jl/57482 "2021-03-24T14:08:38Z")

</div>

These two packages seem to be incompatible. Without fully understanding the internals of NLopt.jl it seems that the vector of optimization variables ends up getting cast as an Array{Float64,1}. This basic snippet works: …

---

## [\[RFC/ANN\] ComponentArrays.jl for building composable models without a modeling language](https://discourse.julialang.org/t/rfc-ann-componentarrays-jl-for-building-composable-models-without-a-modeling-language/38001)

<div class="topic-metadata">

**Author:** [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Replies:** 22\
**Last updated:** [April 25, 2020, 8:59pm UTC](https://discourse.julialang.org/t/rfc-ann-componentarrays-jl-for-building-composable-models-without-a-modeling-language/38001 "2020-04-25T20:59:17Z")

</div>

Hey everyone. ComponentArrays.jl is my first package and I’m looking for some feedback and to gauge interest before I think about going down the path of registering it. I wrote this package mostly for myself for my work …
