diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/_import_tools.py | 4 | ||||
-rw-r--r-- | numpy/add_newdocs.py | 10 | ||||
-rw-r--r-- | numpy/core/code_generators/generate_ufunc_api.py | 2 | ||||
-rw-r--r-- | numpy/core/defmatrix.py | 16 | ||||
-rw-r--r-- | numpy/core/numeric.py | 8 | ||||
-rw-r--r-- | numpy/core/records.py | 18 | ||||
-rw-r--r-- | numpy/core/scons_support.py | 8 | ||||
-rw-r--r-- | numpy/core/setup.py | 8 | ||||
-rw-r--r-- | numpy/core/setupscons.py | 8 | ||||
-rw-r--r-- | numpy/distutils/command/scons.py | 20 | ||||
-rw-r--r-- | numpy/distutils/misc_util.py | 10 | ||||
-rw-r--r-- | numpy/doc/example.py | 2 | ||||
-rw-r--r-- | numpy/fft/setupscons.py | 2 | ||||
-rw-r--r-- | numpy/lib/arraysetops.py | 2 | ||||
-rw-r--r-- | numpy/lib/format.py | 5 | ||||
-rw-r--r-- | numpy/lib/io.py | 50 | ||||
-rw-r--r-- | numpy/lib/scimath.py | 28 | ||||
-rw-r--r-- | numpy/lib/setupscons.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_format.py | 28 | ||||
-rw-r--r-- | numpy/lib/utils.py | 16 | ||||
-rw-r--r-- | numpy/linalg/linalg.py | 94 | ||||
-rw-r--r-- | numpy/linalg/setupscons.py | 2 | ||||
-rw-r--r-- | numpy/random/setupscons.py | 8 |
23 files changed, 170 insertions, 181 deletions
diff --git a/numpy/_import_tools.py b/numpy/_import_tools.py index d289a752b..4053057ab 100644 --- a/numpy/_import_tools.py +++ b/numpy/_import_tools.py @@ -152,10 +152,10 @@ class PackageLoader: Parameters ---------- - *packges : arg-tuple + *packges : arg-tuple the names (one or more strings) of all the modules one wishes to load into the top-level namespace. - verbose= : integer + verbose= : integer verbosity level [default: -1]. verbose=-1 will suspend also warnings. force= : bool diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index d727df234..7955beca7 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1,7 +1,7 @@ # This is only meant to add docs to # objects defined in C-extension modules. # The purpose is to allow easier editing of the -# docstrings without requiring a re-compile. +# docstrings without requiring a re-compile. from lib import add_newdoc add_newdoc('numpy.core','dtype', @@ -238,7 +238,7 @@ add_newdoc('numpy.core.multiarray','fromfile', open file object or string containing file name. dtype : data-type data type of the returned array - count : int + count : int number of items to read (-1 mean 'all') sep : string separater between items if file is a text file (default "") @@ -1107,8 +1107,8 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('round', is done if the array is not of float type and 'decimals' is >= 0. The keyword 'out' may be used to specify a different array to hold the - result rather than the default new array. If the type of the array - specified by 'out' differs from that of 'a', the result is cast to the + result rather than the default new array. If the type of the array + specified by 'out' differs from that of 'a', the result is cast to the new type, otherwise the original type is kept. Floats round to floats by default. @@ -1209,7 +1209,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('sort', |'heapsort' | 3 | O(n*log(n)) | 0 | no | |------------------------------------------------------| - All the sort algorithms make temporary copies of the data when the sort is + All the sort algorithms make temporary copies of the data when the sort is not along the last axis. Consequently, sorts along the last axis are faster and use less space than sorts along other axis. """)) diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index fa858b207..a7afc5aaa 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -71,7 +71,7 @@ void *PyUFunc_API[] = { def generate_api(output_dir, force=False): basename = 'ufunc_api' - + h_file = os.path.join(output_dir, '__%s.h' % basename) c_file = os.path.join(output_dir, '__%s.c' % basename) d_file = os.path.join(output_dir, '%s.txt' % basename) diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py index 7e1cacfce..c3f57efdf 100644 --- a/numpy/core/defmatrix.py +++ b/numpy/core/defmatrix.py @@ -51,16 +51,16 @@ def asmatrix(data, dtype=None): class matrix(N.ndarray): """mat = matrix(data, dtype=None, copy=True) - Returns a matrix from an array-like object, or a string of + Returns a matrix from an array-like object, or a string of data. A matrix is a specialized 2-d array that retains it's 2-d nature through operations and where '*' means matrix - multiplication and '**' means matrix power. + multiplication and '**' means matrix power. Parameters ---------- data : array-like or string - If data is a string, then interpret the string as a matrix - with commas or spaces separating columns and semicolons + If data is a string, then interpret the string as a matrix + with commas or spaces separating columns and semicolons separating rows. If data is array-like than convert the array to a matrix. dtype : data-type @@ -273,7 +273,7 @@ class matrix(N.ndarray): the flattened array by default, otherwise over the specified axis. Parameters - ---------- + ---------- axis : integer Axis along which the means are computed. The default is to compute the standard deviation of the flattened array. @@ -289,7 +289,7 @@ class matrix(N.ndarray): cast if necessary. Returns - ------- + ------- mean : The return type varies, see above. A new array holding the result is returned unless out is specified, in which case a reference to out is returned. @@ -342,7 +342,7 @@ class matrix(N.ndarray): mean : average Notes - ----- + ----- The standard deviation is the square root of the average of the squared deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The computed standard @@ -362,7 +362,7 @@ class matrix(N.ndarray): ---------- axis : integer Axis along which the variance is computed. The default is to - compute the variance of the flattened array. + compute the variance of the flattened array. dtype : data-type Type to use in computing the variance. For arrays of integer type the default is float32, for arrays of float types it is diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 312db3510..00c70256f 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -149,7 +149,7 @@ def asfortranarray(a, dtype=None): def require(a, dtype=None, requirements=None): """Return an ndarray of the provided type that satisfies requirements. - + This function is useful to be sure that an array with the correct flags is returned for passing to compiled code (perhaps through ctypes). @@ -160,7 +160,7 @@ def require(a, dtype=None, requirements=None): dtype : data-type The required data-type (None is the default data-type -- float64) requirements : list of strings - The requirements list can be any of the + The requirements list can be any of the 'ENSUREARRAY' ('E') - ensure that a base-class ndarray 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array @@ -169,7 +169,7 @@ def require(a, dtype=None, requirements=None): 'OWNDATA' ('O') - ensure an array that owns its own data The returned array will be guaranteed to have the listed requirements - by making a copy if needed. + by making a copy if needed. """ if requirements is None: requirements = [] @@ -276,7 +276,7 @@ def vdot(a, b): try: # importing this changes the dot function for basic 4 types # to blas-optimized versions. - from _dotblas import dot, vdot, inner, alterdot, restoredot + from _dotblas import dot, vdot, inner, alterdot, restoredot except ImportError: def alterdot(): "Does Nothing" diff --git a/numpy/core/records.py b/numpy/core/records.py index 2067ed059..f9826376e 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -45,9 +45,9 @@ def find_duplicate(list): class format_parser: """Class to convert formats, names, titles description to a dtype - After constructing the format_parser object, the dtype attribute is + After constructing the format_parser object, the dtype attribute is the converted data-type. - + dtype = format_parser(formats, names, titles).dtype Parameters @@ -59,18 +59,18 @@ class format_parser: comma-separated field names --- 'col1, col2, col3' list or tuple of field names titles : sequence - sequence of title strings or unicode + sequence of title strings or unicode aligned : bool align the fields by padding as the C-compiler would - byteorder : - If specified, all the fields will be changed to the + byteorder : + If specified, all the fields will be changed to the provided byteorder. Otherwise, the default byteorder is used. Returns ------- object - A Python object whose dtype attribute is a data-type. + A Python object whose dtype attribute is a data-type. """ def __init__(self, formats, names, titles, aligned=False, byteorder=None): self._parseFormats(formats, aligned) @@ -227,9 +227,9 @@ class recarray(ndarray): by the *formats*, *names*, *titles*, *aligned*, and *byteorder* keywords. buf : [buffer] or None If this is None, then a new array is created of the given shape and data-type - If this is an object exposing the buffer interface, then the array will - use the memory from an existing buffer. In this case, the *offset* and - *strides* keywords can also be used. + If this is an object exposing the buffer interface, then the array will + use the memory from an existing buffer. In this case, the *offset* and + *strides* keywords can also be used. See Also -------- diff --git a/numpy/core/scons_support.py b/numpy/core/scons_support.py index 2c08d648f..bb4721744 100644 --- a/numpy/core/scons_support.py +++ b/numpy/core/scons_support.py @@ -30,12 +30,12 @@ def split_ext(string): # Ufunc and multiarray API generators #------------------------------------ def do_generate_array_api(target, source, env): - nowrap_do_generate_array_api([str(i) for i in target], + nowrap_do_generate_array_api([str(i) for i in target], [str(i) for i in source]) return 0 def do_generate_ufunc_api(target, source, env): - nowrap_do_generate_ufunc_api([str(i) for i in target], + nowrap_do_generate_ufunc_api([str(i) for i in target], [str(i) for i in source]) return 0 @@ -74,7 +74,7 @@ def generate_from_template_emitter(target, source, env): base, ext = split_ext(pbasename(str(source[0]))) t = pjoin(pdirname(str(target[0])), base) return ([t], source) - + #---------------- # umath generator #---------------- @@ -92,7 +92,7 @@ def generate_umath(target, source, env): def generate_umath_emitter(target, source, env): t = str(target[0]) + '.c' return ([t], source) - + #----------------------------------------- # Other functions related to configuration #----------------------------------------- diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 869b6926f..f06762445 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -175,7 +175,7 @@ def configuration(parent_package='',top_path=None): " python-dev|python-devel." % (python_h) config.numpy_include_dirs - result = config_cmd.try_run(testcode, + result = config_cmd.try_run(testcode, include_dirs = [python_include] + \ config.numpy_include_dirs, library_dirs = default_lib_dirs) @@ -190,7 +190,7 @@ def configuration(parent_package='',top_path=None): target_f.close() print 'EOF' return target - + def generate_api_func(module_name): def generate_api(ext, build_dir): script = join(codegen_dir, module_name + '.py') @@ -405,9 +405,9 @@ def generate_numpyconfig_code(target): #include "config.h" int main() -{ +{ FILE* f; - + f = fopen("%s", "w"); if (f == NULL) { return -1; diff --git a/numpy/core/setupscons.py b/numpy/core/setupscons.py index 7118b1dab..857491b88 100644 --- a/numpy/core/setupscons.py +++ b/numpy/core/setupscons.py @@ -25,10 +25,10 @@ def configuration(parent_package='',top_path=None): join('code_generators', 'multiarray_api_order.txt'), join('code_generators', 'ufunc_api_order.txt')] core_src = [join('src', basename(i)) for i in glob.glob(join(local_dir, - 'src', + 'src', '*.c'))] core_src += [join('src', basename(i)) for i in glob.glob(join(local_dir, - 'src', + 'src', '*.src'))] source_files = dot_blas_src + api_definition + core_src + \ @@ -54,7 +54,7 @@ def configuration(parent_package='',top_path=None): incl_dir = os.path.dirname(target) if incl_dir not in config.numpy_include_dirs: config.numpy_include_dirs.append(incl_dir) - config.add_data_files((header_dir, target)) + config.add_data_files((header_dir, target)) def add_array_api(): scons_build_dir = get_scons_build_dir() @@ -83,7 +83,7 @@ def configuration(parent_package='',top_path=None): add_ufunc_api() config.add_configres() - config.add_sconscript('SConstruct', + config.add_sconscript('SConstruct', post_hook = add_generated_files, source_files = source_files) diff --git a/numpy/distutils/command/scons.py b/numpy/distutils/command/scons.py index 43fe8178f..9bb61ae07 100644 --- a/numpy/distutils/command/scons.py +++ b/numpy/distutils/command/scons.py @@ -14,21 +14,21 @@ from numpy.distutils.misc_util import get_numpy_include_dirs def get_scons_build_dir(): """Return the top path where everything produced by scons will be put. - + The path is relative to the top setup.py""" from numscons import get_scons_build_dir return get_scons_build_dir() def get_scons_configres_dir(): """Return the top path where everything produced by scons will be put. - + The path is relative to the top setup.py""" from numscons import get_scons_configres_dir return get_scons_configres_dir() def get_scons_configres_filename(): """Return the top path where everything produced by scons will be put. - + The path is relative to the top setup.py""" from numscons import get_scons_configres_filename return get_scons_configres_filename() @@ -101,7 +101,7 @@ def dist2sconscxx(compiler): def get_compiler_executable(compiler): """For any give CCompiler instance, this gives us the name of C compiler (the actual executable). - + NOTE: does NOT work with FCompiler instances.""" # Geez, why does distutils has no common way to get the compiler name... if compiler.compiler_type == 'msvc': @@ -112,7 +112,7 @@ def get_compiler_executable(compiler): # hardcoded string #compiler.initialize() #print compiler.cc - return 'cl.exe' + return 'cl.exe' else: return compiler.compiler[0] @@ -124,7 +124,7 @@ def get_f77_compiler_executable(compiler): def get_cxxcompiler_executable(compiler): """For any give CCompiler instance, this gives us the name of CXX compiler (the actual executable). - + NOTE: does NOT work with FCompiler instances.""" # Geez, why does distutils has no common way to get the compiler name... if compiler.compiler_type == 'msvc': @@ -135,7 +135,7 @@ def get_cxxcompiler_executable(compiler): # hardcoded string #compiler.initialize() #print compiler.cc - return 'cl.exe' + return 'cl.exe' else: return compiler.compiler_cxx[0] @@ -181,7 +181,7 @@ class scons(old_build_ext): # XXX: add an option to the scons command for configuration (auto/force/cache). description = "Scons builder" user_options = old_build_ext.user_options + \ - [('jobs=', None, + [('jobs=', None, "specify number of worker threads when executing scons"), ('scons-tool-path=', None, 'specify additional path '\ '(absolute) to look for scons tools'), @@ -239,11 +239,11 @@ class scons(old_build_ext): self.scons_compiler = dist2sconscc(distutils_compiler) self.scons_compiler_path = protect_path(get_tool_path(distutils_compiler)) except DistutilsPlatformError, e: - if not self._bypass_distutils_cc: + if not self._bypass_distutils_cc: raise e else: self.scons_compiler = compiler_type - + # We do the same for the fortran compiler ... fcompiler_type = self.fcompiler from numpy.distutils.fcompiler import new_fcompiler diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index a698ae415..acc2f5ebf 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1192,8 +1192,8 @@ class Configuration(object): full_source_files.extend([self.paths(i)[0] for i in source_files]) if dist is not None: - dist.scons_data.append((fullsconsname, - pre_hook, + dist.scons_data.append((fullsconsname, + pre_hook, post_hook, full_source_files, parent_name)) @@ -1203,8 +1203,8 @@ class Configuration(object): # options in distutils command. dist.add_extension('', sources = []) else: - self.scons_data.append((fullsconsname, - pre_hook, + self.scons_data.append((fullsconsname, + pre_hook, post_hook, full_source_files, parent_name)) @@ -1214,7 +1214,7 @@ class Configuration(object): def add_configres(self): from numscons import get_scons_configres_dir, get_scons_configres_filename - file = os.path.join(get_scons_configres_dir(), self.local_path, + file = os.path.join(get_scons_configres_dir(), self.local_path, get_scons_configres_filename()) def add_scripts(self,*files): diff --git a/numpy/doc/example.py b/numpy/doc/example.py index 32a7e6602..bfc0cf338 100644 --- a/numpy/doc/example.py +++ b/numpy/doc/example.py @@ -53,7 +53,7 @@ def foo(var1, var2, long_var_name='hi') : Explanation See Also - -------- + -------- otherfunc : relationship (optional) newfunc : relationship (optional) diff --git a/numpy/fft/setupscons.py b/numpy/fft/setupscons.py index 2fe9509e8..54551b0a3 100644 --- a/numpy/fft/setupscons.py +++ b/numpy/fft/setupscons.py @@ -4,7 +4,7 @@ def configuration(parent_package = '', top_path = None): config.add_data_dir('tests') - config.add_sconscript('SConstruct', + config.add_sconscript('SConstruct', source_files = ['fftpack_litemodule.c', 'fftpack.c', 'fftpack.h']) diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 1d99f7a97..f8304cced 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -207,7 +207,7 @@ def setmember1d( ar1, ar2 ): b1 = nm.zeros( ar1.shape, dtype = nm.int8 ) b2 = nm.ones( ar2.shape, dtype = nm.int8 ) tt = nm.concatenate( (b1, b2) ) - + # We need this to be a stable sort, so always use 'mergesort' here. The # values from the first array should always come before the values from the # second array. diff --git a/numpy/lib/format.py b/numpy/lib/format.py index bb58c5c61..10d6d27b7 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -227,7 +227,7 @@ def read_array_header_1_0(fp): raise ValueError("Header does not contain the correct keys: %r" % (keys,)) # Sanity-check the values. - if (not isinstance(d['shape'], tuple) or + if (not isinstance(d['shape'], tuple) or not numpy.all([isinstance(x, int) for x in d['shape']])): raise ValueError("shape is not valid: %r" % (d['shape'],)) if not isinstance(d['fortran_order'], bool): @@ -407,6 +407,3 @@ def open_memmap(filename, mode='r+', dtype=None, shape=None, mode=mode, offset=offset) return marray - - - diff --git a/numpy/lib/io.py b/numpy/lib/io.py index 077bc797b..aa832487f 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -19,8 +19,8 @@ from _compiled_base import packbits, unpackbits _file = file class BagObj(object): - """A simple class that converts attribute lookups to - getitems on the class passed in. + """A simple class that converts attribute lookups to + getitems on the class passed in. """ def __init__(self, obj): self._obj = obj @@ -31,8 +31,8 @@ class BagObj(object): raise AttributeError, key class NpzFile(object): - """A dictionary-like object with lazy-loading of files in the zipped - archive provided on construction. + """A dictionary-like object with lazy-loading of files in the zipped + archive provided on construction. The arrays and file strings are lazily loaded on either getitem access using obj['key'] or attribute lookup using obj.f.key @@ -54,13 +54,13 @@ class NpzFile(object): def __getitem__(self, key): # FIXME: This seems like it will copy strings around - # more than is strictly necessary. The zipfile + # more than is strictly necessary. The zipfile # will read the string and then # the format.read_array will copy the string - # to another place in memory. - # It would be better if the zipfile could read + # to another place in memory. + # It would be better if the zipfile could read # (or at least uncompress) the data - # directly into the array memory. + # directly into the array memory. member = 0 if key in self._files: member = 1 @@ -90,21 +90,21 @@ def load(file, memmap=False): memmap : bool If true, then memory-map the .npy file or unzip the .npz file into a temporary directory and memory-map each component - This has no effect for a pickle. + This has no effect for a pickle. Returns ------- result : array, tuple, dict, etc. - data stored in the file. + data stored in the file. If file contains pickle data, then whatever is stored in the pickle is returned. - If the file is .npy file, then an array is returned. - If the file is .npz file, then a dictionary-like object is returned + If the file is .npy file, then an array is returned. + If the file is .npz file, then a dictionary-like object is returned which has a filename:array key:value pair for every file in the zip. Raises ------ - IOError + IOError """ if isinstance(file, type("")): fid = _file(file,"rb") @@ -124,7 +124,7 @@ def load(file, memmap=False): elif magic == format.MAGIC_PREFIX: # .npy file return format.read_array(fid) else: # Try a pickle - try: + try: return _cload(fid) except: raise IOError, \ @@ -133,8 +133,8 @@ def load(file, memmap=False): def save(file, arr): """Save an array to a binary file (a string or file-like object). - If the file is a string, then if it does not have the .npy extension, - it is appended and a file open. + If the file is a string, then if it does not have the .npy extension, + it is appended and a file open. Data is saved to the open file in NumPy-array format @@ -144,7 +144,7 @@ def save(file, arr): ... np.save('myfile', a) a = np.load('myfile.npy') - """ + """ if isinstance(file, str): if not file.endswith('.npy'): file = file + '.npy' @@ -158,15 +158,15 @@ def save(file, arr): def savez(file, *args, **kwds): """Save several arrays into an .npz file format which is a zipped-archive of arrays - - If keyword arguments are given, then filenames are taken from the keywords. - If arguments are passed in with no keywords, then stored file names are - arr_0, arr_1, etc. + + If keyword arguments are given, then filenames are taken from the keywords. + If arguments are passed in with no keywords, then stored file names are + arr_0, arr_1, etc. """ if isinstance(file, str): if not file.endswith('.npz'): - file = file + '.npz' + file = file + '.npz' namedict = kwds for i, val in enumerate(args): @@ -190,7 +190,7 @@ def savez(file, *args, **kwds): format.write_array(fid, np.asanyarray(val)) fid.close() zip.write(filename, arcname=fname) - + zip.close() for name in todel: os.remove(name) @@ -359,7 +359,3 @@ def savetxt(fname, X, fmt='%.18e',delimiter=' '): if origShape is not None: X.shape = origShape - - - - diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py index 429eac9c8..f35c87578 100644 --- a/numpy/lib/scimath.py +++ b/numpy/lib/scimath.py @@ -93,7 +93,7 @@ def _fix_real_lt_zero(x): """Convert `x` to complex if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). - + Parameters ---------- x : array_like @@ -119,7 +119,7 @@ def _fix_int_lt_zero(x): """Convert `x` to double if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). - + Parameters ---------- x : array_like @@ -145,7 +145,7 @@ def _fix_real_abs_gt_1(x): """Convert `x` to complex if it has real components x_i with abs(x_i)>1. Otherwise, output is just the array version of the input (via asarray). - + Parameters ---------- x : array_like @@ -203,7 +203,7 @@ def log(x): If x contains negative inputs, the answer is computed and returned in the complex domain. - + Parameters ---------- x : array_like @@ -221,7 +221,7 @@ def log(x): Negative arguments are correctly handled (recall that for negative arguments, the identity exp(log(z))==z does not hold anymore): - + >>> log(-math.exp(1)) == (1+1j*math.pi) True """ @@ -233,7 +233,7 @@ def log10(x): If x contains negative inputs, the answer is computed and returned in the complex domain. - + Parameters ---------- x : array_like @@ -263,7 +263,7 @@ def logn(n, x): If x contains negative inputs, the answer is computed and returned in the complex domain. - + Parameters ---------- x : array_like @@ -293,7 +293,7 @@ def log2(x): If x contains negative inputs, the answer is computed and returned in the complex domain. - + Parameters ---------- x : array_like @@ -307,7 +307,7 @@ def log2(x): (We set the printing precision so the example can be auto-tested) >>> import numpy as np; np.set_printoptions(precision=4) - + >>> log2([4,8]) array([ 2., 3.]) @@ -323,7 +323,7 @@ def power(x, p): If x contains negative values, it is converted to the complex domain. If p contains negative values, it is converted to floating point. - + Parameters ---------- x : array_like @@ -332,7 +332,7 @@ def power(x, p): Returns ------- array_like - + Examples -------- (We set the printing precision so the example can be auto-tested) @@ -357,7 +357,7 @@ def arccos(x): For real x with abs(x)<=1, this returns the principal value. If abs(x)>1, the complex arccos() is computed. - + Parameters ---------- x : array_like @@ -385,7 +385,7 @@ def arcsin(x): For real x with abs(x)<=1, this returns the principal value. If abs(x)>1, the complex arcsin() is computed. - + Parameters ---------- x : array_like @@ -414,7 +414,7 @@ def arctanh(x): For real x with abs(x)<=1, this returns the principal value. If abs(x)>1, the complex arctanh() is computed. - + Parameters ---------- x : array_like diff --git a/numpy/lib/setupscons.py b/numpy/lib/setupscons.py index ab0c304d3..4f31f6e8a 100644 --- a/numpy/lib/setupscons.py +++ b/numpy/lib/setupscons.py @@ -5,7 +5,7 @@ def configuration(parent_package='',top_path=None): config = Configuration('lib',parent_package,top_path) - config.add_sconscript('SConstruct', + config.add_sconscript('SConstruct', source_files = [join('src', '_compiled_base.c')]) config.add_data_dir('tests') diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 28e938f0f..e7b27ce94 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -21,9 +21,9 @@ Set up: ... np.complex128, ... object, ... ] - >>> + >>> >>> basic_arrays = [] - >>> + >>> >>> for scalar in scalars: ... for endian in '<>': ... dtype = np.dtype(scalar).newbyteorder(endian) @@ -36,20 +36,20 @@ Set up: ... basic.reshape((3,5)).T, ... basic.reshape((3,5))[::-1,::2], ... ]) - ... - >>> + ... + >>> >>> Pdescr = [ ... ('x', 'i4', (2,)), ... ('y', 'f8', (2, 2)), ... ('z', 'u1')] - >>> - >>> + >>> + >>> >>> PbufferT = [ ... ([3,2], [[6.,4.],[6.,4.]], 8), ... ([4,3], [[7.,5.],[7.,5.]], 9), ... ] - >>> - >>> + >>> + >>> >>> Ndescr = [ ... ('x', 'i4', (2,)), ... ('Info', [ @@ -68,14 +68,14 @@ Set up: ... ('Value', 'c16')]), ... ('y', 'f8', (2, 2)), ... ('z', 'u1')] - >>> - >>> + >>> + >>> >>> NbufferT = [ ... ([3,2], (6j, 6., ('nn', [6j,4j], [6.,4.], [1,2]), 'NN', True), 'cc', ('NN', 6j), [[6.,4.],[6.,4.]], 8), ... ([4,3], (7j, 7., ('oo', [7j,5j], [7.,5.], [2,1]), 'OO', False), 'dd', ('OO', 7j), [[7.,5.],[7.,5.]], 9), ... ] - >>> - >>> + >>> + >>> >>> record_arrays = [ ... np.array(PbufferT, dtype=np.dtype(Pdescr).newbyteorder('<')), ... np.array(NbufferT, dtype=np.dtype(Ndescr).newbyteorder('<')), @@ -111,7 +111,7 @@ Test the header writing. ... f = StringIO() ... format.write_array_header_1_0(f, arr) ... print repr(f.getvalue()) - ... + ... "F\x00{'descr': '|u1', 'fortran_order': False, 'shape': (0,)} \n" "F\x00{'descr': '|u1', 'fortran_order': False, 'shape': ()} \n" "F\x00{'descr': '|u1', 'fortran_order': False, 'shape': (15,)} \n" @@ -506,5 +506,3 @@ def test_read_version_1_0_bad_magic(): for magic in bad_version_magic + malformed_magic: f = StringIO(magic) yield raises(ValueError)(format.read_array), f - - diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index a3bdc743b..9c97a1fdf 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -106,7 +106,7 @@ def deprecate(func, oldname=None, newname=None): else: str1 = "%s is deprecated, use %s" % (oldname, newname), depdoc = '%s is DEPRECATED!! -- use %s instead' % (oldname, newname,) - + def newfunc(*args,**kwds): warnings.warn(str1, DeprecationWarning) return func(*args, **kwds) @@ -487,28 +487,28 @@ def source(object, output=sys.stdout): # * raise SyntaxError instead of a custom exception. class SafeEval(object): - + def visit(self, node, **kw): cls = node.__class__ meth = getattr(self,'visit'+cls.__name__,self.default) return meth(node, **kw) - + def default(self, node, **kw): raise SyntaxError("Unsupported source construct: %s" % node.__class__) - + def visitExpression(self, node, **kw): for child in node.getChildNodes(): return self.visit(child, **kw) - + def visitConst(self, node, **kw): return node.value def visitDict(self, node,**kw): return dict([(self.visit(k),self.visit(v)) for k,v in node.items]) - + def visitTuple(self, node, **kw): return tuple([self.visit(i) for i in node.nodes]) - + def visitList(self, node, **kw): return [self.visit(i) for i in node.nodes] @@ -578,5 +578,3 @@ def safe_eval(source): raise #----------------------------------------------------------------------------- - - diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 5b35f1b49..1ee2b9bf8 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -138,11 +138,11 @@ def _assertNonEmpty(*arrays): def tensorsolve(a, b, axes=None): """Solve the tensor equation a x = b for x - + It is assumed that all indices of x are summed over in the product, together with the rightmost indices of a, similarly as in tensordot(a, x, axes=len(b.shape)). - + Parameters ---------- a : array, shape b.shape+Q @@ -153,11 +153,11 @@ def tensorsolve(a, b, axes=None): axes : tuple of integers Axes in a to reorder to the right, before inversion. If None (default), no reordering is done. - + Returns ------- x : array, shape Q - + Examples -------- >>> from numpy import * @@ -169,7 +169,7 @@ def tensorsolve(a, b, axes=None): (2, 3, 4) >>> allclose(tensordot(a, x, axes=3), b) True - + """ a = asarray(a) b = asarray(b) @@ -206,7 +206,7 @@ def solve(a, b): x : array, shape (M,) Raises LinAlgError if a is singular or not square - + """ one_eq = len(b.shape) == 1 if one_eq: @@ -239,10 +239,10 @@ def tensorinv(a, ind=2): The result is an inverse corresponding to the operation tensordot(a, b, ind), ie., - + x == tensordot(tensordot(tensorinv(a), a, ind), x, ind) == tensordot(tensordot(a, tensorinv(a), ind), x, ind) - + for all x (up to floating-point accuracy). Parameters @@ -298,12 +298,12 @@ def tensorinv(a, ind=2): def inv(a): """Compute the inverse of a matrix. - + Parameters ---------- a : array-like, shape (M, M) Matrix to be inverted - + Returns ------- ainv : array-like, shape (M, M) @@ -330,20 +330,20 @@ def inv(a): def cholesky(a): """Compute the Cholesky decomposition of a matrix. - + Returns the Cholesky decomposition, :lm:`A = L L^*` of a Hermitian positive-definite matrix :lm:`A`. - + Parameters ---------- a : array, shape (M, M) Matrix to be decomposed - + Returns ------- L : array, shape (M, M) Lower-triangular Cholesky factor of A - + Raises LinAlgError if decomposition fails Examples @@ -357,7 +357,7 @@ def cholesky(a): >>> dot(L, L.T.conj()) array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) - + """ _assertRank2(a) _assertSquareness(a) @@ -400,7 +400,7 @@ def qr(a, mode='full'): Q : double or complex array, shape (M, K) R : double or complex array, shape (K, N) Size K = min(M, N) - + mode = 'r' R : double or complex array, shape (K, N) @@ -429,7 +429,7 @@ def qr(a, mode='full'): True >>> allclose(r, triu(r3[:6,:6], k=0)) True - + """ _assertRank2(a) m, n = a.shape @@ -507,7 +507,7 @@ def qr(a, mode='full'): def eigvals(a): """Compute the eigenvalues of a general matrix. - + Parameters ---------- a : array, shape (M, M) @@ -520,7 +520,7 @@ def eigvals(a): The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices. - + Raises LinAlgError if eigenvalue computation does not converge See Also @@ -534,7 +534,7 @@ def eigvals(a): This is a simple interface to the LAPACK routines dgeev and zgeev that sets the flags to return only the eigenvalues of general real and complex arrays respectively. - + The number w is an eigenvalue of a if there exists a vector v satisfying the equation dot(a,v) = w*v. Alternately, if w is a root of the characteristic equation det(a - w[i]*I) = 0, where det is the @@ -586,7 +586,7 @@ def eigvals(a): def eigvalsh(a, UPLO='L'): """Compute the eigenvalues of a Hermitean or real symmetric matrix. - + Parameters ---------- a : array, shape (M, M) @@ -596,7 +596,7 @@ def eigvalsh(a, UPLO='L'): Specifies whether the pertinent array data is taken from the upper or lower triangular part of a. Possible values are 'L', and 'U' for upper and lower respectively. Default is 'L'. - + Returns ------- w : double array, shape (M,) @@ -616,7 +616,7 @@ def eigvalsh(a, UPLO='L'): This is a simple interface to the LAPACK routines dsyevd and zheevd that sets the flags to return only the eigenvalues of real symmetric and complex Hermetian arrays respectively. - + The number w is an eigenvalue of a if there exists a vector v satisfying the equation dot(a,v) = w*v. Alternately, if w is a root of the characteristic equation det(a - w[i]*I) = 0, where det is the @@ -714,10 +714,10 @@ def eig(a): that fact. If the eigenvalues are all different, then theoretically the eigenvectors are independent. Likewise, the matrix of eigenvectors is unitary if the matrix a is normal, i.e., if dot(a, a.H) = dot(a.H, a). - + The left and right eigenvectors are not necessarily the (Hermitian) transposes of each other. - + """ a, wrap = _makearray(a) _assertRank2(a) @@ -775,7 +775,7 @@ def eig(a): def eigh(a, UPLO='L'): """Compute eigenvalues for a Hermitian or real symmetric matrix. - + Parameters ---------- a : array, shape (M, M) @@ -785,7 +785,7 @@ def eigh(a, UPLO='L'): Specifies whether the pertinent array date is taken from the upper or lower triangular part of a. Possible values are 'L', and 'U'. Default is 'L'. - + Returns ------- w : double array, shape (M,) @@ -793,7 +793,7 @@ def eigh(a, UPLO='L'): v : double or complex double array, shape (M, M) The normalized eigenvector corresponding to the eigenvalue w[i] is the column v[:,i]. - + Raises LinAlgError if eigenvalue computation does not converge See Also @@ -801,13 +801,13 @@ def eigh(a, UPLO='L'): eigvalsh : eigenvalues of symmetric or Hemitiean arrays. eig : eigenvalues and right eigenvectors for non-symmetric arrays eigvals : eigenvalues of non-symmetric array. - + Notes ----- A simple interface to the LAPACK routines dsyevd and zheevd that compute the eigenvalues and eigenvectors of real symmetric and complex Hermitian arrays respectively. - + The number w is an eigenvalue of a if there exists a vector v satisfying the equation dot(a,v) = w*v. Alternately, if w is a root of the characteristic equation det(a - w[i]*I) = 0, where det is the @@ -866,7 +866,7 @@ def svd(a, full_matrices=1, compute_uv=1): an 1d-array s of singular values (real, non-negative) such that a == U S Vh if S is an suitably shaped matrix of zeros whose main diagonal is s. - + Parameters ---------- a : array, shape (M, N) @@ -876,7 +876,7 @@ def svd(a, full_matrices=1, compute_uv=1): If false, the shapes are (M,K), (K,N) where K = min(M,N) compute_uv : boolean Whether to compute also U, Vh in addition to s - + Returns ------- U: array, shape (M,M) or (M,K) depending on full_matrices @@ -884,7 +884,7 @@ def svd(a, full_matrices=1, compute_uv=1): The singular values, sorted so that s[i] >= s[i+1] K = min(M, N) Vh: array, shape (N,N) or (K,N) depending on full_matrices - + For compute_uv = False, only s is returned. Raises LinAlgError if SVD computation does not converge @@ -895,14 +895,14 @@ def svd(a, full_matrices=1, compute_uv=1): >>> U, s, Vh = linalg.svd(a) >>> U.shape, Vh.shape, s.shape ((9, 9), (6, 6), (6,)) - + >>> U, s, Vh = linalg.svd(a, full_matrices=False) >>> U.shape, Vh.shape, s.shape ((9, 6), (6, 6), (6,)) >>> S = diag(s) >>> allclose(a, dot(U, dot(S, Vh))) True - + >>> s2 = linalg.svd(a, compute_uv=False) >>> allclose(s, s2) True @@ -969,11 +969,11 @@ def svd(a, full_matrices=1, compute_uv=1): def pinv(a, rcond=1e-15 ): """Compute the (Moore-Penrose) pseudo-inverse of a matrix. - + Calculate a generalized inverse of a matrix using its singular-value decomposition and including all 'large' singular values. - + Parameters ---------- a : array, shape (M, N) @@ -982,11 +982,11 @@ def pinv(a, rcond=1e-15 ): Cutoff for 'small' singular values. Singular values smaller than rcond*largest_singular_value are considered zero. - + Returns ------- B : array, shape (N, M) - + Raises LinAlgError if SVD computation does not converge Examples @@ -998,7 +998,7 @@ def pinv(a, rcond=1e-15 ): True >>> allclose(B, dot(B, dot(a, B))) True - + """ a, wrap = _makearray(a) _assertNonEmpty(a) @@ -1028,7 +1028,7 @@ def det(a): ------- det : float or complex Determinant of a - + Notes ----- The determinant is computed via LU factorization, LAPACK routine z/dgetrf. @@ -1057,9 +1057,9 @@ def det(a): def lstsq(a, b, rcond=-1): """Compute least-squares solution to equation :m:`a x = b` - + Compute a vector x such that the 2-norm :m:`|b - a x|` is minimised. - + Parameters ---------- a : array, shape (M, N) @@ -1068,9 +1068,9 @@ def lstsq(a, b, rcond=-1): Cutoff for 'small' singular values. Singular values smaller than rcond*largest_singular_value are considered zero. - + Raises LinAlgError if computation does not converge - + Returns ------- x : array, shape (N,) or (N, K) depending on shape of b @@ -1169,7 +1169,7 @@ def norm(x, ord=None): -2 smallest singular value as below other - sum(abs(x)**ord)**(1./ord) ===== ============================ ========================== - + Returns ------- n : float @@ -1180,7 +1180,7 @@ def norm(x, ord=None): For values ord < 0, the result is, strictly speaking, not a mathematical 'norm', but it may still be useful for numerical purposes. - + """ x = asarray(x) nd = len(x.shape) diff --git a/numpy/linalg/setupscons.py b/numpy/linalg/setupscons.py index d585bcaae..0cf22dd4f 100644 --- a/numpy/linalg/setupscons.py +++ b/numpy/linalg/setupscons.py @@ -6,7 +6,7 @@ def configuration(parent_package='',top_path=None): config.add_data_dir('tests') - config.add_sconscript('SConstruct', + config.add_sconscript('SConstruct', source_files = ['lapack_litemodule.c', 'zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', 'dlamch.c', diff --git a/numpy/random/setupscons.py b/numpy/random/setupscons.py index 969300ff6..f5342c39e 100644 --- a/numpy/random/setupscons.py +++ b/numpy/random/setupscons.py @@ -5,12 +5,12 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration, get_mathlibs config = Configuration('random',parent_package,top_path) - source_files = [join('mtrand', i) for i in ['mtrand.c', + source_files = [join('mtrand', i) for i in ['mtrand.c', 'mtrand.pyx', 'numpy.pxi', - 'randomkit.c', - 'randomkit.h', - 'Python.pxi', + 'randomkit.c', + 'randomkit.h', + 'Python.pxi', 'initarray.c', 'initarray.h', 'distributions.c', |