[pypy-commit] pypy default: float64 and int64 arrays with no values show their dtypes in their reprs.
alex_gaynor
noreply at buildbot.pypy.org
Thu Sep 1 20:17:32 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r46996:6bff38bd825c
Date: 2011-09-01 14:17 -0400
http://bitbucket.org/pypy/pypy/changeset/6bff38bd825c/
Log: float64 and int64 arrays with no values show their dtypes in their
reprs.
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -206,7 +206,7 @@
res = "array([" + ", ".join(concrete._getnums(False)) + "]"
dtype = concrete.find_dtype()
if (dtype is not space.fromcache(interp_dtype.W_Float64Dtype) and
- dtype is not space.fromcache(interp_dtype.W_Int64Dtype)):
+ dtype is not space.fromcache(interp_dtype.W_Int64Dtype)) or not self.find_size():
res += ", dtype=" + dtype.name
res += ")"
return space.wrap(res)
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
@@ -52,10 +52,14 @@
from numpy import array, zeros
a = array(range(5), float)
assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])"
+ a = array([], float)
+ assert repr(a) == "array([], dtype=float64)"
a = zeros(1001)
assert repr(a) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])"
a = array(range(5), long)
assert repr(a) == "array([0, 1, 2, 3, 4])"
+ a = array([], long)
+ assert repr(a) == "array([], dtype=int64)"
a = array([True, False, True, False], "?")
assert repr(a) == "array([True, False, True, False], dtype=bool)"
More information about the pypy-commit
mailing list