Skip to content

Commit

Permalink
fix plotting labels in the integration weights compressing tool (qua-…
Browse files Browse the repository at this point in the history
  • Loading branch information
yomach authored Feb 22, 2022
1 parent de9e34a commit e33538a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Fixed
- Interactive Plotting Toolbox - Fixed several small issues when loading a figure
- Interactive Plotting Toolbox - Fixed several small issues when loading a figure
- Integration Weights Tool - When compressing and plotting integration weights, the correct label is shown.
### Added
- Interactive Plotting Toolbox - Added default markers when fitting
- Interactive Plotting Toolbox - Improved example and added a demo video
Expand Down
14 changes: 7 additions & 7 deletions qualang_tools/config/integration_weights_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,29 @@ def compress_integration_weights(integration_weights, N=100, plot=False):
)
if plot:
plt.figure()
plot_integration_weights(integration_weights_before)
plot_integration_weights(integration_weights)
plot_integration_weights(integration_weights_before, label="Original")
plot_integration_weights(integration_weights, label="Compressed")
plt.show()
return integration_weights


def plot_integration_weights(integration_weights):
def plot_integration_weights(integration_weights, label=None):
"""
Plot the integration weights in units of ns, receives the integration weights in both formats
:param integration_weights: The integration_weights to be plotted.
:param str label: The label of the integration_weights.
"""

if isinstance(integration_weights[0], tuple):
a = [[i[0]] * i[1] for i in integration_weights]
unpacked_weights = sum(a, start=[])
label = "Converted"
elif isinstance(integration_weights[0], float):
a = [[i] * 4 for i in integration_weights]
unpacked_weights = sum(a, start=[])
label = "Original"
else:
raise Exception("Unknown input")

plt.plot(unpacked_weights, label=label)
plt.legend()
plt.show()
if label is not None:
plt.legend()

0 comments on commit e33538a

Please sign in to comment.