SciML / SciML/ComponentArrays.jl

Add utility for structured updates in `ComponentArrays`

Open
#303 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
375
Forks
42
Avg merge
7h 25m
Merged PRs (30d)
17

Description

Motivation

In fitting or optimization workflows, it’s common to work with a structured ComponentArray template and update only a subset of its parameters during each iteration. While manual assignment is always possible using field names or indices, it’s often verbose and error-prone.

I'd like to have a utility function that enables updating parameters by name using existing axis metadata, without reconstructing the structure or altering types.

Proposed Functionality

Introduce update_component_array(default, update) that:

  • Updates a ComponentArray default with values from another ComponentArray update
  • Modifies only matching entries (partial updates supported)
  • Preserves structure, type, and axis information of the original array

Example Usage

default = ComponentArray(sig = (mu = 1.0, sigma = 2.0), bg = 3.0)
update  = ComponentArray(sig = (mu = 1.1,), bg = 3.3)

result = update_component_array(default, update)

result.sig.mu    # 1.1
result.sig.sigma # 2.0
result.bg        # 3.3

Btw

Originally, I tried to implement deep_merge, but it's really hard to make it type stable. I'd be happy to have the update solution

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing ComponentArray axis metadata and named-component update APIs; the issue does not identify specific files or tests. Define update_component_array(default, update) so partial matching updates preserve the default's structure, type, and axes, then add coverage for the nested sig and bg example and type-stability behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.