def test_from_weighted_mean(self): qlist = [ Quantity(self.custom_symbol, val) for val in np.arange(1, 2.01, 0.01) ] qagg = Quantity.from_weighted_mean(qlist) self.assertAlmostEqual(qagg.magnitude, 1.5) self.assertAlmostEqual(qagg.uncertainty, 0.2915475947422652)
def get_aggregated_quantities(self): """ Return mean values for all quantities for each symbol. Returns: (dict<Symbol, weighted_mean) mapping from a Symbol to an aggregated statistic. """ # TODO: proper weighting system, and more flexibility in object handling aggregated = {} for symbol, quantities in self._symbol_to_quantity.items(): if not symbol.category == 'object': aggregated[symbol] = Quantity.from_weighted_mean( list(quantities)) return aggregated