enthought/chaco — pull request #222 by mdickinson (2014-10-14 13:56:22+00:00)
Title: Fix sign inversion bug in Base1DMapper.

There was a sign inversion bug in `Base1DMapper` that affected resizing of plots using an origin of `"top left"` and having `stretch_data = False`. Resizing the generated plot produced a flicker, and a `RuntimeError` exception with message: "DataRange low is greater than high; unable to compute axis ticks."

This PR gives a fix.

For the record, here's a minimal script that demonstrates the bug. Run the script below, then resize. The plot will flicker, and you'll see the following traceback:

```
Traceback (most recent call last):
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/qt4/base_window.py", line 198, in paintEvent
self.handler.paintEvent(event)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/qt4/base_window.py", line 50, in paintEvent
self._enable_window._paint(event)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/abstract_window.py", line 467, in _paint
self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/component.py", line 424, in draw
self._draw(gc, view_bounds, mode)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/component.py", line 776, in _draw
self._dispatch_draw(layer, gc, view_bounds, mode)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/container.py", line 257, in _dispatch_draw
my_handler(gc, view_bounds, mode)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/container.py", line 297, in _draw_container_underlay
self._draw_underlay(gc, view_bounds, mode)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/enable/enable/component.py", line 884, in _draw_underlay
underlay.overlay(self, gc, view_bounds, mode)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/chaco/chaco/axis.py", line 222, in overlay
self._draw_component(gc, view_bounds, mode, component)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/chaco/chaco/axis.py", line 247, in _draw_component
self._compute_tick_positions(gc, component)
File "/Users/mdickinson/Enthought/Source/meta-geophysics/meta-ETS/chaco/chaco/axis.py", line 463, in _compute_tick_positions
raise RuntimeError, "DataRange low is greater than high; unable to compute axis ticks."
RuntimeError: DataRange low is greater than high; unable to compute axis ticks.
```

Here's the script.

```python
from numpy import linspace
from scipy.special import jn

from chaco.api import ArrayPlotData, Plot
from enable.api import Component, ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import Group, Item, View

class Demo(HasTraits):
plot = Instance(Component)

def _plot_default(self):
x = linspace(-2.0, 10.0, 100)
plot_data = ArrayPlotData(x=x, y=jn(3, x))
plot = Plot(plot_data, origin="top left")
plot.value_mapper.stretch_data = False
plot.plot(("x", "y"))
return plot

traits_view = View(
Group(
Item(
'plot',
editor=ComponentEditor(),
show_label=False,
),
),
resizable=True,
)

if __name__ == "__main__":
demo = Demo()
demo.configure_traits()