From numpy-svn at scipy.org Fri Jun 1 06:15:43 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 1 Jun 2007 05:15:43 -0500 (CDT) Subject: [Numpy-svn] r3853 - trunk/numpy/distutils Message-ID: <20070601101543.3DC2939C16C@new.scipy.org> Author: pearu Date: 2007-06-01 05:15:17 -0500 (Fri, 01 Jun 2007) New Revision: 3853 Added: trunk/numpy/distutils/interactive.py Modified: trunk/numpy/distutils/core.py Log: Undo changeset 3839: interactive support is being used (this convinient on windows where one can click on setup.py and build the numpy or whatever package in 2 keystrokes). Modified: trunk/numpy/distutils/core.py =================================================================== --- trunk/numpy/distutils/core.py 2007-05-31 22:11:24 UTC (rev 3852) +++ trunk/numpy/distutils/core.py 2007-06-01 10:15:17 UTC (rev 3853) @@ -98,7 +98,24 @@ dist = distutils.dist.Distribution() return dist +def _exit_interactive_session(_cache=[]): + if _cache: + return # been here + _cache.append(1) + print '-'*72 + raw_input('Press ENTER to close the interactive session..') + print '='*72 + def setup(**attr): + + if len(sys.argv)<=1 and not attr.get('script_args',[]): + from interactive import interactive_sys_argv + import atexit + atexit.register(_exit_interactive_session) + sys.argv[:] = interactive_sys_argv(sys.argv) + if len(sys.argv)>1: + return setup(**attr) + cmdclass = numpy_cmdclass.copy() new_attr = attr.copy() Added: trunk/numpy/distutils/interactive.py =================================================================== --- trunk/numpy/distutils/interactive.py 2007-05-31 22:11:24 UTC (rev 3852) +++ trunk/numpy/distutils/interactive.py 2007-06-01 10:15:17 UTC (rev 3853) @@ -0,0 +1,187 @@ +import os +import sys +from pprint import pformat + +__all__ = ['interactive_sys_argv'] + +def show_information(*args): + print 'Python',sys.version + for a in ['platform','prefix','byteorder','path']: + print 'sys.%s = %s' % (a,pformat(getattr(sys,a))) + for a in ['name']: + print 'os.%s = %s' % (a,pformat(getattr(os,a))) + if hasattr(os,'uname'): + print 'system,node,release,version,machine = ',os.uname() + +def show_environ(*args): + for k,i in os.environ.items(): + print ' %s = %s' % (k, i) + +def show_fortran_compilers(*args): + from fcompiler import show_fcompilers + show_fcompilers() + +def show_compilers(*args): + from distutils.ccompiler import show_compilers + show_compilers() + +def show_tasks(argv,ccompiler,fcompiler): + print """\ + +Tasks: + i - Show python/platform/machine information + ie - Show environment information + c - Show C compilers information + c - Set C compiler (current:%s) + f - Show Fortran compilers information + f - Set Fortran compiler (current:%s) + e - Edit proposed sys.argv[1:]. + +Task aliases: + 0 - Configure + 1 - Build + 2 - Install + 2 - Install with prefix. + 3 - Inplace build + 4 - Source distribution + 5 - Binary distribution + +Proposed sys.argv = %s + """ % (ccompiler, fcompiler, argv) + + +from exec_command import splitcmdline + +def edit_argv(*args): + argv = args[0] + readline = args[1] + if readline is not None: + readline.add_history(' '.join(argv[1:])) + try: + s = raw_input('Edit argv [UpArrow to retrive %r]: ' % (' '.join(argv[1:]))) + except EOFError: + return + if s: + argv[1:] = splitcmdline(s) + return + +def interactive_sys_argv(argv): + print '='*72 + print 'Starting interactive session' + print '-'*72 + + readline = None + try: + try: + import readline + except ImportError: + pass + else: + import tempfile + tdir = tempfile.gettempdir() + username = os.environ.get('USER',os.environ.get('USERNAME','UNKNOWN')) + histfile = os.path.join(tdir,".pyhist_interactive_setup-" + username) + try: + try: readline.read_history_file(histfile) + except IOError: pass + import atexit + atexit.register(readline.write_history_file, histfile) + except AttributeError: pass + except Exception, msg: + print msg + + task_dict = {'i':show_information, + 'ie':show_environ, + 'f':show_fortran_compilers, + 'c':show_compilers, + 'e':edit_argv, + } + c_compiler_name = None + f_compiler_name = None + + while 1: + show_tasks(argv,c_compiler_name, f_compiler_name) + try: + task = raw_input('Choose a task (^D to quit, Enter to continue with setup): ').lower() + except EOFError: + print + task = 'quit' + if task=='': break + if task=='quit': sys.exit() + task_func = task_dict.get(task,None) + if task_func is None: + if task[0]=='c': + c_compiler_name = task[1:] + if c_compiler_name=='none': + c_compiler_name = None + continue + if task[0]=='f': + f_compiler_name = task[1:] + if f_compiler_name=='none': + f_compiler_name = None + continue + if task[0]=='2' and len(task)>1: + prefix = task[1:] + task = task[0] + else: + prefix = None + if task == '4': + argv[1:] = ['sdist','-f'] + continue + elif task in '01235': + cmd_opts = {'config':[],'config_fc':[], + 'build_ext':[],'build_src':[], + 'build_clib':[]} + if c_compiler_name is not None: + c = '--compiler=%s' % (c_compiler_name) + cmd_opts['config'].append(c) + if task != '0': + cmd_opts['build_ext'].append(c) + cmd_opts['build_clib'].append(c) + if f_compiler_name is not None: + c = '--fcompiler=%s' % (f_compiler_name) + cmd_opts['config_fc'].append(c) + if task != '0': + cmd_opts['build_ext'].append(c) + cmd_opts['build_clib'].append(c) + if task=='3': + cmd_opts['build_ext'].append('--inplace') + cmd_opts['build_src'].append('--inplace') + conf = [] + sorted_keys = ['config','config_fc','build_src', + 'build_clib','build_ext'] + for k in sorted_keys: + opts = cmd_opts[k] + if opts: conf.extend([k]+opts) + if task=='0': + if 'config' not in conf: + conf.append('config') + argv[1:] = conf + elif task=='1': + argv[1:] = conf+['build'] + elif task=='2': + if prefix is not None: + argv[1:] = conf+['install','--prefix=%s' % (prefix)] + else: + argv[1:] = conf+['install'] + elif task=='3': + argv[1:] = conf+['build'] + elif task=='5': + if sys.platform=='win32': + argv[1:] = conf+['bdist_wininst'] + else: + argv[1:] = conf+['bdist'] + else: + print 'Skipping unknown task:',`task` + else: + print '-'*68 + try: + task_func(argv,readline) + except Exception,msg: + print 'Failed running task %s: %s' % (task,msg) + break + print '-'*68 + print + + print '-'*72 + return argv From numpy-svn at scipy.org Fri Jun 1 06:42:10 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 1 Jun 2007 05:42:10 -0500 (CDT) Subject: [Numpy-svn] r3854 - trunk/numpy/core Message-ID: <20070601104210.A038239C02D@new.scipy.org> Author: pearu Date: 2007-06-01 05:42:04 -0500 (Fri, 01 Jun 2007) New Revision: 3854 Modified: trunk/numpy/core/setup.py Log: Fix: _dotblas will not ork with fortran compiled blas. Modified: trunk/numpy/core/setup.py =================================================================== --- trunk/numpy/core/setup.py 2007-06-01 10:15:17 UTC (rev 3853) +++ trunk/numpy/core/setup.py 2007-06-01 10:42:04 UTC (rev 3854) @@ -235,6 +235,8 @@ #blas_info = {} def get_dotblas_sources(ext, build_dir): if blas_info: + if ('NO_ATLAS_INFO',1) in blas_info.get('define_macros',[]): + return None # dotblas needs ATLAS, Fortran compiled blas will not be sufficient. return ext.depends[:1] return None # no extension module will be built From numpy-svn at scipy.org Fri Jun 1 09:37:06 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 1 Jun 2007 08:37:06 -0500 (CDT) Subject: [Numpy-svn] r3855 - in trunk/numpy/distutils: . fcompiler Message-ID: <20070601133706.71B4039C00F@new.scipy.org> Author: pearu Date: 2007-06-01 08:36:59 -0500 (Fri, 01 Jun 2007) New Revision: 3855 Modified: trunk/numpy/distutils/ccompiler.py trunk/numpy/distutils/fcompiler/__init__.py Log: Fixed detecting fortran compilers under windows. Modified: trunk/numpy/distutils/ccompiler.py =================================================================== --- trunk/numpy/distutils/ccompiler.py 2007-06-01 10:42:04 UTC (rev 3854) +++ trunk/numpy/distutils/ccompiler.py 2007-06-01 13:36:59 UTC (rev 3855) @@ -255,11 +255,12 @@ """ Compiler version. Returns None if compiler is not available. """ if not force and hasattr(self,'version'): return self.version + self.find_executables() try: version_cmd = self.version_cmd except AttributeError: return None - if not version_cmd or not version_cmd[0] or None in version_cmd: + if not version_cmd or not version_cmd[0]: return None cmd = ' '.join(version_cmd) try: @@ -277,6 +278,7 @@ return version status, output = exec_command(cmd,use_tee=0) + version = None if status in ok_status: version = matcher(output) Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-01 10:42:04 UTC (rev 3854) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-01 13:36:59 UTC (rev 3855) @@ -257,18 +257,23 @@ return fc_exe return None + ctype = self.compiler_type f90 = set_exe('compiler_f90') -# if not f90: -# raise CompilerNotFound('f90') - f77 = set_exe('compiler_f77', f90=f90) - if not f77: - raise CompilerNotFound('f77') - set_exe('compiler_fix', f90=f90) + if not f90: + f77 = set_exe('compiler_f77') + if f77: + log.warn('%s: no Fortran 90 compiler found' % ctype) + else: + raise CompilerNotFound('%s: f90 nor f77' % ctype) + else: + f77 = set_exe('compiler_f77', f90=f90) + if not f77: + log.warn('%s: no Fortran 77 compiler found' % ctype) + set_exe('compiler_fix', f90=f90) set_exe('linker_so', f77=f77, f90=f90) set_exe('linker_exe', f77=f77, f90=f90) set_exe('version_cmd', f77=f77, f90=f90) - set_exe('archiver') set_exe('ranlib') @@ -385,7 +390,7 @@ ## Public methods: - def customize(self, dist): + def customize(self, dist = None): """Customize Fortran compiler. This method gets Fortran compiler specific information from From numpy-svn at scipy.org Fri Jun 1 09:57:29 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 1 Jun 2007 08:57:29 -0500 (CDT) Subject: [Numpy-svn] r3856 - trunk/numpy/distutils/fcompiler Message-ID: <20070601135729.EAA4339C00F@new.scipy.org> Author: pearu Date: 2007-06-01 08:57:24 -0500 (Fri, 01 Jun 2007) New Revision: 3856 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: Reduced find_executables messages. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-01 13:36:59 UTC (rev 3855) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-01 13:57:24 UTC (rev 3856) @@ -207,7 +207,7 @@ ## They are private to FCompiler class and may return unexpected ## results if used elsewhere. So, you have been warned.. - def find_executables(self): + def find_executables(self,exe_cache = {}): """Go through the self.executables dictionary, and attempt to find and assign appropiate executables. @@ -219,12 +219,13 @@ or the Fortran 90 compiler executable is used, unless overridden by an environment setting. """ - exe_cache = {} + if exe_cache: # been here + return def cached_find_executable(exe): if exe in exe_cache: return exe_cache[exe] fc_exe = find_executable(exe) - exe_cache[exe] = fc_exe + exe_cache[exe] = exe_cache[fc_exe] = fc_exe return fc_exe def set_exe(exe_key, f77=None, f90=None): cmd = self.executables.get(exe_key, None) From numpy-svn at scipy.org Fri Jun 1 15:29:40 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 1 Jun 2007 14:29:40 -0500 (CDT) Subject: [Numpy-svn] r3857 - trunk/numpy/lib Message-ID: <20070601192940.8B5F239C00F@new.scipy.org> Author: cookedm Date: 2007-06-01 14:29:37 -0500 (Fri, 01 Jun 2007) New Revision: 3857 Modified: trunk/numpy/lib/polynomial.py Log: add __neg__ and __pos__ methods to poly1d Modified: trunk/numpy/lib/polynomial.py =================================================================== --- trunk/numpy/lib/polynomial.py 2007-06-01 13:57:24 UTC (rev 3856) +++ trunk/numpy/lib/polynomial.py 2007-06-01 19:29:37 UTC (rev 3857) @@ -547,6 +547,12 @@ def __call__(self, val): return polyval(self.coeffs, val) + def __neg__(self): + return poly1d(-self.coeffs) + + def __pos__(self): + return self + def __mul__(self, other): if isscalar(other): return poly1d(self.coeffs * other) From numpy-svn at scipy.org Sun Jun 3 00:26:26 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 2 Jun 2007 23:26:26 -0500 (CDT) Subject: [Numpy-svn] r3858 - trunk/numpy/distutils/fcompiler Message-ID: <20070603042626.9167D39C0D3@new.scipy.org> Author: cookedm Date: 2007-06-02 23:26:22 -0500 (Sat, 02 Jun 2007) New Revision: 3858 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: Fix #534, introduced by r3856. The return when exe_cache had something in it meant that FCompiler.find_executables would be executed *once*, regardless of how many subclasses called it. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-01 19:29:37 UTC (rev 3857) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-03 04:26:22 UTC (rev 3858) @@ -177,6 +177,8 @@ shared_lib_format = "%s%s" exe_extension = "" + _exe_cache = {} + def __init__(self, *args, **kw): CCompiler.__init__(self, *args, **kw) self.distutils_vars = self.distutils_vars.clone(self._environment_hook) @@ -207,7 +209,7 @@ ## They are private to FCompiler class and may return unexpected ## results if used elsewhere. So, you have been warned.. - def find_executables(self,exe_cache = {}): + def find_executables(self): """Go through the self.executables dictionary, and attempt to find and assign appropiate executables. @@ -219,8 +221,7 @@ or the Fortran 90 compiler executable is used, unless overridden by an environment setting. """ - if exe_cache: # been here - return + exe_cache = self._exe_cache def cached_find_executable(exe): if exe in exe_cache: return exe_cache[exe] From numpy-svn at scipy.org Tue Jun 5 06:41:49 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 5 Jun 2007 05:41:49 -0500 (CDT) Subject: [Numpy-svn] r3859 - trunk/numpy/distutils/fcompiler Message-ID: <20070605104149.2EF8239C09D@new.scipy.org> Author: pearu Date: 2007-06-05 05:41:43 -0500 (Tue, 05 Jun 2007) New Revision: 3859 Modified: trunk/numpy/distutils/fcompiler/intel.py Log: Updated intel compiler arch flags -- intel compiler users should recheck these options. Modified: trunk/numpy/distutils/fcompiler/intel.py =================================================================== --- trunk/numpy/distutils/fcompiler/intel.py 2007-06-03 04:26:22 UTC (rev 3858) +++ trunk/numpy/distutils/fcompiler/intel.py 2007-06-05 10:41:43 UTC (rev 3859) @@ -52,6 +52,7 @@ return ['-O3','-unroll'] def get_flags_arch(self): + v = self.get_version() opt = [] if cpu.has_fdiv_bug(): opt.append('-fdiv_check') @@ -65,8 +66,25 @@ opt.append('-tpp5') elif cpu.is_PentiumIV() or cpu.is_Xeon(): opt.extend(['-tpp7','-xW']) - if cpu.has_mmx() and not cpu.is_Xeon(): - opt.append('-xM') + if v and v <= '7.1': + if cpu.has_mmx() and (cpu.is_PentiumII() or cpu.is_PentiumIII()): + opt.append('-xM') + elif v and v >= '8.0': + if cpu.is_PentiumIII(): + opt.append('-xK') + if cpu.has_sse3(): + opt.extend(['-xP']) + elif cpu.is_PentiumIV(): + opt.append('-xW') + if cpu.has_sse2(): + opt.append('-xN') + elif cpu.is_PentiumM(): + opt.extend(['-xB']) + if (cpu.is_Xeon() or cpu.is_Core2() or cpu.is_Core2Extreme()) and cpu.getNCPUs()==2: + opt.extend(['-xT']) + if cpu.has_sse3() and (cpu.is_PentiumIV() or cpu.is_CoreDuo() or cpu.is_CoreSolo()): + opt.extend(['-xP']) + if cpu.has_sse2(): opt.append('-arch SSE2') elif cpu.has_sse(): From numpy-svn at scipy.org Tue Jun 5 14:54:32 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 5 Jun 2007 13:54:32 -0500 (CDT) Subject: [Numpy-svn] r3860 - trunk Message-ID: <20070605185432.B513A39C015@new.scipy.org> Author: pearu Date: 2007-06-05 13:54:28 -0500 (Tue, 05 Jun 2007) New Revision: 3860 Modified: trunk/setup.py Log: Fix ticket 535. Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2007-06-05 10:41:43 UTC (rev 3859) +++ trunk/setup.py 2007-06-05 18:54:28 UTC (rev 3860) @@ -48,9 +48,10 @@ config.add_subpackage('numpy') - config.add_data_files(('numpy','*.txt'), ('.','COMPATIBILITY'), - ('.','scipy_compatibility'), - ('.','site.cfg.example')) + config.add_data_files(('numpy','*.txt'), + ('numpy','COMPATIBILITY'), + ('numpy','scipy_compatibility'), + ('numpy','site.cfg.example')) config.get_version('numpy/version.py') # sets config.version From numpy-svn at scipy.org Thu Jun 7 01:51:20 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 7 Jun 2007 00:51:20 -0500 (CDT) Subject: [Numpy-svn] r3861 - trunk/numpy/f2py Message-ID: <20070607055120.321E139C075@new.scipy.org> Author: cookedm Date: 2007-06-07 00:51:11 -0500 (Thu, 07 Jun 2007) New Revision: 3861 Modified: trunk/numpy/f2py/f2py_testing.py Log: f2py_testing: remove jiffies, memusage definitions. Use numpy.testing.util versions instead Modified: trunk/numpy/f2py/f2py_testing.py =================================================================== --- trunk/numpy/f2py/f2py_testing.py 2007-06-05 18:54:28 UTC (rev 3860) +++ trunk/numpy/f2py/f2py_testing.py 2007-06-07 05:51:11 UTC (rev 3861) @@ -1,5 +1,7 @@ import os,sys,re,time +from numpy.testing.utils import jiffies, memusage + def cmdline(): m=re.compile(r'\A\d+\Z') args = [] @@ -12,38 +14,6 @@ f2py_opts = ' '.join(args) return repeat,f2py_opts -if sys.platform[:5]=='linux': - def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()), - _load_time=time.time()): - """ Return number of jiffies (1/100ths of a second) that this - process has been scheduled in user mode. See man 5 proc. """ - try: - f=open(_proc_pid_stat,'r') - l = f.readline().split(' ') - f.close() - return int(l[13]) - except: - return int(100*(time.time()-_load_time)) - - def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())): - """ Return virtual memory size in bytes of the running python. - """ - try: - f=open(_proc_pid_stat,'r') - l = f.readline().split(' ') - f.close() - return int(l[22]) - except: - return -else: - def jiffies(_load_time=time.time()): - """ Return number of jiffies (1/100ths of a second) that this - process has been scheduled in user mode. [Emulation with time.time]. """ - return int(100*(time.time()-_load_time)) - - def memusage(): - pass - def run(runtest,test_functions,repeat=1): l = [(t,repr(t.__doc__.split('\n')[1].strip())) for t in test_functions] #l = [(t,'') for t in test_functions] From numpy-svn at scipy.org Fri Jun 8 01:50:29 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 00:50:29 -0500 (CDT) Subject: [Numpy-svn] r3862 - trunk/numpy/core Message-ID: <20070608055029.BE3C739C0C6@new.scipy.org> Author: oliphant Date: 2007-06-08 00:50:09 -0500 (Fri, 08 Jun 2007) New Revision: 3862 Modified: trunk/numpy/core/memmap.py Log: Fix so that _mmap gets carried through .transpose Modified: trunk/numpy/core/memmap.py =================================================================== --- trunk/numpy/core/memmap.py 2007-06-07 05:51:11 UTC (rev 3861) +++ trunk/numpy/core/memmap.py 2007-06-08 05:50:09 UTC (rev 3862) @@ -77,9 +77,13 @@ return self def __array_finalize__(self, obj): - if obj is not None and not isinstance(obj, memmap): - raise ValueError, "Cannot create a memmap array that way" - self._mmap = None + if obj is not None: + if not isinstance(obj, memmap): + raise ValueError, "Cannot create a memmap array that way" + self._mmap = obj._mmap + else: + self._mmap = None + return def sync(self): self._mmap.flush() From numpy-svn at scipy.org Fri Jun 8 01:51:17 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 00:51:17 -0500 (CDT) Subject: [Numpy-svn] r3863 - trunk/numpy/core Message-ID: <20070608055117.289F539C0D3@new.scipy.org> Author: oliphant Date: 2007-06-08 00:51:08 -0500 (Fri, 08 Jun 2007) New Revision: 3863 Modified: trunk/numpy/core/memmap.py Log: Fix so that _mmap gets carried through .transpose Modified: trunk/numpy/core/memmap.py =================================================================== --- trunk/numpy/core/memmap.py 2007-06-08 05:50:09 UTC (rev 3862) +++ trunk/numpy/core/memmap.py 2007-06-08 05:51:08 UTC (rev 3863) @@ -81,6 +81,10 @@ if not isinstance(obj, memmap): raise ValueError, "Cannot create a memmap array that way" self._mmap = obj._mmap + self._offset = obj._offset + self._mode = obj._mode + self._size = obj._size + self._name = obj._name else: self._mmap = None return From numpy-svn at scipy.org Fri Jun 8 02:08:21 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 01:08:21 -0500 (CDT) Subject: [Numpy-svn] r3864 - trunk/numpy/core Message-ID: <20070608060821.17D4039C0C6@new.scipy.org> Author: oliphant Date: 2007-06-08 01:08:04 -0500 (Fri, 08 Jun 2007) New Revision: 3864 Modified: trunk/numpy/core/memmap.py Log: Restore back to original .transpose behavior in memmap.py with explanation of the problem. Modified: trunk/numpy/core/memmap.py =================================================================== --- trunk/numpy/core/memmap.py 2007-06-08 05:51:08 UTC (rev 3863) +++ trunk/numpy/core/memmap.py 2007-06-08 06:08:04 UTC (rev 3864) @@ -80,14 +80,12 @@ if obj is not None: if not isinstance(obj, memmap): raise ValueError, "Cannot create a memmap array that way" - self._mmap = obj._mmap - self._offset = obj._offset - self._mode = obj._mode - self._size = obj._size - self._name = obj._name + # it would be nice to carry the along the _mmap name + # but then we might have problems because self could close + # it while obj is still holding it. So, we don't do + # anything at this point. else: self._mmap = None - return def sync(self): self._mmap.flush() From numpy-svn at scipy.org Fri Jun 8 02:30:02 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 01:30:02 -0500 (CDT) Subject: [Numpy-svn] r3865 - trunk/numpy/testing Message-ID: <20070608063002.E360F39C0C6@new.scipy.org> Author: pearu Date: 2007-06-08 01:29:34 -0500 (Fri, 08 Jun 2007) New Revision: 3865 Modified: trunk/numpy/testing/utils.py Log: Typo fix: expose memusage for nt OS. Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2007-06-08 06:08:04 UTC (rev 3864) +++ trunk/numpy/testing/utils.py 2007-06-08 06:29:34 UTC (rev 3865) @@ -92,12 +92,12 @@ finally: win32pdh.CloseQuery(hq) - def memusage(processName="python", instance=0): - # from win32pdhutil, part of the win32all package - import win32pdh - return GetPerformanceAttributes("Process", "Virtual Bytes", - processName, instance, - win32pdh.PDH_FMT_LONG, None) + def memusage(processName="python", instance=0): + # from win32pdhutil, part of the win32all package + import win32pdh + return GetPerformanceAttributes("Process", "Virtual Bytes", + processName, instance, + win32pdh.PDH_FMT_LONG, None) def build_err_msg(arrays, err_msg, header='Items are not equal:', verbose=True, From numpy-svn at scipy.org Fri Jun 8 03:32:23 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 02:32:23 -0500 (CDT) Subject: [Numpy-svn] r3866 - trunk/numpy/distutils/fcompiler Message-ID: <20070608073223.AE7A639C0C6@new.scipy.org> Author: pearu Date: 2007-06-08 02:32:05 -0500 (Fri, 08 Jun 2007) New Revision: 3866 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: use get_flags_version to set version cmd flags. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-08 06:29:34 UTC (rev 3865) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-08 07:32:05 UTC (rev 3866) @@ -425,7 +425,8 @@ # methods may call self.get_version. vers_cmd = self.command_vars.version_cmd if vers_cmd: - vflags = self.flag_vars.version + vflags = self.get_flags_version() + assert None not in vflags,`vflags` self.set_executables(version_cmd=[vers_cmd]+vflags) f77flags = [] From numpy-svn at scipy.org Fri Jun 8 03:36:57 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 02:36:57 -0500 (CDT) Subject: [Numpy-svn] r3867 - trunk/numpy/distutils/fcompiler Message-ID: <20070608073657.6770239C1EE@new.scipy.org> Author: pearu Date: 2007-06-08 02:36:33 -0500 (Fri, 08 Jun 2007) New Revision: 3867 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: Fix typo. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-08 07:32:05 UTC (rev 3866) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-08 07:36:33 UTC (rev 3867) @@ -42,7 +42,7 @@ def str2bool(s): if is_string(s): - return not (s == '0' or s.lower() == 'False') + return not (s == '0' or s.lower() == 'false') return bool(s) class FCompiler(CCompiler): From numpy-svn at scipy.org Fri Jun 8 10:14:44 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 8 Jun 2007 09:14:44 -0500 (CDT) Subject: [Numpy-svn] r3868 - trunk/numpy/f2py Message-ID: <20070608141444.E686739C224@new.scipy.org> Author: pearu Date: 2007-06-08 09:14:38 -0500 (Fri, 08 Jun 2007) New Revision: 3868 Modified: trunk/numpy/f2py/f2py2e.py Log: Fix f2py --fcompiler=.. option. Modified: trunk/numpy/f2py/f2py2e.py =================================================================== --- trunk/numpy/f2py/f2py2e.py 2007-06-08 07:36:33 UTC (rev 3867) +++ trunk/numpy/f2py/f2py2e.py 2007-06-08 14:14:38 UTC (rev 3868) @@ -437,6 +437,7 @@ v = '--fcompiler=' if s[:len(v)]==v: from numpy.distutils import fcompiler + fcompiler.load_all_fcompiler_classes() allowed_keys = fcompiler.fcompiler_class.keys() nv = ov = s[len(v):].lower() if ov not in allowed_keys: From numpy-svn at scipy.org Tue Jun 12 16:06:22 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 12 Jun 2007 15:06:22 -0500 (CDT) Subject: [Numpy-svn] r3869 - trunk/numpy/distutils/fcompiler Message-ID: <20070612200622.4363939C100@new.scipy.org> Author: cookedm Date: 2007-06-12 15:06:18 -0500 (Tue, 12 Jun 2007) New Revision: 3869 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: add fdebug as distutils key in [config_fc] for compiler flags to use when compiling Fortran in debug mode. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-08 14:14:38 UTC (rev 3868) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-12 20:06:18 UTC (rev 3869) @@ -118,7 +118,7 @@ arch = ('flags.arch', 'FARCH', 'arch', flaglist), arch_f77 = ('flags.arch_f77', None, None, flaglist), arch_f90 = ('flags.arch_f90', None, None, flaglist), - debug = ('flags.debug', 'FDEBUG', None, None, flaglist), + debug = ('flags.debug', 'FDEBUG', 'fdebug', None, flaglist), debug_f77 = ('flags.debug_f77', None, None, flaglist), debug_f90 = ('flags.debug_f90', None, None, flaglist), flags = ('self.get_flags', 'FFLAGS', 'fflags', flaglist), From numpy-svn at scipy.org Fri Jun 15 16:55:43 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 15 Jun 2007 15:55:43 -0500 (CDT) Subject: [Numpy-svn] r3870 - trunk/numpy/distutils/command Message-ID: <20070615205543.91BC039C080@new.scipy.org> Author: cookedm Date: 2007-06-15 15:55:41 -0500 (Fri, 15 Jun 2007) New Revision: 3870 Modified: trunk/numpy/distutils/command/build_clib.py Log: Minor refactoring of build_clib (break up build_library a bit) Modified: trunk/numpy/distutils/command/build_clib.py =================================================================== --- trunk/numpy/distutils/command/build_clib.py 2007-06-12 20:06:18 UTC (rev 3869) +++ trunk/numpy/distutils/command/build_clib.py 2007-06-15 20:55:41 UTC (rev 3870) @@ -99,156 +99,159 @@ def build_libraries(self, libraries): for (lib_name, build_info) in libraries: - # default compilers - compiler = self.compiler - fcompiler = self.fcompiler + self.build_a_library(build_info, lib_name, libraries) - sources = build_info.get('sources') - if sources is None or not is_sequence(sources): - raise DistutilsSetupError, \ - ("in 'libraries' option (library '%s'), " + - "'sources' must be present and must be " + - "a list of source filenames") % lib_name - sources = list(sources) + def build_a_library(self, build_info, lib_name, libraries): + # default compilers + compiler = self.compiler + fcompiler = self.fcompiler - c_sources, cxx_sources, f_sources, fmodule_sources \ - = filter_sources(sources) - requiref90 = not not fmodule_sources or \ - build_info.get('language','c')=='f90' + sources = build_info.get('sources') + if sources is None or not is_sequence(sources): + raise DistutilsSetupError, \ + ("in 'libraries' option (library '%s'), " + + "'sources' must be present and must be " + + "a list of source filenames") % lib_name + sources = list(sources) - # save source type information so that build_ext can use it. - source_languages = [] - if c_sources: source_languages.append('c') - if cxx_sources: source_languages.append('c++') - if requiref90: source_languages.append('f90') - elif f_sources: source_languages.append('f77') - build_info['source_languages'] = source_languages + c_sources, cxx_sources, f_sources, fmodule_sources \ + = filter_sources(sources) + requiref90 = not not fmodule_sources or \ + build_info.get('language','c')=='f90' - lib_file = compiler.library_filename(lib_name, - output_dir=self.build_clib) - depends = sources + build_info.get('depends',[]) - if not (self.force or newer_group(depends, lib_file, 'newer')): - log.debug("skipping '%s' library (up-to-date)", lib_name) - continue - else: - log.info("building '%s' library", lib_name) + # save source type information so that build_ext can use it. + source_languages = [] + if c_sources: source_languages.append('c') + if cxx_sources: source_languages.append('c++') + if requiref90: source_languages.append('f90') + elif f_sources: source_languages.append('f77') + build_info['source_languages'] = source_languages - config_fc = build_info.get('config_fc',{}) - if fcompiler is not None and config_fc: - log.info('using additional config_fc from setup script '\ - 'for fortran compiler: %s' \ - % (config_fc,)) - from numpy.distutils.fcompiler import new_fcompiler - fcompiler = new_fcompiler(compiler=fcompiler.compiler_type, - verbose=self.verbose, - dry_run=self.dry_run, - force=self.force, - requiref90=requiref90) - if fcompiler is not None: - dist = self.distribution - base_config_fc = dist.get_option_dict('config_fc').copy() - base_config_fc.update(config_fc) - fcompiler.customize(base_config_fc) + lib_file = compiler.library_filename(lib_name, + output_dir=self.build_clib) + depends = sources + build_info.get('depends',[]) + if not (self.force or newer_group(depends, lib_file, 'newer')): + log.debug("skipping '%s' library (up-to-date)", lib_name) + return + else: + log.info("building '%s' library", lib_name) - # check availability of Fortran compilers - if (f_sources or fmodule_sources) and fcompiler is None: - raise DistutilsError, "library %s has Fortran sources"\ - " but no Fortran compiler found" % (lib_name) + config_fc = build_info.get('config_fc',{}) + if fcompiler is not None and config_fc: + log.info('using additional config_fc from setup script '\ + 'for fortran compiler: %s' \ + % (config_fc,)) + from numpy.distutils.fcompiler import new_fcompiler + fcompiler = new_fcompiler(compiler=fcompiler.compiler_type, + verbose=self.verbose, + dry_run=self.dry_run, + force=self.force, + requiref90=requiref90) + if fcompiler is not None: + dist = self.distribution + base_config_fc = dist.get_option_dict('config_fc').copy() + base_config_fc.update(config_fc) + fcompiler.customize(base_config_fc) - macros = build_info.get('macros') - include_dirs = build_info.get('include_dirs') - extra_postargs = build_info.get('extra_compiler_args') or [] + # check availability of Fortran compilers + if (f_sources or fmodule_sources) and fcompiler is None: + raise DistutilsError, "library %s has Fortran sources"\ + " but no Fortran compiler found" % (lib_name) - # where compiled F90 module files are: - module_dirs = build_info.get('module_dirs') or [] - module_build_dir = os.path.dirname(lib_file) - if requiref90: self.mkpath(module_build_dir) + macros = build_info.get('macros') + include_dirs = build_info.get('include_dirs') + extra_postargs = build_info.get('extra_compiler_args') or [] - if compiler.compiler_type=='msvc': - # this hack works around the msvc compiler attributes - # problem, msvc uses its own convention :( - c_sources += cxx_sources - cxx_sources = [] + # where compiled F90 module files are: + module_dirs = build_info.get('module_dirs') or [] + module_build_dir = os.path.dirname(lib_file) + if requiref90: self.mkpath(module_build_dir) - objects = [] - if c_sources: - log.info("compiling C sources") - objects = compiler.compile(c_sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=include_dirs, - debug=self.debug, - extra_postargs=extra_postargs) + if compiler.compiler_type=='msvc': + # this hack works around the msvc compiler attributes + # problem, msvc uses its own convention :( + c_sources += cxx_sources + cxx_sources = [] - if cxx_sources: - log.info("compiling C++ sources") - cxx_compiler = compiler.cxx_compiler() - cxx_objects = cxx_compiler.compile(cxx_sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=include_dirs, - debug=self.debug, - extra_postargs=extra_postargs) - objects.extend(cxx_objects) + objects = [] + if c_sources: + log.info("compiling C sources") + objects = compiler.compile(c_sources, + output_dir=self.build_temp, + macros=macros, + include_dirs=include_dirs, + debug=self.debug, + extra_postargs=extra_postargs) - if f_sources or fmodule_sources: - extra_postargs = [] - f_objects = [] + if cxx_sources: + log.info("compiling C++ sources") + cxx_compiler = compiler.cxx_compiler() + cxx_objects = cxx_compiler.compile(cxx_sources, + output_dir=self.build_temp, + macros=macros, + include_dirs=include_dirs, + debug=self.debug, + extra_postargs=extra_postargs) + objects.extend(cxx_objects) - if requiref90: - if fcompiler.module_dir_switch is None: - existing_modules = glob('*.mod') - extra_postargs += fcompiler.module_options(\ - module_dirs,module_build_dir) + if f_sources or fmodule_sources: + extra_postargs = [] + f_objects = [] - if fmodule_sources: - log.info("compiling Fortran 90 module sources") - f_objects += fcompiler.compile(fmodule_sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=include_dirs, - debug=self.debug, - extra_postargs=extra_postargs) + if requiref90: + if fcompiler.module_dir_switch is None: + existing_modules = glob('*.mod') + extra_postargs += fcompiler.module_options(\ + module_dirs,module_build_dir) - if requiref90 and self.fcompiler.module_dir_switch is None: - # move new compiled F90 module files to module_build_dir - for f in glob('*.mod'): - if f in existing_modules: - continue - t = os.path.join(module_build_dir, f) - if os.path.abspath(f)==os.path.abspath(t): - continue - if os.path.isfile(t): - os.remove(t) - try: - self.move_file(f, module_build_dir) - except DistutilsFileError: - log.warn('failed to move %r to %r' \ - % (f, module_build_dir)) + if fmodule_sources: + log.info("compiling Fortran 90 module sources") + f_objects += fcompiler.compile(fmodule_sources, + output_dir=self.build_temp, + macros=macros, + include_dirs=include_dirs, + debug=self.debug, + extra_postargs=extra_postargs) - if f_sources: - log.info("compiling Fortran sources") - f_objects += fcompiler.compile(f_sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=include_dirs, - debug=self.debug, - extra_postargs=extra_postargs) - else: - f_objects = [] + if requiref90 and self.fcompiler.module_dir_switch is None: + # move new compiled F90 module files to module_build_dir + for f in glob('*.mod'): + if f in existing_modules: + continue + t = os.path.join(module_build_dir, f) + if os.path.abspath(f)==os.path.abspath(t): + continue + if os.path.isfile(t): + os.remove(t) + try: + self.move_file(f, module_build_dir) + except DistutilsFileError: + log.warn('failed to move %r to %r' \ + % (f, module_build_dir)) - objects.extend(f_objects) + if f_sources: + log.info("compiling Fortran sources") + f_objects += fcompiler.compile(f_sources, + output_dir=self.build_temp, + macros=macros, + include_dirs=include_dirs, + debug=self.debug, + extra_postargs=extra_postargs) + else: + f_objects = [] - # assume that default linker is suitable for - # linking Fortran object files - compiler.create_static_lib(objects, lib_name, - output_dir=self.build_clib, - debug=self.debug) + objects.extend(f_objects) - # fix library dependencies - clib_libraries = build_info.get('libraries',[]) - for lname, binfo in libraries: - if lname in clib_libraries: - clib_libraries.extend(binfo[1].get('libraries',[])) - if clib_libraries: - build_info['libraries'] = clib_libraries + # assume that default linker is suitable for + # linking Fortran object files + compiler.create_static_lib(objects, lib_name, + output_dir=self.build_clib, + debug=self.debug) + + # fix library dependencies + clib_libraries = build_info.get('libraries',[]) + for lname, binfo in libraries: + if lname in clib_libraries: + clib_libraries.extend(binfo[1].get('libraries',[])) + if clib_libraries: + build_info['libraries'] = clib_libraries From numpy-svn at scipy.org Fri Jun 15 17:24:52 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 15 Jun 2007 16:24:52 -0500 (CDT) Subject: [Numpy-svn] r3871 - in trunk/numpy/distutils: . command fcompiler Message-ID: <20070615212452.EA9BC39C0BB@new.scipy.org> Author: cookedm Date: 2007-06-15 16:24:46 -0500 (Fri, 15 Jun 2007) New Revision: 3871 Modified: trunk/numpy/distutils/ccompiler.py trunk/numpy/distutils/command/build_ext.py trunk/numpy/distutils/command/config.py trunk/numpy/distutils/environment.py trunk/numpy/distutils/fcompiler/__init__.py trunk/numpy/distutils/fcompiler/absoft.py trunk/numpy/distutils/fcompiler/gnu.py trunk/numpy/distutils/fcompiler/intel.py Log: Better version handling in fcompiler * Remove FCompiler.get_version_cmd, FCompiler.get_flags_version, FCompiler.get_linker_so_cmd, and FCompiler.get_linker_exe_cmd; subclasses should do this in FCompiler.update_executables() * FCompiler attributes .compiler_f77, .version_cmd, etc., are now properties that read from the .executables dictionary. * Update intel.py and absoft.py for above * Add extra asserts for defensive programming. Most of our problems here seem to come from bad values being generated, and the error not being caught until later. * must call FCompiler.customize() before FCompiler.get_version(); command/build_ext.py and command/config.py updated * verify that commands make sense earlier -- must be None or lists of strings Also, * add IA-32 as another pattern to search for in 32-bit Intel compiler version. * minor formatting * add debugging helpers to environment.py:EnvironmentConfig class Modified: trunk/numpy/distutils/ccompiler.py =================================================================== --- trunk/numpy/distutils/ccompiler.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/ccompiler.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -174,8 +174,10 @@ if not attr: continue log.info("compiler '%s' is set to %s" % (attrname,attr)) - try: self.get_version() - except: pass + try: + self.get_version() + except: + pass if log._global_log.threshold<2: print '*'*80 print self.__class__ @@ -251,8 +253,8 @@ return m.group(0) return matcher -def CCompiler_get_version(self, force=0, ok_status=[0]): - """ Compiler version. Returns None if compiler is not available. """ +def CCompiler_get_version(self, force=False, ok_status=[0]): + """Compiler version. Returns None if compiler is not available.""" if not force and hasattr(self,'version'): return self.version self.find_executables() Modified: trunk/numpy/distutils/command/build_ext.py =================================================================== --- trunk/numpy/distutils/command/build_ext.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/command/build_ext.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -178,8 +178,8 @@ fcompiler = self._f77_compiler if fcompiler: ctype = fcompiler.compiler_type + fcompiler.customize(self.distribution) if fcompiler and fcompiler.get_version(): - fcompiler.customize(self.distribution) fcompiler.customize_cmd(self) fcompiler.show_customization() else: @@ -200,8 +200,8 @@ fcompiler = self._f90_compiler if fcompiler: ctype = fcompiler.compiler_type + fcompiler.customize(self.distribution) if fcompiler and fcompiler.get_version(): - fcompiler.customize(self.distribution) fcompiler.customize_cmd(self) fcompiler.show_customization() else: Modified: trunk/numpy/distutils/command/config.py =================================================================== --- trunk/numpy/distutils/command/config.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/command/config.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -28,10 +28,11 @@ if not isinstance(self.fcompiler, FCompiler): self.fcompiler = new_fcompiler(compiler=self.fcompiler, dry_run=self.dry_run, force=1) - if self.fcompiler is not None and self.fcompiler.get_version(): + if self.fcompiler is not None: self.fcompiler.customize(self.distribution) - self.fcompiler.customize_cmd(self) - self.fcompiler.show_customization() + if self.fcompiler.get_version(): + self.fcompiler.customize_cmd(self) + self.fcompiler.show_customization() def _wrap_method(self,mth,lang,args): from distutils.ccompiler import CompileError Modified: trunk/numpy/distutils/environment.py =================================================================== --- trunk/numpy/distutils/environment.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/environment.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -10,6 +10,25 @@ self._conf = None self._hook_handler = None + def dump_variable(self, name): + conf_desc = self._conf_keys[name] + hook, envvar, confvar, convert = conf_desc + if not convert: + convert = lambda x : x + print '%s.%s:' % (self._distutils_section, name) + v = self._hook_handler(name, hook) + print ' hook : %s' % (convert(v),) + if envvar: + v = os.environ.get(envvar, None) + print ' environ: %s' % (convert(v),) + if confvar and self._conf: + v = self._conf.get(confvar, (None, None))[1] + print ' config : %s' % (convert(v),) + + def dump_variables(self): + for name in self._conf_keys: + self.dump_variable(name) + def __getattr__(self, name): try: conf_desc = self._conf_keys[name] Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -2,6 +2,15 @@ Contains FCompiler, an abstract base class that defines the interface for the numpy.distutils Fortran compiler abstraction model. + +Terminology: + +To be consistent, where the term 'executable' is used, it means the single +file, like 'gcc', that is executed, and should be a string. In contrast, +'command' means the entire command line, like ['gcc', '-c', 'file.c'], and +should be a list. + +But note that FCompiler.executables is actually a dictionary of commands. """ __all__ = ['FCompiler','new_fcompiler','show_fcompilers', @@ -20,14 +29,14 @@ from distutils.fancy_getopt import FancyGetopt from distutils.errors import DistutilsModuleError, \ DistutilsExecError, CompileError, LinkError, DistutilsPlatformError -from distutils.util import split_quoted +from distutils.util import split_quoted, strtobool +from distutils.spawn import _nt_quote_args from numpy.distutils.ccompiler import CCompiler, gen_lib_options from numpy.distutils import log -from numpy.distutils.misc_util import is_string, is_sequence, make_temp_file +from numpy.distutils.misc_util import is_string, all_strings, is_sequence, make_temp_file from numpy.distutils.environment import EnvironmentConfig -from numpy.distutils.exec_command import find_executable, splitcmdline -from distutils.spawn import _nt_quote_args +from numpy.distutils.exec_command import find_executable __metaclass__ = type @@ -36,32 +45,35 @@ def flaglist(s): if is_string(s): - return splitcmdline(s) + return split_quoted(s) else: return s def str2bool(s): if is_string(s): - return not (s == '0' or s.lower() == 'false') + return strtobool(s) return bool(s) +def is_sequence_of_strings(seq): + return is_sequence(seq) and all_strings(seq) + class FCompiler(CCompiler): """Abstract base class to define the interface that must be implemented by real Fortran compiler classes. Methods that subclasses may redefine: - find_executables(), get_version_cmd(), get_linker_so(), get_version() + update_executables(), find_executables(), get_version() get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug() get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(), get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(), get_flags_arch_f90(), get_flags_debug_f90(), - get_flags_fix(), get_flags_linker_so(), get_flags_version() + get_flags_fix(), get_flags_linker_so() DON'T call these methods (except get_version) after constructing a compiler instance or inside any other method. - All methods, except get_version_cmd() and get_flags_version(), may - call the get_version() method. + All methods, except update_executables() and find_executables(), + may call the get_version() method. After constructing a compiler instance, always call customize(dist=None) method that finalizes compiler construction and makes the following @@ -98,16 +110,15 @@ compiler_f77 = ('exe.compiler_f77', 'F77', 'f77exec', None), compiler_f90 = ('exe.compiler_f90', 'F90', 'f90exec', None), compiler_fix = ('exe.compiler_fix', 'F90', 'f90exec', None), - version_cmd = ('self.get_version_cmd', None, None, None), - linker_so = ('self.get_linker_so', 'LDSHARED', 'ldshared', None), - linker_exe = ('self.get_linker_exe', 'LD', 'ld', None), + version_cmd = ('exe.version_cmd', None, None, None), + linker_so = ('exe.linker_so', 'LDSHARED', 'ldshared', None), + linker_exe = ('exe.linker_exe', 'LD', 'ld', None), archiver = (None, 'AR', 'ar', None), ranlib = (None, 'RANLIB', 'ranlib', None), ) flag_vars = EnvironmentConfig( distutils_section='config_fc', - version = ('flags.version', None, None, None), f77 = ('flags.f77', 'F77FLAGS', 'f77flags', flaglist), f90 = ('flags.f90', 'F90FLAGS', 'f90flags', flaglist), free = ('flags.free', 'FREEFLAGS', 'freeflags', flaglist), @@ -177,20 +188,31 @@ shared_lib_format = "%s%s" exe_extension = "" + # If compiler does not support compiling Fortran 90 then it can + # suggest using another compiler. For example, gnu would suggest + # gnu95 compiler type when there are F90 sources. + suggested_f90_compiler = None + _exe_cache = {} + _executable_keys = ['version_cmd', 'compiler_f77', 'compiler_f90', + 'compiler_fix', 'linker_so', 'linker_exe', 'archiver', + 'ranlib'] + def __init__(self, *args, **kw): CCompiler.__init__(self, *args, **kw) self.distutils_vars = self.distutils_vars.clone(self._environment_hook) self.command_vars = self.command_vars.clone(self._environment_hook) self.flag_vars = self.flag_vars.clone(self._environment_hook) self.executables = self.executables.copy() - for e in ['version_cmd', 'compiler_f77', 'compiler_f90', - 'compiler_fix', 'linker_so', 'linker_exe', 'archiver', - 'ranlib']: + for e in self._executable_keys: if e not in self.executables: self.executables[e] = None + # Some methods depend on .customize() being called first, so + # this keeps track of whether that's happened yet. + self._is_customised = False + def __copy__(self): obj = new.instance(self.__class__, self.__dict__) obj.distutils_vars = obj.distutils_vars.clone(obj._environment_hook) @@ -199,11 +221,41 @@ obj.executables = obj.executables.copy() return obj - # If compiler does not support compiling Fortran 90 then it can - # suggest using another compiler. For example, gnu would suggest - # gnu95 compiler type when there are F90 sources. - suggested_f90_compiler = None + # Use properties for the attributes used by CCompiler. Setting them + # as attributes from the self.executables dictionary is error-prone, + # so we get them from there each time. + def _command_property(key): + def fget(self): + assert self._is_customised + return self.executables[key] + return property(fget=fget) + version_cmd = _command_property('version_cmd') + compiler_f77 = _command_property('compiler_f77') + compiler_f90 = _command_property('compiler_f90') + compiler_fix = _command_property('compiler_fix') + linker_so = _command_property('linker_so') + linker_exe = _command_property('linker_exe') + archiver = _command_property('archiver') + ranlib = _command_property('ranlib') + # Make our terminology consistent. + def set_executable(self, key, value): + self.set_command(key, value) + + def set_commands(self, **kw): + for k, v in kw.items(): + self.set_command(k, v) + + def set_command(self, key, value): + if not key in self._executable_keys: + raise ValueError( + "unknown executable '%s' for class %s" % + (key, self.__class__.__name__)) + if is_string(value): + value = split_quoted(value) + assert value is None or is_sequence_of_strings(value[1:]), (key, value) + self.executables[key] = value + ###################################################################### ## Methods that subclasses may redefine. But don't call these methods! ## They are private to FCompiler class and may return unexpected @@ -220,7 +272,10 @@ Also, if the 0th element is "" or "", the Fortran 77 or the Fortran 90 compiler executable is used, unless overridden by an environment setting. + + Subclasses should call this if overriden. """ + assert self._is_customised exe_cache = self._exe_cache def cached_find_executable(exe): if exe in exe_cache: @@ -228,6 +283,11 @@ fc_exe = find_executable(exe) exe_cache[exe] = exe_cache[fc_exe] = fc_exe return fc_exe + def verify_command_form(name, value): + if value is not None and not is_sequence_of_strings(value): + raise ValueError( + "%s value %r is invalid in class %s" % + (name, value, self.__class__.__name__)) def set_exe(exe_key, f77=None, f90=None): cmd = self.executables.get(exe_key, None) if not cmd: @@ -257,6 +317,7 @@ if fc_exe: cmd[0] = fc_exe return fc_exe + self.set_command(exe_key, None) return None ctype = self.compiler_type @@ -279,94 +340,48 @@ set_exe('archiver') set_exe('ranlib') - def get_version_cmd(self): - """Compiler command to print out version information.""" - f77 = self.executables.get('compiler_f77') - if f77 is not None: - f77 = f77[0] - cmd = self.executables.get('version_cmd') - if cmd is not None: - cmd = cmd[0] - if cmd == f77: - cmd = self.compiler_f77[0] - else: - f90 = self.executables.get('compiler_f90') - if f90 is not None: - f90 = f90[0] - if cmd == f90: - cmd = self.compiler_f90[0] - return cmd + def update_executables(elf): + """Called at the beginning of customisation. Subclasses should + override this if they need to set up the executables dictionary. - def get_linker_so(self): - """Linker command to build shared libraries.""" - f77 = self.executables.get('compiler_f77') - if f77 is not None: - f77 = f77[0] - ln = self.executables.get('linker_so') - if ln is not None: - ln = ln[0] - if ln == f77: - ln = self.compiler_f77[0] - else: - f90 = self.executables.get('compiler_f90') - if f90 is not None: - f90 = f90[0] - if ln == f90: - ln = self.compiler_f90[0] - return ln + Note that self.find_executables() is run afterwards, so the + self.executables dictionary values can contain or as + the command, which will be replaced by the found F77 or F90 + compiler. + """ + pass - def get_linker_exe(self): - """Linker command to build shared libraries.""" - f77 = self.executables.get('compiler_f77') - if f77 is not None: - f77 = f77[0] - ln = self.executables.get('linker_exe') - if ln is not None: - ln = ln[0] - if ln == f77: - ln = self.compiler_f77[0] - else: - f90 = self.executables.get('compiler_f90') - if f90 is not None: - f90 = f90[0] - if ln == f90: - ln = self.compiler_f90[0] - return ln - def get_flags(self): """List of flags common to all compiler types.""" return [] + self.pic_flags - def _get_executable_flags(self, key): + def _get_command_flags(self, key): cmd = self.executables.get(key, None) if cmd is None: return [] return cmd[1:] - def get_flags_version(self): - """List of compiler flags to print out version information.""" - return self._get_executable_flags('version_cmd') def get_flags_f77(self): """List of Fortran 77 specific flags.""" - return self._get_executable_flags('compiler_f77') + return self._get_command_flags('compiler_f77') def get_flags_f90(self): """List of Fortran 90 specific flags.""" - return self._get_executable_flags('compiler_f90') + return self._get_command_flags('compiler_f90') def get_flags_free(self): """List of Fortran 90 free format specific flags.""" return [] def get_flags_fix(self): """List of Fortran 90 fixed format specific flags.""" - return self._get_executable_flags('compiler_fix') + return self._get_command_flags('compiler_fix') def get_flags_linker_so(self): """List of linker flags to build a shared library.""" - return self._get_executable_flags('linker_so') + return self._get_command_flags('linker_so') def get_flags_linker_exe(self): """List of linker flags to build an executable.""" - return self._get_executable_flags('linker_exe') + return self._get_command_flags('linker_exe') def get_flags_ar(self): """List of archiver flags. """ - return self._get_executable_flags('archiver') + return self._get_command_flags('archiver') def get_flags_opt(self): """List of architecture independent compiler flags.""" return [] @@ -388,6 +403,10 @@ """List of compiler library directories.""" return self.library_dirs[:] + def get_version(self, force=False, ok_status=[0]): + assert self._is_customised + return CCompiler.get_version(force=force, ok_status=ok_status) + ############################################################ ## Public methods: @@ -404,31 +423,26 @@ instance is needed for (iii) and (iv). """ log.info('customize %s' % (self.__class__.__name__)) + + self._is_customised = True + self.distutils_vars.use_distribution(dist) self.command_vars.use_distribution(dist) self.flag_vars.use_distribution(dist) + self.update_executables() + + # find_executables takes care of setting the compiler commands, + # version_cmd, linker_so, linker_exe, ar, and ranlib self.find_executables() noopt = self.distutils_vars.get('noopt', False) - if 0: # change to `if 1:` when making release. - # Don't use architecture dependent compiler flags: - noarch = True - else: - noarch = self.distutils_vars.get('noarch', noopt) + noarch = self.distutils_vars.get('noarch', noopt) debug = self.distutils_vars.get('debug', False) f77 = self.command_vars.compiler_f77 f90 = self.command_vars.compiler_f90 - # Must set version_cmd before others as self.get_flags* - # methods may call self.get_version. - vers_cmd = self.command_vars.version_cmd - if vers_cmd: - vflags = self.get_flags_version() - assert None not in vflags,`vflags` - self.set_executables(version_cmd=[vers_cmd]+vflags) - f77flags = [] f90flags = [] freeflags = [] @@ -445,23 +459,18 @@ fixflags = self.flag_vars.fix + f90flags oflags, aflags, dflags = [], [], [] - def to_list(flags): - if is_string(flags): - return [flags] - return flags # examine get_flags__ for extra flags # only add them if the method is different from get_flags_ def get_flags(tag, flags): # note that self.flag_vars. calls self.get_flags_() - flags.extend(to_list(getattr(self.flag_vars, tag))) + flags.extend(getattr(self.flag_vars, tag)) this_get = getattr(self, 'get_flags_' + tag) for name, c, flagvar in [('f77', f77, f77flags), ('f90', f90, f90flags), ('f90', fix, fixflags)]: t = '%s_%s' % (tag, name) if c and this_get is not getattr(self, 'get_flags_' + t): - flagvar.extend(to_list(getattr(self.flag_vars, t))) - return oflags + flagvar.extend(getattr(self.flag_vars, t)) if not noopt: get_flags('opt', oflags) if not noarch: @@ -469,42 +478,37 @@ if debug: get_flags('debug', dflags) - fflags = to_list(self.flag_vars.flags) + dflags + oflags + aflags + fflags = self.flag_vars.flags + dflags + oflags + aflags if f77: - self.set_executables(compiler_f77=[f77]+f77flags+fflags) + self.set_commands(compiler_f77=[f77]+f77flags+fflags) if f90: - self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags) + self.set_commands(compiler_f90=[f90]+freeflags+f90flags+fflags) if fix: - self.set_executables(compiler_fix=[fix]+fixflags+fflags) + self.set_commands(compiler_fix=[fix]+fixflags+fflags) + #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS - linker_so = self.command_vars.linker_so + linker_so = self.linker_so if linker_so: - linker_so_flags = to_list(self.flag_vars.linker_so) + linker_so_flags = self.flag_vars.linker_so if sys.platform.startswith('aix'): python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') - linker_so = [ld_so_aix, linker_so, '-bI:'+python_exp] - else: - linker_so = [linker_so] - self.set_executables(linker_so=linker_so+linker_so_flags) + linker_so = [ld_so_aix] + linker_so + ['-bI:'+python_exp] + self.set_commands(linker_so=linker_so+linker_so_flags) - linker_exe = self.command_vars.linker_exe + linker_exe = self.linker_exe if linker_exe: - linker_exe_flags = to_list(self.flag_vars.linker_exe) - self.set_executables(linker_exe=[linker_exe]+linker_exe_flags) + linker_exe_flags = self.flag_vars.linker_exe + self.set_commands(linker_exe=linker_exe+linker_exe_flags) ar = self.command_vars.archiver if ar: - arflags = to_list(self.flag_vars.ar) - self.set_executables(archiver=[ar]+arflags) + arflags = self.flag_vars.ar + self.set_commands(archiver=[ar]+arflags) - ranlib = self.command_vars.ranlib - if ranlib: - self.set_executables(ranlib=[ranlib]) - self.set_library_dirs(self.get_library_dirs()) self.set_libraries(self.get_libraries()) @@ -525,7 +529,6 @@ if l[:4]==' --': l = ' ' + l[4:] print l - return ################### @@ -573,8 +576,6 @@ except DistutilsExecError, msg: raise CompileError, msg - return - def module_options(self, module_dirs, module_build_dir): options = [] if self.module_dir_switch is not None: @@ -645,7 +646,6 @@ raise LinkError, msg else: log.debug("skipping %s (up-to-date)", output_filename) - return def _environment_hook(self, name, hook_name): if hook_name is None: Modified: trunk/numpy/distutils/fcompiler/absoft.py =================================================================== --- trunk/numpy/distutils/fcompiler/absoft.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/fcompiler/absoft.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -30,7 +30,7 @@ # Note that fink installs g77 as f77, so need to use f90 for detection. executables = { - 'version_cmd' : ['', None], + 'version_cmd' : None, # set by update_executables 'compiler_f77' : ["f77"], 'compiler_fix' : ["f90"], 'compiler_f90' : ["f90"], @@ -45,9 +45,10 @@ module_dir_switch = None module_include_switch = '-p' - def get_flags_version(self): + def update_executables(self): f = cyg2win32(dummy_fortran_file()) - return ['-V', '-c', f+'.f', '-o', f+'.o'] + self.executables['version_cmd'] = ['', '-V', '-c', + f+'.f', '-o', f+'.o'] def get_flags_linker_so(self): if os.name=='nt': Modified: trunk/numpy/distutils/fcompiler/gnu.py =================================================================== --- trunk/numpy/distutils/fcompiler/gnu.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/fcompiler/gnu.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -297,7 +297,7 @@ 'linker_so' : ["", "-Wall"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"], - 'linker_exe' : [None,"-Wall"] + 'linker_exe' : [None, "-Wall"] } # use -mno-cygwin flag for g77 when Python is not Cygwin-Python Modified: trunk/numpy/distutils/fcompiler/intel.py =================================================================== --- trunk/numpy/distutils/fcompiler/intel.py 2007-06-15 20:55:41 UTC (rev 3870) +++ trunk/numpy/distutils/fcompiler/intel.py 2007-06-15 21:24:46 UTC (rev 3871) @@ -13,22 +13,28 @@ def intel_version_match(type): # Match against the important stuff in the version string - return simple_version_match(start=r'Intel.*?Fortran.*?%s.*?Version' % (type,)) + return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,)) -class IntelFCompiler(FCompiler): +class BaseIntelFCompiler(FCompiler): + def update_executables(self): + f = dummy_fortran_file() + self.executables['version_cmd'] = ['', '-FI', '-V', '-c', + f + '.f', '-o', f + '.o'] +class IntelFCompiler(BaseIntelFCompiler): + compiler_type = 'intel' description = 'Intel Fortran Compiler for 32-bit apps' - version_match = intel_version_match('32-bit') + version_match = intel_version_match('32-bit|IA-32') possible_executables = ['ifort', 'ifc'] executables = { - 'version_cmd' : ['', None], - 'compiler_f77' : [None,"-72","-w90","-w95"], + 'version_cmd' : None, # set by update_executables + 'compiler_f77' : [None, "-72", "-w90", "-w95"], 'compiler_f90' : [None], - 'compiler_fix' : [None,"-FI"], - 'linker_so' : ["","-shared"], + 'compiler_fix' : [None, "-FI"], + 'linker_so' : ["", "-shared"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } @@ -37,10 +43,6 @@ module_dir_switch = '-module ' # Don't remove ending space! module_include_switch = '-I' - def get_flags_version(self): - f = dummy_fortran_file() - return ['-FI', '-V', '-c', f + '.f', '-o', f + '.o'] - def get_flags(self): opt = self.pic_flags + ["-cm"] return opt @@ -112,9 +114,9 @@ possible_executables = ['ifort', 'efort', 'efc'] executables = { - 'version_cmd' : ['', None], - 'compiler_f77' : [None,"-FI","-w90","-w95"], - 'compiler_fix' : [None,"-FI"], + 'version_cmd' : None, + 'compiler_f77' : [None, "-FI", "-w90", "-w95"], + 'compiler_fix' : [None, "-FI"], 'compiler_f90' : [None], 'linker_so' : ['', "-shared"], 'archiver' : ["ar", "-cr"], @@ -130,7 +132,7 @@ possible_executables = ['ifort', 'efort', 'efc'] executables = { - 'version_cmd' : ['', None], + 'version_cmd' : None, 'compiler_f77' : [None, "-FI", "-w90", "-w95"], 'compiler_fix' : [None, "-FI"], 'compiler_f90' : [None], @@ -148,16 +150,16 @@ # Is there no difference in the version string between the above compilers # and the Visual compilers? -class IntelVisualFCompiler(FCompiler): +class IntelVisualFCompiler(BaseIntelFCompiler): compiler_type = 'intelv' description = 'Intel Visual Fortran Compiler for 32-bit apps' - version_match = intel_version_match('32-bit') + version_match = intel_version_match('32-bit|IA-32') ar_exe = 'lib.exe' possible_executables = ['ifl'] executables = { - 'version_cmd' : ['', None], + 'version_cmd' : None, 'compiler_f77' : [None,"-FI","-w90","-w95"], 'compiler_fix' : [None,"-FI","-4L72","-w"], 'compiler_f90' : [None], @@ -172,10 +174,6 @@ module_dir_switch = '/module:' #No space after /module: module_include_switch = '/I' - def get_flags_version(self): - f = dummy_fortran_file() - return ['-FI', '-V', '-c', f + '.f', '-o', f + '.o'] - def get_flags(self): opt = ['/nologo','/MD','/nbs','/Qlowercase','/us'] return opt @@ -213,7 +211,7 @@ ar_exe = IntelVisualFCompiler.ar_exe executables = { - 'version_cmd' : ['', None], + 'version_cmd' : None, 'compiler_f77' : [None,"-FI","-w90","-w95"], 'compiler_fix' : [None,"-FI","-4L72","-w"], 'compiler_f90' : [None], From numpy-svn at scipy.org Sat Jun 16 04:44:42 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 16 Jun 2007 03:44:42 -0500 (CDT) Subject: [Numpy-svn] r3872 - trunk/numpy/distutils/fcompiler Message-ID: <20070616084442.3165939C076@new.scipy.org> Author: pearu Date: 2007-06-16 03:44:24 -0500 (Sat, 16 Jun 2007) New Revision: 3872 Modified: trunk/numpy/distutils/fcompiler/__init__.py Log: Fix build breakage. Modified: trunk/numpy/distutils/fcompiler/__init__.py =================================================================== --- trunk/numpy/distutils/fcompiler/__init__.py 2007-06-15 21:24:46 UTC (rev 3871) +++ trunk/numpy/distutils/fcompiler/__init__.py 2007-06-16 08:44:24 UTC (rev 3872) @@ -405,7 +405,7 @@ def get_version(self, force=False, ok_status=[0]): assert self._is_customised - return CCompiler.get_version(force=force, ok_status=ok_status) + return CCompiler.get_version(self, force=force, ok_status=ok_status) ############################################################ From numpy-svn at scipy.org Sun Jun 17 14:18:33 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 17 Jun 2007 13:18:33 -0500 (CDT) Subject: [Numpy-svn] r3873 - trunk/numpy/doc/swig Message-ID: <20070617181833.5489139C043@new.scipy.org> Author: wfspotz at sandia.gov Date: 2007-06-17 13:18:22 -0500 (Sun, 17 Jun 2007) New Revision: 3873 Modified: trunk/numpy/doc/swig/numpy.i Log: Fixed format string warning Modified: trunk/numpy/doc/swig/numpy.i =================================================================== --- trunk/numpy/doc/swig/numpy.i 2007-06-16 08:44:24 UTC (rev 3872) +++ trunk/numpy/doc/swig/numpy.i 2007-06-17 18:18:22 UTC (rev 3873) @@ -292,14 +292,14 @@ } else { - sprintf(s, "%d,", size[i]); + sprintf(s, "%ld,", (long int)size[i]); } strcat(desired_dims,s); } len = strlen(desired_dims); desired_dims[len-1] = ']'; for (i = 0; i < n; i++) { - sprintf(s, "%d,", array_size(ary,i)); + sprintf(s, "%ld,", (long int)array_size(ary,i)); strcat(actual_dims,s); } len = strlen(actual_dims); From numpy-svn at scipy.org Sun Jun 17 15:18:00 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 17 Jun 2007 14:18:00 -0500 (CDT) Subject: [Numpy-svn] r3874 - trunk/numpy Message-ID: <20070617191800.B4BC639C05D@new.scipy.org> Author: cookedm Date: 2007-06-17 14:17:58 -0500 (Sun, 17 Jun 2007) New Revision: 3874 Modified: trunk/numpy/__init__.py Log: Print install location, numpy version, and python verstion in numpy.test() Modified: trunk/numpy/__init__.py =================================================================== --- trunk/numpy/__init__.py 2007-06-17 18:18:22 UTC (rev 3873) +++ trunk/numpy/__init__.py 2007-06-17 19:17:58 UTC (rev 3874) @@ -85,6 +85,10 @@ """ def test(*args, **kw): + import os, sys + print 'Numpy is installed in %s' % (os.path.split(__file__)[0],) + print 'Numpy version %s' % (__version__,) + print 'Python version %s' % (sys.version.replace('\n', '',),) return NumpyTest().test(*args, **kw) test.__doc__ = NumpyTest.test.__doc__ From numpy-svn at scipy.org Tue Jun 19 20:30:13 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 19 Jun 2007 19:30:13 -0500 (CDT) Subject: [Numpy-svn] r3875 - trunk/numpy/numarray Message-ID: <20070620003013.D559A39C0B6@new.scipy.org> Author: fperez Date: 2007-06-19 19:30:11 -0500 (Tue, 19 Jun 2007) New Revision: 3875 Modified: trunk/numpy/numarray/functions.py Log: Small fix for numpy.info(), which was unconditionally broken Modified: trunk/numpy/numarray/functions.py =================================================================== --- trunk/numpy/numarray/functions.py 2007-06-17 19:17:58 UTC (rev 3874) +++ trunk/numpy/numarray/functions.py 2007-06-20 00:30:11 UTC (rev 3875) @@ -376,7 +376,7 @@ else: extra = "" tic = "" - print >> output, "data pointer: %s%s" % (hex(obj.ctypes._as_parameter_), extra) + print >> output, "data pointer: %s%s" % (hex(obj.ctypes._as_parameter_.value), extra) print >> output, "byteorder: ", endian = obj.dtype.byteorder if endian in ['|','=']: From numpy-svn at scipy.org Sat Jun 30 10:42:34 2007 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 30 Jun 2007 09:42:34 -0500 (CDT) Subject: [Numpy-svn] r3876 - in trunk/numpy: . core/src core/tests Message-ID: <20070630144234.6DFB739C04E@new.scipy.org> Author: charris Date: 2007-06-30 09:42:31 -0500 (Sat, 30 Jun 2007) New Revision: 3876 Modified: trunk/numpy/add_newdocs.py trunk/numpy/core/src/_sortmodule.c.src trunk/numpy/core/tests/test_regression.py Log: Replace <= by < in the insertion sort part of argsort(kind='mergesort') for strings. Fixes ticket #540. Modified: trunk/numpy/add_newdocs.py =================================================================== --- trunk/numpy/add_newdocs.py 2007-06-20 00:30:11 UTC (rev 3875) +++ trunk/numpy/add_newdocs.py 2007-06-30 14:42:31 UTC (rev 3876) @@ -367,7 +367,7 @@ sort order, and so on). The keys argument must be a sequence of things that can be converted to arrays of the same shape. - :Parameters: + Parameters: a : array type Array containing values that the returned indices should sort. @@ -376,16 +376,16 @@ Axis to be indirectly sorted. None indicates that the flattened array should be used. Default is -1. - :Returns: + Returns: indices : integer array Array of indices that sort the keys along the specified axis. The array has the same shape as the keys. - :SeeAlso: + SeeAlso: - - argsort : indirect sort - - sort : inplace sort + argsort : indirect sort + sort : inplace sort """) Modified: trunk/numpy/core/src/_sortmodule.c.src =================================================================== --- trunk/numpy/core/src/_sortmodule.c.src 2007-06-20 00:30:11 UTC (rev 3875) +++ trunk/numpy/core/src/_sortmodule.c.src 2007-06-30 14:42:31 UTC (rev 3876) @@ -377,7 +377,7 @@ *pi = *pj; } for(pk = pw, pm = pl; pk < pi && pj <= pr; ++pm) { - if (@comp@(v+(*pk)*len,v+(*pj)*len,len)<=0) { + if (@comp@(v+(*pk)*len,v+(*pj)*len,len) <= 0) { *pm = *pk; ++pk; }else{ @@ -393,8 +393,8 @@ for(pi = pl + 1; pi <= pr; ++pi) { vi = *pi; vp = v + vi*len; - for(pj = pi, pk = pi - 1; \ - pj > pl && (@comp@(vp, v+(*pk)*len,len)<=0); \ + for(pj = pi, pk = pi - 1; \ + pj > pl && (@comp@(vp, v+(*pk)*len,len) < 0);\ --pj, --pk) { *pj = *pk; } Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2007-06-20 00:30:11 UTC (rev 3875) +++ trunk/numpy/core/tests/test_regression.py 2007-06-30 14:42:31 UTC (rev 3876) @@ -687,5 +687,11 @@ x = N.random.rand(*(2,)*16) y = x.transpose(range(16)) + def check_string_mergesort(self, level=rlevel): + """Ticket #540""" + x = N.array(['a']*32) + assert_array_equal(x.argsort(kind='m'), N.arange(32)) + + if __name__ == "__main__": NumpyTest().run()