Skip to content

Commit

Permalink
Add warning for build_call_graph returning a set
Browse files Browse the repository at this point in the history
- We changed build_call_graph to return a dictionary
as a part quantumlib#845.
- This now emits a deprecation warning now that all the
built-in bloqs are converted.
  • Loading branch information
dstrain115 committed Sep 9, 2024
1 parent 7e318f2 commit b15e081
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qualtran/resource_counting/_call_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Functionality for the `Bloq.call_graph()` protocol."""

import collections.abc
import warnings
from collections import defaultdict
from typing import (
Callable,
Expand Down Expand Up @@ -92,6 +93,10 @@ def _generalize_callees(
callee_counts: Dict[Bloq, Union[int, sympy.Expr]] = defaultdict(lambda: 0)
if isinstance(raw_callee_counts, set):
raw_callee_iterator: Iterable[BloqCountT] = raw_callee_counts
warnings.warn(
"build_call_graph returning sets is deprecated (got {raw_callee_counts})."
"Please change build_call_graph for this bloq to use a dictionary."
)
else:
raw_callee_iterator = raw_callee_counts.items()
for callee, n in raw_callee_iterator:
Expand Down

0 comments on commit b15e081

Please sign in to comment.