Simplified and improved output of Dimension.pprint
@@ -215,19 +215,16 @@ class Dimension(param.Parameterized):
def pprint(self):
- spec = self.name if self.name == self.label else (self.name, self.label)
- excluded = ['name'] if self.name == self.label else ['name', 'label']
- changed_params = {k:v for k,v in self.get_param_values(onlychanged=True)
- if k not in excluded}
- if len(changed_params) == 0:
- return 'Dimension({spec})'.format(spec=repr(spec))
-
- ordering = sorted( sorted(changed_params.keys()),
+ changed = dict(self.get_param_values(onlychanged=True))
+ if len(set([changed.get(k, k) for k in ['name','label']])) == 1:
+ return 'Dimension({spec})'.format(spec=repr(self.name))
+
+ ordering = sorted( sorted(changed.keys()),
key=lambda k: (- float('inf')
if self.params(k).precedence is None
else self.params(k).precedence))
- kws = ", ".join('%s=%s' % (k, changed_params[k]) for k in ordering)
- return 'Dimension({spec}, {kws})'.format(spec=repr(spec), kws=kws)
+ kws = ", ".join('%s=%r' % (k, changed[k]) for k in ordering if k != 'name')
+ return 'Dimension({spec}, {kws})'.format(spec=repr(self.name), kws=kws)
def __call__(self, spec=None, **overrides):
