Open bramathon opened 11 months ago
This will require some design work in quil-rs
to resolve. The issue is that, when parsing a program, the string pi
is parsed as the Quil keyword pi
. However, when constructing a gate in Python, np.pi
is just a float. quil-rs
would either need to rewrite expressions containing pi
before storing them, or do so during comparison checks to make this work.
I would just like it to be one way or the other. I think the simplest way is when parsing a problem, replace pi with 3.14159...
This is ugly for program readers, but at least consistent.
On Fri, Sept 22, 2023, 18:07 Marquess Valdez @.***> wrote:
This will require some design work in quil-rs to resolve. The issue is that, when parsing a program, the string pi is parsed as the Quil keyword pi. However, when constructing a gate in Python, np.pi is just a float. quil-rs would either need to rewrite expressions containing pi before storing them, or do so during comparison checks to make this work.
— Reply to this email directly, view it on GitHub https://github.com/rigetti/pyquil/issues/1664#issuecomment-1731758241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEWA7RPAFT5IJJSXNMETU3X3XAVHANCNFSM6AAAAAA5DAHBSU . You are receiving this because you authored the thread.Message ID: @.***>
Isn't pi
literal always converted into a float per https://github.com/rigetti/quil-rs/pull/240 ?
I would just like it to be one way or the other. I think the simplest way is when parsing a problem, replace pi with 3.14159...
This is ugly for program readers, but at least consistent.
Consistent with np.pi
(itself a float), perhaps - but inconsistent with the input program, because it would no longer round-trip to the same string, where, syntactically, pi != 3.14...
. IMO this current behavior seems reasonable - np.pi
is a number, but Quil pi
is a special identifier to Quil itself, described in the Quil spec.
Issue Description
If I construct a program from a string, parameters such as "pi/2" are preserved and output that way. However, if I construct the same program in python, the parameter is output as 1.5707963267948966.
The two programs below are entirely equivalent and should compare as equal, but they do not.
How to Reproduce
Code Snippet