Skip to content

Conversation

nkanazawa1989
Copy link
Collaborator

@nkanazawa1989 nkanazawa1989 commented Aug 18, 2023

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 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.

… columns are managed by a mix-in. Remove baseclass ThreadSafeDataFrame having both responsibility since this is only used for analysis results.
@nkanazawa1989 nkanazawa1989 changed the title Fix/followup 1133 Reimplement AnalysisResultTable Aug 18, 2023
@nkanazawa1989 nkanazawa1989 added this to the Release 0.6 milestone Aug 18, 2023
@nkanazawa1989
Copy link
Collaborator Author

This must be merged before 0.6 otherwise we will introduce breaking API change.

Copy link
Contributor

@itoko itoko left a 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:
Copy link
Contributor

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.

Copy link
Collaborator Author

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(
Copy link
Contributor

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)

Copy link
Collaborator Author

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

Copy link
Contributor

@itoko itoko left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue Aug 29, 2023
Merged via the queue into qiskit-community:main with commit f5c759b Aug 29, 2023
nkanazawa1989 added a commit to nkanazawa1989/qiskit-experiments that referenced this pull request Jan 10, 2024
### 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.
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.

2 participants