From 7c4a60f5794724fff3fc155043ae53f25de9ac05 Mon Sep 17 00:00:00 2001 From: bdg221 Date: Wed, 30 Oct 2024 13:41:56 -0700 Subject: [PATCH] Check type inside Sequence and Iterators --- mitiq/executor/executor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mitiq/executor/executor.py b/mitiq/executor/executor.py index 4f7790f3d..bf50a2bbf 100644 --- a/mitiq/executor/executor.py +++ b/mitiq/executor/executor.py @@ -208,7 +208,12 @@ def evaluate( # check returned type manual_return_type = None if len(all_results) > 0: - manual_return_type = type(all_results[0]) + if isinstance(all_results[0], Sequence): + manual_return_type = type(all_results[0][0]) + elif isinstance(all_results[0], Iterable): + manual_return_type = type(next(iter(all_results[0]))) + else: + manual_return_type = type(all_results[0]) # Parse the results. if manual_return_type in FloatLike: