Skip to content

Commit

Permalink
Small fixes for dataset length
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 8, 2016
1 parent d0c84d6 commit dbae3e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def __getitem__(self, slices):
selection = dict(zip(self.dimensions(label=True), slices))
data = self.select(**selection)
if value_select:
if len(data) == 1:
if data.shape[0] == 1:
return data[value_select][0]
else:
return data.reindex(vdims=[value_select])
Expand Down
2 changes: 1 addition & 1 deletion holoviews/element/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def compare_bounds(cls, el1, el2, msg='Bounds'):
@classmethod
def compare_dataset(cls, el1, el2, msg='Dataset'):
cls.compare_dimensioned(el1, el2)
if len(el1) != len(el2):
if el1.shape[0] != el2.shape[0]:
raise AssertionError("%s not of matching length." % msg)
dimension_data = [(d, el1[d], el2[d]) for d in el1.dimensions()]
for dim, d1, d2 in dimension_data:
Expand Down
4 changes: 2 additions & 2 deletions tests/testdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_dataset_array_hm(self):
def test_dataset_add_dimensions_value_hm(self):
table = self.dataset_hm.add_dimension('z', 1, 0)
self.assertEqual(table.kdims[1], 'z')
self.compare_arrays(table.dimension_values('z'), np.zeros(len(table)))
self.compare_arrays(table.dimension_values('z'), np.zeros(table.shape[0]))

def test_dataset_add_dimensions_values_hm(self):
table = self.dataset_hm.add_dimension('z', 1, range(1,12))
Expand Down Expand Up @@ -294,7 +294,7 @@ def test_dataset_groupby_dynamic(self):
def test_dataset_add_dimensions_value_ht(self):
table = self.dataset_ht.add_dimension('z', 1, 0)
self.assertEqual(table.kdims[1], 'z')
self.compare_arrays(table.dimension_values('z'), np.zeros(len(table)))
self.compare_arrays(table.dimension_values('z'), np.zeros(table.shape[0]))

def test_dataset_add_dimensions_values_ht(self):
table = self.dataset_ht.add_dimension('z', 1, range(1,12))
Expand Down

0 comments on commit dbae3e6

Please sign in to comment.