From 6915dce0a4b8b574f51d50a4858accabbef7772b Mon Sep 17 00:00:00 2001 From: John Wiggins Date: Tue, 3 Jul 2018 13:51:52 +0200 Subject: [PATCH] FIX: Ensure contiguous inputs to points_in_polygon (#410) --- chaco/polygon_plot.py | 2 +- chaco/tools/lasso_selection.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/chaco/polygon_plot.py b/chaco/polygon_plot.py index 4234bf667..aec89af41 100644 --- a/chaco/polygon_plot.py +++ b/chaco/polygon_plot.py @@ -134,7 +134,7 @@ def hittest(self, screen_pt, threshold=7.0, return_distance=False): data_pt = self.map_data(screen_pt, all_values=True) index = self.index.get_data() value = self.value.get_data() - poly = np.vstack((index,value)).T + poly = np.column_stack((index, value)) if points_in_polygon([data_pt], poly)[0] == 1: return True else: diff --git a/chaco/tools/lasso_selection.py b/chaco/tools/lasso_selection.py index fa2d5b4f9..053eb863d 100644 --- a/chaco/tools/lasso_selection.py +++ b/chaco/tools/lasso_selection.py @@ -2,7 +2,7 @@ """ # Major library imports import numpy -from numpy import array, empty, sometrue, vstack, zeros, ascontiguousarray +from numpy import array, column_stack, empty, sometrue, vstack, zeros # Enthought library imports from traits.api import Any, Array, Enum, Event, Bool, Instance, \ @@ -308,9 +308,8 @@ def _map_data(self, point): def _get_data(self): """ Returns the datapoints in the plot, as an Nx2 array of (x,y). """ - points = array((self.plot.index.get_data(), - self.plot.value.get_data())) - return ascontiguousarray(points.T) + return column_stack((self.plot.index.get_data(), + self.plot.value.get_data())) #------------------------------------------------------------------------ # Property getter/setters