Skip to content

Commit

Permalink
fix color
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Feb 14, 2017
1 parent 35dfb47 commit 02ab457
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions py/model_reporter/xhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2564,15 +2564,16 @@ def xhtml_possible_overspecification(self,**format):
x.end('tr')
x.end('thead')

def colorspec(problem_value, field_data):
def colorspec(problem_value, field_data=None):
nonlocal x
if field_data is None:
field_data = problem_value
y = -numpy.log10(numpy.fabs(problem_value))-2
if y<0: y=0
y /= 4
if y>1: y=1
y = 255-255.0*y
color = '#{:02X}0000'.format(int(y))
x.start('span', {'style': 'color:#FF0000'})
x.start('span', {'style': 'color:#{:02X}0000'.format(int(y))})
x.data(str(field_data))
x.end('span')

Expand All @@ -2583,40 +2584,16 @@ def colorspec(problem_value, field_data):
except ValueError:
x.td(str(overspec[0]))
x.start('td')
if numpy.fabs(overspec[2][0])>0.01:
x.start('span', {'style': 'color:#FF0000'})
elif numpy.fabs(overspec[2][0])>0.0001:
x.start('span', {'style': 'color:#770000'})
x.data(str(overspec[2][0]))
if numpy.fabs(overspec[2][0])>0.0001:
x.end('span')
colorspec(overspec[2][0])
for problem_param in overspec[2][1:]:
x.simple('br')
if numpy.fabs(problem_param)>0.01:
x.start('span', {'style': 'color:#FF0000'})
elif numpy.fabs(problem_param)>0.0001:
x.start('span', {'style': 'color:#770000'})
x.data(str(problem_param))
if numpy.fabs(problem_param)>0.0001:
x.end('span')
colorspec(problem_param)
x.end('td')
x.start('td')
if numpy.fabs(overspec[2][0])>0.01:
x.start('span', {'style': '#FF0000'})
elif numpy.fabs(overspec[2][0])>0.0001:
x.start('span', {'style': '#770000'})
x.data(overspec[1][0])
if numpy.fabs(overspec[2][0])>0.0001:
x.end('span')
colorspec(overspec[2][0], overspec[1][0])
for problem_param, problem_value in zip(overspec[1][1:],overspec[2][1:]):
x.simple('br')
if numpy.fabs(problem_value)>0.01:
x.start('span', {'style': 'color:#FF0000'})
elif numpy.fabs(problem_value)>0.0001:
x.start('span', {'style': 'color:#770000'})
x.data(problem_param)
if numpy.fabs(problem_value)>0.0001:
x.end('span')
colorspec(problem_value, problem_param)
x.end('td')
x.end('tr')
x.end('table')
Expand Down

0 comments on commit 02ab457

Please sign in to comment.