diff --git a/benchmarks/sorting.py b/benchmarks/sorting.py index d018e19d4c26..23d58983a39d 100644 --- a/benchmarks/sorting.py +++ b/benchmarks/sorting.py @@ -29,8 +29,3 @@ print "Numarray: ", t1.repeat(3,100) print "NumPy: ", t2.repeat(3,100) print "Numeric: ", t3.repeat(3,100) - - - - - diff --git a/numpy/_import_tools.py b/numpy/_import_tools.py index 4989ab340c84..24ef492197f7 100644 --- a/numpy/_import_tools.py +++ b/numpy/_import_tools.py @@ -91,7 +91,7 @@ def _init_info_modules(self, packages=None): def _get_sorted_names(self): """ Return package names sorted in the order as they should be - imported due to dependence relations between packages. + imported due to dependence relations between packages. """ depend_dict = {} @@ -178,14 +178,14 @@ def __call__(self,*packages, **options): if '.' not in package_name: self.parent_export_names.append(package_name) continue - + old_object = frame.f_locals.get(package_name,None) cmdstr = 'import '+package_name if self._execcmd(cmdstr): continue self.imported_packages.append(package_name) - + if verbose!=-1: new_object = frame.f_locals.get(package_name) if old_object is not None and old_object is not new_object: @@ -242,7 +242,7 @@ def _execcmd(self,cmdstr): self.error('%s -> failed: %s' % (cmdstr,msg)) return True else: - self.log('%s -> success' % (cmdstr)) + self.log('%s -> success' % (cmdstr)) return def _obj2repr(self,obj): diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py index 429e423c5afd..65bd1c149f79 100644 --- a/numpy/core/__init__.py +++ b/numpy/core/__init__.py @@ -26,5 +26,5 @@ __all__ += char.__all__ def test(level=1, verbosity=1): - from numpy.testing import NumpyTest + from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity) diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 0326109c7881..4b2e4eaca75d 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -64,7 +64,7 @@ def __getitem__(self, key): return (self._flagnum & num == num) and not \ (self._flagnum & _cnum == _cnum) raise KeyError, "Unknown flag: %s" % key - + def __setitem__(self, item, val): if self.scalar: raise ValueError, "Cannot set flags on array scalars." @@ -80,7 +80,7 @@ def __setitem__(self, item, val): # now actually update array flags self._arr.setflags(**kwds) - + def get_fnc(self): fl = self._flagnum @@ -152,15 +152,15 @@ def set_updateifcopy(self, val): behaved = property(get_behaved, None, "") carray = property(get_carray, None, "") farray = property(get_farray, None, "") - + # make sure the tuple entries are PyArray_Descr -# or convert them +# or convert them # -# make sure offsets are all interpretable -# as positive integers and -# convert them to positive integers if so +# make sure offsets are all interpretable +# as positive integers and +# convert them to positive integers if so # # # return totalsize from last offset and size @@ -223,7 +223,7 @@ def _usefields(adict, align): # from the fields attribute of a descriptor # This calls itself recursively but should eventually hit # a descriptor that has no fields and then return -# a simple typestring +# a simple typestring def _array_descr(descriptor): fields = descriptor.fields @@ -258,7 +258,7 @@ def _reconstruct(subtype, shape, dtype): format_re = re.compile(r'(?P *[(]?[ ,0-9]*[)]? *)(?P[><|A-Za-z0-9.]*)') def _split(input): - """Split the input formats string into field formats without splitting + """Split the input formats string into field formats without splitting the tuple used to specify multi-dimensional arrays.""" newlist = [] @@ -274,7 +274,7 @@ def _split(input): # if the parenthesis is not balanced, hold the string if left > right : - hold = item + hold = item # when balanced, append to the output list and reset the hold elif left == right: @@ -301,9 +301,9 @@ def _commastring(astr): # convert item try: (repeats, dtype) = format_re.match(item).groups() - except (TypeError, AttributeError): + except (TypeError, AttributeError): raise ValueError('format %s is not recognized' % item) - + if (repeats == ''): newitem = dtype else: diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index a78601188c5d..a649d02114ce 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -4,7 +4,7 @@ """ __all__ = ["set_summary", "summary_off", "set_precision", "set_line_width", "array2string"] - + # # Written by Konrad Hinsen # last revision: 1996-3-13 @@ -63,7 +63,7 @@ def _numeric_compress(arr): _line_width = 75 -def set_printoptions(precision=None, threshold=None, edgeitems=None, +def set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None): """Set options associated with printing. @@ -82,8 +82,8 @@ def set_printoptions(precision=None, threshold=None, edgeitems=None, suppress Boolean value indicating whether or not suppress printing of small floating point values using scientific notation (default False) - """ - + """ + global _summaryThreshhold, _summaryEdgeItems, _float_output_precision, \ _line_width, _float_output_suppress_small if (linewidth is not None): @@ -126,7 +126,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', if max_line_width is None: max_line_width = _line_width - + if precision is None: precision = _float_output_precision @@ -139,7 +139,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', else: summary_insert = "" data = a.ravel() - + try: format_function = a._format except AttributeError: @@ -168,7 +168,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', else: format = '%s' format_function = lambda x, f = format: format % str(x) - + next_line_prefix = " " # skip over "[" next_line_prefix += " "*len(prefix) # skip over array( @@ -211,11 +211,11 @@ def _formatArray(a, format_function, rank, max_line_len, 1. Full output 2. Summarized output - + """ if rank == 0: return str(a.item()) - + if summary_insert and 2*edge_items < len(a): leading_items, trailing_items, summary_insert1 = \ edge_items, edge_items, summary_insert @@ -223,20 +223,20 @@ def _formatArray(a, format_function, rank, max_line_len, leading_items, trailing_items, summary_insert1 = 0, len(a), "" if rank == 1: - + s = "" line = next_line_prefix for i in xrange(leading_items): word = format_function(a[i]) + separator s, line = _extendLine(s, line, word, max_line_len, next_line_prefix) - + if summary_insert1: s, line = _extendLine(s, line, summary_insert1, max_line_len, next_line_prefix) for i in xrange(trailing_items, 1, -1): - word = format_function(a[-i]) + separator + word = format_function(a[-i]) + separator s, line = _extendLine(s, line, word, max_line_len, next_line_prefix) - + word = format_function(a[-1]) s, line = _extendLine(s, line, word, max_line_len, next_line_prefix) s += line + "]\n" @@ -251,10 +251,10 @@ def _formatArray(a, format_function, rank, max_line_len, " " + next_line_prefix, separator, edge_items, summary_insert) s = s.rstrip() + sep.rstrip() + '\n'*max(rank-1,1) - + if summary_insert1: s += next_line_prefix + summary_insert1 + "\n" - + for i in xrange(trailing_items, 1, -1): if leading_items or i != trailing_items: s += next_line_prefix diff --git a/numpy/core/code_generators/generate_array_api.py b/numpy/core/code_generators/generate_array_api.py index 8a043c65f987..72e0caa29299 100644 --- a/numpy/core/code_generators/generate_array_api.py +++ b/numpy/core/code_generators/generate_array_api.py @@ -88,7 +88,7 @@ (void *) &PyArrayDescr_Type, (void *) &PyArrayIter_Type, (void *) &PyArrayMultiIter_Type, - (int *) &PyArray_NUMUSERTYPES, + (int *) &PyArray_NUMUSERTYPES, %s }; """ diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 4edbb5363dd0..42b038b22eba 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -73,11 +73,11 @@ def __init__(self, nin, nout, identity, docstring, #each entry in defdict is #name: [string of chars for which it is defined, -# string of characters using func interface, -# tuple of strings giving funcs for data, +# string of characters using func interface, +# tuple of strings giving funcs for data, # (in, out), or (instr, outstr) giving the signature as character codes, # identity, -# docstring, +# docstring, # output specification (optional) # ] diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 79cc9b69aa56..a220919c51ae 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -38,7 +38,7 @@ def __new__(subtype, shape, itemsize=1, unicode=False, buffer=None, def __array_finalize__(self, obj): if not _globalvar and self.dtype.char not in 'SU': raise ValueError, "Can only create a chararray from string data." - + def _richcmpfunc(self, other, op): b = broadcast(self, other) @@ -49,7 +49,7 @@ def _richcmpfunc(self, other, op): r2 = val[1] res[k] = eval("r1 %s r2" % op, {'r1':r1,'r2':r2}) return result - + # these should probably be moved to C def __eq__(self, other): return self._richcmpfunc(other, '==') @@ -65,10 +65,10 @@ def __le__(self, other): def __gt__(self, other): return self._richcmpfunc(other, '>') - + def __lt__(self, other): return self._richcmpfunc(other, '<') - + def __add__(self, other): b = broadcast(self, other) arr = b.iters[1].base @@ -77,17 +77,17 @@ def __add__(self, other): res = result.flat for k, val in enumerate(b): res[k] = (val[0] + val[1]) - return result + return result def __radd__(self, other): b = broadcast(other, self) outitem = b.iters[0].base.itemsize + \ b.iters[1].base.itemsize - result = chararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = (val[0] + val[1]) - return result + return result def __mul__(self, other): b = broadcast(self, other) @@ -107,7 +107,7 @@ def __rmul__(self, other): if not issubclass(arr.dtype.type, integer): raise ValueError, "Can only multiply by integers" outitem = b.iters[0].base.itemsize * arr.max() - result = chararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = val[0]*val[1] @@ -124,7 +124,7 @@ def __mod__(self, other): newarr = chararray(b.shape, maxsize, self.dtype is unicode_) newarr[:] = res return newarr - + def __rmod__(self, other): return NotImplemented @@ -186,22 +186,22 @@ def rsplit(self, sep=None, maxsplit=None): def ljust(self, width): return self._generalmethod('ljust', broadcast(self, width)) def rjust(self, width): - return self._generalmethod('rjust', broadcast(self, width)) + return self._generalmethod('rjust', broadcast(self, width)) def center(self, width): - return self._generalmethod('center', broadcast(self, width)) + return self._generalmethod('center', broadcast(self, width)) def count(self, sub, start=None, end=None): return self._typedmethod('count', broadcast(self, sub, start, end), int) def decode(self,encoding=None,errors=None): return self._generalmethod('decode', broadcast(self, encoding, errors)) - + def encode(self,encoding=None,errors=None): return self._generalmethod('encode', broadcast(self, encoding, errors)) - + def endswith(self, suffix, start=None, end=None): return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool) - + def expandtabs(self, tabsize=None): return self._generalmethod('endswith', broadcast(self, tabsize)) @@ -211,7 +211,7 @@ def find(self, sub, start=None, end=None): def index(self, sub, start=None, end=None): return self._typedmethod('index', broadcast(self, sub, start, end), int) - def _ismethod(self, name): + def _ismethod(self, name): result = empty(self.shape, dtype=bool) res = result.flat for k, val in enumerate(self.flat): @@ -230,7 +230,7 @@ def isdigit(self): def islower(self): return self._ismethod('islower') - + def isspace(self): return self._ismethod('isspace') @@ -242,7 +242,7 @@ def isupper(self): def join(self, seq): return self._generalmethod('join', broadcast(self, seq)) - + def lower(self): return self._samemethod('lower') @@ -253,25 +253,25 @@ def replace(self, old, new, count=None): return self._generalmethod('replace', broadcast(self, old, new, count)) def rfind(self, sub, start=None, end=None): - return self._typedmethod('rfind', broadcast(self, sub, start, end), int) + return self._typedmethod('rfind', broadcast(self, sub, start, end), int) def rindex(self, sub, start=None, end=None): return self._typedmethod('rindex', broadcast(self, sub, start, end), int) def rstrip(self, chars=None): - return self._generalmethod('rstrip', broadcast(self, chars)) + return self._generalmethod('rstrip', broadcast(self, chars)) def split(self, sep=None, maxsplit=None): return self._typedmethod('split', broadcast(self, sep, maxsplit), object) def splitlines(self, keepends=None): return self._typedmethod('splitlines', broadcast(self, keepends), object) - + def startswith(self, prefix, start=None, end=None): return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool) def strip(self, chars=None): - return self._generalmethod('strip', broadcast(self, chars)) + return self._generalmethod('strip', broadcast(self, chars)) def swapcase(self): return self._samemethod('swapcase') @@ -284,16 +284,16 @@ def translate(self, table, deletechars=None): return self._generalmethod('translate', broadcast(self, table)) else: return self._generalmethod('translate', broadcast(self, table, deletechars)) - + def upper(self): return self._samemethod('upper') def zfill(self, width): return self._generalmethod('zfill', broadcast(self, width)) - + def array(obj, itemsize=None, copy=True, unicode=False, fortran=False): - + if isinstance(obj, chararray): if itemsize is None: itemsize = obj.itemsize @@ -313,7 +313,7 @@ def array(obj, itemsize=None, copy=True, unicode=False, fortran=False): if copy: return new.copy() else: return new - + if unicode: dtype = "U" else: dtype = "S" @@ -323,13 +323,13 @@ def array(obj, itemsize=None, copy=True, unicode=False, fortran=False): if isinstance(obj, (str, _unicode)): if itemsize is None: itemsize = len(obj) - shape = len(obj) / itemsize + shape = len(obj) / itemsize return chararray(shape, itemsize=itemsize, unicode=unicode, buffer=obj) - # default + # default val = narray(obj, dtype=dtype, fortran=fortran, subok=1) - + return val.view(chararray) def asarray(obj, itemsize=None, unicode=False, fortran=False): diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py index d89260ef6747..388d7b1c97cc 100644 --- a/numpy/core/defmatrix.py +++ b/numpy/core/defmatrix.py @@ -43,12 +43,12 @@ def _convert_from_string(data): newdata.append(newrow) return newdata -def asmatrix(data, dtype=None): - """ Returns 'data' as a matrix. Unlike matrix(), no copy is performed - if 'data' is already a matrix or array. Equivalent to: - matrix(data, copy=False) - """ - return matrix(data, dtype=dtype, copy=False) +def asmatrix(data, dtype=None): + """ Returns 'data' as a matrix. Unlike matrix(), no copy is performed + if 'data' is already a matrix or array. Equivalent to: + matrix(data, copy=False) + """ + return matrix(data, dtype=dtype, copy=False) class matrix(N.ndarray): __array_priority__ = 10.0 @@ -89,7 +89,7 @@ def __new__(subtype, data, dtype=None, copy=True): fortran = False if (ndim == 2) and arr.flags.fortran: fortran = True - + if not (fortran or arr.flags.contiguous): arr = arr.copy() @@ -142,14 +142,14 @@ def _get_truendim(self): for val in shp: if (val > 1): truend += 1 return truend - + def __mul__(self, other): if isinstance(other, N.ndarray) or N.isscalar(other) or \ not hasattr(other, '__rmul__'): return N.dot(self, other) else: return NotImplemented - + def __rmul__(self, other): return N.dot(other, self) @@ -211,8 +211,8 @@ def sum(self, axis=None, dtype=None): return s.transpose() else: return s - - # Needed becase tolist method expects a[i] + + # Needed becase tolist method expects a[i] # to have dimension a.ndim-1 def tolist(self): return self.__array__().tolist() @@ -267,7 +267,7 @@ def _from_string(str,gdict,ldict): def bmat(obj, ldict=None, gdict=None): """Build a matrix object from string, nested sequence, or array. - Ex: F = bmat('A, B; C, D') + Ex: F = bmat('A, B; C, D') F = bmat([[A,B],[C,D]]) F = bmat(r_[c_[A,B],c_[C,D]]) diff --git a/numpy/core/info.py b/numpy/core/info.py index 30071426b966..8947fea6f2fa 100644 --- a/numpy/core/info.py +++ b/numpy/core/info.py @@ -12,7 +12,7 @@ - fromstring - Construct array from (byte) string - take - Select sub-arrays using sequence of indices - put - Set sub-arrays using sequence of 1-D indices -- putmask - Set portion of arrays using a mask +- putmask - Set portion of arrays using a mask - reshape - Return array with new shape - repeat - Repeat elements of array - choose - Construct new array from indexed array tuple @@ -25,20 +25,20 @@ - cumproduct - Cumulative product over a specified dimension - alltrue - Logical and over an entire axis - sometrue - Logical or over an entire axis -- allclose - Tests if sequences are essentially equal +- allclose - Tests if sequences are essentially equal More Functions: - arrayrange (arange) - Return regularly spaced array - asarray - Guarantee NumPy array -- sarray - Guarantee a NumPy array that keeps precision +- sarray - Guarantee a NumPy array that keeps precision - convolve - Convolve two 1-d arrays - swapaxes - Exchange axes - concatenate - Join arrays together - transpose - Permute axes - sort - Sort elements of array - argsort - Indices of sorted array -- argmax - Index of largest value +- argmax - Index of largest value - argmin - Index of smallest value - innerproduct - Innerproduct of two arrays - dot - Dot product (matrix multiplication) @@ -52,7 +52,7 @@ - dumps - Return pickled string representing data - load - Return array stored in file object - loads - Return array from pickled string -- ravel - Return array as 1-D +- ravel - Return array as 1-D - nonzero - Indices of nonzero elements for 1-D array - shape - Shape of array - where - Construct array from binary result @@ -61,23 +61,23 @@ - ones - Array of all ones - identity - 2-D identity array (matrix) -(Universal) Math Functions +(Universal) Math Functions - add logical_or exp - subtract logical_xor log - multiply logical_not log10 - divide maximum sin - divide_safe minimum sinh - conjugate bitwise_and sqrt - power bitwise_or tan - absolute bitwise_xor tanh - negative invert ceil - greater left_shift fabs - greater_equal right_shift floor - less arccos arctan2 - less_equal arcsin fmod - equal arctan hypot - not_equal cos around + add logical_or exp + subtract logical_xor log + multiply logical_not log10 + divide maximum sin + divide_safe minimum sinh + conjugate bitwise_and sqrt + power bitwise_or tan + absolute bitwise_xor tanh + negative invert ceil + greater left_shift fabs + greater_equal right_shift floor + less arccos arctan2 + less_equal arcsin fmod + equal arctan hypot + not_equal cos around logical_and cosh sign arccosh arcsinh arctanh diff --git a/numpy/core/ma.py b/numpy/core/ma.py index 3f047ce3f2c0..3354f49c2c01 100644 --- a/numpy/core/ma.py +++ b/numpy/core/ma.py @@ -62,7 +62,7 @@ def __str__ (self): return str(self._display) __repr__ = __str__ - + #if you single index into a masked location you get this object. masked_print_option = _MaskedPrintOption('--') @@ -302,7 +302,7 @@ def __init__ (self, aufunc, fill=0, domain=None): self.__name__ = getattr(aufunc, "__name__", str(aufunc)) ufunc_domain[aufunc] = domain ufunc_fills[aufunc] = fill, - + def __call__ (self, a, *args, **kwargs): "Execute the call behavior." # numeric tries to return scalars rather than arrays when given scalars. @@ -354,7 +354,7 @@ def __call__(self, a, b): m = mask_or(ma, mb) result = self.f(d1, d2) return masked_array(result, m) - + def __str__ (self): return "Masked version of " + str(self.f) @@ -448,7 +448,7 @@ def nonzero(a): a must be 1d """ return asarray(filled(a, 0).nonzero()) - + around = masked_unary_operation(oldnumeric.round_) floor = masked_unary_operation(umath.floor) ceil = masked_unary_operation(umath.ceil) @@ -498,7 +498,7 @@ def size (object, axis=None): class MaskedArray (object): """Arrays with possibly masked values. - Masked values of 1 exclude the corresponding element from + Masked values of 1 exclude the corresponding element from any computation. Construction: @@ -525,7 +525,7 @@ class MaskedArray (object): The fill_value is not used for computation within this module. """ __array_priority__ = 10.1 - def __init__(self, data, dtype=None, copy=True, fortran=False, + def __init__(self, data, dtype=None, copy=True, fortran=False, mask=nomask, fill_value=None): """array(data, dtype=None, copy=True, fortran=False, mask=nomask, fill_value=None) If data already a numeric array, its dtype becomes the default value of dtype. @@ -639,9 +639,9 @@ def __array_wrap__ (self, array, context): else: if m.shape != shape: m = reduce(mask_or, [getmaskarray(a) for a in args]) - + return MaskedArray(array, copy=False, mask=m) - + def _get_shape(self): "Return the current shape." return self._data.shape @@ -789,7 +789,7 @@ def __getitem__(self, i): return dout mi = m[i] if mi.size == 1: - if mi: + if mi: return masked else: return dout @@ -869,12 +869,12 @@ def __nonzero__(self): """ # XXX: This changes bool conversion logic from MA. # XXX: In MA bool(a) == len(a) != 0, but in numpy - # XXX: scalars do not have len + # XXX: scalars do not have len m = self._mask d = self._data return bool(m is not nomask and m.any() or d is not nomask and d.any()) - + def __len__ (self): """Return length of first dimension. This is weird but Python's slicing behavior depends on it.""" @@ -1201,7 +1201,7 @@ def count (self, axis = None): del t[axis] return ones(t) * n if axis is None: - w = oldnumeric.ravel(m).astype(int) + w = oldnumeric.ravel(m).astype(int) n1 = size(w) if n1 == 1: n2 = w[0] @@ -1314,7 +1314,7 @@ def raw_data (self): The raw data; portions may be meaningless. May be noncontiguous. Expert use only.""" return self._data - data = property(fget=raw_data, + data = property(fget=raw_data, doc="The data, but values at masked locations are meaningless.") def raw_mask (self): @@ -1322,7 +1322,7 @@ def raw_mask (self): May be noncontiguous. Expert use only. """ return self._mask - mask = property(fget=raw_mask, + mask = property(fget=raw_mask, doc="The mask, may be nomask. Values where mask true are meaningless.") def reshape (self, *s): @@ -1348,7 +1348,7 @@ def _get_size (self): return self._data.size size = property(fget=_get_size, doc="Number of elements in the array.") ## CHECK THIS: signature of numeric.array.size? - + def _get_dtype(self): return self._data.dtype dtype = property(fget=_get_dtype, doc="type of the array elements.") diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 8e9faa5b03c3..72596ff5ed97 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -55,7 +55,7 @@ def __new__(subtype, name, dtype=uint8, mode='r+', offset=0, bytes = offset + size*_dbytes - if mode == 'w+' or (mode == 'r+' and flen < bytes): + if mode == 'w+' or (mode == 'r+' and flen < bytes): fid.seek(bytes-1,0) fid.write(chr(0)) fid.flush() diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 4ba59908141a..58d943066434 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -337,7 +337,7 @@ def load(file): def ones(shape, dtype=int_, fortran=False): """ones(shape, dtype=int_) returns an array of the given - dimensions which is initialized to all ones. + dimensions which is initialized to all ones. """ a = empty(shape, dtype, fortran) a.fill(1) @@ -381,7 +381,7 @@ def _setpyvals(lst, frame, where=0): elif where == 1 or wh == 'g': frame.f_globals[UFUNC_PYVALS_NAME] = lst elif where == 2 or wh == 'b': - frame.f_builtins[UFUNC_PYVALS_NAME] = lst + frame.f_builtins[UFUNC_PYVALS_NAME] = lst umath.update_use_defaults() return diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 30d90df8c434..d4a095c5bd91 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -172,7 +172,7 @@ def _add_aliases(): if (name != 'longdouble' and name != 'clongdouble') or \ myname not in allTypes.keys(): allTypes[myname] = typeobj - typeDict[myname] = typeobj + typeDict[myname] = typeobj if base == 'complex': na_name = '%s%d' % (base.capitalize(), bit/2) elif base == 'bool': @@ -205,7 +205,7 @@ def _add_integer_aliases(): bits = val[2] intname = 'int%d' % bits UIntname = 'UInt%d' % bits - Intname = 'Int%d' % bits + Intname = 'Int%d' % bits uval = typeinfo['U'+ctype] if intname not in allTypes.keys(): uintname = 'uint%d' % bits @@ -217,7 +217,7 @@ def _add_integer_aliases(): typeDict[uintname] = utypeobj typeDict[Intname] = typeobj typeDict[UIntname] = utypeobj - typeNA[Intname] = typeobj + typeNA[Intname] = typeobj typeNA[UIntname] = utypeobj typeNA[typeobj] = Intname typeNA[utypeobj] = UIntname @@ -227,7 +227,7 @@ def _add_integer_aliases(): typeNA[typeobj] = Intname typeNA[utypeobj] = UIntname typeNA[val[0]] = Intname - typeNA[uval[0]] = UIntname + typeNA[uval[0]] = UIntname _add_integer_aliases() # We use these later @@ -426,4 +426,3 @@ def sctype2char(sctype): __all__.append(key) del key - diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py index 4e3add5b4521..5e661b1ad3ff 100644 --- a/numpy/core/oldnumeric.py +++ b/numpy/core/oldnumeric.py @@ -3,7 +3,7 @@ __all__ = ['asarray', 'array', 'concatenate', 'NewAxis', 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype', - 'LittleEndian', 'Bool', + 'LittleEndian', 'Bool', 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt', 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger', # UnsignedInt64 and Unsigned128 added below if possible @@ -19,7 +19,7 @@ # functions that are now methods 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask', 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin', - 'searchsorted', 'alen', + 'searchsorted', 'alen', 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape', 'compress', 'clip', 'sum', 'product', 'prod', 'sometrue', 'alltrue', 'any', 'all', 'cumsum', 'cumproduct', 'cumprod', 'ptp', 'ndim', @@ -323,7 +323,7 @@ def shape(a): return asarray(a).shape def compress(condition, m, axis=-1): - """compress(condition, x, axis=-1) = those elements of x corresponding + """compress(condition, x, axis=-1) = those elements of x corresponding to those elements of condition that are "true". condition must be the same size as the given dimension of x.""" return asarray(m).compress(condition, axis) diff --git a/numpy/core/records.py b/numpy/core/records.py index f389388d78f6..3fc307f6979f 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -22,8 +22,8 @@ 'i':'|'} # formats regular expression -# allows multidimension spec with a tuple syntax in front -# of the letter code '(2,3)f4' and ' ( 2 , 3 ) f4 ' +# allows multidimension spec with a tuple syntax in front +# of the letter code '(2,3)f4' and ' ( 2 , 3 ) f4 ' # are equally allowed numfmt = nt.typeDict @@ -68,7 +68,7 @@ def _setfieldnames(self, names, titles): raise NameError, "illegal input names %s" % `names` self._names = [n.strip() for n in names[:self._nfields]] - else: + else: self._names = [] # if the names are not specified, they will be assigned as "f1, f2,..." @@ -89,17 +89,17 @@ def _setfieldnames(self, names, titles): if (self._nfields > len(titles)): self._titles += [None]*(self._nfields-len(titles)) - + def _createdescr(self): self._descr = sb.dtype({'names':self._names, 'formats':self._f_formats, 'offsets':self._offsets, 'titles':self._titles}) - + class record(nt.void): def __repr__(self): return self.__str__() - + def __str__(self): return str(self.item()) @@ -121,7 +121,7 @@ def __setattr__(self, attr, val): return self.setfield(val,*res[:2]) return nt.void.__setattr__(self,attr,val) - + # The recarray is almost identical to a standard array (which supports # named fields already) The biggest difference is that it can use # attribute-lookup to find the fields and it is constructed using @@ -159,7 +159,7 @@ def __getattribute__(self, attr): res = fielddict[attr][:2] except: return object.__getattribute__(self,attr) - + obj = self.getfield(*res) # if it has fields return a recarray, otherwise return # normal array @@ -168,20 +168,20 @@ def __getattribute__(self, attr): if obj.dtype.char in 'SU': return obj.view(chararray) return obj.view(sb.ndarray) - - + + def __setattr__(self, attr, val): fielddict = sb.ndarray.__getattribute__(self,'dtype').fields try: res = fielddict[attr][:2] except: return object.__setattr__(self,attr,val) - + return self.setfield(val,*res) def field(self,attr, val=None): fielddict = sb.ndarray.__getattribute__(self,'dtype').fields - + if isinstance(attr,int): attr=fielddict[-1][attr] @@ -210,7 +210,7 @@ def fromarrays(arrayList, formats=None, names=None, titles=None, shape=None, if isinstance(shape, int): shape = (shape,) - + if formats is None: # go through each object in the list to see if it is an ndarray # and determine the formats. @@ -231,7 +231,7 @@ def fromarrays(arrayList, formats=None, names=None, titles=None, shape=None, parsed = format_parser(formats, names, titles, aligned) _names = parsed._names _array = recarray(shape, parsed._descr) - + # populate the record array (makes a copy) for i in range(len(arrayList)): _array[_names[i]] = arrayList[i] @@ -264,7 +264,7 @@ def fromrecords(recList, formats=None, names=None, titles=None, shape=None, chararray(['dbe', 'de']) >>> import cPickle >>> print cPickle.loads(cPickle.dumps(r)) - recarray[ + recarray[ (456, 'dbe', 1.2), (2, 'de', 1.3) ] @@ -298,7 +298,7 @@ def fromrecords(recList, formats=None, names=None, titles=None, shape=None, res = retval.view(recarray) res.dtype = sb.dtype((record, res.dtype)) return res - + def fromstring(datastring, formats, shape=None, names=None, titles=None, byteorder=None, aligned=0, offset=0): @@ -309,7 +309,7 @@ def fromstring(datastring, formats, shape=None, names=None, titles=None, itemsize = parsed._descr.itemsize if (shape is None or shape == 0 or shape == -1): shape = (len(datastring)-offset) / itemsize - + _array = recarray(shape, parsed._descr, names=names, titles=titles, buf=datastring, offset=offset, byteorder=byteorder) @@ -358,7 +358,7 @@ def fromfile(fd, formats, shape=None, names=None, titles=None, shape[ shape.index(-1) ] = size / -shapesize shape = tuple(shape) shapeprod = sb.array(shape).prod() - + nbytes = shapeprod*itemsize if nbytes > size: @@ -372,13 +372,13 @@ def fromfile(fd, formats, shape=None, names=None, titles=None, raise IOError("Didn't read as many bytes as expected") if name: fd.close() - + return _array def array(obj, formats=None, names=None, titles=None, shape=None, byteorder=None, aligned=0, offset=0, strides=None): - + if isinstance(obj, (type(None), str, file)) and (formats is None): raise ValueError("Must define formats if object is "\ "None, string, or an open file") @@ -416,4 +416,3 @@ def array(obj, formats=None, names=None, titles=None, shape=None, return res else: raise ValueError("Unknown input type") - diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 75e21551ae50..c0f44bc34e76 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -75,12 +75,12 @@ def generate_config_h(ext, build_dir): moredefs.append('HAVE_ISINF') if config_cmd.check_func('rint', **kws_args): moredefs.append('HAVE_RINT') - + if sys.version[:3] < '2.4': kws_args['headers'].append('stdlib.h') if config_cmd.check_func('strtod', **kws_args): moredefs.append(('PyOS_ascii_strtod', 'strtod')) - + if moredefs: target_f = open(target,'a') for d in moredefs: @@ -155,14 +155,14 @@ def generate_umath_c(ext,build_dir): join('include','numpy','*object.h'), 'include/numpy/fenv/fenv.c', 'include/numpy/fenv/fenv.h', - join(codegen_dir,'genapi.py'), - join(codegen_dir,'*.txt') + join(codegen_dir,'genapi.py'), + join(codegen_dir,'*.txt') ] # Don't install fenv unless we need them. if sys.platform == 'cygwin': config.add_data_dir('include/numpy/fenv') - + config.add_extension('multiarray', sources = [join('src','multiarraymodule.c'), generate_config_h, diff --git a/numpy/core/tests/test_defmatrix.py b/numpy/core/tests/test_defmatrix.py index 1eb91c8f9a6c..1546847d43ba 100644 --- a/numpy/core/tests/test_defmatrix.py +++ b/numpy/core/tests/test_defmatrix.py @@ -19,11 +19,11 @@ def check_basic(self): [3,4,3,4]]) assert all(B.A == D) assert all(C.A == D) - + vec = arange(5) mvec = matrix(vec) assert mvec.shape == (1,5) - + class test_properties(ScipyTestCase): def check_sum(self): """Test whether matrix.sum(axis=1) preserves orientation. @@ -42,15 +42,15 @@ def check_sum(self): def check_basic(self): import numpy.linalg as linalg - - A = array([[1., 2.], + + A = array([[1., 2.], [3., 4.]]) mA = matrix(A) assert allclose(linalg.inv(A), mA.I) assert all(array(transpose(A) == mA.T)) assert all(array(transpose(A) == mA.H)) assert all(A == mA.A) - + B = A + 2j*A mB = matrix(B) assert allclose(linalg.inv(B), mB.I) @@ -68,19 +68,19 @@ def check_comparisons(self): assert all(mA <= mB) assert all(mA <= mA) assert not any(mA < mA) - + assert not any(mB < mA) assert all(mB >= mA) assert all(mB >= mB) assert not any(mB > mB) - + assert all(mA == mA) assert not any(mA == mB) assert all(mB != mA) - + assert not all(abs(mA) > 0) assert all(abs(mB > 0)) - + def check_asmatrix(self): A = arange(100).reshape(10,10) mA = asmatrix(A) @@ -96,14 +96,14 @@ class test_casting(ScipyTestCase): def check_basic(self): A = arange(100).reshape(10,10) mA = matrix(A) - + mB = mA.copy() O = ones((10,10), float64) * 0.1 mB = mB + O assert mB.dtype.type == float64 assert all(mA != mB) assert all(mB == mA+0.1) - + mC = mA.copy() O = ones((10,10), complex128) mC = mC * O @@ -113,7 +113,7 @@ def check_basic(self): class test_algebra(ScipyTestCase): def check_basic(self): import numpy.linalg as linalg - + A = array([[1., 2.], [3., 4.]]) mA = matrix(A) @@ -122,7 +122,7 @@ def check_basic(self): for i in xrange(6): assert allclose((mA ** i).A, B) B = dot(B, A) - + Ainv = linalg.inv(A) B = identity(2) for i in xrange(6): @@ -130,7 +130,7 @@ def check_basic(self): B = dot(B, Ainv) assert allclose((mA * mA).A, dot(A, A)) - assert allclose((mA + mA).A, (A + A)) + assert allclose((mA + mA).A, (A + A)) assert allclose((3*mA).A, (3*A)) if __name__ == "__main__": diff --git a/numpy/core/tests/test_ma.py b/numpy/core/tests/test_ma.py index abee7d91f20c..02ccb4625518 100644 --- a/numpy/core/tests/test_ma.py +++ b/numpy/core/tests/test_ma.py @@ -1,4 +1,4 @@ -import numpy +import numpy import types, time from numpy.core.ma import * from numpy.testing import ScipyTestCase, ScipyTest @@ -16,7 +16,7 @@ class test_ma(ScipyTestCase): def __init__(self, *args, **kwds): ScipyTestCase.__init__(self, *args, **kwds) self.setUp() - + def setUp (self): x=numpy.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y=numpy.array([5.,0.,3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) @@ -48,14 +48,14 @@ def check_testBasic1d(self): def check_testBasic2d(self): "Test of basic array creation and properties in 2 dimensions." - for s in [(4,3), (6,2)]: + for s in [(4,3), (6,2)]: (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d x.shape = s y.shape = s xm.shape = s ym.shape = s xf.shape = s - + self.failIf(isMaskedArray(x)) self.failUnless(isMaskedArray(xm)) self.assertEqual(shape(xm), s) @@ -75,7 +75,7 @@ def check_testArithmetic (self): self.failUnless(eq (a2d * a2d, a2d * a2dm)) self.failUnless(eq (a2d + a2d, a2d + a2dm)) self.failUnless(eq (a2d - a2d, a2d - a2dm)) - for s in [(12,), (4,3), (2,6)]: + for s in [(12,), (4,3), (2,6)]: x = x.reshape(s) y = y.reshape(s) xm = xm.reshape(s) @@ -108,7 +108,7 @@ def check_testMixedArithmetic(self): ma = array([1]) self.failUnless(isinstance(na + ma, MaskedArray)) self.failUnless(isinstance(ma + na, MaskedArray)) - + def check_testUfuncs1 (self): "Test various functions such as sin, cos." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d @@ -138,7 +138,7 @@ def check_testUfuncs1 (self): self.failUnless (eq(numpy.concatenate((x,y)), concatenate((x,y)))) self.failUnless (eq(numpy.concatenate((x,y)), concatenate((xm,y)))) self.failUnless (eq(numpy.concatenate((x,y,x)), concatenate((x,ym,x)))) - + def check_xtestCount (self): "Test count" ott = array([0.,1.,2.,3.], mask=[1,0,0,0]) @@ -152,9 +152,9 @@ def check_xtestCount (self): self.failUnless (eq(3, count(ott))) assert getmask(count(ott,0)) is nomask self.failUnless (eq([1,2],count(ott,0))) - + def check_testMinMax (self): - "Test minimum and maximum." + "Test minimum and maximum." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d xr = numpy.ravel(x) #max doesn't work if shaped xmr = ravel(xm) @@ -179,8 +179,8 @@ def check_testAddSumProd (self): self.failUnless (eq(numpy.add.reduce(x,1), add.reduce(x,1))) self.failUnless (eq(numpy.sum(x,1), sum(x,1))) self.failUnless (eq(numpy.product(x,1), product(x,1))) - - + + def check_testCI(self): "Test of conversions and indexing" x1 = numpy.array([1,2,4,3]) @@ -229,7 +229,7 @@ def check_testCI(self): self.assertEqual(type(s1), str) self.assertEqual(s1, s2) assert x1[1:1].shape == (0,) - + def check_testCopySize(self): "Tests of some subtle points of copying and sizing." n = [0,0,1,0,0] @@ -238,17 +238,17 @@ def check_testCopySize(self): self.failUnless(m is m2) m3 = make_mask(m, copy=1) self.failUnless(m is not m3) - + x1 = numpy.arange(5) y1 = array(x1, mask=m) self.failUnless( y1.raw_data() is not x1) self.failUnless( allequal(x1,y1.raw_data())) self.failUnless( y1.mask is m) - + y1a = array(y1, copy=0) self.failUnless( y1a.raw_data() is y1.raw_data()) self.failUnless( y1a.mask is y1.mask) - + y2 = array(x1, mask=m, copy=0) self.failUnless( y2.raw_data() is x1) self.failUnless( y2.mask is m) @@ -257,10 +257,10 @@ def check_testCopySize(self): self.failUnless( y2[2] is not masked) self.failUnless( y2.mask is not m) self.failUnless( allequal(y2.mask, 0)) - + y3 = array(x1*1.0, mask=m) self.failUnless(filled(y3).dtype is (x1*1.0).dtype) - + x4 = arange(4) x4[2] = masked y4 = resize(x4, (8,)) @@ -270,7 +270,7 @@ def check_testCopySize(self): self.failUnless( eq(y5, [0,0,1,1,2,2,3,3])) y6 = repeat(x4, 2) self.failUnless( eq(y5, y6)) - + def check_testPut(self): "Test of put" d = arange(5) @@ -284,24 +284,24 @@ def check_testPut(self): self.failUnless( x[3] is masked) self.failUnless( x[4] is not masked) self.failUnless( eq(x, [0,10,2,-1,40])) - - x = array(d, mask = m) + + x = array(d, mask = m) x.put([-1,100,200]) self.failUnless( eq(x, [-1,100,200,0,0])) self.failUnless( x[3] is masked) self.failUnless( x[4] is masked) - - x = array(d, mask = m) + + x = array(d, mask = m) x.putmask([30,40]) self.failUnless( eq(x, [0,1,2,30,40])) self.failUnless( x.mask is nomask) - - x = array(d, mask = m) + + x = array(d, mask = m) y = x.compressed() z = array(x, mask = m) z.put(y) assert eq (x, z) - + def check_testMaPut(self): (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1] @@ -310,7 +310,7 @@ def check_testMaPut(self): assert take(xm, i) == z put(ym, i, zm) assert take(ym, i) == zm - + def check_testOddFeatures(self): "Test of other odd features" x = arange(20); x=x.reshape(4,5) @@ -321,7 +321,7 @@ def check_testOddFeatures(self): assert eq(z.imag, 10*x) assert eq((z*conjugate(z)).real, 101*x*x) z.imag[...] = 0.0 - + x = arange(10) x[3] = masked assert str(x[3]) == str(masked) @@ -400,9 +400,9 @@ def check_testOddFeatures(self): assert eq(z, [99,99,99,1,1,1]) z = where(c, 1, masked) assert eq(z, [99, 1, 1, 99, 99, 99]) - + def check_testMinMax(self): - "Test of minumum, maximum." + "Test of minumum, maximum." assert eq(minimum([1,2,3],[4,0,9]), [1,0,3]) assert eq(maximum([1,2,3],[4,0,9]), [4,2,9]) x = arange(5) @@ -413,7 +413,7 @@ def check_testMinMax(self): assert eq(maximum(x,y), where(greater(x,y), x, y)) assert minimum(x) == 0 assert maximum(x) == 4 - + def check_testTakeTransposeInnerOuter(self): "Test of take, transpose, inner, outer products" x = arange(24) @@ -433,11 +433,11 @@ def check_testTakeTransposeInnerOuter(self): assert t[0] == 'abc' assert t[1] == 2 assert t[2] == 3 - + def check_testInplace(self): """Test of inplace operations and rich comparisons""" y = arange(10) - + x = arange(10) xm = arange(10) xm[2] = masked @@ -445,7 +445,7 @@ def check_testInplace(self): assert eq(x, y+1) xm += 1 assert eq(x, y+1) - + x = arange(10) xm = arange(10) xm[2] = masked @@ -453,7 +453,7 @@ def check_testInplace(self): assert eq(x, y-1) xm -= 1 assert eq(xm, y-1) - + x = arange(10)*1.0 xm = arange(10)*1.0 xm[2] = masked @@ -461,7 +461,7 @@ def check_testInplace(self): assert eq(x, y*2) xm *= 2.0 assert eq(xm, y*2) - + x = arange(10)*2 xm = arange(10) xm[2] = masked @@ -469,7 +469,7 @@ def check_testInplace(self): assert eq(x, y) xm /= 2 assert eq(x, y) - + x = arange(10)*1.0 xm = arange(10)*1.0 xm[2] = masked @@ -477,7 +477,7 @@ def check_testInplace(self): assert eq(x, y/2.0) xm /= arange(10) assert eq(xm, ones((10,))) - + x = arange(10).astype(float32) xm = arange(10) xm[2] = masked @@ -508,7 +508,7 @@ def check_testMasked(self): #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, 2) #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx) #self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked) - + def check_testAverage1(self): "Test of average." ott = array([0.,1.,2.,3.], mask=[1,0,0,0]) @@ -557,7 +557,7 @@ def check_testAverage2(self): self.failUnless(allclose(average(z, axis=0), [0.,1.,99.,99.,4.0, 7.5])) self.failUnless(allclose(average(z, axis=1), [2.5, 5.0])) self.failUnless(allclose( average(z,weights=w2), [0.,1., 99., 99., 4.0, 10.0])) - + a = arange(6) b = arange(6) * 3 r1, w1 = average([[a,b],[b,a]], axis=1, returned=1) @@ -643,12 +643,12 @@ def setUp(self): self.d = (array([1.0, 0, -1, pi/2]*2, mask=[0,1]+[0]*6), array([1.0, 0, -1, pi/2]*2, mask=[1,0]+[0]*6),) - + def check_testUfuncRegression(self): for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate', - 'sin', 'cos', 'tan', + 'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', - 'sinh', 'cosh', 'tanh', + 'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh', @@ -674,7 +674,7 @@ def check_testUfuncRegression(self): mr = mf(*args) self.failUnless(eq(ur.filled(0), mr.filled(0), f)) self.failUnless(eqmask(ur.mask, mr.mask)) - + def test_reduce(self): a = self.d[0] self.failIf(alltrue(a)) @@ -696,14 +696,14 @@ def test_nonzero(self): for t in "?bhilqpBHILQPfdgFDGO": x = array([1,0,2,0], mask=[0,0,1,1]) self.failUnless(eq(nonzero(x), [0])) - + def eqmask(m1, m2): if m1 is nomask: return m2 is nomask if m2 is nomask: return m1 is nomask return (m1 == m2).all() - + def timingTest(): for f in [testf, testinplace]: for n in [1000,10000,50000]: @@ -712,8 +712,8 @@ def timingTest(): t2 = testtc(n, f) print f.test_name print """\ -n = %7d -numpy time (ms) %6.1f +n = %7d +numpy time (ms) %6.1f MA maskless ratio %6.1f MA masked ratio %6.1f """ % (n, t*1000.0, t1/t, t2/t) @@ -755,5 +755,5 @@ def testinplace(x): testinplace.test_name = 'Inplace operations' if __name__ == "__main__": - ScipyTest('numpy.core.ma').run() + ScipyTest('numpy.core.ma').run() #timingTest() diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 25f2d9964150..36ba229bd86c 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -24,7 +24,7 @@ def check_otherflags(self): assert_equal(self.a.flags.writeable, True) assert_equal(self.a.flags.aligned, True) assert_equal(self.a.flags.updateifcopy, False) - + class test_attributes(ScipyTestCase): def setUp(self): @@ -47,7 +47,7 @@ def check_attributes(self): assert_equal(self.one.ndim, 1) assert_equal(self.two.ndim, 2) assert_equal(self.three.ndim, 3) - num = self.two.itemsize + num = self.two.itemsize assert_equal(self.two.size, 20) assert_equal(self.two.nbytes, 20*num) assert_equal(self.two.itemsize, self.two.dtype.itemsize) @@ -74,7 +74,7 @@ def make_array(size, offset, strides): self.failUnlessRaises(ValueError, make_array, 8, 3, 1) #self.failUnlessRaises(ValueError, make_array, 8, 3, 0) #self.failUnlessRaises(ValueError, lambda: ndarray([1], strides=4)) - + def check_set_stridesattr(self): x = self.one @@ -90,7 +90,7 @@ def make_array(size, offset, strides): self.failUnlessRaises(ValueError, make_array, 4, 2, -1) self.failUnlessRaises(ValueError, make_array, 8, 3, 1) #self.failUnlessRaises(ValueError, make_array, 8, 3, 0) - + def check_fill(self): for t in "?bhilqpBHILQPfdgFDGO": x = empty((3,2,1), t) @@ -119,18 +119,18 @@ def check_ascii(self): a = fromstring('1 , 2 , 3 , 4',sep=',') b = fromstring('1,2,3,4',dtype=float,sep=',') assert_array_equal(a,b) - + class test_zero_rank(ScipyTestCase): def setUp(self): self.d = array(0), array('x', object) - + def check_ellipsis_subscript(self): a,b = self.d self.failUnlessEqual(a[...], 0) self.failUnlessEqual(b[...], 'x') self.failUnless(a[...] is a) self.failUnless(b[...] is b) - + def check_empty_subscript(self): a,b = self.d self.failUnlessEqual(a[()], 0) @@ -151,7 +151,7 @@ def check_ellipsis_subscript_assignment(self): self.failUnlessEqual(a, 42) b[...] = '' self.failUnlessEqual(b.item(), '') - + def check_empty_subscript_assignment(self): a,b = self.d a[()] = 42 @@ -191,7 +191,7 @@ def check_constructor(self): y = ndarray((),buffer=x) y[()] = 6 self.failUnlessEqual(x[()], 6) - + class test_creation(ScipyTestCase): def check_from_attribute(self): class x(object): @@ -229,12 +229,12 @@ class test_pickling(ScipyTestCase): def setUp(self): self.carray = array([[2,9],[7,0],[3,8]]) self.tarray = transpose(self.carray) - + def check_both(self): import pickle assert_equal(self.carray, pickle.loads(self.carray.dumps())) assert_equal(self.tarray, pickle.loads(self.tarray.dumps())) - + # Import tests from unicode set_local_path() from test_unicode import * diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index dbd905546bbc..f864837e2353 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -25,7 +25,7 @@ def check_matvec(self): assert_almost_equal(c1, c2, decimal=self.N) def check_matvec2(self): - A, b2 = self.A, self.b2 + A, b2 = self.A, self.b2 c1 = dot(A, b2) c2 = dot_(A, b2) assert_almost_equal(c1, c2, decimal=self.N) @@ -46,7 +46,7 @@ def check_vecmat3(self): A, b4 = self.A, self.b4 c1 = dot(A.transpose(),b4) c2 = dot_(A.transpose(),b4) - assert_almost_equal(c1, c2, decimal=self.N) + assert_almost_equal(c1, c2, decimal=self.N) def check_vecvecouter(self): b1, b3 = self.b1, self.b3 @@ -96,7 +96,7 @@ def test_bitwise_or(self): self.failUnless((t | f) is t) self.failUnless((f | f) is f) - def test_bitwise_and(self): + def test_bitwise_and(self): f = False_ t = True_ self.failUnless((t & t) is t) @@ -104,13 +104,10 @@ def test_bitwise_and(self): self.failUnless((t & f) is f) self.failUnless((f & f) is f) - def test_bitwise_xor(self): + def test_bitwise_xor(self): f = False_ t = True_ self.failUnless((t ^ t) is f) self.failUnless((f ^ t) is t) self.failUnless((t ^ f) is t) self.failUnless((f ^ f) is f) - - - diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index 3dd2d3cf8d32..9ad1197857ad 100644 --- a/numpy/core/tests/test_numerictypes.py +++ b/numpy/core/tests/test_numerictypes.py @@ -106,9 +106,9 @@ def check_zeros0D(self): """Check creation of 0-dimensional objects""" h = zeros((), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) - self.assert_(h.dtype.fields['x'][0].name[:4] == 'void') - self.assert_(h.dtype.fields['x'][0].char == 'V') - self.assert_(h.dtype.fields['x'][0].type == numpy.void) + self.assert_(h.dtype.fields['x'][0].name[:4] == 'void') + self.assert_(h.dtype.fields['x'][0].char == 'V') + self.assert_(h.dtype.fields['x'][0].type == numpy.void) # A small check that data is ok assert_equal(h['z'], zeros((), dtype='u1')) @@ -116,9 +116,9 @@ def check_zerosSD(self): """Check creation of single-dimensional objects""" h = zeros((2,), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) - self.assert_(h.dtype['y'].name[:4] == 'void') - self.assert_(h.dtype['y'].char == 'V') - self.assert_(h.dtype['y'].type == numpy.void) + self.assert_(h.dtype['y'].name[:4] == 'void') + self.assert_(h.dtype['y'].char == 'V') + self.assert_(h.dtype['y'].type == numpy.void) # A small check that data is ok assert_equal(h['z'], zeros((2,), dtype='u1')) @@ -126,9 +126,9 @@ def check_zerosMD(self): """Check creation of multi-dimensional objects""" h = zeros((2,3), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) - self.assert_(h.dtype['z'].name == 'uint8') - self.assert_(h.dtype['z'].char == 'B') - self.assert_(h.dtype['z'].type == numpy.uint8) + self.assert_(h.dtype['z'].name == 'uint8') + self.assert_(h.dtype['z'].char == 'B') + self.assert_(h.dtype['z'].type == numpy.uint8) # A small check that data is ok assert_equal(h['z'], zeros((2,3), dtype='u1')) @@ -238,7 +238,7 @@ class test_read_values_plain_multiple(read_values_plain): class read_values_nested(ScipyTestCase): """Check the reading of values in heterogeneous arrays (nested)""" - + def check_access_top_fields(self): """Check reading the top fields of a nested array""" h = array(self._buffer, dtype=self._descr) diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index 4cdbcb59c460..386734cabb09 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -18,7 +18,7 @@ def check_method_array(self): def check_method_array2(self): r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1') assert_equal(r[1].item(),(2, 22.0, 'b')) - + def check_recarray_slices(self): r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1') assert_equal(r[1::2][1].item(),(4, 44.0, 'd')) @@ -38,6 +38,6 @@ def check_recarray_fromfile(self): fd = open(filename) fd.seek(2880*2) r = rec.fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big') - + if __name__ == "__main__": ScipyTest().run() diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index b052145a9a5a..d78d1cbfe4de 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -60,7 +60,7 @@ def __array_wrap__(self, arr, context): r = with_wrap() r.arr = arr r.context = context - return r + return r a = with_wrap() x = minimum(a, a) assert_equal(x.arr, zeros(1)) @@ -78,7 +78,7 @@ def __array__(self): def __array_wrap__(self, arr): r = with_wrap() r.arr = arr - return r + return r a = with_wrap() x = minimum(a, a) assert_equal(x.arr, zeros(1)) @@ -158,6 +158,6 @@ def test_mixed(self): c = array([True,True]) a = array([True,True]) assert_equal(choose(c, (a, 1)), array([1,1])) - + if __name__ == "__main__": ScipyTest().run() diff --git a/numpy/core/tests/test_unicode.py b/numpy/core/tests/test_unicode.py index a8b4a97945e5..8da329860f97 100644 --- a/numpy/core/tests/test_unicode.py +++ b/numpy/core/tests/test_unicode.py @@ -185,7 +185,7 @@ def check_valuesSD(self): """Check assignment of single-dimensional objects with values""" ua = zeros((2,), dtype='U%s' % self.ulen) ua[0] = self.ucs_value*self.ulen - self.content_test(ua, ua[0], 4*self.ulen*2) + self.content_test(ua, ua[0], 4*self.ulen*2) ua[1] = self.ucs_value*self.ulen self.content_test(ua, ua[1], 4*self.ulen*2) diff --git a/numpy/dft/__init__.py b/numpy/dft/__init__.py index 817c99bc8ec9..0c5a7f2ed8ae 100644 --- a/numpy/dft/__init__.py +++ b/numpy/dft/__init__.py @@ -5,6 +5,5 @@ from helper import * def test(level=1, verbosity=1): - from numpy.testing import NumpyTest + from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity) - diff --git a/numpy/dft/fftpack.py b/numpy/dft/fftpack.py index 05efc759c6b5..eebbc73a5ed8 100644 --- a/numpy/dft/fftpack.py +++ b/numpy/dft/fftpack.py @@ -1,12 +1,12 @@ """ -Discrete Fourier Transforms - FFT.py +Discrete Fourier Transforms - FFT.py The underlying code for these functions is an f2c translated and modified version of the FFTPACK routines. -fft(a, n=None, axis=-1) -inverse_fft(a, n=None, axis=-1) -real_fft(a, n=None, axis=-1) +fft(a, n=None, axis=-1) +inverse_fft(a, n=None, axis=-1) +real_fft(a, n=None, axis=-1) inverse_real_fft(a, n=None, axis=-1) hermite_fft(a, n=None, axis=-1) inverse_hermite_fft(a, n=None, axis=-1) @@ -14,9 +14,9 @@ inverse_fftnd(a, s=None, axes=None) real_fftnd(a, s=None, axes=None) inverse_real_fftnd(a, s=None, axes=None) -fft2d(a, s=None, axes=(-2,-1)) +fft2d(a, s=None, axes=(-2,-1)) inverse_fft2d(a, s=None, axes=(-2, -1)) -real_fft2d(a, s=None, axes=(-2,-1)) +real_fft2d(a, s=None, axes=(-2,-1)) inverse_real_fft2d(a, s=None, axes=(-2, -1)) """ __all__ = ['fft','inverse_fft', 'ifft', 'real_fft', 'refft', @@ -33,7 +33,7 @@ _fft_cache = {} _real_fft_cache = {} -def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, +def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, work_function=fftpack.cfftf, fft_cache = _fft_cache ): a = asarray(a) @@ -68,7 +68,7 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, def fft(a, n=None, axis=-1): - """fft(a, n=None, axis=-1) + """fft(a, n=None, axis=-1) Will return the n point discrete Fourier transform of a. n defaults to the length of a. If n is larger than a, then a will be zero-padded to make up @@ -90,7 +90,7 @@ def fft(a, n=None, axis=-1): def inverse_fft(a, n=None, axis=-1): - """inverse_fft(a, n=None, axis=-1) + """inverse_fft(a, n=None, axis=-1) Will return the n point inverse discrete Fourier transform of a. n defaults to the length of a. If n is larger than a, then a will be @@ -115,7 +115,7 @@ def inverse_fft(a, n=None, axis=-1): def real_fft(a, n=None, axis=-1): - """real_fft(a, n=None, axis=-1) + """real_fft(a, n=None, axis=-1) Will return the n point discrete Fourier transform of the real valued array a. n defaults to the length of a. n is the length of the input, not @@ -137,7 +137,7 @@ def real_fft(a, n=None, axis=-1): def inverse_real_fft(a, n=None, axis=-1): """inverse_real_fft(a, n=None, axis=-1) - + Will return the real valued n point inverse discrete Fourier transform of a, where a contains the nonnegative frequency terms of a Hermite-symmetric sequence. n is the length of the result, not the input. If n is not @@ -189,7 +189,7 @@ def inverse_hermite_fft(a, n=None, axis=-1): inverse_hermite_fft(hermite_fft(a), len(a)) == a within numerical accuracy.""" - + a = asarray(a).astype(Float) if n == None: n = shape(a)[axis] @@ -244,15 +244,15 @@ def fftnd(a, s=None, axes=None): def inverse_fftnd(a, s=None, axes=None): """inverse_fftnd(a, s=None, axes=None) - + The inverse of fftnd.""" - + return _raw_fftnd(a, s, axes, inverse_fft) def fft2d(a, s=None, axes=(-2,-1)): - """fft2d(a, s=None, axes=(-2,-1)) - + """fft2d(a, s=None, axes=(-2,-1)) + The 2d fft of a. This is really just fftnd with different default behavior.""" @@ -275,7 +275,7 @@ def real_fftnd(a, s=None, axes=None): transform as real_fft is performed along the axis specified by the last element of axes, then complex transforms as fft are performed along the other axes.""" - + a = asarray(a).astype(Float) s, axes = _cook_nd_args(a, s, axes) a = real_fft(a, s[-1], axes[-1]) @@ -284,11 +284,11 @@ def real_fftnd(a, s=None, axes=None): return a def real_fft2d(a, s=None, axes=(-2,-1)): - """real_fft2d(a, s=None, axes=(-2,-1)) + """real_fft2d(a, s=None, axes=(-2,-1)) The 2d fft of the real valued array a. This is really just real_fftnd with different default behavior.""" - + return real_fftnd(a, s, axes) @@ -300,7 +300,7 @@ def inverse_real_fftnd(a, s=None, axes=None): inverse_real_fft is performed along the last axis. As with inverse_real_fft, the length of the result along that axis must be specified if it is to be odd.""" - + a = asarray(a).astype(Complex) s, axes = _cook_nd_args(a, s, axes, invreal=1) for ii in range(len(axes)-1): @@ -314,7 +314,7 @@ def inverse_real_fft2d(a, s=None, axes=(-2,-1)): The inverse of real_fft2d. This is really just inverse_real_fftnd with different default behavior.""" - + return inverse_real_fftnd(a, s, axes) ifft = inverse_fft diff --git a/numpy/dft/helper.py b/numpy/dft/helper.py index b402eb9ae5f4..4e1da2abdda9 100644 --- a/numpy/dft/helper.py +++ b/numpy/dft/helper.py @@ -64,4 +64,3 @@ def fftfreq(n,d=1.0): assert isinstance(n,types.IntType) or isinstance(n, integer) k = range(0,(n-1)/2+1)+range(-(n/2),0) return array(k,'d')/(n*d) - diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 3e5d25dceeef..6fb169f76d25 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -240,15 +240,15 @@ def CCompiler_get_version(self, force=0, ok_status=[0]): + (('linux.*','intel'),('linux.*','intele')) if sys.platform == 'win32': - compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler', - "Mingw32 port of GNU C Compiler for Win32"\ - "(for MSC built Python)") - if mingw32(): - # On windows platforms, we want to default to mingw32 (gcc) - # because msvc can't build blitz stuff. - log.info('Setting mingw32 as default compiler for nt.') - ccompiler._default_compilers = (('nt', 'mingw32'),) \ - + ccompiler._default_compilers + compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler', + "Mingw32 port of GNU C Compiler for Win32"\ + "(for MSC built Python)") + if mingw32(): + # On windows platforms, we want to default to mingw32 (gcc) + # because msvc can't build blitz stuff. + log.info('Setting mingw32 as default compiler for nt.') + ccompiler._default_compilers = (('nt', 'mingw32'),) \ + + ccompiler._default_compilers _distutils_new_compiler = new_compiler diff --git a/numpy/distutils/command/__init__.py b/numpy/distutils/command/__init__.py index 5ec3e370af36..dfe81d54205b 100644 --- a/numpy/distutils/command/__init__.py +++ b/numpy/distutils/command/__init__.py @@ -9,7 +9,7 @@ 'clean', 'install_lib', 'install_scripts', - 'bdist', + 'bdist', 'bdist_dumb', 'bdist_wininst', ] diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index ddd23becab8c..88107087a5dc 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -358,7 +358,7 @@ def pyrex_sources(self, sources, extension): output_file=target_file) pyrex_result = Main.compile(source, options=options) if pyrex_result.num_errors != 0: - raise RuntimeError("%d errors in Pyrex compile" % + raise RuntimeError("%d errors in Pyrex compile" % pyrex_result.num_errors) else: log.warn("Pyrex needed to compile %s but not available."\ diff --git a/numpy/distutils/command/config_compiler.py b/numpy/distutils/command/config_compiler.py index c6073e77b3e3..1c7aad7b7597 100644 --- a/numpy/distutils/command/config_compiler.py +++ b/numpy/distutils/command/config_compiler.py @@ -52,5 +52,3 @@ def finalize_options(self): def run(self): # Do nothing. return - - diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py index d3e2de3570d5..33a6c2a10970 100644 --- a/numpy/distutils/conv_template.py +++ b/numpy/distutils/conv_template.py @@ -14,7 +14,7 @@ # Each replace will use one entry from the list of named replacements # Note that all #..# forms in a block must have the same number of -# comma-separated entries. +# comma-separated entries. __all__ = ['process_str', 'process_file'] @@ -144,7 +144,7 @@ def process_str(allstr): struct = parse_structure(newstr) # return a (sorted) list of tuples for each begin repeat section # each tuple is the start and end of a region to be template repeated - + oldend = 0 for sub in struct: writestr += newstr[oldend:sub[0]] diff --git a/numpy/distutils/cpuinfo.py b/numpy/distutils/cpuinfo.py index 92dd5486caa7..fdc87b6db467 100644 --- a/numpy/distutils/cpuinfo.py +++ b/numpy/distutils/cpuinfo.py @@ -3,8 +3,8 @@ cpuinfo Copyright 2002 Pearu Peterson all rights reserved, -Pearu Peterson -Permission to use, modify, and distribute this software is given under the +Pearu Peterson +Permission to use, modify, and distribute this software is given under the terms of the SciPy (BSD style) license. See LICENSE.txt that came with this distribution for specifics. @@ -42,7 +42,7 @@ def __getattr__(self,name): return lambda func=self._try_call,attr=attr : func(attr) else: return lambda : None - raise AttributeError,name + raise AttributeError,name def _getNCPUs(self): return 1 @@ -53,7 +53,7 @@ def _is_32bit(self): class linux_cpuinfo(cpuinfo_base): info = None - + def __init__(self): if self.info is not None: return @@ -242,7 +242,7 @@ def _is_32bit(self): class irix_cpuinfo(cpuinfo_base): info = None - + def __init__(self): if self.info is not None: return @@ -315,7 +315,7 @@ def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000() class darwin_cpuinfo(cpuinfo_base): info = None - + def __init__(self): if self.info is not None: return @@ -381,7 +381,7 @@ def _is_ppc860(self): return self.__machine(860) class sunos_cpuinfo(cpuinfo_base): info = None - + def __init__(self): if self.info is not None: return diff --git a/numpy/distutils/fcompiler/absoft.py b/numpy/distutils/fcompiler/absoft.py index ed67ff3dc310..8f4a913b4670 100644 --- a/numpy/distutils/fcompiler/absoft.py +++ b/numpy/distutils/fcompiler/absoft.py @@ -114,7 +114,7 @@ def get_flags_f90(self): "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) if self.get_version(): if self.get_version()>'4.6': - opt.extend(["-YDEALLOC=ALL"]) + opt.extend(["-YDEALLOC=ALL"]) return opt def get_flags_fix(self): diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 10bafdf8edc9..7a08fba4ae06 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -60,7 +60,7 @@ def get_flags_linker_so(self): major, minor = target.split('.') if int(minor) < 3: minor = '3' - warnings.warn('Environment variable ' + warnings.warn('Environment variable ' 'MACOSX_DEPLOYMENT_TARGET reset to 10.3') os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major, minor) @@ -103,7 +103,7 @@ def get_libraries(self): g2c = self.g2c else: g2c = self.g2c - + if sys.platform=='win32': # To avoid undefined reference __EH_FRAME_BEGIN__ linker error, # don't use -lgcc option for mingw32 g77 linker. @@ -142,7 +142,7 @@ def get_flags_arch(self): if getattr(cpu,'is_ppc%s'%a)(): opt.append('-mcpu='+a) opt.append('-mtune='+a) - break + break return opt # default march options in case we find nothing better @@ -196,7 +196,7 @@ def get_flags_arch(self): if cpu.is_PentiumM(): march_opt = '-march=pentium-m' - # Note: gcc 3.2 on win32 has breakage with -march specified + # Note: gcc 3.2 on win32 has breakage with -march specified if '3.1.1' <= gnu_ver <= '3.4' and sys.platform=='win32': march_opt = '' @@ -216,7 +216,7 @@ def get_flags_arch(self): if cpu.is_Intel(): opt.append('-fomit-frame-pointer') if cpu.is_32bit(): - opt.append('-malign-double') + opt.append('-malign-double') return opt class Gnu95FCompiler(GnuFCompiler): diff --git a/numpy/distutils/from_template.py b/numpy/distutils/from_template.py index 96866bb9bf4c..93bbbc82d998 100644 --- a/numpy/distutils/from_template.py +++ b/numpy/distutils/from_template.py @@ -13,7 +13,7 @@ The number of comma-separeted words in '<..>' will determine the number of replicates. - + '<..>' may have two different forms, named and short. For example, named: @@ -24,7 +24,7 @@ <_t> is already defined: <_t=real,double precision,complex,double complex> short: - , a short form of the named, useful when no

