enthought / enthought/enable

Some functions in Agg wrapper don't play nice with numpy dtypes

Open
#95 1 comment 0 reactions 0 assignees View on GitHub
difficulty: advanced priority: low type: bug
Dominant language
C
Stars
97
Forks
45
PR merge metrics
No merged PRs in 30d

Description

I noticed this issue with `GraphicsContextArray.clip_to_rect`, but I imagine this is an issue in a few other agg functions.

This issue pops up when running one of the Chaco examples:

https://github.com/enthought/chaco/blob/master/examples/user_guide/grid_plot_container.py

The problem in the example is that the height is being set to an `int`, which gets converted to a numpy `int` at some point. A python `int` seems to cast correctly, but numpy `int`s don't:

``` python
import numpy as np
from kiva.agg import GraphicsContextArray

def python_ints(values):
return [int(a) for a in values]

def python_floats(values):
return [float(a) for a in values]

def test_clip_to_rect_dtypes():

gc = GraphicsContextArray((3, 3))
rect = np.zeros(4)

convert_funcs = [
python_ints,
python_floats,
np.float64,
np.float32,
np.int64,
np.int32,
np.uint8,
]

with gc:
for convert in convert_funcs:
try:
gc.clip_to_rect(*convert(rect))
except Exception as error:
print convert
print error

if __name__ == '__main__':
test_clip_to_rect_dtypes()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.