spectralpython / spectral

Python module for hyperspectral image processing
MIT License
563 stars 138 forks source link

[AttributeError: module 'numpy' has no attribute 'asscalar'] when calling read_datum on an ImageArray object #139

Closed mhmdjouni closed 1 year ago

mhmdjouni commented 1 year ago

Hello,

I was running a code snippet to call read_datum() on an ImageArray object, for example: hsi_arr.read_datum(i=350, j=250, k=70) where hsi_arr is an ImageArray object

and the following error occurs:

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pypespoc-uXjjbsMt-py3.10\lib\site-packages\spectral\image.py:164, in ImageArray.read_datum(self, i, j, k)
    162 def read_datum(self, i, j, k):
    163     '''For SpyFile compatibility. Equivlalent to arr[i, j, k]'''
--> 164     return np.asscalar(self[i, j, k])

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pypespoc-uXjjbsMt-py3.10\lib\site-packages\numpy\__init__.py:311, in __getattr__(attr)
    308     from .testing import Tester
    309     return Tester
--> 311 raise AttributeError("module {!r} has no attribute "
    312                      "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute 'asscalar'

Following this page, it says: Deprecated since version 1.16: Deprecated, use numpy.ndarray.item() instead.