Skip to content

Commit

Permalink
Raising a warning for running analysis on an empty ExperimentData o…
Browse files Browse the repository at this point in the history
…bject (#1313)

### Summary

Added a warning for the user if the `ExperimentData` data is empty
before running an analysis and if the data couldn't be retrieved.

### Details and comments

Some details that should be in this section include:

- The user will get an un-inductive error regarding the analysis while
the reason it was raised is because the analysis doesn't have data to
analyze from the experiment. We can see an example in #1182 .
- A solution that was suggested was to raise an error that says the user
is trying to run analysis on empty `ExperimentData` object but the team
didn't want to constraint the user to run analysis only if the
experiment has data so we decided that raising a warning is enough.

Changes:
- [x] Added warning before analysis if `ExperimentData.data()` is empty.

### PR checklist (delete when all criteria are met)

- [x] I have read the contributing guide `CONTRIBUTING.md`.
- [x] I have added a release note file using `reno` if this change needs
to be documented in the release notes.

---------

Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
  • Loading branch information
ItamarGoldman and yaelbh authored Nov 13, 2023
1 parent af04300 commit 2307d0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qiskit_experiments/framework/base_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from collections import OrderedDict
from datetime import datetime
from typing import List, Tuple, Union, Dict
import warnings

from dateutil import tz

Expand Down Expand Up @@ -166,6 +167,9 @@ def run_analysis(expdata: ExperimentData):
# Clearing previous analysis data
experiment_data._clear_results()

if not expdata.data():
warnings.warn("ExperimentData object data is empty.\n")

# Making new analysis
results, figures = analysis._run_analysis(expdata)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
other:
- |
Display a warning when running an analysis on `ExperimentData` objects which do not contain data.

0 comments on commit 2307d0e

Please sign in to comment.