def test_compute_mean_curve_invalid_weights(self): curves = [ [1.0, 0.85, 0.67, 0.3], [0.87, 0.76, 0.59, 0.21], [0.62, 0.41, 0.37, 0.0], ] weights = [0.6, None, 0.4] with self.assertRaises(TypeError): # None is not a valid weight mean_curve(curves, weights)
def test_mean_std(self): values = [[5, 4], [10, 9], [8, 7]] weights = [.2, .3, .5] mean = mean_curve(values, weights) std = std_curve(values, weights) aaae(mean, [8, 7]) aaae(std, [1.73205081, 1.73205081])
def test_compute_mean_curve(self): curves = [ [1.0, 0.85, 0.67, 0.3], [0.87, 0.76, 0.59, 0.21], [0.62, 0.41, 0.37, 0.0], ] expected_mean_curve = numpy.array([0.83, 0.67333333, 0.54333333, 0.17]) numpy.testing.assert_allclose(expected_mean_curve, mean_curve(curves))
def test_compute_mean_curve_weighted(self): curves = [ [1.0, 0.85, 0.67, 0.3], [0.87, 0.76, 0.59, 0.21], [0.62, 0.41, 0.37, 0.0], ] weights = [0.5, 0.3, 0.2] expected_mean_curve = numpy.array([0.885, 0.735, 0.586, 0.213]) numpy.testing.assert_allclose( expected_mean_curve, mean_curve(curves, weights=weights))
def test_compute_mean_curve_weights_None(self): # If all weight values are None, ignore the weights altogether curves = [ [1.0, 0.85, 0.67, 0.3], [0.87, 0.76, 0.59, 0.21], [0.62, 0.41, 0.37, 0.0], ] weights = None expected_mean_curve = numpy.array([0.83, 0.67333333, 0.54333333, 0.17]) numpy.testing.assert_allclose( expected_mean_curve, mean_curve(curves, weights=weights))