Skip to content

Commit

Permalink
Expose parameter to control chain collapse. Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
JSKenyon committed Dec 11, 2024
1 parent 7efa134 commit 40271b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions quartical/calibration/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def solver_wrapper(
**{k: chain_kwargs.get(k, None) for k in chain_fields}
)

solver_opts.collapse_chain = True # TODO: Expose + default to this.

if solver_opts.collapse_chain:
mapping_inputs, chain_inputs, collapsed_term = get_collapsed_inputs(
ms_kwargs,
Expand Down Expand Up @@ -344,7 +342,8 @@ def get_collapsed_inputs(

if l_terms:
n_l_d = max([s.shape[3] for s in l_terms])
l_dir_map = np.zeros(n_d, dtype=np.int32) if n_l_d > 1 else np.arange(n_d, dtype=np.int32) # TODO: Wrong.
dir_map_func = np.zeros if n_l_d > 1 else np.arange
l_dir_map = dir_map_func(n_d, dtype=np.int32)

# TODO: Cache array to avoid allocation?
l_gain = combine_gains(
Expand All @@ -369,7 +368,8 @@ def get_collapsed_inputs(

if r_terms:
n_r_d = max([s.shape[3] for s in r_terms])
r_dir_map = np.zeros(n_d, dtype=np.int32) if n_r_d > 1 else np.arange(n_d, dtype=np.int32) # TODO: Wrong.
dir_map_func = np.zeros if n_r_d > 1 else np.arange
r_dir_map = dir_map_func(n_d, dtype=np.int32)

r_gain = combine_gains(
chain_kwargs["gains"][active_term + 1:],
Expand Down
10 changes: 10 additions & 0 deletions quartical/config/argument_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ solver:
almost always be enabled so that data associated with diverging gains
is properly flagged.

collapse_chain:
dtype: bool
default: True
info:
Determines whether the chain is collapsed into the minimum number of
terms inside the solver. This will typically increase memory footprint,
but may speed up calibration when utilising many gain terms. Set to false
to apply every term on-the-fly inside the solver (behaviour prior to
v0.2.6).

robust:
dtype: bool
default: False
Expand Down

0 comments on commit 40271b5

Please sign in to comment.