[pypy-commit] pypy default: An extra test
Author: Armin Rigo Branch: Changeset: r69097:f6c9256018a2 Date: 2014-02-08 11:11 +0100 http://bitbucket.org/pypy/pypy/changeset/f6c9256018a2/ Log:An extra test diff --git a/rpython/jit/metainterp/test/test_history.py b/rpython/jit/metainterp/test/test_history.py --- a/rpython/jit/metainterp/test/test_history.py +++ b/rpython/jit/metainterp/test/test_history.py @@ -1,6 +1,8 @@ from rpython.jit.metainterp.history import * from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.rlib.rfloat import NAN, INFINITY +from rpython.jit.codewriter import longlong +from rpython.translator.c.test.test_standalone import StandaloneTests def test_repr(): @@ -56,3 +58,19 @@ assert not c3.same_constant(c6) assert not c5.same_constant(c2) assert not c5.same_constant(c4) + + +class TestZTranslated(StandaloneTests): +def test_ztranslated_same_constant_float(self): +def fn(args): +n = INFINITY +c1 = ConstFloat(longlong.getfloatstorage(n - INFINITY)) +c2 = ConstFloat(longlong.getfloatstorage(n - INFINITY)) +c3 = ConstFloat(longlong.getfloatstorage(12.34)) +if c1.same_constant(c2): +print "ok!" +return 0 + +t, cbuilder = self.compile(fn) +data = cbuilder.cmdexec('') +assert "ok!\n" in data ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add tests
Author: Armin Rigo Branch: Changeset: r69096:4d5c3e138c63 Date: 2014-02-08 11:01 +0100 http://bitbucket.org/pypy/pypy/changeset/4d5c3e138c63/ Log:Add tests diff --git a/rpython/jit/metainterp/test/test_history.py b/rpython/jit/metainterp/test/test_history.py --- a/rpython/jit/metainterp/test/test_history.py +++ b/rpython/jit/metainterp/test/test_history.py @@ -1,5 +1,6 @@ from rpython.jit.metainterp.history import * from rpython.rtyper.lltypesystem import lltype, llmemory, rffi +from rpython.rlib.rfloat import NAN, INFINITY def test_repr(): @@ -38,3 +39,20 @@ assert not c3a.same_constant(c1b) assert not c3a.same_constant(c2b) assert c3a.same_constant(c3b) + +def test_same_constant_float(): +c1 = Const._new(12.34) +c2 = Const._new(12.34) +c3 = Const._new(NAN) +c4 = Const._new(NAN) +c5 = Const._new(INFINITY) +c6 = Const._new(INFINITY) +assert c1.same_constant(c2) +assert c3.same_constant(c4) +assert c5.same_constant(c6) +assert not c1.same_constant(c4) +assert not c1.same_constant(c6) +assert not c3.same_constant(c2) +assert not c3.same_constant(c6) +assert not c5.same_constant(c2) +assert not c5.same_constant(c4) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Backout b58a2c01fd59, adding this check again. I'm not sure, but I think
Author: Armin Rigo Branch: Changeset: r69099:966942db58df Date: 2014-02-08 11:13 +0100 http://bitbucket.org/pypy/pypy/changeset/966942db58df/ Log:Backout b58a2c01fd59, adding this check again. I'm not sure, but I think it should be fixed by 3a0ef8f31265. diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py --- a/rpython/jit/metainterp/pyjitpl.py +++ b/rpython/jit/metainterp/pyjitpl.py @@ -594,11 +594,9 @@ if tobox is not None: # sanity check: see whether the current struct value # corresponds to what the cache thinks the value is -# XXX pypy with the following check fails on micronumpy, -# XXX investigate -#resbox = executor.execute(self.metainterp.cpu, self.metainterp, -# rop.GETFIELD_GC, fielddescr, box) -#assert resbox.constbox().same_constant(tobox.constbox()) +resbox = executor.execute(self.metainterp.cpu, self.metainterp, + rop.GETFIELD_GC, fielddescr, box) +assert resbox.constbox().same_constant(tobox.constbox()) return tobox resbox = self.execute_with_descr(opnum, fielddescr, box) self.metainterp.heapcache.getfield_now_known(box, fielddescr, resbox) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the test on 64-bit
Author: Armin Rigo Branch: Changeset: r69098:3a0ef8f31265 Date: 2014-02-08 11:11 +0100 http://bitbucket.org/pypy/pypy/changeset/3a0ef8f31265/ Log:Fix the test on 64-bit diff --git a/rpython/jit/codewriter/longlong.py b/rpython/jit/codewriter/longlong.py --- a/rpython/jit/codewriter/longlong.py +++ b/rpython/jit/codewriter/longlong.py @@ -26,6 +26,7 @@ getrealfloat= lambda x: x gethash = compute_hash gethash_fast= longlong2float.float2longlong +extract_bits= longlong2float.float2longlong is_longlong = lambda TYPE: False # - @@ -42,6 +43,7 @@ getrealfloat= longlong2float.longlong2float gethash = lambda xll: rarithmetic.intmask(xll - (xll >> 32)) gethash_fast= gethash +extract_bits= lambda x: x is_longlong = lambda TYPE: (TYPE is lltype.SignedLongLong or TYPE is lltype.UnsignedLongLong) diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -275,7 +275,8 @@ def same_constant(self, other): if isinstance(other, ConstFloat): -return self.value == other.value +return (longlong.extract_bits(self.value) == +longlong.extract_bits(other.value)) return False def nonnull(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add comment
Author: Armin Rigo Branch: Changeset: r69100:dd43ba74cfeb Date: 2014-02-08 11:19 +0100 http://bitbucket.org/pypy/pypy/changeset/dd43ba74cfeb/ Log:Add comment diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -275,6 +275,9 @@ def same_constant(self, other): if isinstance(other, ConstFloat): +# careful in this comparison: if self.value and other.value +# are both NaN, stored as regular floats, then it will turn +# out to be false... return (longlong.extract_bits(self.value) == longlong.extract_bits(other.value)) return False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Expand the comment
Author: Armin Rigo Branch: Changeset: r69101:61a9f16c3e8b Date: 2014-02-08 11:35 +0100 http://bitbucket.org/pypy/pypy/changeset/61a9f16c3e8b/ Log:Expand the comment diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -276,8 +276,9 @@ def same_constant(self, other): if isinstance(other, ConstFloat): # careful in this comparison: if self.value and other.value -# are both NaN, stored as regular floats, then it will turn -# out to be false... +# are both NaN, stored as regular floats (i.e. on 64-bit), +# then just using "==" would say False: two NaNs are always +# different from each other. return (longlong.extract_bits(self.value) == longlong.extract_bits(other.value)) return False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Merged in krono/pypy/camelot (pull request #205)
Author: Armin Rigo Branch: Changeset: r69103:8d9c30585d33 Date: 2014-02-08 23:04 +0100 http://bitbucket.org/pypy/pypy/changeset/8d9c30585d33/ Log:Merged in krono/pypy/camelot (pull request #205) Essential! Thanks Tobias. diff --git a/rpython/tool/ansi_mandelbrot.py b/rpython/tool/ansi_mandelbrot.py --- a/rpython/tool/ansi_mandelbrot.py +++ b/rpython/tool/ansi_mandelbrot.py @@ -14,8 +14,12 @@ """ -palette = [39, 34, 35, 36, 31, 33, 32, 37] - +import os +if os.environ.get('TERM', 'dumb').find('256') > 0: +from ansiramp import ansi_ramp80 +palette = map(lambda x: "38;5;%d" % x, ansi_ramp80) +else: +palette = [39, 34, 35, 36, 31, 33, 32, 37] colour_range = None # used for debugging diff --git a/rpython/tool/ansiramp.py b/rpython/tool/ansiramp.py new file mode 100755 --- /dev/null +++ b/rpython/tool/ansiramp.py @@ -0,0 +1,20 @@ +#! /usr/bin/env python +import colorsys + +def hsv2ansi(h, s, v): +# h: 0..1, s/v: 0..1 +if s < 0.001: +return int(v * 23) + 232 +r, g, b = map(lambda x: int(x * 5), colorsys.hsv_to_rgb(h, s, v)) +return 16 + (r * 36) + (g * 6) + b + +def ramp_idx(i, num): +h = 0.57 + float(i)/num +s = float(num - i) / i if i > (num * 0.85) else 1 +v = 1 +return hsv2ansi(h, s, v) + +def ansi_ramp(num): +return [ramp_idx(i, num) for i in range(num)] + +ansi_ramp80 = ansi_ramp(80) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy camelot: Color change for mandelbrot on 256 color terminals
Author: Tobias Pape Branch: camelot Changeset: r69102:3be1ce5533b4 Date: 2014-02-08 22:50 +0100 http://bitbucket.org/pypy/pypy/changeset/3be1ce5533b4/ Log:Color change for mandelbrot on 256 color terminals diff --git a/rpython/tool/ansi_mandelbrot.py b/rpython/tool/ansi_mandelbrot.py --- a/rpython/tool/ansi_mandelbrot.py +++ b/rpython/tool/ansi_mandelbrot.py @@ -14,8 +14,12 @@ """ -palette = [39, 34, 35, 36, 31, 33, 32, 37] - +import os +if os.environ.get('TERM', 'dumb').find('256') > 0: +from ansiramp import ansi_ramp80 +palette = map(lambda x: "38;5;%d" % x, ansi_ramp80) +else: +palette = [39, 34, 35, 36, 31, 33, 32, 37] colour_range = None # used for debugging diff --git a/rpython/tool/ansiramp.py b/rpython/tool/ansiramp.py new file mode 100755 --- /dev/null +++ b/rpython/tool/ansiramp.py @@ -0,0 +1,20 @@ +#! /usr/bin/env python +import colorsys + +def hsv2ansi(h, s, v): +# h: 0..1, s/v: 0..1 +if s < 0.001: +return int(v * 23) + 232 +r, g, b = map(lambda x: int(x * 5), colorsys.hsv_to_rgb(h, s, v)) +return 16 + (r * 36) + (g * 6) + b + +def ramp_idx(i, num): +h = 0.57 + float(i)/num +s = float(num - i) / i if i > (num * 0.85) else 1 +v = 1 +return hsv2ansi(h, s, v) + +def ansi_ramp(num): +return [ramp_idx(i, num) for i in range(num)] + +ansi_ramp80 = ansi_ramp(80) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit