jonkeane commented on a change in pull request #11355:
URL: https://github.com/apache/arrow/pull/11355#discussion_r727257627
##########
File path: r/tests/testthat/test-compute-arith.R
##########
@@ -67,10 +67,14 @@ test_that("Division", {
expect_equal(a %/% 2, Array$create(c(0L, 1L, 1L, 2L, NA_integer_)))
expect_equal(a / 2 / 2, Array$create(c(1:4 / 2 / 2, NA_real_)))
expect_equal(a %/% 2 %/% 2, Array$create(c(0L, 0L, 0L, 1L, NA_integer_)))
+ expect_equal(a / 0, Array$create(c(Inf, Inf, Inf, Inf, NA_real_)))
+ # TODO add tests for integer division %/% by 0
Review comment:
We should add the ticket number that we just created here (or we could
remove these todos totally)
##########
File path: r/tests/testthat/test-dplyr-funcs-math.R
##########
@@ -288,3 +288,20 @@ test_that("trig functions", {
df
)
})
+
+test_that("arith functions ", {
+ df <- tibble(x = c(1:5, NA))
+
+ expect_dplyr_equal(
+ input %>%
+ transmute(int_div = x %/% 2,
+ addition = x + 1,
+ multiplication = x * 3,
+ subtraction = x - 5,
+ division = x / 2,
+ power = x ^ 3,
+ modulo = x %% 3) %>%
+ collect(),
Review comment:
Minor styling nit (the linter will probably complain about this anyway)
```suggestion
input %>%
transmute(
addition = x + 1,
subtraction = x - 5,
multiplication = x * 3,
division = x / 2,
int_div = x %/% 2,
power = x ^ 3,
modulo = x %% 3
) %>%
collect(),
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]