-
Notifications
You must be signed in to change notification settings - Fork 62
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
Implement string interpolation for floats #39
Conversation
assert.eq(str(sorted([inf, neginf, nan, 1e300, -1e300, 1.0, -1.0, 1, -1, 1e-300, -1e-300, 0, 0.0, negzero, 1e-300, -1e-300])), "[-inf, -1e+300, -1.0, -1, -1e-300, -1e-300, 0, 0.0, -0.0, 1e-300, 1e-300, 1.0, 1, 1e+300, +inf, nan]") | ||
assert.eq( | ||
str(sorted([inf, neginf, nan, 1e300, -1e300, 1.0, -1.0, 1, -1, 1e-300, -1e-300, 0, 0.0, negzero, 1e-300, -1e-300])), | ||
"[-inf, -1e+300, -1.0, -1, -1e-300, -1e-300, 0, 0.0, -0.0, 1e-300, 1e-300, 1.0, 1, 1e+300, +inf, nan]") |
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.
Restored the original since we no longer ignore this test.
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.
Awesome work! Very impressive. As before, I'll let you address/comment on the issues below, then once you've updated, mirror it in to FB side and merge.
@ndmitchell has anything changed in ci checks? I've noticed that clippy found a lot of problems that are not related to changes in this PR. |
The clippy changes are partly due to nightly clippy detecting more things, and partly due to code changes. I think we're down to one in the latest HEAD, as I was working on it yesterday. Don't worry too much - we have a set of lints we apply internally too, so that will catch the ones we care about. |
@ndmitchell has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@ndmitchell merged this pull request in 8c89e4d. |
Thanks for the code! All landed and most appreciated! In internal code review we debated |
Yeah, I learned about Happy to help as always |
Addresses: #3
Spec: https://github.com/bazelbuild/starlark/blob/689f54426951638ef5b7c41a14d8fc48e65c5f77/spec.md#string-interpolation
Changes:
float::write_{decimal,scientific,compact}
functions for various kinds of string interpolation for floatsDisplay for StarlarkFloat
usewrite_compact
(as per spec)write_*
functions