Fix forder-order equivalence test for atypical collate locales - #7837
Fix forder-order equivalence test for atypical collate locales#7837MichaelChirico wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7837 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 88 88
Lines 17292 17292
=======================================
Hits 17122 17122
Misses 170 170 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
39d4309 to
cf55605
Compare
cf55605 to
995819c
Compare
9548bbd to
4c6d0a2
Compare
|
Generated via commit 096e827 Download link for the artifact containing the test results: ↓ atime-results.zip
|
4c6d0a2 to
01b4d1f
Compare
01b4d1f to
0b5068c
Compare
|
The approach with sort(c('ib', 'ya'))
# [1] "ya" "ib"
sort(c('i', 'y'))
# [1] "i" "y"i.e. there's a mix of right-to-left and left-to-right logic to determine sort order. Now, I am trying |
9eaee4d to
47d54bc
Compare
d7cf097 to
5b56eb4
Compare
16f7a09 to
417989b
Compare
096e827 to
e40fca4
Compare
|
Tried this: # collations.mk
LOCALES = $(shell locale -a | sed 's/[.].*//' | sort -u | grep -v -e '^C$' -e '^POSIX$')
OUTPUTS = $(foreach locale,$(LOCALES),LC_COLLATE_$(locale).out)
R = R
all: $(OUTPUTS)
LC_COLLATE_%.out:
LC_COLLATE=$* R_LIBS_USER=data.table.Rcheck $(R)script -e 'library(data.table); test.data.table()' >$@ 2>&1 || truesudo apt install locales-all
R CMD INSTALL -l data.table.Rcheck $whatever
OMP_THREAD_LIMIT=1 make -f collations.mk -j`nproc`With 1.18.4 I get: (probably should've tried with and with The sets of failed tests are quite interesting. Here are their sizes and the sizes of their set difference:
In So why do tests Sys.setlocale('LC_COLLATE', 'hu_HU')
s <- c("pzvz", "pzsz")
order(s)
# [1] 1 2
data.table:::forderv(s)
# [1] 2 1
c('pz', 'vz', 'sz', 'zs') %in% c_sortable_pairs
# [1] TRUE TRUE TRUE FALSEWhile the strings have been constructed from |
|
Excellent. I wonder how many locales it's worth including in the matrix for other.Rraw. I could add
I think you mean to use (of course, I do find the exercise a bit "fun" so am happy to tilt at the windmill 😃) |
|
If you would like to save some CI time, you could merge
Exactly!
What are the alternatives? Generating "words" using some sort of Markov algorithm that always produces good bigrams? Wrapping all sorting tests in |
e40fca4 to
8f7db24
Compare

Running
test.data.table()in anLC_ALL=lv_LV.utf8session can error like:It's all down to
xtfrm(letters)not being able to support C-collated sorting, so using it in a locale wheresort(letters)differs from ASCII causes issues.In 268c7d6, I tried just using
order(method='radix')as much as possible, but tests1252.*explicitly guard against doing that given it's kinda pointless to test our implementation against... whatever drift has happened between our implementations since our algorithm was first merged into {base}.So here, I take the approach to avoid using all of
lettersin such cases, instead focusing on the C-sortable subset ofletters(see comment below for more nuance on this).According to Gemini, the three most adversarial locales for this exercise are
lv_LV,lt_LT, andaz_AZ, each of which leave only 11 letters in the chosen algorithm. I confirm that result, but it doesn't rule out there being some other more adversarial locale. Gemini also mentionshaw_USandsm_WScould leave 9, but it seems like in practice those locales just use normal ASCII sorting.