def test_can_compute_var_one_element(self):
     # Arrange
     stat = StatisticalValues(1)
     # Act
     var = stat.variance()
     # Assert
     self.assertEqual(var, 0)
 def test_can_compute_var(self):
     # Arrange
     stat = StatisticalValues([1, 2, 3, 2])
     # Act
     var = stat.variance()
     # Assert
     self.assertEqual(var, 0.5)
 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)