-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
featurea feature request or enhancementa feature request or enhancement
Description
library(waldo)
dt <- as.POSIXct("2016-07-18 16:06:00", tz = "UTC")
compare(dt, dt + 5)
#> `old`: "2016-07-18 16:06:00"
#> `new`: "2016-07-18 16:06:05"
compare(1468857960, 1468857965)
#> `old`: 1468857960
#> `new`: 1468857965
(tol <- testthat::testthat_tolerance())
#> [1] 1.490116e-08
compare(dt, dt + 5, tolerance = tol)
#> ✓ No differences
compare(1468857960, 1468857965, tolerance = tol)
#> ✓ No differences
Created on 2022-03-12 by the reprex package (v2.0.1)
Compared with all.equal()
which has different behaviour for POSIXct:
library(waldo)
dt <- as.POSIXct("2016-07-18 16:06:00", tz = "UTC")
all.equal(dt, dt + 5)
#> [1] "Mean absolute difference: 5"
all.equal(1468857960, 1468857965)
#> [1] TRUE
Created on 2022-03-12 by the reprex package (v2.0.1)
I don't think the behaviour is correct in either case: the purpose of tolerance is to ignore minor differences that arise due to floating point error, not to ignore differences in integers that can be exactly represented in floating point.
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement