Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r69488:28a4bfdc3627 Date: 2014-02-26 20:12 -0500 http://bitbucket.org/pypy/pypy/changeset/28a4bfdc3627/
Log: fixes for cpyext ndarrayobject 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 @@ -9,8 +9,7 @@ from pypy.module.cpyext.api import PyObject from pypy.module.micronumpy.interp_numarray import W_NDimArray, array from pypy.module.micronumpy.interp_dtype import get_dtype_cache, W_Dtype -from pypy.module.micronumpy.arrayimpl.concrete import ConcreteArray -from pypy.module.micronumpy.arrayimpl.scalar import Scalar +from pypy.module.micronumpy.concrete import ConcreteArray from rpython.rlib.rawstorage import RAW_STORAGE_PTR NPY_C_CONTIGUOUS = 0x0001 @@ -167,7 +166,7 @@ # void *data = PyArray_DATA(arr); impl = w_array.implementation w_array = W_NDimArray.from_shape(space, [1], impl.dtype) - w_array.implementation.setitem(0, impl.value) + w_array.implementation.setitem(0, impl.getitem(impl.start + 0)) w_array.implementation.shape = [] return w_array @@ -214,12 +213,8 @@ order='C', owning=False, w_subtype=None): shape, dtype = get_shape_and_dtype(space, nd, dims, typenum) storage = rffi.cast(RAW_STORAGE_PTR, data) - if nd == 0: - w_val = dtype.itemtype.box_raw_data(storage) - return W_NDimArray(Scalar(dtype, w_val)) - else: - return W_NDimArray.from_shape_and_storage(space, shape, storage, dtype, - order=order, owning=owning, w_subtype=w_subtype) + return W_NDimArray.from_shape_and_storage(space, shape, storage, dtype, + order=order, owning=owning, w_subtype=w_subtype) @cpython_api([Py_ssize_t, rffi.LONGP, Py_ssize_t], PyObject) 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 @@ -77,7 +77,7 @@ def test_FromAny_scalar(self, space, api): a0 = scalar(space) - assert a0.implementation.get_scalar_value().value == 10. + assert a0.get_scalar_value().value == 10. a = api._PyArray_FromAny(a0, NULL, 0, 0, 0, NULL) assert api._PyArray_NDIM(a) == 0 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 @@ -31,7 +31,6 @@ @staticmethod def from_shape(space, shape, dtype, order='C', w_instance=None): from pypy.module.micronumpy import concrete - strides, backstrides = calc_strides(shape, dtype.base, order) impl = concrete.ConcreteArray(shape, dtype.base, order, strides, backstrides) @@ -43,7 +42,6 @@ def from_shape_and_storage(space, shape, storage, dtype, order='C', owning=False, w_subtype=None, w_base=None, writable=True): from pypy.module.micronumpy import concrete - assert shape strides, backstrides = calc_strides(shape, dtype, order) if w_base is not None: if owning: @@ -56,7 +54,6 @@ impl = concrete.ConcreteNonWritableArrayWithBase(shape, dtype, order, strides, backstrides, storage, w_base) - elif owning: # Will free storage when GCd impl = concrete.ConcreteArray(shape, dtype, order, strides, _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit