vrunge / gfpop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

min/max NA is sometimes dbl, sometimes lgl

julianstanley opened this issue · comments

Hi Vincent, and CC @tdhock

These two bits of code should produce the exact same thing, right?

std_default <- gfpop::graph(type = "std")

and

std_custom <- gfpop::graph(
  gfpop::Edge(state1 = "Std", state2 = "Std", type = "null", gap = 1, penalty = 0, K = Inf, a = 0),
  gfpop::Edge(state1 = "Std", state2 = "Std", type = "std", gap = 0, penalty = 0, K = Inf, a = 0)
)

But testthat doesn't agree, because the min and max columns of the std_default are numeric, but they are logical in std_custom.

> library(testthat)
> expect_equal(std_default, std_custom)
# Error: `std_default` not equal to `std_custom`.
# Component “min”: Modes: numeric, logical
# Component “min”: target is numeric, current is logical
# Component “max”: Modes: numeric, logical
# Component “max”: target is numeric, current is logical

Do you agree that these should be equal? If so, I think it's as easy as just casting min and max as numeric in the Edge() function. So, changing this line:

data.frame(state1, state2, type, parameter, penalty, K, a, min=NA, max=NA, stringsAsFactors = FALSE)

To:

data.frame(state1, state2, type, parameter, penalty, K, a, 
    min = as.numeric(NA), max = as.numeric(NA), stringsAsFactors = FALSE)

If I do that on my end and then name it Edge_new(), test_that seems happy:

std_custom_revised <- gfpop::graph(
  Edge_new(state1 = 'Std', state2 = 'Std', type = 'null', gap = 1, penalty = 0, K = Inf, a = 0),
  Edge_new(state1 = 'Std', state2 = 'Std', type = 'std', gap = 0, penalty = 0, K = Inf, a = 0)
) 
> expect_equal(std_default, std_custom_revised)
>