-
Notifications
You must be signed in to change notification settings - Fork 16
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
Pretty print model as Essence #582
Merged
Merged
Conversation
This file contains 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
Implement `Display` for `Model` to print it in Essence. Using this, change CLI logging to print models in essence instead of JSON.
* During integration testing, pretty print the initial and rewritten models in Essence in the human rule trace. * Change verbose print statements in the integration tester to pretty print the model as Essence. Currently we only have the rewritten model output in `Debug` format; having this in Essence should help with debugging.
niklasdewally
changed the title
impl Display for Model, printing it as Essence
Pretty print model as Essence
Jan 10, 2025
Change type of `SymbolTable` from `HashMap` to `BTreeMap`. `BTreeMap` gives variables an ordering in the symbol table, allowing them to be printed in a deterministic order. It also implements `Eq`, and `Hash`, which will allow us to compare symbol tables to each other in the future. Previously, with a `HashMap`, the key ordering was unspecified, so they could be printed in any order. The keys printing in a different order in the expected and generated test files broke some tests. We plan to convert more `HashMaps` to `BTreeMaps` in the future for similar reasons. For example, using it for solution sets will allow us to compare them easier (due to implementing `Eq` and `Hash`) [#531].
FYI: @Soph1514 @ewilbert7 |
ozgurakgun
approved these changes
Jan 10, 2025
I'll fix the new clippy warnings before merging |
lgtm, except the hygiene issue |
niklasdewally
force-pushed
the
nik/pr/tester-print-final-model
branch
from
January 10, 2025 16:17
d086e42
to
fe3e1ee
Compare
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.
Using the pretty printers implement Display for Model to print it in Essence syntax.
Continuation of #568 , in which I added a pretty printer for variable declarations.
Changelog
impl Display for Model, printing it as Essence
Implement
Display
forModel
to print it in Essence.Using this, change CLI logging to print models in essence instead of
JSON.
tester: pretty print initial and rewritten models in human rule trace
During integration testing, pretty print the initial and rewritten
models in Essence in the human rule trace.
Change verbose print statements in the integration tester to pretty
print the model as Essence.
Currently we only have the rewritten model output in
Debug
format;having this in Essence should help with debugging.
refactor!: Change type of SymbolTable from HashMap to BTreeMap
Change type of
SymbolTable
fromHashMap
toBTreeMap
.BTreeMap
gives variables an ordering in the symbol table, allowingthem to be printed in a deterministic order. It also implements
Eq
,and
Hash
, which will allow us to compare symbol tables to each otherin the future.
Previously, with a
HashMap
, the key ordering was unspecified, so theycould be printed in any order. The keys printing in a different order in
the expected and generated test files broke some tests.
We plan to convert more
HashMaps
toBTreeMaps
in the future forsimilar reasons. For example, using it for solution sets will allow us
to compare them easier (due to implementing
Eq
andHash
) (#531)