[llvm-commits] [LNT] r161386 - /lnt/trunk/lnt/server/ui/util.py
Daniel Dunbar
daniel at zuster.org
Wed Aug 15 11:28:21 PDT 2012
On Mon, Aug 6, 2012 at 7:54 PM, Michael Gottesman <mgottesman at apple.com> wrote:
> Author: mgottesman
> Date: Mon Aug 6 21:54:52 2012
> New Revision: 161386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161386&view=rev
> Log:
> [LNT] Added code to lnt/server/ui/util.py so that one can get the color string from a
> cell without needing to render an actual html table cell. Also coloring NaNs was not
> being handled correctly since the code was checking for non floats only instead of
> non floats and NaNs.
>
> Modified:
> lnt/trunk/lnt/server/ui/util.py
>
> Modified: lnt/trunk/lnt/server/ui/util.py
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/util.py?rev=161386&r1=161385&r2=161386&view=diff
> ==============================================================================
> --- lnt/trunk/lnt/server/ui/util.py (original)
> +++ lnt/trunk/lnt/server/ui/util.py Mon Aug 6 21:54:52 2012
> @@ -173,7 +173,10 @@
>
> def getColor(self):
> v = self.value
> - if not isinstance(v, float):
> +
> + # NaN is the unique floating point number with the property
> + # that NaN != NaN. We use this to detect actual NaNs.
> + if not isinstance(v, float) or v != v:
> return self.kNANColor
This should just use math.isnan(), I think.
- Daniel
>
> # Clamp value.
> @@ -199,15 +202,18 @@
> return self.value
> return '%.*f%%' % (self.precision, self.value*100)
>
> + def getColorString(self):
> + r,g,b = [clamp(int(v*255), 0, 255)
> + for v in self.getColor()]
> + return "#%02x%02x%02x" % (r,g,b)
> +
> def render(self, style=None):
> if style is None:
> style_string = ""
> else:
> style_string = ' style="%s"' % (style,)
> - r,g,b = [clamp(int(v*255), 0, 255)
> - for v in self.getColor()]
> - res = '<td%s bgcolor="#%02x%02x%02x">%s</td>' % (
> - style_string, r, g, b, self.getValue())
> + res = '<td%s bgcolor="%s">%s</td>' % (
> + style_string, self.getColorString(), self.getValue())
> return res
>
> def sorted(l, *args, **kwargs):
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list