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

Merged
merged 9 commits into from
Dec 3, 2024

Conversation

r2evans
Copy link
Contributor

@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.61%. Comparing base (f05893e) to head (ab550ed).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6593   +/-   ##
=======================================
  Coverage   98.61%   98.61%           
=======================================
  Files          79       79           
  Lines       14534    14535    +1     
=======================================
+ Hits        14333    14334    +1     
  Misses        201      201           

☔ 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
Contributor 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
Contributor 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
Contributor Author

r2evans commented Oct 28, 2024

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

@MichaelChirico MichaelChirico added this to the 1.17.0 milestone Dec 3, 2024
@MichaelChirico
Copy link
Member

Thanks @r2evans! I've sent you an invite to join as a project member. Most notably, that will let you create branches directly on this repo going forward which simplifies collaboration a bit. I'm also adding you as a contributor to the DESCRIPTION

@MichaelChirico MichaelChirico merged commit d4244e8 into Rdatatable:master Dec 3, 2024
8 of 9 checks passed
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