def test_calc_multi(self): x = Quantity((7,8,9), (1,1,2)) sq = lambda a: a**2 dr = lambda a: 2*a self.assertQuantity(x.calc(sq, dr), (7**2,8**2,9**2), (2*1*7,2*1*8,2*2*9) )
def test_calc(self): x = Quantity(7, 3) y = Quantity(7, 3, 'm') sq = lambda a: a**2 dr = lambda a: 2*a pu = lambda a: list(range(8)) self.assertQuantity(x.calc(sq, dr), 49, 42) self.assertQuantity(x.calc(sq, 2*7), 49, 42) self.assertQuantity(x.calc(sq), 49, 42) self.assertQuantity(y.calc(sq, dr, reqUnitless=False), 49, 42) self.assertQuantity(y.calc(sq, dr, reqUnitless=False, propagateUnit=1), 49, 42, self.METER) self.assertQuantity(y.calc(sq, dr, reqUnitless=False, propagateUnit=2), 49, 42, [2]+[0]*7) self.assertQuantity(y.calc(sq, dr, reqUnitless=False, propagateUnit=pu), 49, 42, list(range(8)))