question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Approximately equal circuits with symbols not detected by cirq.approx_eq

See original GitHub issue

Description of the issue Circuits with symbols are determined to be unequal by cirq.approx_eq when they should be approximately equal.

How to reproduce the issue

q = cirq.GridQubit(0, 0)
s = sympy.Symbol("s")

no_symbol_1 = cirq.Circuit(cirq.rz(1.515)(q))
no_symbol_2 = cirq.Circuit(cirq.rz(1.510)(q))
print(cirq.approx_eq(no_symbol_1, no_symbol_2, atol=0.1))

symbol_1 = cirq.Circuit(cirq.rz(1.515*s)(q))
symbol_2 = cirq.Circuit(cirq.rz(1.510*s)(q))
print(cirq.approx_eq(symbol_1, symbol_2, atol=0.1))

First output is True, second output is False

Cirq version 0.8.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tonybruguier-googlecommented, Aug 5, 2020

Is help still needed on this? I am looking for a good first issue.

1reaction
balopatcommented, Aug 5, 2020

Thank you for filing this @zaqqwerty - this should work. Either approx_eq should throw an error if the arguments are parametrized that it’s not supported or support it properly. This behavior is a silent failure. Marked it as a bug.

It also seems like a self contained issue, perfect for contributors to pick up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module: cirq
Cirq is a framework for creating, editing, and invoking quantum circuits.
Read more >
Using parametrised values and 'Symbols' in Cirq
So when you write cirq.Rx(cirq.Symbol("θ")) it internally attempts to scale the argument, and you get an error about multiplication/division not ...
Read more >
Unicode Characters: 02A00 to 02AFF
02A0 02A1 02A2 02A3 02A4 02A5 02A6 02A7 02A8 02A9 02AA 02AB 02AC 02AD 0 ⨀ ⨐ ⨠ ⨰ ⩀ ⩐ ⩠ ⩰ ⪀...
Read more >
other symbols used in math
More information about mathematical symbols may be found in individual ... Note that "approximately equal" is reflexive and symmetric but not transitive.
Read more >
HTML Math Symbols, Entities and Codes
Easily find HTML math symbols, entities, characters and codes with ASCII, HEX, ... greater than and less than signs, equals sign, not equal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found