Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests fail if z in .GlobalEnv #3705

Closed
MichaelChirico opened this issue Jul 15, 2019 · 3 comments · Fixed by #5101
Closed

tests fail if z in .GlobalEnv #3705

MichaelChirico opened this issue Jul 15, 2019 · 3 comments · Fixed by #5101
Labels
Milestone

Comments

@MichaelChirico
Copy link
Member

MichaelChirico commented Jul 15, 2019

library(data.table)
z = 4
test.data.table()
Error in test.data.table() : 
  3 errors out of 9118 in 00:01:00 elapsed (00:02:40 cpu) on Thu Jul 11 08:46:42 2019. [endian==little, sizeof(long double)==16, sizeof(pointer)==8, TZ=Asia/Singapore, locale='LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C', l10n_info()='MBCS=TRUE; UTF-8=TRUE; Latin-1=FALSE', getDTthreads()='omp_get_num_procs()==8; R_DATATABLE_NUM_PROCS_PERCENT=="" (default 50); R_DATATABLE_NUM_THREADS==""; omp_get_thread_limit()==2147483647; omp_get_max_threads()==8; OMP_THREAD_LIMIT==""; OMP_NUM_THREADS==""; data.table is using 4 threads. This is set on startup, and by setDTthreads(). See ?setDTthreads.; RestoreAfterFork==true']. Search tests/tests.Rraw for test numbers: 1894.09, 1894.13, 1894.14
if (exists("z")) rm(z)
test(1894.09, DT[, sum(z)*..z], error="Variable 'z' is not found in calling scope. Looking in calling scope because this symbol was prefixed with .. in the j= parameter.")
z = 3L
test(1894.10, DT[, sum(z)*..z], 72L)
setnames(DT, "z", "..z")
test(1894.11, DT[, sum(y)*..z], INT(105,120,135))
rm(z)
test(1894.12, DT[, sum(y)*..z], INT(105,120,135))
setnames(DT, "..z", "z")
test(1894.13, DT[, sum(y)*..z], error="Variable 'z' is not found in calling scope")
..z = 4L
test(1894.14, DT[, sum(y)*..z], 60L)  # 'manual' prefix (we have recommended in the past) still works, for now.

There's if (exists('z')) rm(z) but that didn't work?

@2005m
Copy link
Contributor

2005m commented Jul 16, 2019

Would you accept this as an answer rm(z, envir = .GlobalEnv) ?

@MichaelChirico
Copy link
Member Author

no, because we don't want to alter user's environment. probably we need to make the environment where tests evaluate have as parent the data.table env (should be globalenv now)

@jangorecki
Copy link
Member

Or we can document that test.data.table should be called in fresh R session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants