From f9107668f25da37df14183b336278d04d6d52b95 Mon Sep 17 00:00:00 2001 From: Patrick Reidy Date: Wed, 11 Jul 2018 15:38:23 -0500 Subject: [PATCH] Added dependencey on stringi --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/textgRid.R | 1 + tests/testthat/test-IntervalTier.R | 18 +++++++++--------- tests/testthat/test-writeTextGrid.R | 16 ++++++++-------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 66624cd..8b74382 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ Description: The software application Praat can be used to annotate Depends: R (>= 3.2.3) Imports: - methods, readr + methods, readr, stringi Suggests: testthat License: GPL-3 diff --git a/NAMESPACE b/NAMESPACE index e369f16..48d334c 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,6 +25,7 @@ exportClasses(Tier) exportMethods(TextGrid) import(methods) import(readr) +import(stringi) importFrom(methods,new) importFrom(methods,setClass) importFrom(methods,setGeneric) diff --git a/R/textgRid.R b/R/textgRid.R index 6785165..3194198 100755 --- a/R/textgRid.R +++ b/R/textgRid.R @@ -11,6 +11,7 @@ #' #' @import methods #' @import readr +#' @import stringi #' #' @section S4 classes: #' \code{\link[=Tier-class]{Tier}}, diff --git a/tests/testthat/test-IntervalTier.R b/tests/testthat/test-IntervalTier.R index f293421..00b0b37 100755 --- a/tests/testthat/test-IntervalTier.R +++ b/tests/testthat/test-IntervalTier.R @@ -72,7 +72,7 @@ test_that('findIntervals() can find intervals with non-empty labels', { # 6.0 -- 9.0 = word.2 # 9.0 -- 10.0 = .words_tier <- .textgrid$Words - expect_equal(object = findIntervals(tier = .words_tier, pattern = '.+', + expect_equal(object = findIntervals(tier = .words_tier, pattern = '.+', stringsAsFactors = FALSE), expected = data.frame( Index = c(2, 4), @@ -90,7 +90,7 @@ test_that('findIntervals() can find intervals with non-empty labels', { Label = c('word.1', 'word.2'), stringsAsFactors = TRUE )) - expect_equal(object = findIntervals(tier = .words_tier, pattern = '1', + expect_equal(object = findIntervals(tier = .words_tier, pattern = '1', stringsAsFactors = FALSE), expected = data.frame( Index = c(2), @@ -99,7 +99,7 @@ test_that('findIntervals() can find intervals with non-empty labels', { Label = c('word.1'), stringsAsFactors = FALSE )) - expect_equal(object = findIntervals(tier = .words_tier, pattern = '1', + expect_equal(object = findIntervals(tier = .words_tier, pattern = '1', stringsAsFactors = TRUE), expected = data.frame( Index = c(2), @@ -108,8 +108,8 @@ test_that('findIntervals() can find intervals with non-empty labels', { Label = c('word.1'), stringsAsFactors = TRUE )) - expect_equal(object = findIntervals(tier = .words_tier, pattern = '.+', - from = 6.5, to = 7.5, + expect_equal(object = findIntervals(tier = .words_tier, pattern = '.+', + from = 6.5, to = 7.5, stringsAsFactors = FALSE), expected = data.frame( Index = c(4), @@ -119,7 +119,7 @@ test_that('findIntervals() can find intervals with non-empty labels', { stringsAsFactors = FALSE )) expect_equal(object = findIntervals(tier = .words_tier, pattern = '.+', - from = 6.5, to = 7.5, + from = 6.5, to = 7.5, stringsAsFactors = TRUE), expected = data.frame( Index = c(4), @@ -167,7 +167,7 @@ test_that('findIntervals() can find intervals with non-empty labels', { Label = paste('phone', c('1a', '1b', '1c', '2a', '2b', '2c', '2d'), sep = '.'), stringsAsFactors = FALSE )) - expect_equal(object = findIntervals(tier = .phones_tier, pattern = '.+', + expect_equal(object = findIntervals(tier = .phones_tier, pattern = '.+', stringsAsFactors = TRUE), expected = data.frame( Index = c(2, 3, 4, 6, 7, 8, 9), @@ -321,13 +321,13 @@ test_that('as.data.frame.IntervalTier() correctly represents interval label', { ) expect_equal( object = as.data.frame(.textgrid$Phones, stringsAsFactors = FALSE)$Label, - expected = c('', paste('phone', c('1a', '1b', '1c'), sep = '.'), '', + expected = c('', paste('phone', c('1a', '1b', '1c'), sep = '.'), '', paste('phone', c('2a', '2b', '2c', '2d'), sep = '.'), '') ) expect_equal( object = as.data.frame(.textgrid$Phones, stringsAsFactors = TRUE)$Label, expected = as.factor( - c('', paste('phone', c('1a', '1b', '1c'), sep = '.'), '', + c('', paste('phone', c('1a', '1b', '1c'), sep = '.'), '', paste('phone', c('2a', '2b', '2c', '2d'), sep = '.'), '') ) ) diff --git a/tests/testthat/test-writeTextGrid.R b/tests/testthat/test-writeTextGrid.R index a3da7d2..9b08741 100644 --- a/tests/testthat/test-writeTextGrid.R +++ b/tests/testthat/test-writeTextGrid.R @@ -6,7 +6,7 @@ test_that('writeTextGrid() returns valid TextGrid character vector', { .fin <- '../test.TextGrid' .textgrid <- TextGrid(.fin) .textgrid_lines <- writeTextGrid(.textgrid) - + expect_s4_class( object = TextGrid(.textgrid_lines), class = 'TextGrid' @@ -19,7 +19,7 @@ test_that('writeTextGrid() output is identical to input TextGrid', { .textgrid_in <- TextGrid(.fin) .textgrid_lines <- writeTextGrid(.textgrid_in) .textgrid_out <- TextGrid(.textgrid_lines) - + expect_identical(.textgrid_out, .textgrid_in) }) @@ -30,7 +30,7 @@ test_that('writeTextGrid() can write to file', { .textgrid_in <- TextGrid(.fin) writeTextGrid(.textgrid_in, path = .fout) .textgrid_out <- TextGrid(.fout) - + expect_identical(.textgrid_out, .textgrid_in) file.remove(.fout) }) @@ -41,11 +41,11 @@ test_that('writeIntervalTier() can write to file', { .fout <- '../test_out.TextGrid' .textgrid_in <- TextGrid(.fin) .tier <- .textgrid_in@.Data[[1]] # an ItervalTier - + .tier_in <- writeIntervalTier(.tier) writeIntervalTier(.tier, path = .fout) .tier_out <- readLines(.fout) - + expect_identical(.tier_in, .tier_out) file.remove(.fout) }) @@ -56,11 +56,11 @@ test_that('writePointTier() can write to file', { .fout <- '../test_out.TextGrid' .textgrid_in <- TextGrid(.fin) .tier <- .textgrid_in@.Data[[3]] # a PointTier - + .tier_in <- writePointTier(.tier) writePointTier(.tier, path = .fout) .tier_out <- readLines(.fout) - + expect_identical(.tier_in, .tier_out) file.remove(.fout) -}) \ No newline at end of file +})