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::comparetoleranceIf non-
NULL, used as threshold for ignoring small floating point difference when comparing numeric vectors. Using any non-NULLvalue will cause integer and double vectors to be compared based on their values, not their types, and will ignore the difference betweenNaNandNA_real_.It uses the same algorithm as
all.equal(), i.e., first we generatex_diffandy_diffby subsettingxandyto 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_diffis small) is less thantolerance.max_diffsControl the maximum number of differences shown. The default shows 10 differences when run interactively and all differences when run in CI. Set
max_diffs = Infto see all differences.ignore_srcrefIgnore differences in function
srcrefs?TRUEby default since thesrcrefdoes not change the behaviour of a function, only its printed representation.ignore_encodingIgnore string encoding?
TRUEby default, because this is R's default behaviour. UseFALSEwhen specifically concerned with the encoding, not just the value of the string.