Skip to content

Commit e3b11ff

Browse files
fix bad branches (#285)
1 parent 2a835af commit e3b11ff

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
1. `as.integer64(2^63)` returns `NA_integer64_` more consistently (e.g. on ARM), consistent with `as.integer(2^31)` (#19). Thanks @dipterix.
7373
1. `[.integer64` now runs faster and correctly regarding `NA` and arrays (#176). Thanks @hcirellu.
7474
1. `integer64() %in% 1L` no longer warns (#265). Thanks @hcirellu.
75+
1. `match.integer64(..., method="orderpos")` and `duplicated.integer64(..., method="orderdup")` no longer fail with "object 's' not found" (#58).
7576

7677
## NOTES
7778

R/highlevel64.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ match.integer64 = function(x, table, nomatch = NA_integer_, nunique=NULL, method
15001500
},
15011501
orderpos={
15021502
if (is.null(cache_env) || !exists("order", cache_env)) {
1503-
o <- seq_along(s)
1503+
o <- seq_along(table)
15041504
ramorder(table, o, na.last=FALSE)
15051505
} else {
15061506
o <- get("order", cache_env)
@@ -1685,7 +1685,7 @@ duplicated.integer64 = function(x, incomparables = FALSE, nunique = NULL, method
16851685
},
16861686
orderdup={
16871687
if (is.null(cache_env) || is.null(cache_env$order)) {
1688-
o <- seq_along(s)
1688+
o <- seq_along(x)
16891689
ramorder(x, o, na.last=FALSE)
16901690
} else {
16911691
o <- get("order", cache_env, inherits=FALSE)

tests/testthat/test-highlevel64.R

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ test_that("Different method= for match() and %in% work", {
3737
expect_identical(match(x, y, method="hashrev"), expected)
3838
expect_identical(match(x, y, method="sortorderpos"), expected)
3939
expect_error(match(x, y, method="_unknown_"), "'arg' should be one of", fixed=TRUE)
40-
# TODO(#58): Fix this, currently fails.
41-
# expect_identical(match(x, y, method="orderpos"), expected)
40+
expect_identical(match(x, y, method="orderpos"), expected)
4241

4342
# NB: %in% is quite a bit different; while there's a public API to
4443
# `%in%.integer64`, likely, there shouldn't be (it's strange to export
@@ -265,8 +264,7 @@ test_that("different method= for duplicated, unique work", {
265264
expect_identical(unique(x, method="sortorderuni"), exp_unq)
266265
expect_identical(unique(x, method="sortuni"), exp_unq)
267266

268-
# TODO(#58): Fix this, currently fails.
269-
# expect_identical(duplicated(x, method="orderdup"), exp_dup)
267+
expect_identical(duplicated(x, method="orderdup"), exp_dup)
270268
expect_identical(unique(x, method="orderuni"), exp_unq)
271269
})
272270

@@ -377,10 +375,10 @@ test_that("prank() works as intended", {
377375
expect_identical(prank(x[1L]), NA_integer64_)
378376
})
379377

380-
test_that("match.integer64 with method='orderpos' fails due to bug", {
378+
test_that("match.integer64 with method='orderpos' works", {
381379
x <- as.integer64(1:5)
382380
table <- as.integer64(3:7)
383-
expect_error(match(x, table, method="orderpos"), "object 's' not found", fixed=TRUE)
381+
expect_identical(match(x, table, method="orderpos"), c(NA, NA, 1:3))
384382
})
385383

386384
test_that("match.integer64 with partial cache triggers fallback", {

0 commit comments

Comments
 (0)