Skip to content
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

add format_list_item.data.frame #6593

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

r2evans
Copy link

@r2evans r2evans commented Oct 28, 2024

Closes #6592, nested 1-column frames break print.data.table

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.60%. Comparing base (afa87e1) to head (480d8d6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6593   +/-   ##
=======================================
  Coverage   98.60%   98.60%           
=======================================
  Files          79       79           
  Lines       14516    14517    +1     
=======================================
+ Hits        14314    14315    +1     
  Misses        202      202           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelChirico
Copy link
Member

Can you check if this fixes #5948, or if the fix there is related?

Comment on lines 20603 to 20610
test(2297.03, format_list_item(data.frame(a=1)[,0]), output = "<data.frame\\[1x0]>")
test(2297.04, format_list_item(data.frame(a=1, b=2)[0,,drop=FALSE]), output = "<data.frame\\[0x2]>")
test(2297.05, format_list_item(data.frame(a=1, b=2)[,0]), output = "<data.frame\\[1x0]>")
test(2297.06, format_list_item(data.table(a=1)), output = "<data.table\\[1x1]>")
test(2297.07, format_list_item(data.table(a=1)[0,]), output = "<data.table\\[0x1]>")
test(2297.08, format_list_item(data.table(a=1)[,0]), output = "<data.table\\[0x0]>")
test(2297.09, format_list_item(data.table(a=1, b=2)[0,]), output = "<data.table\\[0x2]>")
test(2297.10, format_list_item(data.table(a=1, b=2)[,0]), output = "<data.table\\[0x0]>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test(2297.03, format_list_item(data.frame(a=1)[,0]), output = "<data.frame\\[1x0]>")
test(2297.04, format_list_item(data.frame(a=1, b=2)[0,,drop=FALSE]), output = "<data.frame\\[0x2]>")
test(2297.05, format_list_item(data.frame(a=1, b=2)[,0]), output = "<data.frame\\[1x0]>")
test(2297.06, format_list_item(data.table(a=1)), output = "<data.table\\[1x1]>")
test(2297.07, format_list_item(data.table(a=1)[0,]), output = "<data.table\\[0x1]>")
test(2297.08, format_list_item(data.table(a=1)[,0]), output = "<data.table\\[0x0]>")
test(2297.09, format_list_item(data.table(a=1, b=2)[0,]), output = "<data.table\\[0x2]>")
test(2297.10, format_list_item(data.table(a=1, b=2)[,0]), output = "<data.table\\[0x0]>")
test(2297.03, format_list_item(data.frame(a=1)[,0]), output = "<data.frame\\[1x0]>")
test(2297.04, format_list_item(data.frame(a=1, b=2)[0,,drop=FALSE]), output = "<data.frame\\[0x2]>")
test(2297.06, format_list_item(data.table(a=1)), output = "<data.table\\[1x1]>")
test(2297.07, format_list_item(data.table(a=numeric())), output = "<data.table\\[0x1]>")
test(2297.08, format_list_item(data.table(), output = "<data.table\\[0x0]>")
test(2297.09, format_list_item(data.table(a=numeric(), b=numeric())), output = "<data.table\\[0x2]>")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two [1x0] and [0x0] tests are redundant, right? removed in the suggested fix.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do a simple expansion of 0, 1, and >1 for number of columns, and 0, 1 rows, not knowing if you were aware of other corner-cases. (This is partly because I discovered during testing that data.frame(b=1)[,0] is 1x0 whereas data.table(b=1)[,0] is 0x0. Not sure if that's intentional.) I'm happy to remove them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's intentional -- #2422 :)

@MichaelChirico
Copy link
Member

Thanks LGTM besides the small tweak to tests & request for whether this can fix a 2nd bug.

@r2evans
Copy link
Author

r2evans commented Oct 28, 2024

This does not affect #5948, I think my comment there covers it. LMK if there's something else for this PR.

@r2evans
Copy link
Author

r2evans commented Oct 28, 2024

stby, I didn't QA the changes, I'll fix that fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

format_col and nested 1-column frames
2 participants