Skip to content

Commit

Permalink
Optimize display of large DynamicMap parameter space (#2646)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed May 4, 2018
1 parent 24df133 commit 9cdad85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,9 @@ def drop_streams(streams, kdims, keys):
stream_params = stream_parameters(streams)
inds, dims = zip(*[(ind, kdim) for ind, kdim in enumerate(kdims)
if kdim not in stream_params])
return dims, [tuple(wrap_tuple(key)[ind] for ind in inds) for key in keys]
get = operator.itemgetter(*inds) # itemgetter used for performance
keys = (get(k) for k in keys)
return dims, ([wrap_tuple(k) for k in keys] if len(inds) == 1 else list(keys))


def itervalues(obj):
Expand Down
6 changes: 1 addition & 5 deletions holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,7 @@ def __init__(self, element, keys=None, ranges=None, dimensions=None,
self.top_level = keys is None
if self.top_level:
dimensions = self.hmap.kdims
values = [d.values for d in dimensions]
if dynamic and values and all(values):
keys = list(product(*values))
else:
keys = list(self.hmap.data.keys())
keys = list(self.hmap.data.keys())

self.style = self.lookup_options(plot_element, 'style') if style is None else style
plot_opts = self.lookup_options(plot_element, 'plot').options
Expand Down
16 changes: 12 additions & 4 deletions holoviews/plotting/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ...core import OrderedDict, NdMapping
from ...core.options import Store
from ...core.ndmapping import item_check
from ...core.util import (dimension_sanitizer, bytes_to_unicode,
unique_array, unicode, isnumeric,
wrap_tuple_streams, drop_streams)
Expand Down Expand Up @@ -110,9 +111,11 @@ def __init__(self, plot, renderer=None, **params):
for stream in plot.streams:
if any(k in plot.dimensions for k in stream.contents):
streams.append(stream)

keys = plot.keys[:1] if self.plot.dynamic else plot.keys
self.dimensions, self.keys = drop_streams(streams,
plot.dimensions,
plot.keys)
keys)
defaults = [kd.default for kd in self.dimensions]
self.init_key = tuple(v if d is None else d for v, d in
zip(self.keys[0], defaults))
Expand All @@ -124,9 +127,11 @@ def __init__(self, plot, renderer=None, **params):
self.renderer = Store.renderers[backend]
else:
self.renderer = renderer

# Create mock NdMapping to hold the common dimensions and keys
self.mock_obj = NdMapping([(k, None) for k in self.keys],
kdims=list(self.dimensions), sort=False)
with item_check(False):
self.mock_obj = NdMapping([(k, None) for k in self.keys], kdims=list(self.dimensions),
sort=False)

NdWidget.widgets[self.id] = self

Expand Down Expand Up @@ -298,7 +303,10 @@ class SelectionWidget(NdWidget):
def get_widgets(self):
# Generate widget data
widgets, dimensions, init_dim_vals = [], [], []
hierarchy = hierarchical(list(self.mock_obj.data.keys()))
if self.plot.dynamic:
hierarchy = None
else:
hierarchy = hierarchical(list(self.mock_obj.data.keys()))
for idx, dim in enumerate(self.mock_obj.kdims):
# Hide widget if it has 1-to-1 mapping to next widget
if self.plot.dynamic:
Expand Down

0 comments on commit 9cdad85

Please sign in to comment.