Skip to content

Commit

Permalink
Ignore non-referenced data in dictionary format
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jul 6, 2018
1 parent 435f00c commit 170e6b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions holoviews/core/data/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def init(cls, eltype, data, kdims, vdims):
if not np.isscalar(vals) and not vals.ndim == 1 and d in dimensions:
raise ValueError('DictInterface expects data for each column to be flat.')
unpacked.append((d, vals))
if not cls.expanded([d[1] for d in unpacked if not np.isscalar(d[1])]):
if not cls.expanded([v for d, v in unpacked if d in dimensions and not np.isscalar(v)]):
raise ValueError('DictInterface expects data to be of uniform shape.')
if isinstance(data, odict_types):
data.update(unpacked)
Expand Down Expand Up @@ -158,7 +158,8 @@ def shape(cls, dataset):

@classmethod
def length(cls, dataset):
lengths = [len(vals) for vals in dataset.data.values() if not np.isscalar(vals)]
lengths = [len(vals) for d, vals in dataset.data.items()
if d in dataset.dimensions() and not np.isscalar(vals)]
return max(lengths) if lengths else 1

@classmethod
Expand Down
7 changes: 7 additions & 0 deletions tests/core/data/testdictinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ def test_dataset_empty_combined_dimension(self):
ds = Dataset({('x', 'y'): []}, kdims=['x', 'y'])
ds2 = Dataset({'x': [], 'y': []}, kdims=['x', 'y'])
self.assertEqual(ds, ds2)

def test_dataset_ignore_non_dimensions(self):
ds = Dataset({'x': [0, 1], 'y': [1, 2], 'ignore_scalar': 1,
'ignore_array': np.array([2, 3]), 'ignore_None': None},
kdims=['x', 'y'])
ds2 = Dataset({'x': [0, 1], 'y': [1, 2]}, kdims=['x', 'y'])
self.assertEqual(ds, ds2)

0 comments on commit 170e6b6

Please sign in to comment.