Skip to content

Commit

Permalink
Ignore non-referenced data in dictionary format (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jul 7, 2018
1 parent a21095a commit e771a9c
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([vs for d, vs in unpacked if d in dimensions and not np.isscalar(vs)]):
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 e771a9c

Please sign in to comment.