Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c.join_keys to merge the parents too #191

Closed
vedhav opened this issue Nov 17, 2023 · 2 comments
Closed

c.join_keys to merge the parents too #191

vedhav opened this issue Nov 17, 2023 · 2 comments

Comments

@vedhav
Copy link
Contributor

vedhav commented Nov 17, 2023

When a join_keys is merged using c.join_keys it's __parents__ attributed is not merged.

jk1 <- join_keys(join_key("a", "b", "ab"))
parents(jk1) <- list("a" = "b")
parents(jk1)
# $a
# [1] "b"
jk2 <- join_keys(join_key("x", "y", "xy"))
parents(jk2) <- list("x" = "y")
parents(jk2)
# $x
# [1] "y"

jk <- c(jk1, jk2)
parents(jk)
# $a
# [1] "b"
@averissimo
Copy link
Contributor

Good catch!!

It was still in time to be fixed on #184

@averissimo
Copy link
Contributor

testthat::test_that("c.join_key_set merges with empty and non-empty parents", {
  jk1 <- join_keys(
    join_key("d1", "d1", "a")
  )

  jk2 <- join_keys(
    join_key("d3", "d3", "c"),
    join_key("d4", "d4", "d"),
    join_key("d4", "d3", "cd")
  )
  parents(jk2) <- list(d3 = "d4")

  expected <- join_keys(
    join_key("d1", "d1", "a"),
    join_key("d3", "d3", "c"),
    join_key("d4", "d4", "d"),
    join_key("d3", "d4", "cd")
  )
  parents(expected) <- list(d3 = "d4")

  testthat::expect_identical(
    c(jk1, jk2),
    expected
  )

  testthat::expect_equal(
    c(jk2, jk1),
    expected
  )
})
#> Test passed 🥳

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

No branches or pull requests

2 participants