-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(rust): right-align numeric columns #7475
feat(rust): right-align numeric columns #7475
Conversation
6c1f6fb
to
4904e39
Compare
Hey, thanks for this :) I put a follow-up comment on the original issue; do you think you could update the PR to include an option for fixing the number of floating point decimal places offered? I suspect right-alignment would be a lot more attractive/useful then. Also, if you could make this opt-in for now, via a suitable |
Hey, thanks for the reply. This looks doable for me, I will give it a shot. |
Fantastic :)
Add them into the |
4904e39
to
f03f90e
Compare
Nice, looks like it's almost there - and |
f03f90e
to
75e2a8b
Compare
ready for review @alexander-beedie :) |
Apologies for the delay; I managed to convince myself that GitHub was acting up last night after accidentally disabling JavaScript in my browser... Have checked out the branch and compiled it up, so...
With those two changes (and a rebase) we should be good to go :) |
FYI, I added a mechanism for allowing directly applied values (those not mediated by env vars) to better participate in |
Right I've updated the PR to use that mechanism for float_precision. This is sort of ready for review again, but there is a bit of an issue regarding the float_precision option. Namely, that when using |
I think that's fine; keeps it simple - can you raise an error if anyone tries to set a nonsense value? Probably anything above 16, which (if I recall correctly) is about the precision limit of an Have had family in town recently, so got a bit backlogged; will download the latest updates at the w/e and run through them (could you do a quick rebase?) 👍 |
3e7e5ba
to
6f6efc2
Compare
Sorry I was a bit busy myself over the Easter. I've tried to rebase tonight but I can't figure out how to without adding in hundreds of commits to the PR. I will try to sort this out next weekend. |
No problem; I think it'll be a great addition :) We have a 4 day weekend coming up here (national holidays), so I'll have plenty of time to review and/or help out.
A rebase + force-push should do the trick? Initially it'll look like you're incorporating tons of things, but after the force you should just be left with your own changes. |
6f6efc2
to
6b2ce08
Compare
@alexander-beedie Hey sorry I only just got around to fixing this, I've added the check for float precision being greater than 16 and rebased.
Yeah that's what I tried originally, but I ended up getting some commits from main in the commits/changes tabs to this PR. It was probably because I merged main into this branch at some earlier point, so I tried removing that merge commit first and that seems to have fixed it. |
Sorry to bother you guys. But is this still happening? @alexander-beedie @alicja-januszkiewicz |
Argh... this is 100% my fault; I must have missed some GitHub notifications and let it slip through the cracks. Short version is that "yes", I'd love to get this merged - it's a great contribution, and (potentially) could even become the default format. @alicja-januszkiewicz; since this is my bad, I have checked out this branch and rebased/merged locally; unfortunately I don't seem able to push it back out, though the "Maintainers are allowed to edit this pull request" option has been checked. I'll see if I can work out why not and will update accordingly 🤔
|
@alexander-beedie do you use the github cli? This always works much, much easier for pushing to a PR. |
I do not, but I'm willing to try ;) Update: Ah! It's ok, all working now. |
6b2ce08
to
ab62e20
Compare
b67e7f1
to
ead4fe8
Compare
Hi, I'd be happy to continue working on this, but I'm not sure what is the next step here - this is still pending review right? @alexander-beedie |
From my perspective I think it's in good shape; @ritchie46 or @orlp, would one of you mind having a quick look? (Note that this is a new formatting option, not enabled by default). Then let's merge and we can iterate further if necessary :) |
crates/polars-core/src/fmt.rs
Outdated
@@ -710,6 +724,15 @@ const SCIENTIFIC_BOUND: f64 = 999999.0; | |||
|
|||
fn fmt_float<T: Num + NumCast>(f: &mut Formatter<'_>, width: usize, v: T) -> fmt::Result { | |||
let v: f64 = NumCast::from(v).unwrap(); | |||
|
|||
let precision = get_float_precision(); | |||
if precision != u8::MAX { |
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.
Instead of usingu8::MAX
to signal 'no option set' I think we should use an Option<T>
initialized with None
.
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.
@alicja-januszkiewicz: want to take this one? :) I'm going to take a look at the max precision value again, as we should consider Decimal too (support for which is going to be turned on by default soon).
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.
Sure, I'll try to get this over by the end of the week.
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've changed the type of FLOAT_PRECISION
from AtomicU8
to RwLock<Option<usize>>
.
I've picked usize
for now as that's the type the write!
and format!
macros expect, so this saves having to repeatedly cast the value.
I've wrapped it in an RwLock
to hopefully retain whatever protection AtomicU8
was providing, as there doesn't seem to be an atomic equivalent of Option
.
9da0da3
to
c15731c
Compare
4608029
to
0abc339
Compare
39ad244
to
08ddbbf
Compare
@stinodego : This is a PR that I think could be merged as @alicja-januszkiewicz is still active on it (congratz mate!) and I think the feature would be well received. |
Definitely. Give me a few minutes with this one; has been a (too) long road getting this one over the line (which is on me 😅) |
08ddbbf
to
ea78949
Compare
Ok, rebased it and added an example to the docstring; pending a look from @orlp, I think we're ready to ship! 🥳 |
1a807ce
to
1a7a485
Compare
closes #7378