[pypy-commit] pypy numpy-refactor: pep8

bdkearns noreply at buildbot.pypy.org
Thu Feb 27 13:17:35 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: numpy-refactor
Changeset: r69507:4769350dc332
Date: 2014-02-27 01:22 -0500
http://bitbucket.org/pypy/pypy/changeset/4769350dc332/

Log:	pep8

diff --git a/pypy/module/micronumpy/arrayops.py b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -8,6 +8,7 @@
 from pypy.module.micronumpy import support
 from pypy.module.micronumpy import constants as NPY
 
+
 def where(space, w_arr, w_x=None, w_y=None):
     """where(condition, [x, y])
 
@@ -91,6 +92,7 @@
     out = W_NDimArray.from_shape(space, shape, dtype)
     return loop.where(space, out, shape, arr, x, y, dtype)
 
+
 def dot(space, w_obj1, w_obj2, w_out=None):
     w_arr = convert_to_array(space, w_obj1)
     if w_arr.is_scalar():
@@ -162,6 +164,7 @@
         axis_start += arr.get_shape()[axis]
     return res
 
+
 @unwrap_spec(repeats=int)
 def repeat(space, w_arr, repeats, w_axis):
     arr = convert_to_array(space, w_arr)
@@ -186,9 +189,11 @@
             Chunks(chunks).apply(space, w_res).implementation.setslice(space, arr)
     return w_res
 
+
 def count_nonzero(space, w_obj):
     return space.wrap(loop.count_all_true(convert_to_array(space, w_obj)))
 
+
 def choose(space, w_arr, w_choices, w_out, w_mode):
     arr = convert_to_array(space, w_arr)
     choices = [convert_to_array(space, w_item) for w_item
@@ -208,6 +213,7 @@
     loop.choose(space, arr, choices, shape, dtype, out, mode)
     return out
 
+
 def put(space, w_arr, w_indices, w_values, w_mode):
     arr = convert_to_array(space, w_arr)
     mode = clipmode_converter(space, w_mode)
@@ -256,6 +262,7 @@
 
         arr.setitem(space, [index], dtype.coerce(space, value))
 
+
 def diagonal(space, arr, offset, axis1, axis2):
     shape = arr.get_shape()
     shapelen = len(shape)
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -70,6 +70,7 @@
         ret = space.newtuple([scalar, space.newtuple([space.wrap(self._get_dtype(space)), space.wrap(self.raw_str())])])
         return ret
 
+
 class PrimitiveBox(Box):
     _mixin_ = True
     _immutable_fields_ = ['value']
@@ -94,6 +95,7 @@
         lltype.free(value, flavor="raw")
         return ret
 
+
 class ComplexBox(Box):
     _mixin_ = True
     _immutable_fields_ = ['real', 'imag']
@@ -361,6 +363,7 @@
         return self.get_dtype(space).itemtype.imag(self)
 
     w_flags = None
+
     def descr_get_flags(self, space):
         if self.w_flags is None:
             self.w_flags = W_FlagsObject(self)
diff --git a/pypy/module/micronumpy/constants.py b/pypy/module/micronumpy/constants.py
--- a/pypy/module/micronumpy/constants.py
+++ b/pypy/module/micronumpy/constants.py
@@ -57,7 +57,7 @@
 INTPLTR = 'p'
 UINTPLTR = 'P'
 
-GENBOOLLTR ='b'
+GENBOOLLTR = 'b'
 SIGNEDLTR = 'i'
 UNSIGNEDLTR = 'u'
 FLOATINGLTR = 'f'
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -46,6 +46,7 @@
                                         "objects are not aligned"))
     return out_shape, right_critical_dim
 
+
 class __extend__(W_NDimArray):
     @jit.unroll_safe
     def descr_get_shape(self, space):
@@ -1124,6 +1125,7 @@
         return w_obj
         pass
 
+
 @unwrap_spec(offset=int)
 def descr_new_array(space, w_subtype, w_shape, w_dtype=None, w_buffer=None,
                     offset=0, w_strides=None, w_order=None):
@@ -1174,6 +1176,7 @@
                         space.wrap('__array_finalize__')), w_subtype)
     return w_ret
 
+
 @unwrap_spec(addr=int)
 def descr__from_shape_and_storage(space, w_cls, w_shape, addr, w_dtype, w_subtype=None):
     """
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -10,9 +10,11 @@
 from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
 from pypy.module.micronumpy import constants as NPY
 
+
 def done_if_true(dtype, val):
     return dtype.itemtype.bool(val)
 
+
 def done_if_false(dtype, val):
     return not dtype.itemtype.bool(val)
 
@@ -545,6 +547,7 @@
         dtypenum += 2
         return descriptor.get_dtype_cache(space).dtypes_by_num[dtypenum]
 
+
 @jit.unroll_safe
 def find_unaryop_result_dtype(space, dt, promote_to_float=False,
         promote_bools=False, promote_to_largest=False):
@@ -571,6 +574,7 @@
                 return dtype
     return dt
 
+
 def find_dtype_for_scalar(space, w_obj, current_guess=None):
     bool_dtype = descriptor.get_dtype_cache(space).w_booldtype
     long_dtype = descriptor.get_dtype_cache(space).w_longdtype
@@ -612,9 +616,9 @@
                 'unable to create dtype from objects, "%T" instance not '
                 'supported', w_obj)
 
+
 def ufunc_dtype_caller(space, ufunc_name, op_name, argcount, comparison_func,
                        bool_result):
-    dtype_cache = descriptor.get_dtype_cache(space)
     def get_op(dtype):
         try:
             return getattr(dtype.itemtype, op_name)
@@ -622,6 +626,7 @@
             raise oefmt(space.w_NotImplementedError,
                         "%s not implemented for %s",
                         ufunc_name, dtype.get_name())
+    dtype_cache = descriptor.get_dtype_cache(space)
     if argcount == 1:
         def impl(res_dtype, value):
             res = get_op(res_dtype)(value)
@@ -763,6 +768,6 @@
             ufunc = W_Ufunc2(func, ufunc_name, **extra_kwargs)
         setattr(self, ufunc_name, ufunc)
 
+
 def get(space):
     return space.fromcache(UfuncState)
-


More information about the pypy-commit mailing list