Skip to content

Commit

Permalink
fix Moment.resolve_parameter not resolving all the expressions
Browse files Browse the repository at this point in the history
Fixes #6778
Fix Moment.resolve_parameters to properly resolve symbolic expressions

    Changed equality check from '!=' to 'is not' to handle cases where symbolic parameters are equivalent but not identical objects

    Ensured that the method returns a new object only when a variable is resolved, maintaining efficient behavior.

    Tested the fix with existing cases for Rx, Ry, and Rz gates to confirm correct behavior when parameters are resolved or remain unchanged.
  • Loading branch information
dv8081 authored Nov 14, 2024
1 parent fd95547 commit d4f883e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cirq-core/cirq/circuits/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _resolve_parameters_(
resolved_ops: List['cirq.Operation'] = []
for op in self:
resolved_op = protocols.resolve_parameters(op, resolver, recursive)
if resolved_op != op:
if resolved_op is not op:
changed = True
resolved_ops.append(resolved_op)
if not changed:
Expand Down

0 comments on commit d4f883e

Please sign in to comment.