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

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Sep 17, 2024

No description provided.

@@ -92,7 +88,14 @@ def f(hugr: Package, expected: Any, fn_name: str = "main"):

@pytest.fixture
def run_int_fn():
return _run_fn("run_int_function")
run_to_res = _run_fn("run_int_function")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The awkward thing is that this makes run_int_fn (the same as before but) different from run_float_fn, so perhaps they should be named differently. check_int_fn perhaps, although it'd be less change to rename the new run_float_fn instead....thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Completely agree. maybe eval_float_fn? It's not too bad to rename run_int_fn -> check_int_fn. Alternatively, we could perhaps move the pytest.approx (nice btw!), would run_float_fn(package, expected = pytest.approx(x)) work?

@@ -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.

@acl-cqc acl-cqc requested a review from doug-q September 17, 2024 16:23
@acl-cqc acl-cqc marked this pull request as ready for review September 17, 2024 16:23
@acl-cqc acl-cqc requested a review from a team as a code owner September 17, 2024 16:23
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.67%. Comparing base (a47ba8a) to head (e5b0601).

Additional details and impacted files
@@                 Coverage Diff                 @@
##           ss/fix-angle-lower     #506   +/-   ##
===================================================
  Coverage               91.67%   91.67%           
===================================================
  Files                      59       59           
  Lines                    6138     6138           
===================================================
  Hits                     5627     5627           
  Misses                    511      511           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@doug-q doug-q left a comment

Choose a reason for hiding this comment

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

Thanks Alan, I really appreciate the help here.

@@ -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

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.

@@ -92,7 +88,14 @@ def f(hugr: Package, expected: Any, fn_name: str = "main"):

@pytest.fixture
def run_int_fn():
return _run_fn("run_int_function")
run_to_res = _run_fn("run_int_function")
Copy link
Contributor

Choose a reason for hiding this comment

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

Completely agree. maybe eval_float_fn? It's not too bad to rename run_int_fn -> check_int_fn. Alternatively, we could perhaps move the pytest.approx (nice btw!), would run_float_fn(package, expected = pytest.approx(x)) work?

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Sep 18, 2024

Completely agree. maybe eval_float_fn? It's not too bad to rename run_int_fn -> check_int_fn. Alternatively, we could perhaps move the pytest.approx (nice btw!), would run_float_fn(package, expected = pytest.approx(x)) work?

Hah! Yes, it's much easier than what I did. I was remembering an assert_close(a, b) but that's numpy not pytest. With pytest.approx, as you say, we don't need to change run_float_fn at all - just pass in a pytest.approx.

Alternatively we could modify run_float_fn to apply the pytest.approx itself (rather than at each callsite) - that would be good practice, I think (so we could have a run_float_fn fixture that takes optional rel and abs precision arguments and passes them onto pytest.approx), but I've not done that here. Thoughts?

@acl-cqc acl-cqc requested a review from doug-q September 18, 2024 09:55
@acl-cqc acl-cqc merged commit 391fee5 into ss/fix-angle-lower Sep 18, 2024
2 checks passed
@acl-cqc acl-cqc deleted the acl/fix-angle-lower2 branch September 18, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants