From 638183b5626cdd159b52c9446db88d23dd782a7e Mon Sep 17 00:00:00 2001 From: Jeremy Carbaugh Date: Mon, 19 Sep 2011 14:41:54 -0400 Subject: [PATCH] add prep_field method to histogram to allow for custom labeling and grouping of values --- saucebrush/stats.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/saucebrush/stats.py b/saucebrush/stats.py index 94e46e2..4099b71 100644 --- a/saucebrush/stats.py +++ b/saucebrush/stats.py @@ -195,10 +195,14 @@ class Histogram(StatsFilter): self._data = {} def process_field(self, item): + item = self.prep_field(item) if item not in self._data: self._data[item] = 0 self._data[item] += 1 + def prep_field(self, item): + return item + def value(self): return self._data.copy() @@ -208,4 +212,3 @@ class Histogram(StatsFilter): key_str = str(key).ljust(self.label_length)[:self.label_length] output += "%s %s\n" % (key_str, "*" * self._data[key]) return output - \ No newline at end of file