Author: Antonio Cuni <anto.c...@gmail.com> Branch: Changeset: r68354:7683ee51bc38 Date: 2013-12-02 11:18 +0100 http://bitbucket.org/pypy/pypy/changeset/7683ee51bc38/
Log: fix arange corner case 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,7 +12,9 @@ if dtype is None: test = _numpypy.multiarray.array([start, stop, step, 0]) dtype = test.dtype - arr = _numpypy.multiarray.zeros(int(math.ceil((stop - start) / step)), dtype=dtype) + length = math.ceil((float(stop) - start) / step) + length = int(length) + arr = _numpypy.multiarray.zeros(length, dtype=dtype) i = start for j in range(arr.size): arr[j] = i 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 @@ -381,6 +381,8 @@ assert a.dtype is dtype(int) a = arange(3, 7, 2) assert (a == [3, 5]).all() + a = arange(3, 8, 2) + assert (a == [3, 5, 7]).all() a = arange(3, dtype=float) assert (a == [0., 1., 2.]).all() assert a.dtype is dtype(float) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit