Optionally ignore indices in all.equal
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start at the all.equal.data.table entry point and trace how differences in data.table indices are detected and reported. Check how the existing check.attributes option is handled, then add a narrowly scoped option for ignoring indices and verify that column-name differences remain detectable.
Written by the indexing model from the issue text.
Description
Different tables that contain the same data and also behave pretty much the same will not be all.equal() when they have different indices. Indices can sometimes appear automatically depending on what operations are performed with tables, so I think it can often be reasonable to ignore differences in indices.
x <- data.table(a = 1)
y <- data.table(a = 1)
all.equal(x, y)
#> [1] TRUE
x[a == 1]
#> a
#> <num>
#> 1: 1
all.equal(x, y) # would be nice to have a way to get 'TRUE' here
#> [1] "Datasets have different indices. 'target': [a]. 'current': has no index."
While one can set check.attributes = FALSE, this also ignores other more important things like column names
all.equal(x, y, check.attributes = FALSE)
#> [1] TRUE
all.equal(x, data.table(b = 1), check.attributes = FALSE) # this is too lenient
#> [1] TRUE
The user can set / unset indices in tables before checking with all.equals(), but that gets unnecessarily complicated when the tables are buried inside larger objects.
It would therefore be useful to have an option check.indices or ignore.indices that makes all.equal() ignore data.table indices.
My use case is that I use all.equal.data.table a lot in unit tests, where I verify that objects created in different ways still contain the same data. Tables may have different indices depending on how objects are created, but because these indices make no relevant difference in object behaviour I would like to ignore them.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·