Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_prob_models(backend):
tb, _ = backend
pyhf.probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
pyhf.probability.Normal(tb.astensor([10.0]), tb.astensor([1])).log_prob(
tb.astensor(2.0)
)
def test_joint(backend):
tb, _ = backend
p1 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
p2 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(3.0))
assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2])) == tb.tolist(
p1 + p2
)
def test_poisson(backend):
tb, _ = backend
result = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
assert result.shape == (1,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(tb.astensor(2.0))
assert result.shape == (2,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(
tb.astensor([2.0, 3.0])
)
assert result.shape == (2,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(
tb.astensor([[2.0, 3.0]])
)
assert result.shape == (1, 2)
def test_independent(backend):
tb, _ = backend
result = probability.Independent(
probability.Poisson(tb.astensor([10.0, 10.0]))
).log_prob(tb.astensor([2.0, 3.0]))
p1 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
p2 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(3.0))
assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist(
result
)
assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist(
result
)
def test_poisson(backend):
tb, _ = backend
result = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
assert result.shape == (1,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(tb.astensor(2.0))
assert result.shape == (2,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(
tb.astensor([2.0, 3.0])
)
assert result.shape == (2,)
result = probability.Poisson(tb.astensor([10.0, 10.0])).log_prob(
tb.astensor([[2.0, 3.0]])
)
assert result.shape == (1, 2)
def test_independent(backend):
tb, _ = backend
result = probability.Independent(
probability.Poisson(tb.astensor([10.0, 10.0]))
).log_prob(tb.astensor([2.0, 3.0]))
p1 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0))
p2 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(3.0))
assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist(
result
)
assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist(
result
)