Skip to content

Commit

Permalink
Added dependencey on stringi
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickreidy committed Jul 11, 2018
1 parent 790972e commit f910766
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -25,6 +25,7 @@ exportClasses(Tier)
exportMethods(TextGrid)
import(methods)
import(readr)
import(stringi)
importFrom(methods,new)
importFrom(methods,setClass)
importFrom(methods,setGeneric)
Expand Down
1 change: 1 addition & 0 deletions R/textgRid.R
Expand Up @@ -11,6 +11,7 @@
#'
#' @import methods
#' @import readr
#' @import stringi
#'
#' @section S4 classes:
#' \code{\link[=Tier-class]{Tier}},
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-IntervalTier.R
Expand Up @@ -72,7 +72,7 @@ test_that('findIntervals() can find intervals with non-empty labels', {
# 6.0 -- 9.0 = word.2
# 9.0 -- 10.0 = <empty>
.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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 = '.'), '')
)
)
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-writeTextGrid.R
Expand Up @@ -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'
Expand All @@ -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)
})

Expand All @@ -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)
})
Expand All @@ -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)
})
Expand All @@ -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)
})
})

0 comments on commit f910766

Please sign in to comment.