joewandy / hlda

Gibbs sampler for the Hierarchical Latent Dirichlet Allocation topic model
GNU General Public License v3.0
147 stars 38 forks source link

Python 3 incompatibility #1

Open tmthyjames opened 6 years ago

tmthyjames commented 6 years ago

Doing

from hlda.sampler import HierarchicalLDA

produces the following error

  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/hlda/sampler.py", line 189
    print 'HierarchicalLDA sampling'
                                   ^
SyntaxError: Missing parentheses in call to 'print'
bwang482 commented 6 years ago

@tmthyjames then you should edit the sampler.py file to make sure it is compatible with python3, e.g. print('HierarchicalLDA sampling')

joewandy commented 6 years ago

I'll finally stop being a relic and ready to join python 3! Let me take a look at this in the coming few days

On 1 Mar 2018 1:18 am, "bluemonk482" notifications@github.com wrote:

@tmthyjames https://github.com/tmthyjames then you should edit the sampler.py file to make sure it is compatible with python3, e.g. print('HierarchicalLDA sampling')

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joewandy/hlda/issues/1#issuecomment-369441717, or mute the thread https://github.com/notifications/unsubscribe-auth/ACaA_xipQO30yBSmhI3eBsb7aVJWlexcks5tZ0x3gaJpZM4R1zzb .

jreades commented 5 years ago

It would be helpful to check a few things (the string formatting could use an update to Python3 and then testing) but I've got this running under Python3 on a fork: https://github.com/jreades/hlda

I can submit a pull request but I suspect that it would be best to tag your current stable version and/or create a Py3 branch before pulling in my changes.

BTW -- great piece of code and demo. Having struggled for quite some time to make sense of topic models and to get many different bits of code to play nicely I literally only had to fix a few print statements and I was up and running with my own data.

tmthyjames commented 5 years ago

@bluemonk482 that's not the point. one 2.7 print statement is indicative of other 2.7-3.* incompatibilities.

@joewandy sounds good! btw, great library you got here!

jreades commented 5 years ago

After fixing the print statements I ran python -3 sampler.py using the default 2.7 installation on my Mac (I do everything in Anaconda) and it only complained that:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/__init__.py:6: DeprecationWarning: CObject type is not supported in 3.x. Please use capsule objects instead.
  from . import multiarray
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/__init__.py:7: DeprecationWarning: CObject type is not supported in 3.x. Please use capsule objects instead.
  from . import umath

The code then appeared to execute correctly and the results I obtained on the provided seemed reasonable. It looks 2to3 would be another way to explore any issues.