Conversation
Solve #437 Add a new CSSparseScalarAggregator class to allow for aggregator with missing values.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solve #457
The idea is to add a new
CSSparseScalarAggregatorclass (subclass ofCSScalarAggregator) to allow for aggregator with missing values. The missing values are replaced bynanvalues.ControlSystem.create_bpm_aggregatorsnow uses this newCSSparseScalarAggregatorto avoid the bug described in #457.AI Summary
Description
A
pyaml.bpm.bpm.BPMmay define only one position plane, e.g. a vertical-only X-BPM (y_posonly). Such a BPM works in a simulator mode, but building the control-system mode failed as soon as it was part of apyaml.arrays.bpmarray (PyAMLException: All devices must be instances of Attribute), because aNoneposition device was passed to the backend aggregator. Reading the BPM alone also failed (None.get()).With this PR, a missing plane reads
NaN, both for a single BPM and in BPM arrays. Grouped (parallel) reads are kept for all accessors, so mixing single-plane BPMs into an array costs nothing in performance.Related Issue
Features/issues described there are:
ControlSystem.create_bpm_aggregatorsnow handles BPMs with a missing position device. It uses a newCSSparseScalarAggregatorthat only adds the existing devices to the backend aggregator and scatters the values back into a NaN-filled array. This keeps one grouped read per accessor (positions,h,v). Falling back to per-BPM reads would cost 2N sequential round trips: with a simulated 1 ms per Tango read, ~260 ms instead of ~1 ms for 120 BPMs + 4 XBPMs.RBpmArray(control system) returnsNaNfor a plane without device and takesunit()from whichever device is defined.Changes to existing functionality
create_bpm_aggregatorsnow returnsCSSparseScalarAggregatorinstances instead ofCSScalarAggregator. Behaviour is unchanged for BPMs with both planes; the only overhead is one array copy per read.CSSparseScalarAggregatoris a subclass rather than a change toCSScalarAggregator, on purpose:CSStrengthScalarAggregatorinherits fromCSScalarAggregator, adds devices throughself._devsdirectly and usesnb_device()as the number of power supplies, so slot tracking in the base class would be bypassed or ambiguous.Testing
The following tests (compatible with pytest) were added in
tests/bpm/test_bpm_controlsystem.py, using the dummytango-pyamlbackend:test_controlsystem_bpm_single_plane: a vertical-only BPM reads[nan, y]and reports the unit of its y device.test_controlsystem_bpm_array_with_single_plane_bpm: an array of two full BPMs + one XBPM builds;positions,handvreturn the right values with NaN at the missing plane; all three aggregators exist and read through the grouped path.test_controlsystem_bpm_array_without_horizontal_plane: an array of XBPMs only returns all-NaNhand correctv.Verify that your checklist complies with the project
🤖 Generated with Claude Code