Warning when GForce functions used but also detected in calling scope
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
First reproduce the provided data.table example with GForce and verbose=TRUE, then trace the GForce rewrite of mean calls and how definitions in the calling scope are handled. The issue is complete only after the warning behavior is agreed and covered by a regression test.
Written by the indexing model from the issue text.
Description
When GForce is enabled, simple calls using GForce functions are replaced with g-versions. If a function is defined in calling scope, I'm not sure if it is better to produce a warning since dynamic scoping does not work here as expected by unfamiliar users?
library(data.table)
data <- as.data.table(mtcars)
data[, .(disp = mean(disp)), keyby = vs]
mean <- sum
mean2 <- mean
data[, .(disp = mean(disp)), keyby = vs]
data[, .(disp = mean(disp), disp2 = mean2(disp)), keyby = vs, verbose = TRUE]
> library(data.table)
> data <- as.data.table(mtcars)
> data[, .(disp = mean(disp)), keyby = vs]
vs disp
1: 0 307.1500
2: 1 132.4571
> mean <- sum
> mean2 <- mean
> data[, .(disp = mean(disp)), keyby = vs]
vs disp
1: 0 307.1500
2: 1 132.4571
> data[, .(disp = mean(disp), disp2 = mean2(disp)), keyby = vs, verbose = TRUE]
Detected that j uses these columns: disp
Finding groups using forderv ... 0.005sec
Finding group sizes from the positions (can be avoided to save RAM) ... 0.000sec
lapply optimization is on, j unchanged as 'list(mean(disp), mean2(disp))'
GForce is on, left j unchanged
Old mean optimization changed j from 'list(mean(disp), mean2(disp))' to 'list(.External(Cfastmean, disp, FALSE), mean2(disp))'
Making each group and running j (GForce FALSE) ...
collecting discontiguous groups took 0.000s for 2 groups
eval(j) took 0.000s for 2 calls
0.000sec
vs disp disp2
1: 0 307.1500 5528.7
2: 1 132.4571 1854.4
- 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 ·