def test_calculate(mus, flags, expected): # type: (List[float], Dict[str, bool], Dict[str, List[float]]) -> None s_weights, s_mus, s_sigmas = \ _ParzenEstimator._calculate(mus, -1.0, 1.0, prior_weight=1.0, consider_prior=flags['prior'], consider_magic_clip=flags['magic_clip'], consider_endpoints=flags['endpoints'], weights_func=default_weights) # Result contains an additional value for a prior distribution if consider_prior is True. np.testing.assert_almost_equal(s_weights, expected['weights']) np.testing.assert_almost_equal(s_mus, expected['mus']) np.testing.assert_almost_equal(s_sigmas, expected['sigmas'])
def test_calculate_shape_check(mus, prior, magic_clip, endpoints): # type: (List[float], bool, bool, bool) -> None s_weights, s_mus, s_sigmas = \ _ParzenEstimator._calculate(mus, -1.0, 1.0, prior_weight=1.0, consider_prior=prior, consider_magic_clip=magic_clip, consider_endpoints=endpoints, weights_func=default_weights) # Result contains an additional value for a prior distribution if prior is True. assert len(s_weights) == len(mus) + int(prior) assert len(s_mus) == len(mus) + int(prior) assert len(s_sigmas) == len(mus) + int(prior)