rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
build_dir = get_package_dir(package)
build_dir = self.get_package_dir(package)
def build_py_modules_sources(self): if not self.py_modules: return log.info('building py_modules sources') new_py_modules = [] if self.inplace: get_package_dir = self.get_finalized_command('build_py').get_package_dir for source in self.py_modules: if is_sequence(source) and len(source)==3: package, module_base, source ...
build_py = self.get_finalized_command('build_py') self.ext_target_dir = build_py.get_package_dir(package)
self.ext_target_dir = self.get_package_dir(package)
def build_extension_sources(self, ext):
if os.name == 'nt' or sys.platform[:4] == 'irix':
if os.name == 'nt' \ or sys.platform[:4] == 'irix' \ or sys.platform[:3] == 'osf':
def build_library(self,library_name,source_list,module_dirs=None, temp_dir = '', build_dir = ''): #make sure the temp directory exists before trying to build files if not build_dir: build_dir = temp_dir import distutils.dir_util distutils.dir_util.mkpath(temp_dir) distutils.dir_util.mkpath(build_dir)
assert isinstance(self.search_static_first, int)
assert isinstance(self.search_static_first, type(0))
def __init__ (self, default_lib_dirs=default_lib_dirs, default_include_dirs=default_include_dirs, ): self.__class__.info = {} self.local_prefixes = [] defaults = {} defaults['library_dirs'] = os.pathsep.join(default_lib_dirs) defaults['include_dirs'] = os.pathsep.join(default_include_dirs) defaults['src_dirs'] = os.pat...
if type(step) is type(1j):
if isinstance(step, complex):
def __getitem__(self,key): try: size = [] typ = int for k in range(len(key)): step = key[k].step start = key[k].start if start is None: start=0 if step is None: step=1 if type(step) is type(1j): size.append(int(abs(step))) typ = float else: size.append(int((key[k].stop - start)/(step*1.0))) if isinstance(step, float) o...
step = (key[k].stop - start)/float(step-1)
if step != 1: step = (key[k].stop - start)/float(step-1)
def __getitem__(self,key): try: size = [] typ = int for k in range(len(key)): step = key[k].step start = key[k].start if start is None: start=0 if step is None: step=1 if type(step) is type(1j): size.append(int(abs(step))) typ = float else: size.append(int((key[k].stop - start)/(step*1.0))) if isinstance(step, float) o...
step = (key.stop-start)/float(step-1)
if step != 1: step = (key.stop-start)/float(step-1)
def __getitem__(self,key): try: size = [] typ = int for k in range(len(key)): step = key[k].step start = key[k].start if start is None: start=0 if step is None: step=1 if type(step) is type(1j): size.append(int(abs(step))) typ = float else: size.append(int((key[k].stop - start)/(step*1.0))) if isinstance(step, float) o...
self.libraries = ['fsu','sunmath','mvec']
self.libraries = ['fsu','sunmath','mvec','f77compat']
def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose)
self.failUnlessRaises(ValueError, make_array, 4, 3, -1)
self.failUnlessRaises(ValueError, make_array, 4, 2, -1)
def make_array(size, offset, strides): return ndarray([size], buffer=x, offset=offset*x.itemsize, strides=strides*x.itemsize)
self.failUnlessRaises(ValueError, make_array, 8, 3, 0)
def make_array(size, offset, strides): return ndarray([size], buffer=x, offset=offset*x.itemsize, strides=strides*x.itemsize)
self.failUnlessRaises(ValueError, make_array, 4, 3, -1)
self.failUnlessRaises(ValueError, make_array, 4, 2, -1)
def make_array(size, offset, strides): try: r = ndarray([size], buffer=x, offset=offset*x.itemsize) except: pass r.strides = strides=strides*x.itemsize return r
self.failUnlessRaises(ValueError, make_array, 8, 3, 0)
def make_array(size, offset, strides): try: r = ndarray([size], buffer=x, offset=offset*x.itemsize) except: pass r.strides = strides=strides*x.itemsize return r
self.f77_switches = ' -pic -f77 -ftrap=%none ' self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'
self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none ' self.f77_opt = ' -fast -dalign -xtarget=generic '
def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose)
self.f90_switches = ' -pic' self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'
self.f90_switches = ' -xcode=pic32 ' self.f90_opt = ' -fast -dalign -xtarget=generic '
def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose)
def get_extra_link_args(self): return ["-Bdynamic", "-G"]
def get_extra_link_args(self): return ["-Bdynamic", "-G"]
return [self.f90_compiler]
return [self.f90_compiler,'-Bdynamic','-G']
def get_linker_so(self): return [self.f90_compiler]
res = sctypeDict.get(rep, default) return res
try: res = dtype(rep) except: return default return res.type
def obj2sctype(rep, default=None): try: if issubclass(rep, generic): return rep except TypeError: pass if isinstance(rep, dtype): return rep.type if isinstance(rep, type): return _python_type(rep) if isinstance(rep, ndarray): return rep.dtype.type res = sctypeDict.get(rep, default) return res
if callable(file):
if callable(filepat):
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir prefix>,<path to data file(s)>) - paths to data files where python datadir prefix defaults to package dir.
return log(x)/log(n)
return nx.log(x)/nx.log(n)
def logn(n, x): """ Take log base n of x. """ x = _fix_real_lt_zero(x) n = _fix_real_lt_zero(n) return log(x)/log(n)
return log(x)/_ln2
return nx.log(x)/_ln2
def log2(x): """ Take log base 2 of x. """ x = _fix_real_lt_zero(x) return log(x)/_ln2
return arccos(x)
return nx.arccos(x)
def arccos(x): x = _fix_real_abs_gt_1(x) return arccos(x)
return arcsin(x)
return nx.arcsin(x)
def arcsin(x): x = _fix_real_abs_gt_1(x) return arcsin(x)
>>> insertinto(a, [1,2], [[4],[5]], axis=0)
>>> insert(a, [1,2], [[4],[5]], axis=0)
def insert(arr, obj, values, axis=None): """Return a new array with values inserted along the given axis before the given indices If axis is None, then ravel the array first. The obj argument can be an integer, a slice, or a sequence of integers. Example: >>> a = array([[1,2,3], [4,5,6], [7,8,9]]) >>> insertinto(a,...
self.info[0]['model name']) is not None
self.info[0]['family']) is not None
def _is_Itanium(self): return re.match(r'.*?Itanium\b', self.info[0]['model name']) is not None
self.linker = 'dllwrap --driver-name g++'
self.linker = 'dllwrap'
def __init__ (self, verbose=0, dry_run=0, force=0):
info = typeinfo[name.upper()]
if name[-1] == '_': newname = name[:-1] else: newname = name info = typeinfo[newname.upper()]
def bitname(obj): """Return a bit-width name for a given type object""" name = obj.__name__ base = '' char = '' try: info = typeinfo[name.upper()] assert(info[-1] == obj) # sanity check bits = info[2] except KeyError: # bit-width name base, bits = _evalname(name) char = base[0] if name == 'bool': char = 'b' base...
if name == 'bool':
if name == 'bool_':
def bitname(obj): """Return a bit-width name for a given type object""" name = obj.__name__ base = '' char = '' try: info = typeinfo[name.upper()] assert(info[-1] == obj) # sanity check bits = info[2] except KeyError: # bit-width name base, bits = _evalname(name) char = base[0] if name == 'bool': char = 'b' base...
elif name=='string':
elif name=='string_':
def bitname(obj): """Return a bit-width name for a given type object""" name = obj.__name__ base = '' char = '' try: info = typeinfo[name.upper()] assert(info[-1] == obj) # sanity check bits = info[2] except KeyError: # bit-width name base, bits = _evalname(name) char = base[0] if name == 'bool': char = 'b' base...
elif name=='unicode':
elif name=='unicode_':
def bitname(obj): """Return a bit-width name for a given type object""" name = obj.__name__ base = '' char = '' try: info = typeinfo[name.upper()] assert(info[-1] == obj) # sanity check bits = info[2] except KeyError: # bit-width name base, bits = _evalname(name) char = base[0] if name == 'bool': char = 'b' base...
elif name=='object':
elif name=='object_':
def bitname(obj): """Return a bit-width name for a given type object""" name = obj.__name__ base = '' char = '' try: info = typeinfo[name.upper()] assert(info[-1] == obj) # sanity check bits = info[2] except KeyError: # bit-width name base, bits = _evalname(name) char = base[0] if name == 'bool': char = 'b' base...
cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)
lib_file = None if sys.platform=='win32': lib_file = os.path.join(self.build_clib,'%s.lib' % lib_name) if not os.path.isfile(lib_file): lib_file = None if lib_file is None: lib_file = os.path.join(self.build_clib,'lib%s.a' % lib_name) cmd = 'ranlib '+lib_file
def build_libraries (self, libraries):
for obj in arrayList: if obj.shape != shape: raise ValueError, "array has different shape"
def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None): """ create a record array from a (flat) list of arrays >>> x1=array([1,2,3,4]) >>> x2=array(['a','dd','xyz','12']) >>> x3=array([1.1,2,3,4]) >>> r=fromarrays([x1,x2,x3],names='a,b,c') >>> print r[1]...
entries = njoin(path,'.svn','entries')
def _get_svn_revision(self,path): """ Return path's SVN revision number. """ entries = njoin(path,'.svn','entries') revision = None if os.path.isfile(entries): f = open(entries) m = re.search(r'revision="(?P<revision>\d+)"',f.read()) f.close() if m: revision = int(m.group('revision')) return revision
m = re.search(r'revision="(?P<revision>\d+)"',f.read())
fstr = f.read()
def _get_svn_revision(self,path): """ Return path's SVN revision number. """ entries = njoin(path,'.svn','entries') revision = None if os.path.isfile(entries): f = open(entries) m = re.search(r'revision="(?P<revision>\d+)"',f.read()) f.close() if m: revision = int(m.group('revision')) return revision
if m: revision = int(m.group('revision'))
if fstr[:5] == '<?xml': m = re.search(r'revision="(?P<revision>\d+)"',fstr) if m: revision = int(m.group('revision')) else: m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr) if m: revision = int(m.group('revision'))
def _get_svn_revision(self,path): """ Return path's SVN revision number. """ entries = njoin(path,'.svn','entries') revision = None if os.path.isfile(entries): f = open(entries) m = re.search(r'revision="(?P<revision>\d+)"',f.read()) f.close() if m: revision = int(m.group('revision')) return revision
If axis is None, then ravel the array first.
If axis is None, then ravel the array first. The obj argument can be an integer, a slice, or a sequence of integers. Example: >>> a = array([[1,2,3], [4,5,6], [7,8,9]]) >>> insertinto(a, [1,2], [[4],[5]], axis=0) array([[1,2,3], [4,4,4], [4,5,6], [5,5,5], [7,8,9])
def insertinto(arr, obj, values, axis=None): """Return a new array with values inserted along the given axis before the given indices If axis is None, then ravel the array first. """ arr = asarray(arr) ndim = arr.ndim if axis is None: if ndim != 1: arr = arr.ravel() axis = 0 if (ndim == 0): arr = arr.copy() arr[...] =...
obj = array(obj, dtype=intp, copy=0, ndmin=1) try: if len(values) != len(obj): raise TypeError except TypeError: values = [values]*len(obj) new = arr k = 0 for item, val in zip(obj, values): new = insertinto(new, item+k, val, axis=axis)
obj = asarray(obj, dtype=intp) numnew = len(obj) index1 = obj + arange(numnew) index2 = setdiff1d(arange(numnew+N),index1) newshape[axis] += numnew new = empty(newshape, arr.dtype, arr.flags.fnc) slobj2 = [slice(None)]*ndim slobj[axis] = index1 slobj2[axis] = index2 new[slobj] = values new[slobj2] = arr
def insertinto(arr, obj, values, axis=None): """Return a new array with values inserted along the given axis before the given indices If axis is None, then ravel the array first. """ arr = asarray(arr) ndim = arr.ndim if axis is None: if ndim != 1: arr = arr.ravel() axis = 0 if (ndim == 0): arr = arr.copy() arr[...] =...
X -= X.mean(axis=axis)[tup]
X -= X.mean(axis=1-axis)[tup]
def cov(m,y=None, rowvar=1, bias=0): """Estimate the covariance matrix. If m is a vector, return the variance. For matrices return the covariance matrix. If y is given it is treated as an additional (set of) variable(s). Normalization is by (N-1) where N is the number of observations (unbiased estimate). If bias i...
target_dir = os.path.join(self.build_src, os.path.dirname(base))
target_dir = appendpath(self.build_src, os.path.dirname(base))
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
target_dir = os.path.join(self.build_src, os.path.dirname(base))
target_dir = appendpath(self.build_src, os.path.dirname(base))
def swig_sources(self, sources, extension): new_sources = [] swig_sources = [] swig_targets = {} target_dirs = [] py_files = [] # swig generated .py files target_ext = '.c' typ = None is_cpp = 0 skip_swig = 0 ext_name = extension.name.split('.')[-1]
return mu.empty(shape, dtype, order)
return mu.empty(shape, dtype)
def empty(shape, typecode='l', dtype=None): dtype = convtypecode(typecode, dtype) return mu.empty(shape, dtype, order)
class forte_fortran_compiler(sun_compiler_base):
class forte_fortran_compiler(sun_compiler_compiler):
def get_linker_so(self): return [self.f90_compiler,'-Bdynamic','-G']
a = asanyarray(a, copy=True)
a = asanyarray(a).copy()
def sort(a, axis=-1): """sort(a,axis=-1) returns array with elements sorted along given axis. """ a = asanyarray(a, copy=True) a.sort(axis) return a
a = ppimport(ns[0])
if ignore_failure: try: a = ppimport(ns[0]) except: return a else: a = ppimport(ns[0])
def ppresolve(a,ignore_failure=None): """ Return resolved object a. a can be module name, postponed module, postponed modules attribute, string representing module attribute, or any Python object. """ global _ppimport_is_enabled if _ppimport_is_enabled: disable() a = ppresolve(a,ignore_failure=ignore_failure) enable()...
sometrue = masked_unary_operation(oldnumeric.sometrue) alltrue = masked_unary_operation(oldnumeric.alltrue, 1)
def __str__ (self): return "Masked version of " + str(self.f)
defaults['lib_dir'] = ':'.join(default_lib_dirs) defaults['include_dir'] = ':'.join(default_include_dirs)
defaults['lib_dir'] = os.pathsep.join(default_lib_dirs) defaults['include_dir'] = os.pathsep.join(default_include_dirs)
def __init__ (self, default_lib_dirs=default_lib_dirs, default_include_dirs=default_include_dirs, ): self.__class__.info = {} #self.__class__.need_refresh = not self.info self.local_prefixes = [] defaults = {} defaults['lib_dir'] = ':'.join(default_lib_dirs) defaults['include_dir'] = ':'.join(default_include_dirs) defa...
dirs = self.cp.get(section, key).split(':') default_dirs = self.cp.get('DEFAULT', key).split(':')
dirs = self.cp.get(section, key).split(os.pathsep) default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)
def get_paths(self, section, key): dirs = self.cp.get(section, key).split(':') default_dirs = self.cp.get('DEFAULT', key).split(':') dirs.extend(default_dirs) return [ d for d in dirs if os.path.isdir(d) ]
default_dirs = self.cp.get('DEFAULT', key).split(':')
default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)
def get_paths(self, section, key): default_dirs = self.cp.get('DEFAULT', key).split(':') dirs = [] for d in self.cp.get(section, key).split(':') + default_dirs: dirs.extend([d]+combine_paths(d,['atlas*','ATLAS*'])) return [ d for d in dirs if os.path.isdir(d) ]
for d in self.cp.get(section, key).split(':') + default_dirs:
for d in self.cp.get(section, key).split(os.pathsep) + default_dirs:
def get_paths(self, section, key): default_dirs = self.cp.get('DEFAULT', key).split(':') dirs = [] for d in self.cp.get(section, key).split(':') + default_dirs: dirs.extend([d]+combine_paths(d,['atlas*','ATLAS*'])) return [ d for d in dirs if os.path.isdir(d) ]
assert all(round(abs(desired - actual),decimal) == 0), msg
assert all(around(abs(desired - actual),decimal) == 0), msg
def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1): """ Raise an assertion if two items are not equal. I think this should be part of unittest.py """ msg = '\nItems are not equal:\n' + err_msg try: if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ): msg = msg \ + 'DESIRED: ' + repr(...
return cName + "(%s, %sdtype=%s)" % (lst, lf, typename)
return cName + "(%s, %sdtype='%s')" % (lst, lf, typename)
def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): if arr.size > 0 or arr.shape==(0,): lst = array2string(arr, max_line_width, precision, suppress_small, ', ', "array(") else: # show zero-length shape unless it is (0,) lst = "[], shape=%s" % (repr(arr.shape),) typeless = arr.dtype.type in _t...
libs = ['dfftw','drfftw']
libs = ['drfftw','dfftw']
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() incl_dir = None libs = self.get_libs(self.section+'_libs', self.libs) info = None for d in lib_dirs: r = self.check_libs(d,libs) if r is not None: info = r break if info is not None: flag = 0 for d in incl_dirs: if len(combine_paths...
libs = ['sfftw','srfftw']
libs = ['srfftw','sfftw']
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() incl_dir = None libs = self.get_libs(self.section+'_libs', self.libs) info = None for d in lib_dirs: r = self.check_libs(d,libs) if r is not None: info = r break if info is not None: flag = 0 for d in incl_dirs: if len(combine_paths...
libs = ['fftw_threads','rfftw_threads']
libs = ['rfftw_threads','fftw_threads']
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() incl_dir = None libs = self.get_libs(self.section+'_libs', self.libs) info = None for d in lib_dirs: r = self.check_libs(d,libs) if r is not None: info = r break if info is not None: flag = 0 for d in incl_dirs: if len(combine_paths...
libs = ['dfftw_threads','drfftw_threads']
libs = ['drfftw_threads','dfftw_threads']
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() incl_dir = None libs = self.get_libs(self.section+'_libs', self.libs) info = None for d in lib_dirs: r = self.check_libs(d,libs) if r is not None: info = r break if info is not None: flag = 0 for d in incl_dirs: if len(combine_paths...
libs = ['sfftw_threads','srfftw_threads']
libs = ['srfftw_threads','sfftw_threads']
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() incl_dir = None libs = self.get_libs(self.section+'_libs', self.libs) info = None for d in lib_dirs: r = self.check_libs(d,libs) if r is not None: info = r break if info is not None: flag = 0 for d in incl_dirs: if len(combine_paths...
return retval.view(recarray)
res = retval.view(recarray) res.dtype = sb.dtype((record, res.dtype)) return res
def fromrecords(recList, formats=None, names=None, titles=None, shape=None, aligned=0): """ create a recarray from a list of records in text form The data in the same field can be heterogeneous, they will be promoted to the highest data type. This method is intended for creating smaller record arrays. If used to cre...
if m is not nomask: try: shape = result.shape except AttributeError: pass else: if m.shape != shape: m = mask_or(getmaskarray(a), getmaskarray(b))
def __call__ (self, a, *args, **kwargs): "Execute the call behavior."
if m is not nomask: try: shape = result.shape except AttributeError: pass else: if m.shape != shape: m = mask_or(getmaskarray(a), getmaskarray(b))
def __call__(self, a, b): "Execute the call behavior." ma = getmask(a) mb = getmask(b) d1 = filled(a, self.fillx) d2 = filled(b, self.filly) t = self.domain(d1, d2)
if m is not nomask: try: shape = result.shape except AttributeError: pass else: if m.shape != shape: m = mask_or(getmaskarray(a), getmaskarray(b))
def __call__ (self, a, b, *args, **kwargs): "Execute the call behavior." m = mask_or(getmask(a), getmask(b)) d1 = filled(a, self.fillx) d2 = filled(b, self.filly) result = self.f(d1, d2, *args, **kwargs) if m is not nomask: try: shape = result.shape except AttributeError: pass else: if m.shape != shape: m = mask_or(get...
self.help_fcompiler = None
def initialize_options(self): self.fcompiler = None self.f77exec = None self.f90exec = None self.f77flags = None self.f90flags = None self.opt = None self.arch = None self.debug = None self.noopt = None self.noarch = None self.help_fcompiler = None return
if self.help_fcompiler: from numpy.distutils.fcompiler import show_fcompilers show_fcompilers(self.distribution) sys.exit()
def finalize_options(self): if self.help_fcompiler: from numpy.distutils.fcompiler import show_fcompilers show_fcompilers(self.distribution) sys.exit() return
loader = _ModuleLoader(fullname,location)
loader = _ModuleLoader(fullname,location,p_frame=p_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(...
def __init__(self,name,location):
def __init__(self,name,location,p_frame=None):
def __init__(self,name,location):
if DEBUG: print 'Executing postponed import for %s' %(name)
def _ppimport_importer(self): name = self.__name__
except:
except Exception,msg: p_frame = self.__dict__.get('_ppimport_p_frame',None) if p_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)
def _ppimport_importer(self): name = self.__name__
sc_desired = desired/pow(10,math.floor(math.log10(desired))) sc_actual = actual/pow(10,math.floor(math.log10(actual)))
sc_desired = desired/pow(10,math.floor(math.log10(abs(desired)))) sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))
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...
def cov(m,y=None, rowvar=0, bias=0):
def cov(m,y=None, rowvar=1, bias=0):
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 variances for each column. cov(m) is the same as ...
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 variances for each column. cov(m) is the same as cov(m, m)
If m is a vector, return the variance. For matrices return the covariance matrix. If y is given it is treated as an additional (set of) variable(s).
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 variances for each column. cov(m) is the same as ...
If rowvar is zero, then each row is a variable with observations in the columns. """ if y is None: y = asarray(m) else: y = asarray(y) m = asarray(m)
If rowvar is non-zero (default), then each row is a variable with observations in the columns, otherwise each column is a variable and the observations are in the rows. """ X = asarray(m,ndmin=2) if X.shape[0] == 1: rowvar = 1
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 variances for each column. cov(m) is the same as ...
m = m.transpose() y = y.transpose() if (m.shape[0] == 1): m = m.transpose() if (y.shape[0] == 1): y = y.transpose() N = m.shape[0] if (y.shape[0] != N): raise ValueError, "x and y must have the same number of observations." m = m - m.mean(axis=0) y = y - y.mean(axis=0)
axis = 0 tup = (newaxis, slice(None)) else: axis = 1 tup = (slice(None),newaxis) if y is not None: y = asarray(y,ndmin=2) X = concatenate((X,y),axis) X -= X.mean(axis=axis)[tup] if rowvar: N = X.shape[1] else: N = X.shape[0]
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 variances for each column. cov(m) is the same as ...
val = squeeze(dot(m.transpose(),y.conj()) / fact) return val
if not rowvar: return (dot(X.transpose(), X.conj()) / fact).squeeze() else: return (dot(X,X.transpose().conj())/fact).squeeze()
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 variances for each column. cov(m) is the same as ...
sources = ['scipy_base.fastumathmodule.c','isnan.c']
sources = ['fastumathmodule.c','isnan.c']
def configuration(parent_package=''): parent_path = parent_package if parent_package: parent_package += '.' local_path = get_path(__name__) config = default_config_dict() config['packages'].append(parent_package+'scipy_base') config['package_dir'][parent_package+'scipy_base'] = local_path config['packages'].append(do...
lapack_libs = self.get_libs('lapack_libs', ['lapack']) for d in lib_dirs: lapack = self.check_libs(d,lapack_libs,[]) if lapack is not None: info = lapack break else: return atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas'])
atlas_libs = self.get_libs('atlas_libs', ['lapack','f77blas', 'cblas', 'atlas'])
def calc_info(self): lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs()
dict_append(info, **atlas)
info = atlas
def calc_info(self): lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs()
if ((os.uname()[0] == 'SunOS')):
if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):
def get_extra_link_args(self): # SunOS often has dynamically loaded symbols defined in the # static library libg2c.a The linker doesn't like this. To # ignore the problem, use the -mimpure-text flag. It isn't # the safest thing, but seems to work. args = [] if ((os.uname()[0] == 'SunOS')): args = ['-mimpure-text'] ...
out = N.ndarray.__getitem__(self, index) if not isinstance(out, matrix):
self._getitem = True try: out = N.ndarray.__getitem__(self, index) finally: self._getitem = False if not isinstance(out, N.ndarray):
def __getitem__(self, index): out = N.ndarray.__getitem__(self, index) if not isinstance(out, matrix): return out # Need to swap if slice is on first index # or there is an integer on the second retscal = False try: n = len(index) if (n==2): if isscalar(index[1]): if isscalar(index[0]): retscal = True elif out.shape[0]...
retscal = False try: n = len(index) if (n==2): if isscalar(index[1]): if isscalar(index[0]): retscal = True elif out.shape[0] == 1: sh = out.shape out.shape = (sh[1], sh[0]) 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])...
if out.ndim == 0: return out[()] if out.ndim == 1: sh = out.shape[0] try: n = len(index) except: n = 0 if n > 1 and isscalar(index[1]): out.shape = (sh,1) else: out.shape = (1,sh)
def __getitem__(self, index): out = N.ndarray.__getitem__(self, index) if not isinstance(out, matrix): return out # Need to swap if slice is on first index # or there is an integer on the second retscal = False try: n = len(index) if (n==2): if isscalar(index[1]): if isscalar(index[0]): retscal = True elif out.shape[0]...
' -YCOM_SFX=_ -YEXT_SFX' \ ' -YEXT_NAMES=LCS -s -YEXT_NAMES=_'
' -YCOM_SFX=_ -YEXT_SFX=_' \ ' -YEXT_NAMES=LCS -s'
def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose)
X = asarray(m,ndmin=2)
X = array(m,copy=False,ndmin=2)
def cov(m,y=None, rowvar=1, bias=0): """Estimate the covariance matrix. If m is a vector, return the variance. For matrices return the covariance matrix. If y is given it is treated as an additional (set of) variable(s). Normalization is by (N-1) where N is the number of observations (unbiased estimate). If bias i...
y = asarray(y,ndmin=2)
y = array(y,copy=False,ndmin=2)
def cov(m,y=None, rowvar=1, bias=0): """Estimate the covariance matrix. If m is a vector, return the variance. For matrices return the covariance matrix. If y is given it is treated as an additional (set of) variable(s). Normalization is by (N-1) where N is the number of observations (unbiased estimate). If bias i...
try: return object.__setattr__(self, attr, val) except AttributeError: pass fielddict = sb.ndarray.__getattribute__(self,'dtype').fields
newattr = attr not in self.__dict__ try: res = object.__setattr__(self, attr, val) except AttributeError: fielddict = sb.ndarray.__getattribute__(self,'dtype').fields else: fielddict = sb.ndarray.__getattribute__(self,'dtype').fields if attr not in fielddict: return res if newattr: object.__delattr__(self, attr)
def __setattr__(self, attr, val): try: return object.__setattr__(self, attr, val) except AttributeError: # Must be a fieldname pass fielddict = sb.ndarray.__getattribute__(self,'dtype').fields try: res = fielddict[attr][:2] except (TypeError,KeyError): raise AttributeError, "record array has no attribute %s" % attr ret...
if isinstance(a.dtype, nx.complexfloating):
if isinstance(a.dtype, NX.complexfloating):
def poly(seq_of_zeros): """ Return a sequence representing a polynomial given a sequence of roots. If the input is a matrix, return the characteristic polynomial. Example: >>> b = roots([1,3,1,5,6]) >>> poly(b) array([1., 3., 1., 5., 6.]) """ seq_of_zeros = atleast_1d(seq_of_zeros) sh = seq_of_zeros.shape if len(sh)...
if not isinstance(p.dtype, (nx.floating, nx.complexfloating)):
if not isinstance(p.dtype, (NX.floating, NX.complexfloating)):
def roots(p): """ Return the roots of the polynomial coefficients in p. The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n] """ # If input is scalar, this makes it an array p = atleast_1d(p) if len(p.s...
assert_equal(N.array([],dtype=object).shape, ()) assert_equal(N.array([[],[],[]],dtype=object).shape, (3,))
assert_equal(N.array([],dtype=object).shape, (0,)) assert_equal(N.array([[],[],[]],dtype=object).shape, (3,0))
def check_object_array_shape(self,level=rlevel): """Ticket #239""" assert_equal(N.array([[1,2],3,4],dtype=object).shape, (3,)) assert_equal(N.array([[1,2],[3,4]],dtype=object).shape, (2,2)) assert_equal(N.array([(1,2),(3,4)],dtype=object).shape, (2,2)) assert_equal(N.array([],dtype=object).shape, ()) assert_equal(N.arr...
new_files = [] for p in files: if isinstance(p,str) and '*' in p: new_files.extend(self.paths(p)) else: new_files.append(p) files = new_files
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir prefix>,<path to data file(s)>) - paths to data files where python datadir prefix defaults to package dir. If path is not absolute then it's datadir prefix is package dir + dirname of the pa...
d = appendpath(d,os.path.dirname(p)) p = (d,p)
pd = os.path.dirname(p) if '*' in pd: pn = os.path.basename(p) n = len(pd.split(os.sep)) for d1 in filter(os.path.isdir,self.paths(pd)): p = os.path.join(d1,pn) d1 = os.sep.join(d1.split(os.sep)[-n:]) new_files.append((appendpath(d,d1),p)) continue d = appendpath(d,pd) p = (d,p)
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir prefix>,<path to data file(s)>) - paths to data files where python datadir prefix defaults to package dir. If path is not absolute then it's datadir prefix is package dir + dirname of the pa...
file_list = self.paths(filepattern)
file_list = self.paths(filepattern,include_non_existing=False)
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir prefix>,<path to data file(s)>) - paths to data files where python datadir prefix defaults to package dir. If path is not absolute then it's datadir prefix is package dir + dirname of the pa...
def _fix_paths(self,paths):
def _fix_paths(self,paths,include_non_existing=True):
def _fix_paths(self,paths): assert isinstance(paths,(list,tuple)),`type(paths)` new_paths = [] for n in paths: if isinstance(n,str): if '*' in n or '?' in n: p = glob.glob(n) p2 = glob.glob(njoin(self.local_path,n)) if p2: new_paths.extend(p2) elif p: new_paths.extend(p) else: new_paths.append(n) self.warn('could not r...
new_paths.append(n)
if include_non_existing: new_paths.append(n)
def _fix_paths(self,paths): assert isinstance(paths,(list,tuple)),`type(paths)` new_paths = [] for n in paths: if isinstance(n,str): if '*' in n or '?' in n: p = glob.glob(n) p2 = glob.glob(njoin(self.local_path,n)) if p2: new_paths.extend(p2) elif p: new_paths.extend(p) else: new_paths.append(n) self.warn('could not r...
new_paths.append(n)
if os.path.exists(n): new_paths.append(n) elif include_non_existing: new_paths.append(n)
def _fix_paths(self,paths): assert isinstance(paths,(list,tuple)),`type(paths)` new_paths = [] for n in paths: if isinstance(n,str): if '*' in n or '?' in n: p = glob.glob(n) p2 = glob.glob(njoin(self.local_path,n)) if p2: new_paths.extend(p2) elif p: new_paths.extend(p) else: new_paths.append(n) self.warn('could not r...
def paths(self,*paths):
def paths(self,*paths,**kws):
def paths(self,*paths): """ Apply glob to paths and prepend local_path if needed. """ return self._fix_paths(paths)
return self._fix_paths(paths)
include_non_existing = kws.get('include_non_existing',True) return self._fix_paths(paths, include_non_existing=include_non_existing)
def paths(self,*paths): """ Apply glob to paths and prepend local_path if needed. """ return self._fix_paths(paths)
'numeric':numpy_info,
'Numeric':Numeric_info,
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':numpy_info,
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 [atlas]) or by setting
numpy/distutils/site.cfg file (section [atlas]) 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 [lapack]) or by setting
numpy/distutils/site.cfg file (section [lapack]) 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 [lapack_src]) or by setting
numpy/distutils/site.cfg file (section [lapack_src]) 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 [blas]) or by setting
numpy/distutils/site.cfg file (section [blas]) 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 [blas_src]) or by setting
numpy/distutils/site.cfg file (section [blas_src]) 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,...