Adds an expectation function that can be used with the testthat package. Compares two tensors and determines whether they are equal or not.
Arguments
- object, expected
Computation and value to compare it to.
Both arguments supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.
- ...
Arguments passed on to
waldo::compare
tolerance
If non-
NULL
, used as threshold for ignoring small floating point difference when comparing numeric vectors. Using any non-NULL
value will cause integer and double vectors to be compared based on their values, not their types, and will ignore the difference betweenNaN
andNA_real_
.It uses the same algorithm as
all.equal()
, i.e., first we generatex_diff
andy_diff
by subsettingx
andy
to look only locations with differences. Then we check thatmean(abs(x_diff - y_diff)) / mean(abs(y_diff))
(or justmean(abs(x_diff - y_diff))
ify_diff
is small) is less thantolerance
.max_diffs
Control the maximum number of differences shown. The default shows 10 differences when run interactively and all differences when run in CI. Set
max_diffs = Inf
to see all differences.ignore_srcref
Ignore differences in function
srcref
s?TRUE
by default since thesrcref
does not change the behaviour of a function, only its printed representation.ignore_encoding
Ignore string encoding?
TRUE
by default, because this is R's default behaviour. UseFALSE
when specifically concerned with the encoding, not just the value of the string.