-
Notifications
You must be signed in to change notification settings - Fork 370
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
allow to flexibly change the display width limit #2403
Conversation
In the process I have noticed that we did an incorrect escaping of CSV and TSV output. I have fixed it. One debatable thing is what we should use in CSV/TSV for non-standard types (like |
@nalimilan - tests will fail now. I will clean them when we decide if we want to use A a comment - I thought of |
I'd prefer using Regarding truncation, I've just checked, and dplyr only truncates when the output would be wider than the screen. Maybe we should do that too? One use case I can imagine is a column with short texts and one or two columns with variables describing them. |
NEWS.md
Outdated
@@ -67,3 +67,6 @@ | |||
([#2315](https://github.com/JuliaData/DataFrames.jl/pull/2315)) | |||
* add rich display support for Markdown cell entries in HTML and LaTeX | |||
([#2346](https://github.com/JuliaData/DataFrames.jl/pull/2346)) | |||
* limit display width in `text/plain` to approximately 32 screen characters |
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.
Is it really approximate? AFAICT, you stop at 32 and take the previous character, so it's always the maximum width before going beyond 32, right?
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.
No, because some characters have more than 1
text width (in which case we can get a bit different result)
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.
Yes but since you return the last character before going beyond 32, the result will always be less than 32, right? I think it would be worth mentioning in the docstring rather than just saying it's approximate.
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.
The precise statement is that the result without …
has maximal text width less or equal than 32 display characters, but how would you phrase it so that this would be readable?
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.
Maybe something like this? Anyway that's internal, what matters is that it's correct even if it's not super easy to read. :-)
`truncstring` indicates the maximal width the output can use before being truncated
(in the `textwidth` sense, excluding `…`).
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.
OK - I have proposed something along these lines 😄
OK - I switch to
If you try to do this it quickly starts to be very messy, it was tried in #2087. Also soon we will have a PrettyTables.jl backend to choose from that does what you propose (but it has a different design in general) - so someone will be able to go for that backend if needed. |
In the use case I have in mind, you have unique texts that you may want to read, so just having an idea of the contents isn't enough. But yeah it's difficult to handle this well in all cases. It's nice if PrettyTables aims to fill this gap. |
I am changing the implementation to add |
I had to add |
We already abbreviate eltypes when they are too long, right? |
Yes, but now |
@nalimilan - this should be good to have a look at. Thank you! |
Can you give an example? I don't get it. :-) |
I explicitly test this case here: |
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.
Looks good with the small suggestion for the docstring.
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Thank you for fixing the docstring. |
Thank you! |
Fixes #2389
I made it a bit different than Markdown rendering, but I think we do not have to be super cautious here as this is just handling corner cases of display.
Also fixes the problem of overwide first column (not as nicely as PrettyTabes.jl but again - this is a rare corner case now as we are trimming at 32 screen width anyway)
CC @nalimilan @ronisbr