-
Notifications
You must be signed in to change notification settings - Fork 991
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
format_col/format_list_item printing generics for customization #3414
Conversation
Can you explain why not |
Its just shy of being flexible enough; see your comment here: |
I sort of see. Just shy meaning the space in |
OK. For some reason I thought I'm still not quite convinced though, as I'm still hung up on the following: This PR introduces two new generics: |
@mattdowle merged this to master and overwrote changes built in #3500 with what was originally proposed here. I think the approach here is cleaner. Also subsumed the NEWS note there into the item for this PR. |
Codecov Report
@@ Coverage Diff @@
## master #3414 +/- ##
==========================================
- Coverage 99.47% 97.17% -2.30%
==========================================
Files 75 66 -9
Lines 14808 12632 -2176
==========================================
- Hits 14730 12275 -2455
- Misses 78 357 +279
Continue to review full report at Codecov.
|
071abde
to
6135767
Compare
6135767
to
bf591d6
Compare
ee8c86b
to
3e40e44
Compare
Just checking back ... is this PR dead? FWIW, here is the approach of custom printers for tibbles: https://pillar.r-lib.org/reference/pillar_shaft.html |
happy to do some testing when ready. This is a must have |
Related: #605 |
OK finally merged & updated this PR against current master. We fail one test:
That's because in this PR I removed the Now I guess we'd have to do a deprecation cycle. Or should we continue to support Default behavior in this PR is to always print the time zone if it's there. |
nvm, it's already done |
…rror; and remove registerS3method as it isn't needed
…remained registered afterwards
@MichaelChirico This looks good to me to merge now. You? |
char.trunc <- function(x, trunc.char = getOption("datatable.prettyprint.char")) { | ||
trunc.char = max(0L, suppressWarnings(as.integer(trunc.char[1L])), na.rm=TRUE) | ||
if (!is.character(x) || trunc.char <= 0L) return(x) | ||
idx = which(nchar(x) > trunc.char) |
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.
not crucial for this PR in particular, but wouldn't nchar(x, 'width')
be more appropriate?
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.
Good idea. Would need a test too in a new PR: your Chinese multi-byte data?
Made a few tweaks, ready for merge now |
Successor to @mllg's original PR (I don't have push access there so just continuing here) #3338.
I've built upon @mllg's initial idea to allow two dimensions of print output customization -- one at the column level and one at the row level (for
list
columns). The latter was covered in #3338.Currently test 1293 fails:
IIUC the problem is that
digits
is passed on through...
format_list_item
and this messes with the output since numerics in lists havedigits
applied as well.In a sense this is a more consistent interpretation, so I didn't bother keeping the status quo behavior, but don't want to overwrite the old test behavior without consulting here first.