def test_fast_mean_with_empty_list_returns_zero(self): # Arrange values = np.asarray([], dtype=np.float64) # Act result = fast_mean(values) # Assert assert result == 0
def test_fast_mean_with_values(self): # Arrange values = np.asarray([0.0, 1.1, 2.2, 3.3, 4.4, 5.5], dtype=np.float64) # Act result = fast_mean(values) # Assert assert result == 2.75 assert np.mean(values) == 2.75
def test_fast_mean_iterated_with_values(self): # Arrange values1 = np.asarray([0.0, 1.1, 2.2], dtype=np.float64) values2 = np.asarray([0.0, 1.1, 2.2, 3.3, 4.4], dtype=np.float64) # Act result1 = fast_mean_iterated(values1, 0.0, fast_mean(values1), 5) result2 = fast_mean_iterated(values2, 5.5, np.mean(values2), 5) # Assert assert result1 == np.mean([0.0, 1.1, 2.2]) assert result2 == 3.3000000000000003
def test_std_dev_with_mean(self): # Arrange values = np.asarray([0.0, 1.1, 2.2, 3.3, 4.4, 8.1, 9.9, -3.0], dtype=np.float64) mean = fast_mean(values) # Act result1 = fast_std(values) result2 = fast_std_with_mean(values, mean) # Assert assert result1 == np.std(values) assert result2 == np.std(values) assert result1 == 3.943665807342199 assert result2 == 3.943665807342199