Skip to content

Interpolated class missing bound_args_indices #5048

Closed
@FabiJa

Description

@FabiJa

Hi,
a have a problem with the Interpolated class in the development branch. As a starting point I tried the example from the source:

import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
import arviz as az
from scipy.stats import gamma
plt.style.use('arviz-darkgrid')
rv = gamma(1.99)
x = np.linspace(rv.ppf(0.01),rv.ppf(0.99), 1000)
points = np.linspace(x[0], x[-1], 50)
pdf = rv.pdf(points)
interpolated = pm.Interpolated.dist(points, pdf)
fig, ax = plt.subplots(1, 1)
ax.plot(x, rv.pdf(x), 'C0', linestyle = '--',  label='Original Gamma pdf',alpha=0.8,lw=2)
ax.plot(points, pdf, color='black', marker='o', label='Lattice Points',alpha=0.5,linestyle='')
ax.plot(x, np.exp(interpolated.logp(x).eval()),'C1',label='Interpolated pdf',alpha=0.8,lw=3)
r = interpolated.random(size=1000)
ax.hist(r, density=True, alpha=0.4,align ='mid',color='grey')
ax.legend(loc='best', frameon=False)
plt.show()

I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_5967/2908023609.py in <module>
     13 ax.plot(x, rv.pdf(x), 'C0', linestyle = '--',  label='Original Gamma pdf',alpha=0.8,lw=2)
     14 ax.plot(points, pdf, color='black', marker='o', label='Lattice Points',alpha=0.5,linestyle='')
---> 15 ax.plot(x, np.exp(interpolated.logp(x).eval()),'C1',label='Interpolated pdf',alpha=0.8,lw=3)
     16 r = interpolated.random(size=1000)
     17 ax.hist(r, density=True, alpha=0.4,align ='mid',color='grey')

~/anaconda3/envs/pymc3_jax/lib/python3.9/site-packages/pymc/distributions/distribution.py in fn(*args, **kwargs)
    128 def _make_nice_attr_error(oldcode: str, newcode: str):
    129     def fn(*args, **kwargs):
--> 130         raise AttributeError(f"The `{oldcode}` method was removed. Instead use `{newcode}`.`")
    131 
    132     return fn

AttributeError: The `rv.logp(x)` method was removed. Instead use `pm.logp(rv, x)`.

Any advice?
Thx.

  • PyMC3 Version: main

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions