HIPS / pgmult

Dependent multinomials made easy: stick-breaking with the Pólya-gamma augmentation
MIT License
59 stars 22 forks source link

Import issues #6

Closed hedgy123 closed 8 years ago

hedgy123 commented 8 years ago

Hi, I am having trouble getting pgmult to work (Python 3.5 on Mac OS X Yosemite). Specifically:

   from pgmult.utils import pi_to_psi, psi_to_pi, ln_pi_to_psi

gives me an error about pypolyagamma:

  from pypolyagamma import PyRNG, PyPolyaGamma, pdgrawvpar, get_omp_num_threads

The error is "no such name PyRNG". So I changed this to

   from pypolyagamma.pypolyagamma import PyRNG, PyPolyaGamma, pdgrawvpar, get_omp_num_threads

in the corresponding init.py. That fixed this error, but now I am having problems with import pgmult.gp

 ---> 29 import pgmult.gp
      30 reload(pgmult.gp)
      31 

      /Users/<USERNAME>/pgmult/pgmult/gp.py in <module>()
      13 
      14 PROFILING = False
 ---> 15 from pgmult.utils.profiling import line_profiled
      16 from .internals.utils import \
      17     kappa_vec, N_vec, psi_to_pi, pi_to_psi, ln_psi_to_pi, ln_pi_to_psi, \

      ImportError: No module named 'pgmult.utils.profiling'; 'pgmult.utils' is not a package

Your help would be greatly appreciated!

slinderman commented 8 years ago

Thanks for pointing this out! Sorry, we left the code in a bit of a messy state after our last project. I just cleaned up a few imports, so the imports in pgmult.gp should be ok now.

As for the pypolyagamma imports, I believe those were fixed in https://github.com/slinderman/pypolyagamma/commit/809b2c22a1882e288f2d664ad7b756b029a5fbf7. Can you make sure you have the latest pypolyagamma?

If all is working, the pgmult test, test/geweke_test_gp.py should run successfully.

Thanks again, Scott

hedgy123 commented 8 years ago

Thanks Scott. I am afraid the new version still has import issues though:

<ipython-input-4-d3ba56e2c5cd> in <module>()
     18 
     19 from pgmult.utils import pi_to_psi, psi_to_pi, ln_pi_to_psi
---> 20 import pgmult.gp
     21 reload(pgmult.gp)
     22 

/Users/<USERNAME>/pgmult/pgmult/gp.py in <module>()
     18 import pypolyagamma as ppg
     19 
---> 20 from hips.inference.elliptical_slice import elliptical_slice
     21 
     22 #TODO: Factor out reusable parts of the GP models

   ImportError: No module named 'hips'

I tried cloning hips-libs/hips but was unable to.

hedgy123 commented 8 years ago

Also, for python 3 I believe you want these two lines:

   from urllib import urlretrieve
   import cPickle as pickle

to be

  from urllib.request import urlretrieve
  import six.moves.cPickle as pickle
hedgy123 commented 8 years ago

I got it to work in python 3.