Skip to content

Conversation

jenshnielsen
Copy link
Collaborator

@jenshnielsen jenshnielsen commented Aug 27, 2025

Export inferred to and from parameters related to setpoints with the same shape as the setpoints when exporting to xarray and the shape is known. Export inferred related to data parameters as data parameters.

TODO

  • Add docs and changelog

@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch from 4fd8248 to 4616cb2 Compare August 27, 2025 12:34
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 76.19048% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.72%. Comparing base (f1dc9af) to head (1f7fce5).

Files with missing lines Patch % Lines
src/qcodes/dataset/exporters/export_to_xarray.py 88.46% 9 Missing ⚠️
src/qcodes/dataset/data_set_cache.py 45.45% 6 Missing ⚠️
src/qcodes/dataset/data_set_in_memory.py 28.57% 5 Missing ⚠️
src/qcodes/dataset/data_set.py 50.00% 4 Missing ⚠️
src/qcodes/dataset/data_set_protocol.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7432      +/-   ##
==========================================
- Coverage   59.73%   59.72%   -0.01%     
==========================================
  Files         347      347              
  Lines       31242    31293      +51     
==========================================
+ Hits        18661    18689      +28     
- Misses      12581    12604      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch 2 times, most recently from b8cde31 to 38abf50 Compare August 28, 2025 11:30
Copy link
Contributor

@astafan8 astafan8 left a comment

Choose a reason for hiding this comment

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

pinging @samantha-ho for review as well :)

@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch 3 times, most recently from 2965bb2 to 1d6e8e5 Compare September 3, 2025 08:14
@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch from 1d6e8e5 to 49073aa Compare September 3, 2025 08:43
@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch 2 times, most recently from 8fb3820 to 0856fba Compare September 3, 2025 10:14
@jenshnielsen jenshnielsen force-pushed the add_interdeps_to_xarray branch from bb913ee to ea9adc2 Compare September 18, 2025 11:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the xarray export functionality to include inferred parameters related to dependencies. The changes add support for exporting inferred parameters that have the same shape as setpoints as coordinates, and inferred parameters related to data parameters as data variables.

  • Adds new method to_xarray_dataset_dict to replace the deprecated to_xarray_dataarray_dict
  • Updates the xarray export logic to include inferred parameters based on their relationships in the dependency graph
  • Adds comprehensive test coverage for the new functionality with various parameter relationship scenarios

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/dataset/test_dataset_export.py Adds type annotations and comprehensive tests for inferred parameter export functionality
tests/dataset/measurement/test_inferred_parameters_fix.py Updates existing tests to verify inferred parameters are now exported as coordinates
src/qcodes/dataset/exporters/export_to_xarray.py Implements core logic for exporting inferred parameters and adds new to_xarray_dataset_dict method
src/qcodes/dataset/data_set_protocol.py Adds protocol definition for new to_xarray_dataset_dict method
src/qcodes/dataset/data_set_in_memory.py Implements to_xarray_dataset_dict method and deprecates old method
src/qcodes/dataset/data_set_cache.py Adds cache support for new dataset dict export method
src/qcodes/dataset/data_set.py Implements to_xarray_dataset_dict method in main DataSet class



@deprecated(
"load_to_xarray_dataarray_dict is deprecated, use load_to_xarray_dataarray_dict instead",
Copy link
Preview

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The deprecation message incorrectly suggests using the same function being deprecated. It should suggest using "load_to_xarray_dataset_dict" instead.

Suggested change
"load_to_xarray_dataarray_dict is deprecated, use load_to_xarray_dataarray_dict instead",
"load_to_xarray_dataarray_dict is deprecated, use load_to_xarray_dataset_dict instead",

Copilot uses AI. Check for mistakes.

meas.register_custom_parameter("x", paramtype="numeric")

# Register y as setpoint inferred from basis
meas.register_custom_parameter("y", basis=("x"), paramtype="numeric")
Copy link
Preview

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The basis parameter should be passed as a tuple with multiple elements or a single string, not a tuple with one element. Consider using basis="x" instead of basis=("x") for single element basis.

Suggested change
meas.register_custom_parameter("y", basis=("x"), paramtype="numeric")
meas.register_custom_parameter("y", basis="x", paramtype="numeric")

Copilot uses AI. Check for mistakes.

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.

2 participants