Skip to content

Commit

Permalink
fixing error with is.atomic(NULL) to FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
edwindj committed Sep 30, 2023
1 parent db111b1 commit 12759b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: errorlocate
Type: Package
Title: Locate Errors with Validation Rules
Version: 1.1
Version: 1.1.1
Authors@R: c(person("Edwin", "de Jonge", email = "edwindjonge@gmail.com", role = c("aut", "cre"), comment=c(ORCID="0000-0002-6580-4718")),
person("Mark", "van der Loo", email = "mark.vanderloo@gmail.com", role = c("aut")))
Description: Errors in data can be located and removed using validation rules from package
Expand Down
2 changes: 1 addition & 1 deletion R/categorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INFIX_CAT_NAME <- ":"
return(TRUE)
}

if(is.atomic(expr)){
if(is.atomic(expr) || is.null(expr)){
return(is.logical(expr))
}

Expand Down
2 changes: 1 addition & 1 deletion R/conditional.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ rep_lin_ <- function(e, or=TRUE, h=new.env()){
l <- left(e)
r <- right(e)

if (is.atomic(e) || is.symbol(e)){
if (is.atomic(e) || is.symbol(e) || is.null(e)){
return(e)
}

Expand Down
7 changes: 6 additions & 1 deletion R/linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ is_lin_ <- function(expr, top=TRUE, ...){
return(is_lin_(l, FALSE) && is_lin_(r, FALSE))
}

if (is.null(expr)){
return(TRUE)
}

if (is.atomic(expr)){
return(is.numeric(expr) || is.null(expr))
return(is.numeric(expr))
}


if (is.symbol(expr) || op == "var_group"){ return(TRUE) }

if (op %in% c("+","-")){
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-errorlocation.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("errorlocation",{
rules <- validator( x > 1)
d <- data.frame( x = c(0,1,2,-1))
N <- nrow(d)
el <- locate_errors(d, rules)
el <- locate_errors(d, rules, Ncpus = 1)

expect_equal(length(el$duration), N)
expect_true(el$duration[3] == 0)
Expand Down

0 comments on commit 12759b0

Please sign in to comment.