Skip to content

Commit

Permalink
fix up again more with prints/list...
Browse files Browse the repository at this point in the history
  • Loading branch information
kratsg committed Dec 22, 2024
1 parent 94e959f commit 2b21a04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/pyhf/infer/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def cdf(self, value):
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> bkg_dist = pyhf.infer.calculators.AsymptoticTestStatDistribution(0.0)
>>> bkg_dist.cdf(0.0)
np.float64(0.5)
>>> print(bkg_dist.cdf(0.0))
0.5
Args:
value (:obj:`float`): The test statistic value.
Expand Down Expand Up @@ -619,8 +619,8 @@ def expected_value(self, nsigma):
>>> normal = pyhf.probability.Normal(mean, std)
>>> samples = normal.sample((100,))
>>> dist = pyhf.infer.calculators.EmpiricalDistribution(samples)
>>> dist.expected_value(nsigma=1)
np.float64(6.15094381...)
>>> print(dist.expected_value(nsigma=1))
6.15094381...
>>> import pyhf
>>> import numpy.random as random
Expand Down
8 changes: 4 additions & 4 deletions src/pyhf/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ def log_prob(self, value):
>>> poissons = pyhf.probability.Poisson(rates)
>>> independent = pyhf.probability.Independent(poissons)
>>> values = pyhf.tensorlib.astensor([8.0, 9.0])
>>> independent.log_prob(values)
np.float64(-4.26248380...)
>>> print(independent.log_prob(values))
-4.26248380...
>>> broadcast_value = pyhf.tensorlib.astensor([11.0])
>>> independent.log_prob(broadcast_value)
np.float64(-4.34774364...)
>>> print(independent.log_prob(broadcast_value))
-4.34774364...
Args:
value (:obj:`tensor` or :obj:`float`): The value at which to evaluate the distribution
Expand Down
22 changes: 11 additions & 11 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ def percentile(
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> a = pyhf.tensorlib.astensor([[10, 7, 4], [3, 2, 1]])
>>> pyhf.tensorlib.percentile(a, 50)
np.float64(3.5)
>>> print(pyhf.tensorlib.percentile(a, 50))
3.5
>>> pyhf.tensorlib.percentile(a, 50, axis=1)
array([7., 2.])
Expand Down Expand Up @@ -380,11 +380,11 @@ def simple_broadcast(self, *args: Sequence[Tensor[T]]) -> Sequence[Tensor[T]]:
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> pyhf.tensorlib.simple_broadcast(
>>> list(pyhf.tensorlib.simple_broadcast(
... pyhf.tensorlib.astensor([1]),
... pyhf.tensorlib.astensor([2, 3, 4]),
... pyhf.tensorlib.astensor([5, 6, 7]))
(array([1., 1., 1.]), array([2., 3., 4.]), array([5., 6., 7.]))
... pyhf.tensorlib.astensor([5, 6, 7])))
[array([1., 1., 1.]), array([2., 3., 4.]), array([5., 6., 7.])]
Args:
args (Array of Tensors): Sequence of arrays
Expand Down Expand Up @@ -466,8 +466,8 @@ def poisson(self, n: Tensor[T], lam: Tensor[T]) -> ArrayLike:
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> pyhf.tensorlib.poisson(5., 6.)
np.float64(0.16062314...)
>>> print(pyhf.tensorlib.poisson(5., 6.))
0.16062314...
>>> values = pyhf.tensorlib.astensor([5., 9.])
>>> rates = pyhf.tensorlib.astensor([6., 8.])
>>> pyhf.tensorlib.poisson(values, rates)
Expand Down Expand Up @@ -509,8 +509,8 @@ def normal(self, x: Tensor[T], mu: Tensor[T], sigma: Tensor[T]) -> ArrayLike:
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> pyhf.tensorlib.normal(0.5, 0., 1.)
np.float64(0.35206532...)
>>> print(pyhf.tensorlib.normal(0.5, 0., 1.))
0.35206532...
>>> values = pyhf.tensorlib.astensor([0.5, 2.0])
>>> means = pyhf.tensorlib.astensor([0., 2.3])
>>> sigmas = pyhf.tensorlib.astensor([1., 0.8])
Expand All @@ -537,8 +537,8 @@ def normal_cdf(
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> pyhf.tensorlib.normal_cdf(0.8)
np.float64(0.78814460...)
>>> print(pyhf.tensorlib.normal_cdf(0.8))
0.78814460...
>>> values = pyhf.tensorlib.astensor([0.8, 2.0])
>>> pyhf.tensorlib.normal_cdf(values)
array([0.7881446 , 0.97724987])
Expand Down

0 comments on commit 2b21a04

Please sign in to comment.