Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indices of wrong type for NumPy 1.12+ #32

Open
kwinkunks opened this issue Jan 2, 2018 · 1 comment
Open

Indices of wrong type for NumPy 1.12+ #32

kwinkunks opened this issue Jan 2, 2018 · 1 comment

Comments

@kwinkunks
Copy link
Member

Since NumPy v1.12, indexing ndarray with the wrong type (e.g. a float) raises IndexError. I think that's what's happening here.

The example code:

from PyQt4.QtGui import QApplication
import segyviewlib
qapp = QApplication([])
l = segyviewlib.segyviewwidget.SegyViewWidget(fname)
l.show()

...results in:


IndexError                                Traceback (most recent call last)
<ipython-input-9-e587dc28b0c1> in <module>()
      2 import segyviewlib
      3 qapp = QApplication([])
----> 4 l = segyviewlib.segyviewwidget.SegyViewWidget(fname)
      5 l.show()

~/anaconda/envs/python36/lib/python3.6/site-packages/segyviewlib-1.1.3.dev2+gc4b38be-py3.6.egg/segyviewlib/segyviewwidget.py in __init__(self, filename, show_toolbar, color_maps, width, height, dpi, segyioargs, parent)
     19         self._slice_data_source = slice_data_source
     20 
---> 21         self._context = SliceViewContext(slice_models, slice_data_source)
     22         self._context.show_indicators(True)
     23 

~/anaconda/envs/python36/lib/python3.6/site-packages/segyviewlib-1.1.3.dev2+gc4b38be-py3.6.egg/segyviewlib/sliceviewcontext.py in __init__(self, slice_models, slice_data_source, colormap, interpolation, image_size, has_data)
     77 
     78         if self._has_data:
---> 79             self._assign_indexes()
     80 
     81             for model in self._available_slice_models:

~/anaconda/envs/python36/lib/python3.6/site-packages/segyviewlib-1.1.3.dev2+gc4b38be-py3.6.egg/segyviewlib/sliceviewcontext.py in _assign_indexes(self)
    242             m.x_indexes = list(self._slice_data_source.indexes_for_direction(m.x_index_direction))
    243             m.y_indexes = list(self._slice_data_source.indexes_for_direction(m.y_index_direction))
--> 244             data = self._slice_data_source.read_slice(m.index_direction, m.index)
    245             m.data = data
    246 

~/anaconda/envs/python36/lib/python3.6/site-packages/segyviewlib-1.1.3.dev2+gc4b38be-py3.6.egg/segyviewlib/slicedatasource.py in read_slice(self, direction, index)
    114     def read_slice(self, direction, index):
    115         if direction == SliceDirection.inline:
--> 116             iline_index = self._source.ilines[index]
    117             return self._source.iline[iline_index].T
    118         elif direction == SliceDirection.crossline:

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
@jokva
Copy link

jokva commented Feb 22, 2019

#37 This is probably the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants