Skip to content

Commit

Permalink
Fixed undefined variable bug in XArrayInterface (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed May 12, 2018
1 parent bbf765a commit 98f09ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ def select(cls, dataset, selection_mask=None, **selection):
return GridInterface.select(dataset, selection_mask, **selection)
dim = dim.name
if isinstance(v, slice):
dim_vals = dataset.data[k].values
v = (v.start, v.stop)
if isinstance(v, set):
validated[dim] = list(v)
elif isinstance(v, tuple):
dim_vals = dataset.data[k].values
upper = None if v[1] is None else v[1]-sys.float_info.epsilon*10
v = v[0], upper
if dim_vals.dtype.kind not in 'OSU' and np.all(dim_vals[1:] < dim_vals[:-1]):
Expand Down
4 changes: 3 additions & 1 deletion holoviews/element/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def compare_dataframe(cls, df1, df2, msg='DataFrames'):

@classmethod
def bounds_check(cls, el1, el2, msg=None):
if el1.bounds.lbrt() != el2.bounds.lbrt():
try:
cls.assert_array_almost_equal_fn(np.array(el1.bounds.lbrt()), np.array(el2.bounds.lbrt()))
except AssertionError:
raise cls.failureException("BoundingBoxes are mismatched: %s != %s."
% (el1.bounds.lbrt(), el2.bounds.lbrt()))

Expand Down
12 changes: 12 additions & 0 deletions tests/core/data/testdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,18 @@ def test_canonical_vdim(self):
self.assertEqual(dataset.dimension_values('z', flat=False),
canonical)

def test_select_slice(self):
ds = self.eltype((self.grid_xs, self.grid_ys[:2],
self.grid_zs[:2]), kdims=['x', 'y'],
vdims=['z'])
self.assertEqual(self.dataset_grid.select(y=slice(0, 0.25)), ds)

def test_select_tuple(self):
ds = self.eltype((self.grid_xs, self.grid_ys[:2],
self.grid_zs[:2]), kdims=['x', 'y'],
vdims=['z'])
self.assertEqual(self.dataset_grid.select(y=(0, 0.25)), ds)

def test_dataset_ndloc_index(self):
xs, ys = np.linspace(0.12, 0.81, 10), np.linspace(0.12, 0.391, 5)
arr = np.arange(10)*np.arange(5)[np.newaxis].T
Expand Down

0 comments on commit 98f09ef

Please sign in to comment.