From 7a177be8198937045c86def5160c017985f6c8de Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 15 Jan 2013 19:12:14 -0800 Subject: [PATCH] Prevent column summation if no non-None cells Change-Id: I96ec5f5c6391c9234f79ad751b5c1671eda393ef --- horizon/tables/base.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 2b31e6954..507293c8f 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -346,13 +346,18 @@ class Column(html.HTMLElement): """ if self.summation not in self.summation_methods: return None + summation_function = self.summation_methods[self.summation] data = [self.get_raw_data(datum) for datum in self.table.data] data = filter(lambda datum: datum is not None, data) - summation = summation_function(data) - for filter_func in self.filters: - summation = filter_func(summation) - return summation + + if len(data): + summation = summation_function(data) + for filter_func in self.filters: + summation = filter_func(summation) + return summation + else: + return None class Row(html.HTMLElement):