Fix 7717, Improve handling of data variables with inferred parameters + tests#7725
Fix 7717, Improve handling of data variables with inferred parameters + tests#7725jenshnielsen merged 14 commits intomicrosoft:mainfrom
Conversation
|
@astafan8 converted to draft until it actually fixes the bug |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7725 +/- ##
=======================================
Coverage 70.60% 70.61%
=======================================
Files 333 333
Lines 32502 32533 +31
=======================================
+ Hits 22947 22972 +25
- Misses 9555 9561 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
astafan8
left a comment
There was a problem hiding this comment.
great to see this fixed! And "add a news fragment"?
There was a problem hiding this comment.
Pull request overview
This PR addresses #7717, where a dataset export to xarray becomes ungridded when two ParameterWithSetpoints share the same setpoints and one parameter is inferred/controlled by the other. The intent is to ensure the export stays gridded and includes the inferred parameter data alongside the measured top-level parameter.
Changes:
- Adds a regression test reproducing the
ParameterWithSetpoints.has_control_of+ shared setpoints scenario. - Updates
InterDependencies_.top_level_parametersto exclude parameters that are inferred-from others from being considered dependency top-level parameters. - Extends the xarray export (pandas-index path) to add inferred parameters as xarray data variables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/dataset/test_parameter_with_setpoints_has_control.py |
Regression test ensuring gridded xarray export includes inferred p1 as a data var while keeping only p2 top-level. |
src/qcodes/dataset/exporters/export_to_xarray.py |
Adds _add_inferred_data_vars to include inferred parameters in xarray output when exporting via pandas index. |
src/qcodes/dataset/descriptions/dependencies.py |
Adjusts top-level parameter detection to prevent inferred parameters from being treated as independent top-level parameters. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Fixes QCoDeS dataset export behavior related to issue #7717, where ParameterWithSetpoints parameters involved in has_control_of/inference relationships could cause to_xarray_dataset() to export ravelled (ungridded) data instead of a properly gridded dataset.
Changes:
- Add regression tests covering 1D and 2D
ParameterWithSetpoints+has_control_ofinference export behavior, plus a warning-path test. - Adjust
InterDependencies_.top_level_parametersto avoid treating inferred parameters as independent top-level parameters. - Extend xarray export to include inferred parameters as data variables when exporting via the pandas-index path, warning when inferred data sizes don’t match the parent parameter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/dataset/test_parameter_with_setpoints_has_control.py |
Adds regression tests reproducing #7717 and validating inferred parameters appear correctly in xarray export. |
src/qcodes/dataset/exporters/export_to_xarray.py |
Adds _add_inferred_data_vars and integrates it into the pandas-index export paths to include inferred parameters. |
src/qcodes/dataset/descriptions/dependencies.py |
Updates top_level_parameters to exclude parameters inferred from others from dependency top-level candidates. |
Instead of assuming a single parent by taking inferred_from_params[0], iterate over all inferred-from parents and use the first one whose flattened data size matches. Log a warning listing all available parents when no match is found. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check inferred parameter data size against the xr_dataset dimensions directly instead of iterating over individual parent sizes. The previous logic could match a parent whose size differed from the dataset grid, causing a ValueError on reshape. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix newsfragment wording to match actual behavior (checks dataset dimensions, not parent parameter size) - Extract _make_controlled_setpoints helper to reduce MySp class duplication across tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.