appears inside + , a short form of the named, useful when no

appears inside a block. In general, '<..>' contains a comma separated list of arbitrary @@ -35,7 +35,7 @@ by -th expression. Note that all '<..>' forms in a block must have the same number of - comma-separated entries. + comma-separated entries. Predefined named template rules: @@ -189,7 +189,7 @@ def namerepl(mobj): newstr = newstr.replace('@rightarrow@','>') newstr = newstr.replace('@leftarrow@','<') return newstr - + def process_str(allstr): newstr = allstr writestr = '' #_head # using _head will break free-format files diff --git a/numpy/distutils/lib2def.py b/numpy/distutils/lib2def.py index 36c41f0b50a2..c42530931fb1 100644 --- a/numpy/distutils/lib2def.py +++ b/numpy/distutils/lib2def.py @@ -27,9 +27,9 @@ DEFAULT_NM = 'nm -Cs' -DEF_HEADER = """LIBRARY python%s.dll -;CODE PRELOAD MOVEABLE DISCARDABLE -;DATA PRELOAD SINGLE +DEF_HEADER = """LIBRARY python%s.dll +;CODE PRELOAD MOVEABLE DISCARDABLE +;DATA PRELOAD SINGLE EXPORTS """ % py_ver @@ -88,7 +88,7 @@ def parse_nm(nm_output): for sym in data: if sym not in flist and (sym[:2] == 'Py' or sym[:3] == '_Py'): dlist.append(sym) - + dlist.sort() flist.sort() return dlist, flist diff --git a/numpy/distutils/line_endings.py b/numpy/distutils/line_endings.py index 4f30af06a234..65fe2d129a05 100644 --- a/numpy/distutils/line_endings.py +++ b/numpy/distutils/line_endings.py @@ -4,16 +4,16 @@ import sys, re, os def dos2unix(file): - "Replace CRLF with LF in argument files. Print names of changed files." + "Replace CRLF with LF in argument files. Print names of changed files." if os.path.isdir(file): print file, "Directory!" return - + data = open(file, "rb").read() if '\0' in data: print file, "Binary!" return - + newdata = re.sub("\r\n", "\n", data) if newdata != data: print 'dos2unix:', file @@ -22,7 +22,7 @@ def dos2unix(file): f.close() return file else: - print file, 'ok' + print file, 'ok' def dos2unix_one_dir(modified_files,dir_name,file_names): for file in file_names: @@ -38,11 +38,11 @@ def dos2unix_dir(dir_name): #---------------------------------- def unix2dos(file): - "Replace LF with CRLF in argument files. Print names of changed files." + "Replace LF with CRLF in argument files. Print names of changed files." if os.path.isdir(file): print file, "Directory!" return - + data = open(file, "rb").read() if '\0' in data: print file, "Binary!" @@ -56,7 +56,7 @@ def unix2dos(file): f.close() return file else: - print file, 'ok' + print file, 'ok' def unix2dos_one_dir(modified_files,dir_name,file_names): for file in file_names: @@ -69,7 +69,7 @@ def unix2dos_dir(dir_name): modified_files = [] os.path.walk(dir_name,unix2dos_one_dir,modified_files) return modified_files - + if __name__ == "__main__": import sys dos2unix_dir(sys.argv[1]) diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index d725872f0587..c54c1abeaef5 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -3,7 +3,7 @@ # NT stuff # 1. Make sure libpython.a exists for gcc. If not, build it. - # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) + # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) # 3. Force windows to use g77 """ @@ -17,7 +17,7 @@ # NT stuff # 1. Make sure libpython.a exists for gcc. If not, build it. -# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) +# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) # --> this is done in numpy/distutils/ccompiler.py # 3. Force windows to use g77 @@ -26,24 +26,24 @@ from numpy.distutils.ccompiler import gen_preprocess_options, gen_lib_options from distutils.errors import DistutilsExecError, CompileError, UnknownFileError -from distutils.unixccompiler import UnixCCompiler - +from distutils.unixccompiler import UnixCCompiler + # the same as cygwin plus some additional parameters class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): """ A modified MingW32 compiler compatible with an MSVC built Python. - + """ - + compiler_type = 'mingw32' - + def __init__ (self, verbose=0, dry_run=0, force=0): - - distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, + + distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose,dry_run, force) - + # we need to support 3.2 which doesn't match the standard # get_versions methods regex if self.gcc_version is None: @@ -53,7 +53,7 @@ def __init__ (self, out.close() result = re.search('(\d+\.\d+)',out_string) if result: - self.gcc_version = StrictVersion(result.group(1)) + self.gcc_version = StrictVersion(result.group(1)) # A real mingw32 doesn't need to specify a different entry point, # but cygwin 2.91.57 in no-cygwin-mode needs it. @@ -65,7 +65,7 @@ def __init__ (self, if self.linker_dll == 'dllwrap': self.linker = 'dllwrap --driver-name g++' elif self.linker_dll == 'gcc': - self.linker = 'g++' + self.linker = 'g++' # **changes: eric jones 4/11/01 # 1. Check for import library on Windows. Build if it doesn't exist. @@ -78,15 +78,15 @@ def __init__ (self, #self.set_executables(compiler='gcc -mno-cygwin -O2 -w', # compiler_so='gcc -mno-cygwin -mdll -O2 -w', # linker_exe='gcc -mno-cygwin', - # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' + # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' # % (self.linker, entry_point)) if self.gcc_version <= "3.0.0": self.set_executables(compiler='gcc -mno-cygwin -O2 -w', compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes', linker_exe='g++ -mno-cygwin', - linker_so='%s -mno-cygwin -mdll -static %s' + linker_so='%s -mno-cygwin -mdll -static %s' % (self.linker, entry_point)) - else: + else: self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall', compiler_so='gcc -O2 -Wall -Wstrict-prototypes', linker_exe='g++ ', @@ -94,11 +94,11 @@ def __init__ (self, # added for python2.3 support # we can't pass it through set_executables because pre 2.2 would fail self.compiler_cxx = ['g++'] - + # Maybe we should also append -mthreads, but then the finished # dlls need another dll (mingwm10.dll see Mingw32 docs) - # (-mthreads: Support thread-safe exception handling on `Mingw32') - + # (-mthreads: Support thread-safe exception handling on `Mingw32') + # no additional libraries needed -- maybe need msvcr71 #self.dll_libraries=[] return @@ -154,14 +154,14 @@ def object_filenames (self, for src_name in source_filenames: # use normcase to make sure '.rc' is really '.rc' and not '.RC' (base, ext) = os.path.splitext (os.path.normcase(src_name)) - + # added these lines to strip off windows drive letters # without it, .o files are placed next to .c files # instead of the build directory drv,base = os.path.splitdrive(base) if drv: base = base[1:] - + if ext not in (self.src_extensions + ['.rc','.res']): raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % \ @@ -176,16 +176,16 @@ def object_filenames (self, obj_names.append (os.path.join (output_dir, base + self.obj_extension)) return obj_names - + # object_filenames () - + def build_import_library(): """ Build the import libraries for Mingw32-gcc on Windows """ if os.name != 'nt': return - lib_name = "python%d%d.lib" % tuple(sys.version_info[:2]) + lib_name = "python%d%d.lib" % tuple(sys.version_info[:2]) lib_file = os.path.join(sys.prefix,'libs',lib_name) out_name = "libpython%d%d.a" % tuple(sys.version_info[:2]) out_file = os.path.join(sys.prefix,'libs',out_name) @@ -199,13 +199,13 @@ def build_import_library(): from numpy.distutils import lib2def - def_name = "python%d%d.def" % tuple(sys.version_info[:2]) + def_name = "python%d%d.def" % tuple(sys.version_info[:2]) def_file = os.path.join(sys.prefix,'libs',def_name) nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file) nm_output = lib2def.getnm(nm_cmd) dlist, flist = lib2def.parse_nm(nm_output) lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w')) - + dll_name = "python%d%d.dll" % tuple(sys.version_info[:2]) args = (dll_name,def_file,out_file) cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index c32b2f23c6ee..329ffde7986a 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -38,7 +38,7 @@ def get_path(mod_name, parent_path=None): d = os.path.dirname(os.path.abspath(mod.__file__)) else: # we're probably running setup.py as execfile("setup.py") - # (likely we're building an egg) + # (likely we're building an egg) d = os.path.abspath('.') # hmm, should we use sys.argv[0] like in __builtin__ case? @@ -85,7 +85,7 @@ def get_mathlibs(path=None): mathlibs.extend(value.split(',')) fid.close() return mathlibs - + def minrelpath(path): """ Resolve `..` from path. """ @@ -866,7 +866,7 @@ def add_library(self,name,sources,**build_info): build_info['sources'] = sources self._fix_paths_dict(build_info) - + self.libraries.append((name,build_info)) dist = self.get_distribution() diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 20dc7292a512..644da207c84a 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -56,7 +56,7 @@ The file 'site.cfg' is looked for in -1) Directory of main setup.py file being run. +1) Directory of main setup.py file being run. 2) Home directory of user running the setup.py file (Not implemented yet) 3) System wide directory (location of this file...) @@ -167,7 +167,7 @@ def get_standard_file(fname): fname) if os.path.isfile(sysfile): filenames.append(sysfile) - + # Home directory # And look for the user config file try: @@ -178,7 +178,7 @@ def get_standard_file(fname): user_file = os.path.join(f, fname) if os.path.isfile(user_file): filenames.append(user_file) - + # Local file if os.path.isfile(fname): filenames.append(os.path.abspath(fname)) @@ -530,7 +530,7 @@ def _check_libs(self,lib_dir,libs, opt_libs, exts): else: warnings.warn("Library error: libs=%s found_libs=%s" % \ (libs, found_libs)) - + def combine_paths(self,*args): return combine_paths(*args,**{'verbosity':self.verbosity}) diff --git a/numpy/distutils/tests/gen_ext/setup.py b/numpy/distutils/tests/gen_ext/setup.py index bbeb9b4b7392..d5f2fa971f02 100644 --- a/numpy/distutils/tests/gen_ext/setup.py +++ b/numpy/distutils/tests/gen_ext/setup.py @@ -16,7 +16,7 @@ A(I) = 0.0D0 ELSEIF (I.EQ.2) THEN A(I) = 1.0D0 - ELSE + ELSE A(I) = A(I-1) + A(I-2) ENDIF ENDDO @@ -45,6 +45,3 @@ def configuration(parent_package='',top_path=None): if __name__ == "__main__": from numpy.distutils.core import setup setup(**configuration(top_path='').todict()) - - - diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py index 214763cef719..c205a3da649e 100644 --- a/numpy/distutils/unixccompiler.py +++ b/numpy/distutils/unixccompiler.py @@ -31,7 +31,7 @@ def UnixCCompile_create_static_lib(self, objects, output_libname, output_filename = \ self.library_filename(output_libname, output_dir=output_dir) - + if self._need_link(objects, output_filename): self.mkpath(os.path.dirname(output_filename)) tmp_objects = objects + self.objects diff --git a/numpy/dual.py b/numpy/dual.py index e6e8884b57c6..3697553b6e38 100644 --- a/numpy/dual.py +++ b/numpy/dual.py @@ -52,4 +52,3 @@ def restore_func(name): def restore_all(): for name in _restore_dict.keys(): restore_func(name) - diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index 4a237d54fa3f..b7e5aec68962 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -4,9 +4,9 @@ Auxiliary functions for f2py2e. Copyright 1999,2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the -terms of the NumPy (BSD style) LICENSE. +terms of the NumPy (BSD style) LICENSE. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. @@ -486,5 +486,3 @@ def applyrules(rules,dict,var={}): if len(ret[k])==1: ret[k]=ret[k][0] if ret[k]==[]: del ret[k] return ret - - diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index 19ebaa15c35d..2cd42b04ab40 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -2,7 +2,7 @@ """ Copyright 1999,2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -68,7 +68,7 @@ if using_newcore: c2capi_map={'double':'PyArray_DOUBLE', 'float':'PyArray_FLOAT', - 'long_double':'PyArray_LONGDOUBLE', + 'long_double':'PyArray_LONGDOUBLE', 'char':'PyArray_BYTE', 'unsigned_char':'PyArray_UBYTE', 'signed_char':'PyArray_BYTE', @@ -78,11 +78,11 @@ 'unsigned':'PyArray_UINT', 'long':'PyArray_LONG', 'unsigned_long':'PyArray_ULONG', - 'long_long':'PyArray_LONGLONG', + 'long_long':'PyArray_LONGLONG', 'unsigned_long_long':'Pyarray_ULONGLONG', 'complex_float':'PyArray_CFLOAT', 'complex_double':'PyArray_CDOUBLE', - 'complex_long_double':'PyArray_CDOUBLE', + 'complex_long_double':'PyArray_CDOUBLE', 'string':'PyArray_STRING'} c2pycode_map={'double':'d', 'float':'f', @@ -104,7 +104,7 @@ if using_newcore: c2pycode_map={'double':'d', 'float':'f', - 'long_double':'g', + 'long_double':'g', 'char':'b', 'unsigned_char':'B', 'signed_char':'b', @@ -114,11 +114,11 @@ 'unsigned':'I', 'long':'l', 'unsigned_long':'L', - 'long_long':'q', + 'long_long':'q', 'unsigned_long_long':'Q', 'complex_float':'F', 'complex_double':'D', - 'complex_long_double':'G', + 'complex_long_double':'G', 'string':'S'} c2buildvalue_map={'double':'d', 'float':'f', @@ -201,7 +201,7 @@ 'string':'%s', } -############### Auxiliary functions +############### Auxiliary functions def getctype(var): """ Determines C type @@ -255,7 +255,7 @@ def getstrlength(var): a=var['charselector'] if a.has_key('*'): len=a['*'] elif a.has_key('len'): len=a['len'] - if re.match(r'\(\s*([*]|[:])\s*\)',len) or re.match(r'([*]|[:])',len): + if re.match(r'\(\s*([*]|[:])\s*\)',len) or re.match(r'([*]|[:])',len): #if len in ['(*)','*','(:)',':']: if isintent_hide(var): errmess('getstrlength:intent(hide): expected a string with defined length but got: %s\n'%(`var`)) @@ -330,7 +330,7 @@ def getpydocsign(a,var): break init='' ctype=getctype(var) - + if hasinitvalue(var): init,showinit=getinit(a,var) init='= %s'%(showinit) @@ -564,7 +564,7 @@ def routsign2map(rout): rout['vars'][a]['note']=['See elsewhere.'] if c2buildvalue_map.has_key(ret['ctype']): ret['rformat']=c2buildvalue_map[ret['ctype']] - else: + else: ret['rformat']='O' errmess('routsign2map: no c2buildvalue key for type %s\n'%(`ret['ctype']`)) if debugcapi(rout): @@ -675,7 +675,7 @@ def cb_routsign2map(rout,um): if iscomplexfunction(rout): ret['rctype']=""" #ifdef F2PY_CB_RETURNCOMPLEX -#ctype# +#ctype# #else void #endif @@ -719,5 +719,3 @@ def common_sign2map(a,var): # obsolute var['note']=['See elsewhere.'] ret['arrdocstr']=getarrdocsign(a,var) # for strings this returns 0-rank but actually is 1-rank return ret - - diff --git a/numpy/f2py/cb_rules.py b/numpy/f2py/cb_rules.py index 314201d870ad..df74703ba145 100644 --- a/numpy/f2py/cb_rules.py +++ b/numpy/f2py/cb_rules.py @@ -4,7 +4,7 @@ Build call-back mechanism for f2py2e. Copyright 2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -364,7 +364,7 @@ \tif (#name#_nofargs>capi_i) { \t\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname#_Dims,#atype#,NULL,(char*)#varname#,0,FARRAY_FLAGS,NULL); /*XXX: Hmm, what will destroy this array??? */ """, - }, + }, """ \t\tif (tmp_arr==NULL) \t\t\tgoto capi_fail; @@ -527,8 +527,3 @@ def buildcallback(rout,um): #print ar['body'] return ################## Build call-back function ############# - - - - - diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index fa6e6e0349f1..38d2a0b94fb5 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -5,7 +5,7 @@ Only required declarations/macros/functions will be used. Copyright 1999,2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -282,73 +282,73 @@ #define TRYPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data); break; #define TRYPYARRAYTEMPLATE(ctype,typecode) \\ - PyArrayObject *arr = NULL;\\ - if (!obj) return -2;\\ - if (!PyArray_Check(obj)) return -1;\\ - if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\ - if (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\ - switch (arr->descr->type_num) {\\ - case PyArray_DOUBLE: *(double *)(arr->data)=*v; break;\\ - case PyArray_INT: *(int *)(arr->data)=*v; break;\\ - case PyArray_LONG: *(long *)(arr->data)=*v; break;\\ - case PyArray_FLOAT: *(float *)(arr->data)=*v; break;\\ - case PyArray_CDOUBLE: *(double *)(arr->data)=*v; break;\\ - case PyArray_CFLOAT: *(float *)(arr->data)=*v; break;\\ - case PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\ - case PyArray_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\ - case PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\ - case PyArray_SHORT: *(short *)(arr->data)=*v; break;\\ - case PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\ - case PyArray_UINT: *(uint *)(arr->data)=*v; break;\\ - case PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\ - case PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\ - case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\ - case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\ - case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\ - case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\ - default: return -2;\\ - };\\ - return 1 + PyArrayObject *arr = NULL;\\ + if (!obj) return -2;\\ + if (!PyArray_Check(obj)) return -1;\\ + if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\ + if (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\ + switch (arr->descr->type_num) {\\ + case PyArray_DOUBLE: *(double *)(arr->data)=*v; break;\\ + case PyArray_INT: *(int *)(arr->data)=*v; break;\\ + case PyArray_LONG: *(long *)(arr->data)=*v; break;\\ + case PyArray_FLOAT: *(float *)(arr->data)=*v; break;\\ + case PyArray_CDOUBLE: *(double *)(arr->data)=*v; break;\\ + case PyArray_CFLOAT: *(float *)(arr->data)=*v; break;\\ + case PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\ + case PyArray_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\ + case PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\ + case PyArray_SHORT: *(short *)(arr->data)=*v; break;\\ + case PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\ + case PyArray_UINT: *(uint *)(arr->data)=*v; break;\\ + case PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\ + case PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\ + case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\ + case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\ + case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\ + case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\ + default: return -2;\\ + };\\ + return 1 """ needs['TRYCOMPLEXPYARRAYTEMPLATE']=['PRINTPYOBJERR'] cppmacros['TRYCOMPLEXPYARRAYTEMPLATE']="""\ #define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break; #define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\\ - PyArrayObject *arr = NULL;\\ - if (!obj) return -2;\\ - if (!PyArray_Check(obj)) return -1;\\ + PyArrayObject *arr = NULL;\\ + if (!obj) return -2;\\ + if (!PyArray_Check(obj)) return -1;\\ if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYCOMPLEXPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\ - if (arr->descr->type==typecode) {\\ + if (arr->descr->type==typecode) {\\ *(ctype *)(arr->data)=(*v).r;\\ *(ctype *)(arr->data+sizeof(ctype))=(*v).i;\\ return 1;\\ }\\ - switch (arr->descr->type_num) {\\ - case PyArray_CDOUBLE: *(double *)(arr->data)=(*v).r;*(double *)(arr->data+sizeof(double))=(*v).i;break;\\ - case PyArray_CFLOAT: *(float *)(arr->data)=(*v).r;*(float *)(arr->data+sizeof(float))=(*v).i;break;\\ - case PyArray_DOUBLE: *(double *)(arr->data)=(*v).r; break;\\ - case PyArray_LONG: *(long *)(arr->data)=(*v).r; break;\\ - case PyArray_FLOAT: *(float *)(arr->data)=(*v).r; break;\\ - case PyArray_INT: *(int *)(arr->data)=(*v).r; break;\\ - case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\ - case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ - case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\ - case PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\ - case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ - case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\ - case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\ - case PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\ - case PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\ - case PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\ - case PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\ - case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\ - case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=(*v).r; break;\\ - case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=(*v).r;*(longdouble *)(arr->data+sizeof(longdouble))=(*v).i;break;\\ + switch (arr->descr->type_num) {\\ + case PyArray_CDOUBLE: *(double *)(arr->data)=(*v).r;*(double *)(arr->data+sizeof(double))=(*v).i;break;\\ + case PyArray_CFLOAT: *(float *)(arr->data)=(*v).r;*(float *)(arr->data+sizeof(float))=(*v).i;break;\\ + case PyArray_DOUBLE: *(double *)(arr->data)=(*v).r; break;\\ + case PyArray_LONG: *(long *)(arr->data)=(*v).r; break;\\ + case PyArray_FLOAT: *(float *)(arr->data)=(*v).r; break;\\ + case PyArray_INT: *(int *)(arr->data)=(*v).r; break;\\ + case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\ + case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ + case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\ + case PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\ + case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ + case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\ + case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\ + case PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\ + case PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\ + case PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\ + case PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\ + case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\ + case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=(*v).r; break;\\ + case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=(*v).r;*(longdouble *)(arr->data+sizeof(longdouble))=(*v).i;break;\\ case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\\ - default: return -2;\\ - };\\ - return -1; + default: return -2;\\ + };\\ + return -1; """ ## cppmacros['NUMFROMARROBJ']="""\ ## #define NUMFROMARROBJ(typenum,ctype) \\ @@ -537,7 +537,7 @@ for (k=0;k +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License @@ -129,4 +129,3 @@ def dadd(line,s=doc): s[0] = '%s\n%s'%(s[0],line) ret['latexdoc']=doc[0] if len(ret['docs'])<=1: ret['docs']='' return ret,fwrap[0] - diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index ec29ca1f1b89..17199faa7274 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -4,7 +4,7 @@ Usage is explained in the comment block below. Copyright 1999-2004 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -298,7 +298,7 @@ def readfortrancode(ffile,dowithline=show,istop=1): ext = os.path.splitext(currentfilename)[1] if is_f_file(currentfilename) and \ not (_has_f90_header(l) or _has_fix_header(l)): - strictf77=1 + strictf77=1 elif is_free_format(currentfilename) and not _has_fix_header(l): sourcecodeform='free' if strictf77: beginpattern=beginpattern77 @@ -696,7 +696,7 @@ def _resolvenameargspattern(line): m1=callnameargspattern.match(line) if m1: return m1.group('name'),m1.group('args'),None return None,[],None - + def analyzeline(m,case,line): global groupcounter,groupname,groupcache,grouplist,filepositiontext,\ currentfilename,f77modulename,neededinterface,neededmodule,expectbegin,\ @@ -740,7 +740,7 @@ def analyzeline(m,case,line): while '' in args: args.remove('') outmess('analyzeline: argument list is malformed (missing argument).\n') - + # end of crack line => block,name,args,result needmodule=0 needinterface=0 @@ -757,7 +757,7 @@ def analyzeline(m,case,line): if f77modulename and neededmodule==-1 and groupcounter<=1: neededmodule=groupcounter+2 needmodule=1 - needinterface=1 + needinterface=1 # Create new block(s) groupcounter=groupcounter+1 groupcache[groupcounter]={} @@ -852,7 +852,7 @@ def analyzeline(m,case,line): if name is not None: if args: args=rmbadname(map(string.strip,string.split(markoutercomma(args),'@,@'))) - else: args=[] + else: args=[] assert result is None,`result` groupcache[groupcounter]['entry'][name] = args previous_context = ('entry',name,groupcounter) @@ -1105,7 +1105,7 @@ def analyzeline(m,case,line): groupcache[groupcounter]['use'][name]['map']=rl else: pass - + else: print m.groupdict() outmess('analyzeline: Could not crack the use statement.\n') @@ -1188,7 +1188,7 @@ def markinnerspaces(line): if cb=='\\' and c in ['\\','\'','"']: l=l+c; cb=c - continue + continue if f==0 and c in ['\'','"']: cc=c; cc1={'\'':'"','"':'\''}[c] if c==cc:f=f+1 elif c==cc:f=f-1 @@ -1292,7 +1292,7 @@ def updatevars(typespec,selector,attrspec,entitydecl): errmess('updatevars:%s: attempt to change %r to %r. Ignoring.\n' \ % (ename,dm1,dm)) break - + if d1.has_key('len'): if typespec in ['complex','integer','logical','real']: if (not edecl.has_key('kindselector')) or (not edecl['kindselector']): @@ -1717,7 +1717,7 @@ def getlincoef(e,xset): # e = a*x+b ; x in xset if (a*0.5+b==c): return a,b,x except: pass - break + break return None,None,None _varname_match = re.compile(r'\A[a-z]\w*\Z').match @@ -1807,7 +1807,7 @@ def getarrlen(dl,args,star='*'): elif d1[0]==-1: c1='+%s'%c1 elif d1[0]<0: c1='+%s*%s'%(-d1[0],c1) else: c1 = '-%s*%s' % (d1[0],c1) - + c2 = str(d2[2]) if c2 not in args: if _varname_match(c2): @@ -2174,10 +2174,10 @@ def analyzevars(block): ('required' not in vars[d]['attrspec']): vars[d]['attrspec'].append('optional') elif d not in ['*',':']: - #/----< no check + #/----< no check #if ni>1: vars[n]['check'].append('shape(%s,%i)==%s'%(n,i,d)) #else: vars[n]['check'].append('len(%s)>=%s'%(n,d)) - if flag: + if flag: if vars.has_key(d): if n not in ddeps: vars[n]['depend'].append(d) @@ -2289,7 +2289,7 @@ def analyzeargs(block): else: na=na+'_e' a=na while block['vars'].has_key(a) or a in block['args']: a=a+'r' - block['vars'][a]=at + block['vars'][a]=at args.append(a) if not block['vars'].has_key(a): block['vars'][a]={} diff --git a/numpy/f2py/doc/collectinput.py b/numpy/f2py/doc/collectinput.py index 7b81b7517fba..2e3a09d9d0f8 100755 --- a/numpy/f2py/doc/collectinput.py +++ b/numpy/f2py/doc/collectinput.py @@ -5,7 +5,7 @@ in separate lines. Copyright 1999 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License @@ -72,6 +72,3 @@ else: print l+l1 sys.stdout.close() - - - diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index e4aeeffe2aba..85102e281292 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -5,7 +5,7 @@ See __usage__ below. Copyright 1999--2005 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -326,7 +326,7 @@ def run_main(comline_list): fobjhsrc = os.path.join(f2pydir,'src','fortranobject.h') fobjcsrc = os.path.join(f2pydir,'src','fortranobject.c') files,options=scaninputline(comline_list) - auxfuncs.options=options + auxfuncs.options=options postlist=callcrackfortran(files,options) isusedby={} for i in range(len(postlist)): @@ -419,7 +419,7 @@ def run_compile(): f2py_flags.extend(f2py_flags2) sys.argv = filter(lambda a,flags=f2py_flags2:a not in flags,sys.argv) - + flib_flags = filter(re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)').match,sys.argv[1:]) sys.argv = filter(lambda a,flags=flib_flags:a not in flags,sys.argv) fc_flags = filter(re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))').match,sys.argv[1:]) @@ -552,4 +552,3 @@ def main(): # EOF - diff --git a/numpy/f2py/f2py_testing.py b/numpy/f2py/f2py_testing.py index 1126c3085379..f94712105ccf 100644 --- a/numpy/f2py/f2py_testing.py +++ b/numpy/f2py/f2py_testing.py @@ -41,7 +41,7 @@ def jiffies(_load_time=time.time()): """ Return number of jiffies (1/100ths of a second) that this process has been scheduled in user mode. [Emulation with time.time]. """ return int(100*(time.time()-_load_time)) - + def memusage(): pass diff --git a/numpy/f2py/f90mod_rules.py b/numpy/f2py/f90mod_rules.py index f345e67edecd..aaedde1b2dda 100644 --- a/numpy/f2py/f90mod_rules.py +++ b/numpy/f2py/f90mod_rules.py @@ -4,7 +4,7 @@ Build F90 module support for f2py2e. Copyright 2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -52,8 +52,8 @@ def findf90modules(m): ns = .TRUE. end if end do - if (ns) then - deallocate(d) + if (ns) then + deallocate(d) end if end if if ((.not.allocated(d)).and.(s(1).ge.1)) then""" @@ -225,7 +225,7 @@ def iadd(line,s=ihooks): s[0] = '%s\n%s'%(s[0],line) fadd('end subroutine f2pyinit%s\n'%(m['name'])) dadd(string.replace(string.join(ret['latexdoc'],'\n'),r'\subsection{',r'\subsubsection{')) - + ret['latexdoc']=[] ret['docs'].append('"\t%s --- %s"'%(m['name'], string.join(undo_rmbadname(modobjs),','))) @@ -236,5 +236,3 @@ def iadd(line,s=ihooks): s[0] = '%s\n%s'%(s[0],line) ret['latexdoc']=doc[0] if len(ret['docs'])<=1: ret['docs']='' return ret,fhooks[0] - - diff --git a/numpy/f2py/func2subr.py b/numpy/f2py/func2subr.py index 1c543c74d988..4cec370326a9 100644 --- a/numpy/f2py/func2subr.py +++ b/numpy/f2py/func2subr.py @@ -4,7 +4,7 @@ Rules for building C/API module with f2py2e. Copyright 1999,2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -160,6 +160,6 @@ def assubr(rout): break if flag: fvar['intent'].append('out=%s' % (rname)) - + rout['args'] = [fname] + rout['args'] return rout,createfuncwrapper(rout) diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 50f646f6fcdc..b8581f7a783b 100644 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -29,7 +29,7 @@ } } - + } } @@ -42,7 +42,7 @@ """ """ Copyright 1999,2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -297,7 +297,7 @@ #latexdocstrsigns# """], 'restdoc':['Wrapped function ``#name#``\n'+'-'*80, - + ] } @@ -770,7 +770,7 @@ # varname = init # else # from_pyobj(varname) -# +# # isoptional and noinitvalue... # if pyobj is not None: # from_pyobj(varname) @@ -783,7 +783,7 @@ {hasinitvalue:'\tif (#varname#_capi == Py_None) #varname# = #init#; else', '_depend':''}, {l_and(isoptional,l_not(hasinitvalue)):'\tif (#varname#_capi != Py_None)', - '_depend':''}, + '_depend':''}, {l_not(islogical):'''\ \t\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can\'t be converted to #ctype#"); \tif (f2py_success) {'''}, @@ -933,7 +933,7 @@ 'frompyobj':'\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);', '_check':l_and(isarray,isintent_copy), '_depend':'', - },{ + },{ 'need':[{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}], '_check':isarray, '_depend':'' @@ -946,7 +946,7 @@ # 'pyobjfrom':{isintent_inout:"""\ # /* Partly because of the following hack, intent(inout) is depreciated, # Use intent(in,out) instead. - + # \tif ((#varname#_capi != Py_None) && PyArray_Check(#varname#_capi) \\ # \t\t&& (#varname#_capi != (PyObject *)capi_#varname#_tmp)) { # \t\tif (((PyArrayObject *)#varname#_capi)->nd != capi_#varname#_tmp->nd) { @@ -1080,7 +1080,7 @@ def buildmodule(m,um): """ - Return + Return """ global f2py_version,options outmess('\tBuilding module "%s"...\n'%(m['name'])) @@ -1098,7 +1098,7 @@ def buildmodule(m,um): continue for b in bi['body']: if b['name']==n: nb=b;break - + if not nb: errmess('buildmodule: Could not found the body of interfaced routine "%s". Skipping.\n'%(n)) continue @@ -1241,7 +1241,7 @@ def buildapi(rout): capi_maps.depargs=depargs var=rout['vars'] auxvars = [a for a in var.keys() if isintent_aux(var[a])] - + if ismoduleroutine(rout): outmess('\t\t\tConstructing wrapper function "%s.%s"...\n'%(rout['modulename'],rout['name'])) else: @@ -1270,7 +1270,7 @@ def buildapi(rout): else: nthk=nthk+1 vrd['nth']=`nthk`+stnd[nthk%10]+' keyword' - else: vrd['nth']='hidden' + else: vrd['nth']='hidden' savevrd[a]=vrd for r in _rules: if r.has_key('_depend'): continue diff --git a/numpy/f2py/setup.py b/numpy/f2py/setup.py index 191639d5c853..7906798bf09f 100755 --- a/numpy/f2py/setup.py +++ b/numpy/f2py/setup.py @@ -6,7 +6,7 @@ python setup.py install Copyright 2001-2005 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. diff --git a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py index dd9a6499984c..2a6ec85f7d7b 100644 --- a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py @@ -84,8 +84,8 @@ class Type(object): _cast_dict['CFLOAT'] = _cast_dict['FLOAT'] + ['CFLOAT'] _cast_dict['CDOUBLE'] = _cast_dict['DOUBLE'] + ['CFLOAT','CDOUBLE'] _cast_dict['CLONGDOUBLE'] = _cast_dict['LONGDOUBLE'] + ['CFLOAT','CDOUBLE','CLONGDOUBLE'] - - + + def __new__(cls,name): if isinstance(name,dtype): dtype0 = name @@ -101,7 +101,7 @@ def __new__(cls,name): obj._init(name) cls._type_cache[name.upper()] = obj return obj - + def _init(self,name): self.NAME = name.upper() self.type_num = getattr(wrap,'PyArray_'+self.NAME) @@ -174,7 +174,7 @@ def __init__(self,typ,dims,intent,obj): if intent.is_intent('cache'): assert isinstance(obj,ndarray),`type(obj)` self.pyarr = array(obj).reshape(*dims) - + else: self.pyarr = array(array(obj, dtype = typ.dtypechar).reshape(*dims), @@ -212,7 +212,7 @@ def __init__(self,typ,dims,intent,obj): assert self.arr_attr[5][3]==self.type.elsize,\ `self.arr_attr[5][3],self.type.elsize` assert self.arr_equal(self.pyarr,self.arr) - + if isinstance(self.obj,ndarray): if typ.elsize==Type(obj.dtype).elsize: if not intent.is_intent('copy') and self.arr_attr[1]<=1: @@ -357,14 +357,14 @@ def check_in_cache_from_2casttype(self): continue obj = array(self.num2seq,dtype=t.dtype) shape = (len(self.num2seq),) - a = self.array(shape,intent.in_.c.cache,obj) + a = self.array(shape,intent.in_.c.cache,obj) assert a.has_shared_memory(),`t.dtype` - a = self.array(shape,intent.in_.cache,obj) + a = self.array(shape,intent.in_.cache,obj) assert a.has_shared_memory(),`t.dtype` - + obj = array(self.num2seq,dtype=t.dtype,fortran=1) - a = self.array(shape,intent.in_.c.cache,obj) + a = self.array(shape,intent.in_.c.cache,obj) assert a.has_shared_memory(),`t.dtype` a = self.array(shape,intent.in_.cache,obj) diff --git a/numpy/f2py/tests/c/return_real.py b/numpy/f2py/tests/c/return_real.py index 7d35b28cf356..27e0843f14f0 100644 --- a/numpy/f2py/tests/c/return_real.py +++ b/numpy/f2py/tests/c/return_real.py @@ -88,7 +88,7 @@ def runtest(t): except IndexError: pass try: raise RuntimeError,`t(())` except IndexError: pass - + try: raise RuntimeError,`t(t)` except TypeError: pass try: raise RuntimeError,`t({})` diff --git a/numpy/f2py/tests/f77/return_complex.py b/numpy/f2py/tests/f77/return_complex.py index 39743a9f6062..9993bb6eb183 100644 --- a/numpy/f2py/tests/f77/return_complex.py +++ b/numpy/f2py/tests/f77/return_complex.py @@ -105,7 +105,7 @@ def runtest(t): except IndexError: pass try: raise RuntimeError,`t(())` except IndexError: pass - + try: raise RuntimeError,`t(t)` except TypeError: pass try: raise RuntimeError,`t({})` diff --git a/numpy/f2py/tests/f77/return_logical.py b/numpy/f2py/tests/f77/return_logical.py index e252e03a6c07..ac807b5be2d9 100644 --- a/numpy/f2py/tests/f77/return_logical.py +++ b/numpy/f2py/tests/f77/return_logical.py @@ -132,4 +132,3 @@ def runtest(t): test_functions = build(f2py_opts) f2py2e.f2py_testing.run(runtest,test_functions,repeat) print 'ok' - diff --git a/numpy/f2py/tests/f77/return_real.py b/numpy/f2py/tests/f77/return_real.py index 7bd34b51d912..29e720a859c4 100644 --- a/numpy/f2py/tests/f77/return_real.py +++ b/numpy/f2py/tests/f77/return_real.py @@ -107,7 +107,7 @@ def runtest(t): except IndexError: pass try: raise RuntimeError,`t(())` except IndexError: pass - + try: raise RuntimeError,`t(t)` except TypeError: pass try: raise RuntimeError,`t({})` diff --git a/numpy/f2py/tests/f90/return_character.py b/numpy/f2py/tests/f90/return_character.py index 0bd7be70113b..45174630afae 100644 --- a/numpy/f2py/tests/f90/return_character.py +++ b/numpy/f2py/tests/f90/return_character.py @@ -97,4 +97,3 @@ def runtest(t): test_functions = build(f2py_opts) f2py2e.f2py_testing.run(runtest,test_functions,repeat) print 'ok' - diff --git a/numpy/f2py/tests/f90/return_complex.py b/numpy/f2py/tests/f90/return_complex.py index 36d8707fc5e8..71179e1f2d95 100644 --- a/numpy/f2py/tests/f90/return_complex.py +++ b/numpy/f2py/tests/f90/return_complex.py @@ -107,7 +107,7 @@ def runtest(t): except IndexError: pass try: raise RuntimeError,`t(())` except IndexError: pass - + try: raise RuntimeError,`t(t)` except TypeError: pass try: raise RuntimeError,`t({})` diff --git a/numpy/f2py/tests/f90/return_integer.py b/numpy/f2py/tests/f90/return_integer.py index 635252ce9c74..3e96dfd5f484 100644 --- a/numpy/f2py/tests/f90/return_integer.py +++ b/numpy/f2py/tests/f90/return_integer.py @@ -107,7 +107,7 @@ def runtest(t): if sys.version[:3]<='2.2': assert t(array([123+3j],'F'))==123 assert t(array([123],'D'))==123 - + try: raise RuntimeError,`t(array([123],'c'))` except ValueError: pass try: raise RuntimeError,`t('abc')` diff --git a/numpy/f2py/tests/f90/return_real.py b/numpy/f2py/tests/f90/return_real.py index 263e28165420..42d40cb954db 100644 --- a/numpy/f2py/tests/f90/return_real.py +++ b/numpy/f2py/tests/f90/return_real.py @@ -109,7 +109,7 @@ def runtest(t): except IndexError: pass try: raise RuntimeError,`t(())` except IndexError: pass - + try: raise RuntimeError,`t(t)` except TypeError: pass try: raise RuntimeError,`t({})` diff --git a/numpy/f2py/use_rules.py b/numpy/f2py/use_rules.py index 28a34091b4b7..43c223a7d683 100644 --- a/numpy/f2py/use_rules.py +++ b/numpy/f2py/use_rules.py @@ -6,7 +6,7 @@ Unfinished. Copyright 2000 Pearu Peterson all rights reserved, -Pearu Peterson +Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. @@ -67,7 +67,7 @@ def buildusevars(m,r): if r.has_key('only') and r['only']: for v in r['map'].keys(): if m['vars'].has_key(r['map'][v]): - + if revmap[r['map'][v]]==v: varsmap[v]=r['map'][v] else: @@ -103,13 +103,7 @@ def buildusevar(name,realname,vars,usemodulename): if hasnote(vars[realname]): vrd['note']=vars[realname]['note'] rd=dictappend({},vrd) var=vars[realname] - + print name,realname,vars[realname] ret=applyrules(usemodule_rules,rd) return ret - - - - - - diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index a7de2e13ff86..f962b13b75e9 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -31,5 +31,5 @@ __all__ += arraysetops.__all__ def test(level=1, verbosity=1): - from numpy.testing import NumpyTest + from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity) diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index d1690d7d1c5c..5b88acd6c73f 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -155,13 +155,13 @@ def test_unique1d_speed( plot_results = False ): a = numpy.fix( nItem / 10 * numpy.random.random( nItem ) ) print 'dictionary:' - tt = time.clock() + tt = time.clock() b = numpy.unique( a ) dt1 = time.clock() - tt print dt1 print 'array:' - tt = time.clock() + tt = time.clock() c = unique1d( a ) dt2 = time.clock() - tt print dt2 diff --git a/numpy/lib/convertcode.py b/numpy/lib/convertcode.py index 0c5a0833b152..38504d5a28cb 100644 --- a/numpy/lib/convertcode.py +++ b/numpy/lib/convertcode.py @@ -15,7 +15,7 @@ # * Eliminates savespace=xxx # * Replace xxx.spacesaver() with True # * Convert xx.savespace(?) to pass + ## xx.savespace(?) -# #### -- not * Convert a.shape = ? to a.reshape(?) +# #### -- not * Convert a.shape = ? to a.reshape(?) # * Prints warning for use of bool, int, float, copmlex, object, and unicode # @@ -128,14 +128,14 @@ def getandcopy(name): def convertfile(filename): """Convert the filename given from using Numeric to using NumPy - + Copies the file to filename.orig and then over-writes the file with the updated code """ filestr = getandcopy(filename) filestr = fromstr(filestr) makenewfile(filename, filestr) - + def fromargs(args): filename = args[1] convertfile(filename) @@ -153,6 +153,3 @@ def convertall(direc=os.path.curdir): if __name__ == '__main__': fromargs(sys.argv) - - - diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index e44e37027e23..e4802f544157 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,7 +1,7 @@ __all__ = ['logspace', 'linspace', 'select', 'piecewise', 'trim_zeros', - 'copy', 'iterable', #'base_repr', 'binary_repr', + 'copy', 'iterable', #'base_repr', 'binary_repr', 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', 'disp', 'unique', 'extract', 'insert', 'nansum', 'nanmax', 'nanargmax', 'nanargmin', 'nanmin', 'vectorize', 'asarray_chkfinite', 'average', @@ -101,9 +101,9 @@ def average(a, axis=0, weights=None, returned=False): If weights are given, result is: sum(a * weights) / sum(weights), - where the weights must have a's shape or be 1D with length the - size of a in the given axis. Integer weights are converted to - Float. Not specifying weights is equivalent to specifying + where the weights must have a's shape or be 1D with length the + size of a in the given axis. Integer weights are converted to + Float. Not specifying weights is equivalent to specifying weights that are all 1. If 'returned' is True, return a tuple: the result and the sum of @@ -121,14 +121,14 @@ def average(a, axis=0, weights=None, returned=False): else: w = array(weights).ravel() * 1.0 n = add.reduce(multiply(a, w)) - d = add.reduce(w) + d = add.reduce(w) else: a = array(a) ash = a.shape if ash == (): a.shape = (1,) if weights is None: - n = add.reduce(a, axis) + n = add.reduce(a, axis) d = ash[axis] * 1.0 if returned: d = ones(n.shape) * d @@ -139,7 +139,7 @@ def average(a, axis=0, weights=None, returned=False): wsh = (1,) if wsh == ash: n = add.reduce(a*w, axis) - d = add.reduce(w, axis) + d = add.reduce(w, axis) elif wsh == (ash[axis],): ni = ash[axis] r = [newaxis]*ni @@ -176,14 +176,14 @@ def piecewise(x, condlist, funclist, *args, **kw): The length of the condition list must be n2 or n2-1 where n2 is the length of the function list. If len(condlist)==n2-1, then an 'otherwise' condition is formed by |'ing all the conditions - and inverting. + and inverting. funclist is a list of functions to call of length (n2). Each function should return an array output for an array input Each function can take (the same set) of extra arguments and keyword arguments which are passed in after the function list. A constant may be used in funclist for a function that returns a - constant (e.g. val and lambda x: val are equivalent in a funclist). + constant (e.g. val and lambda x: val are equivalent in a funclist). The output is the same shape and type as x and is found by calling the functions on the appropriate portions of x. @@ -234,7 +234,7 @@ def select(condlist, choicelist, default=0): arrays in choicelist. If condlist is [c0, ..., cN-1] then choicelist must be of length N. The elements of the choicelist can then be represented as [v0, ..., vN-1]. The default choice if none of the - conditions are met is given as the default argument. + conditions are met is given as the default argument. The conditions are tested in order and the first one statisfied is used to select the choice. In other words, the elements of the @@ -335,7 +335,7 @@ def gradient(f, *varargs): slice2[axis] = slice(2, None) slice3[axis] = slice(None, -2) # 1D equivalent -- out[1:-1] = (f[2:] - f[:-2])/2.0 - out[slice1] = (f[slice2] - f[slice3])/2.0 + out[slice1] = (f[slice2] - f[slice3])/2.0 slice1[axis] = 0 slice2[axis] = 1 slice3[axis] = 0 @@ -624,7 +624,7 @@ def __call__(self, *args): def cov(m,y=None, rowvar=0, bias=0): """Estimate the covariance matrix. - + If m is a vector, return the variance. For matrices where each row is an observation, and each column a variable, return the covariance matrix. Note that in this case diag(cov(m)) is a vector of @@ -765,7 +765,7 @@ def _chbevl(x, vals): b0 = x*b1 - b2 + vals[i] return 0.5*(b0 - b2) - + def _i0_1(x): return exp(x) * _chbevl(x/2.0-2, _i0A) diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py index 776e2550c8ec..7c677071dd5c 100644 --- a/numpy/lib/getlimits.py +++ b/numpy/lib/getlimits.py @@ -117,4 +117,3 @@ def __str__(self): f = finfo(numeric.longfloat) print 'longfloat epsilon:',f.eps print 'longfloat tiny:',f.tiny - diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 15aae9949b9e..96726f57c1d9 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -78,7 +78,7 @@ class nd_grid(object): >>> ogrid = nd_grid(sparse=True) >>> ogrid[0:5,0:5] - [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])] + [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])] """ def __init__(self, sparse=False): self.sparse = sparse @@ -99,7 +99,7 @@ def __getitem__(self,key): if isinstance(step,types.FloatType) or \ isinstance(start, types.FloatType) or \ isinstance(key[k].stop, types.FloatType): - typecode = _nx.Float + typecode = _nx.Float if self.sparse: nn = map(lambda x,t: _nx.arange(x,dtype=t),size,(typecode,)*len(size)) else: @@ -280,7 +280,7 @@ class ndindex(object): """Pass in a sequence of integers corresponding to the number of dimensions in the counter. This iterator will then return an N-dimensional counter. - + Example: >>> for index in ndindex(4,3,2): print index @@ -292,7 +292,7 @@ class ndindex(object): (3,2,0) (3,2,1) """ - + def __init__(self, *args): self.nd = len(args) self.ind = [0]*self.nd @@ -311,10 +311,10 @@ def _incrementone(self, axis): else: self.ind[axis] = 0 self._incrementone(axis-1) - + def ndincr(self): self._incrementone(self.nd-1) - + def next(self): if (self.index >= self.total): raise StopIteration @@ -370,4 +370,3 @@ def __getslice__(self, start, stop): index_exp = _index_expression_class() # End contribution from Konrad. - diff --git a/numpy/lib/info.py b/numpy/lib/info.py index bf6878b73852..0944fa9b5e1f 100644 --- a/numpy/lib/info.py +++ b/numpy/lib/info.py @@ -1,6 +1,6 @@ __doc_title__ = """Basic functions used by several sub-packages and useful to have in the main name-space.""" -__doc__ = __doc_title__ + """ +__doc__ = __doc_title__ + """ Type handling ============== @@ -15,7 +15,7 @@ isposinf -- Tests for positive infinity | isnan -- Tests for nans |---- array results isinf -- Tests for infinity | -isfinite -- Tests for finite numbers ---| +isfinite -- Tests for finite numbers ---| isscalar -- True if argument is a scalar nan_to_num -- Replaces NaN's with 0 and infinities with large numbers cast -- Dictionary of functions to force cast to each type @@ -80,7 +80,7 @@ rot90 -- Rotate a 2D array a multiple of 90 degrees eye -- Return a 2D array with ones down a given diagonal diag -- Construct a 2D array from a vector, or return a given - diagonal from a 2D array. + diagonal from a 2D array. mat -- Construct a Matrix bmat -- Build a Matrix from blocks diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index cbcfa9e70102..b6ace7dd8656 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -17,7 +17,7 @@ def apply_along_axis(func1d,axis,arr,*args): if axis < 0: axis += nd if (axis >= nd): - raise ValueError("axis must be less than arr.ndim; axis=%d, rank=%d." + raise ValueError("axis must be less than arr.ndim; axis=%d, rank=%d." % (axis,nd)) ind = [0]*(nd-1) i = zeros(nd,'O') @@ -150,11 +150,11 @@ def atleast_3d(*arys): """ Force a sequence of arrays to each be at least 3D. Description: - Force an array each be at least 3D. If the array is 0D or 1D, - the array is converted to a single 1xNx1 array of values where - N is the orginal length of the array. If the array is 2D, the + Force an array each be at least 3D. If the array is 0D or 1D, + the array is converted to a single 1xNx1 array of values where + N is the orginal length of the array. If the array is 2D, the array is converted to a single MxNx1 array of values where MxN - is the orginal shape of the array. Otherwise, the array is + is the orginal shape of the array. Otherwise, the array is unaltered. Arguments: arys -- arrays to be converted to 3 or more dimensional array. @@ -170,7 +170,7 @@ def atleast_3d(*arys): result = ary[newaxis,:,newaxis] elif len(ary.shape) == 2: result = ary[:,:,newaxis] - else: + else: result = ary res.append(result) if len(res) == 1: @@ -185,10 +185,10 @@ def vstack(tup): Description: Take a sequence of arrays and stack them veritcally to make a single array. All arrays in the sequence - must have the same shape along all but the first axis. + must have the same shape along all but the first axis. vstack will rebuild arrays divided by vsplit. Arguments: - tup -- sequence of arrays. All arrays must have the same + tup -- sequence of arrays. All arrays must have the same shape. Examples: >>> import numpy @@ -219,7 +219,7 @@ def hstack(tup): must have the same shape along all but the second axis. hstack will rebuild arrays divided by hsplit. Arguments: - tup -- sequence of arrays. All arrays must have the same + tup -- sequence of arrays. All arrays must have the same shape. Examples: >>> import numpy @@ -245,7 +245,7 @@ def column_stack(tup): to make a single 2D array. All arrays in the sequence must have the same length. Arguments: - tup -- sequence of 1D arrays. All arrays must have the same + tup -- sequence of 1D arrays. All arrays must have the same length. Examples: >>> import numpy @@ -265,12 +265,12 @@ def dstack(tup): Description: Take a sequence of arrays and stack them along the third axis. - All arrays in the sequence must have the same shape along all - but the third axis. This is a simple way to stack 2D arrays + All arrays in the sequence must have the same shape along all + but the third axis. This is a simple way to stack 2D arrays (images) into a single 3D array for processing. dstack will rebuild arrays divided by dsplit. Arguments: - tup -- sequence of arrays. All arrays must have the same + tup -- sequence of arrays. All arrays must have the same shape. Examples: >>> import numpy @@ -294,7 +294,7 @@ def _replace_zero_by_x_arrays(sub_arys): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.array([]) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)): - sub_arys[i] = _nx.array([]) + sub_arys[i] = _nx.array([]) return sub_arys def array_split(ary,indices_or_sections,axis = 0): @@ -368,9 +368,9 @@ def split(ary,indices_or_sections,axis=0): Divide ary into a list of sub-arrays along the specified axis. If indices_or_sections is an integer, ary is divided into that many equally sized arrays. - If it is impossible to make an equal split, an error is + If it is impossible to make an equal split, an error is raised. This is the only way this function differs from - the array_split() function. If indices_or_sections is a + the array_split() function. If indices_or_sections is a list of sorted integers, its entries define the indexes where ary is split. diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index 1c013619bad6..22f0a043c389 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -129,7 +129,7 @@ def check_manyways( self ): b = numpy.fix( nItem / 10 * numpy.random.random( nItem ) ) c1 = intersect1d_nu( a, b ) - c2 = unique1d( intersect1d( a, b ) ) + c2 = unique1d( intersect1d( a, b ) ) assert_array_equal( c1, c2 ) a = numpy.array( [5, 7, 1, 2, 8] ) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 41cdf45b4619..592bd99e7199 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -22,7 +22,7 @@ def check_nd(self): assert(any(y1)) assert_array_equal(sometrue(y1),[1,1,0]) assert_array_equal(sometrue(y1,axis=1),[0,1,1]) - + class test_all(ScipyTestCase): def check_basic(self): y1 = [0,1,1,0] @@ -53,7 +53,7 @@ def check_basic(self): y4[1,0] = 2 assert_array_equal(y4.mean(0), average(y4, 0)) assert_array_equal(y4.mean(1), average(y4, 1)) - + y5 = rand(5,5) assert_array_equal(y5.mean(0), average(y5, 0)) assert_array_equal(y5.mean(1), average(y5, 1)) @@ -147,7 +147,7 @@ def check_basic(self): self.failUnlessRaises(ArithmeticError, prod, a) else: assert_equal(prod(a),26400) - assert_array_equal(prod(a2,axis=0), + assert_array_equal(prod(a2,axis=0), array([50,36,84,180],ctype)) assert_array_equal(prod(a2,axis=-1),array([24, 1890, 600],ctype)) @@ -242,7 +242,7 @@ def check_both(self): insert(a,mask,0) insert(a,mask,c) assert_array_equal(a,ac) - + class test_vectorize(ScipyTestCase): def check_simple(self): def addsubtract(a,b): @@ -262,75 +262,75 @@ def addsubtract(a,b): f = vectorize(addsubtract) r = f([0,3,6,9],5) assert_array_equal(r,[5,8,1,4]) - + class test_unwrap(ScipyTestCase): - def check_simple(self): - #check that unwrap removes jumps greather that 2*pi - assert_array_equal(unwrap([1,1+2*pi]),[1,1]) - #check that unwrap maintans continuity - assert(all(diff(unwrap(rand(10)*100)) 1e10) and assert_all(isfinite(vals)) + assert_all(isfinite(vals)) + #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) # !! This is actually (unexpectedly) positive # !! inf. Comment out for now, and see if it # !! changes - #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) + #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) class test_real_if_close(ScipyTestCase): diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 39a908268c75..2f8069a8b995 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -9,8 +9,8 @@ import sys def fliplr(m): - """ returns an array m with the rows preserved and columns flipped - in the left/right direction. Works on the first two dimensions of m. + """ returns an array m with the rows preserved and columns flipped + in the left/right direction. Works on the first two dimensions of m. """ m = asanyarray(m) if m.ndim < 2: @@ -29,7 +29,7 @@ def flipud(m): def rot90(m, k=1): """ returns the array found by rotating m by k*90 degrees in the counterclockwise direction. Works on the first two - dimensions of m. + dimensions of m. """ m = asanyarray(m) if m.ndim < 2: @@ -41,7 +41,7 @@ def rot90(m, k=1): else: return fliplr(m.transpose()) # k==3 def eye(N, M=None, k=0, dtype=int_): - """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones, + """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones, and everything else is zeros. """ if M is None: M = N @@ -49,7 +49,7 @@ def eye(N, M=None, k=0, dtype=int_): return m.astype(dtype) def diag(v, k=0): - """ returns the k-th diagonal if v is a array or returns a array + """ returns the k-th diagonal if v is a array or returns a array with v as the k-th diagonal if v is a vector. """ v = asarray(v) @@ -77,7 +77,7 @@ def diag(v, k=0): fi = i + (i-k)*N2 return v.flat[fi] else: - raise ValueError, "Input must be 1- or 2-d." + raise ValueError, "Input must be 1- or 2-d." def tri(N, M=None, k=0, dtype=int_): diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py index e72a757e0ea5..661f6393947e 100644 --- a/numpy/lib/type_check.py +++ b/numpy/lib/type_check.py @@ -32,13 +32,13 @@ def mintypecode(typechars,typeset='GDFgdf',default='d'): for t in typechars] intersection = [t for t in typecodes if t in typeset] if not intersection: - return default + return default if 'F' in intersection and 'd' in intersection: - return 'D' + return 'D' l = [] for t in intersection: - i = _typecodes_by_elsize.index(t) - l.append((i,t)) + i = _typecodes_by_elsize.index(t) + l.append((i,t)) l.sort() return l[0][1] diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index c291c7e9cc95..1084a03e79c7 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -56,4 +56,3 @@ def log2(x, y=None): umath.log(x, y) y /= _log2 return y - diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 7e20c3c7ad74..e64f5d978dbb 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -10,14 +10,14 @@ def issubclass_(arg1, arg2): def issubsctype(arg1, arg2): return issubclass(obj2sctype(arg1), obj2sctype(arg2)) - + def get_numpy_include(): - """Return the directory in the package that contains the numpy/*.h header + """Return the directory in the package that contains the numpy/*.h header files. - + Extension modules that need to compile against numpy should use this function to locate the appropriate include directory. Using distutils: - + import numpy Extension('extension_name', ... include_dirs=[numpy.get_numpy_include()]) diff --git a/numpy/linalg/__init__.py b/numpy/linalg/__init__.py index 287b3959ee21..85d81d0a826d 100644 --- a/numpy/linalg/__init__.py +++ b/numpy/linalg/__init__.py @@ -4,5 +4,5 @@ from linalg import * def test(level=1, verbosity=1): - from numpy.testing import NumpyTest + from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity) diff --git a/numpy/linalg/info.py b/numpy/linalg/info.py index da6a9df2092f..45e2d664024e 100644 --- a/numpy/linalg/info.py +++ b/numpy/linalg/info.py @@ -15,11 +15,10 @@ eig --- Find the eigenvalues and vectors of a square matrix eigh --- Find the eigenvalues and eigenvectors of a Hermitian matrix eigvals --- Find the eigenvalues of a square matrix - eigvalsh --- Find the eigenvalues of a Hermitian matrix. + eigvalsh --- Find the eigenvalues of a Hermitian matrix. svd --- Singular value decomposition of a matrix - cholesky --- Cholesky decomposition of a matrix + cholesky --- Cholesky decomposition of a matrix """ depends = ['core'] - diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 58bc9fbffc36..5b8ce6fbe5a6 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -13,7 +13,7 @@ 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares' ] - + from numpy.core import * import lapack_lite @@ -49,7 +49,7 @@ def _castCopyAndTranspose(type, *arrays): for a in arrays: cast_arrays = cast_arrays + (transpose(a).astype(type),) if len(cast_arrays) == 1: - return cast_arrays[0] + return cast_arrays[0] else: return cast_arrays @@ -66,7 +66,7 @@ def _fastCopyAndTranspose(type, *arrays): else: cast_arrays = cast_arrays + (_fastCT(a.astype(type)),) if len(cast_arrays) == 1: - return cast_arrays[0] + return cast_arrays[0] else: return cast_arrays @@ -385,7 +385,7 @@ def generalized_inverse(a, rcond = 1.e-10): s[i] = 1./s[i] else: s[i] = 0.; - return wrap(dot(transpose(vt), + return wrap(dot(transpose(vt), multiply(s[:, NewAxis],transpose(u)))) # Determinant @@ -557,5 +557,3 @@ def test(a, b): a = a+0j b = b+0j test(a, b) - - diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index c68023a7fef0..139b6f77faa2 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -23,7 +23,7 @@ def get_lapack_lite_sources(ext, build_dir): 'f2c_lite.c','f2c.h'], extra_info = lapack_info ) - + return config if __name__ == '__main__': diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py index 13d0e3a22f5b..5a74232087e2 100644 --- a/numpy/random/__init__.py +++ b/numpy/random/__init__.py @@ -8,11 +8,11 @@ def __RandomState_ctor(): """Return a RandomState instance. - + This function exists solely to assist (un)pickling. """ return RandomState() def test(level=1, verbosity=1): - from numpy.testing import NumpyTest + from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity) diff --git a/numpy/random/setup.py b/numpy/random/setup.py index bc9d4f059d4e..3dca04759fe2 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -21,7 +21,7 @@ def generate_libraries(ext, build_dir): libs = [] # Configure mtrand config.add_extension('mtrand', - sources=[join('mtrand', x) for x in + sources=[join('mtrand', x) for x in ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']]+[generate_libraries], libraries=libs, @@ -30,7 +30,7 @@ def generate_libraries(ext, build_dir): join('mtrand','*.pxi'), ] ) - + return config def testcode_wincrypt(): @@ -50,4 +50,3 @@ def testcode_wincrypt(): if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict()) - diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 4b43c428e389..5b7ef9953e30 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -197,7 +197,7 @@ def stopTest(self, test): class SciPyTextTestRunner(unittest.TextTestRunner): def _makeResult(self): return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity) - + class NumpyTest: """ Numpy tests site manager. @@ -295,7 +295,7 @@ def _get_method_names(self,clsobj,level): for base in clsobj.__bases__: for n in self._get_method_names(base,level): if n not in names: - names.append(n) + names.append(n) return names def _get_short_module_name(self, module): @@ -304,7 +304,7 @@ def _get_short_module_name(self, module): if short_module_name=='__init__': short_module_name = module.__name__.split('.')[-1] short_module_name = self._rename_map.get(short_module_name,short_module_name) - return short_module_name + return short_module_name def _get_module_tests(self,module,level,verbosity): mstr = self._module_str diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index fe3a3c0931b5..173122d5e64c 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -12,8 +12,8 @@ def rand(*args): """Returns an array of random numbers with the given shape. - - This only uses the standard library, so it is useful for testing purposes. + + This only uses the standard library, so it is useful for testing purposes. """ import random from numpy.core import zeros, Float64 @@ -66,7 +66,7 @@ def memusage(): if os.name=='nt': # Code stolen from enthought/debug/memusage.py - import win32pdh + import win32pdh # from win32pdhutil, part of the win32all package def GetPerformanceAttributes(object, counter, instance = None, inum=-1, format = win32pdh.PDH_FMT_LONG, machine=None): @@ -90,7 +90,7 @@ def GetPerformanceAttributes(object, counter, instance = None, win32pdh.RemoveCounter(hc) finally: win32pdh.CloseQuery(hq) - + def memusage(processName="python", instance=0): return GetPerformanceAttributes("Process", "Virtual Bytes", processName, instance, @@ -260,4 +260,3 @@ def assert_array_less(x,y,err_msg=''): def runstring(astr, dict): exec astr in dict -