rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
raise ValueError, "invalid entry" | raise ValueError, "index (%d) out of range (0<=index<=%d) "\ "in dimension %d" % (obj, N, axis) | 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. 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]]) >>> insertint... |
return nt.void.__getattribute__(self, attr) | else: raise AttributeError, "'record' object has no "\ "attribute '%s'" % attr | def __getattribute__(self, attr): if attr in ['setfield', 'getfield', 'dtype']: return nt.void.__getattribute__(self, attr) fielddict = nt.void.__getattribute__(self, 'dtype').fields res = fielddict.get(attr,None) if res: return self.getfield(*res[:2]) return nt.void.__getattribute__(self, attr) |
return nt.void.__setattr__(self,attr,val) | else: raise AttributeError, "'record' object has no "\ "attribute '%s'" % attr | def __setattr__(self, attr, val): if attr in ['setfield', 'getfield', 'dtype']: raise AttributeError, "Cannot set '%s' attribute" % attr; fielddict = nt.void.__getattribute__(self,'dtype').fields res = fielddict.get(attr,None) if res: return self.setfield(val,*res[:2]) |
res = fielddict[attr][:2] | try: res = fielddict[attr][:2] except KeyError: raise AttributeError, "record array has no attribute %s" % attr | def __getattribute__(self, attr): try: return object.__getattribute__(self,attr) except AttributeError: # attr must be a fieldname pass fielddict = sb.ndarray.__getattribute__(self,'dtype').fields res = fielddict[attr][:2] obj = self.getfield(*res) # if it has fields return a recarray, otherwise return # normal array i... |
res = fielddict[attr][:2] | try: res = fielddict[attr][:2] except KeyError: raise AttributeError, "record array has no attribute %s" % 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 res = fielddict[attr][:2] return self.setfield(val,*res) |
'M': 'O_O_method'} | 'M': 'OO_O_method'} | def indent(st,spaces): indention = ' '*spaces indented = indention + string.replace(st,'\n','\n'+indention) # trim off any trailing spaces indented = re.sub(r' +$',r'',indented) return indented |
for name, vals in funcdict.iteritems(): | for name, uf in funcdict.iteritems(): | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
k=0; sub=0; numin, numout = vals[3] if numin > 1: | k = 0 sub = 0 if uf.nin > 1: assert uf.nin == 2 | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
instr = ''.join([x*numin for x in list(vals[0])]) if len(vals) > 6: if isinstance(vals[6],type('')): outstr = vals[6] else: instr, outstr = vals[6] else: outstr = ''.join([x*numout for x in list(vals[0])]) _valslen = len(vals[0]) assert _valslen*numout == len(outstr), "input/output signature doesn't match" assert len(... | for t in uf.type_descriptions: if t.func_data is not None: | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
(name, k, thedict[char]) | (name, k, thedict[t.type]) | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
thisfunc = vals[2][sub] if len(thisfunc) > 8 and thisfunc[:8] == "PyNumber": | if t.type == 'O': | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
(name, k, thisfunc) | (name, k, t.func_data) | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
datalist.append('(void *)NULL'); | datalist.append('(void *)NULL') elif t.type == 'M': datalist.append('(void *)"%s"' % t.func_data) | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
datalist.append('(void *)%s' % thisfunc) | datalist.append('(void *)%s' % t.func_data) | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
else: datalist.append('(void *)NULL'); funclist.append('%s_%s' % (chartoname[char].upper(), name)) insubstr = instr[numin*k:numin*(k+1)] outsubstr = outstr[numout*k:numout*(k+1)] siglist.extend(['PyArray_%s' % chartoname[x].upper() for x in insubstr]) siglist.extend(['PyArray_%s' % chartoname[x].upper() for x in outsu... | else: datalist.append('(void *)NULL'); tname = chartoname[t.type].upper() funclist.append('%s_%s' % (tname, name)) if t.in_ is None: xlist = t.type * uf.nin else: xlist = t.in_ for x in xlist: siglist.append('PyArray_%s' % (chartoname[x].upper(),)) if t.out is None: xlist = t.type * uf.nout else: xlist = t.out for x i... | def make_arrays(funcdict): # functions array contains an entry for every type implemented # NULL should be placed where PyUfunc_ style function will be filled in later # code1list = [] code2list = [] for name, vals in funcdict.iteritems(): funclist = [] datalist = [] siglist = [] k=0; sub=0; numin, numout = vals[3] ... |
for name, vals in funcdict.items(): | for name, uf in funcdict.items(): | def make_ufuncs(funcdict): code3list = [] for name, vals in funcdict.items(): mlist = [] mlist.append(\ |
"%s", 0);""" % (name,name,name,len(vals[0]), vals[3][0], vals[3][1], vals[4], name, vals[5])) mlist.append(r"""PyDict_SetItemString(dictionary, "%s", f);"""%name) | "%s", 0);""" % (name, name, name, len(uf.type_descriptions), uf.nin, uf.nout, uf.identity, name, uf.docstring)) mlist.append(r"""PyDict_SetItemString(dictionary, "%s", f);""" % name) | def make_ufuncs(funcdict): code3list = [] for name, vals in funcdict.items(): mlist = [] mlist.append(\ |
def convert_vals(funcdict): for name, vals in funcdict.iteritems(): if vals[4] is None: vals[4] = None_ vals2 = vals[2] if len(vals2) > 0: alist = vals2[0].split(',') if len(alist) == 4: a = alist[0] if 'f' in vals[1]: newlist = [ a+'f', a, a+'l'] else: newlist = ['nc_'+a+'f', 'nc_'+a, 'nc_'+a+'l'] elif len(alist) == 7... | def make_ufuncs(funcdict): code3list = [] for name, vals in funcdict.items(): mlist = [] mlist.append(\ | |
convert_vals(funcdict) | def make_code(funcdict,filename): convert_vals(funcdict) code1, code2 = make_arrays(funcdict) code3 = make_ufuncs(funcdict) code2 = indent(code2,4) code3 = indent(code3,4) code = r""" | |
def __array_wrap__ (self, array, context): | def __array_wrap__ (self, array, context=None): | def __array_wrap__ (self, array, context): """Special hook for ufuncs. |
def _choose(self, *args): | def _choose(self, *args, **kwds): | def _choose(self, *args): return choose(self, args) |
def _clip(self,a_min,a_max): | def _clip(self,a_min,a_max,out=None): | def _clip(self,a_min,a_max): return MaskedArray(data = self.data.clip(asarray(a_min).data, asarray(a_max).data), mask = mask_or(self.mask, mask_or(getmask(a_min),getmask(a_max)))) |
if os.name != 'posix': print len(cmd), s, o | if os.name != 'posix': print " ".join(cmd) print o | def CCompiler_spawn(self, cmd, display=None): if display is None: display = cmd if type(display) is type([]): display = ' '.join(display) log.info(display) if type(cmd) is type([]) and os.name == 'nt': cmd = _nt_quote_args(cmd) s,o = exec_command(cmd) if os.name != 'posix': print len(cmd), s, o if s: if type(cmd) is ty... |
if key == '__coerce__': raise KeyError | def __getattr__(self, key): if key == '__coerce__': raise KeyError if key in ['r','roots']: return roots(self.coeffs) elif key in ['c','coef','coefficients']: return self.coeffs elif key in ['o']: return self.order else: return self.__dict__[key] | |
if year == year and month == month and day == day: | if fyear == year and fmonth == month and fday == day: | def local_source_up_to_date(self): """ Hook to test whether a file found in the repository is current """ file = os.path.join(local_repository,self.tarball) up_to_date = 0 try: file_time = os.stat(file)[stat.ST_MTIME] fyear,fmonth,fday = time.localtime(file_time)[:3] year,month,day = time.localtime()[:3] if year == yea... |
level = 1 """ | level = 10 | def full_scipy_build(build_dir = '.', test_level = 10, python_version = '2.2.1', numeric_version = '21.0', f2py_version = '2.13.175-1250', atlas_version = '3.3.14', scipy_version = 'snapshot'): # for now the atlas version is ignored. Only the # binaries for RH are supported at the moment. build_info = {'pyth... |
""" | def full_scipy_build(build_dir = '.', test_level = 10, python_version = '2.2.1', numeric_version = '21.0', f2py_version = '2.13.175-1250', atlas_version = '3.3.14', scipy_version = 'snapshot'): # for now the atlas version is ignored. Only the # binaries for RH are supported at the moment. build_info = {'pyth... | |
""" | def full_scipy_build(build_dir = '.', test_level = 10, python_version = '2.2.1', numeric_version = '21.0', f2py_version = '2.13.175-1250', atlas_version = '3.3.14', scipy_version = 'snapshot'): # for now the atlas version is ignored. Only the # binaries for RH are supported at the moment. build_info = {'pyth... | |
self.inplace = 0 | self.inplace = None | def initialize_options(self): self.extensions = None self.package = None self.py_modules = None self.build_src = None self.build_lib = None self.build_base = None self.force = None self.inplace = 0 self.package_dir = None self.f2pyflags = None self.swigflags = None return |
build_dir = '.' | build_dir = self.ext_target_dir | def generate_sources(self, sources, extension): new_sources = [] func_sources = [] for source in sources: if type(source) is type(''): new_sources.append(source) else: func_sources.append(source) if not func_sources: return new_sources if self.inplace: build_dir = '.' else: build_dir = self.build_src self.mkpath(build_... |
py_files.append(os.path.join(target_dir,name+'.py')) | py_files.append(os.path.join(py_target_dir, name+'.py')) | 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] |
self.spawn(swig_cmd + self.swigflags + ["-o", target, source]) | self.spawn(swig_cmd + self.swigflags \ + ["-o", target, '-outdir', py_target_dir, source]) | 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] |
try: import MacOS except ImportError: is_framework = False else: is_framework = (MacOS.linkmodel == 'framework') if is_framework: target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) if target is None: target = '10.3' major, minor = target.split('.') if int(minor) < 3: minor = '3' warnings.warn('Environment varia... | target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) if target is None: target = '10.3' major, minor = target.split('.') if int(minor) < 3: minor = '3' warnings.warn('Environment variable ' 'MACOSX_DEPLOYMENT_TARGET reset to 10.3') os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major, minor) opt.extend(['-un... | def get_flags_linker_so(self): opt = [] if sys.platform=='darwin': try: import MacOS except ImportError: is_framework = False else: is_framework = (MacOS.linkmodel == 'framework') if is_framework: # This is when Python is from Apple framework target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) if target is None: ... |
pp = self.path_in_package.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. | |
pattern_list = pp + d.split(os.sep) | pattern_list = 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. |
path_list = path.split(os.sep) | if not os.path.isdir(path): print 'Not a directory, skipping',path continue rpath = rel_path(path, self.local_path) path_list = rpath.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. |
assert s==path_list[i],`s,path_list[i],data_path,d` | assert s==path_list[i],`s,path_list[i],data_path,d,path,rpath` | 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. |
target_list = target_list[len(pp):] | 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. | |
fc = 'f77' | fc = 'f90' | def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose) |
self.f77_switches = ' -pic' | self.f77_switches = ' -pic -f77 -ftrap=%none ' | def __init__(self, fc=None, f90c=None, verbose=0): fortran_compiler_base.__init__(self, verbose=verbose) |
return [self.f77_compiler] | return [self.f90_compiler] | def get_linker_so(self): return [self.f77_compiler] |
return a.put(a, ind, v.astype(a.dtype)) | return a.put(ind, v.astype(a.dtype)) | def put (a, ind, v): """put(a, ind, v) results in a[n] = v[n] for all n in ind If v is shorter than mask it will be repeated as necessary. In particular v can be a scalar or length 1 array. The routine put is the equivalent of the following (although the loop is in C for speed): ind = array(indices, copy=False) v = ar... |
ev = linalg.eigvals(a) | if a.dtype.type in (single, double): ad = a.astype(double) else: ad = a.astype(cdouble) ev = linalg.eigvals(ad) | def do(self, a, b): d = linalg.det(a) ev = linalg.eigvals(a) assert_almost_equal(d, multiply.reduce(ev)) |
distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++') | link_cmds = ld.split() if gcc_exists(link_cmds[0]): link_cmds[0] = 'g++' ld = ' '.join(link_cmds) distutils.sysconfig._config_vars['LDSHARED'] = ld | def _init_posix(): old_init_posix() ld = distutils.sysconfig._config_vars['LDSHARED'] distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++') |
def gcc_exists(): | def gcc_exists(name = 'gcc'): | def gcc_exists(): """ Test to make sure gcc is found Does this return correct value on win98??? """ result = 0 try: w,r=os.popen4('gcc -v') w.close() str_result = r.read() #print str_result if string.find(str_result,'Reading specs') != -1: result = 1 except: # This was needed because the msvc compiler messes with # th... |
w,r=os.popen4('gcc -v') | w,r=os.popen4(cmd) | def gcc_exists(): """ Test to make sure gcc is found Does this return correct value on win98??? """ result = 0 try: w,r=os.popen4('gcc -v') w.close() str_result = r.read() #print str_result if string.find(str_result,'Reading specs') != -1: result = 1 except: # This was needed because the msvc compiler messes with # th... |
result = not os.system('gcc -v') | result = not os.system(cmd) | def gcc_exists(): """ Test to make sure gcc is found Does this return correct value on win98??? """ result = 0 try: w,r=os.popen4('gcc -v') w.close() str_result = r.read() #print str_result if string.find(str_result,'Reading specs') != -1: result = 1 except: # This was needed because the msvc compiler messes with # th... |
ext = Extension(dot_join(package,'_compiled_base'),sources) | depends = ['_scipy_mapping.c','_scipy_number.c'] depends = [os.path.join(local_path,x) for x in depends] ext = Extension(dot_join(package,'_compiled_base'),sources, depends = depends) | def configuration(parent_package='',parent_path=None): from scipy_distutils.system_info import get_info, NumericNotFoundError 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_jo... |
print 'Inserting %r to sys.path' % (d1) | print 'Inserting %r to sys.path for test_file %r' % (d1, testfile) | def set_package_path(level=1): """ Prepend package directory to sys.path. set_package_path should be called from a test_file.py that satisfies the following tree structure: <somepath>/<somedir>/test_file.py Then the first existing path name from the following list <somepath>/build/lib.<platform>-<version> <somepath... |
print>>sys.stderr,'Warning: %s' % (message) | from numpy.distutils.misc_util import yellow_text print>>sys.stderr,yellow_text('Warning: %s' % (message)) | def warn(self, message): print>>sys.stderr,'Warning: %s' % (message) sys.stderr.flush() |
return self._check_testcase_name(name) is not None def get_testfile(self, short_module_name): return 'test_' + short_module_name + '.py' | return not not self._check_testcase_name(name) testfile_patterns = ['test_%(modulename)s.py'] def get_testfile(self, module, verbosity = 0): """ Return path to module test file. """ mstr = self._module_str short_module_name = self._get_short_module_name(module) d = os.path.split(module.__file__)[0] test_dir = os.path.... | def check_testcase_name(self, name): return self._check_testcase_name(name) is not None |
def _get_module_tests(self,module,level,verbosity): mstr = self._module_str | def _get_short_module_name(self, module): | def _get_module_tests(self,module,level,verbosity): mstr = self._module_str d,f = os.path.split(module.__file__) |
full_module_name = module.__name__+'.'+short_module_name test_dir = os.path.join(d,'tests') fn = self.get_testfile(short_module_name) test_file = os.path.join(test_dir,fn) local_test_dir = os.path.join(os.getcwd(),'tests') local_test_file = os.path.join(local_test_dir, fn) if os.path.basename(os.path.dirname(local_te... | test_file = self.get_testfile(module, verbosity) if test_file is None: return [] | def _get_module_tests(self,module,level,verbosity): mstr = self._module_str d,f = os.path.split(module.__file__) |
parent_module_name = '.'.join(module.__name__.split('.')[:-1]) test_module_name,ext = os.path.splitext(os.path.basename(test_file)) test_dir_module = parent_module_name+'.tests' test_module_name = test_dir_module+'.'+test_module_name if not sys.modules.has_key(test_dir_module): sys.modules[test_dir_module] = imp.new_m... | def _get_module_tests(self,module,level,verbosity): mstr = self._module_str d,f = os.path.split(module.__file__) | |
test_module = imp.load_module(full_module_name, f, test_file, ('.py', 'r', 1)) | test_module = imp.load_module(test_module_name, f, test_file, ('.py', 'r', 1)) | def _get_module_tests(self,module,level,verbosity): mstr = self._module_str d,f = os.path.split(module.__file__) |
self.warn(' !! FAILURE importing tests for %s' % mstr(module)) | sys.path[:] = old_sys_path self.warn('FAILURE importing tests for %s' % (mstr(module))) | def _get_module_tests(self,module,level,verbosity): mstr = self._module_str d,f = os.path.split(module.__file__) |
sys.path.append(os.path.join('.','compiler')) | sys.path.append(os.path.join('.','weave')) | # lib2def lives in compiler |
self.compiler.libraries.append(lib_dir) | self.compiler.library_dirs.append(lib_dir) | def build_extension(self, ext): #XXX: anything else we need to save? save_linker_so = self.compiler.linker_so save_compiler_libs = self.compiler.libraries save_compiler_libs_dirs = self.compiler.library_dirs # support for building static fortran libraries need_f_libs = 0 need_f_opts = getattr(ext,'need_fcompiler_opts'... |
if sys.platform[:3] > '2.3': | if sys.version[:3] > '2.3': | def link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols = None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): if sys.platform[:3] > '2.3': if libraries: libraries.append('msvcr71') else: libraries = ['msvcr71... |
interactive = len(sys.argv)<=1 if interactive: | if len(sys.argv)<=1: | def setup(**attr): interactive = len(sys.argv)<=1 if interactive: from interactive import interactive_sys_argv sys.argv[:] = interactive_sys_argv(sys.argv) cmdclass = numpy_cmdclass.copy() new_attr = attr.copy() if new_attr.has_key('cmdclass'): cmdclass.update(new_attr['cmdclass']) new_attr['cmdclass'] = cmdclass i... |
if interactive: try: r = old_setup(**new_attr) except Exception, msg: print '-'*72 print 'setup failed with:',msg raw_input('Press ENTER to close the interactive session..') raise msg print '-'*72 raw_input('Press ENTER to close the interactive session..') print '='*72 else: return old_setup(**new_attr) | return old_setup(**new_attr) | def setup(**attr): interactive = len(sys.argv)<=1 if interactive: from interactive import interactive_sys_argv sys.argv[:] = interactive_sys_argv(sys.argv) cmdclass = numpy_cmdclass.copy() new_attr = attr.copy() if new_attr.has_key('cmdclass'): cmdclass.update(new_attr['cmdclass']) new_attr['cmdclass'] = cmdclass i... |
return array(lst) | return array(lst, dtype) | def indices(dimensions, dtype=int): """indices(dimensions,dtype=int) returns an array representing a grid of indices with row-only, and column-only variation. """ tmp = ones(dimensions, dtype) lst = [] for i in range(len(dimensions)): lst.append( add.accumulate(tmp, i, )-1 ) return array(lst) |
module_dir_switch = None module_include_switch = None | module_dir_switch = '/module:' module_include_switch = '/I' | def get_flags_linker_so(self): if sys.platform[:5]=='linux': return ['-shared'] return ['-shared','-Wl,-expect_unresolved,*'] |
self.need_refresh = not self.info | def __init__ (self): self.__class__.info = {} self.need_refresh = not self.info self.local_prefixes = [] | |
self.__class__.info = info | self.saved_results[self.__class__.__name__] = info def has_info(self): return self.saved_results.has_key(self.__class__.__name__) | def set_info(self,**info): self.__class__.info = info |
if self.need_refresh: | flag = 0 if not self.has_info(): flag = 1 | def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ if self.need_refresh: if self.verbose: print self.__class__.__name__ + ':' for p in self.local_prefixes + prefixes: if self.verbose: print ' Looking in',p,'...' self.calc_info(p) if self.info: br... |
if self.info: break self.need_refresh = 0 | if self.has_info(): break | def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ if self.need_refresh: if self.verbose: print self.__class__.__name__ + ':' for p in self.local_prefixes + prefixes: if self.verbose: print ' Looking in',p,'...' self.calc_info(p) if self.info: br... |
if not self.info: | if not self.has_info(): | def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ if self.need_refresh: if self.verbose: print self.__class__.__name__ + ':' for p in self.local_prefixes + prefixes: if self.verbose: print ' Looking in',p,'...' self.calc_info(p) if self.info: br... |
for k,v in self.info.items(): print ' %s = %s'%(k,v) print return self.info | res = self.saved_results.get(self.__class__.__name__) if self.verbose and flag: for k,v in res.items(): print ' %s = %s'%(k,v) print return res | def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ if self.need_refresh: if self.verbose: print self.__class__.__name__ + ':' for p in self.local_prefixes + prefixes: if self.verbose: print ' Looking in',p,'...' self.calc_info(p) if self.info: br... |
dict_append(info,define_macros=('SCIPY_FFTW_H',1)) | dict_append(info,define_macros=[('SCIPY_FFTW_H',1)]) | def calc_info(self,prefix): lib_dirs = filter(os.path.isdir, combine_paths(prefix,'lib',['fftw*','FFTW*'])) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['fftw*','FFTW*'],'lib')) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['lib','fftw*','FFTW*'])) if not lib_dirs: ... |
dict_append(info,define_macros=('SCIPY_DFFTW_H',1)) | dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)]) | def calc_info(self,prefix): lib_dirs = filter(os.path.isdir, combine_paths(prefix,'lib',['fftw*','FFTW*'])) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['fftw*','FFTW*'],'lib')) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['lib','fftw*','FFTW*'])) if not lib_dirs: ... |
dict_append(info,define_macros=('SCIPY_SFFTW_H',1)) | dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)]) | def calc_info(self,prefix): lib_dirs = filter(os.path.isdir, combine_paths(prefix,'lib',['fftw*','FFTW*'])) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['fftw*','FFTW*'],'lib')) if not lib_dirs: lib_dirs = filter(os.path.isdir, combine_paths(prefix,['lib','fftw*','FFTW*'])) if not lib_dirs: ... |
if len (args)==1: return [r for r in map(glob,args[0]) if r] if len (args)==2: | if len(args)==1: result = reduce(lambda a,b:a+b,map(glob,args[0]),[]) elif len (args)==2: | def combine_paths(*args): """ Return a list of existing paths composed by all combinations of items from arguments. """ r = [] for a in args: if not a: continue if type(a) is types.StringType: a = [a] r.append(a) args = r if not args: return [] if len (args)==1: return [r for r in map(glob,args[0]) if r] if len (args)=... |
return result result = combine_paths(*(combine_paths(args[0],args[1])+args[2:])) | else: result = combine_paths(*(combine_paths(args[0],args[1])+args[2:])) | def combine_paths(*args): """ Return a list of existing paths composed by all combinations of items from arguments. """ r = [] for a in args: if not a: continue if type(a) is types.StringType: a = [a] r.append(a) args = r if not args: return [] if len (args)==1: return [r for r in map(glob,args[0]) if r] if len (args)=... |
if n=='system_info': continue | if n in ['system_info','get_info']: continue | def show_all(): import system_info import pprint match_info = re.compile(r'.*?_info').match for n in filter(match_info,dir(system_info)): if n=='system_info': continue c = getattr(system_info,n)() r = c.get_info() |
a = _castCopyAndTranspose(t, a) | a = _fastCopyAndTranspose(t, a) | def cholesky(a): _assertRank2(a) _assertSquareness(a) t, result_t = _commonType(a) a = _castCopyAndTranspose(t, a) m = a.shape[0] n = a.shape[1] if isComplexType(t): lapack_routine = lapack_lite.zpotrf else: lapack_routine = lapack_lite.dpotrf results = lapack_routine('L', n, a, m, 0) if results['info'] > 0: raise LinA... |
a = _castCopyAndTranspose(t, a) | a = _fastCopyAndTranspose(t, a) | def eigvalsh(a, UPLO='L'): _assertRank2(a) _assertSquareness(a) t, result_t = _commonType(a) real_t = _linalgRealType(t) a = _castCopyAndTranspose(t, a) n = a.shape[0] liwork = 5*n+3 iwork = zeros((liwork,), fortran_int) if isComplexType(t): lapack_routine = lapack_lite.zheevd w = zeros((n,), real_t) lwork = 1 work = z... |
a = _castCopyAndTranspose(t, a) | a = _fastCopyAndTranspose(t, a) | def eigh(a, UPLO='L'): """Compute eigenvalues for a Hermitian-symmetric matrix. """ a, wrap = _makearray(a) _assertRank2(a) _assertSquareness(a) t, result_t = _commonType(a) real_t = _linalgRealType(t) a = _castCopyAndTranspose(t, a) n = a.shape[0] liwork = 5*n+3 iwork = zeros((liwork,), fortran_int) if isComplexType(t... |
a, bstar = _castCopyAndTranspose(t, a, bstar) | a, bstar = _fastCopyAndTranspose(t, a, bstar) | def lstsq(a, b, rcond=1.e-10): """returns x,resids,rank,s |
path = default_dir() | path = catalog.default_dir() | def check_is_writable(self): path = default_dir() name = os.path.join(path,'dummy_catalog') test_file = open(name,'w') try: test_file.write('making sure default location is writable\n') finally: test_file.close() os.remove(name) |
in_path = default_dir() | in_path = catalog.default_dir() | def check_default(self): in_path = default_dir() path = catalog.catalog_path(in_path) d,f = os.path.split(path) assert(d == in_path) assert(f == os_dependent_catalog_name()) |
assert(f == os_dependent_catalog_name()) | assert(f == catalog.os_dependent_catalog_name()) | def check_default(self): in_path = default_dir() path = catalog.catalog_path(in_path) d,f = os.path.split(path) assert(d == in_path) assert(f == os_dependent_catalog_name()) |
assert(f == os_dependent_catalog_name()) | assert(f == catalog.os_dependent_catalog_name()) | def check_current(self): in_path = '.' path = catalog.catalog_path(in_path) d,f = os.path.split(path) assert(d == os.path.abspath(in_path)) assert(f == os_dependent_catalog_name()) |
assert(order == ['first','second','third',default_dir()]) | assert(order == ['first','second','third',catalog.default_dir()]) | def check_build_search_order1(self): """ MODULE in search path should be replaced by module_dir. """ q = catalog.catalog(['first','MODULE','third']) q.set_module_directory('second') order = q.build_search_order() assert(order == ['first','second','third',default_dir()]) |
assert(order == ['first','third',default_dir()]) | assert(order == ['first','third',catalog.default_dir()]) | def check_build_search_order2(self): """ MODULE in search path should be removed if module_dir==None. """ q = catalog.catalog(['first','MODULE','third']) order = q.build_search_order() assert(order == ['first','third',default_dir()]) |
assert(order == ['first','second',default_dir()]) | assert(order == ['first','second',catalog.default_dir()]) | def check_build_search_order3(self): """ If MODULE is absent, module_dir shouldn't be in search path. """ q = catalog.catalog(['first','second']) q.set_module_directory('third') order = q.build_search_order() assert(order == ['first','second',default_dir()]) |
assert(order == ['first','second','third','fourth','fifth',default_dir()]) | assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()]) | def check_build_search_order4(self): """ Make sure environment variable is getting used. """ q = catalog.catalog(['first','second']) if sys.platform == 'win32': sep = ';' else: sep = ':' os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth')) q.set_module_directory('third') order = q.build_search_order() a... |
PyArrayObject *arr = NULL;\\ if (!obj) return -2;\\ if (!PyArray_Check(obj)) return -1;\\ if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYCOMPLEXPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\ if (arr->descr->type==typecode) {\\ *(ctype *)(arr->data)=(*v).r;\\ *(ctype *)(arr->data+sizeof(ctype))=(*v).i;\\ ret... | #ifdef NUMARRAY | |
if a.ndim == 0: return array([],dtype=intp) else: b = a.nonzero() retarr = empty((b[0].shape[0],a.ndim),dtype=intp) for k in xrange(a.ndim): retarr[:,k] = b[k] return retarr | return transpose(a.nonzero()) | def argwhere(a): """Return a 2-d array of shape N x a.ndim where each row is a sequence of indices into a. This sequence must be converted to a tuple in order to be used to index into a. """ if a.ndim == 0: return array([],dtype=intp) else: b = a.nonzero() retarr = empty((b[0].shape[0],a.ndim),dtype=intp) for k in xra... |
for arg in args: try: n = len(arg) if (n==0): return self.zerocall(args) except (AttributeError, TypeError): pass return squeeze(arraymap(self.thefunc,args,self.otypes)) def zerocall(self,args): | try: return squeeze(arraymap(self.thefunc,args,self.otypes)) except IndexError: return self.zerocall(*args) def zerocall(self,*args): | def __call__(self,*args): for arg in args: try: n = len(arg) if (n==0): return self.zerocall(args) except (AttributeError, TypeError): pass return squeeze(arraymap(self.thefunc,args,self.otypes)) |
_lkup = {'0':'000', '1':'001', '2':'010', '3':'011', '4':'100', '5':'101', '6':'110', '7':'111', 'L':''} | _lkup = { '0':'0000', '1':'0001', '2':'0010', '3':'0011', '4':'0100', '5':'0101', '6':'0110', '7':'0111', '8':'1000', '9':'1001', 'a':'1010', 'b':'1011', 'c':'1100', 'd':'1101', 'e':'1110', 'f':'1111', 'L':''} | def isscalar(num): """Returns True if the type of num is a scalar type. """ if isinstance(num, generic): return True else: return type(num) in ScalarType |
ostr = oct(num) | ostr = hex(num) | def binary_repr(num): """Return the binary representation of the input number as a string. This is equivalent to using base_repr with base 2, but about 25x faster. """ ostr = oct(num) bin = '' for ch in ostr[1:]: bin += _lkup[ch] ind = 0 while bin[ind] == '0': ind += 1 return bin[ind:] |
for ch in ostr[1:]: | for ch in ostr[2:]: | def binary_repr(num): """Return the binary representation of the input number as a string. This is equivalent to using base_repr with base 2, but about 25x faster. """ ostr = oct(num) bin = '' for ch in ostr[1:]: bin += _lkup[ch] ind = 0 while bin[ind] == '0': ind += 1 return bin[ind:] |
ind = 0 while bin[ind] == '0': ind += 1 return bin[ind:] | if '1' in bin: ind = 0 while bin[ind] == '0': ind += 1 return bin[ind:] else: return '0' | def binary_repr(num): """Return the binary representation of the input number as a string. This is equivalent to using base_repr with base 2, but about 25x faster. """ ostr = oct(num) bin = '' for ch in ostr[1:]: bin += _lkup[ch] ind = 0 while bin[ind] == '0': ind += 1 return bin[ind:] |
pattern_list = abspath(d).split(os.sep) | pattern_list = allpath(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. |
assert_equal(r[0],(456, 'dbe', 1.2)) | assert_equal(r[0].toscalar(),(456, 'dbe', 1.2)) | def check_fromrecords(self): r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3') assert_equal(r[0],(456, 'dbe', 1.2)) |
putmask(ddmod,(ddmod==-pi) & (dd > 0),pi) | Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi) | def unwrap(p,discont=pi,axis=-1): """unwraps radian phase p by changing absolute jumps greater than discont to their 2*pi complement along the given axis. """ p = asarray(p) nd = len(p.shape) dd = diff(p,axis=axis) slice1 = [slice(None,None)]*nd # full slices slice1[axis] = slice(1,None) ddmod = mod(dd+pi,2*pi)-pi ... |
putmask(ph_correct,abs(dd)<discont,0) | Numeric.putmask(ph_correct,abs(dd)<discont,0) | def unwrap(p,discont=pi,axis=-1): """unwraps radian phase p by changing absolute jumps greater than discont to their 2*pi complement along the given axis. """ p = asarray(p) nd = len(p.shape) dd = diff(p,axis=axis) slice1 = [slice(None,None)]*nd # full slices slice1[axis] = slice(1,None) ddmod = mod(dd+pi,2*pi)-pi ... |
putmask(x,isnan(x),-inf) | Numeric.putmask(x,isnan(x),-inf) | def nanmax(x,axis=-1): """Find the maximum over the given axis ignoring nans. """ x = asarray(x).copy() putmask(x,isnan(x),-inf) return amax(x,axis) |
putmask(x,isnan(x),-inf) | Numeric.putmask(x,isnan(x),-inf) | def nanargmax(x,axis=-1): """Find the maximum over the given axis ignoring nans. """ x = asarray(x).copy() putmask(x,isnan(x),-inf) return argmax(x,axis) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.