Error in `quantile.default(x, probs = (1 - cl)/2)`: missing values and NaN's not allowed if 'na.rm' is FALSE

# test each estimation method with sample of
# Expected results: treatment effects = 1, p-value for pre-test
# uniformly distributed, ipw model is incorectly specified here
test_that("mixture weights sum up to 1", {
disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, CI=TRUE, boots=2, mixture=TRUE, num.cores=1)
test_that("disco weights sum up to 1", {
## test for more than pre- and post-period
disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1)
test_that("wrong treatment period throws error", {
test_that("simplex results in weakly positive weights", {
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1, simplex=TRUE))
# expect true up to some margin of error
test_that("simplex results in weakly positive weights for mixture", {
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1, simplex=TRUE, mixture=TRUE))
test_that("returned quantile functions and cdfs are weakly increasing", { # TODO left off here
expect_true(all(t_cdf[-1] - t_cdf[-length(t_cdf)] > -1e-5))
expect_true(all(disco_cdf[-1] - disco_cdf[-length(disco_cdf)] > -1e-5))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1, simplex=TRUE, mixture=FALSE))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, qmethod="qkden", seed=1, num.cores=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, qmethod="extreme", seed=1, num.cores=1))
test_that("discrete support works for mixture", {
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0,  seed=1, num.cores=1, mixture=TRUE, grid.cat=sprt))
# check that the length of the cdf is the same as the length of the support
# check that disco quantile function is weakly increasing
test_that("test that variations of other arguments work",  {
expect_error(DiSCo(df=df, id_col.target=1, t0=t0, M=M, seed=1))
expect_no_error(DiSCo(df=df, id_col.target=1, t0=t0, M=M, seed=1))
expect_error(DiSCo(df=df, id_col.target=1, t0=t0, G=G, seed=1))
expect_no_error(DiSCo(df=df, id_col.target=1, t0=t0, G=G, seed=1))
# expect_error(DiSCo(df=df, id_col.target=1, t0=t0, num.cores=num.cores, seed=1))
# expect_no_error(DiSCo(df=df, id_col.target=1, t0=t0, num.cores=num.cores, seed=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, permutation=TRUE, seed=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, permutation=TRUE, seed=1, mixture=TRUE))
# permutation TRUE and mixture TRUE and grid.cat
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, permutation=TRUE, seed=1, mixture=TRUE, grid.cat=sprt))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, permutation=FALSE, seed=1))
expect_error(DiSCo(df=df, id_col.target=1, t0=t0, q_min=q_min, seed=1))
expect_error(DiSCo(df=df, id_col.target=1, t0=t0, q_max=q_max, seed=1))
expect_error(DiSCo(df=df, id_col.target=1, t0=t0, q_min=q_min, q_max=q_max, seed=1))
expect_no_error(DiSCo(df=df, id_col.target=1, t0=t0, q_min=q_min, q_max=q_max, seed=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, CI=FALSE, seed=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, CI=TRUE, replace=FALSE, boots=2, seed=1))
disco <- DiSCo(df=df, id_col.target=1, t0=t0, CI=TRUE, replace=FALSE, boots=34, seed=1)
expect_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, boots=0, seed=1, CI=TRUE, num.cores=1))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, cl=0, seed=1, CI=TRUE, num.cores=1, boot=2))
expect_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, cl=-1, seed=1, CI=TRUE, num.cores=1, boot=2))
expect_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, cl=2, seed=1, CI=TRUE, num.cores=1, boot=2))
expect_no_error(disco <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1))
expect_no_error(disco2 <- DiSCo(df=df, id_col.target=1, t0=t0, seed=1, num.cores=1))