Repository navigation
Add templates 8 - #1161
Merged
Merged
Add templates 8#1161
Conversation
Contributor
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
82 tasks done
depial
approved these changes
Oct 24, 2026
depial
left a comment
Contributor
There was a problem hiding this comment.
Just one note, but you can feel free to leave things as they are.
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.
Five template and another macro. Some tweaks to how matrices and empty values are handled, but I don't think these should break many solutions.
Adds Jinja2 test templates for flower-field, game-of-life, spiral-matrix, saddle-points and matrix
Each
runtests.jlis regenerated from canonical data, and every exercise passes against its example solution. Every templated exercise still passesgenerate_tests.py --check, so the existing generated files don't change. Each exercise has the same number of assertions and covers the same cases as before, so no tests were removed.Things to look at:
julia_matrixmacro (config/generator_macros.j2). It turns the canonical list of rows into a real JuliaMatrix:[[1, 2], [4, 3]]becomes[1 2; 4 3]. A single row such as[2 5 3 5]is already a 1×n matrix.reshape([2, 1, 4, 1], :, 1). A plain[1]would be aVector, and aVectoris never==to aMatrix.[]or[[]]in the canonical data) becomesMatrix{Int}(undef, 0, 0).reshape([], 0, 2)and is now the canonical 0×0Matrix{Int}.sort(saddlepoints(M)) == [...], with the expected points sorted by the template. Saddle points have no natural order, and the canonical data lists(1, 3)before(1, 1)in one case, while the example returns them in column-major order. Solutions can return the points in any order.Int[], aVector, and is now a 0×0 matrix.NTuple{2,Int}[...]literals and are now plain tuple vectors, because==doesn't compare element types.String[]instead of[], so solutions with a typed signature such asgarden::Vector{String}accept it. A bare[]is aVector{Any}. Expected values stay as written.rows, columns = matrix(s). The canonicalrow/columnproperty decides whether the test indexesrowsorcolumns.