Skip to content

Commit

Permalink
Fixed bug initializing empty data in combined dictionary format
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 14, 2018
1 parent 50fadb1 commit 08103fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions holoviews/core/data/dictionary.py
Expand Up @@ -89,11 +89,15 @@ def init(cls, eltype, data, kdims, vdims):
for d, vals in data.items():
if isinstance(d, tuple):
vals = np.asarray(vals)
if not vals.ndim == 2 and vals.shape[1] == len(d):
if vals.shape == (0,):
for sd in d:
unpacked.append((sd, np.array([])))
elif not vals.ndim == 2 and vals.shape[1] == len(d):
raise ValueError("Values for %s dimensions did not have "
"the expected shape.")
for i, sd in enumerate(d):
unpacked.append((sd, vals[:, i]))
else:
for i, sd in enumerate(d):
unpacked.append((sd, vals[:, i]))
else:
vals = vals if np.isscalar(vals) else np.asarray(vals)
if not np.isscalar(vals) and not vals.ndim == 1:
Expand Down
5 changes: 5 additions & 0 deletions tests/core/data/testdataset.py
Expand Up @@ -1077,6 +1077,11 @@ def test_dataset_empty_list_init_dtypes(self):
for d in 'xy':
self.assertEqual(dataset.dimension_values(d).dtype, np.float64)

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)


class GridTests(object):
"""
Expand Down

0 comments on commit 08103fc

Please sign in to comment.