Skip to content

Commit 8325bd9

Browse files
fix failing tests
1 parent eed6148 commit 8325bd9

File tree

8 files changed

+23
-25
lines changed

8 files changed

+23
-25
lines changed

R/apg.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#' get_apg_orders()
1111
#' get_apg_families()
1212
#' }
13-
1413
#' @export
1514
#' @rdname apg
1615
get_apg_orders <- function(...) {

R/class2tree.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ mainTaxonomyRank <- function() {
231231
#' @noRd
232232
#' @author Vinh Tran {tran@bio.uni-frankfurt.de}
233233
get_rank <- function (x) {
234-
rank_df <- x[, 'rank']
235-
names(rank_df) <- x[, 'rank']
234+
rank_df <- x$rank
235+
names(rank_df) <- x$rank
236236

237-
id_df <- x[, 'id']
237+
id_df <- x$id
238238
joined_df <- cbind(
239239
data.frame(rank_df, stringsAsFactors = FALSE),
240240
data.frame(id_df, stringsAsFactors = FALSE)
@@ -247,19 +247,19 @@ get_rank <- function (x) {
247247
df <- data.frame(
248248
t(data.frame(rev(joined_df$rank_df))), stringsAsFactors = FALSE
249249
)
250-
outDf <- data.frame(tip = x[nrow(x), "name"], df, stringsAsFactors = FALSE)
250+
outDf <- data.frame(tip = x$name[nrow(x)], df, stringsAsFactors = FALSE)
251251
return(outDf)
252252
}
253253

254254
#' Get taxonomy names and IDs for all ranks
255255
#' @noRd
256256
#' @author Vinh Tran {tran@bio.uni-frankfurt.de}
257257
get_name <- function (x) {
258-
rank_df <- x[, 'rank']
259-
names(rank_df) <- x[, 'rank']
258+
rank_df <- x$rank
259+
names(rank_df) <- x$rank
260260

261-
nameDf <- x[, 'name']
262-
id_df <- x[, 'id']
261+
nameDf <- x$name
262+
id_df <- x$id
263263

264264
joined_df <- cbind(
265265
data.frame(rank_df,stringsAsFactors=FALSE),
@@ -273,7 +273,7 @@ get_name <- function (x) {
273273
joined_df$name <- paste0(joined_df$nameDf, "##", joined_df$rank_df)
274274

275275
df <- data.frame(t(data.frame(rev(joined_df$name))), stringsAsFactors = FALSE)
276-
outDf <- data.frame(tip = x[nrow(x), "name"], df, stringsAsFactors = FALSE)
276+
outDf <- data.frame(tip = x$name[nrow(x)], df, stringsAsFactors = FALSE)
277277
return(outDf)
278278
}
279279

R/classification.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ process_ids <- function(input, db, fxn, ...){
321321
pow = as_pow)
322322
as_fxn(input, check = FALSE)
323323
} else {
324-
eval(fxn)(input, ...)
324+
out <- rep(taxa::taxon(NA), length(input))
325+
out[!is.na(input)] <- eval(fxn)(input[!is.na(input)], ...)
325326
}
326327
}
327328

R/downstream-utils.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ prune_too_low <- function(x, rank, ignore_no_rank = FALSE, zoo = FALSE,
1515
# the pruning
1616
rr <- if (zoo) taxize_ds$rank_ref_zoo else taxize_ds$rank_ref
1717
rank_target_no <- as.numeric(rr[which_rank(rank, zoo = zoo), "rankid"])
18-
rank_nos <- as.numeric(
19-
rr[vapply(x$rank, function(z) which_rank(z, zoo = zoo), 1),
20-
"rankid"])
18+
rank_nos <- as.numeric(rr$rankid[vapply(x$rank, function(z) which_rank(z, zoo = zoo), 1)])
2119
if (ignore_no_rank) rank_nos[rank_nos %in% c(300, 400)] <- 0
2220
x[!rank_nos > rank_target_no, ]
2321
}

tests/fixtures/apgFamilies.yml renamed to tests/fixtures/get_apg_families.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ http_interactions:
2525
vary: Accept-Encoding
2626
server: Microsoft-IIS/7.5
2727
x-powered-by: ASP.NET
28-
date: Wed, 15 Sep 2021 22:40:50 GMT
28+
date: Tue, 26 Oct 2021 08:37:56 GMT
2929
content-length: '42693'
3030
body:
3131
encoding: UTF-8
@@ -2088,5 +2088,5 @@ http_interactions:
20882088
: \"http://www.\");\r\ndocument.write(unescape(\"%3Cscript src='\" + gaJsHost
20892089
+ \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\r\n</script>\r\n<script
20902090
type=\"text/javascript\">\r\nvar pageTracker = _gat._getTracker(\"UA-3783322-4\");\r\npageTracker._trackPageview();\r\n</script>\r\n\r\n</body>\r\n</html>\r\n"
2091-
recorded_at: 2021-09-15 22:40:50 GMT
2091+
recorded_at: 2021-10-26 08:37:56 GMT
20922092
recorded_with: vcr/1.0.2, webmockr/0.8.0

tests/fixtures/apgOrders.yml renamed to tests/fixtures/get_apg_orders.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ http_interactions:
2525
vary: Accept-Encoding
2626
server: Microsoft-IIS/7.5
2727
x-powered-by: ASP.NET
28-
date: Wed, 15 Sep 2021 22:40:49 GMT
28+
date: Tue, 26 Oct 2021 08:37:55 GMT
2929
content-length: '10700'
3030
body:
3131
encoding: UTF-8
@@ -652,5 +652,5 @@ http_interactions:
652652
: \"http://www.\");\r\ndocument.write(unescape(\"%3Cscript src='\" + gaJsHost
653653
+ \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\r\n</script>\r\n<script
654654
type=\"text/javascript\">\r\nvar pageTracker = _gat._getTracker(\"UA-3783322-4\");\r\npageTracker._trackPageview();\r\n</script>\r\n\r\n</body>\r\n</html>\r\n"
655-
recorded_at: 2021-09-15 22:40:50 GMT
655+
recorded_at: 2021-10-26 08:37:55 GMT
656656
recorded_with: vcr/1.0.2, webmockr/0.8.0

tests/testthat/test-apgscraping.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
context("apg* functions")
22

3-
test_that("apgOrders works", {
3+
test_that("get_apg_orders works", {
44
skip_on_cran()
5-
vcr::use_cassette("apgOrders", {
6-
orders <- apgOrders()
5+
vcr::use_cassette("get_apg_orders", {
6+
orders <- get_apg_orders()
77
})
88

99
expect_is(orders, "data.frame")
@@ -12,10 +12,10 @@ test_that("apgOrders works", {
1212
expect_equal(NCOL(orders), 4)
1313
})
1414

15-
test_that("apgFamilies works", {
15+
test_that("get_apg_families works", {
1616
skip_on_cran()
17-
vcr::use_cassette("apgFamilies", {
18-
families <- apgFamilies()
17+
vcr::use_cassette("get_apg_families", {
18+
families <- get_apg_families()
1919
})
2020

2121
expect_is(families, "data.frame")

tests/testthat/test-classification-gbif.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test_that("classification works for GBIF data", {
88
names(clas_gbif) <- NULL
99
})
1010

11-
expect_that(clas_gbif[[2]], equals(NA))
11+
expect_null(clas_gbif[[2]])
1212
expect_is(clas_gbif, "classification")
1313
expect_is(clas_gbif[[1]], "data.frame")
1414
expect_equal(length(clas_gbif), 2)

0 commit comments

Comments
 (0)