Skip to content

Commit

Permalink
Suppress internally-generated deprecation warning
Browse files Browse the repository at this point in the history
The deprecation warning emplaced for `is_state()` proved somewhat noisy
since this function is used internally by several other functions. So it
has been silenced for now.

Additionally, some changes were made to NAMESPACE to address some issues
raised by CRAN check for Debian and Solaris.
  • Loading branch information
BroVic committed Aug 20, 2020
1 parent 471ab2d commit 88d37d2
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: naijR
Type: Package
Title: Operations to Ease Data Analyses Specific to Nigeria
Version: 0.1.3
Date: 2020-08-03
Version: 0.1.4
Date: 2020-08-20
Depends:
R (>= 3.6)
Imports:
Expand All @@ -12,7 +12,6 @@ Imports:
maps (>= 3.3.0),
rgdal (>= 1.4.4),
rlang (>= 0.4.0),
tools (>= 3.6.3),
lifecycle (>= 0.2.0)
Suggests:
covr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(map_ng)
export(states)
import(lifecycle)
import(magrittr)
import(mapdata)
import(stats)
importFrom(RColorBrewer,brewer.pal)
importFrom(RColorBrewer,brewer.pal.info)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# naijR 0.1.3
# v0.1.3

* Added a `NEWS.md` file to track changes to the package.
* Recognise abbreviations of 'Federal Capital Territory' i.e. FCT.
* Disable error-check on character type for `is_state` so it can be used more effectively for functional programming constructs.

# v0.1.4

* Suppress deprecation warning for `is_state()` when it is called internally by package function; displayed only when function is called directly.
2 changes: 1 addition & 1 deletion R/lgas_nigeria.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ globalVariables(c("lgas_nigeria", "state", "lga"))
lgas_ng <- function(ng.state = NA_character_) {
stopifnot(is.character(ng.state))
if (!all(is.na(ng.state))) {
if (!is_state(ng.state))
if (!suppressWarnings(is_state(ng.state)))
stop("One or more elements of 'ng.state' is not a State in Nigeria")
lst <- lapply(
ng.state,
Expand Down
16 changes: 10 additions & 6 deletions R/map_nigeria.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ map_ng <- function(region = character(),
return(FALSE)
arg <- enexpr(val)
if (!no.region &&
is.character(region) && is_state(region) && !is_null(arg))
is.character(region) &&
suppressWarnings(is_state(region)) &&
!is_null(arg))
return(TRUE)
if (!is.data.frame(data))
return(FALSE)
Expand All @@ -283,14 +285,14 @@ map_ng <- function(region = character(),




#' @import mapdata
#' @importFrom maps SpatialPolygons2map
.getMapData <- function(region)
{
stopifnot(is.character(region))
if (identical(region, 'Nigeria'))
return("mapdata::worldHires")
if (!is_state(region)) {
if (!suppressWarnings(is_state(region))) {
ss <- paste(region, collapse = ', ')
stop("Invalid region(s) for the map: ", ss)
}
Expand Down Expand Up @@ -340,7 +342,7 @@ map_ng <- function(region = character(),
if (is.factor(x))
x <- as.character(x)
if (is.character(x))
is_state(x)
suppressWarnings(is_state(x))
else
FALSE
}, logical(1))
Expand Down Expand Up @@ -399,7 +401,7 @@ map_ng <- function(region = character(),
#' @import magrittr
.assertListElements <- function(x) {
stopifnot(c('region', 'value', 'breaks') %in% names(x))
region.valid <- is_state(x$region)
region.valid <- suppressWarnings(is_state(x$region))
value.valid <-
x$value %>%
{
Expand Down Expand Up @@ -528,7 +530,9 @@ map_ng <- function(region = character(),
# properly applied to the respective regions and not recycled.
.reassignColours <- function(names, regions, in.colours)
{
stopifnot(is.character(names), is_state(regions), .isHexColor(in.colours))
stopifnot(is.character(names),
suppressWarnings(is_state(regions)),
.isHexColor(in.colours))
out.colours <- new.names <- rep(NA, length(names))
for (i in seq_along(regions)) {
regx <- .regexDuplicatedPolygons(regions[i])
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-lgas_nigeria.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


test_that("illegal input is caught early", {
expect_warning(try(lgas_ng("Saarland"), silent = TRUE)) # Deprecation!
expect_error(lgas_ng("Saarland"))
expect_error(lgas_ng("Maryland"),
"One or more elements of 'ng.state' is not a State in Nigeria",
fixed = TRUE)
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-map_nigeria.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ test_that("Colours are reassigned when duplicate polygons exist", {
expect_true(any(duplicated(names(fin.color))))
expect_equal(sum(duplicated(names(fin.color))), 3L)
expect_error(.reassignColours(mapnames, not.ng, init.color),
"is_state\\(regions\\) is not TRUE")
"suppressWarnings(is_state(regions)) is not TRUE",
fixed = TRUE)
expect_error(
.reassignColours(mapnames, statenames, rep("NoHexs", length(statenames))),
".isHexColor\\(in.colours\\) is not TRUE")
Expand Down

0 comments on commit 88d37d2

Please sign in to comment.