Skip to content

Commit

Permalink
Reports: round values to desired precision before determining colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Sep 23, 2020
1 parent efd4f0e commit 80469ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ v6.2 (unreleased)

Lab
^^^
* Reports: round values to desired precision before determining colors (Jendrik Seipp).
* For developers: run CI tests on Ubuntu 20.04 in addition to 18.04 (Jendrik Seipp).

Downward Lab
Expand Down
19 changes: 15 additions & 4 deletions lab/reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,15 +724,26 @@ def _format_row(self, row_name, row):
row[col_name] = value
return

# Get the slice of the row that should be formated (i.e. the data columns).
# Note that there might be other columns (e.g. added by dynamic data
# modules) that should not be formated.
# Get the slice of the row that should be formatted (i.e., the data columns).
# Note that there might be other columns (e.g., added by dynamic data
# modules) that should not be formatted.
row_slice = {col_name: row.get(col_name) for col_name in self.col_names}

min_wins = self.get_min_wins(row_name)
highlight = min_wins is not None
colored = self.colored and highlight
colors = tools.get_colors(row_slice, min_wins) if colored else None
if colored:

def try_to_round(v):
try:
return round(v, self.digits)
except TypeError:
return v

rounded_row_slice = {
col: try_to_round(val) for col, val in row_slice.items()
}
colors = tools.get_colors(rounded_row_slice, min_wins)

if highlight:
min_value, max_value = tools.get_min_max(row_slice.values())
Expand Down

0 comments on commit 80469ec

Please sign in to comment.