Skip to content

Commit

Permalink
Add warning for build_call_graph returning a set (#1396)
Browse files Browse the repository at this point in the history
* Add warning for build_call_graph returning a set

- We changed build_call_graph to return a dictionary
as a part #845.
- This now emits a deprecation warning now that all the
built-in bloqs are converted.

* Add DeprecationWarning

---------

Co-authored-by: Matthew Harrigan <[email protected]>
  • Loading branch information
dstrain115 and mpharrigan authored Sep 9, 2024
1 parent a6fc9f3 commit b5722c0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 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 @@ -94,6 +95,11 @@ 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.",
DeprecationWarning,
)
else:
raw_callee_iterator = raw_callee_counts.items()
for callee, n in raw_callee_iterator:
Expand Down

0 comments on commit b5722c0

Please sign in to comment.