[pypy-commit] pypy object-dtype2: add failing test (passes with -A)
mattip
noreply at buildbot.pypy.org
Fri Apr 17 16:41:52 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: object-dtype2
Changeset: r76819:b72789c9b72e
Date: 2015-04-17 17:41 +0300
http://bitbucket.org/pypy/pypy/changeset/b72789c9b72e/
Log: add failing test (passes with -A)
diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -6,7 +6,7 @@
from pypy.interpreter.typedef import (TypeDef, GetSetProperty,
interp_attrproperty, interp_attrproperty_w)
from rpython.rlib import jit
-from rpython.rlib.objectmodel import specialize, compute_hash
+from rpython.rlib.objectmodel import specialize, compute_hash, we_are_translated
from rpython.rlib.rarithmetic import r_longlong, r_ulonglong
from pypy.module.micronumpy import types, boxes, base, support, constants as NPY
from pypy.module.micronumpy.appbridge import get_appbridge_cache
@@ -496,8 +496,17 @@
def dtype_from_spec(space, w_spec):
- w_lst = get_appbridge_cache(space).call_method(space,
- 'numpy.core._internal', '_commastring', Arguments(space, [w_spec]))
+
+ if we_are_translated():
+ w_lst = get_appbridge_cache(space).call_method(space,
+ 'numpy.core._internal', '_commastring', Arguments(space, [w_spec]))
+ else:
+ # testing, handle manually
+ if space.eq_w(w_spec, space.wrap('u4,u4,u4')):
+ w_lst = space.newlist([space.wrap('u4')]*3)
+ else:
+ raise oefmt(space.w_RuntimeError,
+ "cannot parse w_spec")
if not space.isinstance_w(w_lst, space.w_list) or space.len_w(w_lst) < 1:
raise oefmt(space.w_RuntimeError,
"_commastring is not returning a list with len >= 1")
diff --git a/pypy/module/micronumpy/test/test_object_arrays.py b/pypy/module/micronumpy/test/test_object_arrays.py
--- a/pypy/module/micronumpy/test/test_object_arrays.py
+++ b/pypy/module/micronumpy/test/test_object_arrays.py
@@ -92,3 +92,17 @@
del fiveOs
gc.collect()
assert a[2].whatami() == 'an object'
+
+ def test_array_interface(self):
+ import numpy as np
+ class DummyArray(object):
+ def __init__(self, interface, base=None):
+ self.__array_interface__ = interface
+ self.base = base
+ a = np.array([(1, 2, 3)], dtype='u4,u4,u4')
+ b = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)], dtype='u4,u4,u4')
+ interface = dict(a.__array_interface__)
+ interface['shape'] = tuple([3])
+ interface['strides'] = tuple([0])
+ c = np.array(DummyArray(interface, base=a))
+ assert (c == np.array([(1, 2, 3), (1, 2, 3), (1, 2, 3)], dtype='u4,u4,u4') ).all()
More information about the pypy-commit
mailing list