From e778c6fb19f7bf0513ed3c63d7e8a83920443dad Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Tue, 9 Feb 2016 03:06:40 +0000
Subject: [PATCH] Ensured initial dynamicmap values are escaped correctly in
widgets
---
holoviews/plotting/widgets/__init__.py | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/holoviews/plotting/widgets/__init__.py b/holoviews/plotting/widgets/__init__.py
index e4c94c6d29..972fc082d0 100644
--- a/holoviews/plotting/widgets/__init__.py
+++ b/holoviews/plotting/widgets/__init__.py
@@ -20,13 +20,26 @@ def isnumeric(val):
except:
return False
-def escape_vals(vals):
+def escape_vals(vals, escape_numerics=True):
"""
Escapes a list of values to a string, converting to
unicode for safety.
"""
- return ["'"+unicode(safe_unicode(v))+"'" if not isnumeric(v) else
- ("'%.1f'" % v if v % 1 == 0 else "'%.10f'" % v) for v in vals]
+ if escape_numerics:
+ ints, floats = "'%.1f'", "'%.10f'"
+ else:
+ ints, floats = "%.1f", "%.10f"
+
+ escaped = []
+ for v in vals:
+ if not isnumeric(v):
+ v = "'"+unicode(safe_unicode(v))+"'"
+ elif v % 1 == 0:
+ v = ints % v
+ else:
+ v = floats % v
+ escaped.append(v)
+ return escaped
def escape_tuple(vals):
return "(" + ", ".join(vals) + (",)" if len(vals) == 1 else ")")
@@ -300,7 +313,7 @@ def get_widgets(self):
next_vals=next_vals)
widgets.append(widget_data)
dimensions.append(dim_str)
- init_dim_vals = escape_list(escape_vals(init_dim_vals))
+ init_dim_vals = escape_list(escape_vals(init_dim_vals, self.plot.dynamic))
return widgets, dimensions, init_dim_vals