Repository navigation
Conversation
…ialization logic with `outcome_graph` helper function, update imports, and streamline related modules.
…parison, eliminate redundant structures, and streamline simplification handling.
…` dataclass, introduce `base.py` for shared context logic, update evaluation methods to use `Context` object, and streamline context selection logic in `select_context`.
…sedQuantity` dataclass, update type aliases and dependent methods, and streamline parameter lookups in evaluation logic.
… `EvaluationParameters` dataclass, update all affected modules and type hints, streamline parameter access, and update dev documentation accordingly.
…_report` helper to centralize feedback and exception handling logic, reduce redundancy, and streamline reserved expression evaluation.
…s, internal references, and type hints across symbolic evaluation modules to streamline parameter usage and improve consistency.
Draft
1 of 2 tasks
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
This is the design-patterns follow-up deferred from #281, and it's stacked on that PR. After the restructure, the contexts were still plain dicts of functions. The evaluation parameters were a
FrozenValuesDictionaryread by string keys, and parsed quantities were aQuantityDict. Because of this, neither mypy nor a reader could see which fields exist. The graph builders also repeated the same setup code, andparse_reserved_expressionsrepeated its learner/task error handling three times.Changes
Behaviour is unchanged. Feedback strings, tags, graph shapes and raised exceptions are all the same as before.
outcome_graphhelper (app/context/graph_helpers.py): creates a graph with its end node and evaluation node. It is used in the generic, WHERE and physical-quantity order graphs. Inorder.pythe graph now gets its real label instead ofNone.check_equality(app/context/symbolic/comparison.py): the simplification retries are now straight-line code with early returns.Contextdataclass (app/context/base.py): a frozen dataclass replaces the context dicts.select_context(params)replacesdetermine_context. The context is passed explicitly instead of being deep-copied intoparameters["context"].ParsedQuantitydataclass (app/context/physical_quantity/parsing.py): replacesQuantityDict.EvaluationParametersdataclass (app/evaluation_parameters.py): replacesFrozenValuesDictionary, andapp/frozen_dict.pyis removed.GraphTemplateandContext.feedback_procedure_generatornow take it.Parametersstays for the raw request parameters. A criterion given twice still fails withCannot parse criteria: …, now through an explicit check._reporthelper (app/evaluation.py): the learner → feedback / task → raise choice inparse_reserved_expressionsis now in one helper. A task parse error still raises without a tag, as before.parameters_dict→parametersin the symbolic context.app/docs/dev.mdare updated.Checklist
app/docs.md) if user-facing behaviour changed (n/a, no behaviour change;app/docs/dev.mdupdated)Testing
pytest app/tests: 1217 passed, 2 skipped, 1 failed. The failure is the knowntest_radians_to_frequency.mypy app: no issues.evaluation_function(..., include_test_data=True)output for 15 symbolic and physical-quantity cases was byte-identical to the output before it (withPYTHONHASHSEED=0). For the_reportcommit, the raised exceptions (args, cause, suppressed context) for bad responses and answers were also compared and matched.🤖 Generated with Claude Code