Skip to content

Comments

Fix: find_missing_integerish() handles complex type#289

Open
ckirchho wants to merge 2 commits intomllg:masterfrom
ckirchho:find_missing_integerish-complex
Open

Fix: find_missing_integerish() handles complex type#289
ckirchho wants to merge 2 commits intomllg:masterfrom
ckirchho:find_missing_integerish-complex

Conversation

@ckirchho
Copy link

Calling qtest(), qassert(), or qexpect() with rules = "X" on an object of complex type that passes the integerish check will throw an internal error from find_missing_integerish() because it is missing a case for CPLXSXP.

Example

qtest(0+1i, "x")
#> [1] FALSE
qtest(0+0i, "x")
#> [1] TRUE
qtest(NA_complex_, "x")
#> [1] TRUE
qtest(0+1i, "X")
#> [1] FALSE
qtest(0+0i, "X")
#> Error in checkmate::qtest(0 + (0+0i), "X"): Error in find_missing_integerish: x must be logical or numeric
qtest(NA_complex_, "X")
#> Error in checkmate::qtest(NA_complex_, "X"): Error in find_missing_integerish: x must be logical or numeric

Corrected

qtest(0+1i, "x")
#> [1] FALSE
qtest(0+0i, "x")
#> [1] TRUE
qtest(NA_complex_, "x")
#> [1] TRUE
qtest(0+1i, "X")
#> [1] FALSE
qtest(0+0i, "X")
#> [1] TRUE
qtest(NA_complex_, "X")
#> [1] FALSE

Created on 2026-01-29 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant