diff options
| author | cookedm <cookedm@localhost> | 2006-03-10 21:31:27 +0000 |
|---|---|---|
| committer | cookedm <cookedm@localhost> | 2006-03-10 21:31:27 +0000 |
| commit | bf57380caa818b73a4c41409de6ff260425f9bb6 (patch) | |
| tree | b2c42e0fde172de5def0c91811845808c00e296e /numpy/lib | |
| parent | f2db317c1fad63f1c85944ba8443b465e32774dc (diff) | |
| download | numpy-bf57380caa818b73a4c41409de6ff260425f9bb6.tar.gz | |
Run reindent.py (script distributed with Python) over the source to remove extraneous whitespace
Diffstat (limited to 'numpy/lib')
| -rw-r--r-- | numpy/lib/__init__.py | 2 | ||||
| -rw-r--r-- | numpy/lib/arraysetops.py | 4 | ||||
| -rw-r--r-- | numpy/lib/convertcode.py | 9 | ||||
| -rw-r--r-- | numpy/lib/function_base.py | 26 | ||||
| -rw-r--r-- | numpy/lib/getlimits.py | 1 | ||||
| -rw-r--r-- | numpy/lib/index_tricks.py | 13 | ||||
| -rw-r--r-- | numpy/lib/info.py | 6 | ||||
| -rw-r--r-- | numpy/lib/shape_base.py | 32 | ||||
| -rw-r--r-- | numpy/lib/tests/test_arraysetops.py | 2 | ||||
| -rw-r--r-- | numpy/lib/tests/test_function_base.py | 126 | ||||
| -rw-r--r-- | numpy/lib/tests/test_shape_base.py | 6 | ||||
| -rw-r--r-- | numpy/lib/tests/test_twodim_base.py | 2 | ||||
| -rw-r--r-- | numpy/lib/tests/test_type_check.py | 46 | ||||
| -rw-r--r-- | numpy/lib/twodim_base.py | 12 | ||||
| -rw-r--r-- | numpy/lib/type_check.py | 8 | ||||
| -rw-r--r-- | numpy/lib/ufunclike.py | 1 | ||||
| -rw-r--r-- | numpy/lib/utils.py | 8 |
17 files changed, 149 insertions, 155 deletions
diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index a7de2e13f..f962b13b7 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -31,5 +31,5 @@ __all__ += utils.__all__ __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 d1690d7d1..5b88acd6c 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 0c5a0833b..38504d5a2 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 e44e37027..e4802f544 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 @@ class vectorize(object): 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 776e2550c..7c677071d 100644 --- a/numpy/lib/getlimits.py +++ b/numpy/lib/getlimits.py @@ -117,4 +117,3 @@ if __name__ == '__main__': 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 15aae9949..96726f57c 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 @@ class nd_grid(object): 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 @@ class ndindex(object): 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 @@ class _index_expression_class(object): index_exp = _index_expression_class() # End contribution from Konrad. - diff --git a/numpy/lib/info.py b/numpy/lib/info.py index bf6878b73..0944fa9b5 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 @@ isneginf -- Tests for negative infinity ---| 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 @@ flipud -- 2D array with rows flipped 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 cbcfa9e70..b6ace7dd8 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 1c013619b..22f0a043c 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -129,7 +129,7 @@ class test_aso( ScipyTestCase ): 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 41cdf45b4..592bd99e7 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -22,7 +22,7 @@ class test_any(ScipyTestCase): 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 @@ class test_average(ScipyTestCase): 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 @@ class test_prod(ScipyTestCase): 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 @@ class test_extins(ScipyTestCase): 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 @@ class test_vectorize(ScipyTestCase): 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))<pi)) - + 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))<pi)) + class test_filterwindows(ScipyTestCase): - def check_hanning(self): - #check symmetry - w=hanning(10) - assert_array_almost_equal(w,flipud(w),7) - #check known value - assert_almost_equal(sum(w),4.500,4) - - def check_hamming(self): - #check symmetry - w=hamming(10) - assert_array_almost_equal(w,flipud(w),7) - #check known value - assert_almost_equal(sum(w),4.9400,4) - - def check_bartlett(self): - #check symmetry - w=bartlett(10) - assert_array_almost_equal(w,flipud(w),7) - #check known value - assert_almost_equal(sum(w),4.4444,4) - - def check_blackman(self): - #check symmetry - w=blackman(10) - assert_array_almost_equal(w,flipud(w),7) - #check known value - assert_almost_equal(sum(w),3.7800,4) - + def check_hanning(self): + #check symmetry + w=hanning(10) + assert_array_almost_equal(w,flipud(w),7) + #check known value + assert_almost_equal(sum(w),4.500,4) + + def check_hamming(self): + #check symmetry + w=hamming(10) + assert_array_almost_equal(w,flipud(w),7) + #check known value + assert_almost_equal(sum(w),4.9400,4) + + def check_bartlett(self): + #check symmetry + w=bartlett(10) + assert_array_almost_equal(w,flipud(w),7) + #check known value + assert_almost_equal(sum(w),4.4444,4) + + def check_blackman(self): + #check symmetry + w=blackman(10) + assert_array_almost_equal(w,flipud(w),7) + #check known value + assert_almost_equal(sum(w),3.7800,4) + class test_trapz(ScipyTestCase): - def check_simple(self): - r=trapz(exp(-1.0/2*(arange(-10,10,.1))**2)/sqrt(2*pi),dx=0.1) - #check integral of normal equals 1 - assert_almost_equal(sum(r),1,7) - + def check_simple(self): + r=trapz(exp(-1.0/2*(arange(-10,10,.1))**2)/sqrt(2*pi),dx=0.1) + #check integral of normal equals 1 + assert_almost_equal(sum(r),1,7) + class test_sinc(ScipyTestCase): - def check_simple(self): - assert(sinc(0)==1) - w=sinc(linspace(-1,1,100)) - #check symmetry - assert_array_almost_equal(w,flipud(w),7) + def check_simple(self): + assert(sinc(0)==1) + w=sinc(linspace(-1,1,100)) + #check symmetry + assert_array_almost_equal(w,flipud(w),7) class test_histogram(ScipyTestCase): - def check_simple(self): - n=100 - v=rand(n) - (a,b)=histogram(v) - #check if the sum of the bins equals the number of samples - assert(sum(a)==n) - #check that the bin counts are evenly spaced when the data is from a linear function - (a,b)=histogram(linspace(0,10,100)) - assert(all(a==10)) - - - - - + def check_simple(self): + n=100 + v=rand(n) + (a,b)=histogram(v) + #check if the sum of the bins equals the number of samples + assert(sum(a)==n) + #check that the bin counts are evenly spaced when the data is from a linear function + (a,b)=histogram(linspace(0,10,100)) + assert(all(a==10)) + + + + + def compare_results(res,desired): for i in range(len(desired)): assert_array_equal(res[i],desired[i]) diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index 11cf8fc91..953f9b277 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -118,7 +118,7 @@ class test_array_split(ScipyTestCase): desired = [array([]),arange(0,5),arange(5,7),arange(7,10), array([]),array([])] compare_results(res,desired) - + class test_split(ScipyTestCase): """* This function is essentially the same as array_split, except that it test if splitting will result in an @@ -131,7 +131,7 @@ class test_split(ScipyTestCase): compare_results(res,desired) def check_unequal_split(self): - a = arange(10) + a = arange(10) try: res = split(a,3) assert(0) # should raise an error @@ -353,7 +353,7 @@ class test_squeeze(ScipyTestCase): assert_array_equal(squeeze(a),reshape(a,(20,10,10))) assert_array_equal(squeeze(b),reshape(b,(20,10,20))) assert_array_equal(squeeze(c),reshape(c,(20,10))) - + # Utility def compare_results(res,desired): diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py index e32f29478..4e5cdb54a 100644 --- a/numpy/lib/tests/test_twodim_base.py +++ b/numpy/lib/tests/test_twodim_base.py @@ -43,7 +43,7 @@ class test_eye(ScipyTestCase): [0,0,0]])) assert_equal(eye(3,4),array([[1,0,0,0], [0,1,0,0], - [0,0,1,0]])) + [0,0,1,0]])) def check_diag2d(self): assert_equal(eye(3,4,k=2),array([[0,0,1,0], [0,0,0,1], diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index 5d026a9f9..6d93989e5 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -10,7 +10,7 @@ restore_path() def assert_all(x): assert(all(x)), x - + class test_mintypecode(ScipyTestCase): def check_default_1(self): @@ -59,7 +59,7 @@ class test_mintypecode(ScipyTestCase): assert_equal(mintypecode('idF'),'D') #assert_equal(mintypecode('idF',savespace=1),'F') assert_equal(mintypecode('idD'),'D') - + class test_isscalar(ScipyTestCase): def check_basic(self): assert(isscalar(3)) @@ -125,12 +125,12 @@ class test_isnan(ScipyTestCase): def check_goodvalues(self): z = array((-1.,0.,1.)) res = isnan(z) == 0 - assert_all(alltrue(res)) - def check_posinf(self): + assert_all(alltrue(res)) + def check_posinf(self): assert_all(isnan(array((1.,))/0.) == 0) - def check_neginf(self): + def check_neginf(self): assert_all(isnan(array((-1.,))/0.) == 0) - def check_ind(self): + def check_ind(self): assert_all(isnan(array((0.,))/0.) == 1) #def check_qnan(self): log(-1) return pi*j now # assert_all(isnan(log(-1.)) == 1) @@ -140,19 +140,19 @@ class test_isnan(ScipyTestCase): assert_all(isnan(1+1j) == 0) def check_complex1(self): assert_all(isnan(array(0+0j)/0.) == 1) - + class test_isfinite(ScipyTestCase): def check_goodvalues(self): z = array((-1.,0.,1.)) res = isfinite(z) == 1 - assert_all(alltrue(res)) - def check_posinf(self): + assert_all(alltrue(res)) + def check_posinf(self): assert_all(isfinite(array((1.,))/0.) == 0) - def check_neginf(self): + def check_neginf(self): assert_all(isfinite(array((-1.,))/0.) == 0) - def check_ind(self): + def check_ind(self): assert_all(isfinite(array((0.,))/0.) == 0) - #def check_qnan(self): + #def check_qnan(self): # assert_all(isfinite(log(-1.)) == 0) def check_integer(self): assert_all(isfinite(1) == 1) @@ -160,23 +160,23 @@ class test_isfinite(ScipyTestCase): assert_all(isfinite(1+1j) == 1) def check_complex1(self): assert_all(isfinite(array(1+1j)/0.) == 0) - + class test_isinf(ScipyTestCase): def check_goodvalues(self): z = array((-1.,0.,1.)) res = isinf(z) == 0 - assert_all(alltrue(res)) - def check_posinf(self): + assert_all(alltrue(res)) + def check_posinf(self): assert_all(isinf(array((1.,))/0.) == 1) - def check_posinf_scalar(self): + def check_posinf_scalar(self): assert_all(isinf(array(1.,)/0.) == 1) - def check_neginf(self): + def check_neginf(self): assert_all(isinf(array((-1.,))/0.) == 1) - def check_neginf_scalar(self): + def check_neginf_scalar(self): assert_all(isinf(array(-1.)/0.) == 1) - def check_ind(self): + def check_ind(self): assert_all(isinf(array((0.,))/0.) == 0) - #def check_qnan(self): + #def check_qnan(self): # assert_all(isinf(log(-1.)) == 0) # assert_all(isnan(log(-1.)) == 1) @@ -216,12 +216,12 @@ class test_nan_to_num(ScipyTestCase): v = 1+1j v += array(-1+1.j)/0. vals = nan_to_num(v) - assert_all(isfinite(vals)) - #assert_all(vals.imag > 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 39a908268..2f8069a8b 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -9,8 +9,8 @@ from numpy.core.numeric import * 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 e72a757e0..661f63939 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 c291c7e9c..1084a03e7 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 7e20c3c7a..e64f5d978 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()]) |
