code: def sum(self, array, role = None):
          
          self.entity.check_role_validity(role)
          self.members.check_array_compatible_with_entity(array)
          if role is not None:
              role_filter = self.members.has_role(role)
              return np.bincount(
                  self.members_entity_id[role_filter],
                  weights = array[role_filter],
                  minlength = self.count)
          else:
              return np.bincount(self.members_entity_id, weights = array)
docs: Return the sum of ``array`` for the members of the entity.
  
              ``array`` must have the dimension of the number of persons in the simulation
  
              If ``role`` is provided, only the entity member with the given role are taken into account.
  
              Example:
  
              >>> salaries = household.members('salary', '2018-01')  # e.g. [2000, 1500, 0, 0, 0]
              >>> household.sum(salaries)
              >>> array([3500])