Skip to content

Commit

Permalink
Further improved OptionTree repr
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Jun 23, 2015
1 parent 869cecb commit 2f824c1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions holoviews/core/options.py
Expand Up @@ -501,24 +501,28 @@ def __repr__(self):
esep, gspecs = (",\n"+(tab*2)), []

for group in groups.keys():
especs = []
especs, accumulator = [], []
if groups[group].kwargs != {}:
especs.append(('.', groups[group].kwargs))
accumulator.append(('.', groups[group].kwargs))

for t, v in sorted(self.items()):
kwargs = v.groups[group].kwargs
if group=='norm' and (kwargs == dict(axiswise=False,framewise=False)):
accumulator.append(('.'.join(t), kwargs))

for (t, kws) in accumulator:
if group=='norm' and all(kws[k] is False for k in ['axiswise','framewise']):
continue
if kwargs:
especs.append(('.'.join(t), kwargs))
elif kws:
especs.append((t, kws))

if especs:
format_kws = [(t,'dict(%s)'
% ', '.join('%s=%r' % (k,v) for k,v in sorted(kws.items())))
for t,kws in especs]
ljust = max(len(t) for t,_ in format_kws)
entries = (tab*2) + esep.join([(tab*2)+'%r : %s' % (t.ljust(ljust),v) for t,v in format_kws])
gspecs.append('%s%s={\n%s}' % (tab,group, entries))
sep = (tab*2) if len(format_kws) >1 else ''
entries = sep + esep.join([sep+'%r : %s' % (t.ljust(ljust),v) for t,v in format_kws])
gspecs.append(('%s%s={\n%s}' if len(format_kws)>1 else '%s%s={%s}') % (tab,group, entries))

return 'OptionTree(groups=%s,\n%s\n)' % (groups.keys(), gsep.join(gspecs))

Expand Down

0 comments on commit 2f824c1

Please sign in to comment.