siavashk / pycpd

Pure Numpy Implementation of the Coherent Point Drift Algorithm
MIT License
513 stars 115 forks source link

Python3.6 Error + Hack #6

Closed alvinwan closed 7 years ago

alvinwan commented 7 years ago

I got the following errors when working with Python3. The package as-is has no problems with Python2 on my system though.

Traceback (most recent call last):
  File "src/label.py", line 21, in <module>
    from cpd import cpd
  File "/Users/alvinwan/Documents/Aspire/pcmatch/src/cpd.py", line 1, in <module>
    from pycpd import rigid_registration
  File "/Users/alvinwan/anaconda3/envs/matching/lib/python3.6/site-packages/pycpd/__init__.py", line 1, in <module>
    from affine_registration import affine_registration
ModuleNotFoundError: No module named 'affine_registration'

I fixed it by using relative imports:

from .affine_registration import affine_registration
from .rigid_registration import rigid_registration
from .deformable_registration import deformable_registration

Food for thought. I considered making another fork and pushing pycpd3 to pip, but I wanted your @siavashk thoughts/permission first. I think the change would break Python2 compatibility.

siavashk commented 7 years ago

Oooh. Interesting. To be honest, I never tested it with Python 3 (I should have, my bad), but kudos to you for reporting this.

I have released pycpd under MIT license, so you don’t really need my permission. But I think it might be a better idea if pycpd worked out of the box for both Python 2 and 3.

If you fork and submit a pull request, I will review it and release a new version of pycpd with your contribution marked in the release notes.

siavashk commented 7 years ago

Your changes work Python 2 as well. I will update the repository and the package manager. Thanks.

siavashk commented 7 years ago

Fixed in d9ee14999d726829caeda2c1ef206a86b0c2ac2e

Note that the fix will not appear on Pypi package manager until I upload it. But installation from source should be fine.

alvinwan commented 7 years ago

@siavashk sick thanks!

siavashk commented 7 years ago

Changes are now available on Pypi.