thisisnic commented on code in PR #35339:
URL: https://github.com/apache/arrow/pull/35339#discussion_r1177733151
##########
r/tests/testthat/test-compute-arith.R:
##########
@@ -175,9 +175,20 @@ test_that("Math group generics work on Array objects", {
round(exp(Array$create(c(2L, 1L))), digits = 10),
Array$create(round(exp(c(2L, 1L)), 10))
)
+ expect_equal(round(cumsum(Array$create(c(2.3, -1.0, 7.9, NA_real_, 1.0))),
+ digits = 10),
+ Array$create(c(2.3, 1.3, 9.2, NA, NA)))
+ expect_equal(cumsum(Array$create(-10L)), Array$create(-10L))
+ expect_equal(cumsum(Array$create(NA_integer_)), Array$create(NA_integer_))
+ expect_equal(
+ cumsum(
+ ChunkedArray$create(c(2L, 7L, 8L), c(-1L, 2L, 17L, NA_integer_, 3L), 18L)
+ )$as_vector(),
+ c(2L, 9L, 17L, 16L, 18L, 35L, NA_integer_, NA_integer_, NA_integer_)
+ )
Review Comment:
I've just made a couple of small changes here - I've used one of our custom
expectation functions, `expect_as_vector()` to simplify the comparison, so we
don't need to call `round()` here or use the `as_vector()` method.
```suggestion
expect_as_vector(
cumsum(Array$create(c(2.3, -1.0, 7.9, NA_real_, 1.0))),
c(2.3, 1.3, 9.2, NA_real_, NA_real_)
)
expect_equal(cumsum(Array$create(-10L)), Array$create(-10L))
expect_equal(cumsum(Array$create(NA_integer_)), Array$create(NA_integer_))
expect_as_vector(
cumsum(ChunkedArray$create(c(2L, 7L, 8L), c(-1L, 2L, 17L, NA_integer_,
3L), 18L)),
c(2L, 9L, 17L, 16L, 18L, 35L, NA_integer_, NA_integer_, NA_integer_)
)
```
--
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]