[pypy-commit] pypy default: Write some tests directly for guard_not_forced_2.
Author: Armin Rigo Branch: Changeset: r67031:0da86701160d Date: 2013-09-18 08:25 +0200 http://bitbucket.org/pypy/pypy/changeset/0da86701160d/ Log:Write some tests directly for guard_not_forced_2. diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -2441,6 +2441,32 @@ assert values == [1, 10] assert self.cpu.get_savedata_ref(deadframe) == random_gcref +def test_guard_not_forced_2(self): +cpu = self.cpu +i0 = BoxInt() +i1 = BoxInt() +tok = BoxPtr() +faildescr = BasicFailDescr(1) +ops = [ +ResOperation(rop.INT_ADD, [i0, ConstInt(10)], i1), +ResOperation(rop.FORCE_TOKEN, [], tok), +ResOperation(rop.GUARD_NOT_FORCED_2, [], None, descr=faildescr), +ResOperation(rop.FINISH, [tok], None, descr=BasicFinalDescr(0)) +] +ops[-2].setfailargs([i1]) +looptoken = JitCellToken() +self.cpu.compile_loop([i0], ops, looptoken) +deadframe = self.cpu.execute_token(looptoken, 20) +fail = self.cpu.get_latest_descr(deadframe) +assert fail.identifier == 0 +frame = self.cpu.get_ref_value(deadframe, 0) +# actually, we should get the same pointer in 'frame' and 'deadframe' +# but it is not the case on LLGraph +if not getattr(self.cpu, 'is_llgraph', False): +assert frame == deadframe +deadframe2 = self.cpu.force(frame) +assert self.cpu.get_int_value(deadframe2, 0) == 30 + def test_call_to_c_function(self): from rpython.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL from rpython.rtyper.lltypesystem.ll2ctypes import libc_name 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 @@ -651,10 +651,10 @@ _list_all_operations(result, self.operations, omit_finish) return result -def summary(self, adding_insns={}):# for debugging +def summary(self, adding_insns={}, omit_finish=True):# for debugging "NOT_RPYTHON" insns = adding_insns.copy() -for op in self._all_operations(omit_finish=True): +for op in self._all_operations(omit_finish=omit_finish): opname = op.getopname() insns[opname] = insns.get(opname, 0) + 1 return insns @@ -895,10 +895,10 @@ "found %d %r, expected %d" % (found, insn, expected_count)) return insns -def check_resops(self, expected=None, **check): +def check_resops(self, expected=None, omit_finish=True, **check): insns = {} for loop in self.get_all_loops(): -insns = loop.summary(adding_insns=insns) +insns = loop.summary(adding_insns=insns, omit_finish=omit_finish) return self._check_insns(insns, expected, check) def _check_insns(self, insns, expected, check): diff --git a/rpython/jit/metainterp/test/test_virtualizable.py b/rpython/jit/metainterp/test/test_virtualizable.py --- a/rpython/jit/metainterp/test/test_virtualizable.py +++ b/rpython/jit/metainterp/test/test_virtualizable.py @@ -153,6 +153,33 @@ assert res == 10180 self.check_resops(setfield_gc=0, getfield_gc=2) +def test_synchronize_in_return_2(self): +myjitdriver = JitDriver(greens = [], reds = ['n', 'xy'], +virtualizables = ['xy']) +class Foo(object): +pass +def g(xy, n): +myjitdriver.jit_merge_point(xy=xy, n=n) +promote_virtualizable(xy, 'inst_x') +xy.inst_x += 1 +return Foo() +def f(n): +xy = self.setup() +promote_virtualizable(xy, 'inst_x') +xy.inst_x = 1 +m = 10 +foo = None +while m > 0: +foo = g(xy, n) +m -= 1 +assert foo is not None +promote_virtualizable(xy, 'inst_x') +return xy.inst_x +res = self.meta_interp(f, [18]) +assert res == 10010 +self.check_resops(omit_finish=False, + guard_not_forced_2=1, finish=1) + def test_virtualizable_and_greens(self): myjitdriver = JitDriver(greens = ['m'], reds = ['n', 'xy'], virtualizables = ['xy']) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: Armin Rigo Branch: Changeset: r67032:635bc4fa02ea Date: 2013-09-21 10:19 +0200 http://bitbucket.org/pypy/pypy/changeset/635bc4fa02ea/ Log:merge heads diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst --- a/pypy/doc/faq.rst +++ b/pypy/doc/faq.rst @@ -356,7 +356,7 @@ attempt to point newcomers at existing alternatives, which are more mainstream and where they will get help from many people.* - *If anybody seriously wants to promote RPython anyway, he is welcome + *If anybody seriously wants to promote RPython anyway, they are welcome to: we won't actively resist such a plan. There are a lot of things that could be done to make RPython a better Java-ish language for example, starting with supporting non-GIL-based multithreading, but we @@ -396,8 +396,8 @@ patch the generated machine code. So the position of the core PyPy developers is that if anyone wants to -make an N+1'th attempt with LLVM, he is welcome, and he will receive a -bit of help on the IRC channel, but he is left with the burden of proof +make an N+1'th attempt with LLVM, they are welcome, and will be happy to +provide help in the IRC channel, but they are left with the burden of proof that it works. -- diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -96,7 +96,7 @@ raise OperationError(space.w_ValueError, space.wrap("index out of range for array")) idx_iter = idx.create_iter() -size = loop.count_all_true_iter(idx_iter, self.get_shape(), idx.get_dtype()) +size = loop.count_all_true_iter(idx_iter, idx.get_shape(), idx.get_dtype()) if size > val.get_size() and val.get_size() > 1: raise OperationError(space.w_ValueError, space.wrap("NumPy boolean array indexing assignment " "cannot assign %d input values to " diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py --- a/pypy/module/micronumpy/loop.py +++ b/pypy/module/micronumpy/loop.py @@ -374,9 +374,12 @@ def setitem_filter(arr, index, value, size): arr_iter = arr.create_iter() -index_iter = index.create_iter(arr.get_shape()) +shapelen = len(arr.get_shape()) +if shapelen > 1 and len(index.get_shape()) < 2: +index_iter = index.create_iter(arr.get_shape(), backward_broadcast=True) +else: +index_iter = index.create_iter() value_iter = value.create_iter([size]) -shapelen = len(arr.get_shape()) index_dtype = index.get_dtype() arr_dtype = arr.get_dtype() while not index_iter.done(): diff --git a/rpython/rtyper/module/ll_os.py b/rpython/rtyper/module/ll_os.py --- a/rpython/rtyper/module/ll_os.py +++ b/rpython/rtyper/module/ll_os.py @@ -1668,6 +1668,16 @@ return extdef([int], int, llimpl=nice_llimpl, export_name="ll_os.ll_os_nice") +@registering_if(os, 'ctermid') +def register_os_ctermid(self): +os_ctermid = self.llexternal('ctermid', [rffi.CCHARP], rffi.CCHARP) + +def ctermid_llimpl(): +return rffi.charp2str(os_ctermid(lltype.nullptr(rffi.CCHARP.TO))) + +return extdef([], str, llimpl=ctermid_llimpl, + export_name="ll_os.ll_os_ctermid") + # --- os.stat & variants --- @registering(os.fstat) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix when running on top of PyPy.
Author: Armin Rigo Branch: Changeset: r67033:1804ac147aa8 Date: 2013-09-21 10:28 +0200 http://bitbucket.org/pypy/pypy/changeset/1804ac147aa8/ Log:Fix when running on top of PyPy. diff --git a/rpython/rlib/parsing/makepackrat.py b/rpython/rlib/parsing/makepackrat.py --- a/rpython/rlib/parsing/makepackrat.py +++ b/rpython/rlib/parsing/makepackrat.py @@ -668,7 +668,7 @@ value = new.function(value.func_code, frame.f_globals) if not hasattr(result, key) and key not in forbidden: setattr(result, key, value) -if result.__init__ is object.__init__: +if result.__init__ == object.__init__: result.__init__ = pcls.__dict__['__init__'] result.init_parser = pcls.__dict__['__init__'] result._code = visitor.get_code() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-scheme default: Upgrade this repo to the current pypy
Author: Armin Rigo Branch: Changeset: r44:3bd6b134d3b4 Date: 2013-09-21 10:29 +0200 http://bitbucket.org/pypy/lang-scheme/changeset/3bd6b134d3b4/ Log:Upgrade this repo to the current pypy diff --git a/scheme/interactive.py b/scheme/interactive.py --- a/scheme/interactive.py +++ b/scheme/interactive.py @@ -6,7 +6,7 @@ ContinuationReturn from scheme.execution import ExecutionContext from scheme.ssparser import parse -from pypy.rlib.parsing.makepackrat import BacktrackException +from rpython.rlib.parsing.makepackrat import BacktrackException import os, sys def check_parens(s): diff --git a/scheme/object.py b/scheme/object.py --- a/scheme/object.py +++ b/scheme/object.py @@ -36,7 +36,7 @@ __slots__ = [] def to_string(self): -return '' +return '<%r>' % (self,) def to_repr(self): return "#" diff --git a/scheme/ssparser.py b/scheme/ssparser.py --- a/scheme/ssparser.py +++ b/scheme/ssparser.py @@ -1,5 +1,5 @@ -from pypy.rlib.parsing.pypackrat import PackratParser -from pypy.rlib.parsing.makepackrat import BacktrackException, Status +from rpython.rlib.parsing.pypackrat import PackratParser +from rpython.rlib.parsing.makepackrat import BacktrackException, Status from scheme.object import W_Pair, W_Integer, W_String, symbol, \ w_nil, W_Boolean, W_Real, \ w_ellipsis, W_Character, SchemeSyntaxError, W_Vector diff --git a/scheme/targetscheme.py b/scheme/targetscheme.py --- a/scheme/targetscheme.py +++ b/scheme/targetscheme.py @@ -2,10 +2,9 @@ A simple standalone target for the scheme interpreter. """ -import autopath import sys -from pypy.rlib.streamio import open_file_as_stream -from pypy.rlib.parsing.makepackrat import BacktrackException +from rpython.rlib.streamio import open_file_as_stream +from rpython.rlib.parsing.makepackrat import BacktrackException from scheme.ssparser import parse from scheme.object import SchemeQuit, ContinuationReturn from scheme.execution import ExecutionContext @@ -29,6 +28,7 @@ ctx = ExecutionContext() try: for sexpr in t: +print sexpr.to_string() # for debugging try: w_retval = sexpr.eval(ctx) print w_retval.to_string() diff --git a/scheme/test/test_parser.py b/scheme/test/test_parser.py --- a/scheme/test/test_parser.py +++ b/scheme/test/test_parser.py @@ -3,7 +3,7 @@ from scheme.object import W_Boolean, W_Real, W_Integer, W_String from scheme.object import W_Pair, W_Nil, W_Symbol, W_Character, W_Vector from scheme.object import SchemeSyntaxError -from pypy.rlib.parsing.makepackrat import BacktrackException +from rpython.rlib.parsing.makepackrat import BacktrackException def parse_sexpr(expr): return parse(expr)[0] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Skip this test that has always been failing. Please fix me.
Author: Armin Rigo Branch: Changeset: r67034:02561547a035 Date: 2013-09-21 14:24 +0200 http://bitbucket.org/pypy/pypy/changeset/02561547a035/ Log:Skip this test that has always been failing. Please fix me. diff --git a/pypy/module/pypyjit/test_pypy_c/test_thread.py b/pypy/module/pypyjit/test_pypy_c/test_thread.py --- a/pypy/module/pypyjit/test_pypy_c/test_thread.py +++ b/pypy/module/pypyjit/test_pypy_c/test_thread.py @@ -1,3 +1,4 @@ +import py from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC @@ -50,6 +51,7 @@ """) def test_lock_acquire_release(self): +py.test.skip("test too precise, please fix me") def main(n): import threading lock = threading.Lock() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: XXX fix me or mark definitely skipped
Author: Armin Rigo Branch: Changeset: r67035:135e4b54c03e Date: 2013-09-21 14:27 +0200 http://bitbucket.org/pypy/pypy/changeset/135e4b54c03e/ Log:XXX fix me or mark definitely skipped diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py b/pypy/module/_pypyjson/test/test__pypyjson.py --- a/pypy/module/_pypyjson/test/test__pypyjson.py +++ b/pypy/module/_pypyjson/test/test__pypyjson.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -import py +import py, sys from pypy.module._pypyjson.interp_decoder import JSONDecoder def test_skip_whitespace(): @@ -16,6 +16,9 @@ class AppTest(object): spaceconfig = {"objspace.usemodules._pypyjson": True} +def setup_class(cls): +cls.w_run_on_16bit = cls.space.wrap(sys.maxunicode == 65535) + def test_raise_on_unicode(self): import _pypyjson raises(TypeError, _pypyjson.loads, u"42") @@ -178,11 +181,11 @@ raises(ValueError, "_pypyjson.loads('[1: 2]')") raises(ValueError, "_pypyjson.loads('[1, 2')") raises(ValueError, """_pypyjson.loads('["extra comma",]')""") - + def test_unicode_surrogate_pair(self): +if self.run_on_16bit: +skip("XXX fix me or mark definitely skipped") import _pypyjson expected = u'z\U0001d120x' res = _pypyjson.loads('"z\\ud834\\udd20x"') assert res == expected - - ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the test, failing if sys.unicode==65535.
Author: Armin Rigo Branch: Changeset: r67036:2e490cdd9f25 Date: 2013-09-21 14:29 +0200 http://bitbucket.org/pypy/pypy/changeset/2e490cdd9f25/ Log:Fix the test, failing if sys.unicode==65535. diff --git a/rpython/rlib/test/test_runicode.py b/rpython/rlib/test/test_runicode.py --- a/rpython/rlib/test/test_runicode.py +++ b/rpython/rlib/test/test_runicode.py @@ -246,7 +246,8 @@ assert decode('+3AE-', 5, None) == (u'\uDC01', 5) assert decode('+3AE-x', 6, None) == (u'\uDC01x', 6) -assert encode(u'\uD801\U000abcde', 2, None) == '+2AHab9ze-' +u = u'\uD801\U000abcde' +assert encode(u, len(u), None) == '+2AHab9ze-' assert decode('+2AHab9ze-', 10, None) == (u'\uD801\U000abcde', 10) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix to (hopefully) support more cases of 16/32-bit-sized unicode chars
Author: Armin Rigo Branch: Changeset: r67037:162d46b91e96 Date: 2013-09-21 14:39 +0200 http://bitbucket.org/pypy/pypy/changeset/162d46b91e96/ Log:Fix to (hopefully) support more cases of 16/32-bit-sized unicode chars diff --git a/rpython/rlib/unicodedata/test/test_ucd.py b/rpython/rlib/unicodedata/test/test_ucd.py --- a/rpython/rlib/unicodedata/test/test_ucd.py +++ b/rpython/rlib/unicodedata/test/test_ucd.py @@ -1,6 +1,7 @@ -from rpython.rlib.runicode import code_to_unichr +from rpython.rlib.runicode import code_to_unichr, MAXUNICODE from rpython.rlib.unicodedata import unicodedb_5_2_0 from rpython.rtyper.test.tool import BaseRtypingTest +from rpython.translator.c.test.test_genc import compile class TestTranslated(BaseRtypingTest): @@ -15,8 +16,13 @@ print hex(res) assert res == f(1) -def test_code_to_unichr(self): -def f(c): -return code_to_unichr(c) + u'' -res = self.ll_to_unicode(self.interpret(f, [0x10346])) -assert res == u'\U00010346' + +def test_code_to_unichr(): +def f(c): +return ord(code_to_unichr(c)[0]) +f1 = compile(f, [int]) +got = f1(0x12346) +if MAXUNICODE == 65535: +assert got == 0xd808# first char of a pair +else: +assert got == 0x12346 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: add branch for __array_preprare__, __array_wrap__
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67038:b0315f391eb5 Date: 2013-09-22 00:10 +0300 http://bitbucket.org/pypy/pypy/changeset/b0315f391eb5/ Log:add branch for __array_preprare__, __array_wrap__ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: add test for ufunc1 and reduce, but numpy does not actually call __array_prepare__. numpy bug?
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67039:8e72bf2e4160 Date: 2013-09-20 13:39 +0300 http://bitbucket.org/pypy/pypy/changeset/8e72bf2e4160/ Log:add test for ufunc1 and reduce, but numpy does not actually call __array_prepare__. numpy bug? diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -260,7 +260,7 @@ assert type(x) == ndarray assert a.called_wrap -def test___array_prepare__(self): +def test___array_prepare__1(self): from numpypy import ndarray, array, add, ones class with_prepare(ndarray): called_prepare = False @@ -288,3 +288,21 @@ assert x.called_prepare raises(TypeError, add, a, b, out=c) +def test___array_prepare__2(self): +from numpypy import ndarray, array, sum, ones, add +class with_prepare(ndarray): +def __array_prepare__(self, arr, context): +x = array(arr).view(type=with_prepare) +x.called_prepare = True +xxx +print 'called_prepare',arr +return x +a = ones(2).view(type=with_prepare) +b = ones((3, 2)) +x = sum(a, axis=0) +assert type(x) == with_prepare +# reduce functions do not call prepare? +assert not getattr(x, 'called_prepare',False) +x = add.reduce(a) +assert type(x) == with_prepare +assert not getattr(x, 'called_prepare',False) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: allow Box results to percolate through, start to fix compile.py
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67040:e69c4253c9d7 Date: 2013-09-20 16:28 +0300 http://bitbucket.org/pypy/pypy/changeset/e69c4253c9d7/ Log:allow Box results to percolate through, start to fix compile.py diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -222,6 +222,10 @@ return None #return getattr(w_obj, 'descr_' + s)(self, *args) +def get_and_call_function(self, w_descr, w_obj, *args_w): +w_impl = self.getattr(w_descr, w_obj) +return self.call_method(w_obj, w_impl, args_w) + @specialize.arg(1) def interp_w(self, tp, what): assert isinstance(what, tp) diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -439,7 +439,7 @@ def descr___array_prepare__(self, space, w_array, w_context): # stub implementation of __array_prepare__() -if isinstance(w_array, W_NDimArray): +if isinstance(w_array, (W_NDimArray, interp_boxes.Box)): return w_array else: raise OperationError(space.w_TypeError, diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -234,6 +234,37 @@ return out return res +def call_prepare(self, space, w_out, w_obj, w_result): +if isinstance(w_out, W_NDimArray): +w_array = space.lookup(w_out, "__array_prepare__") +w_caller = w_out +else: +w_array = space.lookup(w_obj, "__array_prepare__") +w_caller = w_obj +if w_array: +w_retVal = space.get_and_call_function(w_array, w_caller, w_result, None) +if not isinstance(w_retVal, (W_NDimArray, interp_boxes.Box)): +raise OperationError(space.w_ValueError, +space.wrap( "__array_prepare__ must return an " +"ndarray or subclass thereof")) +if isinstance(w_result, interp_boxes.Box) or \ +w_result.is_scalar(): +if not isinstance(w_retVal, interp_boxes.Box) and not w_retVal.is_scalar(): +raise OperationError(space.w_TypeError, +space.wrap( "__array_prepare__ must return an " +"ndarray or subclass thereof which is " +"otherwise identical to its input")) +elif w_result.get_shape() != w_retVal.get_shape() or \ + w_result.implementation.get_strides() != \ +w_retVal.implementation.get_strides(): +raise OperationError(space.w_TypeError, +space.wrap( "__array_prepare__ must return an " +"ndarray or subclass thereof which is " +"otherwise identical to its input")) +return w_retVal +return w_result + + class W_Ufunc1(W_Ufunc): argcount = 1 @@ -319,22 +350,6 @@ else: self.done_func = None -def call_prepare(self, space, w_out, w_obj, w_result): -if isinstance(w_out, W_NDimArray): -w_array = space.lookup(w_out, "__array_prepare__") -w_caller = w_out -else: -w_array = space.lookup(w_obj, "__array_prepare__") -w_caller = w_obj -if w_array: -w_result = space.get_and_call_function(w_array, w_caller, w_result, None) -if not isinstance(w_result, W_NDimArray): -raise OperationError(space.w_ValueError, -space.wrap("object __array_prepare__ method not" - " producing an array")) -return w_result - - @jit.unroll_safe def call(self, space, args_w): if len(args_w) > 2: @@ -387,6 +402,7 @@ out.set_scalar_value(arr) else: out.fill(arr) +arr = out return self.call_prepare(space, out, w_lhs, arr) new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs) new_shape = shape_agreement(space, new_shape, out, broadcast_down=False) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: Backed out changeset: b95fcd12507d - belongs on branch
Author: Matti Picus Branch: pypy-pyarray Changeset: r67046:c51e676b8312 Date: 2013-09-22 00:17 +0300 http://bitbucket.org/pypy/pypy/changeset/c51e676b8312/ Log:Backed out changeset: b95fcd12507d - belongs on branch diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py --- a/pypy/module/micronumpy/base.py +++ b/pypy/module/micronumpy/base.py @@ -86,7 +86,7 @@ return W_NDimArray(scalar.Scalar(dtype, w_val)) -def convert_to_array(space, w_obj, use_prepare=False): +def convert_to_array(space, w_obj): #XXX: This whole routine should very likely simply be array() from pypy.module.micronumpy.interp_numarray import array from pypy.module.micronumpy import interp_ufuncs @@ -101,7 +101,7 @@ if isinstance(w_result, W_NDimArray): return w_result else: -raise OperationError(space.w_ValueError, +raise OperationError(space.w_ValueError, space.wrap("object __array__ method not producing an array")) elif issequence_w(space, w_obj): # Convert to array. diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -437,7 +437,7 @@ # stub implementation of __array__() return self -def descr___array_prepare__(self, space, w_array, w_context): +def descr___array_prepare__(self, space, w_array): # stub implementation of __array_prepare__() if isinstance(w_array, W_NDimArray): return w_array diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -319,22 +319,6 @@ else: self.done_func = None -def call_prepare(self, space, w_out, w_obj, w_result): -if isinstance(w_out, W_NDimArray): -w_array = space.lookup(w_out, "__array_prepare__") -w_caller = w_out -else: -w_array = space.lookup(w_obj, "__array_prepare__") -w_caller = w_obj -if w_array: -w_result = space.get_and_call_function(w_array, w_caller, w_result, None) -if not isinstance(w_result, W_NDimArray): -raise OperationError(space.w_ValueError, -space.wrap("object __array_prepare__ method not" - " producing an array")) -return w_result - - @jit.unroll_safe def call(self, space, args_w): if len(args_w) > 2: @@ -367,11 +351,11 @@ "ufunc '%s' not supported for the input types" % self.name)) if space.is_none(w_out): out = None -#elif not isinstance(w_out, W_NDimArray): -#raise OperationError(space.w_TypeError, space.wrap( -#'output must be an array')) +elif not isinstance(w_out, W_NDimArray): +raise OperationError(space.w_TypeError, space.wrap( +'output must be an array')) else: -out = convert_to_array(space, w_out) +out = w_out calc_dtype = out.get_dtype() if self.comparison_func: res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype @@ -387,13 +371,14 @@ out.set_scalar_value(arr) else: out.fill(arr) -return self.call_prepare(space, out, w_lhs, arr) +else: +out = arr +return out new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs) new_shape = shape_agreement(space, new_shape, out, broadcast_down=False) -w_result = loop.call2(space, new_shape, self.func, calc_dtype, +return loop.call2(space, new_shape, self.func, calc_dtype, res_dtype, w_lhs, w_rhs, out) -# XXX handle array_priority -return self.call_prepare(space, out, w_lhs, w_result) + W_Ufunc.typedef = TypeDef("ufunc", __module__ = "numpypy", diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -267,24 +267,8 @@ def __array_prepare__(self, arr, context): self.called_prepare = True return array(arr).view(type=with_prepare) -class with_prepare_fail(ndarray): -called_prepare = False -def __array_prepare__(self, arr, context): -self.called_prepare = True -return array(arr[0]).view(type=with_prepare) -a = array(1) -b = array(1).view(type=with_prepare) -x = add(a, a, out=b) +a = array(1).view(type=with_prepare) +x = add(
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: fix translation
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67045:995703e4a6b6 Date: 2013-09-22 00:08 +0300 http://bitbucket.org/pypy/pypy/changeset/995703e4a6b6/ Log:fix translation diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -439,7 +439,8 @@ def descr___array_prepare__(self, space, w_array, w_context): # stub implementation of __array_prepare__() -if isinstance(w_array, (W_NDimArray, interp_boxes.Box)): +if isinstance(w_array, W_NDimArray) or \ + isinstance(w_array, interp_boxes.Box): return w_array else: raise OperationError(space.w_TypeError, diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -232,7 +232,7 @@ if out: out.set_scalar_value(res) return out -if not type(obj) == W_NDimArray: +if type(obj) is not W_NDimArray: #If obj is a subtype of W_NDimArray, return a empty-shape instance out = W_NDimArray.from_shape(space, [], dtype, w_instance=obj) out.set_scalar_value(res) @@ -240,6 +240,7 @@ return res def call_prepare(self, space, w_out, w_obj, w_result): +assert isinstance(w_result, W_NDimArray) if isinstance(w_out, W_NDimArray): w_array = space.lookup(w_out, "__array_prepare__") w_caller = w_out @@ -248,7 +249,8 @@ w_caller = w_obj if w_array: w_retVal = space.get_and_call_function(w_array, w_caller, w_result, None) -if not isinstance(w_retVal, (W_NDimArray, interp_boxes.Box)): +if not isinstance(w_retVal, W_NDimArray) and \ + not isinstance(w_retVal, interp_boxes.Box): raise OperationError(space.w_ValueError, space.wrap( "__array_prepare__ must return an " "ndarray or subclass thereof")) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: typo, fix if clause, actually set return value
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67043:d3b4a2771960 Date: 2013-09-21 23:11 +0300 http://bitbucket.org/pypy/pypy/changeset/d3b4a2771960/ Log:typo, fix if clause, actually set return value diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -852,7 +852,7 @@ # --- reduce --- def _reduce_ufunc_impl(ufunc_name, promote_to_largest=False, - cumultative=False): + cumulative=False): def impl(self, space, w_axis=None, w_out=None, w_dtype=None): if space.is_none(w_out): out = None @@ -863,9 +863,9 @@ out = w_out return getattr(interp_ufuncs.get(space), ufunc_name).reduce( space, self, True, promote_to_largest, w_axis, -False, out, w_dtype, cumultative=cumultative) +False, out, w_dtype, cumulative=cumulative) return func_with_new_name(impl, "reduce_%s_impl_%d_%d" % (ufunc_name, -promote_to_largest, cumultative)) +promote_to_largest, cumulative)) descr_sum = _reduce_ufunc_impl("add") descr_sum_promote = _reduce_ufunc_impl("add", True) @@ -875,8 +875,8 @@ descr_all = _reduce_ufunc_impl('logical_and') descr_any = _reduce_ufunc_impl('logical_or') -descr_cumsum = _reduce_ufunc_impl('add', cumultative=True) -descr_cumprod = _reduce_ufunc_impl('multiply', cumultative=True) +descr_cumsum = _reduce_ufunc_impl('add', cumulative=True) +descr_cumprod = _reduce_ufunc_impl('multiply', cumulative=True) def descr_mean(self, space, w_axis=None, w_out=None): if space.is_none(w_axis): diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -144,7 +144,7 @@ w_dtype) def reduce(self, space, w_obj, multidim, promote_to_largest, w_axis, - keepdims=False, out=None, dtype=None, cumultative=False): + keepdims=False, out=None, dtype=None, cumulative=False): if self.argcount != 2: raise OperationError(space.w_ValueError, space.wrap("reduce only " "supported for binary functions")) @@ -176,7 +176,7 @@ "%s.reduce without identity", self.name) if shapelen > 1 and axis < shapelen: temp = None -if cumultative: +if cumulative: shape = obj_shape[:] temp_shape = obj_shape[:axis] + obj_shape[axis + 1:] if out: @@ -210,8 +210,8 @@ else: out = W_NDimArray.from_shape(space, shape, dtype, w_instance=obj) return loop.do_axis_reduce(shape, self.func, obj, dtype, axis, out, - self.identity, cumultative, temp) -if cumultative: + self.identity, cumulative, temp) +if cumulative: if out: if out.get_shape() != [obj.get_size()]: raise OperationError(space.w_ValueError, space.wrap( @@ -232,9 +232,11 @@ if out: out.set_scalar_value(res) return out -if space.type(obj) != W_NDimArray: +if not type(obj) == W_NDimArray: #If obj is a subtype of W_NDimArray, return a empty-shape instance -return W_NDimArray.from_shape(space, [], dtype, w_instance=obj) +out = W_NDimArray.from_shape(space, [], dtype, w_instance=obj) +out.set_scalar_value(res) +return out return res def call_prepare(self, space, w_out, w_obj, w_result): diff --git a/pypy/module/micronumpy/iter.py b/pypy/module/micronumpy/iter.py --- a/pypy/module/micronumpy/iter.py +++ b/pypy/module/micronumpy/iter.py @@ -275,11 +275,11 @@ return self.indexes[d] class AxisIterator(base.BaseArrayIterator): -def __init__(self, array, shape, dim, cumultative): +def __init__(self, array, shape, dim, cumulative): self.shape = shape strides = array.get_strides() backstrides = array.get_backstrides() -if cumultative: +if cumulative: self.strides = strides self.backstrides = backstrides elif len(shape) == len(strides): diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py --- a/pypy/module/micronumpy/loop.py +++ b/pypy/module/micronumpy/loop.py @@ -218,10 +218,10 @@ 'func', 'dtype'], reds='auto') -def do_axis_reduce(shape, func, arr, dtype, axis, out, identi
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: implement for W_Ufunc1
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67044:47a1da6a0385 Date: 2013-09-21 23:51 +0300 http://bitbucket.org/pypy/pypy/changeset/47a1da6a0385/ Log:implement for W_Ufunc1 diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -325,15 +325,17 @@ w_obj.get_scalar_value().convert_to(calc_dtype)) if out is None: return w_val -if out.is_scalar(): -out.set_scalar_value(w_val) -else: -out.fill(res_dtype.coerce(space, w_val)) -return out +if isinstance(out, W_NDimArray): +if out.is_scalar(): +out.set_scalar_value(w_val) +else: +out.fill(res_dtype.coerce(space, w_val)) +return self.call_prepare(space, out, w_obj, w_val) shape = shape_agreement(space, w_obj.get_shape(), out, broadcast_down=False) -return loop.call1(space, shape, self.func, calc_dtype, res_dtype, +w_result = loop.call1(space, shape, self.func, calc_dtype, res_dtype, w_obj, out) +return self.call_prepare(space, out, w_obj, w_result) class W_Ufunc2(W_Ufunc): @@ -408,6 +410,7 @@ else: out.fill(arr) arr = out +# XXX handle array_priority return self.call_prepare(space, out, w_lhs, arr) new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs) new_shape = shape_agreement(space, new_shape, out, broadcast_down=False) diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -299,8 +299,11 @@ return array(arr[0]).view(type=with_prepare) a = array(1) b = array(1).view(type=with_prepare) +print 'x' x = log(a, out=b) +print 'aaa' assert x == 0 +print 'x' assert type(x) == with_prepare assert x.called_prepare x.called_prepare = False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: finish review items for pypy-pyarray branch
Author: Matti Picus Branch: pypy-pyarray Changeset: r67048:74096886f5f4 Date: 2013-09-22 00:22 +0300 http://bitbucket.org/pypy/pypy/changeset/74096886f5f4/ Log:finish review items for pypy-pyarray branch diff --git a/TODO.txt b/TODO.txt deleted file mode 100644 --- a/TODO.txt +++ /dev/null @@ -1,5 +0,0 @@ -TODO list by mattip -=== - -- test, implement use of __array_prepare__() -- test, implement use of __array_wrap__() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: add 1 arg ufunc tests
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67041:4c78008e85f4 Date: 2013-09-20 17:00 +0300 http://bitbucket.org/pypy/pypy/changeset/4c78008e85f4/ Log:add 1 arg ufunc tests diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -260,17 +260,16 @@ assert type(x) == ndarray assert a.called_wrap -def test___array_prepare__1(self): +def test___array_prepare__2arg(self): from numpypy import ndarray, array, add, ones class with_prepare(ndarray): -called_prepare = False def __array_prepare__(self, arr, context): -self.called_prepare = True -return array(arr).view(type=with_prepare) +retVal = array(arr).view(type=with_prepare) +retVal.called_prepare = True +return retVal class with_prepare_fail(ndarray): called_prepare = False def __array_prepare__(self, arr, context): -self.called_prepare = True return array(arr[0]).view(type=with_prepare) a = array(1) b = array(1).view(type=with_prepare) @@ -288,17 +287,42 @@ assert x.called_prepare raises(TypeError, add, a, b, out=c) -def test___array_prepare__2(self): +def test___array_prepare__1arg(self): +from numpypy import ndarray, array, log, ones +class with_prepare(ndarray): +def __array_prepare__(self, arr, context): +retVal = array(arr).view(type=with_prepare) +retVal.called_prepare = True +return retVal +class with_prepare_fail(ndarray): +def __array_prepare__(self, arr, context): +return array(arr[0]).view(type=with_prepare) +a = array(1) +b = array(1).view(type=with_prepare) +x = log(a, out=b) +assert x == 0 +assert type(x) == with_prepare +assert x.called_prepare +x.called_prepare = False +a = ones((3, 2)).view(type=with_prepare) +b = ones((3, 2)) +c = ones((3, 2)).view(type=with_prepare_fail) +x = log(a) +assert (x == 0).all() +assert type(x) == with_prepare +assert x.called_prepare +raises(TypeError, log, a, out=c) + + +def test___array_prepare__nocall(self): from numpypy import ndarray, array, sum, ones, add class with_prepare(ndarray): def __array_prepare__(self, arr, context): x = array(arr).view(type=with_prepare) x.called_prepare = True -xxx print 'called_prepare',arr return x a = ones(2).view(type=with_prepare) -b = ones((3, 2)) x = sum(a, axis=0) assert type(x) == with_prepare # reduce functions do not call prepare? ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: move 61c630f73ba3 to branch and remove untested __array_prepare__, __array_wrap__
Author: Matti Picus Branch: pypy-pyarray Changeset: r67047:746c18a936f7 Date: 2013-09-22 00:21 +0300 http://bitbucket.org/pypy/pypy/changeset/746c18a936f7/ Log:move 61c630f73ba3 to branch and remove untested __array_prepare__, __array_wrap__ diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -437,22 +437,6 @@ # stub implementation of __array__() return self -def descr___array_prepare__(self, space, w_array): -# stub implementation of __array_prepare__() -if isinstance(w_array, W_NDimArray): -return w_array -else: -raise OperationError(space.w_TypeError, - space.wrap("can only be called with ndarray object")) - -def descr___array_wrap__(self, space, w_array): -# stub implementation of __array_wrap__() -if isinstance(w_array, W_NDimArray): -return w_array -else: -raise OperationError(space.w_TypeError, - space.wrap("can only be called with ndarray object")) - def descr_array_iface(self, space): addr = self.implementation.get_storage_as_int(space) # will explode if it can't @@ -1157,8 +1141,6 @@ __array_finalize__ = interp2app(W_NDimArray.descr___array_finalize__), __array__ = interp2app(W_NDimArray.descr___array__), -__array_prepare__ = interp2app(W_NDimArray.descr___array_prepare__), -__array_wrap__= interp2app(W_NDimArray.descr___array_wrap__), ) @unwrap_spec(ndmin=int, copy=bool, subok=bool) diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -245,30 +245,3 @@ c = array(a, float) assert c.dtype is dtype(float) -def test___array_wrap__(self): -from numpypy import ndarray, add, ones -class with_wrap(object): -called_wrap = False -def __array__(self): -return ones(1) -def __array_wrap__(self, arr, context): -self.called_wrap = True -return arr -a = with_wrap() -x = add(a, a) -assert x == 2 -assert type(x) == ndarray -assert a.called_wrap - -def test___array_prepare__(self): -from numpypy import ndarray, array, add, ones -class with_prepare(ndarray): -called_prepare = False -def __array_prepare__(self, arr, context): -self.called_prepare = True -return array(arr).view(type=with_prepare) -a = array(1).view(type=with_prepare) -x = add(a, a) -assert x == 2 -assert type(x) == with_prepare -assert a.called_prepare ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: merge default into branch
Author: Matti Picus Branch: pypy-pyarray Changeset: r67049:e8756ac043ff Date: 2013-09-22 00:37 +0300 http://bitbucket.org/pypy/pypy/changeset/e8756ac043ff/ Log:merge default into branch diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py b/pypy/module/_pypyjson/test/test__pypyjson.py --- a/pypy/module/_pypyjson/test/test__pypyjson.py +++ b/pypy/module/_pypyjson/test/test__pypyjson.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -import py +import py, sys from pypy.module._pypyjson.interp_decoder import JSONDecoder def test_skip_whitespace(): @@ -16,6 +16,9 @@ class AppTest(object): spaceconfig = {"objspace.usemodules._pypyjson": True} +def setup_class(cls): +cls.w_run_on_16bit = cls.space.wrap(sys.maxunicode == 65535) + def test_raise_on_unicode(self): import _pypyjson raises(TypeError, _pypyjson.loads, u"42") @@ -178,11 +181,11 @@ raises(ValueError, "_pypyjson.loads('[1: 2]')") raises(ValueError, "_pypyjson.loads('[1, 2')") raises(ValueError, """_pypyjson.loads('["extra comma",]')""") - + def test_unicode_surrogate_pair(self): +if self.run_on_16bit: +skip("XXX fix me or mark definitely skipped") import _pypyjson expected = u'z\U0001d120x' res = _pypyjson.loads('"z\\ud834\\udd20x"') assert res == expected - - diff --git a/pypy/module/pypyjit/test_pypy_c/test_thread.py b/pypy/module/pypyjit/test_pypy_c/test_thread.py --- a/pypy/module/pypyjit/test_pypy_c/test_thread.py +++ b/pypy/module/pypyjit/test_pypy_c/test_thread.py @@ -1,3 +1,4 @@ +import py from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC @@ -50,6 +51,7 @@ """) def test_lock_acquire_release(self): +py.test.skip("test too precise, please fix me") def main(n): import threading lock = threading.Lock() diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -2441,6 +2441,32 @@ assert values == [1, 10] assert self.cpu.get_savedata_ref(deadframe) == random_gcref +def test_guard_not_forced_2(self): +cpu = self.cpu +i0 = BoxInt() +i1 = BoxInt() +tok = BoxPtr() +faildescr = BasicFailDescr(1) +ops = [ +ResOperation(rop.INT_ADD, [i0, ConstInt(10)], i1), +ResOperation(rop.FORCE_TOKEN, [], tok), +ResOperation(rop.GUARD_NOT_FORCED_2, [], None, descr=faildescr), +ResOperation(rop.FINISH, [tok], None, descr=BasicFinalDescr(0)) +] +ops[-2].setfailargs([i1]) +looptoken = JitCellToken() +self.cpu.compile_loop([i0], ops, looptoken) +deadframe = self.cpu.execute_token(looptoken, 20) +fail = self.cpu.get_latest_descr(deadframe) +assert fail.identifier == 0 +frame = self.cpu.get_ref_value(deadframe, 0) +# actually, we should get the same pointer in 'frame' and 'deadframe' +# but it is not the case on LLGraph +if not getattr(self.cpu, 'is_llgraph', False): +assert frame == deadframe +deadframe2 = self.cpu.force(frame) +assert self.cpu.get_int_value(deadframe2, 0) == 30 + def test_call_to_c_function(self): from rpython.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL from rpython.rtyper.lltypesystem.ll2ctypes import libc_name 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 @@ -651,10 +651,10 @@ _list_all_operations(result, self.operations, omit_finish) return result -def summary(self, adding_insns={}):# for debugging +def summary(self, adding_insns={}, omit_finish=True):# for debugging "NOT_RPYTHON" insns = adding_insns.copy() -for op in self._all_operations(omit_finish=True): +for op in self._all_operations(omit_finish=omit_finish): opname = op.getopname() insns[opname] = insns.get(opname, 0) + 1 return insns @@ -895,10 +895,10 @@ "found %d %r, expected %d" % (found, insn, expected_count)) return insns -def check_resops(self, expected=None, **check): +def check_resops(self, expected=None, omit_finish=True, **check): insns = {} for loop in self.get_all_loops(): -insns = loop.summary(adding_insns=insns) +insns = loop.summary(adding_insns=insns, omit_finish=omit_finish) return self._check_insns(insns, expected, check) def _check_insns(self, insns, expected, check): diff --git a/rpython/jit/metainterp/test/test_virtualizable.py b/rpython/jit/metainterp/test/test_virtualizable.py --- a/rpython/jit/metainterp/test/test_virtualizable.py +++ b/rpython/jit
[pypy-commit] pypy numpypy-array_prepare_-array_wrap: update test, fix implementation of reduce
Author: Matti Picus Branch: numpypy-array_prepare_-array_wrap Changeset: r67042:5c0ec116cb8b Date: 2013-09-21 22:37 +0300 http://bitbucket.org/pypy/pypy/changeset/5c0ec116cb8b/ Log:update test, fix implementation of reduce diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -232,6 +232,9 @@ if out: out.set_scalar_value(res) return out +if space.type(obj) != W_NDimArray: +#If obj is a subtype of W_NDimArray, return a empty-shape instance +return W_NDimArray.from_shape(space, [], dtype, w_instance=obj) return res def call_prepare(self, space, w_out, w_obj, w_result): diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -314,7 +314,7 @@ raises(TypeError, log, a, out=c) -def test___array_prepare__nocall(self): +def test___array_prepare__reduce(self): from numpypy import ndarray, array, sum, ones, add class with_prepare(ndarray): def __array_prepare__(self, arr, context): @@ -323,10 +323,15 @@ print 'called_prepare',arr return x a = ones(2).view(type=with_prepare) -x = sum(a, axis=0) +x = sum(a) assert type(x) == with_prepare -# reduce functions do not call prepare? +assert x.shape == () +# reduce functions do not call prepare, is this a numpy 'feature'? assert not getattr(x, 'called_prepare',False) x = add.reduce(a) assert type(x) == with_prepare assert not getattr(x, 'called_prepare',False) +a = ones((2,3)).view(type=with_prepare) +x = sum(a, axis=0) +assert type(x) == with_prepare +assert not getattr(x, 'called_prepare',False) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: fix test, change implementation for pendatic exception string, improve test
Author: Matti Picus Branch: pypy-pyarray Changeset: r67051:c1a7865243c0 Date: 2013-09-22 09:32 +0300 http://bitbucket.org/pypy/pypy/changeset/c1a7865243c0/ Log:fix test, change implementation for pendatic exception string, improve test diff --git a/pypy/module/cpyext/ndarrayobject.py b/pypy/module/cpyext/ndarrayobject.py --- a/pypy/module/cpyext/ndarrayobject.py +++ b/pypy/module/cpyext/ndarrayobject.py @@ -171,8 +171,16 @@ @cpython_api([PyObject, Py_ssize_t, Py_ssize_t, Py_ssize_t], PyObject) def _PyArray_FromObject(space, w_obj, typenum, min_depth, max_depth): -return _PyArray_FromAny(space, w_obj, typenum, min_depth, max_depth, NPY_BEHAVED); - +try: +return _PyArray_FromAny(space, w_obj, typenum, min_depth, max_depth, +0, None); +except OperationError, e: +if e.match(space, space.w_NotImplementedError): +errstr = space.str_w(e.get_w_value(space)) +errstr = errstr.replace('FromAny','FromObject') +raise OperationError(space.w_NotImplementedError, space.wrap( +errstr)) +raise def get_shape_and_dtype(space, nd, dims, typenum): shape = [] diff --git a/pypy/module/cpyext/test/test_api.py b/pypy/module/cpyext/test/test_api.py --- a/pypy/module/cpyext/test/test_api.py +++ b/pypy/module/cpyext/test/test_api.py @@ -46,7 +46,7 @@ raise Exception("DID NOT RAISE") if getattr(space, 'w_' + expected_exc.__name__) is not operror.w_type: raise Exception("Wrong exception") -state.clear_exception() +return state.clear_exception() def setup_method(self, func): freeze_refcnts(self) diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py b/pypy/module/cpyext/test/test_ndarrayobject.py --- a/pypy/module/cpyext/test/test_ndarrayobject.py +++ b/pypy/module/cpyext/test/test_ndarrayobject.py @@ -96,10 +96,11 @@ def test_FromObject(self, space, api): a = array(space, [10, 5, 3]) -assert api._PyArray_FromObject(a, NULL, 0, 0, 0, NULL) is a -self.raises(space, api, NotImplementedError, api._PyArray_FromObject, -space.wrap(a), space.w_None, space.wrap(0), -space.wrap(3), space.wrap(0), space.w_None) +assert api._PyArray_FromObject(a, None, 0, 0) is a +exc = self.raises(space, api, NotImplementedError, api._PyArray_FromObject, +space.wrap(a), space.wrap(11), space.wrap(0), +space.wrap(3) ) +assert exc.errorstr(space).find('FromObject') >= 0 def test_list_from_fixedptr(self, space, api): A = lltype.GcArray(lltype.Float) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: fix tests
Author: Matti Picus Branch: pypy-pyarray Changeset: r67050:21c62d1734c4 Date: 2013-09-22 08:36 +0300 http://bitbucket.org/pypy/pypy/changeset/21c62d1734c4/ Log:fix tests diff --git a/pypy/module/test_lib_pypy/numpypy/test_numpy.py b/pypy/module/test_lib_pypy/numpypy/test_numpy.py --- a/pypy/module/test_lib_pypy/numpypy/test_numpy.py +++ b/pypy/module/test_lib_pypy/numpypy/test_numpy.py @@ -96,10 +96,13 @@ def test___all__(self): import numpy -assert '__all__' in numpy +assert '__all__' in dir(numpy) assert 'numpypy' not in dir(numpy) def test_get_include(self): +import sys +if not hasattr(sys, 'pypy_translation_info'): +skip("pypy white-box test") import numpy, os assert 'get_include' in dir(numpy) path = numpy.get_include() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy-pyarray: whoops
Author: Matti Picus Branch: pypy-pyarray Changeset: r67052:e89d93815460 Date: 2013-09-22 09:37 +0300 http://bitbucket.org/pypy/pypy/changeset/e89d93815460/ Log:whoops diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py b/pypy/module/cpyext/test/test_ndarrayobject.py --- a/pypy/module/cpyext/test/test_ndarrayobject.py +++ b/pypy/module/cpyext/test/test_ndarrayobject.py @@ -242,6 +242,7 @@ PyObject * obj2 = PyArray_ZEROS(2, dims2, 11, 0); PyArray_FILLWBYTE(obj2, 42); PyArray_CopyInto(obj2, obj1); +Py_DECREF(obj1); return obj2; ''' ), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit