def _observe_members(self, change):
if self.size > 0 and self.attributes is not None and self.agent_type is not None:
if isinstance(self.attributes, Collection):
self.members = [self.agent_type(**a) for a in self.attributes]
elif isinstance(self.attributes, Generator):
self.members = [self.agent_type(**next(self.attributes)) for _ in range(self.size)]
elif isinstance(self.attributes, Callable):
self.members = [self.agent_type(**self.attributes()) for _ in range(self.size)]
else:
raise TraitError
评论列表
文章目录