From 8489507fe0f5635ff71294a18a1f0c7af3e3f7ce Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 18 Mar 2021 15:22:03 -0500 Subject: [PATCH 1/3] have get_data return empty 1d array of length 0, not 0.0 if _data is None --- chaco/array_data_source.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/array_data_source.py b/chaco/array_data_source.py index 1df4e1dbe..cec77480d 100644 --- a/chaco/array_data_source.py +++ b/chaco/array_data_source.py @@ -1,7 +1,7 @@ """ Defines the ArrayDataSource class.""" # Major library imports -from numpy import array, isfinite, ones, ndarray +from numpy import array, empty, isfinite, ones, ndarray import numpy as np # Enthought library imports @@ -153,7 +153,7 @@ def get_data(self): if self._data is not None: return self._data else: - return 0.0 + return empty(shape=(0,)) def get_data_mask(self): """get_data_mask() -> (data_array, mask_array) From 09fedad10fe8a17bf0c06d0daaf6bae667240bb3 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 18 Mar 2021 15:41:09 -0500 Subject: [PATCH 2/3] remove unneeded try except in _compute_bounds --- chaco/array_data_source.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/chaco/array_data_source.py b/chaco/array_data_source.py index cec77480d..ee8001fa2 100644 --- a/chaco/array_data_source.py +++ b/chaco/array_data_source.py @@ -248,11 +248,8 @@ def _compute_bounds(self, data=None): #data = self._data data = self.get_data() - data_len = 0 - try: - data_len = len(data) - except Exception: - pass + data_len = len(data) + if data_len == 0: self._min_index = 0 self._max_index = 0 From 9a731d6fa495e23cc48506b58c4f7fe9751524e7 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 13 Apr 2021 07:54:33 -0500 Subject: [PATCH 3/3] remove commented out code --- chaco/array_data_source.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/chaco/array_data_source.py b/chaco/array_data_source.py index 7bd20c858..37c6ce404 100644 --- a/chaco/array_data_source.py +++ b/chaco/array_data_source.py @@ -238,10 +238,6 @@ def _compute_bounds(self, data=None): # version of the dataset? if data is None: - # Several sources weren't setting the _data attribute, so we - # go through the interface. This seems like the correct thing - # to do anyway... right? - # data = self._data data = self.get_data() data_len = len(data)