Skip to content

Commit

Permalink
Fix OnAttach
Browse files Browse the repository at this point in the history
  • Loading branch information
2005m committed Feb 26, 2024
1 parent 0d948ca commit 7814227
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions MD5
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ a137f7855b41b074e2babaf8a1562551 *man/shareData.Rd
54f91d543a10f8c9aef7082da2b86de7 *man/topn.Rd
a7f31cee15b9624dab8f4d13d3c66bad *man/vswitch.Rd
c797ca387dccc02751cfe85108fb0159 *NAMESPACE
a19c6faffef01603c022f6291d46bf21 *R/call.R
82928f8fb69a52a14469d8e1f225ba3d *R/call.R
2d6c06dfc570d456af125c160cf150d7 *README.md
b68e68fed386fa0ce15ec6ec2e1f91a5 *src/dup.c
17b8c354cd84b5d85ab5a62ef2bfab4e *src/dupLen.c
Expand All @@ -33,5 +33,5 @@ bafdafd654269acd054525571dbe1b44 *src/share.c
53711690f6c15f3f36edb4b9360043a4 *src/topn.c
b9daa73f97bb19027aaa5bfdc00c4087 *src/utils.c
3476a1e2381bb86f68a72844ee61bc7b *src/vswitch.c
3f8dc4ecf4ad26fb959a2291ab167630 *tests/test_kit.R
f0b7442cb1c46dd6a5f7344199bc1ac4 *tests/test_kit.Rout.save
b28a565eeb0b8e5f7e2969be373d32f4 *tests/test_kit.R
84aecd97807e8ec130ee14422da21389 *tests/test_kit.Rout.save
18 changes: 12 additions & 6 deletions R/call.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ topn = function(vec, n=6L, decreasing=TRUE, hasna=TRUE,index=TRUE) if(ind
uniqLen = function(x) .Call(CdupLenR, x)
vswitch = function(x, values, outputs, default=NULL, nThread=getOption("kit.nThread"), checkEnc = TRUE) .Call(CvswitchR, x, values, outputs, default, nThread, checkEnc)

.onAttach = function(libname, pkgname) packageStartupMessage(paste0("Attaching kit 0.0.16 (OPENMP ",if(.Call(CompEnabledR)) "enabled" else "disabled"," using 1 thread)"))
.onUnload = function(libpath) library.dynam.unload("kit", libpath) #nocov

.onLoad = function(libname, pkgname) {
if (!("kit.nThread" %in% names(options()))) {
options("kit.nThread"=1L)
}
}
.onAttach = function(libname, pkgname) { #nocov
omp = if(.Call(CompEnabledR)) "enabled" else "disabled" #nocov
nth = getOption("kit.nThread") #nocov
thd = if (nth > 1L) " threads)" else " thread)" #nocov
packageStartupMessage(paste0("Attaching kit 0.0.16 (OPENMP ",omp," using ",nth,thd)) #nocov
} #nocov

.onLoad = function(libname, pkgname) { #nocov
if (!("kit.nThread" %in% names(options()))) { #nocov
options("kit.nThread"=1L) #nocov
} #nocov
} #nocov

pcount = function(..., value) {
if(is.na(value[1])) {
Expand Down
1 change: 0 additions & 1 deletion tests/test_kit.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ check = function(test,x,y,error=NULL,warning=NULL) {
return(invisible(FALSE))
}

library(kit); unloadNamespace("kit")

topn = kit::topn
setlevels = kit::setlevels
Expand Down
2 changes: 0 additions & 2 deletions tests/test_kit.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ Type 'q()' to quit R.
+ return(invisible(FALSE))
+ }
>
> library(kit); unloadNamespace("kit")
Attaching kit 0.0.16 (OPENMP enabled using 1 thread)
>
> topn = kit::topn
> setlevels = kit::setlevels
Expand Down

0 comments on commit 7814227

Please sign in to comment.