-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed dynamic stream sources assignment in plotting code #1297
Changes from 1 commit
a283ee7
e60d01c
1fe4859
9248fb9
3ab6adf
9cd0109
ce4c476
75d6261
5941c83
1f78b12
f88b8f4
048642f
521f7be
243bd41
63c50f6
945d363
9779aa6
1be4abe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,21 @@ def isoverlay_fn(obj): | |
return isinstance(obj, DynamicMap) and (isinstance(obj.last, CompositeOverlay)) | ||
|
||
|
||
def overlay_depth(obj): | ||
""" | ||
Computes the depth of a DynamicMap overlay if it can be determined | ||
otherwise return None. | ||
""" | ||
if isinstance(obj, DynamicMap): | ||
if isinstance(obj.last, CompositeOverlay): | ||
return len(obj.last) | ||
elif obj.last is None: | ||
return None | ||
return 1 | ||
else: | ||
return 1 | ||
|
||
|
||
def compute_overlayable_zorders(obj, path=[]): | ||
""" | ||
Traverses an overlayable composite container to determine which | ||
|
@@ -108,6 +123,7 @@ def compute_overlayable_zorders(obj, path=[]): | |
isdynoverlay = obj.callback._is_overlay | ||
if obj not in zorder_map[0] and not isoverlay: | ||
zorder_map[0].append(obj) | ||
depth = overlay_depth(obj) | ||
|
||
# Process the inputs of the DynamicMap callback | ||
dmap_inputs = obj.callback.inputs if obj.callback.link_inputs else [] | ||
|
@@ -116,13 +132,18 @@ def compute_overlayable_zorders(obj, path=[]): | |
# Skips branches of graph that collapse Overlay layers | ||
# to avoid adding layers that have been reduced or removed | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if you have an operation that takes in an overlay of 3 things and returns an overlay of 2 things? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now handled. |
||
elif depth is not None and depth < overlay_depth(inp): | ||
# Skips branch of graph where the number of elements in an | ||
# overlay has been reduced | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean linking from inputs is disabled for this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it can't figure out which parts of the input operation should continue to be linked. A user may be able to supply that information but at that point its easier for them to declare their own Callable and list the inputs they need explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example in the example used for the unit test they could do this: combined = (area_redim*curve_redim*area2).map(lambda x: x.clone(x.items()[:2]), Overlay)
combined.callback.inputs += [area_redim, curve_redim] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not bad at and better than trying to complicate things for what I expect is a fairly rare case anyway. |
||
|
||
# Recurse into DynamicMap.callback.inputs and update zorder_map | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this would not happen for a DynamicMap callback with inputs that is user defined i.e There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's correct, the branch below handles that by iterating over the items in the user defined DynamicMap, which will ensure the zorder is maintained but won't attempt to figure out linked inputs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. As we discussed, this should be ok as the user can set things up explicitly if they want to transfer sources around (which means they shouldn't ever need to use Seems fine. |
||
z = z if isdynoverlay else 0 | ||
dinputs = compute_overlayable_zorders(inp, path=path) | ||
deep_zorders = compute_overlayable_zorders(inp, path=path) | ||
offset = max(zorder_map.keys()) | ||
for k, v in dinputs.items(): | ||
zorder_map[offset+k+z] = list(unique_iterator(zorder_map[offset+k+z]+v)) | ||
for dz, objs in deep_zorders.items(): | ||
global_z = offset+dz+z | ||
zorder_map[global_z] = list(unique_iterator(zorder_map[global_z]+objs)) | ||
|
||
# If object branches but does not declare inputs (e.g. user defined | ||
# DynamicMaps returning (Nd)Overlay) add the items on the DynamicMap.last | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would execute if
.last
is None. Maybe this is ok because you are assuminginitial_key
is called already?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is in plotting, the graph has to have been evaluated by this point, even if certain (unimportant) intermediate nodes haven't been.