Skip to content

Indices of wrong type for NumPy 1.12+ #32

Description

@kwinkunks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions