CurveAnalysis base class#765
Conversation
fb14230 to
5d3a33f
Compare
5d3a33f to
3a4f605
Compare
eggerdj
left a comment
There was a problem hiding this comment.
This seems to be in good shape. Do you also need to refactor the other analysis classes to this?
| A method to format curve data. By default this method takes y value average | ||
| over the same x values and then sort the entire data by x values. |
There was a problem hiding this comment.
| A method to format curve data. By default this method takes y value average | |
| over the same x values and then sort the entire data by x values. | |
| A method to format curve data. By default this method takes the average of the y values | |
| over the same x values and then sort the entire data by x values. |
This is not something that is needed all the time right? This is most useful for RB correct? Perhaps that's worth mentioning here.
There was a problem hiding this comment.
No this is always done. Because some guess function relies on the sequence ordering, e.g. computing slope by something like dx = x[1] - x[0]. There is no guarantee x values are in ascending order.
There was a problem hiding this comment.
There are two things here.
a) averaging the y data
b) sorting according to x data.
Makes sense to always do b). Do we always do a)?
There was a problem hiding this comment.
Yes, should do. If you concatenate two experiments, you will create experiment data that may consist of something like x = [0,1,2,3,0,1,2,3] that will crash some guess function.
| https://github.com/Qiskit/qiskit-experiments/issues | ||
| """ | ||
| class CurveAnalysis(BaseCurveAnalysis): | ||
| """Base class for curve analyis.""" |
There was a problem hiding this comment.
This is not a base class is it?
There was a problem hiding this comment.
This is still base class (e.g. ErrorAmplificationAnalysis(CurveAnalysis)). The reason we introduce BaseCurveAnalysis is to remove boilerplate code in GroupedCurveAnalysis.
There was a problem hiding this comment.
hmmm the naming gets a bit confusing no? Since CurveAnalysis is still a base class it could be called BaseCurveAnalysis which is already taken. What are the distinctive features between CurveAnalysis (a base class) and BaseCurveAnalysis? Perhaps that can help with the naming.
There was a problem hiding this comment.
Can you also add a bit more to the class docstring to explain why we have this class? Currently it reads Base class for curve analyis. which is too brief given that we have another class called BaseCurveAnalysis.
There was a problem hiding this comment.
This will be clearer once we introduce the GroupCurveAnalysis (perhaps MultiGroupCurveAnalysis to be precise). The base one is the superclass of both CurveAnalysis and GroupCurveAnalysis . The difference between CurveAnalysis and BaseCurveAnalysis is implementation of _run_analysis method. In the group one the logic inside the _run_analysis will be different from CurveAnalysis though each subroutines can be reused. This is why BaseCurveAnalysis only implements subroutines.
qiskit_experiments/library/characterization/analysis/drag_analysis.py
Outdated
Show resolved
Hide resolved
…ure/curve_analysis_baseclass
Co-authored-by: Daniel J. Egger <38065505+eggerdj@users.noreply.github.com>
d3cde71 to
62d1609
Compare
| https://github.com/Qiskit/qiskit-experiments/issues | ||
| """ | ||
| class CurveAnalysis(BaseCurveAnalysis): | ||
| """Base class for curve analyis.""" |
There was a problem hiding this comment.
Can you also add a bit more to the class docstring to explain why we have this class? Currently it reads Base class for curve analyis. which is too brief given that we have another class called BaseCurveAnalysis.
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
| Curve Analysis Overview | ||
| ======================= | ||
|
|
||
| The base class :class:`CurveAnalysis` implements the multi-objective optimization on |
There was a problem hiding this comment.
I wonder if this is starting to get too detailed for class level API docs and should instead be moved to its own separate User Guide on curve analysis?
There was a problem hiding this comment.
Sounds good. Do we create user guide with this PR? I've already moved some long API docs (basically how code author can override method) to here and left :ref: link in the original place so I cannot simply remove this. Note that this is not a class level docs, this is module docs so I think this is probably okey for now.
There was a problem hiding this comment.
Yeah this can be a separate PR, I think we should do a bit of planning on what would make some good mode detailed user guides
Co-authored-by: Daniel J. Egger <38065505+eggerdj@users.noreply.github.com>
e7f83e9 to
3a86a25
Compare
Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
3d043d9 to
3d7a5e4
Compare
chriseclectic
left a comment
There was a problem hiding this comment.
Looks good, couple more documentation comments
| """Description of curve.""" | ||
| """A dataclass to describe the definition of the curve. | ||
|
|
||
| Args: |
There was a problem hiding this comment.
I was curious what the "correct" way to comment a dataclass is and found this https://stackoverflow.com/a/51131941
They suggest preferring option (3) using Attributes: rather than using Args:. I didn't test myself, but I wonder if this will will override the empty attribute desciptions currently populated here. Checking the artifact on this PR the attribute doc stirngs are unchanged, but the Parameters: field is populated correctly from these args.
Can you try changing to attributes and checking what the built docs looks like and pick the one you think looks best?
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
38ceaa0 to
d7e25a4
Compare
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
eggerdj
left a comment
There was a problem hiding this comment.
This looks good to me. @chriseclectic as you have also commented on this PR I'll let you give the final approval.
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniel J. Egger <38065505+eggerdj@users.noreply.github.com>
Co-authored-by: Daniel J. Egger <38065505+eggerdj@users.noreply.github.com>
…wa1989/qiskit-experiments into feature/curve_analysis_baseclass
317c687 to
67c942b
Compare
…wa1989/qiskit-experiments into feature/curve_analysis_baseclass
Refactor of CurveAnalysis and introduction of BaseCurveAnalysis class Co-authored-by: Daniel J. Egger <38065505+eggerdj@users.noreply.github.com> Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>


Summary
This PR introduces base class for curve analysis. See #737 for details.
Blocked by #762Details and comments
TODO
groupto curve analysis #715 )