From bbb3445d1073ae84ab8662d1e5498a11f019877a Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 17:49:04 +0000 Subject: [PATCH 01/10] Added test defining target behaviour --- inst/tests/tests.Rraw | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index f6d17a0762..832711c64d 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16770,6 +16770,11 @@ test(2132.2, fifelse(TRUE, 1, s2), error = "S4 class objects (except nanot test(2132.3, fcase(TRUE, s1, FALSE, s2), error = "S4 class objects (except nanotime) are not supported. Please see https://github.com/Rdatatable/data.table/issues/4131.") rm(s1, s2, class2132) +# Complex to character conversion in rbindlist #4202 +A = data.table(A=complex(real = 1:3, imaginary=c(0, -1, 1))) +B = data.table(A=c('qwe', 'asd')) +DT = data.table(A=c(A$A, B$A)) +test(2133, rbind(A,B), DT) ######################## # Add new tests here # From 4daca3fec069c302c9a6c5cf46260851589194b2 Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 18:10:35 +0000 Subject: [PATCH 02/10] AllNA handles complex types now --- src/utils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.c b/src/utils.c index e2c12940ff..02ce8820fe 100644 --- a/src/utils.c +++ b/src/utils.c @@ -62,6 +62,13 @@ bool allNA(SEXP x, bool errorForBadType) { } } return true; + case CPLXSXP: { + const Rcomplex *xd = COMPLEX(x); + for (int i=0; i Date: Mon, 27 Jan 2020 18:10:47 +0000 Subject: [PATCH 03/10] Increased test coverage --- inst/tests/tests.Rraw | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 832711c64d..052da61501 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16774,7 +16774,15 @@ rm(s1, s2, class2132) A = data.table(A=complex(real = 1:3, imaginary=c(0, -1, 1))) B = data.table(A=c('qwe', 'asd')) DT = data.table(A=c(A$A, B$A)) -test(2133, rbind(A,B), DT) +test(2133.1, rbind(A,B), DT) + +A = data.table(A=c(complex(real = 1:3, imaginary=c(0, -1, 1)), NA)) +DT = data.table(A=c(A$A, B$A)) +test(2133.2, rbind(A,B), DT) + +A = data.table(A=c(complex(real = 1:3, imaginary=c(0, -1, 1)), NaN)) +DT = data.table(A=c(A$A, B$A)) +test(2133.2, rbind(A,B), DT) ######################## # Add new tests here # From 0ffd3bf10109a9f2c883c10cf2897aecb8efdc27 Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 18:12:13 +0000 Subject: [PATCH 04/10] Added NEWS item --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 2d607e9bad..f19b949395 100644 --- a/NEWS.md +++ b/NEWS.md @@ -87,6 +87,8 @@ unit = "s") 6. `all.equal(DT, y)` no longer errors when `y` is not a data.table, [#4042](https://github.com/Rdatatable/data.table/issues/4042). Thanks to @d-sci for reporting and the PR. +7. `rbindlist` no longer errors when coercing complex vectors to character vectors, [#4202](https://github.com/Rdatatable/data.table/issues/4202). Thanks to @sritchie73 for reporting and the PR. + ## NOTES 1. `as.IDate`, `as.ITime`, `second`, `minute`, and `hour` now recognize UTC equivalents for speed: GMT, GMT-0, GMT+0, GMT0, Etc/GMT, and Etc/UTC, [#4116](https://github.com/Rdatatable/data.table/issues/4116). From 2829fd7ff4a0be11f3f1358e04f024e881e9dfad Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 18:23:06 +0000 Subject: [PATCH 05/10] Fixed bad test number --- inst/tests/tests.Rraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 052da61501..c4997cd1c4 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16782,7 +16782,7 @@ test(2133.2, rbind(A,B), DT) A = data.table(A=c(complex(real = 1:3, imaginary=c(0, -1, 1)), NaN)) DT = data.table(A=c(A$A, B$A)) -test(2133.2, rbind(A,B), DT) +test(2133.3, rbind(A,B), DT) ######################## # Add new tests here # From f0e80443ad157492dbe9366b972ba5750c06ee3a Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 19:54:37 +0000 Subject: [PATCH 06/10] Added test for codecov --- inst/tests/tests.Rraw | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index c4997cd1c4..80ab30caee 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16784,6 +16784,10 @@ A = data.table(A=c(complex(real = 1:3, imaginary=c(0, -1, 1)), NaN)) DT = data.table(A=c(A$A, B$A)) test(2133.3, rbind(A,B), DT) +A = data.table(A=as.complex(rep(NA, 5))) +DT = data.table(A=c(A$A, B$A)) +test(2133.4, rbind(A,B), DT) + ######################## # Add new tests here # ######################## From 917080d68c7384010c0a1b862d646bf5ddc4f7f5 Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 20:23:29 +0000 Subject: [PATCH 07/10] modified test to hopefully trigger codecov --- inst/tests/tests.Rraw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 80ab30caee..0e48d562d4 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16785,8 +16785,8 @@ DT = data.table(A=c(A$A, B$A)) test(2133.3, rbind(A,B), DT) A = data.table(A=as.complex(rep(NA, 5))) -DT = data.table(A=c(A$A, B$A)) -test(2133.4, rbind(A,B), DT) +DT = data.table(A=c(A$A, A$A)) +test(2133.4, rbind(A,A), DT) ######################## # Add new tests here # From f85e22f9eb7deaa35feaa66d61a2adf018e609b4 Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 22:04:36 +0000 Subject: [PATCH 08/10] reverting previous commit --- inst/tests/tests.Rraw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 0e48d562d4..80ab30caee 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16785,8 +16785,8 @@ DT = data.table(A=c(A$A, B$A)) test(2133.3, rbind(A,B), DT) A = data.table(A=as.complex(rep(NA, 5))) -DT = data.table(A=c(A$A, A$A)) -test(2133.4, rbind(A,A), DT) +DT = data.table(A=c(A$A, B$A)) +test(2133.4, rbind(A,B), DT) ######################## # Add new tests here # From 016df307491012d94f9f2483d34880b937a9cf78 Mon Sep 17 00:00:00 2001 From: Scott Ritchie Date: Mon, 27 Jan 2020 23:35:46 +0000 Subject: [PATCH 09/10] Created macro ISNAN_COMPLEX --- src/data.table.h | 3 +++ src/utils.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data.table.h b/src/data.table.h index f2687f52ea..3faadbe574 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -47,6 +47,9 @@ typedef R_xlen_t RLEN; #define NA_INTEGER64 INT64_MIN #define MAX_INTEGER64 INT64_MAX +// for use with CPLXSXP, no macro provided by R internals +#define ISNAN_COMPLEX(x) (ISNAN(x.r) || ISNAN(x.i)) // TRUE if either real or imaginary component is NA or NaN + // Backport macros added to R in 2017 so we don't need to update dependency from R 3.0.0 #ifndef MAYBE_SHARED # define MAYBE_SHARED(x) (NAMED(x) > 1) diff --git a/src/utils.c b/src/utils.c index 02ce8820fe..87348beb7c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -64,7 +64,7 @@ bool allNA(SEXP x, bool errorForBadType) { return true; case CPLXSXP: { const Rcomplex *xd = COMPLEX(x); - for (int i=0; i Date: Mon, 17 Feb 2020 23:01:52 -0700 Subject: [PATCH 10/10] Extra parens in macro around (x) in case x is an expression --- src/data.table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data.table.h b/src/data.table.h index 3faadbe574..90ff7fb6fc 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -48,7 +48,7 @@ typedef R_xlen_t RLEN; #define MAX_INTEGER64 INT64_MAX // for use with CPLXSXP, no macro provided by R internals -#define ISNAN_COMPLEX(x) (ISNAN(x.r) || ISNAN(x.i)) // TRUE if either real or imaginary component is NA or NaN +#define ISNAN_COMPLEX(x) (ISNAN((x).r) || ISNAN((x).i)) // TRUE if either real or imaginary component is NA or NaN // Backport macros added to R in 2017 so we don't need to update dependency from R 3.0.0 #ifndef MAYBE_SHARED