class_docstr: Tests for pm.Bound distribution
class_docstr_tok: ["Tests","for","pm.Bound","distribution"]
code: def test_discrete(self):
      with pm.Model() as model:
          dist = pm.Poisson.dist(mu=4)
          with pytest.warns(
              FutureWarning, match="Bound has been deprecated"
          ):
              with warnings.catch_warnings():
                  warnings.filterwarnings(
                      "ignore",
                      "invalid value encountered in add",
                      RuntimeWarning,
                  )
                  UnboundedPoisson = pm.Bound("unbound", dist)
              LowerPoisson = pm.Bound("lower", dist, lower=1)
              UpperPoisson = pm.Bound("upper", dist, upper=10)
              BoundedPoisson = pm.Bound(
                  "bounded", dist, lower=1, upper=10
              )
  
      assert (
          model.compile_fn(model.logp(LowerPoisson), point_fn=False)(0)
          == -np.inf
      )
      assert (
          model.compile_fn(model.logp(UpperPoisson), point_fn=False)(11)
          == -np.inf
      )
      assert (
          model.compile_fn(model.logp(BoundedPoisson), point_fn=False)(
              0
          )
          == -np.inf
      )
      assert (
          model.compile_fn(model.logp(BoundedPoisson), point_fn=False)(
              11
          )
          == -np.inf
      )
  
      assert (
          model.compile_fn(
              model.logp(UnboundedPoisson), point_fn=False
          )(0)
          != -np.inf
      )
      assert (
          model.compile_fn(
              model.logp(UnboundedPoisson), point_fn=False
          )(11)
          != -np.inf
      )
  
      ref_dist = pm.Poisson.dist(mu=4)
      assert np.allclose(
          model.compile_fn(
              model.logp(UnboundedPoisson), point_fn=False
          )(5),
          pm.logp(ref_dist, 5).eval(),
      )
      assert np.allclose(
          model.compile_fn(model.logp(LowerPoisson), point_fn=False)(5),
          pm.logp(ref_dist, 5).eval(),
      )
      assert np.allclose(
          model.compile_fn(model.logp(UpperPoisson), point_fn=False)(5),
          pm.logp(ref_dist, 5).eval(),
      )
      assert np.allclose(
          model.compile_fn(model.logp(BoundedPoisson), point_fn=False)(
              5
          ),
          pm.logp(ref_dist, 5).eval(),
      )
  
file_path: pymc/tests/distributions/test_bound.py
imports: import warnings
  import numpy
  import pytest
  import scipy.stats
  from pytensor.tensor.random.op import RandomVariable
  import pymc
label_desc: Use image node_id 2 for calling the TestBound obj's underlying member method code with example usage: obj.test_discrete() without return types