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

Allow same-sex relationship in the demography module #3

Open
asiripanich opened this issue Feb 5, 2020 · 0 comments
Open

Allow same-sex relationship in the demography module #3

asiripanich opened this issue Feb 5, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@asiripanich
Copy link
Member

If there is any same-sex couple getting married via the cohabitation route then the following checkmate command will raise a 'unique integer' error since the ids of those individuals will appear twice in both vector ids.

https://github.com/dymium-org/dymiumModules/blob/d53fdb47680efc9a05e56f0c420c85907e73794e/modules/demography/marriage.R#L75-L80

One way to fix this would be to call unique on the id vectors, only if the duplicated ids belong to individuals in a same-sex partnership.

#' Check to make sure that the duplicated ids come from same-sex cohabiting
    #' individuals to get married.
    if (length(unique(cohabiting_person_to_marry_ids)) !=
        length(cohabiting_person_to_marry_ids)) {
      tab <- table(cohabiting_person_to_marry_ids)
      if (any(tab > 2)) {
        stop("There are some ids that appear more than twice. Please debug or report this.")
      }
      potential_same_sex_ind_ids <- as.integer(names(tab[tab != 1]))
      #' pssind = potential_same_sex_ind
      pssind_sex <- Ind$get_attr("sex", ids = potential_same_sex_ind_ids)
      pssind_partner_ids <- Ind$get_attr("partner_id", ids = potential_same_sex_ind_ids)
      pssind_partner_sex <- Ind$get_attr("sex", ids = pssind_partner_ids)
      if (all(pssind_sex == pssind_partner_sex)) {
        stop("There are duplicated ids of opposite couples in the marriage from cohabitation process.")
      } else {
        cohabiting_person_to_marry_ids <- unique(cohabiting_person_to_marry_ids)
      }
    }
@asiripanich asiripanich added the bug Something isn't working label Feb 5, 2020
@asiripanich asiripanich changed the title Allow same-sex marriages Allow same-sex relationship Mar 18, 2020
@asiripanich asiripanich changed the title Allow same-sex relationship Allow same-sex relationship in the demography module Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant