enthought / enthought/mayavi

Broken support for signed integers in tvtk.TypeInt8Array

Open
#1,170 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

Hello,
when I try to store an integer array in tvtk.TypeInt8Array I get an error from tvtk.
Running following code
’’’
import numpy as np
from tvtk.api import tvtk

gl = np.arange(5, dtype=np.int8)
gl_arr = tvtk.TypeInt8Array(name='gray_levels')
gl_arr.from_array(gl)
’’’
produces
'''
Traceback (most recent call last):
File "/home/jakub.jerabek/PycharmProjects/ims_lab/GLA_lab/VTK_visual/combine_stripes/min_uint_problem.py", line 6, in
gl_arr.from_array(gl)
File "/home/jakub.jerabek/anaconda3/envs/py310/lib/python3.10/site-packages/tvtk/tvtk_classes.zip/tvtk_classes/data_array.py", line 818, in from_array
File "/home/jakub.jerabek/anaconda3/envs/py310/lib/python3.10/site-packages/tvtk/array_handler.py", line 340, in array2vtk
arr_dtype = get_numeric_array_type(vtk_typecode)
File "/home/jakub.jerabek/anaconda3/envs/py310/lib/python3.10/site-packages/tvtk/array_handler.py", line 237, in get_numeric_array_type
return get_vtk_to_numeric_typemap()[vtk_array_type]
KeyError: 15
'''
Changing the type to TypeUInt8Array removes the error.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with tvtk/array_handler.py, especially get_numeric_array_type, and trace the from_array call in tvtk/data_array.py using the provided NumPy int8 reproducer. Confirm that TypeInt8Array no longer raises KeyError: 15 and that signed integer arrays are accepted without changing the existing unsigned behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
computer-graphics, data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.