[pypy-commit] pypy numpy-fixes: test, fix for arange(array([10]))

mattip noreply at buildbot.pypy.org
Sun May 10 18:13:38 CEST 2015


Author: mattip <matti.picus at gmail.com>
Branch: numpy-fixes
Changeset: r77282:60e310f3d11e
Date: 2015-05-10 19:13 +0300
http://bitbucket.org/pypy/pypy/changeset/60e310f3d11e/

Log:	test, fix for arange(array([10]))

diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -12,8 +12,8 @@
         stop = start
         start = 0
     if dtype is None:
-        test = _numpypy.multiarray.array([start, stop, step, 0])
-        dtype = test.dtype
+        # find minimal acceptable dtype but not less than int
+        dtype = _numpypy.multiarray.result_type(start, stop, step, int)
     length = math.ceil((float(stop) - start) / step)
     length = int(length)
     arr = _numpypy.multiarray.empty(length, dtype=dtype)
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -465,7 +465,7 @@
         assert b.dtype is dtype(complex)
 
     def test_arange(self):
-        from numpy import arange, dtype
+        from numpy import arange, dtype, array
         a = arange(3)
         assert (a == [0, 1, 2]).all()
         assert a.dtype is dtype(int)
@@ -486,6 +486,9 @@
         assert len(a) == 8
         assert arange(False, True, True).dtype is dtype(int)
 
+        a = arange(array([10]))
+        assert a.shape == (10,)
+
     def test_copy(self):
         from numpy import arange, array
         a = arange(5)


More information about the pypy-commit mailing list