def test_kernel_model_sample():
    """Test borg.models.KernelModel.sample()."""

    successes = numpy.array([[0, 1], [1, 0], [0, 0]], numpy.intc)
    failures = numpy.array([[0, 0], [0, 0], [0, 1]], numpy.intc)
    durations = \
        numpy.array([
            [[numpy.nan], [42.0]],
            [[24.0], [numpy.nan]],
            [[numpy.nan], [numpy.nan]],
            ])
    kernel = borg.models.DeltaKernel()
    alpha = 1.0 + 1e-8
    model = borg.models.KernelModel(successes, failures, durations, 100.0, alpha, kernel)
    samples = model.sample(16, 4)

    nose.tools.assert_true(numpy.all(numpy.logaddexp.reduce(samples, axis = -1) < 1e-10))
    nose.tools.assert_true(numpy.any(numpy.abs(samples[..., 0] - numpy.log((alpha) / (5 * alpha - 4))) < 1e-10))
    nose.tools.assert_true(numpy.any(numpy.abs(samples[..., -1] - numpy.log(1.0 / 5)) < 1e-10))
    nose.tools.assert_true(numpy.any(numpy.abs(samples[..., -1] - numpy.log((alpha) / (5 * alpha - 4))) < 1e-10))
    nose.tools.assert_true(numpy.any(numpy.abs(samples[..., -1] - numpy.log((alpha - 1) / (4 - 5 * alpha))) < 1e-10))
dataset/ETHPy150Open borg-project/borg/borg/test/test_models.py/test_kernel_model_sample/swapped operands of `-`