rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
ds = os.path.join(*([d]+os.path.normpath(path).split()[1:]))
ds = os.path.join(d,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 + ...
- 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults
- 2-sequence (<datadir prefix>,<path to data file(s)>) - paths to data files where python datadir prefix defaults
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
If path is not absolute then it's datadir suffix is
If path is not absolute then it's datadir prefix is
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
if type(p) is type(''):
if type(p) is not type(()):
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
file_list = self.paths(p) if not os.path.isabs(p):
if type(p) is type('') and not os.path.isabs(p):
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
elif type(p) is type(()): assert len(p)==2,`p` d = p[0] if type(p[1]) is type(''): file_list = self.paths(p[1])
p = (d,p) new_files.append(p) files = [] for prefix,filepattern in new_files: if type(filepattern) is type(''): file_list = self.paths(filepattern) elif callable(filepattern): file_list = [filepattern] else: file_list = self.paths(*filepattern) nof_path_components = [len(f.split(os.sep)) \ for f in file_list if type(f...
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
file_list = self.paths(*p[1]) else: d = os.path.join(*(self.name.split('.'))) file_list = [p] if not data_dict.has_key(d): data_dict[d] = file_list[:] else: data_dict[d].extend(file_list)
p = prefix if not data_dict.has_key(p): data_dict[p] = [f] else: data_dict[p].append(f)
def add_data_files(self,*files): """ Add data files to configuration data_files. Argument(s) can be either - 2-sequence (<datadir suffix>,<path to data file(s)>) - paths to data files where python datadir suffix defaults to package dir. If path is not absolute then it's datadir suffix is package dir + dirname of the pa...
info = self.check_libs(os.path.join(prefix,'lib'),
atlas = self.check_libs(os.path.join(prefix,'lib'),
def calc_info_debian(self,prefix): print 'Trying Debian setup' info = self.check_libs(os.path.join(prefix,'lib'), ['cblas','f77blas','atlas'],[]) if not info: return lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[]) if not lapack: lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[...
if not info: return
if not atlas: return
def calc_info_debian(self,prefix): print 'Trying Debian setup' info = self.check_libs(os.path.join(prefix,'lib'), ['cblas','f77blas','atlas'],[]) if not info: return lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[]) if not lapack: lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[...
dict_append(info,**lapack)
dict_append(info,**atlas)
def calc_info_debian(self,prefix): print 'Trying Debian setup' info = self.check_libs(os.path.join(prefix,'lib'), ['cblas','f77blas','atlas'],[]) if not info: return lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[]) if not lapack: lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[...
self.add_data_files(generate_svn_version_py())
d = os.path.join(*(self.name.split('.'))) self.add_data_files((d,generate_svn_version_py()))
def rm_file(f=target): try: os.remove(f); print 'removed',f except OSError: pass try: os.remove(f+'c'); print 'removed',f+'c' except OSError: pass
short_module_name = module.__name__.split('.')[-1]
short_module_name = os.path.splitext(os.path.basename(f))[0]
def _get_module_tests(self,module,level): mstr = self._module_str d,f = os.path.split(module.__file__) short_module_name = module.__name__.split('.')[-1] test_dir = os.path.join(d,'tests') test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')
if not hasattr(test_module,'test_suite_list'): if hasattr(test_module,'test_suite'): try: total_suite = test_module.test_suite(level) return total_suite._tests except: print ' !! FAILURE building tests for ', mstr(module) print ' ', output_exception() return [] suite_list = [] for name in dir(test_module): obj = g...
if hasattr(test_module,'test_suite'): try: total_suite = test_module.test_suite(level) return total_suite._tests except: print ' !! FAILURE building tests for ', mstr(module) print ' ', output_exception() return [] suite_list = [] for name in dir(test_module): obj = getattr(test_module, name) if type(obj) is not t...
def _get_module_tests(self,module,level): mstr = self._module_str d,f = os.path.split(module.__file__) short_module_name = module.__name__.split('.')[-1] test_dir = os.path.join(d,'tests') test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')
np.random.seed(1) x = np.rand(5) y = np.rand(5)
x = array([ 0.41702200, 0.72032449, 0.00011437481, 0.302332573, 0.146755891]) y = array([ 0.09233859, 0.18626021, 0.34556073, 0.39676747, 0.53881673])
def check_simple(self): import numpy as np np.random.seed(1) x = np.rand(5) y = np.rand(5) xedges = np.linspace(0,1,10) yedges = np.linspace(0,1,10) H = np.histogram2d(x,y, (xedges, yedges))[0] answer = np.array([[0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0...
format_re = re.compile(r'(?P<repeat> *[(]?[ ,0-9]*[)]? *)(?P<dtype>[><|A-Za-z0-9.]*)')
format_re = re.compile(r'(?P<order1>[<>|=]?)(?P<repeats> *[(]?[ ,0-9]*[)]? *)(?P<order2>[<>|=]?)(?P<dtype>[A-Za-z0-9.]*)')
def _split(input): """Split the input formats string into field formats without splitting the tuple used to specify multi-dimensional arrays.""" newlist = [] hold = '' for element in input.split(','): if hold != '': item = hold + ',' + element else: item = element left = item.count('(') right = item.count(')') # if ...
(repeats, dtype) = format_re.match(item).groups()
(order1, repeats, order2, dtype) = format_re.match(item).groups()
def _commastring(astr): res = _split(astr) if (len(res)) < 1: raise ValueError, "unrecognized formant" result = [] for k,item in enumerate(res): # convert item try: (repeats, dtype) = format_re.match(item).groups() except (TypeError, AttributeError): raise ValueError('format %s is not recognized' % item) if (repeats =...
a = a._ppimport_module
a = getattr(a,'_ppimport_module',a)
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()...
def _scipy_pydoc_help_call(self,*args,**kwds): _old_pydoc_help_call.__doc__
def _ppimport_pydoc_help_call(self,*args,**kwds):
def _scipy_pydoc_help_call(self,*args,**kwds): _old_pydoc_help_call.__doc__ return _old_pydoc_help_call(self, *map(_ppresolve_ignore_failure,args), **kwds)
_pydoc.help.__class__.__call__ = _new.instancemethod(_scipy_pydoc_help_call,
_ppimport_pydoc_help_call.__doc__ = _old_pydoc_help_call.__doc__ _pydoc.help.__class__.__call__ = _new.instancemethod(_ppimport_pydoc_help_call,
def _scipy_pydoc_help_call(self,*args,**kwds): _old_pydoc_help_call.__doc__ return _old_pydoc_help_call(self, *map(_ppresolve_ignore_failure,args), **kwds)
def _scipy_pydoc_Doc_document(self,*args,**kwds): _old_pydoc_Doc_document.__doc__
def _ppimport_pydoc_Doc_document(self,*args,**kwds):
def _scipy_pydoc_Doc_document(self,*args,**kwds): _old_pydoc_Doc_document.__doc__ args = (_ppresolve_ignore_failure(args[0]),) + args[1:] return _old_pydoc_Doc_document(self,*args,**kwds)
_pydoc.Doc.document = _new.instancemethod(_scipy_pydoc_Doc_document,
_ppimport_pydoc_Doc_document.__doc__ = _old_pydoc_Doc_document.__doc__ _pydoc.Doc.document = _new.instancemethod(_ppimport_pydoc_Doc_document,
def _scipy_pydoc_Doc_document(self,*args,**kwds): _old_pydoc_Doc_document.__doc__ args = (_ppresolve_ignore_failure(args[0]),) + args[1:] return _old_pydoc_Doc_document(self,*args,**kwds)
def _scipy_pydoc_describe(object): _old_pydoc_describe.__doc__
def _ppimport_pydoc_describe(object):
def _scipy_pydoc_describe(object): _old_pydoc_describe.__doc__ return _old_pydoc_describe(_ppresolve_ignore_failure(object))
_pydoc.describe = _scipy_pydoc_describe import inspect as _inspect _old_inspect_getfile = _inspect.getfile def _scipy_inspect_getfile(object): _old_inspect_getfile.__doc__ if isinstance(object,_ModuleLoader): return object.__dict__['__file__'] return _old_inspect_getfile(object) _inspect.getfile = _scipy_inspect_getfi...
_ppimport_pydoc_describe.__doc__ = _old_pydoc_describe.__doc__ _pydoc.describe = _ppimport_pydoc_describe import inspect as _inspect _old_inspect_getfile = _inspect.getfile def _ppimport_inspect_getfile(object): if isinstance(object,_ModuleLoader): return object.__dict__['__file__'] return _old_inspect_getfile(object)...
def _scipy_pydoc_describe(object): _old_pydoc_describe.__doc__ return _old_pydoc_describe(_ppresolve_ignore_failure(object))
if compiler_name == 'gcc':
if compiler_name is None: compiler_dir = '' elif compiler_name == 'gcc':
def get_compiler_dir(compiler_name): if compiler_name == 'gcc': status, text = run_command(compiler_name + ' --version') try: import re version = re.findall('\d\.\d',text)[0] except IndexError: version = '' compiler_dir = compiler_name + version else: compiler_dir = compiler_name return compiler_dir
{l_not(l_or(isintent_out,isintent_hide)):"""\
{l_not(isintent_hide):"""\
{l_not(isintent_callback):'\t#cbname#_typedef #varname#_cptr;'}
{l_and(isintent_hide,l_not(isintent_out)):"""\t\tPy_XDECREF(capi_
{isintent_hide:"""\t\tPy_XDECREF(capi_
{l_not(isintent_callback):'\t#cbname#_typedef #varname#_cptr;'}
if not lib_dirs: return
if not lib_dirs: lib_dirs = [prefix]
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 not incl_dirs: return
if not incl_dirs: incl_dirs = [prefix]
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: ...
return os.path.join(*l)
return os.sep.join(l)
def minrelpath(path): """ Resolve `..` and '.' from path. """ if not is_string(path): return path if '.' not in path: return path l = path.split(os.sep) while l: try: i = l.index('.',1) except ValueError: break del l[i] j = 1 while l: try: i = l.index('..',j) except ValueError: break if l[i-1]=='..': j += 1 else: del l...
return a1 - a2
val = a1 - a2
def polysub(a1, a2): """Subtracts two polynomials represented as sequences """ truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d)) a1 = atleast_1d(a1) a2 = atleast_1d(a2) diff = len(a2) - len(a1) if diff == 0: return a1 - a2 elif diff > 0: zr = NX.zeros(diff, a1.dtype) val = NX.concatenate((zr, a1)) - a2 else...
raise ValueError, "array-shape mismatch in array", k
raise ValueError, "array-shape mismatch in array %d" % k
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]...
print 'command:', self.ver_cmd
def get_version(self): """Return the compiler version. If compiler is not available, return empty string.""" # XXX: Is there compilers that have no version? If yes, # this test will fail even if the compiler is available. if self.version is not None: # Finding version is expensive, so return previously found # ver...
print exit_status, out_text
def get_version(self): """Return the compiler version. If compiler is not available, return empty string.""" # XXX: Is there compilers that have no version? If yes, # this test will fail even if the compiler is available. if self.version is not None: # Finding version is expensive, so return previously found # ver...
ver_match = r'g77 version (?P<version>[^\s*]*)'
ver_match = r'GNU Fortran (?P<version>[^\s*]*)'
def get_extra_link_args(self):
self.ver_cmd = self.f77_compiler + ' -v '
self.ver_cmd = self.f77_compiler + ' --version'
def __init__(self, fc = None, f90c = None): fortran_compiler_base.__init__(self) if sys.platform == 'win32': self.libraries = ['gcc','g2c'] self.library_dirs = self.find_lib_directories() else: # On linux g77 does not need lib_directories to be specified. self.libraries = ['g2c']
pardir = os.path.join(temp,'catalog_test')
pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())
def get_test_dir(self,erase = 0): # make sure tempdir catalog doesn't exist import tempfile temp = tempfile.gettempdir() pardir = os.path.join(temp,'catalog_test') if not os.path.exists(pardir): os.mkdir(pardir) catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat') if os.path.exists(catalog_file) and e...
formats = sb.dtype(dtype) if isinstance(formats, sb.dtype): descr = formats
descr = sb.dtype(dtype)
def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None, formats=None, names=None, titles=None, byteorder=None, aligned=False): if dtype is not None: formats = sb.dtype(dtype)
if dtype is not None: formats = sb.dtype(dtype)
def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, 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] (2,...
if formats is None:
if formats is None and dtype is None:
def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, 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] (2,...
if isinstance(formats, sb.dtype): descr = formats _names = descr.names
if dtype is not None: descr = sb.dtype(dtype) _names = dtype.names
def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, 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] (2,...
if dtype is not None: formats = sb.dtype(dtype)
def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, byteorder=None): """ 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 re...
if formats is None:
if formats is None and dtype is None:
def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, byteorder=None): """ 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 re...
if isinstance(formats, sb.dtype): descr = formats
if dtype is not None: descr = sb.dtype(dtype)
def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=0, byteorder=None): """ 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 re...
formats = sb.dtype(dtype) if formats is None: raise ValueError, "Must have dtype= or formats=" if isinstance(formats, sb.dtype): descr = formats
descr = sb.dtype(dtype)
def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, byteorder=None, aligned=0): """ create a (read-only) record array from binary data contained in a string""" if dtype is not None: formats = sb.dtype(dtype) if formats is None: raise ValueError, "Must have dtype= or for...
if dtype is not None: formats = sb.dtype(dtype)
def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, byteorder=None, aligned=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. >>> import testdata, sys >>> fd=open(testdata.filename) >>> fd.seek(2880*...
if isinstance(formats, sb.dtype): descr = formats
if dtype is not None: descr = sb.dtype(dtype)
def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, byteorder=None, aligned=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. >>> import testdata, sys >>> fd=open(testdata.filename) >>> fd.seek(2880*...
noarch = conf.get('noarch',[None,1,noopt])[2]
if 0: noarch = 1 else: noarch = conf.get('noarch',[None,noopt])[1]
def customize(self, dist=None): """ Customize Fortran compiler.
target_dir = self.build_src
if type(extension) is type(()): name = extension[0] else: name = extension.name target_dir = os.path.join(*([self.build_src]\ +name.split('.')[:-1]))
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
import scipy.base as base include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))
import scipy if scipy.show_core_config is None: include_dirs.append(os.path.join(os.path.dirname(scipy.__file__), 'base','include')) else: import scipy.base as base include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))
def get_scipy_include_dirs(): include_dirs = Configuration.scipy_include_dirs[:] if not include_dirs: import scipy.base as base include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include')) #from distutils.sysconfig import get_python_inc #prefix = [] #for name in scipy.__file__.split(os.sep): # if name...
ar_exe = MSVCCompiler().lib
m = MSVCCompiler() m.initialize() ar_exe = m.lib
def get_flags_linker_so(self): if sys.platform[:5]=='linux': return ['-shared'] return ['-shared','-Wl,-expect_unresolved,*']
fielddict = ndarray.__getattribute__(self,'dtype').fields
fielddict = ndarray.__getattribute__(self,'dtype').fields or {}
def __setattr__(self, attr, val): newattr = attr not in self.__dict__ try: ret = object.__setattr__(self, attr, val) except: fielddict = ndarray.__getattribute__(self,'dtype').fields if attr not in fielddict: exctype, value = sys.exc_info()[:2] raise exctype, value else: fielddict = ndarray.__getattribute__(self,'dtype...
postpone = options.get('postpone',False)
postpone = options.get('postpone',None)
def __call__(self,*packages, **options): """Load one or more packages into parent package top-level namespace.
if (postpone and not global_symbols) or postpone_import:
if (postpone and not global_symbols) \ or (postpone_import and postpone is not None):
def __call__(self,*packages, **options): """Load one or more packages into parent package top-level namespace.
if step is None: step = 1
start = key[k].start if start is None: start=0 if step is None: step=1
def __getitem__(self,key): try: size = [] typecode = Numeric.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))) typecode = Numeric.Float else: size.append(int((key[k].stop - start)/(step*1.0))...
step = (key[k].stop - key[k].start)/float(step-1) nn[k] = (nn[k]*step+key[k].start)
step = (key[k].stop - start)/float(step-1) nn[k] = (nn[k]*step+start)
def __getitem__(self,key): try: size = [] typecode = Numeric.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))) typecode = Numeric.Float else: size.append(int((key[k].stop - start)/(step*1.0))...
print 'Inserting %r to sys.path' % (d1)
if DEBUG: print 'Inserting %r to sys.path' % (d1)
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...
val = val[0]
val = ''
def __getitem__(self, obj): val = ndarray.__getitem__(self, obj) if isinstance(val, (string_, unicode_)): temp = val.rstrip() if len(temp) == 0: val = val[0] else: val = temp return val
_cast_dict['LONGLONG'] = _cast_dict['LONG'] + ['ULONG','LONGLONG'] _cast_dict['ULONGLONG'] = _cast_dict['ULONG'] + ['LONG','ULONGLONG']
_cast_dict['LONGLONG'] = _cast_dict['LONG'] + ['LONGLONG'] _cast_dict['ULONGLONG'] = _cast_dict['ULONG'] + ['ULONGLONG']
def is_intent_exact(self,*names): return len(self.intent_list)==len(names) and self.is_intent(*names)
def find_modules(self): old_py_modules = self.py_modules[:] new_py_modules = filter(lambda i:type(i) is type(str), self.py_modules) self.py_modules[:] = new_py_modules modules = old_build_py.find_modules(self) self.py_modules[:] = old_py_modules return modules
def find_package_modules(self, package, package_dir): modules = old_build_py.find_package_modules(self, package, package_dir)
if self.inplace:
if self.inplace and not is_sequence(extension):
def generate_sources(self, sources, extension): new_sources = [] func_sources = [] for source in sources: if is_string(source): new_sources.append(source) else: func_sources.append(source) if not func_sources: return new_sources if self.inplace: build_dir = self.ext_target_dir else: if is_sequence(extension): name = ex...
return a * b
return _nx.multiply(a,b)
def kron(a,b): """kronecker product of a and b Kronecker product of two arrays is block array [[ 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 = get_array_wrap(a, b) b = asanyarray(b) a = array(a,copy=False,s...
p = self.combine_paths (d,['libdjbfft.a'])
p = self.combine_paths (d,['libdjbfft.a','libdjbfft'+so_ext])
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() info = None for d in lib_dirs: p = self.combine_paths (d,['djbfft.a']) if p: info = {'extra_objects':p} break p = self.combine_paths (d,['libdjbfft.a']) if p: info = {'libraries':['djbfft'],'library_dirs':[d]} break if info is None:...
if obj.dtypechar in 'SU':
if obj.dtype in [sb.string, sb.unicode_]:
def __getattribute__(self, attr): fielddict = sb.ndarray.__getattribute__(self,'dtypedescr').fields try: res = fielddict[attr][:2] except: return sb.ndarray.__getattribute__(self,attr) obj = self.getfield(*res) # if it has fields return a recarray, otherwise return # normal array if obj.dtypedescr.fields: return obj i...
print msg
print msg,'in scipy_distutils, trying from distutils..'
def new_compiler (plat=None, compiler=None, verbose=0, dry_run=0, force=0): # Try first C compilers from scipy_distutils. if plat is None: plat = os.name try: if compiler is None: compiler = get_default_compiler(plat) (module_name, class_name, long_description) = compiler_class[compiler] except KeyError: msg = "don't k...
except ImportError:
except ImportError, msg:
def new_compiler (plat=None, compiler=None, verbose=0, dry_run=0, force=0): # Try first C compilers from scipy_distutils. if plat is None: plat = os.name try: if compiler is None: compiler = get_default_compiler(plat) (module_name, class_name, long_description) = compiler_class[compiler] except KeyError: msg = "don't k...
if (item == 'NOTSWAPPED'):
if (item == 'NOTSWAPPED' or item == 'N'):
def __setitem__(self, item, val): val = not not val # convert to boolean if item not in _setable: raise KeyError, "Cannot set flag", item dict.__setitem__(self, item, val) # Does this matter?
def cyg2win32(path)
def cyg2win32(path):
def cyg2win32(path) if sys.platform=='cygwin' and path.startswith('/cygdrive'): path = path[10] + ':' + os.path.normcase(path[11:]) return path
verbose = 1
verbosity = 1
def get_info(name): cl = {'atlas':atlas_info, 'x11':x11_info, 'fftw':fftw_info, 'dfftw':dfftw_info, 'sfftw':sfftw_info, 'fftw_threads':fftw_threads_info, 'dfftw_threads':dfftw_threads_info, 'sfftw_threads':sfftw_threads_info, 'djbfft':djbfft_info, 'blas':blas_info, 'lapack':lapack_info, 'lapack_src':lapack_src_info, 'b...
if self.verbose:
if self.verbosity>0:
def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ flag = 0 if not self.has_info(): flag = 1 if self.verbose: print self.__class__.__name__ + ':' if hasattr(self, 'calc_info'): self.calc_info() if self.verbose: if not self.has_info(): print ' NOT...
if self.verbose and flag:
if self.verbosity>0 and flag:
def get_info(self): """ Return a dictonary with items that are compatible with scipy_distutils.setup keyword arguments. """ flag = 0 if not self.has_info(): flag = 1 if self.verbose: print self.__class__.__name__ + ':' if hasattr(self, 'calc_info'): self.calc_info() if self.verbose: if not self.has_info(): print ' NOT...
p = combine_paths(lib_dir, 'lib'+l+ext)
p = self.combine_paths(lib_dir, 'lib'+l+ext)
def _lib_list(self, lib_dir, libs, ext): assert type(lib_dir) is type('') liblist = [] for l in libs: p = combine_paths(lib_dir, 'lib'+l+ext) if p: assert len(p)==1 liblist.append(p[0]) return liblist
if len(combine_paths(d,self.includes))==2:
if len(self.combine_paths(d,self.includes))==2:
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...
p = combine_paths (d,['djbfft.a'])
p = self.combine_paths (d,['djbfft.a'])
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() info = None for d in lib_dirs: p = combine_paths (d,['djbfft.a']) if p: info = {'extra_objects':p} break if info is None: return for d in incl_dirs: if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2: dict_append(info,include_dirs=...
if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:
if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() info = None for d in lib_dirs: p = combine_paths (d,['djbfft.a']) if p: info = {'extra_objects':p} break if info is None: return for d in incl_dirs: if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2: dict_append(info,include_dirs=...
dirs.extend(combine_paths(d,['atlas*','ATLAS*',
dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',
def get_paths(self, section, key): pre_dirs = system_info.get_paths(self, section, key) dirs = [] for d in pre_dirs: dirs.extend(combine_paths(d,['atlas*','ATLAS*', 'sse*','3dnow'])+[d]) return [ d for d in dirs if os.path.isdir(d) ]
lib_dirs2 = combine_paths(d,['atlas*','ATLAS*'])+[d]
lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]
def calc_info(self): lib_dirs = self.get_lib_dirs() info = {} atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas']) lapack_libs = self.get_libs('lapack_libs',['lapack']) atlas = None lapack = None for d in lib_dirs: atlas = self.check_libs(d,atlas_libs,[]) if atlas is not None: lib_dirs2 = combine_pat...
h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]
h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]
def calc_info(self): lib_dirs = self.get_lib_dirs() info = {} atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas']) lapack_libs = self.get_libs('lapack_libs',['lapack']) atlas = None lapack = None for d in lib_dirs: atlas = self.check_libs(d,atlas_libs,[]) if atlas is not None: lib_dirs2 = combine_pat...
dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))
dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))
def get_paths(self, section, key): pre_dirs = system_info.get_paths(self, section, key) dirs = [] for d in pre_dirs: dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC'])) return [ d for d in dirs if os.path.isdir(d) ]
dirs.extend([d] + combine_paths(d,['blas']))
dirs.extend([d] + self.combine_paths(d,['blas']))
def get_paths(self, section, key): pre_dirs = system_info.get_paths(self, section, key) dirs = [] for d in pre_dirs: dirs.extend([d] + combine_paths(d,['blas'])) return [ d for d in dirs if os.path.isdir(d) ]
if combine_paths(d, 'X11/X.h'):
if self.combine_paths(d, 'X11/X.h'):
def calc_info(self): if sys.platform in ['win32','cygwin']: 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 i...
def combine_paths(*args):
def combine_paths(*args,**kws):
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: result = reduce(lambda a,b:a+b,map(glob,args[0]),[]) elif ...
__file__ except NameError: __file__ = sys.argv[0] cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],
f = __file__ except NameError,msg: f = sys.argv[0] cf = os.path.join(os.path.split(os.path.abspath(f))[0],
def __init__ (self, default_lib_dirs=default_lib_dirs, default_include_dirs=default_include_dirs, verbosity = 1, ): self.__class__.info = {} self.local_prefixes = [] defaults = {} defaults['libraries'] = '' defaults['library_dirs'] = os.pathsep.join(default_lib_dirs) defaults['include_dirs'] = os.pathsep.join(default_i...
/* Numarray */ /* XXX: need the corresponding numarray code here */
#ifdef NUMARRAY
/* Numeric */
#ifdef NUMARRAY
TRYPYARRAYTEMPLATELONG\\
#ifdef NUMARRAY
TRYPYARRAYTEMPLATECHAR\\
case PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\
#ifdef NUMARRAY
case PyArray_SBYTE: *(signed char *)(arr->data)=*v; break;\\
case PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\
#ifdef NUMARRAY
TRYPYARRAYTEMPLATEOBJECT\\
case PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\ case PyArray_UINT: *(uint *)(arr->data)=*v; break;\\ case PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\ case PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\ case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\ case PyArray_LONGDOUBLE: *(long...
#ifdef NUMARRAY
return 1; PyArrayObject *arr = NULL;\\ if (!obj) return -2;\\ if (!PyArray_Check(obj)) return -1;\\ if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\ if (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\ switch (arr->descr->type_num) {\\ TRYPY...
return 1
#ifdef NUMARRAY
/* XXX: need the corresponding numarray code here */
#ifdef NUMARRAY
TRYCOMPLEXPYARRAYTEMPLATELONG\\
case PyArray_LONG: *(long *)(arr->data)=(*v).r; break;\\
#ifdef NUMARRAY
TRYCOMPLEXPYARRAYTEMPLATECHAR\\
#ifdef NUMARRAY
case PyArray_SBYTE: *(signed char *)(arr->data)=(*v).r; break;\\ TRYCOMPLEXPYARRAYTEMPLATEOBJECT\\ default: return -2;\\ };\\ return -1; PyArrayObject *arr = NULL;\\ if (!obj) return -2;\\ if (!PyArray_Check(obj)) return -1;\\ if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYCOMPLEXPYARRAYTEMPLATE:\");PRINTPYOBJ...
case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\ case PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\ case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\
#ifdef NUMARRAY
TRYCOMPLEXPYARRAYTEMPLATECHAR\\ case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\ case PyArray_SBYTE: *(signed char *)(arr->data)=(*v).r; break;\\
case PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\ case PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\ case PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\ case PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\ case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\ case PyArra...
#ifdef NUMARRAY
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
\t\t{ STRINGCOPYN(arr->data,str,PyArray_SIZE(arr)); }
\t\t{ STRINGCOPYN(arr->data,str,PyArray_NBYTES(arr)); }
#ifdef OLDPYNUM
macros = [('SCIPY_FFTW_H',1)]
macros = [('SCIPY_FFTW_H',None)]
def _check_libs(self,lib_dir,libs, opt_libs, ext): found_libs = self._lib_list(lib_dir, libs, ext) if len(found_libs) == len(libs): found_libs = self._extract_lib_names(found_libs) info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]} opt_found_libs = self._lib_list(lib_dir, opt_libs, ext) if len(opt_found_libs...
macros = [('SCIPY_DFFTW_H',1)]
macros = [('SCIPY_DFFTW_H',None)]
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...
macros = [('SCIPY_SFFTW_H',1)]
macros = [('SCIPY_SFFTW_H',None)]
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...
macros = [('SCIPY_FFTW_THREADS_H',1)]
macros = [('SCIPY_FFTW_THREADS_H',None)]
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...