There was an error while loading. Please reload this page.
1 parent 6688f1a commit 83d6bafCopy full SHA for 83d6baf
pkg/DESCRIPTION
@@ -23,7 +23,7 @@ Description: Implements an approximate string matching version of R's native
23
vectors representing generic sequences. This package is built for speed and
24
runs in parallel by using 'openMP'. An API for C or C++ is exposed as well.
25
Reference: MPJ van der Loo (2014) <doi:10.32614/RJ-2014-011>.
26
-Version: 0.9.13
+Version: 0.9.15
27
Depends:
28
R (>= 2.15.3)
29
URL: https://github.com/markvanderloo/stringdist
pkg/NEWS
@@ -1,4 +1,9 @@
1
-version 0.9.13
+version 0.9.15
2
+- Fixe issue with zero-length 'nthreads' argument in all exported functions
3
+ with this parameter. (Thanks to Brian Ripley for the notification and pointer
4
+ to the problem)
5
+
6
+version 0.9.14
7
- Fixed issue with zero-length strings in 'qgrams' (Thanks to Brian Ripley
8
for the notification and pointer to the origin of the problem)
9
pkg/R/afind.R
@@ -87,6 +87,8 @@ afind <- function(x, pattern, window=NULL
87
, is.logical(value) && !is.na(value)
88
, ifelse(method %in% c('osa','dl'), length(weight) >= 4, TRUE)
89
, ifelse(method %in% c('lv','jw') , length(weight) >= 3, TRUE)
90
+ , length(nthread) == 1
91
+ , is.numeric(nthread)
92
, nthread > 0
93
)
94
pkg/R/amatch.R
@@ -104,6 +104,8 @@ amatch <- function(x, table, nomatch=NA_integer_, matchNA=TRUE
104
, is.logical(useBytes)
105
106
107
108
109
110
111
if (method == 'jw') weight <- weight[c(2,1,3)]
@@ -212,6 +214,8 @@ seq_amatch <- function(x, table, nomatch=NA_integer_, matchNA=TRUE
212
214
, matchNA %in% c(TRUE,FALSE)
213
215
216
217
218
219
220
221
pkg/R/seqdist.R
@@ -69,6 +69,8 @@ seq_dist <- function(a, b
69
, p >= 0
70
71
72
73
74
75
76
pkg/R/stringdist.R
@@ -63,14 +63,14 @@
63
#' }
64
#' Or use \code{citation('stringdist')} to get a bibtex item.
65
#'
66
-#' @aliases stringdist-package
+#' @name stringdist-package
67
#' @docType package
68
#' @useDynLib stringdist, .registration=TRUE
#' @importFrom parallel detectCores
-{}
+"_PACKAGE"
listwarning <- function(x,y){
sprintf("
@@ -156,6 +156,8 @@ stringdist <- function(a, b
156
157
158
159
160
161
162
163
@@ -224,6 +226,8 @@ stringdistmatrix <- function(a, b
224
226
225
227
228
229
230
231
232
233
@@ -342,7 +346,7 @@ lower_tri <- function(a
342
346
if (is.na(method)){
343
347
stop(sprintf("method '%s' is not defined",method))
344
348
}
345
-
349
350
x <- .Call("R_lower_tri", a, methnr
351
, as.double(weight), as.double(p), as.double(bt)
352
, as.integer(q), as.integer(useBytes), as.integer(nthread)
pkg/inst/tinytest/test_afind.R
@@ -1,5 +1,16 @@
options(sd_num_thread=1L)
+# tests against cases that used to segfault when we did not check
+# NULL cases.
+expect_error(afind("a","b",nthread=1:4))
+expect_error(afind("a","b",nthread="foo"))
+expect_error(afind("a","b",nthread=integer(0)))
+expect_error(afind("a","b",nthread=NULL))
10
11
12
13
14
texts = c("When I grow up, I want to be"
15
, "one of the harversters of the sea"
16
, "I think before my days are gone"
pkg/inst/tinytest/test_amatch.R
@@ -1,5 +1,12 @@
options(sd_num_thread=2)
## amatch: Optimal String Alignment
+expect_error(amatch("a","b",nthread=1:4))
+expect_error(amatch("a","b",nthread="foo"))
+expect_error(amatch("a","b",nthread=integer(0)))
+expect_error(amatch("a","b",nthread=NULL))
## simple test and multiple edge cases
expect_equal(amatch("aa",c("ba","bb"), method="osa",maxDist=1L), 1L)
@@ -187,5 +194,9 @@ options(sd_num_thread=2)
187
194
expect_false(seq_ain(x,table))
188
195
189
196
197
+expect_error(seq_amatch(x,table,nthread=1:4))
198
+expect_error(seq_amatch(x,table,nthread="foo"))
199
+expect_error(seq_amatch(x,table,nthread=integer(0)))
200
+expect_error(seq_amatch(x,table,nthread=NULL))
190
201
191
202
pkg/inst/tinytest/test_seq_dist.R
@@ -1,5 +1,11 @@
## seq_dist
+expect_error(seq_dist(a=list(c(1L,2L,3L)), b=list(c(2L,1L,3L)),nthread=1:4))
+expect_error(seq_dist(a=list(c(1L,2L,3L)), b=list(c(2L,1L,3L)),nthread="foo"))
+expect_error(seq_dist(a=list(c(1L,2L,3L)), b=list(c(2L,1L,3L)),nthread=integer(0)))
+expect_error(seq_dist(a=list(c(1L,2L,3L)), b=list(c(2L,1L,3L)),nthread=NULL))
# A simple test to see that everything is passed on to the correct
# algorithm
pkg/inst/tinytest/test_stringdist.R
@@ -8,11 +8,19 @@ options(sd_num_thread=2)
expect_error(stringdist("a","b",weight=c(-1,1,1,1)))
expect_error(stringdist("a","b",weight=c(1,0,1,1)))
expect_error(stringdist("a","b",weight=c(1,1,1,4)))
+ expect_error(stringdist("a","b",nthread=1:4))
+ expect_error(stringdist("a","b",nthread="foo"))
+ expect_error(stringdist("a","b",nthread=integer(0)))
+ expect_error(stringdist("a","b",nthread=NULL))
expect_warning(stringdist(letters[1:3],letters[1:2]))
expect_warning(stringdist(list('a'),'a'))
17
expect_warning(stringdist('a',list('a')))
18
expect_warning(stringdistmatrix(list('a')))
19
expect_warning(stringdistmatrix(list('a'),list('b')))
20
+ expect_error(stringdistmatrix("a","b",nthread=1:4))
21
+ expect_error(stringdistmatrit("a","b",nthread="foo"))
22
+ expect_error(stringdistmatrit("a","b",nthread=integer(0)))
+ expect_error(stringdistmatrit("a","b",nthread=NULL))
0 commit comments