Skip to content

Commit

Permalink
Suppress names of internal function calls in warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
joelnitta committed May 25, 2023
1 parent 66987d2 commit de35790
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
3 changes: 2 additions & 1 deletion R/dct_add_row.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ dct_add_row <- function(tax_dat,
paste(
"Class of taxonID column changed in either new_dat or tax_dat",
"so new data could be added"
)
),
call. = FALSE
)
}
# - duplicated taxonID in new and old data
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ assert_that_d <- function(condition,
return(TRUE)
} else {
if (!quiet) {
warning(unclass(assert_res)$message)
warning(
unclass(assert_res)$message,
call. = FALSE
)
}
do.call("return", list(data), envir = env)
}
Expand Down
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ filmies_small |>
#> 3 54115097 <NA> accepted species Cephalomanes crassum (Copel.) M. G. Price <NA>
#> 4 54133784 54115098 synonym species Trichomanes densinervium Copel. <NA>
#> 5 54115098 <NA> accepted species Cephalomanes densinervium (Copel.) Copel. <NA>
#> 6 193e2011c8ace0ed138af91f41a335cc <NA> accepted <NA> Hymenophyllum dwctaxonense Nitta 2023-05-25 11:04
#> 6 193e2011c8ace0ed138af91f41a335cc <NA> accepted <NA> Hymenophyllum dwctaxonense Nitta 2023-05-25 14:19
```

`dct_modify_row()` modifies a row, automatically re-mapping synonyms if
Expand All @@ -154,8 +154,8 @@ filmies_small |>
#> 1 54115096 <NA> accepted species Cephalomanes atrovirens Presl <NA>
#> 2 54133783 54115097 synonym species Trichomanes crassum Copel. <NA>
#> 3 54115097 <NA> accepted species Cephalomanes crassum (Copel.) M. G. Price <NA>
#> 4 54133784 54115097 synonym species Trichomanes densinervium Copel. 2023-05-25 11:04:55.415253
#> 5 54115098 54115097 synonym species Cephalomanes densinervium (Copel.) Copel. 2023-05-25 11:04:55.387007
#> 4 54133784 54115097 synonym species Trichomanes densinervium Copel. 2023-05-25 14:19:00.826117
#> 5 54115098 54115097 synonym species Cephalomanes densinervium (Copel.) Copel. 2023-05-25 14:19:00.796366
```

`dct_fill_col()` fills in values for columns that have “term” - “termID”
Expand Down Expand Up @@ -222,12 +222,9 @@ This can be done by setting `on_fail` to `"summary"`:
dct_validate(filmies_dirty, on_fail = "summary")
```

#> Warning in assert_that_d(length(duplicated_tax_id) == 0, data = tibble::tibble(taxonID = duplicated_tax_id, : taxonID detected with
#> duplicated value
#> Warning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, : taxonID detected whose
#> acceptedNameUsageID value does not map to taxonID of an existing name.
#> Warning in assert_that_d(length(duplicated_sci_name) == 0, data = tibble::tibble(taxonID = bad_tax_id, : scientificName detected with
#> duplicated value
#> Warning: taxonID detected with duplicated value
#> Warning: taxonID detected whose acceptedNameUsageID value does not map to taxonID of an existing name.
#> Warning: scientificName detected with duplicated value
#> # A tibble: 9 × 5
#> taxonID acceptedNameUsageID scientificName error check
#> <chr> <chr> <chr> <glue> <chr>
Expand Down Expand Up @@ -259,18 +256,18 @@ dct_filmies |>
) |>
dct_validate()
#> # A tibble: 2,452 × 6
#> taxonID acceptedNameUsageID taxonomicStatus taxonRank scientificName modified
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 54115096 <NA> accepted species Cephalomanes atrovirens Presl <NA>
#> 2 54133783 <NA> accepted species Trichomanes crassum Copel. 2023-05-25 11:04:55.54027
#> 3 54115097 <NA> accepted species Cephalomanes crassum (Copel.) M. G. Price <NA>
#> 4 54133784 54115098 synonym species Trichomanes densinervium Copel. <NA>
#> 5 54115098 <NA> accepted species Cephalomanes densinervium (Copel.) Copel. <NA>
#> 6 54133786 54115100 synonym species Cephalomanes curvatum (J. Sm.) V. D. Bosch <NA>
#> 7 54133787 54115100 synonym species Cephalomanes javanica (Bl.) V. D. Bosch <NA>
#> 8 54133788 54115100 synonym species Cephalomanes oblongifolium Presl <NA>
#> 9 54133789 54115100 synonym species Cephalomanes zollingeri V. D. Bosch <NA>
#> 10 54133790 54115100 synonym species Lacostea javanica (Bl.) Prantl <NA>
#> taxonID acceptedNameUsageID taxonomicStatus taxonRank scientificName modified
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 54115096 <NA> accepted species Cephalomanes atrovirens Presl <NA>
#> 2 54133783 <NA> accepted species Trichomanes crassum Copel. 2023-05-25 14:19:00.950024
#> 3 54115097 <NA> accepted species Cephalomanes crassum (Copel.) M. G. Price <NA>
#> 4 54133784 54115098 synonym species Trichomanes densinervium Copel. <NA>
#> 5 54115098 <NA> accepted species Cephalomanes densinervium (Copel.) Copel. <NA>
#> 6 54133786 54115100 synonym species Cephalomanes curvatum (J. Sm.) V. D. Bosch <NA>
#> 7 54133787 54115100 synonym species Cephalomanes javanica (Bl.) V. D. Bosch <NA>
#> 8 54133788 54115100 synonym species Cephalomanes oblongifolium Presl <NA>
#> 9 54133789 54115100 synonym species Cephalomanes zollingeri V. D. Bosch <NA>
#> 10 54133790 54115100 synonym species Lacostea javanica (Bl.) Prantl <NA>
#> # ℹ 2,442 more rows
```

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/_snaps/dct_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected with identical acceptedNameUsageID>
<simpleWarning: taxonID detected with identical acceptedNameUsageID>

---

Expand Down Expand Up @@ -42,7 +42,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected with identical parentNameUsageID>
<simpleWarning: taxonID detected with identical parentNameUsageID>

---

Expand Down Expand Up @@ -70,7 +70,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected with identical originalNameUsageID>
<simpleWarning: taxonID detected with identical originalNameUsageID>

---

Expand Down Expand Up @@ -98,7 +98,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected whose acceptedNameUsageID value does not map to taxonID of an existing name.>
<simpleWarning: taxonID detected whose acceptedNameUsageID value does not map to taxonID of an existing name.>

---

Expand Down Expand Up @@ -126,7 +126,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected whose parentNameUsageID value does not map to taxonID of an existing name.>
<simpleWarning: taxonID detected whose parentNameUsageID value does not map to taxonID of an existing name.>

---

Expand Down Expand Up @@ -154,7 +154,7 @@
Code
(expect_warning(dct_validate(bad_dat, on_fail = "summary")))
Output
<simpleWarning in assert_that_d(sum(map_id_is_bad) == 0, data = tibble::tibble(taxonID = bad_taxon_id, scientificName = bad_sci_name, `:=`({ { col_select } }, bad_acc_id), error = error_msg, check = "check_mapping"), msg = error_msg, quiet = quiet): taxonID detected whose originalNameUsageID value does not map to taxonID of an existing name.>
<simpleWarning: taxonID detected whose originalNameUsageID value does not map to taxonID of an existing name.>

---

Expand Down

0 comments on commit de35790

Please sign in to comment.