pymc-devs / pymc-bart

https://www.pymc.io/projects/bart
Other
87 stars 17 forks source link

Import issue pymc 5.0.2 #42

Closed juanitorduz closed 1 year ago

juanitorduz commented 1 year ago

Hi! I am having an issue importing pymc_bart

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 8
      6 import pandas as pd
      7 import pymc as pm
----> 8 import pymc_bart as pmb
      9 import pytensor.tensor as pt
     10 import seaborn as sns

File ~/.local/share/virtualenvs/martech-notebooks-HvCbrrBM/lib/python3.10/site-packages/pymc_bart/__init__.py:17
     14 import pymc as pm
     16 from pymc_bart.bart import BART
---> 17 from pymc_bart.pgbart import PGBART
     18 from pymc_bart.utils import plot_dependence, plot_variable_importance
     20 __all__ = ["BART", "PGBART"]

File ~/.local/share/virtualenvs/martech-notebooks-HvCbrrBM/lib/python3.10/site-packages/pymc_bart/pgbart.py:27
     24 from pytensor.tensor.var import Variable
     26 from pymc.model import modelcontext
---> 27 from pymc.step_methods.arraystep import ArrayStepShared, Competence
     28 from pymc.pytensorf import inputvars, join_nonshared_inputs, make_shared_replacements
     31 from pymc_bart.bart import BARTRV

ImportError: cannot import name 'Competence' from 'pymc.step_methods.arraystep' (/Users/juanitorduz/.local/share/virtualenvs/martech-notebooks-HvCbrrBM/lib/python3.10/site-packages/pymc/step_methods/arraystep.py)

I think a recent in pymc (https://github.com/pymc-devs/pymc/commit/10c66b4a418f5bab3693d42e2e468808aafe2c9a) has conflicts with https://github.com/pymc-devs/pymc-bart/blob/main/pymc_bart/pgbart.py#L27

I could try to create a PR but I do not know how to handle backward compatibility.

aloctavodia commented 1 year ago

Hi!, thanks for reporting and offering to do a PR.

So far we have been trying to keep pymc-bart on sync with the latest release of pymc, so maybe we just make the change. Alternatively, I guess we can check against pm.version and then do one or the other import.