summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2007-01-08 21:56:54 +0000
committerStefan van der Walt <stefan@sun.ac.za>2007-01-08 21:56:54 +0000
commit1bd2d49ef378fb869d015cef32c3e44a4c03a8f0 (patch)
tree43335baf1da0b6e9de0ad806e721a077e3cbfa45 /numpy/core
parent98b6d48b07f4eadfb7d1fc41483debe7e07eecd6 (diff)
downloadnumpy-1bd2d49ef378fb869d015cef32c3e44a4c03a8f0.tar.gz
Whitespace cleanup.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/_internal.py13
-rw-r--r--numpy/core/arrayprint.py2
-rw-r--r--numpy/core/code_generators/generate_array_api.py4
-rw-r--r--numpy/core/code_generators/generate_umath.py2
-rw-r--r--numpy/core/defchararray.py12
-rw-r--r--numpy/core/defmatrix.py27
-rw-r--r--numpy/core/fromnumeric.py6
-rw-r--r--numpy/core/ma.py8
-rw-r--r--numpy/core/numeric.py32
-rw-r--r--numpy/core/numerictypes.py2
-rw-r--r--numpy/core/records.py44
-rw-r--r--numpy/core/setup.py5
-rw-r--r--numpy/core/tests/test_defmatrix.py4
-rw-r--r--numpy/core/tests/test_errstate.py7
-rw-r--r--numpy/core/tests/test_ma.py40
-rw-r--r--numpy/core/tests/test_multiarray.py47
-rw-r--r--numpy/core/tests/test_numeric.py14
-rw-r--r--numpy/core/tests/test_numerictypes.py4
-rw-r--r--numpy/core/tests/test_scalarmath.py3
-rw-r--r--numpy/core/tests/test_umath.py3
20 files changed, 136 insertions, 143 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
index 3684ba492..ba526b732 100644
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -1,4 +1,3 @@
-
#A place for code to be called from C-code
# that implements more complicated stuff.
@@ -40,7 +39,7 @@ def _makenames_list(adict):
titles = [x[3] for x in allfields]
return names, formats, offsets, titles
-
+
# Called in PyArray_DescrConverter function when
# a dictionary without "names" and "formats"
# fields is used as a data-type descriptor.
@@ -219,7 +218,7 @@ class _missing_ctypes(object):
def c_void_p(self, num):
return num
-
+
class _ctypes(object):
def __init__(self, array, ptr=None):
try:
@@ -233,7 +232,7 @@ class _ctypes(object):
self._zerod = True
else:
self._zerod = False
-
+
def data_as(self, obj):
return self._ctypes.cast(self._data, obj)
@@ -246,12 +245,12 @@ class _ctypes(object):
if self._zerod:
return None
return (obj*self._arr.ndim)(*self._arr.strides)
-
+
def get_data(self):
return self._data
def get_shape(self):
- if self._zerod:
+ if self._zerod:
return None
return (_getintp_ctype()*self._arr.ndim)(*self._arr.shape)
@@ -262,7 +261,7 @@ class _ctypes(object):
def get_as_parameter(self):
return self._ctypes.c_void_p(self._data)
-
+
data = property(get_data, None, doc="c-types data")
shape = property(get_shape, None, doc="c-types shape")
strides = property(get_strides, None, doc="c-types strides")
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 390252368..f0629660a 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -125,7 +125,7 @@ def _leading_trailing(a):
def _boolFormatter(x):
if x: return ' True'
else: return 'False'
-
+
def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
prefix=""):
diff --git a/numpy/core/code_generators/generate_array_api.py b/numpy/core/code_generators/generate_array_api.py
index 5da4b2439..c6f73c33f 100644
--- a/numpy/core/code_generators/generate_array_api.py
+++ b/numpy/core/code_generators/generate_array_api.py
@@ -16,8 +16,8 @@ h_template = r"""
#ifdef _MULTIARRAYMODULE
typedef struct {
- PyObject_HEAD
- npy_bool obval;
+ PyObject_HEAD
+ npy_bool obval;
} PyBoolScalarObject;
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index 96a681d3c..26ef5218f 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -267,7 +267,7 @@ defdict = {
Ufunc(2, 1, None,
'returns minimum (if x1 < x2: x1; else: x2) elementwise',
TD(noobj),
- TD(O, f='_npy_ObjectMin')
+ TD(O, f='_npy_ObjectMin')
),
'bitwise_and' :
Ufunc(2, 1, One,
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index c77ec30be..4ce06b247 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -38,7 +38,7 @@ class chararray(ndarray):
return self
def __array_finalize__(self, obj):
- # The b is a special case because it is used for reconstructing.
+ # The b is a special case because it is used for reconstructing.
if not _globalvar and self.dtype.char not in 'SUb':
raise ValueError, "Can only create a chararray from string data."
@@ -52,23 +52,23 @@ class chararray(ndarray):
val = temp
return val
- def __eq__(self, other):
+ def __eq__(self, other):
return compare_chararrays(self, other, '==', True)
- def __ne__(self, other):
+ def __ne__(self, other):
return compare_chararrays(self, other, '!=', True)
def __ge__(self, other):
- return compare_chararrays(self, other, '>=', True)
+ return compare_chararrays(self, other, '>=', True)
def __le__(self, other):
- return compare_chararrays(self, other, '<=', True)
+ return compare_chararrays(self, other, '<=', True)
def __gt__(self, other):
return compare_chararrays(self, other, '>', True)
def __lt__(self, other):
- return compare_chararrays(self, other, '<', True)
+ return compare_chararrays(self, other, '<', True)
def __add__(self, other):
b = broadcast(self, other)
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index becfa74c9..e64fd8c6d 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -1,4 +1,3 @@
-
__all__ = ['matrix', 'bmat', 'mat', 'asmatrix']
import numeric as N
@@ -135,7 +134,7 @@ class matrix(N.ndarray):
if out.ndim == 0:
return out[()]
if out.ndim == 1:
- sh = out.shape[0]
+ sh = out.shape[0]
# Determine when we should have a column array
try:
n = len(index)
@@ -146,14 +145,14 @@ class matrix(N.ndarray):
else:
out.shape = (1,sh)
return out
-
+
def _get_truendim(self):
shp = self.shape
truend = 0
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 \
@@ -249,28 +248,28 @@ class matrix(N.ndarray):
def var(self, axis=None, dtype=None, out=None):
return N.ndarray.var(self, axis, dtype, out)._align(axis)
-
+
def prod(self, axis=None, dtype=None, out=None):
return N.ndarray.prod(self, axis, dtype, out)._align(axis)
-
+
def any(self, axis=None, out=None):
- return N.ndarray.any(self, axis, out)._align(axis)
+ return N.ndarray.any(self, axis, out)._align(axis)
def all(self, axis=None, out=None):
return N.ndarray.all(self, axis, out)._align(axis)
-
+
def max(self, axis=None, out=None):
return N.ndarray.max(self, axis, out)._align(axis)
def argmax(self, axis=None, out=None):
return N.ndarray.argmax(self, axis, out)._align(axis)
-
+
def min(self, axis=None, out=None):
return N.ndarray.min(self, axis, out)._align(axis)
-
+
def argmin(self, axis=None, out=None):
return N.ndarray.argmin(self, axis, out)._align(axis)
-
+
def ptp(self, axis=None, out=None):
return N.ndarray.ptp(self, axis, out)._align(axis)
@@ -289,10 +288,10 @@ class matrix(N.ndarray):
def getA(self):
return self.__array__()
-
+
def getA1(self):
return self.__array__().ravel()
-
+
def getT(self):
return self.transpose()
@@ -300,7 +299,7 @@ class matrix(N.ndarray):
if issubclass(self.dtype.type, N.complexfloating):
return self.transpose().conjugate()
else:
- return self.transpose()
+ return self.transpose()
T = property(getT, None, doc="transpose")
A = property(getA, None, doc="base array")
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index e153f6061..e80006a15 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -124,13 +124,13 @@ def sort(a, axis=-1, kind='quicksort', order=None):
axis -- axis to be sorted (default -1). Can be None
to indicate that a flattened and sorted array should
- be returned (the array method does not support this).
+ be returned (the array method does not support this).
kind -- sorting algorithm (default 'quicksort')
Possible values: 'quicksort', 'mergesort', or 'heapsort'.
order -- For an array with fields defined, this argument allows
specification of which fields to compare first, second,
etc. Not all fields need be specified.
-
+
Returns: None.
@@ -171,7 +171,7 @@ def argsort(a, axis=-1, kind='quicksort', order=None):
axis -- axis to be indirectly sorted (default -1)
Can be None to indicate return indices into the
- flattened array.
+ flattened array.
kind -- sorting algorithm (default 'quicksort')
Possible values: 'quicksort', 'mergesort', or 'heapsort'
order -- For an array with fields defined, this argument allows
diff --git a/numpy/core/ma.py b/numpy/core/ma.py
index 5bd7ed7d2..fc1e89d7b 100644
--- a/numpy/core/ma.py
+++ b/numpy/core/ma.py
@@ -2101,7 +2101,7 @@ def diagonal(a, k = 0, axis1=0, axis2=1):
return masked_array(d, m)
else:
return masked_array(d, fromnumeric.diagonal(m, k, axis1, axis2))
-
+
def trace (a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
"""trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals
(defined by the last two dimenions) of the array.
@@ -2177,7 +2177,7 @@ array.choose = _m(_choose)
del _choose
def _clip(self,a_min,a_max,out=None):
- return MaskedArray(data = self.data.clip(asarray(a_min).data,
+ return MaskedArray(data = self.data.clip(asarray(a_min).data,
asarray(a_max).data),
mask = mask_or(self.mask,
mask_or(getmask(a_min),getmask(a_max))))
@@ -2215,7 +2215,7 @@ array.getfield = _m(not_implemented)
def _max(a, axis=None, out=None):
if out is not None:
- raise TypeError("Output arrays Unsupported for masked arrays")
+ raise TypeError("Output arrays Unsupported for masked arrays")
if axis is None:
return maximum(a)
else:
@@ -2254,7 +2254,7 @@ def _squeeze(self):
except AttributeError:
result = _wrapit(self, 'squeeze')
return result
-array.squeeze = _m(_squeeze)
+array.squeeze = _m(_squeeze)
array.strides = property(_m(not_implemented))
array.sum = _m(sum)
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 0905b3939..4329cae5c 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -159,7 +159,7 @@ def require(a, dtype=None, requirements=None):
subok = 0
else:
subok = 1
-
+
arr = array(a, dtype=dtype, copy=False, subok=subok)
copychar = 'A'
@@ -176,7 +176,7 @@ def require(a, dtype=None, requirements=None):
if not arr.flags[prop]:
arr = arr.copy(copychar)
break
- return arr
+ return arr
def isfortran(a):
"""Returns True if 'a' is arranged in Fortran-order in memory with a.ndim > 1
@@ -240,7 +240,7 @@ def outer(a,b):
def vdot(a, b):
"""Returns the dot product of 2 vectors (or anything that can be made into
a vector).
-
+
Note: this is not the same as `dot`, as it takes the conjugate of its first
argument if complex and always returns a scalar."""
return dot(asarray(a).ravel().conj(), asarray(b).ravel())
@@ -265,7 +265,7 @@ def tensordot(a, b, axes=2):
the axes to be summed over are given by the axes argument.
the first element of the sequence determines the axis or axes
in arr1 to sum over, and the second element in axes argument sequence
- determines the axis or axes in arr2 to sum over.
+ determines the axis or axes in arr2 to sum over.
When there is more than one axis to sum over, the corresponding
arguments to axes should be sequences of the same length with the first
@@ -273,7 +273,7 @@ def tensordot(a, b, axes=2):
and so forth.
If the axes argument is an integer, N, then the last N dimensions of a
- and first N dimensions of b are summed over.
+ and first N dimensions of b are summed over.
"""
try:
iter(axes)
@@ -375,8 +375,8 @@ def rollaxis(a, axis, start=0):
raise ValueError, msg % ('axis', axis, n)
if not (0 <= start < n+1):
raise ValueError, msg % ('start', start, n+1)
- if (axis < start): # it's been removed
- start -= 1
+ if (axis < start): # it's been removed
+ start -= 1
if axis==start:
return a
axes = range(0,n)
@@ -488,7 +488,7 @@ def indices(dimensions, dtype=int):
def fromfunction(function, shape, **kwargs):
"""Returns an array constructed by calling a function on a tuple of number
grids.
-
+
The function should accept as many arguments as the length of shape and work
on array inputs. The shape argument is a sequence of numbers indicating the
length of the desired output for each axis.
@@ -496,7 +496,7 @@ def fromfunction(function, shape, **kwargs):
The function can also accept keyword arguments (except dtype), which will be
passed through fromfunction to the function itself. The dtype argument
(default float) determines the data-type of the index grid passed to the
- function.
+ function.
"""
dtype = kwargs.pop('dtype', float)
args = indices(shape, dtype=dtype)
@@ -532,7 +532,7 @@ _lkup = {
'C':'1100',
'D':'1101',
'E':'1110',
- 'F':'1111',
+ 'F':'1111',
'L':''}
def binary_repr(num):
@@ -698,7 +698,7 @@ def seterr(all=None, divide=None, over=None, under=None, invalid=None):
FloatingPointError: overflow encountered in short_scalars
>>> seterr(all='ignore')
{'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
-
+
"""
pyvals = umath.geterrobj()
@@ -785,16 +785,16 @@ def geterrcall():
"""
return umath.geterrobj()[2]
-class _unspecified(object):
+class _unspecified(object):
pass
_Unspecified = _unspecified()
class errstate(object):
"""with errstate(**state): --> operations in following block use given state.
-
+
# Set error handling to known state.
- >>> _ = seterr(invalid='raise', divide='raise', over='raise', under='ignore')
-
+ >>> _ = seterr(invalid='raise', divide='raise', over='raise', under='ignore')
+
|>> a = -arange(3)
|>> with errstate(invalid='ignore'):
... print sqrt(a)
@@ -812,7 +812,7 @@ class errstate(object):
Traceback (most recent call last):
...
FloatingPointError: divide by zero encountered in divide
-
+
"""
# Note that we don't want to run the above doctests because they will fail
# without a from __future__ import with_statement
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index bc9fbe41e..0836241cd 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -216,7 +216,7 @@ def _add_integer_aliases():
Intname = 'Int%d' % bits
uval = typeinfo['U'+ctype]
typeobj = val[-1]
- utypeobj = uval[-1]
+ utypeobj = uval[-1]
if intname not in allTypes.keys():
uintname = 'uint%d' % bits
allTypes[intname] = typeobj
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 838372cf2..b8fca5d0b 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -1,4 +1,4 @@
-# All of the functions allow formats to be a dtype
+# All of the functions allow formats to be a dtype
__all__ = ['record', 'recarray', 'format_parser']
import numeric as sb
@@ -110,7 +110,7 @@ class format_parser:
if (byteorder is not None):
byteorder = _byteorderconv[byteorder[0]]
descr = descr.newbyteorder(byteorder)
-
+
self._descr = descr
class record(nt.void):
@@ -129,7 +129,7 @@ class record(nt.void):
pass
fielddict = nt.void.__getattribute__(self, 'dtype').fields
res = fielddict.get(attr,None)
- if res:
+ if res:
obj = self.getfield(*res[:2])
# if it has fields return a recarray,
# if it's a string return 'SU' return a chararray
@@ -142,7 +142,7 @@ class record(nt.void):
else:
raise AttributeError, "'record' object has no "\
"attribute '%s'" % attr
-
+
def __setattr__(self, attr, val):
if attr in ['setfield', 'getfield', 'dtype']:
@@ -171,7 +171,7 @@ class recarray(ndarray):
def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None,
formats=None, names=None, titles=None,
byteorder=None, aligned=False):
-
+
if dtype is not None:
descr = sb.dtype(dtype)
else:
@@ -207,7 +207,7 @@ class recarray(ndarray):
# Save the dictionary
# If the attr is a field name and not in the saved dictionary
# Undo any "setting" of the attribute and do a setfield
-# Thus, you can't create attributes on-the-fly that are field names.
+# Thus, you can't create attributes on-the-fly that are field names.
def __setattr__(self, attr, val):
newattr = attr not in self.__dict__
@@ -224,14 +224,14 @@ class recarray(ndarray):
return ret
if newattr: # We just added this one
try: # or this setattr worked on an internal
- # attribute.
+ # attribute.
object.__delattr__(self, attr)
except:
return ret
try:
res = fielddict[attr][:2]
except (TypeError,KeyError):
- raise AttributeError, "record array has no attribute %s" % attr
+ raise AttributeError, "record array has no attribute %s" % attr
return self.setfield(val,*res)
def __getitem__(self, indx):
@@ -268,8 +268,8 @@ class recarray(ndarray):
dtype = sb.dtype(obj)
if dtype.fields is None:
return self.__array__().view(dtype)
- return ndarray.view(self, obj)
-
+ return ndarray.view(self, obj)
+
def fromarrays(arrayList, dtype=None, shape=None, formats=None,
names=None, titles=None, aligned=False, byteorder=None):
""" create a record array from a (flat) list of arrays
@@ -284,9 +284,9 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
>>> r.a
array([1, 2, 3, 4])
"""
-
+
arrayList = [sb.asarray(x) for x in arrayList]
-
+
if shape is None or shape == 0:
shape = arrayList[0].shape
@@ -318,18 +318,18 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
if len(descr) != len(arrayList):
raise ValueError, "mismatch between the number of fields "\
"and the number of arrays"
-
+
d0 = descr[0].shape
nn = len(d0)
if nn > 0:
shape = shape[:-nn]
-
+
for k, obj in enumerate(arrayList):
nn = len(descr[k].shape)
testshape = obj.shape[:len(obj.shape)-nn]
if testshape != shape:
raise ValueError, "array-shape mismatch in array %d" % k
-
+
_array = recarray(shape, descr)
# populate the record array (makes a copy)
@@ -369,7 +369,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,
(2, 'de', 1.3)
]
"""
-
+
nfields = len(recList[0])
if formats is None and dtype is None: # slower
obj = sb.array(recList,dtype=object)
@@ -400,7 +400,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,
retval.shape = shape
res = retval.view(recarray)
-
+
res.dtype = sb.dtype((record, res.dtype))
return res
@@ -409,7 +409,7 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None,
names=None, titles=None, aligned=False, byteorder=None):
""" create a (read-only) record array from binary data contained in
a string"""
-
+
if dtype is None and formats is None:
raise ValueError, "Must have dtype= or formats="
@@ -418,11 +418,11 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None,
descr = sb.dtype(dtype)
else:
descr = format_parser(formats, names, titles, aligned, byteorder)._descr
-
+
itemsize = descr.itemsize
if (shape is None or shape == 0 or shape == -1):
shape = (len(datastring)-offset) / itemsize
-
+
_array = recarray(shape, descr, buf=datastring, offset=offset)
return _array
@@ -465,7 +465,7 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None,
if (offset > 0):
fd.seek(offset, 1)
size = get_remaining_size(fd)
-
+
if dtype is not None:
descr = sb.dtype(dtype)
else:
@@ -520,7 +520,7 @@ def array(obj, dtype=None, shape=None, offset=0, strides=None, formats=None,
'aligned' : aligned,
'byteorder' : byteorder
}
-
+
if obj is None:
if shape is None:
raise ValueError("Must define a shape if obj is None")
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 7953ba576..ac13f10c8 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -1,4 +1,3 @@
-
import imp
import os
import sys
@@ -54,7 +53,7 @@ def configuration(parent_package='',top_path=None):
# which is done in error-handling
# ufunc code. NPY_ALLOW_C_API and friends
# cause the segfault. So, we disable threading
- # for now.
+ # for now.
if sys.version[:5] < '2.4.2':
nosmp = 1
else:
@@ -100,7 +99,7 @@ def configuration(parent_package='',top_path=None):
if sys.platform == 'win32':
moredefs.append('NPY_NO_SIGNAL')
-
+
if sys.version[:3] < '2.4':
if config_cmd.check_func('strtod', decl=False,
headers=['stdlib.h']):
diff --git a/numpy/core/tests/test_defmatrix.py b/numpy/core/tests/test_defmatrix.py
index 27e72f3b5..1330bfff2 100644
--- a/numpy/core/tests/test_defmatrix.py
+++ b/numpy/core/tests/test_defmatrix.py
@@ -177,8 +177,8 @@ class test_indexing(NumpyTestCase):
y = zeros((3,1),float)
y[:,0] = [0.8,0.2,0.3]
x[:,1] = y>0.5
- assert_equal(x, [[0,1],[0,0],[0,0]])
-
+ assert_equal(x, [[0,1],[0,0],[0,0]])
+
if __name__ == "__main__":
NumpyTest().run()
diff --git a/numpy/core/tests/test_errstate.py b/numpy/core/tests/test_errstate.py
index f0f894655..a7ce798b0 100644
--- a/numpy/core/tests/test_errstate.py
+++ b/numpy/core/tests/test_errstate.py
@@ -1,4 +1,3 @@
-
# The following exec statement (or something like it) is needed to
# prevent SyntaxError on Python < 2.5. Even though this is a test,
# SyntaxErrors are not acceptable; on Debian systems, they block
@@ -17,7 +16,7 @@ from numpy.testing import *
class test_errstate(NumpyTestCase):
-
+
def test_invalid(self):
with errstate(all='raise', under='ignore'):
a = -arange(3)
@@ -31,7 +30,7 @@ class test_errstate(NumpyTestCase):
pass
else:
self.fail()
-
+
def test_divide(self):
with errstate(all='raise', under='ignore'):
a = -arange(3)
@@ -45,7 +44,7 @@ class test_errstate(NumpyTestCase):
pass
else:
self.fail()
-
+
def test_errcall(self):
def foo(*args):
print args
diff --git a/numpy/core/tests/test_ma.py b/numpy/core/tests/test_ma.py
index d37ae5625..00bd5c86d 100644
--- a/numpy/core/tests/test_ma.py
+++ b/numpy/core/tests/test_ma.py
@@ -715,32 +715,32 @@ class test_ufuncs(NumpyTestCase):
class test_array_methods(NumpyTestCase):
-
+
def setUp(self):
- x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928,
- 8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732,
- 3.012, 6.022, 5.095, 3.116, 5.238, 3.957,
+ x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928,
+ 8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732,
+ 3.012, 6.022, 5.095, 3.116, 5.238, 3.957,
6.04 , 9.63 , 7.712, 3.382, 4.489, 6.479,
- 7.189, 9.645, 5.395, 4.961, 9.894, 2.893,
+ 7.189, 9.645, 5.395, 4.961, 9.894, 2.893,
7.357, 9.828, 6.272, 3.758, 6.693, 0.993])
X = x.reshape(6,6)
XX = x.reshape(3,2,2,3)
-
- m = numpy.array([0, 1, 0, 1, 0, 0,
- 1, 0, 1, 1, 0, 1,
- 0, 0, 0, 1, 0, 1,
- 0, 0, 0, 1, 1, 1,
- 1, 0, 0, 1, 0, 0,
+
+ m = numpy.array([0, 1, 0, 1, 0, 0,
+ 1, 0, 1, 1, 0, 1,
+ 0, 0, 0, 1, 0, 1,
+ 0, 0, 0, 1, 1, 1,
+ 1, 0, 0, 1, 0, 0,
0, 0, 1, 0, 1, 0])
mx = array(data=x,mask=m)
mX = array(data=X,mask=m.reshape(X.shape))
mXX = array(data=XX,mask=m.reshape(XX.shape))
-
- m2 = numpy.array([1, 1, 0, 1, 0, 0,
- 1, 1, 1, 1, 0, 1,
- 0, 0, 1, 1, 0, 1,
- 0, 0, 0, 1, 1, 1,
- 1, 0, 0, 1, 1, 0,
+
+ m2 = numpy.array([1, 1, 0, 1, 0, 0,
+ 1, 1, 1, 1, 0, 1,
+ 0, 0, 1, 1, 0, 1,
+ 0, 0, 0, 1, 1, 1,
+ 1, 0, 0, 1, 1, 0,
0, 0, 1, 0, 1, 1])
m2x = array(data=x,mask=m2)
m2X = array(data=X,mask=m2.reshape(X.shape))
@@ -789,14 +789,14 @@ class test_array_methods(NumpyTestCase):
self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(0)))
mXcp = mX.cumprod(1)
self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(1)))
-
+
def test_cumsum(self):
(x,X,XX,m,mx,mX,mXX,) = self.d
mXcp = mX.cumsum(0)
self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(0)))
mXcp = mX.cumsum(1)
self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(1)))
-
+
def test_varstd(self):
(x,X,XX,m,mx,mX,mXX,) = self.d
self.failUnless(eq(mX.var(axis=None),mX.compressed().var()))
@@ -809,7 +809,7 @@ class test_array_methods(NumpyTestCase):
self.failUnless(eq(mXvar0[k],mX[:,k].compressed().var()))
self.failUnless(eq(numpy.sqrt(mXvar0[k]),
mX[:,k].compressed().std()))
-
+
def eqmask(m1, m2):
if m1 is nomask:
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 58c93947d..ef2f0baad 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -1,4 +1,3 @@
-
from numpy.testing import *
from numpy.core import *
from numpy import random
@@ -196,7 +195,7 @@ class test_zero_rank(NumpyTestCase):
def check_output(self):
x = array(2)
self.failUnlessRaises(ValueError, add, x, [1], x)
-
+
class test_creation(NumpyTestCase):
def check_from_attribute(self):
class x(object):
@@ -283,23 +282,23 @@ class test_pickling(NumpyTestCase):
p = loads(s)
assert_equal(a, p)
-class test_fancy_indexing(NumpyTestCase):
- def check_list(self):
- x = ones((1,1))
- x[:,[0]] = 2.0
- assert_array_equal(x, array([[2.0]]))
+class test_fancy_indexing(NumpyTestCase):
+ def check_list(self):
+ x = ones((1,1))
+ x[:,[0]] = 2.0
+ assert_array_equal(x, array([[2.0]]))
- x = ones((1,1,1))
- x[:,:,[0]] = 2.0
- assert_array_equal(x, array([[[2.0]]]))
+ x = ones((1,1,1))
+ x[:,:,[0]] = 2.0
+ assert_array_equal(x, array([[[2.0]]]))
- def check_tuple(self):
- x = ones((1,1))
- x[:,(0,)] = 2.0
- assert_array_equal(x, array([[2.0]]))
- x = ones((1,1,1))
- x[:,:,(0,)] = 2.0
- assert_array_equal(x, array([[[2.0]]]))
+ def check_tuple(self):
+ x = ones((1,1))
+ x[:,(0,)] = 2.0
+ assert_array_equal(x, array([[2.0]]))
+ x = ones((1,1,1))
+ x[:,:,(0,)] = 2.0
+ assert_array_equal(x, array([[[2.0]]]))
class test_string_compare(NumpyTestCase):
def check_string(self):
@@ -309,8 +308,8 @@ class test_string_compare(NumpyTestCase):
assert_array_equal(g1 != g2, [g1[i] != g2[i] for i in [0,1,2]])
assert_array_equal(g1 <= g2, [g1[i] <= g2[i] for i in [0,1,2]])
assert_array_equal(g1 >= g2, [g1[i] >= g2[i] for i in [0,1,2]])
- assert_array_equal(g1 < g2, [g1[i] < g2[i] for i in [0,1,2]])
- assert_array_equal(g1 > g2, [g1[i] > g2[i] for i in [0,1,2]])
+ assert_array_equal(g1 < g2, [g1[i] < g2[i] for i in [0,1,2]])
+ assert_array_equal(g1 > g2, [g1[i] > g2[i] for i in [0,1,2]])
def check_mixed(self):
g1 = array(["spam","spa","spammer","and eggs"])
@@ -321,7 +320,7 @@ class test_string_compare(NumpyTestCase):
assert_array_equal(g1 > g2, [x > g2 for x in g1])
assert_array_equal(g1 <= g2, [x <= g2 for x in g1])
assert_array_equal(g1 >= g2, [x >= g2 for x in g1])
-
+
def check_unicode(self):
g1 = array([u"This",u"is",u"example"])
@@ -330,8 +329,8 @@ class test_string_compare(NumpyTestCase):
assert_array_equal(g1 != g2, [g1[i] != g2[i] for i in [0,1,2]])
assert_array_equal(g1 <= g2, [g1[i] <= g2[i] for i in [0,1,2]])
assert_array_equal(g1 >= g2, [g1[i] >= g2[i] for i in [0,1,2]])
- assert_array_equal(g1 < g2, [g1[i] < g2[i] for i in [0,1,2]])
- assert_array_equal(g1 > g2, [g1[i] > g2[i] for i in [0,1,2]])
+ assert_array_equal(g1 < g2, [g1[i] < g2[i] for i in [0,1,2]])
+ assert_array_equal(g1 > g2, [g1[i] > g2[i] for i in [0,1,2]])
class test_argmax(NumpyTestCase):
@@ -339,10 +338,10 @@ class test_argmax(NumpyTestCase):
a = random.normal(0,1,(4,5,6,7,8))
for i in xrange(a.ndim):
amax = a.max(i)
- aargmax = a.argmax(i)
+ aargmax = a.argmax(i)
axes = range(a.ndim)
axes.remove(i)
- assert all(amax == aargmax.choose(*a.transpose(i,*axes)))
+ assert all(amax == aargmax.choose(*a.transpose(i,*axes)))
class test_newaxis(NumpyTestCase):
def check_basic(self):
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index ea2486972..7242d17d0 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -8,7 +8,7 @@ class Vec:
def __init__(self,sequence=None):
if sequence is None:
sequence=[]
- self.array=array(sequence)
+ self.array=array(sequence)
def __add__(self,other):
out=Vec()
out.array=self.array+other.array
@@ -118,7 +118,7 @@ class test_dot(NumpyTestCase):
b2 = rand(1,1)
c1 = dot(b1,b2)
c2 = dot_(b1,b2)
- assert_almost_equal(c1, c2, decimal=self.N)
+ assert_almost_equal(c1, c2, decimal=self.N)
def check_all(self):
dims = [(),(1,),(1,1)]
@@ -196,14 +196,14 @@ class test_seterr(NumpyTestCase):
self.fail()
seterr(divide='ignore')
array([1.]) / array([0.])
-
-
+
+
class test_fromiter(NumpyTestCase):
-
+
def makegen(self):
for x in xrange(24):
yield x**2
-
+
def test_types(self):
ai32 = fromiter(self.makegen(), int32)
ai64 = fromiter(self.makegen(), int64)
@@ -247,7 +247,7 @@ class test_binary_repr(NumpyTestCase):
def test_large(self):
assert_equal(binary_repr(10736848),'101000111101010011010000')
-
+
import sys
if sys.version_info[:2] >= (2, 5):
set_local_path()
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
index ae52f8603..b6a7f6202 100644
--- a/numpy/core/tests/test_numerictypes.py
+++ b/numpy/core/tests/test_numerictypes.py
@@ -50,7 +50,7 @@ Ndescr = [
('z2', 'b1')]),
('color', 'S2'),
('info', [
- ('Name', 'U8'),
+ ('Name', 'U8'),
('Value', 'c16')]),
('y', 'f8', (2, 2)),
('z', 'u1')]
@@ -333,7 +333,7 @@ class test_read_values_nested_multiple(read_values_nested, NumpyTestCase):
class test_empty_field(NumpyTestCase):
def check_assign(self):
- a = numpy.arange(10, dtype=numpy.float32)
+ a = numpy.arange(10, dtype=numpy.float32)
a.dtype = [("int", "<0i4"),("float", "<2f4")]
assert(a['int'].shape == (5,0))
assert(a['float'].shape == (5,2))
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index 078114dae..1839874a5 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -1,4 +1,3 @@
-
from numpy.testing import *
set_package_path()
import numpy.core.umath as ncu
@@ -11,7 +10,7 @@ types = [N.bool_, N.byte, N.ubyte, N.short, N.ushort, N.intc, N.uintc,
N.single, N.double, N.longdouble, N.csingle,
N.cdouble, N.clongdouble]
-# This compares scalarmath against ufuncs.
+# This compares scalarmath against ufuncs.
class test_types(NumpyTestCase):
def check_types(self, level=1):
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 13a1ce31e..37d361db9 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -1,4 +1,3 @@
-
from numpy.testing import *
set_package_path()
from numpy.core.umath import minimum, maximum, exp
@@ -167,7 +166,7 @@ class _test_complex_real(NumpyTestCase):
def setUp(self):
self.x = 0.52
self.z = self.x+0j
- self.funcs = ['arcsin', 'arccos', 'arctan', 'arcsinh', 'arccosh',
+ self.funcs = ['arcsin', 'arccos', 'arctan', 'arcsinh', 'arccosh',
'arctanh', 'sin', 'cos', 'tan', 'exp', 'log', 'sqrt',
'log10']
def test_it(self):