all.equal no longer error when not a DT#4072
Conversation
| stopifnot(is.logical(trim.levels), is.logical(check.attributes), is.logical(ignore.col.order), is.logical(ignore.row.order), is.numeric(tolerance)) | ||
| if (!is.data.table(target) || !is.data.table(current)) stop("'target' and 'current' must both be data.tables") | ||
| stopifnot(is.logical(trim.levels), is.logical(check.attributes), is.logical(ignore.col.order), is.logical(ignore.row.order), is.numeric(tolerance), is.data.table(target)) | ||
| if (!is.data.table(current)) return(NextMethod()) |
There was a problem hiding this comment.
This will return all.equal(data.table(a=1), data.frame(a=1)) to TRUE right? Shouldn't that be FALSE with reason "current is not a data.table"?
There was a problem hiding this comment.
It will return
[1] "Attributes: < Names: 2 string mismatches >"
[2] "Attributes: < Length mismatch: comparison on first 2 components >"
[3] "Attributes: < Component 1: target is externalptr, current is character >"
[4] "Attributes: < Component 2: Modes: character, numeric >"
[5] "Attributes: < Component 2: Lengths: 2, 1 >"
[6] "Attributes: < Component 2: target is character, current is numeric >"
which is the same (just with some terms swapped) as the result of all.equal(data.frame(a=1), data.table(a=1))
Codecov Report
@@ Coverage Diff @@
## master #4072 +/- ##
==========================================
+ Coverage 99.54% 99.54% +<.01%
==========================================
Files 72 72
Lines 13918 13932 +14
==========================================
+ Hits 13854 13868 +14
Misses 64 64
Continue to review full report at Codecov.
|
|
@jangorecki raised an interesting point with regards to all.equal(data.frame(a=1), c(a=1), check.attributes = F)
#> [1] TRUE
all.equal(c(a=1), data.frame(a=1), check.attributes = F)
#> [1] "target is numeric, current is data.frame"Current data.table always errors when the second argument isn't a data.table (regardless of all.equal(data.table(a=1), c(a=1), check.attributes = F) # would ERROR before
#> [1] "target is data.table, current is numeric"
all.equal(c(a=1), data.table(a=1), check.attributes = F)
#> [1] "target is numeric, current is data.table"
all.equal(data.table(a=1), data.frame(a=1), check.attributes = F) # would ERROR before
#> [1] "target is data.table, current is data.frame"
all.equal(data.frame(a=1), data.table(a=1), check.attributes = F)
#> [1] TRUE |
|
Ok, new attempt to handle
|
|
Addressed most of your comments as suggested. I didn't change |
|
@d-sci thanks, I am getting your point. The thing is that if we supply a list into |
|
Ok, fair enough, switched over to |
|
We need documentation update for |
|
Thanks for fixing missing S3 registration. Unless you have something more in mind I think we can remove WIP label already. |
|
Yep, this is ready in my mind! Thanks for all your comments and suggestions. |
|
Thanks, @d-sci. I added you to DESCRIPTION in this PR and invited you to be project member. Please accept the invite displayed in your GitHub repositories page and then you can create branches in the main project so we can more easily commit to each other's branches. Welcome! |
Closes #4042
Fix so that
all.equal(DT, not_a_DT)returns the typical messages rather than error.I had to modify old tests 1613.59 and 1613.60, which were checking for this error.