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

all.equal.data.table uses relative difference on POSIXct column (should be absolute) #4543

Closed
MichaelChirico opened this issue Jun 13, 2020 · 3 comments · Fixed by #4546
Closed

Comments

@MichaelChirico
Copy link
Member

DT1 = data.table(t = .POSIXct(1590973200, tz='UTC'))
DT2 = data.table(t = .POSIXct(1590974413, tz='UTC'))
all.equal(DT1, DT2)
# [1] "Column 't': Mean relative difference: 7.624264e-07"

vs base:

DT1 = data.frame(t = .POSIXct(1590973200, tz='UTC'))
DT2 = data.frame(t = .POSIXct(1590974413, tz='UTC'))
all.equal(DT1, DT2)
# [1] "Component “t”: Mean absolute difference: 1213"

For POSIXct column, relative difference is meaningless since it's somewhat arbitrarily relative to the 0 time of UTC epoch.

@jangorecki
Copy link
Member

I would expect it to fall back to a base R all.equal in such a simple comparison

@MichaelChirico
Copy link
Member Author

found the culprit

cols.r = all.equal(unclass(x), unclass(y), tolerance = tolerance, 
          ..., check.attributes = check.attributes)

@MichaelChirico
Copy link
Member Author

Introduced by @mattdowle here:

23bd166

Seems the goal was to break from all.equal.data.frame which considers 1L different from structure(1L, class='foo') even when check.attributes=FALSE.

I agree with that, but I think we should still dispatch to all.equal methods if they're there...

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

Successfully merging a pull request may close this issue.

2 participants