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

python: sanitize number formatting #130

Merged
merged 3 commits into from
Jun 17, 2024
Merged

python: sanitize number formatting #130

merged 3 commits into from
Jun 17, 2024

Conversation

axel-h
Copy link
Member

@axel-h axel-h commented Mar 27, 2023

  • Fix the calculation of leading zeros. Using "int(log10(cnt + 1)) + 1" is broken, it evaluates to 2 for cnt=9, and thus results in the strings "00"-"08". Using "1 if (n <= 1) else (1 + int(log10(n - 1)))" seems overly complicated here, so a naive and readable way is used.
  • switch to f-strings for better readability

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

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

I usually like f-strings, but you're now duplicating the format a bunch of times. Is that really better?

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

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

Looking at it more deeply, @kent-mcleod was pointing out that this is a breaking change, because it changes the names in the generated capDL spec.

It's not catastrophic, but it will make it harder for people to migrate between versions, because it introduces unnecessary change. Not that people should rely on the names, but I'm sure some things do.

If this was fixing an actual problem it would make sense to look into it and accept that potential additional work for people, but doing that for the purely aesthetic reason to get the right number of leading zeroes in an artefact that is usually not for human consumption is not worth it, so I don't think we should merge this PR.

I'd be up for adding a comment that we know it's not the right number, but that we currently don't want to break spec compatibility.

@axel-h
Copy link
Member Author

axel-h commented May 18, 2023

Actually, this is a follow-up on my PR comment #104 (comment) but the changes there got merged already, and this was not addressed.
So, while this is another breaking change, it "fixes" things to the intention of that PR. The f-strings try to make it a bit less obscure, we can drop this part.
I agree it is just aesthetic in the end, and unfortunately I did not find the time to make the PR earlier. However, there has not been any release since then, so for the upcoming release it's all a breaking change anyway.

@axel-h axel-h requested a review from wom-bat May 19, 2023 03:19
@lsf37 lsf37 self-assigned this Jun 17, 2024
- Fix the calculation of leading zeros. Using "int(log10(cnt + 1)) + 1"
  is broken, it evaluates to 2 for cnt=9, and thus results in the
  strings "00"-"08". Using "1 if (n <= 1) else (1 + int(log10(n - 1)))"
  seems overly complicated here, so a naive and readable way is used.
- switch to f-strings

Signed-off-by: Axel Heider <[email protected]>
Signed-off-by: Gerwin Klein <[email protected]>
@lsf37 lsf37 merged commit f7be6b4 into seL4:master Jun 17, 2024
25 checks passed
@axel-h axel-h deleted the patch-axel-4 branch July 2, 2024 10:17
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