Skip to content

Commit

Permalink
Fix caller function name in case of recursive call in input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
donsano33 committed Dec 13, 2023
1 parent 88c0908 commit 2b0767d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions qiskit_dynamics/backend/dynamics_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,16 +930,17 @@ def default_experiment_result_function(
raise QiskitError(f"meas_level=={backend.options.meas_level} not implemented.")


def _validate_run_input(run_input, accept_list=True):
def _validate_run_input(run_input, accept_list=True, caller_func_name: str = None):
"""Raise errors if the run_input is not one of QuantumCircuit, Schedule, ScheduleBlock, or
a list of these.
"""
if caller_func_name is None:
caller_func_name = inspect.stack()[1].function
if isinstance(run_input, list) and accept_list:
# if list apply recursively, but no longer accept lists
for x in run_input:
_validate_run_input(x, accept_list=False)
_validate_run_input(x, accept_list=False, caller_func_name=caller_func_name)
elif not isinstance(run_input, (QuantumCircuit, Schedule, ScheduleBlock)):
caller_func_name = inspect.stack()[1].function
raise QiskitError(
f"Input type {type(run_input)} not supported by DynamicsBackend.{caller_func_name}."
)
Expand Down

0 comments on commit 2b0767d

Please sign in to comment.