Skip to content

Instantly share code, notes, and snippets.

@Br3nda
Created August 9, 2018 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Br3nda/66a8d555267d7884684a428504ed98be to your computer and use it in GitHub Desktop.
Save Br3nda/66a8d555267d7884684a428504ed98be to your computer and use it in GitHub Desktop.

Number of children in a family

class number_of_children_in_family(Variable):
    value_type = int
    definition_period = MONTH
    entity = Family
    label = u"The number of children in a family"

    def formula(families, period):
        return families.nb_persons(role=Family.CHILD)

Does a family have children

class is_a_child_in_a_family(Variable):
    value_type = bool
    entity = Person
    label = u"person is a child in a family"
    definition_period = ETERNITY

    def formula(person, period):
        return person.has_role(Family.CHILD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment