def test_setitem3(): outcomes = (0, 1) pmf = [1 / 2, 1 / 2] d = ScalarDistribution(outcomes, pmf, sample_space=(0, 1, 2)) d[2] = 1 / 2 d.normalize() assert_array_almost_equal(d.pmf, [1 / 3] * 3)
def test_setitem3(): outcomes = (0, 1) pmf = [1 / 2, 1 / 2] d = ScalarDistribution(outcomes, pmf, sample_space=(0, 1, 2)) d[2] = 1 / 2 d.normalize() assert np.allclose(d.pmf, [1 / 3] * 3)
def test_del2(): d = ScalarDistribution([1 / 2, 1 / 2]) d.make_dense() del d[1] d.normalize() assert d[0] == pytest.approx(1)
def test_del2(): d = ScalarDistribution([1 / 2, 1 / 2]) d.make_dense() del d[1] d.normalize() assert_almost_equal(d[0], 1)
def test_del1(): d = ScalarDistribution([1 / 2] * 2) del d[1] d.normalize() assert d[0] == pytest.approx(1)