Skip to content

Carry a swept variable's label and units onto the result coordinate - #34

Merged
fedonman merged 1 commit into
mainfrom
result-coord-labels
Sep 2, 2026
Merged

Carry a swept variable's label and units onto the result coordinate#34
fedonman merged 1 commit into
mainfrom
result-coord-labels

Conversation

@fedonman

@fedonman fedonman commented Sep 2, 2026

Copy link
Copy Markdown
Member

The executor built each result axis from the swept variable's id alone, so a coordinate arrived with an empty attrs even when the program declared a label and units. It now writes them on as long_name and units, the two keys xarray's plotting reads, so result.get(m0).sel(IQ="I").plot() labels its own x axis instead of falling back to the id. A key the variable did not declare is left out rather than written as None, and the array's own attrs and name are untouched. Three doc passages that said otherwise move with it.

Closes #31

@pullpo-for-slack

Copy link
Copy Markdown

🔗Pullpo.io Slack PR-Channel

@pullpo-for-slack

pullpo-for-slack Bot commented Sep 2, 2026

Copy link
Copy Markdown

AI Analysis

Oupsie! Looks like something went wrong on our end.
We'll investigate it and solve it for future pull requests!

The executor took a variable's id when it built an axis and dropped everything
else, so every result coordinate arrived with an empty attrs dict. A program
that declared label="Drive amplitude", units="V" had both strings sitting on
the Variable and no way to reach them from the result.

Each axis now carries the attributes alongside its coords, and _finalize writes
them onto the matching coordinate of every field array. The keys are long_name
and units, which is what xarray's own plotting accessor reads, so
result.get(m0).sel(IQ="I").plot() labels its x axis rather than falling back to
the variable id. A key the variable did not declare is left out instead of
written as None, which xarray would render.

The array's own attrs and name are untouched: a measurement has no unit the
executor knows, and the y axis of a readout plot is physics.

Three doc passages said otherwise and move with it: variables.md listed the
executor and the result objects among the things that ignore units, rabi.md
explained that the axis label had to be typed out by hand, and the array
contract in measurements.md said nothing about coordinate attributes.
@fedonman
fedonman force-pushed the result-coord-labels branch from 57e9b38 to e850760 Compare September 2, 2026 00:40
@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@flavie-lebars flavie-lebars left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@fedonman
fedonman merged commit 6510273 into main Sep 2, 2026
9 checks passed
@fedonman
fedonman deleted the result-coord-labels branch September 2, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Carry a swept variable's label and units onto the result coordinate

2 participants