nodes: 0, module; 1, function_definition; 2, function_name:value_nth_person; 3, parameters; 4, block; 5, identifier:self; 6, identifier:n; 7, identifier:array; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, comment:# For households that have at least n persons, set the result as the value of criteria for the person for which the position is n.; 16, comment:# The map is needed b/c the order of the nth persons of each household in the persons vector is not necessarily the same than the household order.; 17, expression_statement; 18, return_statement; 19, identifier:default; 20, integer:0; 21, comment:"""
              Get the value of array for the person whose position in the entity is n.
  
              Note that this position is arbitrary, and that members are not sorted.
  
              If the nth person does not exist, return  ``default`` instead.
  
              The result is a vector which dimension is the number of entities.
          """; 22, call; 23, assignment; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, identifier:result; 29, attribute; 30, argument_list; 31, identifier:positions; 32, attribute; 33, identifier:nb_persons_per_entity; 34, call; 35, identifier:members_map; 36, attribute; 37, identifier:result; 38, call; 39, subscript; 40, subscript; 41, attribute; 42, identifier:check_array_compatible_with_entity; 43, identifier:array; 44, identifier:self; 45, identifier:members_position; 46, attribute; 47, argument_list; 48, identifier:self; 49, identifier:ordered_members_map; 50, attribute; 51, argument_list; 52, identifier:result; 53, comparison_operator:nb_persons_per_entity > n; 54, subscript; 55, comparison_operator:positions[members_map] == n; 56, identifier:self; 57, identifier:members; 58, identifier:self; 59, identifier:nb_persons; 60, identifier:self; 61, identifier:filled_array; 62, identifier:default; 63, keyword_argument; 64, identifier:nb_persons_per_entity; 65, identifier:n; 66, identifier:array; 67, identifier:members_map; 68, subscript; 69, identifier:n; 70, identifier:dtype; 71, attribute; 72, identifier:positions; 73, identifier:members_map; 74, identifier:array; 75, identifier:dtype
code: def value_nth_person(self, n, array, default = 0):
          """
              Get the value of array for the person whose position in the entity is n.
  
              Note that this position is arbitrary, and that members are not sorted.
  
              If the nth person does not exist, return  ``default`` instead.
  
              The result is a vector which dimension is the number of entities.
          """
          self.members.check_array_compatible_with_entity(array)
          positions = self.members_position
          nb_persons_per_entity = self.nb_persons()
          members_map = self.ordered_members_map
          result = self.filled_array(default, dtype = array.dtype)
          # For households that have at least n persons, set the result as the value of criteria for the person for which the position is n.
          # The map is needed b/c the order of the nth persons of each household in the persons vector is not necessarily the same than the household order.
          result[nb_persons_per_entity > n] = array[members_map][positions[members_map] == n]
  
          return result