Skip to content

as_epi_archive doesn't preserve keys from a keyed data.table or epi_df #201

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

Open
kenmawer opened this issue Aug 12, 2022 · 1 comment
Open
Labels
bug Something isn't working P2 low priority

Comments

@kenmawer
Copy link
Contributor

kenmawer commented Aug 12, 2022

What should be discussed is to what extent as_epi_archive should retain already defined keys in a keyed data.table or epi_df.

@kenmawer kenmawer changed the title as_epi_archive doesn't absorb keys from a keyed data.table or epi_df as_epi_archive doesn't preserve keys from a keyed data.table or epi_df Aug 12, 2022
@brookslogan
Copy link
Contributor

it looks like we have a few unwanted behaviors:

  • keyed data.table + no other_keys arg --> we ignore the current key & replace with default geo time version
  • epi_df with other_keys + no other_keys arg --> same deal
  • epi_df with additional metadata --> no $additional_metadata

(Some of these may currently be tested for, but unwanted. We should alter+add tests accordingly.)

We should probably aim for something like the following:

  • If user provides other_keys arg, just use that as the archive's other keys.
  • If user does not provide other_keys arg:
    • If x is an epi_df, set archive other keys as something like c(setdiff(attr(x,"metadata")$other_keys, "version"), "version")
    • If x is a keyed data.table, check that they key includes geo&time value (error if not), then set archive other keys to c(setdiff(key(x), c("geo_value","time_value","version")), "version")
    • If x is an unkeyed data.table, use character(0L) as the archive other keys

@brookslogan brookslogan added bug Something isn't working P2 low priority labels Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 low priority
Projects
None yet
Development

No branches or pull requests

2 participants