Closed MichaelChirico closed 11 months ago
A very ad hoc benchmark suggests we should skip the unique()
step, especially for readability:
x = sample(letters, 100, TRUE)
microbenchmark(times = 10000, all(unique(x) %in% letters), all(x %in% letters))
# Unit: microseconds
# expr min lq mean median uq max neval cld
# all(unique(x) %in% letters) 8.209 16.7145 25.84045 17.485 18.6015 47076.585 10000 b
# all(x %in% letters) 4.289 9.1590 12.61616 9.734 10.5710 3739.765 10000 a
Thanks!
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
Follow-up to #309.
I also saw these tests using
sort(unique())
, but I don't have enough context to know whether it's preferable to switch those toexpect_in()
as well:https://github.com/tidymodels/dials/blob/55763e0cbd49a16a3f5a532dc92b9069258d54e7/tests/testthat/test-aaa_values.R#L264-L271