[pypy-commit] pypy default: small beautification

alex_gaynor noreply at buildbot.pypy.org
Tue Jan 3 17:36:22 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r51001:1946d8c1d887
Date: 2012-01-03 10:36 -0600
http://bitbucket.org/pypy/pypy/changeset/1946d8c1d887/

Log:	small beautification

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
@@ -424,13 +424,10 @@
                 res.append(')')
         else:
             concrete.to_str(space, 1, res, indent='       ')
-        if (dtype is interp_dtype.get_dtype_cache(space).w_float64dtype or \
-             dtype.kind == interp_dtype.SIGNEDLTR and \
-             dtype.itemtype.get_element_size() == rffi.sizeof(lltype.Signed)) \
-            and self.size:
-            # Do not print dtype
-            pass
-        else:
+        if (dtype is not interp_dtype.get_dtype_cache(space).w_float64dtype and
+            not (dtype.kind == interp_dtype.SIGNEDLTR and
+            dtype.itemtype.get_element_size() == rffi.sizeof(lltype.Signed)) or
+            not self.size):
             res.append(", dtype=" + dtype.name)
         res.append(")")
         return space.wrap(res.build())
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
@@ -184,15 +184,16 @@
         from numpypy import array
         x = array(0.2)
         assert x.ndim == 0
-        x = array([1,2])
+        x = array([1, 2])
         assert x.ndim == 1
-        x = array([[1,2], [3,4]])
+        x = array([[1, 2], [3, 4]])
         assert x.ndim == 2
-        x = array([[[1,2], [3,4]], [[5,6], [7,8]] ])
+        x = array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
         assert x.ndim == 3
-        # numpy actually raises an AttributeError, but numpypy raises an AttributeError
-        raises (TypeError, 'x.ndim=3')
-        
+        # numpy actually raises an AttributeError, but numpypy raises an
+        # AttributeError
+        raises (TypeError, 'x.ndim = 3')
+
     def test_init(self):
         from numpypy import zeros
         a = zeros(15)
@@ -1361,7 +1362,7 @@
 class AppTestRepr(BaseNumpyAppTest):
     def test_repr(self):
         from numpypy import array, zeros
-        intSize = array(5).dtype.itemsize
+        int_size = array(5).dtype.itemsize
         a = array(range(5), float)
         assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])"
         a = array([], float)
@@ -1369,12 +1370,12 @@
         a = zeros(1001)
         assert repr(a) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])"
         a = array(range(5), long)
-        if a.dtype.itemsize == intSize:
+        if a.dtype.itemsize == int_size:
             assert repr(a) == "array([0, 1, 2, 3, 4])"
         else:
             assert repr(a) == "array([0, 1, 2, 3, 4], dtype=int64)"
         a = array(range(5), 'int32')
-        if a.dtype.itemsize == intSize:
+        if a.dtype.itemsize == int_size:
             assert repr(a) == "array([0, 1, 2, 3, 4])"
         else:
             assert repr(a) == "array([0, 1, 2, 3, 4], dtype=int32)"


More information about the pypy-commit mailing list