spectralpython / spectral

Python module for hyperspectral image processing
MIT License
573 stars 139 forks source link

spylab.py throws AttributeError: 'dict' object has no attribute 'has_key' #56

Closed lewismc closed 7 years ago

lewismc commented 7 years ago

Using the Python3 branch, and running the following code, I get the above Error.

from spectral import *
img = spectral.open_image('avng.jpl.nasa.gov/AVNG_2015_data_distribution/L2/ang20150422t163638_rfl_v1e/ang20150422t163638_corr_v1e_img.hdr')
print(img)
# Data Source:   '././ang20150422t163638_corr_v1e_img'
#   # Rows:           4031
#   # Samples:         899
#   # Bands:           432
#   Interleave:        BIL
#   Quantization:  32 bits
#   Data format:   float32
view = imshow(img, (29, 19, 9))
print(view)
...
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-680f59826a83> in <module>()
----> 1 print(view)

/Users/lmcgibbn/miniconda3/lib/python3.5/site-packages/spectral-0.18-py3.5.egg/spectral/graphics/spypylab.py in __str__(self)
   1127             interp = self.interpolation
   1128         s += '  {0:<20}:  {1}\n'.format("Interpolation", interp)
-> 1129         if meta.has_key('rgb range'):
   1130             s += '  {0:<20}:\n'.format("RGB data limits")
   1131             for (c, r) in zip('RGB', meta['rgb range']):

AttributeError: 'dict' object has no attribute 'has_key'

This is due to has_key being removed in Python 3 see https://docs.python.org/3.1/whatsnew/3.0.html#builtins

lewismc commented 7 years ago

Thanks @tboggs