-
Notifications
You must be signed in to change notification settings - Fork 48
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 update sha1.default()
to work with any class
#226
Conversation
…e now duplicate classes
# Conflicts: # ChangeLog
Reverse-dependency checks came and went. (The machine I run these on is not often used for |
I reverted those removals. |
Appreciate the reversal. I keep pondering this, and the actual hard error in there with I updated my branch, borrowed you additional tests and am running it in reverse dependency checks now. |
Is there a scenario where using Since Another example that would be fixed with a default method that provides a result is digest::sha1(logLik(lmx <- lm(x ~ 1, data = data.frame(x = 1:5))))
#> Error: sha1() has no method for the 'logLik' class Created on 2025-01-03 with reprex v2.1.1 My concern is that this becomes whack-a-mole when going through all the required and recommended libraries that are unlikely to provide their own |
I think I prefer to follow the explicit S3 dispatch where we already use it that is in > library(digest)
> digest(logLik(lmx <- lm(x ~ 1, data = data.frame(x = 1:5))), algo="sha1")
[1] "e2f78853387414a8b41d7793383ab062aa27241e"
> meaning that if you need it you could (if push came to shove) define a local sha1 override for it. The package is 20+ years old, the S3-based sha1 support is nine years old. I think on balance I rather stay with the design that worked than to (more radically than we need to) alter it now. The aim is to have something reliable for all/most use cases. |
That said, whackamole is a risk, and Maybe fusing our two competing PR and turning the stop() into a warning() (or message()) and proceeding is a good middle ground. |
> library(digest)
> sha1(logLik(lmx <- lm(x ~ 1, data = data.frame(x = 1:5))))
sha1() has no method for the 'logLik' class, so using fallback.
[1] "7d7ba7a23dbe3ccc8342811bf6dce184501dc12a"
> suppressMessages(sha1(logLik(lmx <- lm(x ~ 1, data = data.frame(x = 1:5)))))
[1] "7d7ba7a23dbe3ccc8342811bf6dce184501dc12a"
> Committed in 7af4aa7. Thoughts? |
…fix-224; Update man to include `sha1.<-()` method # Conflicts: # R/sha1.R # inst/tinytest/test_sha1.R
I like that compromise. I've merged the branches. |
expect_message( | ||
sha1(logLik(lmx <- lm(x ~ 1, data = data.frame(x = 1:5)))), | ||
pattern = "sha1\\(\\) has no method for the 'logLik' class, so using fallback\\." | ||
) |
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.
I hate hate hate hate this editor default of using four lines for what can be / should be two. Sadly I am in the minority on this.
No need to change though.
@@ -41,7 +41,7 @@ Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd | |||
person("Michael", "Chirico", role="ctb", comment = c(ORCID = "0000-0003-0787-087X")), | |||
person("Kevin", "Ushey", role="ctb", comment = c(ORCID = "0000-0003-2880-7407")), | |||
person("Carl", "Pearson", role="ctb", comment = c(ORCID = "0000-0003-0701-7860"))) | |||
Version: 0.6.37.1 | |||
Version: 0.6.37.1.1 |
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.
I tend to try to keep these things out of PRs but I can clean this up post-merge.
No need to change.
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.
Nice. Some procrastination and noodling over alternatives made this better.
* Add update `sha1.default()` to work with any class and remove what are now duplicate classes * Update docs * Clarify new instructions for using `sha1()` * Clarify description of sha1() changes * Expanding sha1 support as discussed in #224 * Add more sha1 tests (borrowed from @billdenney) * Add ChangeLog * Revert removal of sha1() S3 methods * Add fallback default methods (following discussion in #224) * test sha1.default() --------- Co-authored-by: Dirk Eddelbuettel <[email protected]>
sha1.default()
to work with any class and remove what are now duplicate classessha1.default()
to work with any class
Should have altered the PR title (but then did so in an Thanks for your attention to detail and patience on this. |
Fix #224