13.07.2015 Views

LIAM 2 User Guide

LIAM 2 User Guide

LIAM 2 User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>LIAM</strong> 2 <strong>User</strong> <strong>Guide</strong>, Release 0.7.0As another example, the process below sets a variable to_separate to True if the variable separate is True for eitherthe individual or his/her partner.- to_separate: separate or partner.separateNote that it is perfectly valid to chain links as, for example, in:grand_parents_income: mother.mother.income + mother.father.income +father.mother.income + father.father.incomeAnother option to get values in the linked individual is to use the form:link_name.get(expr)this syntax is a bit more verbose in the simple case, but is much more powerful as it allows to evaluate (almost)any expression on the linked individual.For example, if you want to get the average age of both parents of the mother of each individual, you can do it so:mother.get((mother.age + father.age) / 2)6.2 one2manyA one2many link links an individual of the entity to at least one other individual in the same (eg. a person tohis/her children) or another entity (a household to its members).entities:household:links:persons: {type: one2many, target: person, field: household_id}person:fields:- age: int- income: float- household_id : intlinks:household: {type: many2one, target: household, field: household_id}• persons is the link from the household to its members.• household is the link form a person to his/her household.To access the information stored in the linked individuals through a one2many link, you have to use aggregatemethods on the link:link_name.method_name([arguments])For example:persons.avg(age)one2many links support the following methods: count(), sum(), avg(), min() and max(). See link methods fordetails.exampleentities:household:fields:- num_children: intlinks:36 Chapter 6. Links

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!