-
Notifications
You must be signed in to change notification settings - Fork 70
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
Conversation
There was a problem hiding this 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?
There was a problem hiding this 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.
Actually, this is a follow-up on my PR comment #104 (comment) but the changes there got merged already, and this was not addressed. |
c42a125
to
889c4b3
Compare
Signed-off-by: Axel Heider <[email protected]>
- 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]>
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.