ajdawson / windspharm

A Python library for spherical harmonic computations on vector winds.
http://ajdawson.github.io/windspharm
MIT License
82 stars 38 forks source link

Python 3 support? #51

Closed fmaussion closed 8 years ago

fmaussion commented 8 years ago

Hi,

thanks for this nice package! It would be great to have a statement on the README page about which versions of python windspharm does support. Installating the latest master with pip on python 3.4 worked fine, but I get two test errors (see log below).

Do you think there will be other problems when using windspharm with python 3?

[c7071047@zid-gpl windspharm-master]$ nosetests .
SS..........SSSSSS....................................E..E.
======================================================================
ERROR: windspharm.tests.test_tools.TestTools.test_get_recovery
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/scratch/c707/c7071047/miniconda3/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/scratch/c707/c7071047/packages/windspharm-master/lib/windspharm/tests/test_tools.py", line 47, in test_get_recovery
    ur1 = recover_data(up, uinfo)
  File "/scratch/c707/c7071047/packages/windspharm-master/lib/windspharm/tools.py", line 148, in recover_data
    for i in xrange(len(rolldims)):
NameError: name 'xrange' is not defined

======================================================================
ERROR: windspharm.tests.test_tools.TestTools.test_prep_recover_data
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/scratch/c707/c7071047/miniconda3/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/scratch/c707/c7071047/packages/windspharm-master/lib/windspharm/tests/test_tools.py", line 40, in test_prep_recover_data
    ur = recover_data(up, uinfo)
  File "/scratch/c707/c7071047/packages/windspharm-master/lib/windspharm/tools.py", line 148, in recover_data
    for i in xrange(len(rolldims)):
NameError: name 'xrange' is not defined

----------------------------------------------------------------------
Ran 51 tests in 2.536s

FAILED (SKIP=8, errors=2)
ajdawson commented 8 years ago

The package is tested against Python 2.7, 3.3 and 3.4 so you should be OK. I'll add something to the documentation to help users know this.

The Python 3 support consists of using the 2to3 tool to convert the source to Python 3 compatible before installation (setuptools/pip does this automatically when installing).

The reason you see the test failure is you are testing against the source code which is written for Python 2, on Python 3 you should test the the installed version. You can do this after you have installed windspharm by going into some directory that is not the windspharm directory (or another Python code directory) and naming the package on the nosetests command line:

mkdir ~/test_directory
cd ~/test_directory
nosetests windspharm -sv
fmaussion commented 8 years ago

Perfect! It works. Thanks