Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExperimentData.add_figures should preserve figure names #629

Closed
kevinsung opened this issue Jan 25, 2022 · 0 comments
Closed

ExperimentData.add_figures should preserve figure names #629

kevinsung opened this issue Jan 25, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kevinsung
Copy link
Contributor

What is the expected behavior?

The figure names passed to ExperimentData.add_figures should match the names passed to ExperimentData.figure when retrieving it. Specifically, the following example should not raise an error:

from matplotlib.pyplot import Figure
from qiskit_experiments.framework import ExperimentData

data = ExperimentData()
data.add_figures(Figure(), 'abcd')
data.figure('abcd.svg')  # OK
data.figure('abcd')  # raises error
@kevinsung kevinsung added the enhancement New feature or request label Jan 25, 2022
@ItamarGoldman ItamarGoldman self-assigned this Oct 2, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 23, 2023
### Summary

Figure names could be referred without ".svg" at the ending.
### Details and comments

Some details that should be in this section include:
In #629 , an issue was raised where a figure that was saved with the
name "abcd" couldn't be accessed. This issue is caused by that the
'add_figures()' method in `ExperimentData` class added ".svg"
automatically. As it explicitly written that SVG extension is added if
the file name doesn't have one, we can conclude that all figure names
have ".svg" extension. To not make a major change in the code I added to
the `figure` method in `ExperimentData` class a check for the extension
of the `figure_key`. If it doesn't have ".svg" ending, it adds one
before trying to pull it from the dict of figures.

---------

Co-authored-by: Yael Ben-Haim <[email protected]>
nkanazawa1989 pushed a commit to nkanazawa1989/qiskit-experiments that referenced this issue Jan 10, 2024
…kit-community#1287)

### Summary

Figure names could be referred without ".svg" at the ending.
### Details and comments

Some details that should be in this section include:
In qiskit-community#629 , an issue was raised where a figure that was saved with the
name "abcd" couldn't be accessed. This issue is caused by that the
'add_figures()' method in `ExperimentData` class added ".svg"
automatically. As it explicitly written that SVG extension is added if
the file name doesn't have one, we can conclude that all figure names
have ".svg" extension. To not make a major change in the code I added to
the `figure` method in `ExperimentData` class a check for the extension
of the `figure_key`. If it doesn't have ".svg" ending, it adds one
before trying to pull it from the dict of figures.

---------

Co-authored-by: Yael Ben-Haim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants