-
Notifications
You must be signed in to change notification settings - Fork 131
Reimplement AnalysisResultTable #1252
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
Reimplement AnalysisResultTable #1252
Conversation
… columns are managed by a mix-in. Remove baseclass ThreadSafeDataFrame having both responsibility since this is only used for analysis results.
This must be merged before 0.6 otherwise we will introduce breaking API change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, LGTM. Not introducing ThreadSafeDataFrame makes sense to me. I've left two minor comments inline.
import pandas as pd | ||
|
||
|
||
class DefaultColumnsMixIn: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class seems not designed to be used in different places (the interface heavily depends on Pandas Dataframe and if we change the implementation of container, this class will be changed accordingly). I think it would be good to notify users not to use (subclass) this class in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This is good suggestion. Done in 9b3bff9
**kwargs, | ||
) | ||
|
||
def drop( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer drop_entry
(To me, drop
feels it implements all features supported in pd.Datafram.drop
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Done in 6925655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
### Summary Follow-up of qiskit-community#1133 for data frame. ### Details and comments I realized I had some mistake when I wrote a base class of `ThreadSafeDataFrame`. We plan to move the curve data (XY data) to the artifact for better reusability of the data points. In addition, [CurveData](https://github.com/Qiskit-Extensions/qiskit-experiments/blob/c66034c90dad73d705af25be7e9ed9617e7eb2ef/qiskit_experiments/curve_analysis/curve_data.py#L88-L113) object which is a container of the XY data is also replaced with the data frame in a follow up PR. Since this table should contain predefined columns such as `xval`, `yval`, `yerr`, I was assuming this container could be a subclass of `ThreadSafeDataFrame` -- but this was not a right assumption. Since the curve analysis always runs on a single thread (analysis callbacks might be run on multiple threads and thus `AnalysisResultTable` must be thread-safe), this curve data frame doesn't need to be thread-safe object. In this PR, a functionality to define default columns of the table is reimplemented as a Python mixin class so that the function to add default columns will be used also for curve data frame without introducing the unnecessary thread safe mechanisms. `AnalysisResultTable` is a thread safe container but the functionality to manage default columns is delegated to the mixin.
Summary
Follow-up of #1133 for data frame.
Details and comments
I realized I had some mistake when I wrote a base class of
ThreadSafeDataFrame
. We plan to move the curve data (XY data) to the artifact for better reusability of the data points. In addition, CurveData object which is a container of the XY data is also replaced with the data frame in a follow up PR. Since this table should contain predefined columns such asxval
,yval
,yerr
, I was assuming this container could be a subclass ofThreadSafeDataFrame
-- but this was not a right assumption.Since the curve analysis always runs on a single thread (analysis callbacks might be run on multiple threads and thus
AnalysisResultTable
must be thread-safe), this curve data frame doesn't need to be thread-safe object. In this PR, a functionality to define default columns of the table is reimplemented as a Python mixin class so that the function to add default columns will be used also for curve data frame without introducing the unnecessary thread safe mechanisms.AnalysisResultTable
is a thread safe container but the functionality to manage default columns is delegated to the mixin.