Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r69290:793aeb9704c0 Date: 2014-02-23 15:05 -0500 http://bitbucket.org/pypy/pypy/changeset/793aeb9704c0/
Log: fix fill for complex with non-native byteorder diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -2684,7 +2684,7 @@ assert arange(3)[array(1)] == 1 def test_fill(self): - from numpypy import array, empty + from numpypy import array, empty, dtype, zeros a = array([1, 2, 3]) a.fill(10) assert (a == [10, 10, 10]).all() @@ -2721,6 +2721,11 @@ else: assert tuple(i) == (123,) * 5 + a = zeros(3, dtype=dtype(complex).newbyteorder()) + a.fill(1.5+2.5j) + for i in a: + assert i == 1.5+2.5j + def test_array_indexing_bool(self): from numpypy import arange a = arange(10) diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py --- a/pypy/module/micronumpy/types.py +++ b/pypy/module/micronumpy/types.py @@ -1054,13 +1054,6 @@ op = '+' if imag >= 0 or rfloat.isnan(imag) else '' return ''.join(['(', real_str, op, imag_str, ')']) - def fill(self, storage, width, box, start, stop, offset): - real, imag = self.unbox(box) - for i in xrange(start, stop, width): - raw_storage_setitem(storage, i+offset, real) - raw_storage_setitem(storage, - i+offset+rffi.sizeof(self.T), imag) - def runpack_str(self, space, s): comp = self.ComponentBoxType._get_dtype(space).itemtype l = len(s) // 2 @@ -1149,6 +1142,11 @@ def store(self, arr, i, offset, box): self._write(arr.storage, i, offset, self.unbox(box)) + def fill(self, storage, width, box, start, stop, offset): + value = self.unbox(box) + for i in xrange(start, stop, width): + self._write(storage, i, offset, value) + @complex_binary_op def add(self, v1, v2): return rcomplex.c_add(v1, v2) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit