From 1f7a059846d6921ba4f34a3671d412093bbb37ab Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 4 May 2021 12:00:40 -0500 Subject: [PATCH 01/25] make return types of map_screen consistent --- chaco/barplot.py | 6 +++++- chaco/base_1d_plot.py | 2 +- chaco/base_2d_plot.py | 2 +- chaco/base_xy_plot.py | 7 ++++++- chaco/data_view.py | 9 +++++++-- chaco/errorbar_plot.py | 2 +- chaco/grid_mapper.py | 5 +++++ chaco/horizon_plot.py | 2 ++ chaco/jitterplot.py | 2 +- chaco/linear_mapper.py | 2 ++ chaco/lineplot.py | 4 ++-- chaco/segment_plot.py | 22 ++++++++++++++++++++++ 12 files changed, 55 insertions(+), 10 deletions(-) diff --git a/chaco/barplot.py b/chaco/barplot.py index 5749f5bf9..4e8b6363e 100644 --- a/chaco/barplot.py +++ b/chaco/barplot.py @@ -2,6 +2,7 @@ """ import logging +import numpy as np from numpy import ( array, compress, @@ -166,9 +167,12 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ + # ensure data_array is an Nx2 ndarray + data_array = np.asarray(data_array) + data_array = data_array.reshape(-1,2) # data_array is Nx2 array if len(data_array) == 0: - return [] + return np.empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) diff --git a/chaco/base_1d_plot.py b/chaco/base_1d_plot.py index 8fbb8f237..66dae6aea 100644 --- a/chaco/base_1d_plot.py +++ b/chaco/base_1d_plot.py @@ -111,7 +111,7 @@ def map_screen(self, data_array): """ # data_array is 1D array of length N if len(data_array) == 0: - return [] + return empty(shape=(0,)) return asarray(self.index_mapper.map_screen(data_array)) def map_data(self, screen_pts): diff --git a/chaco/base_2d_plot.py b/chaco/base_2d_plot.py index 469b3a43c..082053e8a 100644 --- a/chaco/base_2d_plot.py +++ b/chaco/base_2d_plot.py @@ -111,7 +111,7 @@ def map_screen(self, data_pts): """ # data_pts is Nx2 array if len(data_pts) == 0: - return [] + return np.empty(shape=(0,2)) return asarray(self.index_mapper.map_screen(data_pts)) def map_data(self, screen_pts): diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index d73571132..f287a8ec0 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -1,6 +1,7 @@ """ Defines the base class for XY plots. """ from math import sqrt +import numpy as np from numpy import around, array, isnan, transpose # Enthought library imports @@ -343,9 +344,13 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ + # ensure data_array is an Nx2 ndarray + data_array = np.asarray(data_array) + data_array = data_array.reshape(-1,2) + # data_array is Nx2 array if len(data_array) == 0: - return [] + return np.empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) diff --git a/chaco/data_view.py b/chaco/data_view.py index 53c300fef..3fd4ceaa3 100644 --- a/chaco/data_view.py +++ b/chaco/data_view.py @@ -1,6 +1,7 @@ """ Defines the DataView class, and associated property traits and property functions. """ +import numpy as np from numpy import array, transpose from traits.api import Bool, Enum, Instance, Property @@ -232,9 +233,13 @@ def map_screen(self, data_array): """Maps an array of data points to screen space and returns an array of screen space points. """ - # data_array is Nx2 array + + # ensure data_array is an Nx2 ndarray + data_array = np.asarray(data_array) + data_array = data_array.reshape(-1,2) + if len(data_array) == 0: - return [] + return np.empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) diff --git a/chaco/errorbar_plot.py b/chaco/errorbar_plot.py index 94c80d18e..b0e4fcb37 100644 --- a/chaco/errorbar_plot.py +++ b/chaco/errorbar_plot.py @@ -39,7 +39,7 @@ def map_screen(self, data_array): or (y, xlow, xhigh) depending on self.orientation. """ if len(data_array) == 0: - return [] + return np.empty(shape=(0,2)) elif data_array.shape[1] == 2: return LinePlot.map_screen(self, data_array) else: diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index 9a810a03e..9d1f5a3bd 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -7,6 +7,7 @@ from contextlib import contextmanager # Major library imports +import numpy as np from numpy import column_stack, transpose # Enthought library imports @@ -116,6 +117,10 @@ def map_screen(self, data_pts): Maps values from data space into screen space. """ + # ensure data_array is an Nx2 ndarray + data_pts = np.asarray(data_pts) + data_pts = data_pts.reshape(-1,2) + xs, ys = transpose(data_pts) screen_xs = self._xmapper.map_screen(xs) screen_ys = self._ymapper.map_screen(ys) diff --git a/chaco/horizon_plot.py b/chaco/horizon_plot.py index 069b04888..7e1e7713b 100644 --- a/chaco/horizon_plot.py +++ b/chaco/horizon_plot.py @@ -20,6 +20,8 @@ def map_screen(self, data_array): return array([self.low_pos]) else: # Scale the data by the number of bands + if not isinstance(data_array, ndarray): + data_array = array(data_array, ndmin=1) return ( data_array * self.bands - self.range.low ) * self._scale + self.low_pos diff --git a/chaco/jitterplot.py b/chaco/jitterplot.py index 79a56e654..dbfe561c1 100644 --- a/chaco/jitterplot.py +++ b/chaco/jitterplot.py @@ -36,7 +36,7 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ if len(data_array) == 0: - return np.zeros(0) + return np.empty(shape=(0,)) if self._screen_cache_valid: sm = self._cached_screen_map diff --git a/chaco/linear_mapper.py b/chaco/linear_mapper.py index 16dd61e46..7f48baf79 100644 --- a/chaco/linear_mapper.py +++ b/chaco/linear_mapper.py @@ -49,6 +49,8 @@ def map_screen(self, data_array): else: return array([self.low_pos]) else: + if not isinstance(data_array, ndarray): + data_array = array(data_array, ndmin=1) return (data_array - self.range.low) * self._scale + self.low_pos def map_data(self, screen_val): diff --git a/chaco/lineplot.py b/chaco/lineplot.py index 6a7861521..a12c6a2b8 100644 --- a/chaco/lineplot.py +++ b/chaco/lineplot.py @@ -114,8 +114,8 @@ def hittest(self, screen_pt, threshold=7.0, return_distance=False): if return_distance: scrn_pt = self.map_screen(data_pt) dist = sqrt( - (screen_pt[0] - scrn_pt[0]) ** 2 - + (screen_pt[1] - scrn_pt[1]) ** 2 + (screen_pt[0] - scrn_pt[0, 0]) ** 2 + + (screen_pt[1] - scrn_pt[0, 1]) ** 2 ) return (data_pt[0], data_pt[1], dist) else: diff --git a/chaco/segment_plot.py b/chaco/segment_plot.py index 633ba05e2..613b3cd97 100644 --- a/chaco/segment_plot.py +++ b/chaco/segment_plot.py @@ -132,6 +132,28 @@ def hittest(self, *args, **kwargs): def map_index(self, *args, **kwargs): raise NotImplementedError() + def map_screen(self, data_array): + """Maps an Nx2x2 array of data points into screen space and returns it + as an array. + + Implements the AbstractPlotRenderer interface. + """ + # ensure data_array is an Nx2x2 ndarray + data_array = np.asarray(data_array) + data_array = data_array.reshape(-1,2, 2) + + if len(data_array) == 0: + return np.empty(shape=(0, 2, 2)) + + x_ary, y_ary = np.transpose(data_array) + + sx = self.index_mapper.map_screen(x_ary) + sy = self.value_mapper.map_screen(y_ary) + if self.orientation == "h": + return np.transpose(np.array((sx, sy))) + else: + return np.transpose(np.array((sy, sx))) + def _gather_points(self): """Collects the data points that are within the bounds of the plot and caches them. From 9e219a04377cbf35191b86f360750184c7cf56c9 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 4 May 2021 12:10:55 -0500 Subject: [PATCH 02/25] use np for numpy --- chaco/barplot.py | 36 +++++++++++++-------------------- chaco/base_xy_plot.py | 21 ++++++++++---------- chaco/data_view.py | 9 ++++----- chaco/grid_mapper.py | 9 ++++----- chaco/log_mapper.py | 46 ++++++++++++++++--------------------------- 5 files changed, 49 insertions(+), 72 deletions(-) diff --git a/chaco/barplot.py b/chaco/barplot.py index 4e8b6363e..5e017268b 100644 --- a/chaco/barplot.py +++ b/chaco/barplot.py @@ -3,15 +3,7 @@ import logging import numpy as np -from numpy import ( - array, - compress, - column_stack, - invert, - isnan, - transpose, - zeros, -) + from traits.api import ( Any, Bool, @@ -173,14 +165,14 @@ def map_screen(self, data_array): # data_array is Nx2 array if len(data_array) == 0: return np.empty(shape=(0,2)) - x_ary, y_ary = transpose(data_array) + x_ary, y_ary = np.transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return transpose(array((sx, sy))) + return np.transpose(np.array((sx, sy))) else: - return transpose(array((sy, sx))) + return np.transpose(np.array((sy, sx))) def map_data(self, screen_pt): """Maps a screen space point into the "index" space of the plot. @@ -224,7 +216,7 @@ def map_index( x = index_data[ndx] y = value_data[ndx] - result = self.map_screen(array([[x, y]])) + result = self.map_screen(np.array([[x, y]])) if result is None: return None @@ -257,7 +249,7 @@ def _gather_points(self): "Chaco: using empty dataset; index_len=%d, value_len=%d." % (len(index), len(value)) ) - self._cached_data_pts = array([]) + self._cached_data_pts = np.array([]) self._cache_valid = True return @@ -270,17 +262,17 @@ def _gather_points(self): # index_range_mask & value_range_mask index_range_mask = self.index_mapper.range.mask_data(index) - nan_mask = invert(isnan(index_mask)) + nan_mask = np.invert(np.isnan(index_mask)) point_mask = index_mask & nan_mask & index_range_mask if self.starting_value is None: - starting_values = zeros(len(index)) + starting_values = np.zeros(len(index)) else: starting_values = self.starting_value.get_data() if self.bar_width_type == "data": half_width = self.bar_width / 2.0 - points = column_stack( + points = np.column_stack( ( index - half_width, index + half_width, @@ -289,8 +281,8 @@ def _gather_points(self): ) ) else: - points = column_stack((index, starting_values, value)) - self._cached_data_pts = compress(point_mask, points, axis=0) + points = np.column_stack((index, starting_values, value)) + self._cached_data_pts = np.compress(point_mask, points, axis=0) self._cache_valid = True @@ -325,7 +317,7 @@ def _draw_plot(self, gc, view_bounds=None, mode="normal"): upper_right_pts[:, 0] += half_width bounds = upper_right_pts - lower_left_pts - gc.rects(column_stack((lower_left_pts, bounds))) + gc.rects(np.column_stack((lower_left_pts, bounds))) gc.draw_path() def _draw_default_axes(self, gc): @@ -341,10 +333,10 @@ def _draw_default_axes(self, gc): if (range.low < 0) and (range.high > 0): if range == self.index_mapper.range: dual = self.value_mapper.range - data_pts = array([[0.0, dual.low], [0.0, dual.high]]) + data_pts = np.array([[0.0, dual.low], [0.0, dual.high]]) else: dual = self.index_mapper.range - data_pts = array([[dual.low, 0.0], [dual.high, 0.0]]) + data_pts = np.array([[dual.low, 0.0], [dual.high, 0.0]]) start, end = self.map_screen(data_pts) gc.move_to(int(start[0]) + 0.5, int(start[1]) + 0.5) gc.line_to(int(end[0]) + 0.5, int(end[1]) + 0.5) diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index f287a8ec0..ed44ff3be 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -2,7 +2,6 @@ """ from math import sqrt import numpy as np -from numpy import around, array, isnan, transpose # Enthought library imports from enable.api import black_color_trait @@ -352,14 +351,14 @@ def map_screen(self, data_array): if len(data_array) == 0: return np.empty(shape=(0,2)) - x_ary, y_ary = transpose(data_array) + x_ary, y_ary = np.transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return transpose(array((sx, sy))) + return np.transpose(np.array((sx, sy))) else: - return transpose(array((sy, sx))) + return np.transpose(np.array((sy, sx))) def map_data(self, screen_pt, all_values=False): """Maps a screen space point into the "index" space of the plot. @@ -373,7 +372,7 @@ def map_data(self, screen_pt, all_values=False): if self.orientation == "v": x, y = y, x if all_values: - return array( + return np.array( (self.index_mapper.map_data(x), self.value_mapper.map_data(y)) ) else: @@ -442,14 +441,14 @@ def map_index( x = index_data[ndx] y = value_data[ndx] - if isnan(x) or isnan(y): + if np.isnan(x) or np.isnan(y): return None # transform x,y in a 1x2 array, which is the preferred format of # map_screen. this makes it robust against differences in # the map_screen methods of logmapper and linearmapper # when passed a scalar - xy = array([[x, y]]) + xy = np.array([[x, y]]) sx, sy = self.map_screen(xy).T if index_only and (threshold == 0.0 or screen_pt[0] - sx < threshold): return ndx @@ -501,13 +500,13 @@ def _draw_default_axes(self, gc): if (range.low < 0) and (range.high > 0): if range == self.index_mapper.range: dual = self.value_mapper.range - data_pts = array([[0.0, dual.low], [0.0, dual.high]]) + data_pts = np.array([[0.0, dual.low], [0.0, dual.high]]) else: dual = self.index_mapper.range - data_pts = array([[dual.low, 0.0], [dual.high, 0.0]]) + data_pts = np.array([[dual.low, 0.0], [dual.high, 0.0]]) start, end = self.map_screen(data_pts) - start = around(start) - end = around(end) + start = np.around(start) + end = np.around(end) gc.move_to(int(start[0]), int(start[1])) gc.line_to(int(end[0]), int(end[1])) gc.stroke_path() diff --git a/chaco/data_view.py b/chaco/data_view.py index 3fd4ceaa3..e6b5720ed 100644 --- a/chaco/data_view.py +++ b/chaco/data_view.py @@ -2,7 +2,6 @@ functions. """ import numpy as np -from numpy import array, transpose from traits.api import Bool, Enum, Instance, Property from enable.api import color_table @@ -240,13 +239,13 @@ def map_screen(self, data_array): if len(data_array) == 0: return np.empty(shape=(0,2)) - x_ary, y_ary = transpose(data_array) + x_ary, y_ary = np.transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return transpose(array((sx, sy))) + return np.transpose(np.array((sx, sy))) else: - return transpose(array((sy, sx))) + return np.transpose(np.array((sy, sx))) def map_data(self, screen_pt): """Maps a screen space point into the 2D data space of this plot. @@ -256,7 +255,7 @@ def map_data(self, screen_pt): # At some point it would be good to change the DataView to use # the GridMapper, and then use its map_data() method. x, y = screen_pt - return array( + return np.array( (self.index_mapper.map_data(x), self.value_mapper.map_data(y)) ) diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index 9d1f5a3bd..b46b081ae 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -8,7 +8,6 @@ # Major library imports import numpy as np -from numpy import column_stack, transpose # Enthought library imports from traits.api import Bool, DelegatesTo, Instance, Float, Property @@ -121,10 +120,10 @@ def map_screen(self, data_pts): data_pts = np.asarray(data_pts) data_pts = data_pts.reshape(-1,2) - xs, ys = transpose(data_pts) + xs, ys = np.transpose(data_pts) screen_xs = self._xmapper.map_screen(xs) screen_ys = self._ymapper.map_screen(ys) - screen_pts = column_stack([screen_xs, screen_ys]) + screen_pts = np.column_stack([screen_xs, screen_ys]) return screen_pts def map_data(self, screen_pts): @@ -132,10 +131,10 @@ def map_data(self, screen_pts): Maps values from screen space into data space. """ - screen_xs, screen_ys = transpose(screen_pts) + screen_xs, screen_ys = np.transpose(screen_pts) xs = self._xmapper.map_data(screen_xs) ys = self._ymapper.map_data(screen_ys) - data_pts = column_stack([xs, ys]) + data_pts = np.column_stack([xs, ys]) return data_pts def map_data_array(self, screen_pts): diff --git a/chaco/log_mapper.py b/chaco/log_mapper.py index 4316576dd..7aff2408e 100644 --- a/chaco/log_mapper.py +++ b/chaco/log_mapper.py @@ -1,18 +1,6 @@ """ Defines the LogMapper and InvalidDataRangeException classes. """ # Major library imports -from numpy import ( - array, - isnan, - log, - log10, - exp, - zeros, - sometrue, - floor, - ceil, - ndarray, -) import numpy as np # Enthought library imports @@ -58,8 +46,8 @@ def map_screen(self, data_array): Overrides AbstractMapper. Maps values from data space to screen space. """ # Ensure that data_array is actually an array. - if not isinstance(data_array, ndarray): - data_array = array(data_array, ndmin=1) + if not isinstance(data_array, np.ndarray): + data_array = np.array(data_array, ndmin=1) # First convert to a [0,1] space, then to the screen space. if not self._cache_valid: self._compute_scale() @@ -68,15 +56,15 @@ def map_screen(self, data_array): else: try: with np.errstate(invalid="ignore"): - mask = (data_array <= LOG_MINIMUM) | isnan(data_array) - if sometrue(mask): - data_array = array(data_array, copy=True, ndmin=1) + mask = (data_array <= LOG_MINIMUM) | np.isnan(data_array) + if np.sometrue(mask): + data_array = np.array(data_array, copy=True, ndmin=1) data_array[mask] = self.fill_value intermediate = ( - log(data_array) - self._inter_offset + np.log(data_array) - self._inter_offset ) / self._inter_scale except ValueError: - intermediate = zeros(len(data_array)) + intermediate = np.zeros(len(data_array)) result = intermediate * self._screen_scale + self._screen_offset return result @@ -89,10 +77,10 @@ def map_data(self, screen_val): if not self._cache_valid: self._compute_scale() if self._null_screen_range or self._null_data_range: - return array([self.range.low]) + return np.array([self.range.low]) # First convert to a [0,1] space, then to the data space intermediate = (screen_val - self._screen_offset) / self._screen_scale - return exp(self._inter_scale * intermediate + self._inter_offset) + return np.exp(self._inter_scale * intermediate + self._inter_offset) def map_data_array(self, screen_vals): return self.map_data(screen_vals) @@ -119,12 +107,12 @@ def _get_safe_scale(self, range): low = 1.0 high = 10.0 else: - log_val = log10(low) - low = pow(10, floor(log_val)) - if ceil(log_val) != floor(log_val): - high = pow(10, ceil(log_val)) + log_val = np.log10(low) + low = pow(10, np.floor(log_val)) + if np.ceil(log_val) != np.floor(log_val): + high = pow(10, np.ceil(log_val)) else: - high = pow(10, ceil(log_val) + 1) + high = pow(10, np.ceil(log_val) + 1) return (low, high) @@ -147,11 +135,11 @@ def _compute_scale(self): self._null_data_range = True else: if low == LOG_MINIMUM: - self._inter_scale = log(high) + self._inter_scale = np.log(high) self._inter_offset = 0.0 else: - self._inter_scale = log(high) - log(low) - self._inter_offset = log(low) + self._inter_scale = np.log(high) - np.log(low) + self._inter_offset = np.log(low) self._screen_scale = screen_range self._screen_offset = self.low_pos From 8eedf6c964aec71600ce1fbc279f49176186994d Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 4 May 2021 12:27:08 -0500 Subject: [PATCH 03/25] flake8 --- chaco/base_xy_plot.py | 12 ++++++++---- chaco/errorbar_plot.py | 4 ++-- chaco/grid_mapper.py | 4 ++-- chaco/segment_plot.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index ed44ff3be..b7802c727 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -345,11 +345,11 @@ def map_screen(self, data_array): """ # ensure data_array is an Nx2 ndarray data_array = np.asarray(data_array) - data_array = data_array.reshape(-1,2) + data_array = data_array.reshape(-1, 2) # data_array is Nx2 array if len(data_array) == 0: - return np.empty(shape=(0,2)) + return np.empty(shape=(0, 2)) x_ary, y_ary = np.transpose(data_array) @@ -500,10 +500,14 @@ def _draw_default_axes(self, gc): if (range.low < 0) and (range.high > 0): if range == self.index_mapper.range: dual = self.value_mapper.range - data_pts = np.array([[0.0, dual.low], [0.0, dual.high]]) + data_pts = np.array( + [[0.0, dual.low], [0.0, dual.high]] + ) else: dual = self.index_mapper.range - data_pts = np.array([[dual.low, 0.0], [dual.high, 0.0]]) + data_pts = np.array( + [[dual.low, 0.0], [dual.high, 0.0]] + ) start, end = self.map_screen(data_pts) start = np.around(start) end = np.around(end) diff --git a/chaco/errorbar_plot.py b/chaco/errorbar_plot.py index b0e4fcb37..9ef4a560e 100644 --- a/chaco/errorbar_plot.py +++ b/chaco/errorbar_plot.py @@ -1,5 +1,5 @@ # Major library imports -from numpy import column_stack, compress, invert, isnan, transpose +from numpy import column_stack, compress, empty, invert, isnan, transpose import logging # Enthought library imports @@ -39,7 +39,7 @@ def map_screen(self, data_array): or (y, xlow, xhigh) depending on self.orientation. """ if len(data_array) == 0: - return np.empty(shape=(0,2)) + return empty(shape=(0, 2)) elif data_array.shape[1] == 2: return LinePlot.map_screen(self, data_array) else: diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index b46b081ae..d192545a1 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -118,8 +118,8 @@ def map_screen(self, data_pts): """ # ensure data_array is an Nx2 ndarray data_pts = np.asarray(data_pts) - data_pts = data_pts.reshape(-1,2) - + data_pts = data_pts.reshape(-1, 2) + xs, ys = np.transpose(data_pts) screen_xs = self._xmapper.map_screen(xs) screen_ys = self._ymapper.map_screen(ys) diff --git a/chaco/segment_plot.py b/chaco/segment_plot.py index 613b3cd97..e49435235 100644 --- a/chaco/segment_plot.py +++ b/chaco/segment_plot.py @@ -140,7 +140,7 @@ def map_screen(self, data_array): """ # ensure data_array is an Nx2x2 ndarray data_array = np.asarray(data_array) - data_array = data_array.reshape(-1,2, 2) + data_array = data_array.reshape(-1, 2, 2) if len(data_array) == 0: return np.empty(shape=(0, 2, 2)) From 32f6c07c9e4c548dd118c42f0fe0bf9a9cbcf8f9 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 4 May 2021 12:31:37 -0500 Subject: [PATCH 04/25] update cursor_tool.py to expect Nx2 array output from map_screen --- chaco/tools/cursor_tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/tools/cursor_tool.py b/chaco/tools/cursor_tool.py index 4002861d1..86cc3eacb 100644 --- a/chaco/tools/cursor_tool.py +++ b/chaco/tools/cursor_tool.py @@ -190,7 +190,7 @@ def draw(self, gc, view_bounds=None): if plot is None: return - sx, sy = plot.map_screen(self.current_position) + sx, sy = plot.map_screen(self.current_position)[0] orientation = plot.orientation if orientation == "h" and sx is not None: @@ -211,7 +211,7 @@ def is_draggable(self, x, y): plot = self.component if plot is not None: orientation = plot.orientation - sx, sy = plot.map_screen(self.current_position) + sx, sy = plot.map_screen(self.current_position)[0] if orientation == "h" and numpy.abs(sx - x) <= self.threshold: return True elif orientation == "v" and numpy.abs(sy - y) <= self.threshold: From 886198458ac74c37fcea9edacf12a395100ae4da Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 4 May 2021 15:52:06 -0500 Subject: [PATCH 05/25] expect correct return type --- chaco/barplot.py | 2 +- chaco/tools/data_label_tool.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/barplot.py b/chaco/barplot.py index 5e017268b..2299c3eaa 100644 --- a/chaco/barplot.py +++ b/chaco/barplot.py @@ -337,7 +337,7 @@ def _draw_default_axes(self, gc): else: dual = self.index_mapper.range data_pts = np.array([[dual.low, 0.0], [dual.high, 0.0]]) - start, end = self.map_screen(data_pts) + start, end = self.map_screen(data_pts)[0] gc.move_to(int(start[0]) + 0.5, int(start[1]) + 0.5) gc.line_to(int(end[0]) + 0.5, int(end[1]) + 0.5) gc.stroke_path() diff --git a/chaco/tools/data_label_tool.py b/chaco/tools/data_label_tool.py index dabf0242f..582f20837 100644 --- a/chaco/tools/data_label_tool.py +++ b/chaco/tools/data_label_tool.py @@ -61,7 +61,7 @@ def drag_start(self, event): """ if self.component: label = self.component - pointx, pointy = label.component.map_screen(label.data_point) + pointx, pointy = label.component.map_screen(label.data_point)[0] self._original_offset = (label.x - pointx, label.y - pointy) event.window.set_mouse_owner(self, event.net_transform()) event.handled = True From 74175b8ea3a3eeda051feb44451bd98d63908a5b Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 13:46:21 -0500 Subject: [PATCH 06/25] add a regression test for 272 --- chaco/tests/test_plot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index b7be564f5..5d2559683 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -1,5 +1,6 @@ import unittest +import numpy as np from numpy import alltrue, arange, array from enable.api import ComponentEditor @@ -109,6 +110,25 @@ def test_text_plot(self): actual = gc.bmp_array[:, :, :] self.assertFalse(alltrue(actual == 255)) + def check_map_screen(self, renderer): + arr = arange(10) + data = ArrayPlotData(x=arr, y=arr) + plot = Plot(data) + plot_renderer = plot.add_xy_plot( + 'x', 'y', plot.renderer_map[renderer] + )[0] + + screen_point = plot_renderer.map_screen((-1, 1)) + + self.assertEqual(type(screen_point), np.ndarray) + self.assertEqual(screen_point.shape, (1,2)) + + # serves as a regression test for enthought/chaco#272 + def test_map_screen(self): + renderers = ["line", "scatter"] + for renderer in renderers: + self.check_map_screen(renderer) + class EmptyLinePlot(HasTraits): plot = Instance(Plot) From 9c85c5ac2ada15b9f4a80bcd9283431c3cee947e Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 13:54:46 -0500 Subject: [PATCH 07/25] run same test on a couple more renderers --- chaco/tests/test_plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index 5d2559683..e01f57476 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -124,8 +124,8 @@ def check_map_screen(self, renderer): self.assertEqual(screen_point.shape, (1,2)) # serves as a regression test for enthought/chaco#272 - def test_map_screen(self): - renderers = ["line", "scatter"] + def test_xy_plot_map_screen(self): + renderers = ["line", "scatter", "bar", "polygon"] for renderer in renderers: self.check_map_screen(renderer) From ad93274d8605cef247ea5328a143cd2643da9a6a Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:03:28 -0500 Subject: [PATCH 08/25] add a test for SegmentPlot which does its own thing --- chaco/tests/test_plot.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index e01f57476..4301b0e52 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -110,6 +110,19 @@ def test_text_plot(self): actual = gc.bmp_array[:, :, :] self.assertFalse(alltrue(actual == 255)) + def test_segment_plot_map_screen(self): + x = arange(10) + y = arange(1, 11) + data = ArrayPlotData(x=x, y=y) + plot = Plot(data) + plot_renderer = plot.plot(("x", "y"), "segment")[0] + + screen_point = plot_renderer.map_screen([(0, 1), (1, 2)]) + + self.assertEqual(type(screen_point), np.ndarray) + self.assertEqual(screen_point.shape, (1,2,2)) + + def check_map_screen(self, renderer): arr = arange(10) data = ArrayPlotData(x=arr, y=arr) From 527bdb9a220592ed806f5f5f3ee15509c9419c53 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:26:52 -0500 Subject: [PATCH 09/25] add explicit map_screen specific test for ImagePlot --- chaco/tests/test_image_plot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chaco/tests/test_image_plot.py b/chaco/tests/test_image_plot.py index 9bed8f7cb..7aa3546ed 100644 --- a/chaco/tests/test_image_plot.py +++ b/chaco/tests/test_image_plot.py @@ -185,6 +185,21 @@ def test_vertical_bottom_right(self): RGB, (IMAGE.T)[::-1, ::-1], origin="bottom right", orientation="v" ) + def test_map_screen(self): + data_source = ImageData(data=RGB) + index, index_mapper = get_image_index_and_mapper(RGB) + renderer = ImagePlot( + value=data_source, + index=index, + index_mapper=index_mapper, + ) + + # ImagePlot map screen is used tto find the screen_bbox, not on data + # itself. + screen_pt = renderer.map_screen([(0, 0)]) + self.assertEqual(type(screen_pt), np.ndarray) + self.assertEqual(screen_pt.shape, (1,2)) + # regression test for enthought/chaco#528 @unittest.skipIf(is_null or is_qt4(), "Skip on 'null' or 'qt4' toolkit") def test_resize_to_zero(self): From db31b7b3df9ee04fce53539698ce070d27605b65 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:30:53 -0500 Subject: [PATCH 10/25] test map screen on no data points ImagePlot --- chaco/base_2d_plot.py | 4 ++-- chaco/tests/test_image_plot.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chaco/base_2d_plot.py b/chaco/base_2d_plot.py index 082053e8a..9cec58048 100644 --- a/chaco/base_2d_plot.py +++ b/chaco/base_2d_plot.py @@ -1,7 +1,7 @@ """ Defines the base class for 2-D plots. """ # Standard library imports -from numpy import asarray, isnan +from numpy import asarray, empty, isnan # Enthought library imports. from traits.api import Enum, Event, Instance, Property, Range, Trait @@ -111,7 +111,7 @@ def map_screen(self, data_pts): """ # data_pts is Nx2 array if len(data_pts) == 0: - return np.empty(shape=(0,2)) + return empty(shape=(0,2)) return asarray(self.index_mapper.map_screen(data_pts)) def map_data(self, screen_pts): diff --git a/chaco/tests/test_image_plot.py b/chaco/tests/test_image_plot.py index 7aa3546ed..1d150c221 100644 --- a/chaco/tests/test_image_plot.py +++ b/chaco/tests/test_image_plot.py @@ -200,6 +200,10 @@ def test_map_screen(self): self.assertEqual(type(screen_pt), np.ndarray) self.assertEqual(screen_pt.shape, (1,2)) + screen_pt = renderer.map_screen([]) + self.assertEqual(type(screen_pt), np.ndarray) + self.assertEqual(screen_pt.shape, (0,2)) + # regression test for enthought/chaco#528 @unittest.skipIf(is_null or is_qt4(), "Skip on 'null' or 'qt4' toolkit") def test_resize_to_zero(self): From 206bc724209274a8ad244805b50f52e7c66297a2 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:33:31 -0500 Subject: [PATCH 11/25] have Plot tests also test map_screen on no data points --- chaco/scatterplot.py | 3 ++- chaco/tests/test_plot.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/chaco/scatterplot.py b/chaco/scatterplot.py index e3cb16f03..b5d73b61d 100644 --- a/chaco/scatterplot.py +++ b/chaco/scatterplot.py @@ -11,6 +11,7 @@ array, asarray, column_stack, + empty, isfinite, isnan, nanargmin, @@ -289,7 +290,7 @@ def map_screen(self, data_array): """ # data_array is Nx2 array if len(data_array) == 0: - return [] + return empty(shape=(0,2)) data_array = asarray(data_array) if len(data_array.shape) == 1: diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index 4301b0e52..fe6dd94ff 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -136,6 +136,11 @@ def check_map_screen(self, renderer): self.assertEqual(type(screen_point), np.ndarray) self.assertEqual(screen_point.shape, (1,2)) + screen_point = plot_renderer.map_screen([]) + + self.assertEqual(type(screen_point), np.ndarray) + self.assertEqual(screen_point.shape, (0,2)) + # serves as a regression test for enthought/chaco#272 def test_xy_plot_map_screen(self): renderers = ["line", "scatter", "bar", "polygon"] From d85658a0ce0e47565569fa6a4f23bcebb14fa965 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:41:25 -0500 Subject: [PATCH 12/25] Revert "use np for numpy" This reverts commit 9e219a04377cbf35191b86f360750184c7cf56c9. --- chaco/barplot.py | 36 ++++++++++++++++++++------------- chaco/base_xy_plot.py | 25 +++++++++++------------ chaco/data_view.py | 9 +++++---- chaco/grid_mapper.py | 13 ++++++------ chaco/log_mapper.py | 46 +++++++++++++++++++++++++++---------------- 5 files changed, 74 insertions(+), 55 deletions(-) diff --git a/chaco/barplot.py b/chaco/barplot.py index 2299c3eaa..46a30e70e 100644 --- a/chaco/barplot.py +++ b/chaco/barplot.py @@ -3,7 +3,15 @@ import logging import numpy as np - +from numpy import ( + array, + compress, + column_stack, + invert, + isnan, + transpose, + zeros, +) from traits.api import ( Any, Bool, @@ -165,14 +173,14 @@ def map_screen(self, data_array): # data_array is Nx2 array if len(data_array) == 0: return np.empty(shape=(0,2)) - x_ary, y_ary = np.transpose(data_array) + x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return np.transpose(np.array((sx, sy))) + return transpose(array((sx, sy))) else: - return np.transpose(np.array((sy, sx))) + return transpose(array((sy, sx))) def map_data(self, screen_pt): """Maps a screen space point into the "index" space of the plot. @@ -216,7 +224,7 @@ def map_index( x = index_data[ndx] y = value_data[ndx] - result = self.map_screen(np.array([[x, y]])) + result = self.map_screen(array([[x, y]])) if result is None: return None @@ -249,7 +257,7 @@ def _gather_points(self): "Chaco: using empty dataset; index_len=%d, value_len=%d." % (len(index), len(value)) ) - self._cached_data_pts = np.array([]) + self._cached_data_pts = array([]) self._cache_valid = True return @@ -262,17 +270,17 @@ def _gather_points(self): # index_range_mask & value_range_mask index_range_mask = self.index_mapper.range.mask_data(index) - nan_mask = np.invert(np.isnan(index_mask)) + nan_mask = invert(isnan(index_mask)) point_mask = index_mask & nan_mask & index_range_mask if self.starting_value is None: - starting_values = np.zeros(len(index)) + starting_values = zeros(len(index)) else: starting_values = self.starting_value.get_data() if self.bar_width_type == "data": half_width = self.bar_width / 2.0 - points = np.column_stack( + points = column_stack( ( index - half_width, index + half_width, @@ -281,8 +289,8 @@ def _gather_points(self): ) ) else: - points = np.column_stack((index, starting_values, value)) - self._cached_data_pts = np.compress(point_mask, points, axis=0) + points = column_stack((index, starting_values, value)) + self._cached_data_pts = compress(point_mask, points, axis=0) self._cache_valid = True @@ -317,7 +325,7 @@ def _draw_plot(self, gc, view_bounds=None, mode="normal"): upper_right_pts[:, 0] += half_width bounds = upper_right_pts - lower_left_pts - gc.rects(np.column_stack((lower_left_pts, bounds))) + gc.rects(column_stack((lower_left_pts, bounds))) gc.draw_path() def _draw_default_axes(self, gc): @@ -333,10 +341,10 @@ def _draw_default_axes(self, gc): if (range.low < 0) and (range.high > 0): if range == self.index_mapper.range: dual = self.value_mapper.range - data_pts = np.array([[0.0, dual.low], [0.0, dual.high]]) + data_pts = array([[0.0, dual.low], [0.0, dual.high]]) else: dual = self.index_mapper.range - data_pts = np.array([[dual.low, 0.0], [dual.high, 0.0]]) + data_pts = array([[dual.low, 0.0], [dual.high, 0.0]]) start, end = self.map_screen(data_pts)[0] gc.move_to(int(start[0]) + 0.5, int(start[1]) + 0.5) gc.line_to(int(end[0]) + 0.5, int(end[1]) + 0.5) diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index b7802c727..f1198dfb6 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -2,6 +2,7 @@ """ from math import sqrt import numpy as np +from numpy import around, array, isnan, transpose # Enthought library imports from enable.api import black_color_trait @@ -351,14 +352,14 @@ def map_screen(self, data_array): if len(data_array) == 0: return np.empty(shape=(0, 2)) - x_ary, y_ary = np.transpose(data_array) + x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return np.transpose(np.array((sx, sy))) + return transpose(array((sx, sy))) else: - return np.transpose(np.array((sy, sx))) + return transpose(array((sy, sx))) def map_data(self, screen_pt, all_values=False): """Maps a screen space point into the "index" space of the plot. @@ -372,7 +373,7 @@ def map_data(self, screen_pt, all_values=False): if self.orientation == "v": x, y = y, x if all_values: - return np.array( + return array( (self.index_mapper.map_data(x), self.value_mapper.map_data(y)) ) else: @@ -441,14 +442,14 @@ def map_index( x = index_data[ndx] y = value_data[ndx] - if np.isnan(x) or np.isnan(y): + if isnan(x) or isnan(y): return None # transform x,y in a 1x2 array, which is the preferred format of # map_screen. this makes it robust against differences in # the map_screen methods of logmapper and linearmapper # when passed a scalar - xy = np.array([[x, y]]) + xy = array([[x, y]]) sx, sy = self.map_screen(xy).T if index_only and (threshold == 0.0 or screen_pt[0] - sx < threshold): return ndx @@ -500,17 +501,13 @@ def _draw_default_axes(self, gc): if (range.low < 0) and (range.high > 0): if range == self.index_mapper.range: dual = self.value_mapper.range - data_pts = np.array( - [[0.0, dual.low], [0.0, dual.high]] - ) + data_pts = array([[0.0, dual.low], [0.0, dual.high]]) else: dual = self.index_mapper.range - data_pts = np.array( - [[dual.low, 0.0], [dual.high, 0.0]] - ) + data_pts = array([[dual.low, 0.0], [dual.high, 0.0]]) start, end = self.map_screen(data_pts) - start = np.around(start) - end = np.around(end) + start = around(start) + end = around(end) gc.move_to(int(start[0]), int(start[1])) gc.line_to(int(end[0]), int(end[1])) gc.stroke_path() diff --git a/chaco/data_view.py b/chaco/data_view.py index e6b5720ed..3fd4ceaa3 100644 --- a/chaco/data_view.py +++ b/chaco/data_view.py @@ -2,6 +2,7 @@ functions. """ import numpy as np +from numpy import array, transpose from traits.api import Bool, Enum, Instance, Property from enable.api import color_table @@ -239,13 +240,13 @@ def map_screen(self, data_array): if len(data_array) == 0: return np.empty(shape=(0,2)) - x_ary, y_ary = np.transpose(data_array) + x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) if self.orientation == "h": - return np.transpose(np.array((sx, sy))) + return transpose(array((sx, sy))) else: - return np.transpose(np.array((sy, sx))) + return transpose(array((sy, sx))) def map_data(self, screen_pt): """Maps a screen space point into the 2D data space of this plot. @@ -255,7 +256,7 @@ def map_data(self, screen_pt): # At some point it would be good to change the DataView to use # the GridMapper, and then use its map_data() method. x, y = screen_pt - return np.array( + return array( (self.index_mapper.map_data(x), self.value_mapper.map_data(y)) ) diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index d192545a1..9d1f5a3bd 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -8,6 +8,7 @@ # Major library imports import numpy as np +from numpy import column_stack, transpose # Enthought library imports from traits.api import Bool, DelegatesTo, Instance, Float, Property @@ -118,12 +119,12 @@ def map_screen(self, data_pts): """ # ensure data_array is an Nx2 ndarray data_pts = np.asarray(data_pts) - data_pts = data_pts.reshape(-1, 2) - - xs, ys = np.transpose(data_pts) + data_pts = data_pts.reshape(-1,2) + + xs, ys = transpose(data_pts) screen_xs = self._xmapper.map_screen(xs) screen_ys = self._ymapper.map_screen(ys) - screen_pts = np.column_stack([screen_xs, screen_ys]) + screen_pts = column_stack([screen_xs, screen_ys]) return screen_pts def map_data(self, screen_pts): @@ -131,10 +132,10 @@ def map_data(self, screen_pts): Maps values from screen space into data space. """ - screen_xs, screen_ys = np.transpose(screen_pts) + screen_xs, screen_ys = transpose(screen_pts) xs = self._xmapper.map_data(screen_xs) ys = self._ymapper.map_data(screen_ys) - data_pts = np.column_stack([xs, ys]) + data_pts = column_stack([xs, ys]) return data_pts def map_data_array(self, screen_pts): diff --git a/chaco/log_mapper.py b/chaco/log_mapper.py index 7aff2408e..4316576dd 100644 --- a/chaco/log_mapper.py +++ b/chaco/log_mapper.py @@ -1,6 +1,18 @@ """ Defines the LogMapper and InvalidDataRangeException classes. """ # Major library imports +from numpy import ( + array, + isnan, + log, + log10, + exp, + zeros, + sometrue, + floor, + ceil, + ndarray, +) import numpy as np # Enthought library imports @@ -46,8 +58,8 @@ def map_screen(self, data_array): Overrides AbstractMapper. Maps values from data space to screen space. """ # Ensure that data_array is actually an array. - if not isinstance(data_array, np.ndarray): - data_array = np.array(data_array, ndmin=1) + if not isinstance(data_array, ndarray): + data_array = array(data_array, ndmin=1) # First convert to a [0,1] space, then to the screen space. if not self._cache_valid: self._compute_scale() @@ -56,15 +68,15 @@ def map_screen(self, data_array): else: try: with np.errstate(invalid="ignore"): - mask = (data_array <= LOG_MINIMUM) | np.isnan(data_array) - if np.sometrue(mask): - data_array = np.array(data_array, copy=True, ndmin=1) + mask = (data_array <= LOG_MINIMUM) | isnan(data_array) + if sometrue(mask): + data_array = array(data_array, copy=True, ndmin=1) data_array[mask] = self.fill_value intermediate = ( - np.log(data_array) - self._inter_offset + log(data_array) - self._inter_offset ) / self._inter_scale except ValueError: - intermediate = np.zeros(len(data_array)) + intermediate = zeros(len(data_array)) result = intermediate * self._screen_scale + self._screen_offset return result @@ -77,10 +89,10 @@ def map_data(self, screen_val): if not self._cache_valid: self._compute_scale() if self._null_screen_range or self._null_data_range: - return np.array([self.range.low]) + return array([self.range.low]) # First convert to a [0,1] space, then to the data space intermediate = (screen_val - self._screen_offset) / self._screen_scale - return np.exp(self._inter_scale * intermediate + self._inter_offset) + return exp(self._inter_scale * intermediate + self._inter_offset) def map_data_array(self, screen_vals): return self.map_data(screen_vals) @@ -107,12 +119,12 @@ def _get_safe_scale(self, range): low = 1.0 high = 10.0 else: - log_val = np.log10(low) - low = pow(10, np.floor(log_val)) - if np.ceil(log_val) != np.floor(log_val): - high = pow(10, np.ceil(log_val)) + log_val = log10(low) + low = pow(10, floor(log_val)) + if ceil(log_val) != floor(log_val): + high = pow(10, ceil(log_val)) else: - high = pow(10, np.ceil(log_val) + 1) + high = pow(10, ceil(log_val) + 1) return (low, high) @@ -135,11 +147,11 @@ def _compute_scale(self): self._null_data_range = True else: if low == LOG_MINIMUM: - self._inter_scale = np.log(high) + self._inter_scale = log(high) self._inter_offset = 0.0 else: - self._inter_scale = np.log(high) - np.log(low) - self._inter_offset = np.log(low) + self._inter_scale = log(high) - log(low) + self._inter_offset = log(low) self._screen_scale = screen_range self._screen_offset = self.low_pos From fabfc2587048aeeb88d7dcb13f2623bf13c325cc Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 14:50:07 -0500 Subject: [PATCH 13/25] follow existing lead of using numpy / remove unneeded [0] --- chaco/barplot.py | 8 ++++---- chaco/base_xy_plot.py | 7 +++---- chaco/data_view.py | 7 +++---- chaco/grid_mapper.py | 5 ++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/chaco/barplot.py b/chaco/barplot.py index 46a30e70e..00e00cb54 100644 --- a/chaco/barplot.py +++ b/chaco/barplot.py @@ -2,11 +2,11 @@ """ import logging -import numpy as np from numpy import ( array, compress, column_stack, + empty, invert, isnan, transpose, @@ -168,11 +168,11 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ # ensure data_array is an Nx2 ndarray - data_array = np.asarray(data_array) + data_array = array(data_array) data_array = data_array.reshape(-1,2) # data_array is Nx2 array if len(data_array) == 0: - return np.empty(shape=(0,2)) + return empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) @@ -345,7 +345,7 @@ def _draw_default_axes(self, gc): else: dual = self.index_mapper.range data_pts = array([[dual.low, 0.0], [dual.high, 0.0]]) - start, end = self.map_screen(data_pts)[0] + start, end = self.map_screen(data_pts) gc.move_to(int(start[0]) + 0.5, int(start[1]) + 0.5) gc.line_to(int(end[0]) + 0.5, int(end[1]) + 0.5) gc.stroke_path() diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index f1198dfb6..4627b9a22 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -1,8 +1,7 @@ """ Defines the base class for XY plots. """ from math import sqrt -import numpy as np -from numpy import around, array, isnan, transpose +from numpy import around, array, empty, isnan, transpose # Enthought library imports from enable.api import black_color_trait @@ -345,12 +344,12 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ # ensure data_array is an Nx2 ndarray - data_array = np.asarray(data_array) + data_array = array(data_array) data_array = data_array.reshape(-1, 2) # data_array is Nx2 array if len(data_array) == 0: - return np.empty(shape=(0, 2)) + return empty(shape=(0, 2)) x_ary, y_ary = transpose(data_array) diff --git a/chaco/data_view.py b/chaco/data_view.py index 3fd4ceaa3..219af48b6 100644 --- a/chaco/data_view.py +++ b/chaco/data_view.py @@ -1,8 +1,7 @@ """ Defines the DataView class, and associated property traits and property functions. """ -import numpy as np -from numpy import array, transpose +from numpy import array, empty, transpose from traits.api import Bool, Enum, Instance, Property from enable.api import color_table @@ -235,11 +234,11 @@ def map_screen(self, data_array): """ # ensure data_array is an Nx2 ndarray - data_array = np.asarray(data_array) + data_array = array(data_array) data_array = data_array.reshape(-1,2) if len(data_array) == 0: - return np.empty(shape=(0,2)) + return empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) sy = self.value_mapper.map_screen(y_ary) diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index 9d1f5a3bd..a88826262 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -7,8 +7,7 @@ from contextlib import contextmanager # Major library imports -import numpy as np -from numpy import column_stack, transpose +from numpy import array, column_stack, transpose # Enthought library imports from traits.api import Bool, DelegatesTo, Instance, Float, Property @@ -118,7 +117,7 @@ def map_screen(self, data_pts): Maps values from data space into screen space. """ # ensure data_array is an Nx2 ndarray - data_pts = np.asarray(data_pts) + data_pts = array(data_pts) data_pts = data_pts.reshape(-1,2) xs, ys = transpose(data_pts) From 8639b2d739a4674a86182cff0be8989aa769b6ae Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 15:51:26 -0500 Subject: [PATCH 14/25] add regression test for enthought/chaco#289 --- chaco/tools/tests/test_cursor_tool.py | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 chaco/tools/tests/test_cursor_tool.py diff --git a/chaco/tools/tests/test_cursor_tool.py b/chaco/tools/tests/test_cursor_tool.py new file mode 100644 index 000000000..7a248f115 --- /dev/null +++ b/chaco/tools/tests/test_cursor_tool.py @@ -0,0 +1,52 @@ +import unittest + +import numpy as np + +from enable.api import ComponentEditor +from enable.testing import EnableTestAssistant +from traits.api import HasTraits, Instance +from traits.etsconfig.api import ETSConfig +from traitsui.api import Item, View +from traitsui.testing.api import UITester + +from chaco.api import ArrayPlotData, Plot +from chaco.tools.cursor_tool import CursorTool + +class TestCursorTool(unittest.TestCase, EnableTestAssistant): + + # regression test for enthought/chaco#289 + @unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") + def test_use_with_log_mappers(self): + class TestCursor(HasTraits): + plot = Instance(Plot) + + traits_view = View( + Item('plot', editor=ComponentEditor(), show_label=False), + width=500, + height=500, + resizable=True + ) + + def _plot_default(self): + arr = np.logspace(0, 10, num=10) + data = ArrayPlotData(x=arr, y=arr) + plot = Plot(data) + renderer = plot.plot( + ("x", "y"), + index_scale="log", + value_scale="log" + )[0] + + cursor = CursorTool(renderer) + + renderer.overlays.append(cursor) + + return plot + + + tester = UITester() + test_cursor = TestCursor() + with tester.create_ui(test_cursor): + self.mouse_move( + test_cursor.plot, 10, 10 + ) From 48e7f9fe0f4887b240628b6ed68929be3fbd0f26 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 5 May 2021 16:07:01 -0500 Subject: [PATCH 15/25] add comment --- chaco/tools/tests/test_cursor_tool.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chaco/tools/tests/test_cursor_tool.py b/chaco/tools/tests/test_cursor_tool.py index 7a248f115..3f7ae686e 100644 --- a/chaco/tools/tests/test_cursor_tool.py +++ b/chaco/tools/tests/test_cursor_tool.py @@ -47,6 +47,7 @@ def _plot_default(self): tester = UITester() test_cursor = TestCursor() with tester.create_ui(test_cursor): + # should not fail self.mouse_move( test_cursor.plot, 10, 10 ) From 77436ac4edf7e14d479db3ea8e4440be11107fea Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 6 May 2021 10:34:37 -0500 Subject: [PATCH 16/25] add regression test for 550 --- chaco/tools/tests/test_data_label_tool.py | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 chaco/tools/tests/test_data_label_tool.py diff --git a/chaco/tools/tests/test_data_label_tool.py b/chaco/tools/tests/test_data_label_tool.py new file mode 100644 index 000000000..50db9f46e --- /dev/null +++ b/chaco/tools/tests/test_data_label_tool.py @@ -0,0 +1,50 @@ +import unittest + +import numpy as np + +from enable.api import ComponentEditor +from enable.testing import EnableTestAssistant +from traits.api import HasTraits, Instance +from traits.etsconfig.api import ETSConfig +from traitsui.api import Item, View + +from chaco.api import ArrayPlotData, DataLabel, Plot +from chaco.tools.api import DataLabelTool + +IMAGE = np.random.random_integers(0, 255, size=(100, 200)).astype(np.uint8) +RGB = np.dstack([IMAGE] * 3) + +class TestDataLabelTool(unittest.TestCase, EnableTestAssistant): + + # regression test for enthought/chaco#550 + def test_use_with_2d_plot(self): + class Test2DPlot(HasTraits): + plot = Instance(Plot) + + traits_view = View( + Item('plot', editor=ComponentEditor(), show_label=False), + width=500, + height=500, + resizable=True + ) + + def _plot_default(self): + pd = ArrayPlotData(image=RGB) + plot = Plot(pd) + self.renderer = plot.img_plot('image')[0] + + label = DataLabel( + component=self.renderer, + data_point=(25,12) + ) + plot.overlays.append(label) + tool = DataLabelTool(label) + label.tools.append(tool) + return plot + + test_2d_plot = Test2DPlot() + # should not fail + self.press_move_release( + test_2d_plot.plot, + [(0, 0), (200, 200), (300, 300)], + ) From e7fd534f3c94ef963aaa54bf05d44ae965fa863f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 6 May 2021 10:44:02 -0500 Subject: [PATCH 17/25] flake8 --- chaco/grid_mapper.py | 4 ++-- chaco/tests/test_plot.py | 9 ++++----- chaco/tools/tests/test_cursor_tool.py | 4 ++-- chaco/tools/tests/test_data_label_tool.py | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/chaco/grid_mapper.py b/chaco/grid_mapper.py index a88826262..907a17a2f 100644 --- a/chaco/grid_mapper.py +++ b/chaco/grid_mapper.py @@ -118,8 +118,8 @@ def map_screen(self, data_pts): """ # ensure data_array is an Nx2 ndarray data_pts = array(data_pts) - data_pts = data_pts.reshape(-1,2) - + data_pts = data_pts.reshape(-1, 2) + xs, ys = transpose(data_pts) screen_xs = self._xmapper.map_screen(xs) screen_ys = self._ymapper.map_screen(ys) diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index fe6dd94ff..ff01b9705 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -120,8 +120,7 @@ def test_segment_plot_map_screen(self): screen_point = plot_renderer.map_screen([(0, 1), (1, 2)]) self.assertEqual(type(screen_point), np.ndarray) - self.assertEqual(screen_point.shape, (1,2,2)) - + self.assertEqual(screen_point.shape, (1, 2, 2)) def check_map_screen(self, renderer): arr = arange(10) @@ -130,16 +129,16 @@ def check_map_screen(self, renderer): plot_renderer = plot.add_xy_plot( 'x', 'y', plot.renderer_map[renderer] )[0] - + screen_point = plot_renderer.map_screen((-1, 1)) self.assertEqual(type(screen_point), np.ndarray) - self.assertEqual(screen_point.shape, (1,2)) + self.assertEqual(screen_point.shape, (1, 2)) screen_point = plot_renderer.map_screen([]) self.assertEqual(type(screen_point), np.ndarray) - self.assertEqual(screen_point.shape, (0,2)) + self.assertEqual(screen_point.shape, (0, 2)) # serves as a regression test for enthought/chaco#272 def test_xy_plot_map_screen(self): diff --git a/chaco/tools/tests/test_cursor_tool.py b/chaco/tools/tests/test_cursor_tool.py index 3f7ae686e..6c27a5b89 100644 --- a/chaco/tools/tests/test_cursor_tool.py +++ b/chaco/tools/tests/test_cursor_tool.py @@ -12,6 +12,7 @@ from chaco.api import ArrayPlotData, Plot from chaco.tools.cursor_tool import CursorTool + class TestCursorTool(unittest.TestCase, EnableTestAssistant): # regression test for enthought/chaco#289 @@ -40,9 +41,8 @@ def _plot_default(self): cursor = CursorTool(renderer) renderer.overlays.append(cursor) - - return plot + return plot tester = UITester() test_cursor = TestCursor() diff --git a/chaco/tools/tests/test_data_label_tool.py b/chaco/tools/tests/test_data_label_tool.py index 50db9f46e..fff5a477f 100644 --- a/chaco/tools/tests/test_data_label_tool.py +++ b/chaco/tools/tests/test_data_label_tool.py @@ -5,7 +5,6 @@ from enable.api import ComponentEditor from enable.testing import EnableTestAssistant from traits.api import HasTraits, Instance -from traits.etsconfig.api import ETSConfig from traitsui.api import Item, View from chaco.api import ArrayPlotData, DataLabel, Plot @@ -14,6 +13,7 @@ IMAGE = np.random.random_integers(0, 255, size=(100, 200)).astype(np.uint8) RGB = np.dstack([IMAGE] * 3) + class TestDataLabelTool(unittest.TestCase, EnableTestAssistant): # regression test for enthought/chaco#550 @@ -35,7 +35,7 @@ def _plot_default(self): label = DataLabel( component=self.renderer, - data_point=(25,12) + data_point=(25, 12) ) plot.overlays.append(label) tool = DataLabelTool(label) From 0bf267e351888594771cfcf0d1820430e93beb6b Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 6 May 2021 13:06:43 -0500 Subject: [PATCH 18/25] more updates --- chaco/polar_line_renderer.py | 4 ++-- chaco/polar_mapper.py | 4 +++- examples/demo/advanced/spec_waterfall.py | 3 ++- examples/demo/basic/hittest_tool.py | 4 ++-- examples/tutorials/scipy2008/custom_overlay_dataspace.py | 2 +- examples/tutorials/scipy2008/custom_overlay_movetool.py | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/chaco/polar_line_renderer.py b/chaco/polar_line_renderer.py index b34cd5b64..a029d4732 100644 --- a/chaco/polar_line_renderer.py +++ b/chaco/polar_line_renderer.py @@ -3,7 +3,7 @@ # Major library imports -from numpy import array, cos, pi, sin, transpose +from numpy import array, cos, empty, pi, sin, transpose # Enthought library imports from enable.api import black_color_trait, LineStyle @@ -88,7 +88,7 @@ def map_screen(self, data_array): """ if len(data_array) == 0: - return [] + return empty(shape=(0, 2)) elif len(data_array) == 1: xtmp, ytmp = transpose(data_array) x_ary = xtmp diff --git a/chaco/polar_mapper.py b/chaco/polar_mapper.py index afb0a531c..35311ec3d 100644 --- a/chaco/polar_mapper.py +++ b/chaco/polar_mapper.py @@ -4,7 +4,7 @@ """ # Major library imports -from numpy import array +from numpy import array, ndarray # Enthought library imports from traits.api import Bool, Float @@ -48,6 +48,8 @@ def map_screen(self, data_array): if self._null_data_range: return array([self.low_pos] * len(data_array)) else: + if not isinstance(data_array, ndarray): + data_array = array(data_array, ndmin=1) return (data_array - self.range.low) * self._scale + self.low_pos def map_data(self, screen_val): diff --git a/examples/demo/advanced/spec_waterfall.py b/examples/demo/advanced/spec_waterfall.py index 49f45001b..e0a11b35c 100644 --- a/examples/demo/advanced/spec_waterfall.py +++ b/examples/demo/advanced/spec_waterfall.py @@ -77,8 +77,9 @@ def map_screen(self, data_array, data_offset=None): mapping data_array with y2_mapper. If data_offset is not provided, then y2_mapper is used. """ + print(data_array.shape) if len(data_array) == 0: - return [] + return empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) sx = self.index_mapper.map_screen(x_ary) if data_offset is not None: diff --git a/examples/demo/basic/hittest_tool.py b/examples/demo/basic/hittest_tool.py index 4f45db75c..429552b04 100644 --- a/examples/demo/basic/hittest_tool.py +++ b/examples/demo/basic/hittest_tool.py @@ -46,14 +46,14 @@ def normal_mouse_move(self, event): else: x, y = self.component.map_data((y, x)) - x, y = self.line_plot.map_screen((x, y)) + x, y = self.line_plot.map_screen((x, y))[0] self.pt = self.line_plot.hittest((x, y), threshold=self.threshold) self.request_redraw() def overlay(self, plot, gc, view_bounds=None, mode="normal"): # If we have a point, draw it to the screen as a small square if self.pt is not None: - x, y = plot.map_screen(self.pt) + x, y = plot.map_screen(self.pt)[0] gc.draw_rect((int(x) - 2, int(y) - 2, 4, 4)) diff --git a/examples/tutorials/scipy2008/custom_overlay_dataspace.py b/examples/tutorials/scipy2008/custom_overlay_dataspace.py index 24fb2321d..27b421b69 100644 --- a/examples/tutorials/scipy2008/custom_overlay_dataspace.py +++ b/examples/tutorials/scipy2008/custom_overlay_dataspace.py @@ -43,7 +43,7 @@ class CustomOverlay(AbstractOverlay): def overlay(self, component, gc, view_bounds=None, mode="normal"): if self.dataspace: - self.x, self.y = component.map_screen(self._anchor) + self.x, self.y = component.map_screen(self._anchor)[0] gc.set_fill_color(self.color_) x = self.x + component.x y = self.y + component.y diff --git a/examples/tutorials/scipy2008/custom_overlay_movetool.py b/examples/tutorials/scipy2008/custom_overlay_movetool.py index 1b30627f5..b6ad1c305 100644 --- a/examples/tutorials/scipy2008/custom_overlay_movetool.py +++ b/examples/tutorials/scipy2008/custom_overlay_movetool.py @@ -53,7 +53,7 @@ class CustomOverlay(AbstractOverlay): def overlay(self, component, gc, view_bounds=None, mode="normal"): if self.dataspace: - self.x, self.y = component.map_screen(self._anchor) + self.x, self.y = component.map_screen(self._anchor)[0] gc.set_fill_color(self.color_) x = self.x + component.x y = self.y + component.y From 9e6da2e0f23f748e87eb159b8b2235ab06a49959 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 12 May 2021 09:02:44 -0500 Subject: [PATCH 19/25] remove debugging print statement --- examples/demo/advanced/spec_waterfall.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/demo/advanced/spec_waterfall.py b/examples/demo/advanced/spec_waterfall.py index e0a11b35c..0df097184 100644 --- a/examples/demo/advanced/spec_waterfall.py +++ b/examples/demo/advanced/spec_waterfall.py @@ -77,7 +77,6 @@ def map_screen(self, data_array, data_offset=None): mapping data_array with y2_mapper. If data_offset is not provided, then y2_mapper is used. """ - print(data_array.shape) if len(data_array) == 0: return empty(shape=(0,2)) x_ary, y_ary = transpose(data_array) From 2f9a95affd68954b6f3b63b34ce2370b913b1fd1 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 12 May 2021 09:04:55 -0500 Subject: [PATCH 20/25] clean up map_screen use in LinearMapper hittest method --- chaco/lineplot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chaco/lineplot.py b/chaco/lineplot.py index a12c6a2b8..5ac3d3cb5 100644 --- a/chaco/lineplot.py +++ b/chaco/lineplot.py @@ -112,10 +112,10 @@ def hittest(self, screen_pt, threshold=7.0, return_distance=False): # screen_pt is one of the points in the lineplot data_pt = (self.index.get_data()[ndx], self.value.get_data()[ndx]) if return_distance: - scrn_pt = self.map_screen(data_pt) + scrn_pt = self.map_screen(data_pt)[0] dist = sqrt( - (screen_pt[0] - scrn_pt[0, 0]) ** 2 - + (screen_pt[1] - scrn_pt[0, 1]) ** 2 + (screen_pt[0] - scrn_pt[0]) ** 2 + + (screen_pt[1] - scrn_pt[1]) ** 2 ) return (data_pt[0], data_pt[1], dist) else: From a35b264230adcf44967cedfaae12eda7fcdaaeb2 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Jun 2021 14:30:35 -0500 Subject: [PATCH 21/25] flake8 --- chaco/plots/segment_plot.py | 2 +- chaco/plots/tests/test_image_plot.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chaco/plots/segment_plot.py b/chaco/plots/segment_plot.py index 1b8a888e4..13000368f 100644 --- a/chaco/plots/segment_plot.py +++ b/chaco/plots/segment_plot.py @@ -152,7 +152,7 @@ def map_screen(self, data_array): return np.transpose(np.array((sx, sy))) else: return np.transpose(np.array((sy, sx))) - + def _gather_points(self): """Collects the data points that are within the bounds of the plot and caches them. diff --git a/chaco/plots/tests/test_image_plot.py b/chaco/plots/tests/test_image_plot.py index 6dafc208a..1825f2f69 100644 --- a/chaco/plots/tests/test_image_plot.py +++ b/chaco/plots/tests/test_image_plot.py @@ -199,11 +199,11 @@ def test_map_screen(self): # itself. screen_pt = renderer.map_screen([(0, 0)]) self.assertEqual(type(screen_pt), np.ndarray) - self.assertEqual(screen_pt.shape, (1,2)) + self.assertEqual(screen_pt.shape, (1, 2)) screen_pt = renderer.map_screen([]) self.assertEqual(type(screen_pt), np.ndarray) - self.assertEqual(screen_pt.shape, (0,2)) + self.assertEqual(screen_pt.shape, (0, 2)) # regression test for enthought/chaco#528 @unittest.skipIf(is_null or is_qt4(), "Skip on 'null' or 'qt4' toolkit") From 58f3a00942334342d0957aa27efc69de6a02accc Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Jun 2021 15:10:27 -0500 Subject: [PATCH 22/25] be less strict in BaseXYPlot --- chaco/base_xy_plot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chaco/base_xy_plot.py b/chaco/base_xy_plot.py index 4627b9a22..c0ca344cc 100644 --- a/chaco/base_xy_plot.py +++ b/chaco/base_xy_plot.py @@ -343,9 +343,13 @@ def map_screen(self, data_array): Implements the AbstractPlotRenderer interface. """ - # ensure data_array is an Nx2 ndarray + # ensure data_array is an N1 x ... Nk x 2 ndarray for some k >= 1 data_array = array(data_array) - data_array = data_array.reshape(-1, 2) + + if data_array.ndim == 1: + data_array = data_array.reshape(-1, 2) + if data_array.shape[-1] != 2: + raise ValueError("Input to map_screen must have shape (..., 2)") # data_array is Nx2 array if len(data_array) == 0: From 704c75826e20faeae87d45742527565492aafc0c Mon Sep 17 00:00:00 2001 From: aaronayres35 <36972686+aaronayres35@users.noreply.github.com> Date: Wed, 7 Jul 2021 09:24:28 -0500 Subject: [PATCH 23/25] Remove repeated test_segment_plot_map_screen --- chaco/tests/test_plot.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index 7465c1165..9e458d5da 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -122,18 +122,6 @@ def test_text_plot(self): actual = gc.bmp_array[:, :, :] self.assertFalse(alltrue(actual == 255)) - def test_segment_plot_map_screen(self): - x = arange(10) - y = arange(1, 11) - data = ArrayPlotData(x=x, y=y) - plot = Plot(data) - plot_renderer = plot.plot(("x", "y"), "segment")[0] - - screen_point = plot_renderer.map_screen([(0, 1), (1, 2)]) - - self.assertEqual(type(screen_point), np.ndarray) - self.assertEqual(screen_point.shape, (1, 2, 2)) - def check_map_screen(self, renderer): arr = arange(10) data = ArrayPlotData(x=arr, y=arr) From 32e2ec6c3538cfc11eeec70dbf45a8365d768164 Mon Sep 17 00:00:00 2001 From: aaronayres35 <36972686+aaronayres35@users.noreply.github.com> Date: Wed, 7 Jul 2021 09:46:37 -0500 Subject: [PATCH 24/25] Remove redundant import --- chaco/plots/barplot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/chaco/plots/barplot.py b/chaco/plots/barplot.py index eae2e921d..4e8915654 100644 --- a/chaco/plots/barplot.py +++ b/chaco/plots/barplot.py @@ -18,7 +18,6 @@ column_stack, empty, invert, - empty, isnan, transpose, zeros, From dd3774cc48b62f4a0d1148b543aa691036f3504e Mon Sep 17 00:00:00 2001 From: aaronayres35 <36972686+aaronayres35@users.noreply.github.com> Date: Wed, 7 Jul 2021 09:47:32 -0500 Subject: [PATCH 25/25] dont remove copyright header --- chaco/tools/tests/test_cursor_tool.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chaco/tools/tests/test_cursor_tool.py b/chaco/tools/tests/test_cursor_tool.py index 25dca3bc2..7f7a443da 100644 --- a/chaco/tools/tests/test_cursor_tool.py +++ b/chaco/tools/tests/test_cursor_tool.py @@ -1,3 +1,12 @@ +# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! import unittest import numpy as np