stefanloock / pyshearlab

pyShearLab is a Python toolbox which is based on ShearLab3D written by Rafael Reisenhofer and has been ported to Python by Stefan Loock.
GNU General Public License v3.0
49 stars 15 forks source link

pyShearLab does not work with Python 2.X #1

Closed stefanloock closed 7 years ago

stefanloock commented 7 years ago

Due to a bug in SLgetWedgeBandpassAndLowpassFilters2D located in the pySLUtilities.py, pyShearLab currently does not work with Python versions below 3.0:

File "pySLUtilities.py", line 543, in SLgetWedgeBandpassAndLowpassFilters2D filterLow2[-1-shearLevel].shape = (1, len(filterLow2[-1-shearLevel])) ValueError: cannot reshape array of size 9 into shape (1,1)

identidata commented 7 years ago

this happens because in python 2 you need to add a dot to the divisor to get a float number.

In python 3.X

>>> 3 / 2
1.5

in python 2.x

>>> 3/2
1

to get a float quotient in python 2.x you need to do

>>> 3/2.
1.5

so change line 154 in pyShearLab2D.py, function SLgetShearletSystem2D from

shearLevels = np.ceil(np.arange(1,nScales+1)/2).astype(int)

to

shearLevels = np.ceil(np.arange(1,nScales+1)/2.).astype(int) 

and build again