Question about PointDataSource and reverse_map

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Question about PointDataSource and reverse_map

Kevin McClaning
All --

Am I missing something or is there a bug? It could be that I'm not using
the PointDataSource object correctly.

Python 2.7.3 |EPD 7.3-1 (32-bit)| (default, Apr 12 2012, 14:30:37) [MSC
v.1500 32 bit (Intel)]

## generate a point data source
from chaco.api import PointDataSource
fooPDS = PointDataSource()

## initialize fooPDS with monotonically increasing x, non-monotonic y data
## use sort_order = 'ascending". Also, the set_data method sets
sort_index to 0,
## indicating the monotonically-increasing data is in the 0th or x
position of each point.
fooPDS.set_data( [[1,2],[3,-5],[4,7],[10,-22]],sort_order='ascending' )
#sort_index set to 0 by default

## check the sort_order and sort_index.
fooPDS.sort_order
## returns 'ascending'
fooPDS.sort_index
## returns 0

## try the reverse_map functions. With outside_returns_none flag =
False, should
## return 0 as the index
fooPDS.reverse_map( [-1,6.9],outside_returns_none = False)
## incorrectly returns None

## should return the index of point [3,-5]
fooPDS.reverse_map( [3.1,6.9],outside_returns_none = False)
## correctly returns 1

## should return the index of point [10,-22]
fooPDS.reverse_map( [9.9,6.9],outside_returns_none = False)
## correctly returns 3

## should return index of point [10,-22] or 3
fooPDS.reverse_map( [10.1,6.9],outside_returns_none = False)
## incorrectly returns None

## With outside_returns_none flag = True, should return none
fooPDS.reverse_map( [-1,6.9],outside_returns_none = True)
## correctly returns None

The problem seems to be in the point_data_source.py file, line 140 (def
_compute_bounds method).
The method doesn't compute the _min_index and _max_index required by the
PointDataSource reverse_map function (lines 127 and 132).

Thanks.
Kevin
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev