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

Register the full IDate S3 class for S4 dispatch #6844

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

aitap
Copy link
Contributor

@aitap aitap commented Feb 28, 2025

As recommended by ?setOldClass, register c("IDate", "Date"), not just "IDate". The unit test doesn't involve lubridate, but also tested with lubridate manually:

> as.IDate(Sys.Date()) - days(1)
[1] "2025-02-27"
> as.IDate("2020-01-30") %m+% months(1)
[1] "2020-02-29"

Fixes: #6839

As recommended by ?setOldClass, register c("IDate", "Date"), not just
"IDate".
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.60%. Comparing base (3bb4e16) to head (f984218).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6844   +/-   ##
=======================================
  Coverage   98.60%   98.60%           
=======================================
  Files          79       79           
  Lines       14661    14661           
=======================================
  Hits        14457    14457           
  Misses        204      204           

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

@@ -16,7 +16,7 @@ methods::setAs("data.table", "data.frame", function(from) {
as.data.frame(from)
})

methods::setOldClass("IDate")
methods::setOldClass(c("IDate", "Date"))
Copy link
Member

Choose a reason for hiding this comment

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

up on L6 I see multiple calls for a similar case on the data.table/data.frame class. should we remove the one-class call there, or is there benefit from having both calls here too?

Copy link
Member

Choose a reason for hiding this comment

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

based on the description of the test= argument I guess we should remove L6

Copy link

github-actions bot commented Feb 28, 2025

Comparison Plot

Generated via commit f984218

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 4 minutes and 35 seconds
Installing different package versions 8 minutes and 10 seconds
Running and plotting the test cases 2 minutes and 21 seconds

@MichaelChirico
Copy link
Member

looks great! missing NEWS

Instead of defining and exporting an S4 class for data.frame (which we
don't own), keep setOldClass(c("data.table", "data.frame")) (which we
do).
@aitap
Copy link
Contributor Author

aitap commented Feb 28, 2025

Hopefully no reverse dependency actually imported the data.frame S4 class from us.

@MichaelChirico MichaelChirico merged commit b0a17dd into master Feb 28, 2025
10 of 11 checks passed
@MichaelChirico MichaelChirico deleted the S4-IDate branch February 28, 2025 13:46
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.

Adding Months to IDate Generates Incompatible classes with Period
2 participants