Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Proposed review changes to #485 #506

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guppylang/prelude/_internal/json_defs/tket2/rotation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"radd": {
"extension": "tket2.rotation",
"name": "radd",
"description": "Add two angles together (experimental).",
"description": "Add two rotations together (experimental).",
"signature": {
"params": [],
"body": {
Expand Down
4 changes: 4 additions & 0 deletions guppylang/prelude/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

@guppy.struct(angles)
class angle:
"""Not an angle in the truest sense but a rotation by a number of half-turns
(does not wrap or identify with itself modulo any number of complete turns).
"""

halfturns: float

@guppy(angles)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def main(a1: angle, a2: angle) -> bool:
a3 = -a1 + a2 * -3
a3 -= a1
a3 += 2 * a1
return a3 == -a2
return a3 / 3 == -a2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a straightforward reversion of an unnecessary change. (The code is not executed, the result does not have to be true, and division is valid.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, this is leftover from a moment where division was banned.


validate(module.compile())

Expand Down Expand Up @@ -247,4 +247,4 @@ def main() -> float:
hugr = module.compile()
validate(hugr)
import math
run_float_fn(hugr, expected=-6 * math.pi)
run_float_fn(hugr, expected=pytest.approx(-6 * math.pi))
Loading