diff --git a/chaco/axis.py b/chaco/axis.py index d2818e168..9635b8fe5 100644 --- a/chaco/axis.py +++ b/chaco/axis.py @@ -10,6 +10,8 @@ """ Defines the PlotAxis class, and associated validator and UI. """ +import logging + # Major library import from numpy import ( array, @@ -58,6 +60,8 @@ from .label import Label from .log_mapper import LogMapper +logger = logging.getLogger(__name__) + def DEFAULT_TICK_FORMATTER(val): return ("%f" % val).rstrip("0").rstrip(".") @@ -500,20 +504,21 @@ def _compute_tick_positions(self, gc, overlay_component=None): screenlow, screenhigh = screenhigh, screenlow if ( - (datalow == datahigh) + (datalow >= datahigh) or (screenlow == screenhigh) or (datalow in [inf, -inf]) or (datahigh in [inf, -inf]) ): + if datalow > datahigh: + logger.warning( + "{self.mapper} has an invalid data range with " + "low={datalow} > high={datahigh}; unable to compute axis " + "ticks." + ) self._reset_cache() self._cache_valid = True return - if datalow > datahigh: - raise RuntimeError( - "DataRange low is greater than high; unable to compute axis ticks." - ) - if not self.tick_generator: return diff --git a/chaco/ticks.py b/chaco/ticks.py index 9eb160f81..284cb742b 100644 --- a/chaco/ticks.py +++ b/chaco/ticks.py @@ -305,6 +305,8 @@ def auto_ticks( if upper > end: end += tick_interval + if isnan([start, end]).any(): + return [] ticks = arange(start, end + (tick_interval / 2.0), tick_interval) if len(ticks) < 2: