Skip to content

Conversation

@chriseclectic
Copy link
Collaborator

@chriseclectic chriseclectic commented May 6, 2021

Summary

Updates the ExperimentData class to handle storing figures and to bring its API a bit closer in line with the draft API of the terra base class in Qiskit/qiskit#5499

This is intended as step towards being able to make ExperimentData a subclass of the ExperimentDataV1 class from Qiskit/qiskit#5499 once it is merged into terra.

Details and comments

  • Changes figure return type of _run_analysis to be a pyplot.figure rather than an axis. This allows the figures to be stored and retrieved from experiment data.
  • Ports implementation of add_figure and figure from Experiment data and service Qiskit/qiskit#5499
  • Adds curve fit plot to T1Experiment
  • Changes ExperimentData.data from property to a method to match terra class API
  • Adds analysis kwarg to BaseExperiment.run which can be set to false to prevent analysis from being run automatically.
  • Clean up composite analysis code

"""
return self._backend

def add_data(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that you copied a lot of sections from the Terra PR. I assume that this is a temporary copy, and that once the Terra PR is merged and we inherit from the class there, these sections will be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep exactly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have a follow up branch to this PR where I started to do this, but its needs a few small changes to the Terra PR that I left as review there: https://github.com/chriseclectic/qiskit-experiments/blob/resultdb/qiskit_experiments/experiment_data.py#L34

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please be aware of #29

Copy link
Collaborator

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

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

This looks good to me. My comments are just questions.

self._format_plot(ax, fit_result, qubit=qubit)
figures = [ax.get_figure()]
else:
figures = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Raising UserWarning would be more friendly :)

@coruscating coruscating merged commit 94c1eba into qiskit-community:main May 13, 2021
nkanazawa1989 pushed a commit to nkanazawa1989/qiskit-experiments that referenced this pull request May 13, 2021
eggerdj added a commit that referenced this pull request Jun 8, 2021
* wip curve fit analysis

* wip curve fit analysis

* curve_fit complete

* - unittest
- bug fix
- lint

* black

* removed redundant code

* fix unittest

* fix docstring

* fix docstring

* wording fix

Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Feedback from eggerdj

- add default data processor
- add data processor calibraiton
- integrate run_fit and series fit
- add data pre-processing (i.e. RB needs to take mean)
- add fitter setup for initial guess and other options

* readd 52c99ea and 0420d1d

* add fit functions

* lint

* review by eggerdj r2

- change dp calibration logic
- add gaussian function

* add data processor keys in metadata

add data processor keys in metadata

* conform to #41

* feedback from chris1
- more general docstring
- add default parameter to fit funcs

* feedback from chris2
- parameter dict handling

* feedback from chris3
- import path

* lint

* add fit option validation

* add unittest and integration test

* black & lint

* simplify the analysis class

* misc

* add default figure generation

* lint

* add default value

* fix docstring typo

* remove outcome from default processing options

* black and lint

* add processor training check

* fix pre processing routine

* update rb analysis as an example
- add num_qubits to curve analysis
- add label generation to curve analysis

* post process error handling when fit failed

* add axis label

* update axis formatting

* more integration with new options

* update irb

* move class attributes to options

* review comment from Chris

* fix bug causes list indices must be ...

* Analysis result formatting

* update error docstring

* lint

* bug fix
- reorder args of protected methods (series comes before xvals)
- make analysis result list
- relevant test fix
- add filter kwargs to interleaved analysis

* lint

* fix spect analysis

* fix composite analysis to use instance's analysis option

* adjust curve figure appearance

* black

* update data and option handling

* - private -> protected member
- param list generation and validation in new method
- all nan sigma handling
- zero sigma handling in curve fitter
- add data extraction utils
- allow bounds = None
-

* update spectroscopy

* black & lint

* rerun rb notebook

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* - more docstring
- add y normalization

* black

* add TODO comment

* add analysis class information to result data

* fix unittest

* update spect analysis docstring

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* rb analysis class docstring

* format docstring

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>
Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
@coruscating coruscating added this to the Release 0.1 milestone Jun 16, 2021
@chriseclectic chriseclectic deleted the expdata branch July 21, 2021 18:45
paco-ri pushed a commit to paco-ri/qiskit-experiments that referenced this pull request Jul 11, 2022
* Update ExperimentData to handle figures

Also makes some changes to be closer to draft API for terra
base class

* Update composite experiment class

* Update RB and T1 experiments

* Update tests

* Fix linting errors

* fix check for matplotlib

* black

* linting

* Fix saving figure to file

* Add type hints to BaseExperiment

* Fix conflicts with main

* unused import

* fix doc string removed by rebase

* Add handling of new and legacy backends
paco-ri pushed a commit to paco-ri/qiskit-experiments that referenced this pull request Jul 11, 2022
* wip curve fit analysis

* wip curve fit analysis

* curve_fit complete

* - unittest
- bug fix
- lint

* black

* removed redundant code

* fix unittest

* fix docstring

* fix docstring

* wording fix

Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Feedback from eggerdj

- add default data processor
- add data processor calibraiton
- integrate run_fit and series fit
- add data pre-processing (i.e. RB needs to take mean)
- add fitter setup for initial guess and other options

* readd 52c99ea and 0420d1d

* add fit functions

* lint

* review by eggerdj r2

- change dp calibration logic
- add gaussian function

* add data processor keys in metadata

add data processor keys in metadata

* conform to qiskit-community#41

* feedback from chris1
- more general docstring
- add default parameter to fit funcs

* feedback from chris2
- parameter dict handling

* feedback from chris3
- import path

* lint

* add fit option validation

* add unittest and integration test

* black & lint

* simplify the analysis class

* misc

* add default figure generation

* lint

* add default value

* fix docstring typo

* remove outcome from default processing options

* black and lint

* add processor training check

* fix pre processing routine

* update rb analysis as an example
- add num_qubits to curve analysis
- add label generation to curve analysis

* post process error handling when fit failed

* add axis label

* update axis formatting

* more integration with new options

* update irb

* move class attributes to options

* review comment from Chris

* fix bug causes list indices must be ...

* Analysis result formatting

* update error docstring

* lint

* bug fix
- reorder args of protected methods (series comes before xvals)
- make analysis result list
- relevant test fix
- add filter kwargs to interleaved analysis

* lint

* fix spect analysis

* fix composite analysis to use instance's analysis option

* adjust curve figure appearance

* black

* update data and option handling

* - private -> protected member
- param list generation and validation in new method
- all nan sigma handling
- zero sigma handling in curve fitter
- add data extraction utils
- allow bounds = None
-

* update spectroscopy

* black & lint

* rerun rb notebook

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* - more docstring
- add y normalization

* black

* add TODO comment

* add analysis class information to result data

* fix unittest

* update spect analysis docstring

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

* rb analysis class docstring

* format docstring

* Update qiskit_experiments/analysis/curve_analysis.py

Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>

Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
Co-authored-by: Daniel Egger <38065505+eggerdj@users.noreply.github.com>
Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
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.

4 participants