rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
numpy_distutils/site.cfg file (section [fftw]) or by setting | numpy/distutils/site.cfg file (section [fftw]) or by setting | def get_info(name,notfound_action=0): """ notfound_action: 0 - do nothing 1 - display warning message 2 - raise error """ cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead 'atlas_threads':atlas_threads_info, # ditto 'atlas_blas':atlas_blas_info, 'atlas_blas_threads':atlas_blas_threads_info,... |
numpy_distutils/site.cfg file (section [djbfft]) or by setting | numpy/distutils/site.cfg file (section [djbfft]) or by setting | def get_info(name,notfound_action=0): """ notfound_action: 0 - do nothing 1 - display warning message 2 - raise error """ cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead 'atlas_threads':atlas_threads_info, # ditto 'atlas_blas':atlas_blas_info, 'atlas_blas_threads':atlas_blas_threads_info,... |
class F2pyNotFoundError(NotFoundError): """ f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found. Get it from above location, install it, and retry setup.py.""" | def get_info(name,notfound_action=0): """ notfound_action: 0 - do nothing 1 - display warning message 2 - raise error """ cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead 'atlas_threads':atlas_threads_info, # ditto 'atlas_blas':atlas_blas_info, 'atlas_blas_threads':atlas_blas_threads_info,... | |
with numpy_distutils.setup keyword arguments. | with numpy.distutils.setup keyword arguments. | def get_info(self,notfound_action=0): """ Return a dictonary with items that are compatible with numpy_distutils.setup keyword arguments. """ flag = 0 if not self.has_info(): flag = 1 if self.verbosity>0: print self.__class__.__name__ + ':' if hasattr(self, 'calc_info'): self.calc_info() if notfound_action: if not self... |
class numpy_info(system_info): section = 'numpy' | class _numpy_info(system_info): section = 'Numeric' | def calc_info(self): if sys.platform in ['win32']: return lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs() x11_libs = self.get_libs('x11_libs', ['X11']) for lib_dir in lib_dirs: info = self.check_libs(lib_dir, x11_libs, []) if info is not None: break else: return inc_dir = None for d in include_di... |
class numarray_info(numpy_info): | class numarray_info(_numpy_info): | def calc_info(self): try: module = __import__(self.modulename) except ImportError: return info = {} macros = [] for v in ['__version__','version']: vrs = getattr(module,v,None) if vrs is None: continue macros = [(self.modulename.upper()+'_VERSION', '"\\"%s\\""' % (vrs)), (self.modulename.upper(),None)] break |
class numpy_info(numpy_info): | class Numeric_info(_numpy_info): section = 'Numeric' modulename = 'Numeric' class numpy_info(_numpy_info): | def calc_info(self): try: module = __import__(self.modulename) except ImportError: return info = {} macros = [] for v in ['__version__','version']: vrs = getattr(module,v,None) if vrs is None: continue macros = [(self.modulename.upper()+'_VERSION', '"\\"%s\\""' % (vrs)), (self.modulename.upper(),None)] break |
except TypeError: | except (TypeError, KeyError): | def getmodule(object): """ Discover the name of the module where object was defined. This is an augmented version of inspect.getmodule that can discover the parent module for extension functions. """ import inspect value = inspect.getmodule(object) if value is None: #walk trough all modules looking for function for na... |
return issubclass(_dtype(arg1).type, _dtype(arg2).type) | if issubclass_(arg2, generic): return issubclass(_dtype(arg1).type, arg2) mro = _dtype(arg2).type.mro() if len(mro) > 1: val = mro[1] else: val = mro[0] return issubclass(_dtype(arg1).type, val) | def issubdtype(arg1, arg2): return issubclass(_dtype(arg1).type, _dtype(arg2).type) |
from scipy_distutils.core import Extension, setup | from core import Extension, setup | def get_atlas_version(**config): from scipy_distutils.core import Extension, setup magic = hex(hash(`config`)) def atlas_version_c(extension, build_dir,macig=magic): source = os.path.join(build_dir,'atlas_version_%s.c' % (magic)) if os.path.isfile(source): from distutils.dep_util import newer if newer(source,__file__):... |
g2c = 'g2c-pic' | g2c = self.g2c + '-pic' | def get_libraries(self): opt = [] d = self.get_libgcc_dir() if d is not None: g2c = 'g2c-pic' f = self.static_lib_format % (g2c, self.static_lib_extension) if not os.path.isfile(os.path.join(d,f)): g2c = 'g2c' else: g2c = 'g2c' if sys.platform=='win32': opt.append('gcc') if g2c is not None: opt.append(g2c) if sys.plat... |
g2c = 'g2c' else: g2c = 'g2c' | g2c = self.g2c else: g2c = self.g2c | def get_libraries(self): opt = [] d = self.get_libgcc_dir() if d is not None: g2c = 'g2c-pic' f = self.static_lib_format % (g2c, self.static_lib_extension) if not os.path.isfile(os.path.join(d,f)): g2c = 'g2c' else: g2c = 'g2c' if sys.platform=='win32': opt.append('gcc') if g2c is not None: opt.append(g2c) if sys.plat... |
register_dtype = multiarray.register_dtype | def extend_all(module): adict = {} for a in __all__: adict[a] = 1 try: mall = getattr(module, '__all__') except AttributeError: mall = [k for k in module.__dict__.keys() if not k.startswith('_')] for a in mall: if a not in adict: __all__.append(a) | |
try: sc_desired = desired/pow(10,math.floor(math.log10(abs(desired)))) | scale = pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))) try: sc_desired = desired/scale | def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1): """ Raise an assertion if two items are not equal. I think this should be part of unittest.py Approximately equal is defined as the number of significant digits correct """ msg = '\nItems are not equal to %d significant digits:\n' % significan... |
sc_actual = actual/pow(10,math.floor(math.log10(abs(actual)))) | sc_actual = actual/scale | def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1): """ Raise an assertion if two items are not equal. I think this should be part of unittest.py Approximately equal is defined as the number of significant digits correct """ msg = '\nItems are not equal to %d significant digits:\n' % significan... |
libray_dirs=config.get('library_dirs', []), | library_dirs=config.get('library_dirs', []), | def get_atlas_version(**config): c = cmd_config(Distribution()) s, o = c.get_output(atlas_version_c_text, libraries=config.get('libraries', []), libray_dirs=config.get('library_dirs', []), ) atlas_version = None if not s: m = re.search(r'ATLAS version (?P<version>\d+[.]\d+[.]\d+)',o) if m: atlas_version = m.group('ver... |
transform as real_fft is performed along the axis specified by the last | transform as rfft is performed along the axis specified by the last | def rfftn(a, s=None, axes=None): """rfftn(a, s=None, axes=None) The n-dimensional discrete Fourier transform of a real array a. A real transform as real_fft is performed along the axis specified by the last element of axes, then complex transforms as fft are performed along the other axes.""" a = asarray(a).astype(fl... |
return real_fftnd(a, s, axes) | return rfftn(a, s, axes) | def rfft2(a, s=None, axes=(-2,-1)): """rfft2(a, s=None, axes=(-2,-1)) The 2d fft of the real valued array a. This is really just rfftn with different default behavior.""" return real_fftnd(a, s, axes) |
The inverse of rfftn. The transform implemented in inverse_fft is | The inverse of rfftn. The transform implemented in ifft is | def irfftn(a, s=None, axes=None): """irfftn(a, s=None, axes=None) The inverse of rfftn. The transform implemented in inverse_fft is applied along all axes but the last, then the transform implemented in inverse_real_fft is performed along the last axis. As with inverse_real_fft, the length of the result along that axi... |
inverse_real_fft is performed along the last axis. As with inverse_real_fft, the length of the result along that axis must be | irfft is performed along the last axis. As with irfft, the length of the result along that axis must be | def irfftn(a, s=None, axes=None): """irfftn(a, s=None, axes=None) The inverse of rfftn. The transform implemented in inverse_fft is applied along all axes but the last, then the transform implemented in inverse_real_fft is performed along the last axis. As with inverse_real_fft, the length of the result along that axi... |
% (target)] s,o = exec_command(cmd,use_tee=0) | % (os.path.basename(target))] s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0) | def atlas_version_c(extension, build_dir,macig=magic): source = os.path.join(build_dir,'atlas_version_%s.c' % (magic)) if os.path.isfile(source): from distutils.dep_util import newer if newer(source,__file__): return source f = open(source,'w') f.write(atlas_version_c_text) f.close() return source |
log.info(' libraries %s not find in %s', ','.join(libs), lib_dir) | log.info(' libraries %s not found in %s', ','.join(libs), lib_dir) | def check_libs(self,lib_dir,libs,opt_libs =[]): """If static or shared libraries are available then return their info dictionary. |
log.info(' libraries %s not find in %s', ','.join(libs), lib_dir) | log.info(' libraries %s not found in %s', ','.join(libs), lib_dir) | def check_libs2(self, lib_dir, libs, opt_libs =[]): """If static or shared libraries are available then return their info dictionary. |
if mod_name == '__main__' and not hasattr('__main__', '__file__'): d = os.path.abspath('.') elif mod_name == '__builtin__': | if mod_name == '__builtin__': | def get_path(mod_name, parent_path=None): """ Return path of the module. Returned path is relative to parent_path when given, otherwise it is absolute path. """ if mod_name == '__main__' and not hasattr('__main__', '__file__'): # we're probably running setup.py as execfile("setup.py") # (likely we're building an egg) ... |
filename = mod.__file__ d = os.path.dirname(os.path.abspath(filename)) | if hasattr(mod,'__file__'): filename = mod.__file__ d = os.path.dirname(os.path.abspath(mod.__file__)) else: d = os.path.abspath('.') | def get_path(mod_name, parent_path=None): """ Return path of the module. Returned path is relative to parent_path when given, otherwise it is absolute path. """ if mod_name == '__main__' and not hasattr('__main__', '__file__'): # we're probably running setup.py as execfile("setup.py") # (likely we're building an egg) ... |
def _usefields(adict): | def _usefields(adict, align): | def _usefields(adict): try: names = adict[-1] except KeyError: names = None if names is None: allfields = [] fnames = adict.keys() for fname in fnames: obj = adict[fname] n = len(obj) if not isinstance(obj, tuple) or n not in [2,3]: raise ValueError, "entry not a 2- or 3- tuple" if (n > 2) and (obj[2] == fname): contin... |
"titles" : titles}) | "titles" : titles}, align) | def _usefields(adict): try: names = adict[-1] except KeyError: names = None if names is None: allfields = [] fnames = adict.keys() for fname in fnames: obj = adict[fname] n = len(obj) if not isinstance(obj, tuple) or n not in [2,3]: raise ValueError, "entry not a 2- or 3- tuple" if (n > 2) and (obj[2] == fname): contin... |
return descriptor.arrtypestr | return descriptor.dtypestr | def _array_descr(descriptor): fields = descriptor.fields if fields is None: return descriptor.arrtypestr #get ordered list of fields with names ordered_fields = fields.items() # remove duplicates new = {} for item in ordered_fields: # We don't want to include redundant or non-string # entries if not isinstance(item[0... |
format_re = re.compile(r'(?P<repeat> *[(]?[ ,0-9]*[)]? *)(?P<dtype>[A-Za-z0-9.]*)') | format_re = re.compile(r'(?P<repeat> *[(]?[ ,0-9]*[)]? *)(?P<dtype>[><|A-Za-z0-9.]*)') | def _reconstruct(subtype, shape, dtype): return ndarray.__new__(subtype, shape, dtype) |
module.__name__+'.test_'+short_module_name, f, test_file,('.py', 'r', 1)) | module.__name__+'.test_'+short_module_name+pref, f, test_file+pref,('.py', 'r', 1)) | def _get_module_tests(self,module,level): mstr = self._module_str d,f = os.path.split(module.__file__) |
if hasattr(self,'compiler') and self.compiler[0].find('gcc')>=0: if sys.version[:3]>='2.3': if not self.compiler_cxx: self.compiler_cxx = [self.compiler[0].replace('gcc','g++')]\ + self.compiler[1:] else: self.compiler_cxx = [self.compiler[0].replace('gcc','g++')]\ | if hasattr(self,'compiler') and self.compiler[0].find('cc')>=0: if not self.compiler_cxx: if self.compiler[0][:3] == 'gcc': a, b = 'gcc', 'g++' else: a, b = 'cc', 'c++' self.compiler_cxx = [self.compiler[0].replace(a,b)]\ | def CCompiler_customize(self, dist, need_cxx=0): # See FCompiler.customize for suggested usage. log.info('customize %s' % (self.__class__.__name__)) customize_compiler(self) if need_cxx: # In general, distutils uses -Wstrict-prototypes, but this option is # not valid for C++ code, only for C. Remove it if it's there t... |
opt.append(os.path.join(d,'lib')) | if self.get_version() >= '10.0': prefix = 'sh' else: prefix = '' if cpu.is_64bit(): suffix = '64' else: suffix = '' opt.append(os.path.join(d, '%slib%s' % (prefix, suffix))) | def get_library_dirs(self): opt = FCompiler.get_library_dirs(self) d = os.environ.get('ABSOFT') if d: opt.append(os.path.join(d,'lib')) return opt |
if self.get_version() >= '8.0': | if self.get_version() >= '10.0': opt.extend(['af90math', 'afio', 'af77math', 'U77']) elif self.get_version() >= '8.0': | def get_libraries(self): opt = FCompiler.get_libraries(self) if self.get_version() >= '8.0': opt.extend(['f90math','fio','f77math','U77']) else: opt.extend(['fio','f90math','fmath','U77']) if os.name =='nt': opt.append('COMDLG32') return opt |
return random_sample(size=args) | if len(args) == 1: return random_sample() else: return random_sample(size=args) | def rand(*args): """rand(d1,...,dn) returns a matrix of the given dimensions which is initialized to random numbers from a uniform distribution in the range [0,1). """ return random_sample(size=args) |
return standard_normal(args) | if len(args) == 1: return standard_normal() else: return standard_normal(args) | def randn(*args): """u = randn(d0,d1,...,dn) returns zero-mean, unit-variance Gaussian random numbers in an array of size (d0,d1,...,dn). """ return standard_normal(args) |
def multivariate_normal(mean, cov, shape=[]): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. | def random_integers(low, high=None, size=None): """Return random integers x such that low <= x <= high. random_integers(low, high=None, size=None) -> random values. If high is None, then 1 <= x <= low. """ if high is None: high = low low = 1 return randint(low, high+1, size) | def multivariate_normal(mean, cov, shape=[]): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. mean must be a 1 dimensional array. cov must be a square two dimensional array ... |
mean must be a 1 dimensional array. cov must be a square two dimensional array with the same number of rows and columns as mean has elements. | def multivariate_normal(mean, cov, size=None): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. | def multivariate_normal(mean, cov, shape=[]): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. mean must be a 1 dimensional array. cov must be a square two dimensional array ... |
The first form returns a single 1-D array containing a multivariate normal. | mean must be a 1 dimensional array. cov must be a square two dimensional array with the same number of rows and columns as mean has elements. | def multivariate_normal(mean, cov, shape=[]): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. mean must be a 1 dimensional array. cov must be a square two dimensional array ... |
The second form returns an array of shape (m, n, ..., cov.shape[0]). In this case, output[i,j,...,:] is a 1-D array containing a multivariate normal.""" mean = Numeric.array(mean) cov = Numeric.array(cov) if len(mean.shape) != 1: raise ArgumentError, "mean must be 1 dimensional." if (len(cov.shape) != 2) or (cov.shape... | The first form returns a single 1-D array containing a multivariate normal. The second form returns an array of shape (m, n, ..., cov.shape[0]). In this case, output[i,j,...,:] is a 1-D array containing a multivariate normal. """ mean = Numeric.array(mean) cov = Numeric.array(cov) if size is None: shape = [] else: sh... | def multivariate_normal(mean, cov, shape=[]): """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) returns an array containing multivariate normally distributed random numbers with specified mean and covariance. mean must be a 1 dimensional array. cov must be a square two dimensional array ... |
depends = build_info.get('depends',[]) | depends = lib[1].get('depends',[]) | def get_lib_source_files(lib): filenames = [] sources = lib[1].get('sources',[]) sources = filter(lambda s:type(s) is types.StringType,sources) filenames.extend(sources) filenames.extend(get_dependencies(sources)) depends = build_info.get('depends',[]) for d in depends: if is_local_src_dir(d): os.path.walk(d,_gsf_visit... |
if check_func('strtod'): | if config_cmd.check_func('strtod', decl=False, headers=['stdlib.h']): | def check_func(func_name): return config_cmd.check_func(func_name, libraries=mathlibs, decl=False, headers=['math.h']) |
'depreciated default_config_dict(%s,%s,%s)' \ | 'deprecated default_config_dict(%s,%s,%s)' \ | def default_config_dict(name = None, parent_name = None, local_path=None): """ Return a configuration dictionary for usage in configuration() function defined in file setup_<name>.py. """ import warnings warnings.warn('Use Configuration(%s,%s,top_path=%s) instead of '\ 'depreciated default_config_dict(%s,%s,%s)' \ % (`... |
def _move_axis_to_0(a, axis): if axis == 0: return a | def rollaxis(a, axis, start=0): """Return transposed array so that axis is rolled before start. if a.shape is (3,4,5,6) rollaxis(a, 3, 1).shape is (3,6,4,5) rollaxis(a, 2, 0).shape is (5,3,4,6) rollaxis(a, 1, 3).shape is (3,5,4,6) rollaxis(a, 1, 4).shape is (3,5,6,4) """ | def tensordot(a, b, axes=(-1,0)): """tensordot returns the product for any (ndim >= 1) arrays. r_{xxx, yyy} = \sum_k a_{xxx,k} b_{k,yyy} where 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 ar... |
axes = range(1, axis+1) + [0,] + range(axis+1, n) | if start < 0: start += n msg = 'rollaxis: %s (%d) must be >=0 and < %d' if not (0 <= axis < n): raise ValueError, msg % ('axis', axis, n) if not (0 <= start < n+1): raise ValueError, msg % ('start', start, n+1) if (axis < start): start -= 1 if axis==start: return a axes = range(0,n) axes.remove(axis) axes.insert(start,... | def _move_axis_to_0(a, axis): if axis == 0: return a n = a.ndim if axis < 0: axis += n axes = range(1, axis+1) + [0,] + range(axis+1, n) return a.transpose(axes) |
a = _move_axis_to_0(asarray(a), axisa) b = _move_axis_to_0(asarray(b), axisb) | a = asarray(a).swapaxes(axisa, 0) b = asarray(b).swapaxes(axisb, 0) | def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None): """Return the cross product of two (arrays of) vectors. The cross product is performed over the last axis of a and b by default, and can handle axes with dimensions 2 and 3. For a dimension of 2, the z-component of the equivalent three-dimensional cross product... |
self.lib_ar = MSVCCompiler().lib + ' /OUT:' | self.lib_ar = '"%s" /OUT:' % (MSVCCompiler().lib) | def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose) |
_nc_compiled_base_ext = _config_compiled_base( package, local_path, "_nc", "NUMERIC", numpy_info) config['ext_modules'].append(_nc_compiled_base_ext) | def configuration(parent_package='',parent_path=None): from scipy_distutils.system_info import get_info, dict_append from scipy_distutils.core import Extension from scipy_distutils.misc_util import get_path,default_config_dict,dot_join from scipy_distutils.misc_util import get_path,default_config_dict,\ dot_join,Source... | |
_compiled_base_c = os.path.join(local_path,'_compiled_base.c') def compiled_base_c(ext,src_dir): source = os.path.join(src_dir,ext.name.split('.')[-1] + '.c') if newer(_compiled_base_c,source): copy_file(_compiled_base_c,source) return [source] ext_args = {} dict_append(ext_args, name=dot_join(package,'_nc_compiled_ba... | def configuration(parent_package='',parent_path=None): from scipy_distutils.system_info import get_info, dict_append from scipy_distutils.core import Extension from scipy_distutils.misc_util import get_path,default_config_dict,dot_join from scipy_distutils.misc_util import get_path,default_config_dict,\ dot_join,Source... | |
_na_compiled_base_ext = _config_compiled_base( package, local_path, "_na", "NUMARRAY", numarray_info) config['ext_modules'].append(_na_compiled_base_ext) | ext_args = {} dict_append(ext_args, name=dot_join(package,'_na_compiled_base'), sources = [compiled_base_c], depends = [_compiled_base_c], define_macros = [('NUMARRAY',None)], include_dirs = [local_path] ) dict_append(ext_args,**numarray_info) config['ext_modules'].append(Extension(**ext_args)) | def configuration(parent_package='',parent_path=None): from scipy_distutils.system_info import get_info, dict_append from scipy_distutils.core import Extension from scipy_distutils.misc_util import get_path,default_config_dict,dot_join from scipy_distutils.misc_util import get_path,default_config_dict,\ dot_join,Source... |
if isinstance(data, types.StringType): | if isinstance(data, str): | def __new__(subtype, data, dtype=None, copy=True): if isinstance(data, matrix): dtype2 = data.dtype if (dtype is None): dtype = dtype2 if (dtype2 == dtype) and (not copy): return data return data.astype(dtype) |
self.shape = (1,self.shape[0]) | self.shape = (1,newshape[0]) | def __array_finalize__(self, obj): ndim = self.ndim if (ndim == 2): return if (ndim > 2): newshape = tuple([x for x in self.shape if x > 1]) ndim = len(newshape) if ndim == 2: self.shape = newshape return elif (ndim > 2): raise ValueError, "shape too large to be a matrix." if ndim == 0: self.shape = (1,1) elif ndim == ... |
if isinstance(index[0], types.SliceType): if (isscalar(index[1])): | if isscalar(index[1]): if isscalar(index[0]): retscal = True elif out.shape[0] == 1: | def __getitem__(self, index): out = N.ndarray.__getitem__(self, index) # Need to swap if slice is on first index retscal = False try: n = len(index) if (n==2): if isinstance(index[0], types.SliceType): if (isscalar(index[1])): sh = out.shape out.shape = (sh[1], sh[0]) else: if (isscalar(index[0])) and (isscalar(index[1... |
else: if (isscalar(index[0])) and (isscalar(index[1])): retscal = True except TypeError: | elif isinstance(index[1], (slice, types.EllipsisType)): if out.shape[0] == 1 and not isscalar(index[0]): sh = out.shape out.shape = (sh[1], sh[0]) except (TypeError, IndexError): | def __getitem__(self, index): out = N.ndarray.__getitem__(self, index) # Need to swap if slice is on first index retscal = False try: n = len(index) if (n==2): if isinstance(index[0], types.SliceType): if (isscalar(index[1])): sh = out.shape out.shape = (sh[1], sh[0]) else: if (isscalar(index[0])) and (isscalar(index[1... |
__doc__ += """ | if __doc__ is not None: __doc__ += """ | def test(level=1, verbosity=1): return NumpyTest().test(level, verbosity) |
include_dirs = [py_incl_dir] | include_dirs.append(py_incl_dir) | def __init__(self): from distutils.sysconfig import get_python_inc py_incl_dir = get_python_inc() include_dirs = [py_incl_dir] for d in default_include_dirs: d = os.path.join(d, os.path.basename(py_incl_dir)) if d not in include_dirs: include_dirs.append(d) system_info.__init__(self, default_lib_dirs=[], default_includ... |
target_dir = os.path.dirname(target_file) | target_dir = os.path.dirname(target_file) or '.' | def f2py_sources(self, sources, extension): new_sources = [] f2py_sources = [] f_sources = [] f2py_targets = {} target_dirs = [] ext_name = extension.name.split('.')[-1] skip_f2py = 0 |
pattern_list = d.split(os.sep) | pattern_list = abspath(d).split(os.sep) | def add_data_dir(self,data_path): """ Recursively add files under data_path to data_files list. Argument can be either - 2-sequence (<datadir suffix>,<path to data directory>) - path to data directory where python datadir suffix defaults to package dir. |
('build-flib', 'b', | ('build-flib=', 'b', | def show_compilers(): for compiler_class in all_compilers: compiler = compiler_class() if compiler.is_available(): print cyan_text(compiler) |
('build-temp', 't', | ('build-temp=', 't', | def show_compilers(): for compiler_class in all_compilers: compiler = compiler_class() if compiler.is_available(): print cyan_text(compiler) |
module_dirs, temp_dir=self.build_temp) | module_dirs, temp_dir=self.build_temp, build_dir=self.build_flib, ) | def build_libraries (self, fortran_libraries): fcompiler = self.fcompiler for (lib_name, build_info) in fortran_libraries: self.announce(" building '%s' library" % lib_name) |
temp_dir = ''): | temp_dir = '', build_dir = ''): | def build_library(self,library_name,source_list,module_dirs=None, temp_dir = ''): #make sure the temp directory exists before trying to build files import distutils.dir_util distutils.dir_util.mkpath(temp_dir) |
self.create_static_lib(obj,library_name,temp_dir, | self.create_static_lib(obj,library_name,build_dir, | def build_library(self,library_name,source_list,module_dirs=None, temp_dir = ''): #make sure the temp directory exists before trying to build files import distutils.dir_util distutils.dir_util.mkpath(temp_dir) |
self.create_static_lib(object_list,library_name,temp_dir) | self.create_static_lib(object_list,library_name,build_dir) | def build_library(self,library_name,source_list,module_dirs=None, temp_dir = ''): #make sure the temp directory exists before trying to build files import distutils.dir_util distutils.dir_util.mkpath(temp_dir) |
'"%s"' % (module.__version__))] | '"\\"%s\\""' % (module.__version__))] | def calc_info(self): try: module = __import__(self.modulename) except ImportError: return info = {} macros = [(self.modulename.upper()+'_VERSION', '"%s"' % (module.__version__))] |
moredefs = [] | try: nosmp = os.environ['NPY_NOSMP'] nosmp = 1 except KeyError: nosmp = 0 if nosmp: moredefs = [('NPY_ALLOW_THREADS', '0')] else: moredefs = [('NPY_ALLOW_THREADS','WITH_THREAD')] | def generate_config_h(ext, build_dir): target = join(build_dir,'config.h') if newer(__file__,target): config_cmd = config.get_config_cmd() print 'Generating',target # tc = generate_testcode(target) from distutils import sysconfig python_include = sysconfig.get_python_inc() result = config_cmd.try_run(tc,include_dirs=[p... |
"""Evaluate the polynomial p at x. | """Evaluate the polynomial p at x. If x is a polynomial then composition. | def polyval(p,x): """Evaluate the polynomial p at x. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1] """ x = Numeric.asarray(x) p = Numeric.asarray(p) y = Numeric.zeros(x.shape,x.typecode()) for i in range(len(p)): y = x * y + p[i] return y |
""" x = Numeric.asarray(x) | x can be a sequence and p(x) will be returned for all elements of x. or x can be another polynomial and the composite polynomial p(x) will be returned. """ | def polyval(p,x): """Evaluate the polynomial p at x. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1] """ x = Numeric.asarray(x) p = Numeric.asarray(p) y = Numeric.zeros(x.shape,x.typecode()) for i in range(len(p)): y = x * y + p[i] return y |
y = Numeric.zeros(x.shape,x.typecode()) | if isinstance(x,poly1d): y = 0 else: x = Numeric.asarray(x) y = Numeric.zeros(x.shape,x.typecode()) | def polyval(p,x): """Evaluate the polynomial p at x. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1] """ x = Numeric.asarray(x) p = Numeric.asarray(p) y = Numeric.zeros(x.shape,x.typecode()) for i in range(len(p)): y = x * y + p[i] return y |
return poly1d(other*self.coeffs) | return poly1d(self.coeffs * other) | def __mul__(self, other): if isscalar(other): return poly1d(other*self.coeffs) else: other = poly1d(other) return poly1d(polymul(self.coeffs, other.coeffs)) |
if isscalar(other): return poly1d(other+self.coeffs) else: other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) | other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) | def __add__(self, other): if isscalar(other): return poly1d(other+self.coeffs) else: other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) |
if isscalar(other): return poly1d(other+self.coeffs) else: other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) | other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) | def __radd__(self, other): if isscalar(other): return poly1d(other+self.coeffs) else: other = poly1d(other) return poly1d(polyadd(self.coeffs, other.coeffs)) |
if isscalar(other): return poly1d(self.coeffs-other) else: other = poly1d(other) return poly1d(polysub(self.coeffs, other.coeffs)) | other = poly1d(other) return poly1d(polysub(self.coeffs, other.coeffs)) | def __sub__(self, other): if isscalar(other): return poly1d(self.coeffs-other) else: other = poly1d(other) return poly1d(polysub(self.coeffs, other.coeffs)) |
if isscalar(other): return poly1d(other-self.coeffs) else: other = poly1d(other) return poly1d(polysub(other.coeffs, self.coeffs)) | other = poly1d(other) return poly1d(polysub(other.coeffs, self.coeffs)) | def __rsub__(self, other): if isscalar(other): return poly1d(other-self.coeffs) else: other = poly1d(other) return poly1d(polysub(other.coeffs, self.coeffs)) |
_array = recarray(shape, parsed._descr) | _array = recarray(shape, parsed._descr, byteorder=byteorder) | def fromfile(fd, formats, shape=None, names=None, titles=None, byteorder=None, aligned=0, offset=0): """Create an array from binary file data If file is a string then that file is opened, else it is assumed to be a file object. No options at the moment, all file positioning must be done prior to this function call wit... |
self.array = array(data, dtype, copy) | self.array = array(data, dtype, copy=copy) | def __init__(self, data, dtype=None, copy=True): self.array = array(data, dtype, copy) |
if save_linker_so[0]=='gcc': | if save_linker_so and save_linker_so[0]=='gcc': | def build_extension(self, ext): # The MSVC compiler doesn't have a linker_so attribute. # Giving it a dummy one of None seems to do the trick. if not hasattr(self.compiler,'linker_so'): self.compiler.linker_so = None #XXX: anything else we need to save? save_linker_so = self.compiler.linker_so save_compiler_libs = se... |
cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name) | cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name) | def build_libraries (self, libraries): |
p_frame = _get_frame(level) | parent_frame = p_frame = _get_frame(level) | def ppimport(name): """ ppimport(name) -> module or module wrapper If name has been imported before, return module. Otherwise return ModuleLoader instance that transparently postpones module import until the first attempt to access module name attributes. """ global _ppimport_is_enabled level = 1 p_frame = _get_frame... |
if _ppimport_is_enabled: | if _ppimport_is_enabled or isinstance(module,types.ModuleType): | def ppimport(name): """ ppimport(name) -> module or module wrapper If name has been imported before, return module. Otherwise return ModuleLoader instance that transparently postpones module import until the first attempt to access module name attributes. """ global _ppimport_is_enabled level = 1 p_frame = _get_frame... |
loader = _ModuleLoader(fullname,location,p_frame=p_frame) | loader = _ModuleLoader(fullname,location,p_frame=parent_frame) | def ppimport(name): """ ppimport(name) -> module or module wrapper If name has been imported before, return module. Otherwise return ModuleLoader instance that transparently postpones module import until the first attempt to access module name attributes. """ global _ppimport_is_enabled level = 1 p_frame = _get_frame... |
print 'ppimport(%s) caller locals:' % (repr(name)) for k in ['__name__','__file__']: v = p_frame.f_locals.get(k,None) if v is not None: print '%s=%s' % (k,v) | if DEBUG: blocks = [] f = p_frame while f: blocks.insert(0,_pprint_frame(f)) f = f.f_back print '='*50 print ' ppimport(%s) traceback' % (repr(name)) print '-'*50 print '\n'.join(blocks) print '='*50 | def _ppimport_importer(self): name = self.__name__ |
def ppresolve(a): | def ppresolve(a,ignore_failure=None): | def ppresolve(a): """ Return resolved object a. a can be module name, postponed module, postponed modules attribute, string representing module attribute, or any Python object. """ if type(a) is type(''): ns = a.split('.') a = ppimport(ns[0]) b = [ns[0]] del ns[0] while ns: if hasattr(a,'_ppimport_importer') or \ hasa... |
a = getattr(a,b[-1],ppimport('.'.join(b))) | if ignore_failure and not hasattr(a, b[-1]): return '.'.join(ns+b) a = getattr(a,b[-1]) | def ppresolve(a): """ Return resolved object a. a can be module name, postponed module, postponed modules attribute, string representing module attribute, or any Python object. """ if type(a) is type(''): ns = a.split('.') a = ppimport(ns[0]) b = [ns[0]] del ns[0] while ns: if hasattr(a,'_ppimport_importer') or \ hasa... |
return _old_pydoc_help_call(self, *map(ppresolve,args), **kwds) | return _old_pydoc_help_call(self, *map(_ppresolve_ignore_failure,args), **kwds) | def _scipy_pydoc_help_call(self,*args,**kwds): return _old_pydoc_help_call(self, *map(ppresolve,args), **kwds) |
args = (ppresolve(args[0]),) + args[1:] | args = (_ppresolve_ignore_failure(args[0]),) + args[1:] | def _scipy_pydoc_Doc_document(self,*args,**kwds): args = (ppresolve(args[0]),) + args[1:] return _old_pydoc_Doc_document(self,*args,**kwds) |
join('/prefix','sub','name')) | ajoin('prefix','sub','name')) | def check_2(self): assert_equal(appendpath('prefix/sub','name'), join('prefix','sub','name')) assert_equal(appendpath('prefix/sub','sup/name'), join('prefix','sub','sup','name')) assert_equal(appendpath('/prefix/sub','/prefix/name'), join('/prefix','sub','name')) |
join('/prefix','sub','sub2','sup','sup2','name')) | ajoin('prefix','sub','sub2','sup','sup2','name')) | def check_3(self): assert_equal(appendpath('/prefix/sub','/prefix/sup/name'), join('/prefix','sub','sup','name')) assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'), join('/prefix','sub','sub2','sup','sup2','name')) assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'), join('/prefix','sub... |
join('/prefix','sub','sub2','sup','name')) | ajoin('prefix','sub','sub2','sup','name')) | def check_3(self): assert_equal(appendpath('/prefix/sub','/prefix/sup/name'), join('/prefix','sub','sup','name')) assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'), join('/prefix','sub','sub2','sup','sup2','name')) assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'), join('/prefix','sub... |
a.fill(1) | try: a.fill(1) except TypeError: obj = _maketup(dtype, 1) a.fill(obj) | def ones(shape, dtype=None, order='C'): """Returns an array of the given dimensions which is initialized to all ones. """ a = empty(shape, dtype, order) a.fill(1) # Above is faster now after addition of fast loops. #a = zeros(shape, dtype, order) #a+=1 return a |
Kronecker product of two matrices is block matrix | Kronecker product of two arrays is block array | def kron(a,b): """kronecker product of a and b Kronecker product of two matrices is block matrix [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] """ wrapper = _getwrapper(a, b) a = asanyarray(a) b = asanyarray(b) if not... |
a = asanyarray(a) b = asanyarray(b) if not (len(a.shape) == len(b.shape) == 2): raise ValueError("a and b must both be two dimensional") | b = asanyarray(b) a = array(a,copy=False,subok=True,ndmin=b.ndim) as = a.shape bs = b.shape | def kron(a,b): """kronecker product of a and b Kronecker product of two matrices is block matrix [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] """ wrapper = _getwrapper(a, b) a = asanyarray(a) b = asanyarray(b) if not... |
a = reshape(a, a.shape) | a = reshape(a, as) | def kron(a,b): """kronecker product of a and b Kronecker product of two matrices is block matrix [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] """ wrapper = _getwrapper(a, b) a = asanyarray(a) b = asanyarray(b) if not... |
b = reshape(b, b.shape) | b = reshape(b, bs) | def kron(a,b): """kronecker product of a and b Kronecker product of two matrices is block matrix [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] """ wrapper = _getwrapper(a, b) a = asanyarray(a) b = asanyarray(b) if not... |
o=o.reshape(a.shape + b.shape) result = concatenate(concatenate(o, axis=1), axis=1) | result = o.reshape(as + bs) axis = a.ndim-1 for k in xrange(b.ndim): result = concatenate(result, axis=axis) | def kron(a,b): """kronecker product of a and b Kronecker product of two matrices is block matrix [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] """ wrapper = _getwrapper(a, b) a = asanyarray(a) b = asanyarray(b) if not... |
if sys.version[:3] < '2.4': kws_args['headers'].append('stdlib.h') if config_cmd.check_func('strtod', **kws_args): moredefs.append(('PyOS_ascii_strtod', 'strtod')) | def generate_config_h(ext, build_dir): target = join(build_dir,'config.h') if newer(__file__,target): config_cmd = config.get_config_cmd() print 'Generating',target # tc = generate_testcode(target) from distutils import sysconfig python_include = sysconfig.get_python_inc() result = config_cmd.try_run(tc,include_dirs=[p... | |
if issubclass(dtypeobj, _nt.bool): format = "%s" format_function = lambda x: format % x if issubclass(dtypeobj, _nt.integer): | if issubclass(dtypeobj, _nt.bool_): format_function = _boolFormatter elif issubclass(dtypeobj, _nt.integer): | def _array2string(a, max_line_width, precision, suppress_small, separator=' ', prefix=""): if max_line_width is None: max_line_width = _line_width if precision is None: precision = _float_output_precision if suppress_small is None: suppress_small = _float_output_suppress_small if a.size > _summaryThreshold: summary... |
descr = dtypedescr(formats, aligned) | descr = sb.dtypedescr(formats, aligned) | def __new__(subtype, shape, formats, names=None, titles=None, buf=None, offset=0, strides=None, swap=0, aligned=0): |
fstr = func2_re[name].sub('\\1B\\2',fstr) | fstr = func_re[name].sub('\\1B\\2',fstr) | def fixtypechars(fstr): for name in _func2 + _func4 + _meth1: fstr = func2_re[name].sub('\\1B\\2',fstr) for char in _chars.keys(): fstr = meth_re[char].sub('\\1%s\\2'%_chars[char], fstr) return fstr |
elif type(s) is type('') and os.path.isfile(s): filenames.append(s) | elif type(s) is type(''): if os.path.isfile(s): filenames.append(s) else: print 'Not existing data file:',s | def get_data_files(data): if type(data) is types.StringType: return [data] sources = data[1] filenames = [] for s in sources: if callable(s): s = s() if s is None: continue if is_local_src_dir(s): os.path.walk(s,_gsf_visit_func,filenames) elif type(s) is type('') and os.path.isfile(s): filenames.append(s) else: raise T... |
ds = path | ds = os.path.join(*(self.name.split('.')+[data_path])) | def add_data_dir(self,data_path): """ Recursively add files under data_path to data_files list. Argument can be either - 2-sequence (<datadir suffix>,<path to data directory>) - path to data directory where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.