def compartments_for(self, flowables, quantity): """ :param flowables: an iterable of flowables :param quantity: a quantity to inspect :return: a sorted list of compartments (sorted by compartment.to_list() """ q = get_entity_uuid(quantity) cmps = set() for i in flowables: for k in self._f_dict[(i, q)].compartments(): if isinstance(k, Compartment): cmps.add(k) return sorted(cmps, key=lambda x: x.to_list())
def factors_for_quantity(self, quantity): """ Finally, my text mode chart expertise pays off! :param quantity: :return: """ q = get_entity_uuid(quantity) rows = sorted(self._q_dict[q], key=lambda x: self.flowables.name(x)) cols = self.compartments_for(rows, quantity) print('%s' % quantity) print('Characterization Factors\n ') dynamic_grid(cols, rows, lambda x, y: self._f_dict[(x, q)][y], ('CAS Number ', lambda x: self.flowables.cas(x)), ('Flowable', lambda x: self.flowables.name(x)), returns_sets=True)