diff --git a/GEODE/Visualisation/Legend.py b/GEODE/Visualisation/Legend.py index 9403bc26690b998ce75213ad872979d8ca3be2e0..11b2e917031bd78b8d7d0b9fccf146d3b8682279 100644 --- a/GEODE/Visualisation/Legend.py +++ b/GEODE/Visualisation/Legend.py @@ -1,6 +1,3 @@ -from GEODE.Functional import curry - -@curry def take(maxWidth, shards): result = [] budget = maxWidth @@ -14,10 +11,16 @@ def take(maxWidth, shards): i += 1 return tuple(result) +def removeTrailingPunctuation(l): + i = len(l)-1 + while i > 0 and all([not c.isalnum() for c in l[i]]): + i -= 1 + return l[:i+1] + def trim(labels, maxWidth=10): if maxWidth is None: return labels else: shards = [label.split(' ') for label in labels] - prefixes = [*map(take(maxWidth), shards)] + prefixes = [removeTrailingPunctuation(take(maxWidth, s)) for s in shards] return [' '.join(prefix) for prefix in prefixes]