validate icon indicating copy to clipboard operation
validate copied to clipboard

integer64 support or throw warning

Open matthiasgomolka opened this issue 5 years ago • 1 comments

Hi Mark,

sorry for bothering you again. I noticed that validate cannot handle integer64 columns from the bit64 package properly. Here is a reprex:

library(validate)
#> Warning: package 'validate' was built under R version 3.5.1
library(bit64)
#> Loading required package: bit
#> Attaching package bit
#> package:bit (c) 2008-2012 Jens Oehlschlaegel (GPL-2)
#> creators: bit bitwhich
#> coercion: as.logical as.integer as.bit as.bitwhich which
#> operator: ! & | xor != ==
#> querying: print length any all min max range sum summary
#> bit access: length<- [ [<- [[ [[<-
#> for more help type ?bit
#> 
#> Attaching package: 'bit'
#> The following object is masked from 'package:base':
#> 
#>     xor
#> Attaching package bit64
#> package:bit64 (c) 2011-2012 Jens Oehlschlaegel
#> creators: integer64 seq :
#> coercion: as.integer64 as.vector as.logical as.integer as.double as.character as.bin
#> logical operator: ! & | xor != == < <= >= >
#> arithmetic operator: + - * / %/% %% ^
#> math: sign abs sqrt log log2 log10
#> math: floor ceiling trunc round
#> querying: is.integer64 is.vector [is.atomic} [length] format print str
#> values: is.na is.nan is.finite is.infinite
#> aggregation: any all min max range sum prod
#> cumulation: diff cummin cummax cumsum cumprod
#> access: length<- [ [<- [[ [[<-
#> combine: c rep cbind rbind as.data.frame
#> WARNING don't use as subscripts
#> WARNING semantics differ from integer
#> for more help type ?bit64
#> 
#> Attaching package: 'bit64'
#> The following object is masked from 'package:bit':
#> 
#>     still.identical
#> The following objects are masked from 'package:base':
#> 
#>     %in%, :, is.double, match, order, rank

vl <- validator(a + b == c)

df_int64 <- data.frame(a = .Machine$integer.max,
                       b = 1,
                       c = as.integer64(.Machine$integer.max + 1))
confront(df_int64, vl)
#> Object of class 'validation'
#> Call:
#>     confront(dat = df_int64, x = vl)
#> 
#> Confrontations: 1
#> With fails    : 1
#> Warnings      : 0
#> Errors        : 0

df_num <- data.frame(a = .Machine$integer.max,
                     b = 1,
                     c = .Machine$integer.max + 1)
confront(df_num, vl)
#> Object of class 'validation'
#> Call:
#>     confront(dat = df_num, x = vl)
#> 
#> Confrontations: 1
#> With fails    : 0
#> Warnings      : 0
#> Errors        : 0

I don't consider this as a major issue since many packages still struggle with integer64 columns but it would be nice if confront() would throw a warning if dat contains integer64 columns.

matthiasgomolka avatar May 07 '19 14:05 matthiasgomolka

Hi Matthias,

Thanks for noting this. It must be because the comparison operators are overwritten by bit64. Validate does check whether the comparison operators are identical to those from the base namespace (and I thought I was just being paranoid when I implemented that). I have to see why no warning is thrown.

markvanderloo avatar May 09 '19 12:05 markvanderloo