def test_can_compute_begining_moment(self): # Arrange stat = StatisticalValues([1, 2, 3, 2]) # Act bmoment = stat.begining_moment(k=1) # Assert self.assertEqual(bmoment, 2.0)
def compute(self): try: calculator = StatisticalValues(self.x) if (self.statistic == 'mean'): self.result = calculator.mean() elif (self.statistic == 'variance'): self.result = calculator.variance() elif (self.statistic == 'median'): self.result = calculator.median() elif (self.statistic == 'begining moment'): self.result = calculator.begining_moment(self.k) elif (self.statistic == 'central moment'): self.result = calculator.central_moment(self.k) except Exception as exp: self.error_msg = "Error: {}". format(exp)
def compute(self): try: calculator = StatisticalValues(self.x) if (self.statistic == 'mean'): self.result = calculator.mean() elif (self.statistic == 'variance'): self.result = calculator.variance() elif (self.statistic == 'median'): self.result = calculator.median() elif (self.statistic == 'begining moment'): self.result = calculator.begining_moment(self.k) elif (self.statistic == 'central moment'): self.result = calculator.central_moment(self.k) self.logger.log( "Statistics with name `{}` was calculated. Result value is {}". format(self.statistic, self.result)) except Exception as exp: self.error_msg = "Error: {}".format(exp) self.logger.log(self.error_msg)
def test_bmoment_raises_on_neg_k(self): # Arrange stat = StatisticalValues([1, 2, 3, 2]) # Act & Assert with self.assertRaises(ValueError): stat.begining_moment(k=-1)