Repository navigation
Conversation
…n, and handle edge cases for non-constant values; add targeted test coverage for criteria mismatches and tolerance checks.
…on_infinite` to evaluate only requested comparisons
…nd update `comparison_function` to return `None` for unresolved symbolic differences
…ass, simplify `parse_criterion_sides`, update match functions, and expand test coverage.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some criteria gave learners an error instead of feedback. These bugs came up during the context refactor (bug report). This is the first PR of the bug-fix stack, and it is stacked on #283.
matchescriteria whose sides weren't exactlyresponse/answercrashed or applied the tolerance to the wrong values. Sets andNonestandard values also crashed_within_tolerance.1/0) sometimes crashed. Every comparison operator was evaluated, not only the one requested, so whether it crashed depended on hash randomisation.response > 1.5 mraisedTypeError(14a). A quantity written out in the criterion was not parsed with units (14b).response matches 2 mwas always false. 14b fixes this.'Rational' * 'NoneType'). 14b fixes this.Changes
_within_tolerance(app/context/physical_quantity/graphs/match.py): returnsFalseunless a tolerance is set, the criterion is response/answer, and both standard values are single sympy expressions.do_comparison_infinite(app/context/symbolic/comparison.py): looks up only the requested operator inCOMPARISON_OPERATORSand evaluates it inside thetry.comparison_function(app/context/physical_quantity/comparison.py): returnsNone(unknown) when sympy cannot decide the truth value, instead of raisingTypeError.CriterionSides(app/context/physical_quantity/comparison.py):parse_criterion_sidesnow returns a frozen dataclass. A side written out as a quantity (INPUTlabel) is parsed with the quantity parser and stands in the expression as acriterion_lhs/criterion_rhssymbol. ItsParsedQuantitygoes intosides.quantitiesnext to the response and answer.match.py(_quantity_match,_dimension_match,_unit_comparison) andorder.py(comparison_base_graph) substitute fromsides.quantities.order.pycompares a quantity without a unit by its value alone.parsed_quantityis split out ofparse_quantityinapp/context/physical_quantity/parsing.py.Checklist
Testing
test_matches_criteria_other_than_response_and_answer_when_values_differ,test_order_criteria_against_written_out_quantityandtest_matches_criteria_against_written_out_quantityinphysical_quantity_evaluation_test.py.test_complex_infinityandtest_do_comparison_infinite_only_evaluates_requested_comparisoninsymbolic_evaluation_test.py. The direct test is there because the end-to-end crash only happened on some runs.pytest app: 1241 passed, 2 skipped, 1 failed. The failure istest_radians_to_frequency, which already failed before this PR.mypy app: no issues.Still open in the bug report, for the next PRs in the stack: 2, 3, 4, 6, 7, 8, 9, 11, 13, 15, and the feedback strings.
🤖 Generated with Claude Code