From 0d948ca206bf9f05832134ac8bf77475c3a09b81 Mon Sep 17 00:00:00 2001 From: 2005m Date: Mon, 26 Feb 2024 20:21:53 +0000 Subject: [PATCH] Do not set kit.nThread if already set --- DESCRIPTION | 4 ++-- MD5 | 8 ++++---- R/call.R | 9 +++++++-- inst/NEWS.Rd | 8 ++++++++ tests/test_kit.Rout.save | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 22d0633..662b3b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: kit Type: Package Title: Data Manipulation Functions Implemented in C -Version: 0.0.15 -Date: 2023-10-01 +Version: 0.0.16 +Date: 2024-03-01 Authors@R: c(person("Morgan", "Jacob", role = c("aut", "cre", "cph"), email = "morgan.emailbox@gmail.com"), person("Sebastian", "Krantz", role = "ctb")) Author: Morgan Jacob [aut, cre, cph], Sebastian Krantz [ctb] diff --git a/MD5 b/MD5 index a5a7770..6b41656 100644 --- a/MD5 +++ b/MD5 @@ -1,7 +1,7 @@ 6071edd604dbeb75308cfbedc7790398 *cleanup d2761d00effd7b096a5bea21bc38742e *configure -f26c0015784f555768de9fd4dbd52191 *DESCRIPTION -771ad7a0ba9d6856cecdc324826a8d09 *inst/NEWS.Rd +63e50ec034f2ae68dc2cac70b943bc5a *DESCRIPTION +06bd5048f6b3775957ec019ae7637a9a *inst/NEWS.Rd a87b0f223435ed35607e8514562b8bfe *LICENSE 2ddfa8d8739668eedda260e6ddc935d4 *man/charToFact.Rd 8f19a2c9feb2f352580fd4892650f285 *man/count.Rd @@ -16,7 +16,7 @@ a137f7855b41b074e2babaf8a1562551 *man/shareData.Rd 54f91d543a10f8c9aef7082da2b86de7 *man/topn.Rd a7f31cee15b9624dab8f4d13d3c66bad *man/vswitch.Rd c797ca387dccc02751cfe85108fb0159 *NAMESPACE -24ce4885aedbca5309ed2ee126324aa2 *R/call.R +a19c6faffef01603c022f6291d46bf21 *R/call.R 2d6c06dfc570d456af125c160cf150d7 *README.md b68e68fed386fa0ce15ec6ec2e1f91a5 *src/dup.c 17b8c354cd84b5d85ab5a62ef2bfab4e *src/dupLen.c @@ -34,4 +34,4 @@ bafdafd654269acd054525571dbe1b44 *src/share.c b9daa73f97bb19027aaa5bfdc00c4087 *src/utils.c 3476a1e2381bb86f68a72844ee61bc7b *src/vswitch.c 3f8dc4ecf4ad26fb959a2291ab167630 *tests/test_kit.R -de61e8bccc19816a0e07c9153a33473b *tests/test_kit.Rout.save +f0b7442cb1c46dd6a5f7344199bc1ac4 *tests/test_kit.Rout.save diff --git a/R/call.R b/R/call.R index 2135ca8..9b171f7 100644 --- a/R/call.R +++ b/R/call.R @@ -27,10 +27,15 @@ 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.15 (OPENMP ",if(.Call(CompEnabledR)) "enabled" else "disabled"," using 1 thread)")) -.onLoad = function(libname, pkgname) options("kit.nThread"=1L) #nocov +.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) + } +} + pcount = function(..., value) { if(is.na(value[1])) { .Call(CpcountNAR, if (...length() == 1L && is.list(..1)) ..1 else list(...)) diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 5ccbe29..b3da689 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -4,6 +4,14 @@ \newcommand{\CRANpkg}{\href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{version 0.0.16 (2024-03-01)}{ + \subsection{Notes}{ + \itemize{ + \item Check if \code{"kit.nThread"} is defined before setting it to \code{1L} + } + } +} + \section{version 0.0.15 (2023-10-01)}{ \subsection{Notes}{ \itemize{ diff --git a/tests/test_kit.Rout.save b/tests/test_kit.Rout.save index 2040208..cf06fff 100644 --- a/tests/test_kit.Rout.save +++ b/tests/test_kit.Rout.save @@ -53,7 +53,7 @@ Type 'q()' to quit R. + } > > library(kit); unloadNamespace("kit") -Attaching kit 0.0.15 (OPENMP enabled using 1 thread) +Attaching kit 0.0.16 (OPENMP enabled using 1 thread) > > topn = kit::topn > setlevels = kit::setlevels