From numpy-svn at scipy.org Wed Jan 2 12:04:17 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Wed, 2 Jan 2008 11:04:17 -0600 (CST)
Subject: [Numpy-svn] r4673 - in trunk/numpy: lib/tests testing
Message-ID: <20080102170417.3EA3C39C31A@new.scipy.org>
Author: oliphant
Date: 2008-01-02 11:04:15 -0600 (Wed, 02 Jan 2008)
New Revision: 4673
Modified:
trunk/numpy/lib/tests/test_format.py
trunk/numpy/testing/utils.py
Log:
Removed dependency on nose.tools. Ripped nose.tools.raise and placed it in numpy.testing
Modified: trunk/numpy/lib/tests/test_format.py
===================================================================
--- trunk/numpy/lib/tests/test_format.py 2007-12-30 17:57:53 UTC (rev 4672)
+++ trunk/numpy/lib/tests/test_format.py 2008-01-02 17:04:15 UTC (rev 4673)
@@ -280,10 +280,8 @@
import shutil
import tempfile
-from nose.tools import raises
-
import numpy as np
-from numpy.testing import assert_array_equal
+from numpy.testing import assert_array_equal, raises
from numpy.lib import format
Modified: trunk/numpy/testing/utils.py
===================================================================
--- trunk/numpy/testing/utils.py 2007-12-30 17:57:53 UTC (rev 4672)
+++ trunk/numpy/testing/utils.py 2008-01-02 17:04:15 UTC (rev 4673)
@@ -11,7 +11,7 @@
__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',
'assert_array_equal', 'assert_array_less', 'assert_string_equal',
'assert_array_almost_equal', 'jiffies', 'memusage', 'rand',
- 'runstring']
+ 'runstring', 'raises']
def rand(*args):
"""Returns an array of random numbers with the given shape.
@@ -270,3 +270,37 @@
if not diff_list: return
msg = 'Differences in strings:\n%s' % (''.join(diff_list)).rstrip()
assert actual==desired, msg
+
+# Ripped from nose.tools
+def raises(*exceptions):
+ """Test must raise one of expected exceptions to pass.
+
+ Example use::
+
+ @raises(TypeError, ValueError)
+ def test_raises_type_error():
+ raise TypeError("This test passes")
+
+ @raises(Exception):
+ def test_that_fails_by_passing():
+ pass
+
+ If you want to test many assertions about exceptions in a single test,
+ you may want to use `assert_raises` instead.
+ """
+ valid = ' or '.join([e.__name__ for e in exceptions])
+ def decorate(func):
+ name = func.__name__
+ def newfunc(*arg, **kw):
+ try:
+ func(*arg, **kw)
+ except exceptions:
+ pass
+ except:
+ raise
+ else:
+ message = "%s() did not raise %s" % (name, valid)
+ raise AssertionError(message)
+ newfunc = make_decorator(func)(newfunc)
+ return newfunc
+ return decorate
From numpy-svn at scipy.org Sat Jan 5 13:44:30 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sat, 5 Jan 2008 12:44:30 -0600 (CST)
Subject: [Numpy-svn] r4674 - trunk/numpy
Message-ID: <20080105184430.A8D4E39C0DC@new.scipy.org>
Author: cookedm
Date: 2008-01-05 12:44:28 -0600 (Sat, 05 Jan 2008)
New Revision: 4674
Modified:
trunk/numpy/matlib.py
Log:
Fix regression in r4659; matlib.py should use from numpy import *
Modified: trunk/numpy/matlib.py
===================================================================
--- trunk/numpy/matlib.py 2008-01-02 17:04:15 UTC (rev 4673)
+++ trunk/numpy/matlib.py 2008-01-05 18:44:28 UTC (rev 4674)
@@ -1,6 +1,7 @@
import numpy as np
-from numpy import ndarray, array
from numpy.core.defmatrix import matrix, asmatrix
+# need * as we're copying the numpy namespace
+from numpy import *
__version__ = np.__version__
From numpy-svn at scipy.org Sun Jan 6 04:28:40 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 03:28:40 -0600 (CST)
Subject: [Numpy-svn] r4675 - branches/distutils_scons_command/numpy/distutils
Message-ID: <20080106092840.1A30E39C10E@new.scipy.org>
Author: cdavid
Date: 2008-01-06 03:28:27 -0600 (Sun, 06 Jan 2008)
New Revision: 4675
Modified:
branches/distutils_scons_command/numpy/distutils/misc_util.py
Log:
Add scons_make_config function to numpy distutils Configuration
Modified: branches/distutils_scons_command/numpy/distutils/misc_util.py
===================================================================
--- branches/distutils_scons_command/numpy/distutils/misc_util.py 2008-01-05 18:44:28 UTC (rev 4674)
+++ branches/distutils_scons_command/numpy/distutils/misc_util.py 2008-01-06 09:28:27 UTC (rev 4675)
@@ -1441,6 +1441,12 @@
"""
self.py_modules.append((self.name,name,generate_config_py))
+ def scons_make_config_py(self, name = '__config__'):
+ """Generate package __config__.py file containing system_info
+ information used during building the package.
+ """
+ self.py_modules.append((self.name, name, scons_generate_config_py))
+
def get_info(self,*names):
"""Get resources information.
"""
From numpy-svn at scipy.org Sun Jan 6 04:38:52 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 03:38:52 -0600 (CST)
Subject: [Numpy-svn] r4676 - branches
Message-ID: <20080106093852.6643F39C139@new.scipy.org>
Author: cdavid
Date: 2008-01-06 03:38:40 -0600 (Sun, 06 Jan 2008)
New Revision: 4676
Added:
branches/build_with_scons/
Log:
Create build_with_scons branch, which will make numpy buildable with numscons
Copied: branches/build_with_scons (from rev 4675, trunk)
From numpy-svn at scipy.org Sun Jan 6 04:39:39 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 03:39:39 -0600 (CST)
Subject: [Numpy-svn] r4677 - trunk
Message-ID: <20080106093939.3E03C39C114@new.scipy.org>
Author: cdavid
Date: 2008-01-06 03:39:33 -0600 (Sun, 06 Jan 2008)
New Revision: 4677
Modified:
trunk/
Log:
Initialized merge tracking via "svnmerge" with revisions "1-4676" from
http://svn.scipy.org/svn/numpy/branches/build_with_scons
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/cleanconfig_rtm:1-4610 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
+ /branches/build_with_scons:1-4676 /branches/cleanconfig_rtm:1-4610 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
From numpy-svn at scipy.org Sun Jan 6 05:10:08 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:10:08 -0600 (CST)
Subject: [Numpy-svn] r4678 - in branches/build_with_scons: . numpy/core
numpy/core/include/numpy numpy/core/src numpy/distutils
numpy/distutils/command
Message-ID: <20080106101008.601CC39C1AC@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:09:33 -0600 (Sun, 06 Jan 2008)
New Revision: 4678
Modified:
branches/build_with_scons/
branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h
branches/build_with_scons/numpy/core/setup.py
branches/build_with_scons/numpy/core/src/arraytypes.inc.src
branches/build_with_scons/numpy/core/src/umathmodule.c.src
branches/build_with_scons/numpy/distutils/command/config.py
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Merged revisions 4612-4617,4628-4631,4638 via svnmerge from
http://svn.scipy.org/svn/numpy/branches/cleanconfig_rtm
................
r4612 | cdavid | 2007-12-18 17:58:13 +0900 (Tue, 18 Dec 2007) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-4611" from
http://svn.scipy.org/svn/numpy/trunk
................
r4613 | cdavid | 2007-12-18 18:26:38 +0900 (Tue, 18 Dec 2007) | 1 line
Clean ndarrayobject.h headers: do not use SIZEOF_*, but NPY_SIZEOF...
................
r4614 | cdavid | 2007-12-18 18:33:11 +0900 (Tue, 18 Dec 2007) | 1 line
Refactor the NPY_ALLOW_THREAD logic outside config.h generation, and put it inside numpy headers
................
r4615 | cdavid | 2007-12-18 18:46:34 +0900 (Tue, 18 Dec 2007) | 1 line
separate config.h (private header) and numpyconfig.h (public header)
................
r4616 | cdavid | 2007-12-18 18:57:21 +0900 (Tue, 18 Dec 2007) | 2 lines
Add CHAR_BITS as a public symbol in numpyconfig header
................
r4617 | cdavid | 2007-12-18 19:05:38 +0900 (Tue, 18 Dec 2007) | 1 line
Fix escaping problem when generating numpyconfig.h on win32
................
r4628 | cdavid | 2007-12-22 12:20:08 +0900 (Sat, 22 Dec 2007) | 1 line
Add code to test for a declaration in header
................
r4629 | cdavid | 2007-12-22 14:52:38 +0900 (Sat, 22 Dec 2007) | 1 line
Add a check_decl function to check for declaration
................
r4630 | cdavid | 2007-12-22 15:28:11 +0900 (Sat, 22 Dec 2007) | 1 line
Remove distutils test for C declaration from numpy.core, since it is put in distutils now
................
r4631 | cdavid | 2007-12-22 15:58:15 +0900 (Sat, 22 Dec 2007) | 18 lines
Merged revisions 4612-4630 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r4620 | cdavid | 2007-12-18 19:41:22 +0900 (Tue, 18 Dec 2007) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-4619" from
http://svn.scipy.org/svn/numpy/branches/distutils_scons_command
........
r4624 | rc | 2007-12-20 19:30:45 +0900 (Thu, 20 Dec 2007) | 2 lines
fixed setmember1d for string arrays
........
r4626 | stefan | 2007-12-21 18:00:24 +0900 (Fri, 21 Dec 2007) | 2 lines
Add test for setdiff1d on character arrays.
........
................
r4638 | cdavid | 2007-12-22 18:21:25 +0900 (Sat, 22 Dec 2007) | 1 line
Get MATHLIB from numpyconfig.h, not from config.h anymore
................
Property changes on: branches/build_with_scons
___________________________________________________________________
Name: svnmerge-integrated
- /branches/cleanconfig_rtm:1-4610 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
+ /branches/cleanconfig_rtm:1-4677 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
Modified: branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h 2008-01-06 10:09:33 UTC (rev 4678)
@@ -13,8 +13,15 @@
everything when you're typing */
#endif
/* This is auto-generated by the installer */
-#include "config.h"
+#include "numpyconfig.h"
+/* Only use thread if configured in config and python supports it */
+#if defined WITH_THREAD && !NPY_NOSMP
+ #define NPY_ALLOW_THREADS 1
+#else
+ #define NPY_ALLOW_THREADS 0
+#endif
+
/* There are several places in the code where an array of dimensions is
* allocated statically. This is the size of that static allocation.
*
@@ -80,7 +87,8 @@
#define NPY_FALSE 0
#define NPY_TRUE 1
-#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE
+
+#if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
typedef double npy_longdouble;
#define NPY_LONGDOUBLE_FMT "g"
#else
@@ -279,22 +287,15 @@
#define NPY_MAX_ULONG ULONG_MAX
-#define NPY_SIZEOF_LONG SIZEOF_LONG
-#define NPY_SIZEOF_INT SIZEOF_INT
-#define NPY_SIZEOF_SHORT SIZEOF_SHORT
-#define NPY_SIZEOF_FLOAT SIZEOF_FLOAT
-#define NPY_SIZEOF_DOUBLE SIZEOF_DOUBLE
-#define NPY_SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE
-#define NPY_SIZEOF_LONGLONG SIZEOF_LONG_LONG
#define NPY_BITSOF_BOOL (sizeof(npy_bool)*CHAR_BIT)
#define NPY_BITSOF_CHAR CHAR_BIT
-#define NPY_BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)
-#define NPY_BITSOF_INT (SIZEOF_INT*CHAR_BIT)
-#define NPY_BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)
-#define NPY_BITSOF_LONGLONG (NPY_SIZEOF_LONGLONG*CHAR_BIT)
-#define NPY_BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)
-#define NPY_BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)
-#define NPY_BITSOF_LONGDOUBLE (NPY_SIZEOF_LONGDOUBLE*CHAR_BIT)
+#define NPY_BITSOF_SHORT (NPY_SIZEOF_SHORT * CHAR_BIT)
+#define NPY_BITSOF_INT (NPY_SIZEOF_INT * CHAR_BIT)
+#define NPY_BITSOF_LONG (NPY_SIZEOF_LONG * CHAR_BIT)
+#define NPY_BITSOF_LONGLONG (NPY_SIZEOF_LONGLONG * CHAR_BIT)
+#define NPY_BITSOF_FLOAT (NPY_SIZEOF_FLOAT * CHAR_BIT)
+#define NPY_BITSOF_DOUBLE (NPY_SIZEOF_DOUBLE * CHAR_BIT)
+#define NPY_BITSOF_LONGDOUBLE (NPY_SIZEOF_LONGDOUBLE * CHAR_BIT)
#if NPY_BITSOF_LONG == 8
#define NPY_INT8 NPY_LONG
@@ -918,8 +919,8 @@
* platform. Py_intptr_t, Py_uintptr_t are defined in pyport.h. */
typedef Py_intptr_t npy_intp;
typedef Py_uintptr_t npy_uintp;
-#define NPY_SIZEOF_INTP SIZEOF_PY_INTPTR_T
-#define NPY_SIZEOF_UINTP SIZEOF_PY_INTPTR_T
+#define NPY_SIZEOF_INTP NPY_SIZEOF_PY_INTPTR_T
+#define NPY_SIZEOF_UINTP NPY_SIZEOF_PY_INTPTR_T
#ifdef constchar
#undef constchar
@@ -940,7 +941,7 @@
#define constchar char
#endif
-#if SIZEOF_PY_INTPTR_T == SIZEOF_INT
+#if NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_INT
#define NPY_INTP NPY_INT
#define NPY_UINTP NPY_UINT
#define PyIntpArrType_Type PyIntArrType_Type
@@ -949,7 +950,7 @@
#define NPY_MIN_INTP NPY_MIN_INT
#define NPY_MAX_UINTP NPY_MAX_UINT
#define NPY_INTP_FMT "d"
-#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG
+#elif NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_LONG
#define NPY_INTP NPY_LONG
#define NPY_UINTP NPY_ULONG
#define PyIntpArrType_Type PyLongArrType_Type
@@ -958,7 +959,7 @@
#define NPY_MIN_INTP MIN_LONG
#define NPY_MAX_UINTP NPY_MAX_ULONG
#define NPY_INTP_FMT "ld"
-#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)
+#elif defined(PY_LONG_LONG) && (NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_LONGLONG)
#define NPY_INTP NPY_LONGLONG
#define NPY_UINTP NPY_ULONGLONG
#define PyIntpArrType_Type PyLongLongArrType_Type
@@ -1894,7 +1895,7 @@
#define PyArray_REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)
#define NPY_REFCOUNT PyArray_REFCOUNT
-#define NPY_MAX_ELSIZE (2*SIZEOF_LONGDOUBLE)
+#define NPY_MAX_ELSIZE (2 * NPY_SIZEOF_LONGDOUBLE)
#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \
PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \
Modified: branches/build_with_scons/numpy/core/setup.py
===================================================================
--- branches/build_with_scons/numpy/core/setup.py 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/core/setup.py 2008-01-06 10:09:33 UTC (rev 4678)
@@ -18,6 +18,11 @@
('rint', 'HAVE_RINT'),
]
+def is_npy_no_signal():
+ """Return True if the NPY_NO_SIGNAL symbol must be defined in configuration
+ header."""
+ return sys.platform == 'win32'
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration,dot_join
from numpy.distutils.system_info import get_info, default_lib_dirs
@@ -53,12 +58,12 @@
raise SystemError,"Failed to test configuration. "\
"See previous error messages for more information."
- # Python 2.3 causes a segfault when
- # trying to re-acquire the thread-state
- # which is done in error-handling
- # ufunc code. NPY_ALLOW_C_API and friends
- # cause the segfault. So, we disable threading
- # for now.
+ # Python 2.3 causes a segfault when
+ # trying to re-acquire the thread-state
+ # which is done in error-handling
+ # ufunc code. NPY_ALLOW_C_API and friends
+ # cause the segfault. So, we disable threading
+ # for now.
if sys.version[:5] < '2.4.2':
nosmp = 1
else:
@@ -73,8 +78,7 @@
nosmp = 1
except KeyError:
nosmp = 0
- if nosmp: moredefs = [('NPY_ALLOW_THREADS', '0')]
- else: moredefs = []
+ moredefs = []
#
mathlibs = []
tc = testcode_mathlib()
@@ -102,7 +106,7 @@
if check_func(func_name):
moredefs.append(defsymbol)
- if sys.platform == 'win32':
+ if is_npy_no_signal():
moredefs.append('NPY_NO_SIGNAL')
if sys.platform=='win32' or os.name=='nt':
@@ -123,8 +127,12 @@
target_f.write('#define %s\n' % (d))
else:
target_f.write('#define %s %s\n' % (d[0],d[1]))
- if not nosmp: # default is to use WITH_THREAD
- target_f.write('#ifdef WITH_THREAD\n#define NPY_ALLOW_THREADS 1\n#else\n#define NPY_ALLOW_THREADS 0\n#endif\n')
+ # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
+ # support thread support reliably
+ if nosmp:
+ target_f.write('#define NPY_NOSMP 1\n')
+ else:
+ target_f.write('#define NPY_NOSMP 0\n')
target_f.close()
print 'File:',target
target_f = open(target)
@@ -151,6 +159,39 @@
config.add_data_files((header_dir,target))
return target
+ def generate_numpyconfig_h(ext, build_dir):
+ """Depends on config.h: generate_config_h has to be called before !"""
+ target = join(build_dir,'numpyconfig.h')
+ if newer(__file__,target):
+ config_cmd = config.get_config_cmd()
+ log.info('Generating %s',target)
+ testcode = generate_numpyconfig_code(target)
+
+ from distutils import sysconfig
+ python_include = sysconfig.get_python_inc()
+ python_h = join(python_include, 'Python.h')
+ if not os.path.isfile(python_h):
+ raise SystemError,\
+ "Non-existing %s. Perhaps you need to install"\
+ " python-dev|python-devel." % (python_h)
+
+ config.numpy_include_dirs
+ result = config_cmd.try_run(testcode,
+ include_dirs = [python_include] + \
+ config.numpy_include_dirs,
+ library_dirs = default_lib_dirs)
+
+ if not result:
+ raise SystemError,"Failed to generate numpy configuration. "\
+ "See previous error messages for more information."
+
+ print 'File: %s' % target
+ target_f = open(target)
+ print target_f.read()
+ target_f.close()
+ print 'EOF'
+ return target
+
def generate_api_func(module_name):
def generate_api(ext, build_dir):
script = join(codegen_dir, module_name + '.py')
@@ -205,6 +246,7 @@
config.add_extension('multiarray',
sources = [join('src','multiarraymodule.c'),
generate_config_h,
+ generate_numpyconfig_h,
generate_array_api,
join('src','scalartypes.inc.src'),
join('src','arraytypes.inc.src'),
@@ -216,6 +258,7 @@
config.add_extension('umath',
sources = [generate_config_h,
+ generate_numpyconfig_h,
join('src','umathmodule.c.src'),
generate_umath_c,
generate_ufunc_api,
@@ -231,6 +274,7 @@
config.add_extension('_sort',
sources=[join('src','_sortmodule.c.src'),
generate_config_h,
+ generate_numpyconfig_h,
generate_array_api,
],
)
@@ -238,6 +282,7 @@
config.add_extension('scalarmath',
sources=[join('src','scalarmathmodule.c.src'),
generate_config_h,
+ generate_numpyconfig_h,
generate_array_api,
generate_ufunc_api],
)
@@ -342,6 +387,79 @@
testcode = '\n'.join(testcode)
return testcode
+def generate_numpyconfig_code(target):
+ """Return the source code as a string of the code to generate the
+ numpyconfig header file."""
+ if sys.platform == 'win32':
+ target = target.replace('\\','\\\\')
+ # Config symbols to prepend
+ prepends = [('NPY_SIZEOF_SHORT', 'SIZEOF_SHORT'),
+ ('NPY_SIZEOF_INT', 'SIZEOF_INT'),
+ ('NPY_SIZEOF_LONG', 'SIZEOF_LONG'),
+ ('NPY_SIZEOF_FLOAT', 'SIZEOF_FLOAT'),
+ ('NPY_SIZEOF_DOUBLE', 'SIZEOF_DOUBLE'),
+ ('NPY_SIZEOF_LONGDOUBLE', 'SIZEOF_LONG_DOUBLE'),
+ ('NPY_SIZEOF_PY_INTPTR_T', 'SIZEOF_PY_INTPTR_T'),
+ ('NPY_NOSMP', 'NPY_NOSMP'),]
+
+ testcode = ["""
+#include
+#include "config.h"
+
+int main()
+{
+ FILE* f;
+
+ f = fopen("%s", "w");
+ if (f == NULL) {
+ return -1;
+ }
+""" % target]
+
+ testcode.append(r"""
+ fprintf(f, "/*\n * This file is generated by %s. DO NOT EDIT \n */\n");
+""" % __file__)
+
+ # Prepend NPY_ to any SIZEOF defines
+ testcode.extend([r' fprintf(f, "#define ' + i + r' %%d \n", %s);' % j for i, j in prepends])
+
+ # Conditionally define NPY_NO_SIGNAL
+ if is_npy_no_signal():
+ testcode.append(r' fprintf(f, "\n#define NPY_NO_SIGNAL\n");')
+
+ tmpcode = r"""
+ #ifdef PY_LONG_LONG
+ fprintf(f, "\n#define %s %%d \n", %s);
+ fprintf(f, "#define %s %%d \n", %s);
+ #else
+ fprintf(f, "/* PY_LONG_LONG not defined */ \n");
+ #endif"""
+ testcode.append(tmpcode % ('NPY_SIZEOF_LONGLONG', 'SIZEOF_LONG_LONG',
+ 'NPY_SIZEOF_PY_LONG_LONG', 'SIZEOF_PY_LONG_LONG'))
+
+ testcode.append(r"""
+#ifndef CHAR_BIT
+ {
+ unsigned char var = 2;
+ int i = 0;
+ while (var >= 2) {
+ var = var << 1;
+ i++;
+ }
+ fprintf(f,"#define CHAR_BIT %d\n", i+1);
+ }
+#else
+ fprintf(f, "/* #define CHAR_BIT %d */\n", CHAR_BIT);
+#endif""")
+
+ testcode.append("""
+ fclose(f);
+
+ return 0;
+}
+""")
+ return "\n".join(testcode)
+
if __name__=='__main__':
from numpy.distutils.core import setup
setup(configuration=configuration)
Modified: branches/build_with_scons/numpy/core/src/arraytypes.inc.src
===================================================================
--- branches/build_with_scons/numpy/core/src/arraytypes.inc.src 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/core/src/arraytypes.inc.src 2008-01-06 10:09:33 UTC (rev 4678)
@@ -1,4 +1,5 @@
/* -*- c -*- */
+#include "config.h"
static longlong
MyPyLong_AsLongLong(PyObject *vv)
Modified: branches/build_with_scons/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/build_with_scons/numpy/core/src/umathmodule.c.src 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/core/src/umathmodule.c.src 2008-01-06 10:09:33 UTC (rev 4678)
@@ -5,6 +5,7 @@
#define _UMATHMODULE
#include "numpy/ufuncobject.h"
#include "abstract.h"
+#include "config.h"
#include
/* A whole slew of basic math functions are provided originally
Modified: branches/build_with_scons/numpy/distutils/command/config.py
===================================================================
--- branches/build_with_scons/numpy/distutils/command/config.py 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/distutils/command/config.py 2008-01-06 10:09:33 UTC (rev 4678)
@@ -101,6 +101,21 @@
(body, headers, include_dirs,
libraries, library_dirs, lang))
+ def check_decl(self, symbol,
+ headers=None, include_dirs=None):
+ self._check_compiler()
+ body = """
+int main()
+{
+#ifndef %s
+ (void) %s;
+#endif
+ ;
+ return 0;
+}""" % (symbol, symbol)
+
+ return self.try_compile(body, headers, include_dirs)
+
def check_func(self, func,
headers=None, include_dirs=None,
libraries=None, library_dirs=None,
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 09:39:33 UTC (rev 4677)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:09:33 UTC (rev 4678)
@@ -112,11 +112,11 @@
return minrelpath(joined)
def get_mathlibs(path=None):
- """Return the MATHLIB line from config.h
+ """Return the MATHLIB line from numpyconfig.h
"""
if path is None:
path = os.path.join(get_numpy_include_dirs()[0], 'numpy')
- config_file = os.path.join(path,'config.h')
+ config_file = os.path.join(path,'numpyconfig.h')
fid = open(config_file)
mathlibs = []
s = '#define MATHLIB'
From numpy-svn at scipy.org Sun Jan 6 05:31:12 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:31:12 -0600 (CST)
Subject: [Numpy-svn] r4679 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106103112.7554139C060@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:31:05 -0600 (Sun, 06 Jan 2008)
New Revision: 4679
Added:
branches/build_with_scons/numpy/distutils/numpy_distribution.py
Modified:
branches/build_with_scons/numpy/distutils/core.py
Log:
Use a custom NumpyDistribution instead of distutils Distribution, to handle
scons scripts.
Modified: branches/build_with_scons/numpy/distutils/core.py
===================================================================
--- branches/build_with_scons/numpy/distutils/core.py 2008-01-06 10:09:33 UTC (rev 4678)
+++ branches/build_with_scons/numpy/distutils/core.py 2008-01-06 10:31:05 UTC (rev 4679)
@@ -21,6 +21,7 @@
import distutils.dist
from numpy.distutils.extension import Extension
+from numpy.distutils.numpy_distribution import NumpyDistribution
from numpy.distutils.command import config, config_compiler, \
build, build_py, build_ext, build_clib, build_src, build_scripts, \
sdist, install_data, install_headers, install, bdist_rpm
@@ -95,9 +96,10 @@
# class is local to a function in setuptools.command.easy_install
if dist is not None and \
'DistributionWithoutHelpCommands' in repr(dist):
+ raise NotImplementedError("setuptools not supported yet for numpy.scons branch")
dist = None
if always and dist is None:
- dist = distutils.dist.Distribution()
+ dist = NumpyDistribution()
return dist
def _exit_interactive_session(_cache=[]):
@@ -175,6 +177,9 @@
and 'headers' not in new_attr:
new_attr['headers'] = []
+ # Use our custom NumpyDistribution class instead of distutils' one
+ new_attr['distclass'] = NumpyDistribution
+
return old_setup(**new_attr)
def _check_append_library(libraries, item):
Added: branches/build_with_scons/numpy/distutils/numpy_distribution.py
===================================================================
--- branches/build_with_scons/numpy/distutils/numpy_distribution.py 2008-01-06 10:09:33 UTC (rev 4678)
+++ branches/build_with_scons/numpy/distutils/numpy_distribution.py 2008-01-06 10:31:05 UTC (rev 4679)
@@ -0,0 +1,28 @@
+# XXX: Handle setuptools ?
+from distutils.core import Distribution
+
+# This class is used because we add new files (sconscripts, and so on) with the
+# scons command
+class NumpyDistribution(Distribution):
+ def __init__(self, attrs = None):
+ # A list of (sconscripts, pre_hook, post_hook, src, parent_names)
+ self.scons_data = []
+ Distribution.__init__(self, attrs)
+
+ def has_scons_scripts(self):
+ return bool(self.scons_data)
+
+ def get_scons_scripts(self):
+ return [i[0] for i in self.scons_data]
+
+ def get_scons_pre_hooks(self):
+ return [i[1] for i in self.scons_data]
+
+ def get_scons_post_hooks(self):
+ return [i[2] for i in self.scons_data]
+
+ def get_scons_sources(self):
+ return [i[3] for i in self.scons_data]
+
+ def get_scons_parent_names(self):
+ return [i[4] for i in self.scons_data]
From numpy-svn at scipy.org Sun Jan 6 05:32:20 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:32:20 -0600 (CST)
Subject: [Numpy-svn] r4680 - in branches/build_with_scons/numpy/distutils: .
command
Message-ID: <20080106103220.C2C1F39C060@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:32:14 -0600 (Sun, 06 Jan 2008)
New Revision: 4680
Added:
branches/build_with_scons/numpy/distutils/command/scons.py
Modified:
branches/build_with_scons/numpy/distutils/core.py
Log:
Add scons command to numpy distutils.
Added: branches/build_with_scons/numpy/distutils/command/scons.py
===================================================================
--- branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 10:31:05 UTC (rev 4679)
+++ branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 10:32:14 UTC (rev 4680)
@@ -0,0 +1,322 @@
+import os
+import os.path
+from os.path import join as pjoin, dirname as pdirname
+
+from distutils.errors import DistutilsPlatformError
+from distutils.errors import DistutilsExecError, DistutilsSetupError
+
+from numpy.distutils.command.build_ext import build_ext as old_build_ext
+from numpy.distutils.ccompiler import CCompiler
+from numpy.distutils.fcompiler import FCompiler
+from numpy.distutils.exec_command import find_executable
+from numpy.distutils import log
+from numpy.distutils.misc_util import get_numpy_include_dirs
+
+def get_scons_build_dir():
+ """Return the top path where everything produced by scons will be put.
+
+ The path is relative to the top setup.py"""
+ return os.path.join('build', 'scons')
+
+def get_scons_configres_dir():
+ """Return the top path where everything produced by scons will be put.
+
+ The path is relative to the top setup.py"""
+ return os.path.join('build', 'scons-configres')
+
+def get_scons_configres_filename():
+ """Return the top path where everything produced by scons will be put.
+
+ The path is relative to the top setup.py"""
+ return '__configres.py'
+
+def get_scons_local_path():
+ """This returns the full path where scons.py for scons-local is located."""
+ import numpy.distutils
+ return pjoin(pdirname(numpy.distutils.__file__), 'scons-local')
+
+def get_python_exec_invoc():
+ """This returns the python executable from which this file is invocated."""
+ # Do we need to take into account the PYTHONPATH, in a cross platform way,
+ # that is the string returned can be executed directly on supported
+ # platforms, and the sys.path of the executed python should be the same
+ # than the caller ? This may not be necessary, since os.system is said to
+ # take into accound os.environ. This actually also works for my way of
+ # using "local python", using the alias facility of bash.
+ import sys
+ return sys.executable
+
+def dirl_to_str(dirlist):
+ """Given a list of directories, returns a string where the paths are
+ concatenated by the path separator.
+
+ example: ['foo/bar', 'bar/foo'] will return 'foo/bar:bar/foo'."""
+ return os.pathsep.join(dirlist)
+
+def dist2sconscc(compiler):
+ """This converts the name passed to distutils to scons name convention (C
+ compiler). compiler should be a CCompiler instance.
+
+ Example:
+ --compiler=intel -> intelc"""
+ compiler_type = compiler.compiler_type
+ if compiler_type == 'msvc':
+ return 'msvc'
+ elif compiler_type == 'intel':
+ return 'intelc'
+ elif compiler_type == 'mingw32':
+ return 'mingw'
+ else:
+ return compiler.compiler[0]
+
+def dist2sconsfc(compiler):
+ """This converts the name passed to distutils to scons name convention
+ (Fortran compiler). The argument should be a FCompiler instance.
+
+ Example:
+ --fcompiler=intel -> ifort on linux, ifl on windows"""
+ if compiler.compiler_type == 'intel':
+ #raise NotImplementedError('FIXME: intel fortran compiler name ?')
+ return 'ifort'
+ elif compiler.compiler_type == 'gnu':
+ return 'g77'
+ elif compiler.compiler_type == 'gnu95':
+ return 'gfortran'
+ else:
+ # XXX: Just give up for now, and use generic fortran compiler
+ return 'fortran'
+
+def dist2sconscxx(compiler):
+ """This converts the name passed to distutils to scons name convention
+ (C++ compiler). The argument should be a Compiler instance."""
+ if compiler.compiler_type == 'gnu':
+ return 'g++'
+ else:
+ return 'c++'
+ return compiler.compiler_cxx[0]
+
+def get_compiler_executable(compiler):
+ """For any give CCompiler instance, this gives us the name of C compiler
+ (the actual executable).
+
+ NOTE: does NOT work with FCompiler instances."""
+ # Geez, why does distutils has no common way to get the compiler name...
+ if compiler.compiler_type == 'msvc':
+ # this is harcoded in distutils... A bit cleaner way would be to
+ # initialize the compiler instance and then get compiler.cc, but this
+ # may be costly: we really just want a string.
+ # XXX: we need to initialize the compiler anyway, so do not use
+ # hardcoded string
+ #compiler.initialize()
+ #print compiler.cc
+ return 'cl.exe'
+ else:
+ return compiler.compiler[0]
+
+def get_f77_compiler_executable(compiler):
+ """For any give FCompiler instance, this gives us the name of F77 compiler
+ (the actual executable)."""
+ return compiler.compiler_f77[0]
+
+def get_cxxcompiler_executable(compiler):
+ """For any give CCompiler instance, this gives us the name of CXX compiler
+ (the actual executable).
+
+ NOTE: does NOT work with FCompiler instances."""
+ # Geez, why does distutils has no common way to get the compiler name...
+ if compiler.compiler_type == 'msvc':
+ # this is harcoded in distutils... A bit cleaner way would be to
+ # initialize the compiler instance and then get compiler.cc, but this
+ # may be costly: we really just want a string.
+ # XXX: we need to initialize the compiler anyway, so do not use
+ # hardcoded string
+ #compiler.initialize()
+ #print compiler.cc
+ return 'cl.exe'
+ else:
+ return compiler.compiler_cxx[0]
+
+def get_tool_path(compiler):
+ """Given a distutils.ccompiler.CCompiler class, returns the path of the
+ toolset related to C compilation."""
+ fullpath_exec = find_executable(get_compiler_executable(compiler))
+ if fullpath_exec:
+ fullpath = pdirname(fullpath_exec)
+ else:
+ raise DistutilsSetupError("Could not find compiler executable info for scons")
+ return fullpath
+
+def get_f77_tool_path(compiler):
+ """Given a distutils.ccompiler.FCompiler class, returns the path of the
+ toolset related to F77 compilation."""
+ fullpath_exec = find_executable(get_f77_compiler_executable(compiler))
+ if fullpath_exec:
+ fullpath = pdirname(fullpath_exec)
+ else:
+ raise DistutilsSetupError("Could not find F77 compiler executable "\
+ "info for scons")
+ return fullpath
+
+def get_cxx_tool_path(compiler):
+ """Given a distutils.ccompiler.CCompiler class, returns the path of the
+ toolset related to C compilation."""
+ fullpath_exec = find_executable(get_cxxcompiler_executable(compiler))
+ if fullpath_exec:
+ fullpath = pdirname(fullpath_exec)
+ else:
+ raise DistutilsSetupError("Could not find compiler executable info for scons")
+ return fullpath
+
+def protect_path(path):
+ """Convert path (given as a string) to something the shell will have no
+ problem to understand (space, etc... problems)."""
+ # XXX: to this correctly, this is totally bogus for now (does not check for
+ # already quoted path, for example).
+ return '"' + path + '"'
+
+class scons(old_build_ext):
+ # XXX: add an option to the scons command for configuration (auto/force/cache).
+ description = "Scons builder"
+ user_options = old_build_ext.user_options + \
+ [('jobs=', None,
+ "specify number of worker threads when executing scons"),
+ ('scons-tool-path=', None, 'specify additional path '\
+ '(absolute) to look for scons tools'),
+ ('silent=', None, 'specify whether scons output should be silent '\
+ '(1), super silent (2) or not (0, default)')]
+
+ def initialize_options(self):
+ old_build_ext.initialize_options(self)
+ self.jobs = None
+ self.silent = 0
+ self.scons_tool_path = ''
+ # If true, we bypass distutils to find the c compiler altogether. This
+ # is to be used in desperate cases (like incompatible visual studio
+ # version).
+ self._bypass_distutils_cc = False
+ self.scons_compiler = None
+ self.scons_compiler_path = None
+ self.scons_fcompiler = None
+
+ def finalize_options(self):
+ old_build_ext.finalize_options(self)
+ if self.distribution.has_scons_scripts():
+ self.sconscripts = self.distribution.get_scons_scripts()
+ self.pre_hooks = self.distribution.get_scons_pre_hooks()
+ self.post_hooks = self.distribution.get_scons_post_hooks()
+ self.pkg_names = self.distribution.get_scons_parent_names()
+ else:
+ self.sconscripts = []
+ self.pre_hooks = []
+ self.post_hooks = []
+ self.pkg_names = []
+
+ # Try to get the same compiler than the ones used by distutils: this is
+ # non trivial because distutils and scons have totally different
+ # conventions on this one (distutils uses PATH from user's environment,
+ # whereas scons uses standard locations). The way we do it is once we
+ # got the c compiler used, we use numpy.distutils function to get the
+ # full path, and add the path to the env['PATH'] variable in env
+ # instance (this is done in numpy.distutils.scons module).
+
+ # XXX: The logic to bypass distutils is ... not so logic.
+ compiler_type = self.compiler
+ if compiler_type == 'msvc':
+ self._bypass_distutils_cc = True
+ from numpy.distutils.ccompiler import new_compiler
+ try:
+ distutils_compiler = new_compiler(compiler=compiler_type,
+ verbose=self.verbose,
+ dry_run=self.dry_run,
+ force=self.force)
+ distutils_compiler.customize(self.distribution)
+ # This initialization seems necessary, sometimes, for find_executable to work...
+ if hasattr(distutils_compiler, 'initialize'):
+ distutils_compiler.initialize()
+ self.scons_compiler = dist2sconscc(distutils_compiler)
+ self.scons_compiler_path = protect_path(get_tool_path(distutils_compiler))
+ except DistutilsPlatformError, e:
+ if not self._bypass_distutils_cc:
+ raise e
+ else:
+ self.scons_compiler = compiler_type
+
+ # We do the same for the fortran compiler ...
+ fcompiler_type = self.fcompiler
+ from numpy.distutils.fcompiler import new_fcompiler
+ self.fcompiler = new_fcompiler(compiler = fcompiler_type,
+ verbose = self.verbose,
+ dry_run = self.dry_run,
+ force = self.force)
+ if self.fcompiler is not None:
+ self.fcompiler.customize(self.distribution)
+
+ # And the C++ compiler
+ cxxcompiler = new_compiler(compiler = compiler_type,
+ verbose = self.verbose,
+ dry_run = self.dry_run,
+ force = self.force)
+ if cxxcompiler is not None:
+ cxxcompiler.customize(self.distribution, need_cxx = 1)
+ cxxcompiler.customize_cmd(self)
+ self.cxxcompiler = cxxcompiler.cxx_compiler()
+ #print self.cxxcompiler.compiler_cxx[0]
+
+ def run(self):
+ # XXX: when a scons script is missing, scons only prints warnings, and
+ # does not return a failure (status is 0). We have to detect this from
+ # distutils (this cannot work for recursive scons builds...)
+
+ # XXX: passing everything at command line may cause some trouble where
+ # there is a size limitation ? What is the standard solution in thise
+ # case ?
+
+ scons_exec = get_python_exec_invoc()
+ scons_exec += ' ' + protect_path(pjoin(get_scons_local_path(), 'scons.py'))
+
+ for sconscript, pre_hook, post_hook, pkg_name in zip(self.sconscripts,
+ self.pre_hooks, self.post_hooks,
+ self.pkg_names):
+ if pre_hook:
+ pre_hook()
+
+ cmd = [scons_exec, "-f", sconscript, '-I.']
+ if self.jobs:
+ cmd.append(" --jobs=%d" % int(self.jobs))
+ cmd.append('scons_tool_path="%s"' % self.scons_tool_path)
+ cmd.append('src_dir="%s"' % pdirname(sconscript))
+ cmd.append('pkg_name="%s"' % pkg_name)
+ #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib,
+ # pdirname(sconscript))))
+ cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib)))
+
+ if not self._bypass_distutils_cc:
+ cmd.append('cc_opt=%s' % self.scons_compiler)
+ cmd.append('cc_opt_path=%s' % self.scons_compiler_path)
+ else:
+ cmd.append('cc_opt=%s' % self.scons_compiler)
+
+
+ if self.fcompiler:
+ cmd.append('f77_opt=%s' % dist2sconsfc(self.fcompiler))
+ cmd.append('f77_opt_path=%s' % protect_path(get_f77_tool_path(self.fcompiler)))
+
+ if self.cxxcompiler:
+ cmd.append('cxx_opt=%s' % dist2sconscxx(self.cxxcompiler))
+ cmd.append('cxx_opt_path=%s' % protect_path(get_cxx_tool_path(self.cxxcompiler)))
+
+ cmd.append('include_bootstrap=%s' % dirl_to_str(get_numpy_include_dirs()))
+ if self.silent:
+ if int(self.silent) == 1:
+ cmd.append('-Q')
+ elif int(self.silent) == 2:
+ cmd.append('-s')
+ cmdstr = ' '.join(cmd)
+ log.info("Executing scons command: %s ", cmdstr)
+ st = os.system(cmdstr)
+ if st:
+ print "status is %d" % st
+ raise DistutilsExecError("Error while executing scons command "\
+ "%s (see above)" % cmdstr)
+ if post_hook:
+ post_hook()
Modified: branches/build_with_scons/numpy/distutils/core.py
===================================================================
--- branches/build_with_scons/numpy/distutils/core.py 2008-01-06 10:31:05 UTC (rev 4679)
+++ branches/build_with_scons/numpy/distutils/core.py 2008-01-06 10:32:14 UTC (rev 4680)
@@ -24,7 +24,7 @@
from numpy.distutils.numpy_distribution import NumpyDistribution
from numpy.distutils.command import config, config_compiler, \
build, build_py, build_ext, build_clib, build_src, build_scripts, \
- sdist, install_data, install_headers, install, bdist_rpm
+ sdist, install_data, install_headers, install, bdist_rpm, scons
from numpy.distutils.misc_util import get_data_files, is_sequence, is_string
numpy_cmdclass = {'build': build.build,
@@ -37,6 +37,7 @@
'build_py': build_py.build_py,
'build_clib': build_clib.build_clib,
'sdist': sdist.sdist,
+ 'scons': scons.scons,
'install_data': install_data.install_data,
'install_headers': install_headers.install_headers,
'install': install.install,
From numpy-svn at scipy.org Sun Jan 6 05:33:04 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:33:04 -0600 (CST)
Subject: [Numpy-svn] r4681 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106103304.30F1239C060@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:33:00 -0600 (Sun, 06 Jan 2008)
New Revision: 4681
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Add the infrastructure to add SConstruct files in
numpy.distutils.Configuration.
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:32:14 UTC (rev 4680)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:33:00 UTC (rev 4681)
@@ -574,7 +574,7 @@
class Configuration(object):
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
- 'libraries', 'headers', 'scripts', 'py_modules']
+ 'libraries', 'headers', 'scripts', 'py_modules', 'scons_data']
_dict_keys = ['package_dir']
_extra_keys = ['name', 'version']
@@ -1165,6 +1165,50 @@
self.warn('distutils distribution has been initialized,'\
' it may be too late to add a library '+ name)
+ def add_sconscript(self, sconscript, subpackage_path=None,
+ standalone = False, pre_hook = None,
+ post_hook = None, source_files = None):
+ """Add a sconscript to configuration.
+
+ pre_hook and post hook should be sequences of callable, which will be
+ use before and after executing scons. """
+ if standalone:
+ parent_name = None
+ else:
+ parent_name = self.name
+
+ dist = self.get_distribution()
+ # Convert the sconscript name to a relative filename (relative from top
+ # setup.py's directory)
+ fullsconsname = self.paths(sconscript)[0]
+
+ # XXX: Think about a way to automatically register source files from
+ # scons...
+ full_source_files = []
+ if source_files:
+ full_source_files.extend([self.paths(i)[0] for i in source_files])
+
+ if dist is not None:
+ dist.scons_data.append((fullsconsname,
+ pre_hook,
+ post_hook,
+ full_source_files,
+ parent_name))
+ self.warn('distutils distribution has been initialized,'\
+ ' it may be too late to add a subpackage '+ subpackage_name)
+ # XXX: we add a fake extension, to correctly initialize some
+ # options in distutils command.
+ dist.add_extension('', sources = [])
+ else:
+ self.scons_data.append((fullsconsname,
+ pre_hook,
+ post_hook,
+ full_source_files,
+ parent_name))
+ # XXX: we add a fake extension, to correctly initialize some
+ # options in distutils command.
+ self.add_extension('', sources = [])
+
def add_scripts(self,*files):
"""Add scripts to configuration.
"""
From numpy-svn at scipy.org Sun Jan 6 05:34:44 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:34:44 -0600 (CST)
Subject: [Numpy-svn] r4682 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106103444.99E9C39C00C@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:34:40 -0600 (Sun, 06 Jan 2008)
New Revision: 4682
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
add an option to change setup filenames to numpy.distutils.Configuration
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:33:00 UTC (rev 4681)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:34:40 UTC (rev 4682)
@@ -586,6 +586,7 @@
top_path=None,
package_path=None,
caller_level=1,
+ setup_name='setup.py',
**attrs):
"""Construct configuration instance of a package.
@@ -674,6 +675,8 @@
if caller_instance.options['delegate_options_to_subpackages']:
self.set_options(**caller_instance.options)
+ self.setup_name = setup_name
+
def todict(self):
"""Return configuration distionary suitable for passing
to distutils.core.setup() function.
@@ -795,7 +798,7 @@
else:
subpackage_path = njoin([subpackage_path] + l[:-1])
subpackage_path = self.paths([subpackage_path])[0]
- setup_py = njoin(subpackage_path, 'setup.py')
+ setup_py = njoin(subpackage_path, self.setup_name)
if not self.options['ignore_setup_xxx_py']:
if not os.path.isfile(setup_py):
setup_py = njoin(subpackage_path,
From numpy-svn at scipy.org Sun Jan 6 05:35:48 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:35:48 -0600 (CST)
Subject: [Numpy-svn] r4683 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106103548.4218F39C00C@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:35:44 -0600 (Sun, 06 Jan 2008)
New Revision: 4683
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Add facilities to generate config file for future sconsified modules.
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:34:40 UTC (rev 4682)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:35:44 UTC (rev 4683)
@@ -1472,6 +1472,51 @@
# else running numpy/core/setup.py
return include_dirs
+def scons_generate_config_py(target):
+ """generate config.py file containing system_info information
+ used during building the package.
+
+ usage:
+ config['py_modules'].append((packagename, '__config__',generate_config_py))
+ """
+ from distutils.dir_util import mkpath
+ import imp
+ d = {}
+ mkpath(os.path.dirname(target))
+ f = open(target, 'w')
+ f.write('# this file is generated by %s\n' % (os.path.abspath(sys.argv[0])))
+ f.write('# it contains system_info results at the time of building this package.\n')
+ f.write('__all__ = ["show"]\n\n')
+ confdir = get_scons_configres_dir()
+ confilename = get_scons_configres_filename()
+ for root, dirs, files in os.walk(confdir):
+ if files:
+ file = os.path.join(root, confilename)
+ assert root.startswith(confdir)
+ pkg_name = '.'.join(root[len(confdir)+1:].split(os.sep))
+ fid = open(file, 'r')
+ try:
+ config_mod = imp.load_module(pkg_name, fid, confilename,
+ ('.py', 'U', 1))
+ d[pkg_name] = config_mod.config
+ finally:
+ fid.close()
+ # d is a dictionary whose keys are package names, and values the
+ # corresponding configuration. Each configuration is itself a dictionary
+ # (lib : libinfo)
+ f.write('_config = %s\n' % d)
+ f.write(r'''
+def show():
+ for pkg, config in _config.items():
+ print "package %s configuration:" % pkg
+ for lib, libc in config.items():
+ print ' %s' % lib
+ for line in libc.split('\n'):
+ print '\t%s' % line
+ ''')
+ f.close()
+ return target
+
#########################
def default_config_dict(name = None, parent_name = None, local_path=None):
From numpy-svn at scipy.org Sun Jan 6 05:42:29 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:42:29 -0600 (CST)
Subject: [Numpy-svn] r4684 -
branches/build_with_scons/numpy/distutils/command
Message-ID: <20080106104229.C95C639C035@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:42:26 -0600 (Sun, 06 Jan 2008)
New Revision: 4684
Modified:
branches/build_with_scons/numpy/distutils/command/scons.py
Log:
Use separate numscons package instead of internal local copy
Modified: branches/build_with_scons/numpy/distutils/command/scons.py
===================================================================
--- branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 10:35:44 UTC (rev 4683)
+++ branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 10:42:26 UTC (rev 4684)
@@ -32,8 +32,8 @@
def get_scons_local_path():
"""This returns the full path where scons.py for scons-local is located."""
- import numpy.distutils
- return pjoin(pdirname(numpy.distutils.__file__), 'scons-local')
+ from numscons import get_scons_path
+ return get_scons_path()
def get_python_exec_invoc():
"""This returns the python executable from which this file is invocated."""
@@ -263,6 +263,13 @@
#print self.cxxcompiler.compiler_cxx[0]
def run(self):
+ if len(self.sconscripts) > 0:
+ try:
+ import numscons
+ except ImportError, e:
+ raise RuntimeError("importing numscons failed (error was %s), using " \
+ "scons within distutils is not possible without "
+ "this package " % str(e))
# XXX: when a scons script is missing, scons only prints warnings, and
# does not return a failure (status is 0). We have to detect this from
# distutils (this cannot work for recursive scons builds...)
From numpy-svn at scipy.org Sun Jan 6 05:43:08 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:43:08 -0600 (CST)
Subject: [Numpy-svn] r4685 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106104308.E8B0239C035@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:43:05 -0600 (Sun, 06 Jan 2008)
New Revision: 4685
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Add scons_make_config function to numpy distutils Configuration.
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:42:26 UTC (rev 4684)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 10:43:05 UTC (rev 4685)
@@ -1441,6 +1441,12 @@
"""
self.py_modules.append((self.name,name,generate_config_py))
+ def scons_make_config_py(self, name = '__config__'):
+ """Generate package __config__.py file containing system_info
+ information used during building the package.
+ """
+ self.py_modules.append((self.name, name, scons_generate_config_py))
+
def get_info(self,*names):
"""Get resources information.
"""
From numpy-svn at scipy.org Sun Jan 6 05:49:29 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 04:49:29 -0600 (CST)
Subject: [Numpy-svn] r4686 - in branches/build_with_scons: . numpy
Message-ID: <20080106104929.8AC8B39C109@new.scipy.org>
Author: cdavid
Date: 2008-01-06 04:49:23 -0600 (Sun, 06 Jan 2008)
New Revision: 4686
Added:
branches/build_with_scons/numpy/setupscons.py
branches/build_with_scons/setupscons.py
Log:
Add root setupscons.py files, to start working on building numpy with numscons.
Added: branches/build_with_scons/numpy/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/setupscons.py 2008-01-06 10:43:05 UTC (rev 4685)
+++ branches/build_with_scons/numpy/setupscons.py 2008-01-06 10:49:23 UTC (rev 4686)
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ config = Configuration('numpy',parent_package,top_path, setup_name = 'setupscons.py')
+ config.add_subpackage('distutils')
+ config.add_subpackage('testing')
+ config.add_subpackage('f2py')
+ config.add_subpackage('core')
+ config.add_subpackage('lib')
+ config.add_subpackage('oldnumeric')
+ config.add_subpackage('numarray')
+ config.add_subpackage('fft')
+ config.add_subpackage('linalg')
+ config.add_subpackage('random')
+ config.add_data_dir('doc')
+ config.add_data_dir('tests')
+ config.scons_make_config_py() # installs __config__.py
+ return config
+
+if __name__ == '__main__':
+ print 'This is the wrong setup.py file to run'
Added: branches/build_with_scons/setupscons.py
===================================================================
--- branches/build_with_scons/setupscons.py 2008-01-06 10:43:05 UTC (rev 4685)
+++ branches/build_with_scons/setupscons.py 2008-01-06 10:49:23 UTC (rev 4686)
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+"""NumPy: array processing for numbers, strings, records, and objects.
+
+NumPy is a general-purpose array-processing package designed to
+efficiently manipulate large multi-dimensional arrays of arbitrary
+records without sacrificing too much speed for small multi-dimensional
+arrays. NumPy is built on the Numeric code base and adds features
+introduced by numarray as well as an extended C-API and the ability to
+create arrays of arbitrary type which also makes NumPy suitable for
+interfacing with general-purpose data-base applications.
+
+There are also basic facilities for discrete fourier transform,
+basic linear algebra and random number generation.
+"""
+
+DOCLINES = __doc__.split("\n")
+
+import __builtin__
+import os
+import sys
+
+CLASSIFIERS = """\
+Development Status :: 4 - Beta
+Intended Audience :: Science/Research
+Intended Audience :: Developers
+License :: OSI Approved
+Programming Language :: C
+Programming Language :: Python
+Topic :: Software Development
+Topic :: Scientific/Engineering
+Operating System :: Microsoft :: Windows
+Operating System :: POSIX
+Operating System :: Unix
+Operating System :: MacOS
+"""
+
+# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
+# update it when the contents of directories change.
+if os.path.exists('MANIFEST'): os.remove('MANIFEST')
+
+# This is a bit hackish: we are setting a global variable so that the main
+# numpy __init__ can detect if it is being loaded by the setup routine, to
+# avoid attempting to load components that aren't built yet. While ugly, it's
+# a lot more robust than what was previously being used.
+__builtin__.__NUMPY_SETUP__ = True
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+
+ config = Configuration(None, parent_package, top_path, setup_name = 'setupscons.py')
+ config.set_options(ignore_setup_xxx_py=True,
+ assume_default_configuration=True,
+ delegate_options_to_subpackages=True,
+ quiet=True)
+
+ config.add_subpackage('numpy')
+
+ config.add_data_files(('numpy','*.txt'),
+ ('numpy','COMPATIBILITY'),
+ ('numpy','site.cfg.example'),
+ ('numpy','setup.py'))
+
+ config.get_version('numpy/version.py') # sets config.version
+
+ return config
+
+def setup_package():
+
+ from numpy.distutils.core import setup
+
+ old_path = os.getcwd()
+ local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
+ os.chdir(local_path)
+ sys.path.insert(0,local_path)
+
+ try:
+ setup(
+ name = 'numpy',
+ maintainer = "NumPy Developers",
+ maintainer_email = "numpy-discussion at lists.sourceforge.net",
+ description = DOCLINES[0],
+ long_description = "\n".join(DOCLINES[2:]),
+ url = "http://numeric.scipy.org",
+ download_url = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103",
+ license = 'BSD',
+ classifiers=filter(None, CLASSIFIERS.split('\n')),
+ author = "Travis E. Oliphant, et.al.",
+ author_email = "oliphant at ee.byu.edu",
+ platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
+ configuration=configuration )
+ finally:
+ del sys.path[0]
+ os.chdir(old_path)
+ return
+
+if __name__ == '__main__':
+ setup_package()
Property changes on: branches/build_with_scons/setupscons.py
___________________________________________________________________
Name: svn:executable
+ *
From numpy-svn at scipy.org Sun Jan 6 07:11:54 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 06:11:54 -0600 (CST)
Subject: [Numpy-svn] r4687 -
branches/build_with_scons/numpy/distutils/command
Message-ID: <20080106121154.5F17339C012@new.scipy.org>
Author: cdavid
Date: 2008-01-06 06:11:48 -0600 (Sun, 06 Jan 2008)
New Revision: 4687
Modified:
branches/build_with_scons/numpy/distutils/command/scons.py
Log:
Define various scons related functions to call numscons instead of being
defined directly in numpy, for bootstrapping issues.
Modified: branches/build_with_scons/numpy/distutils/command/scons.py
===================================================================
--- branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 10:49:23 UTC (rev 4686)
+++ branches/build_with_scons/numpy/distutils/command/scons.py 2008-01-06 12:11:48 UTC (rev 4687)
@@ -16,19 +16,22 @@
"""Return the top path where everything produced by scons will be put.
The path is relative to the top setup.py"""
- return os.path.join('build', 'scons')
+ from numscons import get_scons_build_dir
+ return get_scons_build_dir()
def get_scons_configres_dir():
"""Return the top path where everything produced by scons will be put.
The path is relative to the top setup.py"""
- return os.path.join('build', 'scons-configres')
+ from numscons import get_scons_configres_dir
+ return get_scons_configres_dir()
def get_scons_configres_filename():
"""Return the top path where everything produced by scons will be put.
The path is relative to the top setup.py"""
- return '__configres.py'
+ from numscons import get_scons_configres_filename
+ return get_scons_configres_filename()
def get_scons_local_path():
"""This returns the full path where scons.py for scons-local is located."""
From numpy-svn at scipy.org Sun Jan 6 07:18:17 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 06:18:17 -0600 (CST)
Subject: [Numpy-svn] r4688 -
branches/build_with_scons/numpy/core/code_generators
Message-ID: <20080106121817.2C63C39C00C@new.scipy.org>
Author: cdavid
Date: 2008-01-06 06:18:13 -0600 (Sun, 06 Jan 2008)
New Revision: 4688
Modified:
branches/build_with_scons/numpy/core/code_generators/generate_array_api.py
Log:
Modify array api generator to be compatible with scons builder
Modified: branches/build_with_scons/numpy/core/code_generators/generate_array_api.py
===================================================================
--- branches/build_with_scons/numpy/core/code_generators/generate_array_api.py 2008-01-06 12:11:48 UTC (rev 4687)
+++ branches/build_with_scons/numpy/core/code_generators/generate_array_api.py 2008-01-06 12:18:13 UTC (rev 4688)
@@ -1,9 +1,6 @@
import os
import genapi
-OBJECT_API_ORDER = 'array_api_order.txt'
-MULTIARRAY_API_ORDER = 'multiarray_api_order.txt'
-
types = ['Generic','Number','Integer','SignedInteger','UnsignedInteger',
'Inexact',
'Floating', 'ComplexFloating', 'Flexible', 'Character',
@@ -122,22 +119,30 @@
"""
def generate_api(output_dir, force=False):
- header_file = os.path.join(output_dir, '__multiarray_api.h')
- c_file = os.path.join(output_dir,'__multiarray_api.c')
- doc_file = os.path.join(output_dir, 'multiarray_api.txt')
+ basename = 'multiarray_api'
- targets = (header_file, c_file, doc_file)
- if (not force
- and not genapi.should_rebuild(targets,
- [OBJECT_API_ORDER,
- MULTIARRAY_API_ORDER,
- __file__])):
+ h_file = os.path.join(output_dir, '__%s.h' % basename)
+ c_file = os.path.join(output_dir, '__%s.c' % basename)
+ d_file = os.path.join(output_dir, '%s.txt' % basename)
+ targets = (h_file, c_file, d_file)
+ sources = ['array_api_order.txt', 'multiarray_api_order.txt']
+
+ if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
return targets
+ else:
+ do_generate_api(targets, sources)
+ return targets
+
+def do_generate_api(targets, sources):
+ header_file = targets[0]
+ c_file = targets[1]
+ doc_file = targets[2]
+
objectapi_list = genapi.get_api_functions('OBJECT_API',
- OBJECT_API_ORDER)
+ sources[0])
multiapi_list = genapi.get_api_functions('MULTIARRAY_API',
- MULTIARRAY_API_ORDER)
+ sources[1])
# API fixes for __arrayobject_api.h
fixed = 10
From numpy-svn at scipy.org Sun Jan 6 07:19:42 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 06:19:42 -0600 (CST)
Subject: [Numpy-svn] r4689 -
branches/build_with_scons/numpy/core/code_generators
Message-ID: <20080106121942.B728939C00C@new.scipy.org>
Author: cdavid
Date: 2008-01-06 06:19:35 -0600 (Sun, 06 Jan 2008)
New Revision: 4689
Modified:
branches/build_with_scons/numpy/core/code_generators/generate_ufunc_api.py
Log:
Modify ufunc api generator to be compatible with scons builder
Modified: branches/build_with_scons/numpy/core/code_generators/generate_ufunc_api.py
===================================================================
--- branches/build_with_scons/numpy/core/code_generators/generate_ufunc_api.py 2008-01-06 12:18:13 UTC (rev 4688)
+++ branches/build_with_scons/numpy/core/code_generators/generate_ufunc_api.py 2008-01-06 12:19:35 UTC (rev 4689)
@@ -1,8 +1,6 @@
import os
import genapi
-UFUNC_API_ORDER = 'ufunc_api_order.txt'
-
h_template = r"""
#ifdef _UMATHMODULE
@@ -72,18 +70,29 @@
"""
def generate_api(output_dir, force=False):
- header_file = os.path.join(output_dir, '__ufunc_api.h')
- c_file = os.path.join(output_dir, '__ufunc_api.c')
- doc_file = os.path.join(output_dir, 'ufunc_api.txt')
+ basename = 'ufunc_api'
+
+ h_file = os.path.join(output_dir, '__%s.h' % basename)
+ c_file = os.path.join(output_dir, '__%s.c' % basename)
+ d_file = os.path.join(output_dir, '%s.txt' % basename)
+ targets = (h_file, c_file, d_file)
- targets = (header_file, c_file, doc_file)
- if (not force
- and not genapi.should_rebuild(targets,
- [UFUNC_API_ORDER, __file__])):
+ sources = ['ufunc_api_order.txt']
+
+ if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
return targets
+ else:
+ do_generate_api(targets, sources)
- ufunc_api_list = genapi.get_api_functions('UFUNC_API', UFUNC_API_ORDER)
+ return targets
+def do_generate_api(targets, sources):
+ header_file = targets[0]
+ c_file = targets[1]
+ doc_file = targets[2]
+
+ ufunc_api_list = genapi.get_api_functions('UFUNC_API', sources[0])
+
# API fixes for __arrayobject_api.h
fixed = 1
From numpy-svn at scipy.org Sun Jan 6 09:08:25 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 08:08:25 -0600 (CST)
Subject: [Numpy-svn] r4690 -
branches/build_with_scons/numpy/core/code_generators
Message-ID: <20080106140825.F2D4439C072@new.scipy.org>
Author: cdavid
Date: 2008-01-06 08:08:19 -0600 (Sun, 06 Jan 2008)
New Revision: 4690
Added:
branches/build_with_scons/numpy/core/code_generators/__init__.py
Log:
Make code_generators a package to import its functions
Added: branches/build_with_scons/numpy/core/code_generators/__init__.py
===================================================================
From numpy-svn at scipy.org Sun Jan 6 09:09:08 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 08:09:08 -0600 (CST)
Subject: [Numpy-svn] r4691 - branches/build_with_scons/numpy/core
Message-ID: <20080106140908.11B0B39C072@new.scipy.org>
Author: cdavid
Date: 2008-01-06 08:09:03 -0600 (Sun, 06 Jan 2008)
New Revision: 4691
Added:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/scons_support.py
branches/build_with_scons/numpy/core/setupscons.py
Log:
Adding scons scripts + support for numpy.core (do not work yet)
Added: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-06 14:08:19 UTC (rev 4690)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-06 14:09:03 UTC (rev 4691)
@@ -0,0 +1,272 @@
+# Last Change: Sun Jan 06 07:00 PM 2008 J
+# vim:syntax=python
+import os
+import sys
+from os.path import join as pjoin, basename as pbasename, dirname as pdirname
+from copy import deepcopy
+
+from numscons import get_python_inc, get_pythonlib_dir
+from numscons import GetNumpyEnvironment
+from numscons import CheckCBLAS
+from numscons.configuration import write_info
+
+from scons_support import CheckBrokenMathlib, define_no_smp, \
+ generate_config_header, generate_config_header_emitter
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = [get_python_inc()])
+if os.name == 'nt':
+ # NT needs the pythonlib to run any code importing Python.h, including
+ # simple code using only typedef and so on, so we need it for configuration
+ # checks
+ env.AppendUnique(LIBPATH = [get_pythonlib_dir()])
+
+#=======================
+# Starting Configuration
+#=======================
+# XXX: separate env for configuration
+config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib,
+ 'CheckCBLAS' : CheckCBLAS})
+
+# Convention: list of tuples (definition, value). value:
+# - 0: #undef definition
+# - 1: #define definition
+# - string: #define definition value
+config_sym = []
+
+#---------------
+# Checking Types
+#---------------
+def check_type(type, include = None):
+ st = config.CheckTypeSize(type, includes = include)
+ type = type.replace(' ', '_')
+ if st:
+ config_sym.append(('SIZEOF_%s' % type.upper(), '%d' % st))
+ else:
+ config_sym.append(('SIZEOF_%s' % type.upper(), 0))
+
+check_type('short')
+check_type('int')
+check_type('long')
+check_type('float')
+check_type('double')
+check_type('long double')
+check_type('Py_intptr_t', include = "#include \n")
+check_type('PY_LONG_LONG', include = "#include \n")
+
+# TODO: check python extension can be built (in root or here ?)
+
+#-----------------------
+# Checking configuration
+#-----------------------
+
+#----------------------
+# Checking signal stuff
+#----------------------
+# TODO
+
+#------------------------------------------
+# Checking the mathlib and its capabilities
+#------------------------------------------
+# Function to check:
+mfuncs = [('expl', 'HAVE_LONGDOUBLE_FUNCS'),
+ ('expf', 'HAVE_FLOAT_FUNCS'),
+ ('log1p', 'HAVE_LOG1P'),
+ ('expm1', 'HAVE_EXPM1'),
+ ('asinh', 'HAVE_INVERSE_HYPERBOLIC'),
+ ('atanhf', 'HAVE_INVERSE_HYPERBOLIC_FLOAT'),
+ ('atanhl', 'HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE'),
+ ('isnan', 'HAVE_ISNAN'),
+ ('isinf', 'HAVE_ISINF'),
+ ('rint', 'HAVE_RINT'),
+ ]
+
+# TODO: checklib vs checkfunc ?
+mlibs = [[], ['m'], ['cpml']]
+mathlib = os.environ.get('MATHLIB')
+if mathlib:
+ mlibs.insert(0, mathlib)
+for mlib in mlibs:
+ st = config.CheckBrokenMathlib(mlib)
+ if st:
+ break
+
+if not st:
+ import SCons
+ raise SCons.Errors.UserError("No usable mathlib was found: chose another "\
+ "one using the MATHLIB env variable, eg "\
+ "'MATHLIB=m python setup.py build'")
+# XXX: this is ugly: mathlib has nothing to do in a public header file
+config_sym.append(('MATHLIB', ','.join(mlib)))
+
+def check_lib(f, autoadd = 0):
+ """Check that f is available in mlib, and add the symbol appropriately.
+
+ f is expected to be a tuble (symbol, cpp define)."""
+ st = config.CheckLibWithHeader(mlib, 'math.h', language = 'C', call = '%s;' % f[0], autoadd = autoadd)
+ if st:
+ config_sym.append((f[1], 1))
+ else:
+ config_sym.append((f[1], 0))
+
+check_lib(mfuncs[0], autoadd = 1)
+for f in mfuncs[1:]:
+ check_lib(f)
+
+#-------------------------------------------------------
+# Define the function PyOS_ascii_strod if not available
+#-------------------------------------------------------
+# XXX: would be better to check for PyOS_ascii_strod instead of version
+if sys.version[:3] < '2.4':
+ if config.CheckFunc('strtod'):
+ config_sym.append(('PyOS_ascii_strtod', 'strtod'))
+
+if define_no_smp():
+ config_sym.append(('NPY_NOSMP', '1'))
+else:
+ config_sym.append(('NPY_NOSMP', '0'))
+
+# XXX: this is ugly
+if sys.platform=='win32' or os.name=='nt':
+ from distutils.msvccompiler import get_build_architecture
+ a = get_build_architecture()
+ print 'BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % (a, os.name, sys.platform)
+ if a == 'AMD64':
+ moredefs.append(('DISTUTILS_USE_SDK', 1))
+
+#--------------
+# Checking Blas
+#--------------
+if config.CheckCBLAS():
+ build_blasdot = 1
+else:
+ build_blasdot = 0
+
+config.Finish()
+write_info(env)
+
+#==========
+# Build
+#==========
+
+#---------------------------------------
+# Generate the public configuration file
+#---------------------------------------
+config_dict = {}
+# XXX: this is ugly, make the API for config.h and numpyconfig.h similar
+for key, value in config_sym:
+ config_dict['@%s@' % key] = str(value)
+env['SUBST_DICT'] = config_dict
+
+include_dir = 'include/numpy'
+env.SubstInFile(pjoin(env['build_dir'], 'numpyconfig.h'),
+ pjoin(env['src_dir'], include_dir, 'numpyconfig.h.in'))
+
+env['CONFIG_H_GEN'] = config_sym
+
+#---------------------------
+# Builder for generated code
+#---------------------------
+from scons_support import do_generate_array_api, do_generate_ufunc_api, \
+ generate_api_emitter,\
+ generate_from_template, generate_from_template_emitter, \
+ generate_umath, generate_umath_emitter
+
+array_api_gen_bld = Builder(action = do_generate_array_api,
+ emitter = generate_api_emitter)
+
+ufunc_api_gen_bld = Builder(action = do_generate_ufunc_api,
+ emitter = generate_api_emitter)
+
+template_bld = Builder(action = generate_from_template,
+ emitter = generate_from_template_emitter)
+
+umath_bld = Builder(action = generate_umath,
+ emitter = generate_umath_emitter)
+
+config_h_bld = Builder(action = generate_config_header,
+ emitter = generate_config_header_emitter)
+
+env.Append(BUILDERS = {'GenerateMultiarrayApi' : array_api_gen_bld,
+ 'GenerateUfuncApi' : ufunc_api_gen_bld,
+ 'GenerateFromTemplate' : template_bld,
+ 'GenerateUmath' : umath_bld,
+ 'GenerateConfigHeader' : config_h_bld})
+
+#------------------------
+# Generate generated code
+#------------------------
+# XXX: the use of env['build_dir'] and env['src_dir'] are really ugly. Will
+# have to think about how removing them (using hierarchical scons and dir
+# option ?)
+from os.path import join as pjoin
+
+config_header = env.GenerateConfigHeader(pjoin(env['build_dir'], 'config.h'), [])
+
+scalartypes_src = env.GenerateFromTemplate(
+ pjoin(env['build_dir'], 'src', 'scalartypes'),
+ pjoin(env['src_dir'], 'src', 'scalartypes.inc.src'))
+
+arraytypes_src = env.GenerateFromTemplate(
+ pjoin(env['build_dir'], 'src', 'arraytypes'),
+ pjoin(env['src_dir'], 'src', 'arraytypes.inc.src'))
+
+sortmodule_src = env.GenerateFromTemplate(
+ pjoin(env['build_dir'], 'src', '_sortmodule'),
+ pjoin(env['src_dir'], 'src', '_sortmodule.c.src'))
+
+umathmodule_src = env.GenerateFromTemplate(
+ pjoin(env['build_dir'], 'src', 'umathmodule'),
+ pjoin(env['src_dir'], 'src', 'umathmodule.c.src'))
+
+scalarmathmodule_src = env.GenerateFromTemplate(
+ pjoin(env['build_dir'], 'src', 'scalarmathmodule'),
+ pjoin(env['src_dir'], 'src', 'scalarmathmodule.c.src'))
+
+umath = env.GenerateUmath(
+ pjoin(env['build_dir'], '__umath_generated'),
+ pjoin(env['src_dir'], 'code_generators', 'generate_umath.py'))
+
+multiarray_api = env.GenerateMultiarrayApi(
+ pjoin(env['build_dir'], 'multiarray_api'),
+ [ pjoin(env['src_dir'], 'code_generators',
+ 'array_api_order.txt'),
+ pjoin(env['src_dir'], 'code_generators',
+ 'multiarray_api_order.txt')])
+
+ufunc_api = env.GenerateUfuncApi(
+ pjoin(env['build_dir'], 'ufunc_api'),
+ pjoin(env['src_dir'], 'code_generators', 'ufunc_api_order.txt'))
+
+env.Append(CPPPATH = [pjoin(env['src_dir'], 'include'), env['build_dir']])
+
+#-----------------
+# Build multiarray
+#-----------------
+multiarray_src = [pjoin('src', 'multiarraymodule.c')]
+multiarray = env.NumpyPythonExtension('multiarray', source = multiarray_src)
+
+#------------------
+# Build sort module
+#------------------
+sort = env.NumpyPythonExtension('_sort', source = sortmodule_src)
+
+#-------------------
+# Build umath module
+#-------------------
+umathmodule = env.NumpyPythonExtension('umath', source = umathmodule_src)
+
+#------------------------
+# Build scalarmath module
+#------------------------
+scalarmathmodule = env.NumpyPythonExtension('scalarmath',
+ source = scalarmathmodule_src)
+
+#----------------------
+# Build _dotblas module
+#----------------------
+if build_blasdot:
+ dotblas_src = [pjoin('blasdot', i) for i in ['_dotblas.c']]
+ blasenv = env.Copy()
+ blasenv.Append(CPPPATH = pjoin(env['src_dir'], 'blasdot'))
+ dotblas = blasenv.NumpyPythonExtension('_dotblas', source = dotblas_src)
Added: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py 2008-01-06 14:08:19 UTC (rev 4690)
+++ branches/build_with_scons/numpy/core/scons_support.py 2008-01-06 14:09:03 UTC (rev 4691)
@@ -0,0 +1,189 @@
+#! Last Change: Sun Jan 06 09:00 PM 2008 J
+
+__docstring__ = """Code to support special facilities to scons which are only
+useful for numpy.core, hence not put into numpy.distutils.scons"""
+
+import sys
+import os
+
+from os.path import join as pjoin, dirname as pdirname, basename as pbasename
+from copy import deepcopy
+
+from code_generators.generate_array_api import \
+ do_generate_api as nowrap_do_generate_array_api
+from code_generators.generate_ufunc_api import \
+ do_generate_api as nowrap_do_generate_ufunc_api
+
+from numscons.numdist import process_c_str as process_str
+from numscons.core.utils import rsplit, isstring
+
+import SCons.Node
+
+def split_ext(string):
+ sp = rsplit(string, '.', 1)
+ if len(sp) == 1:
+ return (sp[0], '')
+ else:
+ return sp
+#------------------------------------
+# Ufunc and multiarray API generators
+#------------------------------------
+def do_generate_array_api(target, source, env):
+ nowrap_do_generate_array_api([str(i) for i in target],
+ [str(i) for i in source])
+ return 0
+
+def do_generate_ufunc_api(target, source, env):
+ nowrap_do_generate_ufunc_api([str(i) for i in target],
+ [str(i) for i in source])
+ return 0
+
+def generate_api_emitter(target, source, env):
+ """Returns the list of targets generated by the code generator for array
+ api and ufunc api."""
+ base, ext = split_ext(str(target[0]))
+ dir = pdirname(base)
+ ba = pbasename(base)
+ h = pjoin(dir, '__' + ba + '.h')
+ c = pjoin(dir, '__' + ba + '.c')
+ txt = base + '.txt'
+ #print h, c, txt
+ t = [h, c, txt]
+ return (t, source)
+
+#-------------------------
+# From template generators
+#-------------------------
+# XXX: this is general and can be used outside numpy.core.
+def do_generate_from_template(targetfile, sourcefile, env):
+ t = open(targetfile, 'w')
+ s = open(sourcefile, 'r')
+ allstr = s.read()
+ s.close()
+ writestr = process_str(allstr)
+ t.write(writestr)
+ t.close()
+ return 0
+
+def generate_from_template(target, source, env):
+ for t, s in zip(target, source):
+ do_generate_from_template(str(t), str(s), env)
+
+def generate_from_template_emitter(target, source, env):
+ base, ext = split_ext(pbasename(str(source[0])))
+ t = pjoin(pdirname(str(target[0])), base)
+ return ([t], source)
+
+#----------------
+# umath generator
+#----------------
+def do_generate_umath(targetfile, sourcefile, env):
+ t = open(targetfile, 'w')
+ from code_generators import generate_umath
+ code = generate_umath.make_code(generate_umath.defdict, generate_umath.__file__)
+ t.write(code)
+ t.close()
+
+def generate_umath(target, source, env):
+ for t, s in zip(target, source):
+ do_generate_umath(str(t), str(s), env)
+
+def generate_umath_emitter(target, source, env):
+ t = str(target[0]) + '.c'
+ return ([t], source)
+
+#-------------------
+# Generate config.h
+#-------------------
+def generate_config_header(target, source, env):
+ t = open(str(target[0]), 'w')
+ if not env.has_key('CONFIG_H_GEN'):
+ # XXX
+ assert 0 == 1
+ sym = env['CONFIG_H_GEN']
+ def write_symbol(define, value):
+ if value == 1:
+ return "#define %s\n\n" % define
+ elif value == 0:
+ return "/* #undef %s */\n\n" % define
+ elif isstring(value):
+ return "#define %s %s\n\n" % (define, value)
+ else:
+ return "#define %s %s\n\n" % (define, ','.join(value))
+ t.writelines([write_symbol(i[0], i[1]) for i in sym])
+ t.write('\n')
+ t.close()
+
+ print 'File: %s' % target[0]
+ target_f = open(str(target[0]))
+ print target_f.read()
+ target_f.close()
+ print 'EOF'
+ return 0
+
+def generate_config_header_emitter(target, source, env):
+ """Add dependency from config list CONFIG_H_GEN to target. Returns
+ original target, source tuple unchanged. """
+ from SCons.Script import Depends
+ d = deepcopy(env['CONFIG_H_GEN']) # copy it
+ Depends(target, SCons.Node.Python.Value(d))
+ return target, source
+
+#-----------------------------------------
+# Other functions related to configuration
+#-----------------------------------------
+def CheckBrokenMathlib(context, mathlib):
+ src = """
+/* check whether libm is broken */
+#include
+int main(int argc, char *argv[])
+{
+ return exp(-720.) > 1.0; /* typically an IEEE denormal */
+}
+"""
+
+ try:
+ oldLIBS = deepcopy(context.env['LIBS'])
+ except:
+ oldLIBS = []
+
+ try:
+ context.Message("Checking if math lib %s is usable for numpy ... " % mathlib)
+ context.env.AppendUnique(LIBS = mathlib)
+ st = context.TryRun(src, '.c')
+ finally:
+ context.env['LIBS'] = oldLIBS
+
+ if st[0]:
+ context.Result(' Yes !')
+ else:
+ context.Result(' No !')
+ return st[0]
+
+def define_no_smp():
+ """Returns True if we should define NPY_NOSMP, False otherwise."""
+ #--------------------------------
+ # Checking SMP and thread options
+ #--------------------------------
+ # Python 2.3 causes a segfault when
+ # trying to re-acquire the thread-state
+ # which is done in error-handling
+ # ufunc code. NPY_ALLOW_C_API and friends
+ # cause the segfault. So, we disable threading
+ # for now.
+ if sys.version[:5] < '2.4.2':
+ nosmp = 1
+ else:
+ # Perhaps a fancier check is in order here.
+ # so that threads are only enabled if there
+ # are actually multiple CPUS? -- but
+ # threaded code can be nice even on a single
+ # CPU so that long-calculating code doesn't
+ # block.
+ try:
+ nosmp = os.environ['NPY_NOSMP']
+ nosmp = 1
+ except KeyError:
+ nosmp = 0
+ return nosmp == 1
+
Added: branches/build_with_scons/numpy/core/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/core/setupscons.py 2008-01-06 14:08:19 UTC (rev 4690)
+++ branches/build_with_scons/numpy/core/setupscons.py 2008-01-06 14:09:03 UTC (rev 4691)
@@ -0,0 +1,103 @@
+import os
+import sys
+import glob
+from os.path import join, basename
+from numpy.distutils import log
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration,dot_join
+ from numpy.distutils.system_info import get_info, default_lib_dirs
+
+ config = Configuration('core',parent_package,top_path)
+ local_dir = config.local_path
+
+ header_dir = 'include/numpy' # this is relative to config.path_in_package
+
+ config.add_subpackage('code_generators')
+
+ # List of files to register to numpy.distutils
+ dot_blas_src = [join('blasdot', '_dotblas.c'),
+ join('blasdot', 'cblas.h')]
+ api_definition = [join('code_generators', 'array_api_order.txt'),
+ join('code_generators', 'multiarray_api_order.txt'),
+ join('code_generators', 'ufunc_api_order.txt')]
+ core_src = [join('src', basename(i)) for i in glob.glob(join(local_dir,
+ 'src',
+ '*.c'))]
+ core_src += [join('src', basename(i)) for i in glob.glob(join(local_dir,
+ 'src',
+ '*.src'))]
+
+ source_files = dot_blas_src + api_definition + core_src + \
+ [join(header_dir, 'numpyconfig.h.in')]
+
+ # Add generated files to distutils...
+ def add_config_header():
+ scons_build_dir = config.get_scons_build_dir()
+ # XXX: I really have to think about how to communicate path info
+ # between scons and distutils, and set the options at one single
+ # location.
+ target = join(scons_build_dir, local_dir, 'config.h')
+ incl_dir = os.path.dirname(target)
+ if incl_dir not in config.numpy_include_dirs:
+ config.numpy_include_dirs.append(incl_dir)
+
+ def add_numpyconfig_header():
+ scons_build_dir = config.get_scons_build_dir()
+ # XXX: I really have to think about how to communicate path info
+ # between scons and distutils, and set the options at one single
+ # location.
+ target = join(scons_build_dir, local_dir, 'numpyconfig.h')
+ incl_dir = os.path.dirname(target)
+ if incl_dir not in config.numpy_include_dirs:
+ config.numpy_include_dirs.append(incl_dir)
+ config.add_data_files((header_dir, target))
+
+ def add_array_api():
+ scons_build_dir = config.get_scons_build_dir()
+ # XXX: I really have to think about how to communicate path info
+ # between scons and distutils, and set the options at one single
+ # location.
+ h_file = join(scons_build_dir, local_dir, '__multiarray_api.h')
+ t_file = join(scons_build_dir, local_dir, 'multiarray_api.txt')
+ config.add_data_files((header_dir, h_file),
+ (header_dir, t_file))
+
+ def add_ufunc_api():
+ scons_build_dir = config.get_scons_build_dir()
+ # XXX: I really have to think about how to communicate path info
+ # between scons and distutils, and set the options at one single
+ # location.
+ h_file = join(scons_build_dir, local_dir, '__ufunc_api.h')
+ t_file = join(scons_build_dir, local_dir, 'ufunc_api.txt')
+ config.add_data_files((header_dir, h_file),
+ (header_dir, t_file))
+
+ def add_generated_files():
+ add_config_header()
+ add_numpyconfig_header()
+ add_array_api()
+ add_ufunc_api()
+ config.add_configres()
+
+ config.add_sconscript('SConstruct',
+ post_hook = add_generated_files,
+ source_files = source_files)
+
+ config.add_data_files('include/numpy/*.h')
+ config.add_include_dirs('src')
+
+ config.numpy_include_dirs.extend(config.paths('include'))
+
+ # Don't install fenv unless we need them.
+ if sys.platform == 'cygwin':
+ config.add_data_dir('include/numpy/fenv')
+
+ config.add_data_dir('tests')
+ config.make_svn_version_py()
+
+ return config
+
+if __name__=='__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Sun Jan 6 09:14:26 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 08:14:26 -0600 (CST)
Subject: [Numpy-svn] r4692 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106141426.A17B839C072@new.scipy.org>
Author: cdavid
Date: 2008-01-06 08:14:23 -0600 (Sun, 06 Jan 2008)
New Revision: 4692
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Add function add_configres for numpy.distutils.Configuration
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 14:09:03 UTC (rev 4691)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 14:14:23 UTC (rev 4692)
@@ -1212,6 +1212,10 @@
# options in distutils command.
self.add_extension('', sources = [])
+ def add_configres(self):
+ file = os.path.join(get_scons_configres_dir(), self.local_path,
+ get_scons_configres_filename())
+
def add_scripts(self,*files):
"""Add scripts to configuration.
"""
From numpy-svn at scipy.org Sun Jan 6 09:18:06 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 08:18:06 -0600 (CST)
Subject: [Numpy-svn] r4693 - branches/build_with_scons/numpy/distutils
Message-ID: <20080106141806.68A2B39C072@new.scipy.org>
Author: cdavid
Date: 2008-01-06 08:18:02 -0600 (Sun, 06 Jan 2008)
New Revision: 4693
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Import get_configres* functions from numscons
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 14:14:23 UTC (rev 4692)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 14:18:02 UTC (rev 4693)
@@ -1213,6 +1213,7 @@
self.add_extension('', sources = [])
def add_configres(self):
+ from numscons import get_scons_configres_dir, get_scons_configres_filename
file = os.path.join(get_scons_configres_dir(), self.local_path,
get_scons_configres_filename())
From numpy-svn at scipy.org Sun Jan 6 09:18:57 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 08:18:57 -0600 (CST)
Subject: [Numpy-svn] r4694 - in branches/build_with_scons/numpy/core: .
include/numpy
Message-ID: <20080106141857.2B3A139C072@new.scipy.org>
Author: cdavid
Date: 2008-01-06 08:18:51 -0600 (Sun, 06 Jan 2008)
New Revision: 4694
Added:
branches/build_with_scons/numpy/core/include/numpy/numpyconfig.h.in
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/setupscons.py
Log:
More work on building numpy.core with scons (still does not work)
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-06 14:18:02 UTC (rev 4693)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-06 14:18:51 UTC (rev 4694)
@@ -1,4 +1,4 @@
-# Last Change: Sun Jan 06 07:00 PM 2008 J
+# Last Change: Sun Jan 06 10:00 PM 2008 J
# vim:syntax=python
import os
import sys
@@ -143,7 +143,7 @@
build_blasdot = 0
config.Finish()
-write_info(env)
+#write_info(env)
#==========
# Build
Added: branches/build_with_scons/numpy/core/include/numpy/numpyconfig.h.in
===================================================================
--- branches/build_with_scons/numpy/core/include/numpy/numpyconfig.h.in 2008-01-06 14:18:02 UTC (rev 4693)
+++ branches/build_with_scons/numpy/core/include/numpy/numpyconfig.h.in 2008-01-06 14:18:51 UTC (rev 4694)
@@ -0,0 +1,23 @@
+#define NPY_SIZEOF_SHORT @SIZEOF_SHORT@
+#define NPY_SIZEOF_INT @SIZEOF_INT@
+#define NPY_SIZEOF_LONG @SIZEOF_LONG@
+#define NPY_SIZEOF_FLOAT @SIZEOF_FLOAT@
+#define NPY_SIZEOF_DOUBLE @SIZEOF_DOUBLE@
+#define NPY_SIZEOF_LONGDOUBLE @SIZEOF_LONG_DOUBLE@
+#define NPY_SIZEOF_PY_INTPTR_T @SIZEOF_PY_INTPTR_T@
+
+#define NPY_NOSMP @NPY_NOSMP@
+
+/* XXX: this has really nothing to do in a config file... */
+#define NPY_MATHLIB @MATHLIB@
+
+/* XXX: this has to be done outside config files !!!! */
+#ifdef PY_LONG_LONG
+ #define NPY_SIZEOF_LONGLONG @SIZEOF_PY_LONG_LONG@
+ #define NPY_SIZEOF_PY_LONG_LONG @SIZEOF_PY_LONG_LONG@
+#endif
+
+#ifndef CHAR_BIT
+ #error Configuration for undefined CHAR_BIT is not supported, contact the maintainter
+ #define CHAR_BIT @CHAR_BIT@
+#endif
Modified: branches/build_with_scons/numpy/core/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/core/setupscons.py 2008-01-06 14:18:02 UTC (rev 4693)
+++ branches/build_with_scons/numpy/core/setupscons.py 2008-01-06 14:18:51 UTC (rev 4694)
@@ -2,8 +2,11 @@
import sys
import glob
from os.path import join, basename
+
from numpy.distutils import log
+from numscons import get_scons_build_dir
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration,dot_join
from numpy.distutils.system_info import get_info, default_lib_dirs
@@ -33,7 +36,7 @@
# Add generated files to distutils...
def add_config_header():
- scons_build_dir = config.get_scons_build_dir()
+ scons_build_dir = get_scons_build_dir()
# XXX: I really have to think about how to communicate path info
# between scons and distutils, and set the options at one single
# location.
@@ -43,7 +46,7 @@
config.numpy_include_dirs.append(incl_dir)
def add_numpyconfig_header():
- scons_build_dir = config.get_scons_build_dir()
+ scons_build_dir = get_scons_build_dir()
# XXX: I really have to think about how to communicate path info
# between scons and distutils, and set the options at one single
# location.
@@ -54,7 +57,7 @@
config.add_data_files((header_dir, target))
def add_array_api():
- scons_build_dir = config.get_scons_build_dir()
+ scons_build_dir = get_scons_build_dir()
# XXX: I really have to think about how to communicate path info
# between scons and distutils, and set the options at one single
# location.
@@ -64,7 +67,7 @@
(header_dir, t_file))
def add_ufunc_api():
- scons_build_dir = config.get_scons_build_dir()
+ scons_build_dir = get_scons_build_dir()
# XXX: I really have to think about how to communicate path info
# between scons and distutils, and set the options at one single
# location.
From numpy-svn at scipy.org Sun Jan 6 21:39:48 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:39:48 -0600 (CST)
Subject: [Numpy-svn] r4695 - branches/build_with_scons/numpy/distutils
Message-ID: <20080107023948.667CC39C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:39:35 -0600 (Sun, 06 Jan 2008)
New Revision: 4695
Modified:
branches/build_with_scons/numpy/distutils/misc_util.py
Log:
Fix missing import from numscons
Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-06 14:18:51 UTC (rev 4694)
+++ branches/build_with_scons/numpy/distutils/misc_util.py 2008-01-07 02:39:35 UTC (rev 4695)
@@ -1491,6 +1491,7 @@
config['py_modules'].append((packagename, '__config__',generate_config_py))
"""
from distutils.dir_util import mkpath
+ from numscons import get_scons_configres_dir, get_scons_configres_filename
import imp
d = {}
mkpath(os.path.dirname(target))
From numpy-svn at scipy.org Sun Jan 6 21:40:44 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:40:44 -0600 (CST)
Subject: [Numpy-svn] r4696 - branches/build_with_scons/numpy/core
Message-ID: <20080107024044.C876639C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:40:39 -0600 (Sun, 06 Jan 2008)
New Revision: 4696
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Re-enable write_info, since the related bug in numscons has been fixed
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-07 02:39:35 UTC (rev 4695)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-07 02:40:39 UTC (rev 4696)
@@ -143,7 +143,7 @@
build_blasdot = 0
config.Finish()
-#write_info(env)
+write_info(env)
#==========
# Build
From numpy-svn at scipy.org Sun Jan 6 21:42:23 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:42:23 -0600 (CST)
Subject: [Numpy-svn] r4697 - branches/build_with_scons/numpy/fft
Message-ID: <20080107024223.BFB7939C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:42:16 -0600 (Sun, 06 Jan 2008)
New Revision: 4697
Added:
branches/build_with_scons/numpy/fft/SConstruct
branches/build_with_scons/numpy/fft/setupscons.py
Log:
numpy.fft builds with scons
Added: branches/build_with_scons/numpy/fft/SConstruct
===================================================================
--- branches/build_with_scons/numpy/fft/SConstruct 2008-01-07 02:40:39 UTC (rev 4696)
+++ branches/build_with_scons/numpy/fft/SConstruct 2008-01-07 02:42:16 UTC (rev 4697)
@@ -0,0 +1,13 @@
+# Last Change: Thu Oct 18 09:00 PM 2007 J
+# vim:syntax=python
+import __builtin__
+__builtin__.__NUMPY_SETUP__ = True
+from numpy.distutils.misc_util import get_numpy_include_dirs
+from numscons import GetNumpyEnvironment, scons_get_paths
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
+
+fftpack_lite = env.NumpyPythonExtension('fftpack_lite',
+ source = ['fftpack_litemodule.c',
+ 'fftpack.c'])
Added: branches/build_with_scons/numpy/fft/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/fft/setupscons.py 2008-01-07 02:40:39 UTC (rev 4696)
+++ branches/build_with_scons/numpy/fft/setupscons.py 2008-01-07 02:42:16 UTC (rev 4697)
@@ -0,0 +1,15 @@
+def configuration(parent_package = '', top_path = None):
+ from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
+ config = Configuration('fft', parent_package, top_path)
+
+ config.add_data_dir('tests')
+
+ config.add_sconscript('SConstruct',
+ source_files = ['fftpack_litemodule.c', 'fftpack.c',
+ 'fftpack.h'])
+
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Sun Jan 6 21:43:12 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:43:12 -0600 (CST)
Subject: [Numpy-svn] r4698 - branches/build_with_scons/numpy/random
Message-ID: <20080107024312.1860A39C2DF@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:43:05 -0600 (Sun, 06 Jan 2008)
New Revision: 4698
Added:
branches/build_with_scons/numpy/random/SConstruct
branches/build_with_scons/numpy/random/setupscons.py
Log:
numpy.random now builds with scons
Added: branches/build_with_scons/numpy/random/SConstruct
===================================================================
--- branches/build_with_scons/numpy/random/SConstruct 2008-01-07 02:42:16 UTC (rev 4697)
+++ branches/build_with_scons/numpy/random/SConstruct 2008-01-07 02:43:05 UTC (rev 4698)
@@ -0,0 +1,50 @@
+# Last Change: Tue Nov 13 11:00 PM 2007 J
+# vim:syntax=python
+import os
+
+import __builtin__
+__builtin__.__NUMPY_SETUP__ = True
+
+from numpy.distutils.misc_util import get_numpy_include_dirs, get_mathlibs
+from numscons import GetNumpyEnvironment, scons_get_paths, \
+ scons_get_mathlib
+
+def CheckWincrypt(context):
+ from copy import deepcopy
+ src = """\
+/* check to see if _WIN32 is defined */
+int main(int argc, char *argv[])
+{
+#ifdef _WIN32
+ return 0;
+#else
+ return 1;
+#endif
+}
+"""
+
+ context.Message("Checking if using wincrypt ... ")
+ st = context.env.TryRun(src, '.C')
+ if st[0] == 0:
+ context.Result('No')
+ else:
+ context.Result('Yes')
+ return st[0]
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
+
+mlib = scons_get_mathlib(env)
+env.AppendUnique(LIBS = mlib)
+
+# On windows, see if we should use Advapi32
+if os.name == 'nt':
+ config = env.NumpyConfigure(custom_tests = {'CheckWincrypt' : CheckWincrypt})
+ if config.CheckWincrypt:
+ config.env.AppendUnique(LIBS = 'Advapi32')
+
+sources = [os.path.join('mtrand', x) for x in
+ ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']]
+
+# XXX: Pyrex dependency
+mtrand = env.NumpyPythonExtension('mtrand', source = sources)
Added: branches/build_with_scons/numpy/random/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/random/setupscons.py 2008-01-07 02:42:16 UTC (rev 4697)
+++ branches/build_with_scons/numpy/random/setupscons.py 2008-01-07 02:43:05 UTC (rev 4698)
@@ -0,0 +1,40 @@
+import glob
+from os.path import join, split
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration, get_mathlibs
+ config = Configuration('random',parent_package,top_path)
+
+ source_files = [join('mtrand', i) for i in ['mtrand.c',
+ 'mtrand.pyx',
+ 'numpy.pxi',
+ 'randomkit.c',
+ 'randomkit.h',
+ 'Python.pxi',
+ 'initarray.c',
+ 'initarray.h',
+ 'distributions.c',
+ 'distributions.h',
+ ]]
+ config.add_sconscript('SConstruct', source_files = source_files)
+ config.add_data_files(('.', join('mtrand', 'randomkit.h')))
+ config.add_data_dir('tests')
+
+ return config
+
+def testcode_wincrypt():
+ return """\
+/* check to see if _WIN32 is defined */
+int main(int argc, char *argv[])
+{
+#ifdef _WIN32
+ return 0;
+#else
+ return 1;
+#endif
+}
+"""
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Sun Jan 6 21:45:12 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:45:12 -0600 (CST)
Subject: [Numpy-svn] r4699 - in branches/build_with_scons/numpy: distutils
f2py oldnumeric testing
Message-ID: <20080107024512.9A62339C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:44:56 -0600 (Sun, 06 Jan 2008)
New Revision: 4699
Added:
branches/build_with_scons/numpy/distutils/setupscons.py
branches/build_with_scons/numpy/f2py/setupscons.py
branches/build_with_scons/numpy/oldnumeric/setupscons.py
branches/build_with_scons/numpy/testing/setupscons.py
Log:
Add setupscons.py for pure python packages
Added: branches/build_with_scons/numpy/distutils/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/distutils/setupscons.py 2008-01-07 02:43:05 UTC (rev 4698)
+++ branches/build_with_scons/numpy/distutils/setupscons.py 2008-01-07 02:44:56 UTC (rev 4699)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ config = Configuration('distutils',parent_package,top_path)
+ config.add_subpackage('command')
+ config.add_subpackage('fcompiler')
+ config.add_data_dir('tests')
+ config.add_data_files('site.cfg')
+ config.make_config_py()
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
Added: branches/build_with_scons/numpy/f2py/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/f2py/setupscons.py 2008-01-07 02:43:05 UTC (rev 4698)
+++ branches/build_with_scons/numpy/f2py/setupscons.py 2008-01-07 02:44:56 UTC (rev 4699)
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+"""
+setup.py for installing F2PY
+
+Usage:
+ python setup.py install
+
+Copyright 2001-2005 Pearu Peterson all rights reserved,
+Pearu Peterson
+Permission to use, modify, and distribute this software is given under the
+terms of the NumPy License.
+
+NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+$Revision: 1.32 $
+$Date: 2005/01/30 17:22:14 $
+Pearu Peterson
+"""
+
+__version__ = "$Id: setup.py,v 1.32 2005/01/30 17:22:14 pearu Exp $"
+
+import os
+import sys
+from distutils.dep_util import newer
+from numpy.distutils import log
+from numpy.distutils.core import setup
+from numpy.distutils.misc_util import Configuration
+
+from __version__ import version
+
+def configuration(parent_package='',top_path=None):
+ config = Configuration('f2py', parent_package, top_path)
+
+ config.add_subpackage('lib')
+
+ config.add_data_dir('docs')
+
+ config.add_data_files('src/fortranobject.c',
+ 'src/fortranobject.h',
+ 'f2py.1'
+ )
+
+ config.make_svn_version_py()
+
+ def generate_f2py_py(build_dir):
+ f2py_exe = 'f2py'+os.path.basename(sys.executable)[6:]
+ if f2py_exe[-4:]=='.exe':
+ f2py_exe = f2py_exe[:-4] + '.py'
+ if 'bdist_wininst' in sys.argv and f2py_exe[-3:] != '.py':
+ f2py_exe = f2py_exe + '.py'
+ target = os.path.join(build_dir,f2py_exe)
+ if newer(__file__,target):
+ log.info('Creating %s', target)
+ f = open(target,'w')
+ f.write('''\
+#!/usr/bin/env %s
+# See http://cens.ioc.ee/projects/f2py2e/
+import os, sys
+for mode in ["g3-numpy", "2e-numeric", "2e-numarray", "2e-numpy"]:
+ try:
+ i=sys.argv.index("--"+mode)
+ del sys.argv[i]
+ break
+ except ValueError: pass
+os.environ["NO_SCIPY_IMPORT"]="f2py"
+if mode=="g3-numpy":
+ try:
+ from main import main
+ except ImportError:
+ from numpy.f2py.lib.api import main
+elif mode=="2e-numeric":
+ from f2py2e import main
+elif mode=="2e-numarray":
+ sys.argv.append("-DNUMARRAY")
+ from f2py2e import main
+elif mode=="2e-numpy":
+ from numpy.f2py import main
+else:
+ print >> sys.stderr, "Unknown mode:",`mode`
+ sys.exit(1)
+main()
+'''%(os.path.basename(sys.executable)))
+ f.close()
+ return target
+
+ config.add_scripts(generate_f2py_py)
+
+ log.info('F2PY Version %s', config.get_version())
+
+ return config
+
+if __name__ == "__main__":
+
+ config = configuration(top_path='')
+ version = config.get_version()
+ print 'F2PY Version',version
+ config = config.todict()
+
+ if sys.version[:3]>='2.3':
+ config['download_url'] = "http://cens.ioc.ee/projects/f2py2e/2.x"\
+ "/F2PY-2-latest.tar.gz"
+ config['classifiers'] = [
+ 'Development Status :: 5 - Production/Stable',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: Science/Research',
+ 'License :: OSI Approved :: NumPy License',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: C',
+ 'Programming Language :: Fortran',
+ 'Programming Language :: Python',
+ 'Topic :: Scientific/Engineering',
+ 'Topic :: Software Development :: Code Generators',
+ ]
+ setup(version=version,
+ description = "F2PY - Fortran to Python Interface Generaton",
+ author = "Pearu Peterson",
+ author_email = "pearu at cens.ioc.ee",
+ maintainer = "Pearu Peterson",
+ maintainer_email = "pearu at cens.ioc.ee",
+ license = "BSD",
+ platforms = "Unix, Windows (mingw|cygwin), Mac OSX",
+ long_description = """\
+The Fortran to Python Interface Generator, or F2PY for short, is a
+command line tool (f2py) for generating Python C/API modules for
+wrapping Fortran 77/90/95 subroutines, accessing common blocks from
+Python, and calling Python functions from Fortran (call-backs).
+Interfacing subroutines/data from Fortran 90/95 modules is supported.""",
+ url = "http://cens.ioc.ee/projects/f2py2e/",
+ keywords = ['Fortran','f2py'],
+ **config)
Property changes on: branches/build_with_scons/numpy/f2py/setupscons.py
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/build_with_scons/numpy/oldnumeric/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/oldnumeric/setupscons.py 2008-01-07 02:43:05 UTC (rev 4698)
+++ branches/build_with_scons/numpy/oldnumeric/setupscons.py 2008-01-07 02:44:56 UTC (rev 4699)
@@ -0,0 +1,8 @@
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ return Configuration('oldnumeric',parent_package,top_path)
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
Added: branches/build_with_scons/numpy/testing/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/testing/setupscons.py 2008-01-07 02:43:05 UTC (rev 4698)
+++ branches/build_with_scons/numpy/testing/setupscons.py 2008-01-07 02:44:56 UTC (rev 4699)
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ config = Configuration('testing',parent_package,top_path)
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(maintainer = "NumPy Developers",
+ maintainer_email = "numpy-dev at numpy.org",
+ description = "NumPy test module",
+ url = "http://www.numpy.org",
+ license = "NumPy License (BSD Style)",
+ configuration = configuration,
+ )
Property changes on: branches/build_with_scons/numpy/testing/setupscons.py
___________________________________________________________________
Name: svn:executable
+ *
From numpy-svn at scipy.org Sun Jan 6 21:46:57 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:46:57 -0600 (CST)
Subject: [Numpy-svn] r4700 - branches/build_with_scons/numpy/numarray
Message-ID: <20080107024657.5BC7239C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:46:49 -0600 (Sun, 06 Jan 2008)
New Revision: 4700
Added:
branches/build_with_scons/numpy/numarray/SConstruct
branches/build_with_scons/numpy/numarray/setupscons.py
Log:
numarray now builds with scons
Added: branches/build_with_scons/numpy/numarray/SConstruct
===================================================================
--- branches/build_with_scons/numpy/numarray/SConstruct 2008-01-07 02:44:56 UTC (rev 4699)
+++ branches/build_with_scons/numpy/numarray/SConstruct 2008-01-07 02:46:49 UTC (rev 4700)
@@ -0,0 +1,12 @@
+# Last Change: Fri Oct 19 09:00 AM 2007 J
+# vim:syntax=python
+import __builtin__
+__builtin__.__NUMPY_SETUP__ = True
+from numpy.distutils.misc_util import get_numpy_include_dirs
+from numscons import GetNumpyEnvironment, scons_get_paths
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
+env.Append(CPPPATH = env['src_dir'])
+
+_capi = env.NumpyPythonExtension('_capi', source = ['_capi.c'])
Added: branches/build_with_scons/numpy/numarray/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/numarray/setupscons.py 2008-01-07 02:44:56 UTC (rev 4699)
+++ branches/build_with_scons/numpy/numarray/setupscons.py 2008-01-07 02:46:49 UTC (rev 4700)
@@ -0,0 +1,14 @@
+from os.path import join
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ config = Configuration('numarray',parent_package,top_path)
+
+ config.add_data_files('numpy/')
+ config.add_sconscript('SConstruct', source_files = ['_capi.c'])
+
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Sun Jan 6 21:47:43 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:47:43 -0600 (CST)
Subject: [Numpy-svn] r4701 - branches/build_with_scons/numpy/lib
Message-ID: <20080107024743.529B539C098@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:47:36 -0600 (Sun, 06 Jan 2008)
New Revision: 4701
Added:
branches/build_with_scons/numpy/lib/SConstruct
branches/build_with_scons/numpy/lib/setupscons.py
Log:
numpy.lib now builds with scons
Added: branches/build_with_scons/numpy/lib/SConstruct
===================================================================
--- branches/build_with_scons/numpy/lib/SConstruct 2008-01-07 02:46:49 UTC (rev 4700)
+++ branches/build_with_scons/numpy/lib/SConstruct 2008-01-07 02:47:36 UTC (rev 4701)
@@ -0,0 +1,12 @@
+# Last Change: Thu Oct 18 09:00 PM 2007 J
+# vim:syntax=python
+import __builtin__
+__builtin__.__NUMPY_SETUP__ = True
+from numpy.distutils.misc_util import get_numpy_include_dirs
+from numscons import GetNumpyEnvironment, scons_get_paths
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
+
+_compiled_base = env.NumpyPythonExtension('_compiled_base',
+ source = ['src/_compiled_base.c'])
Added: branches/build_with_scons/numpy/lib/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/lib/setupscons.py 2008-01-07 02:46:49 UTC (rev 4700)
+++ branches/build_with_scons/numpy/lib/setupscons.py 2008-01-07 02:47:36 UTC (rev 4701)
@@ -0,0 +1,16 @@
+from os.path import join
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+
+ config = Configuration('lib',parent_package,top_path)
+
+ config.add_sconscript('SConstruct',
+ source_files = [join('src', '_compiled_base.c')])
+ config.add_data_dir('tests')
+
+ return config
+
+if __name__=='__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Sun Jan 6 21:48:35 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 6 Jan 2008 20:48:35 -0600 (CST)
Subject: [Numpy-svn] r4702 - branches/build_with_scons/numpy/linalg
Message-ID: <20080107024835.777F739C25D@new.scipy.org>
Author: cdavid
Date: 2008-01-06 20:48:27 -0600 (Sun, 06 Jan 2008)
New Revision: 4702
Added:
branches/build_with_scons/numpy/linalg/SConstruct
branches/build_with_scons/numpy/linalg/setupscons.py
Log:
numpy.linalg now builds with scons
Added: branches/build_with_scons/numpy/linalg/SConstruct
===================================================================
--- branches/build_with_scons/numpy/linalg/SConstruct 2008-01-07 02:47:36 UTC (rev 4701)
+++ branches/build_with_scons/numpy/linalg/SConstruct 2008-01-07 02:48:27 UTC (rev 4702)
@@ -0,0 +1,33 @@
+# Last Change: Fri Nov 16 05:00 PM 2007 J
+# vim:syntax=python
+import os.path
+
+import __builtin__
+__builtin__.__NUMPY_SETUP__ = True
+
+from numpy.distutils.misc_util import get_numpy_include_dirs, get_mathlibs
+from numscons import GetNumpyEnvironment, scons_get_paths, \
+ scons_get_mathlib
+from numscons import CheckF77LAPACK
+from numscons.configuration import write_info
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
+
+config = env.NumpyConfigure(custom_tests =
+ {'CheckLAPACK' : CheckF77LAPACK})
+
+use_lapack = config.CheckLAPACK()
+
+mlib = scons_get_mathlib(env)
+env.AppendUnique(LIBS = mlib)
+
+config.Finish()
+write_info(env)
+
+sources = ['lapack_litemodule.c']
+if not use_lapack:
+ sources.extend(['zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c',
+ 'dlamch.c', 'f2c_lite.c'])
+lapack_lite = env.NumpyPythonExtension('lapack_lite', source = sources)
+
Added: branches/build_with_scons/numpy/linalg/setupscons.py
===================================================================
--- branches/build_with_scons/numpy/linalg/setupscons.py 2008-01-07 02:47:36 UTC (rev 4701)
+++ branches/build_with_scons/numpy/linalg/setupscons.py 2008-01-07 02:48:27 UTC (rev 4702)
@@ -0,0 +1,20 @@
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ from numpy.distutils.system_info import get_info
+ config = Configuration('linalg',parent_package,top_path)
+
+ config.add_data_dir('tests')
+
+ config.add_sconscript('SConstruct',
+ source_files = ['lapack_litemodule.c',
+ 'zlapack_lite.c', 'dlapack_lite.c',
+ 'blas_lite.c', 'dlamch.c',
+ 'f2c_lite.c','f2c.h'],
+ post_hook = config.add_configres)
+
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(configuration=configuration)
From numpy-svn at scipy.org Mon Jan 7 09:59:31 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Mon, 7 Jan 2008 08:59:31 -0600 (CST)
Subject: [Numpy-svn] r4703 - in branches/build_with_scons/numpy: core linalg
Message-ID: <20080107145931.7458639C2AA@new.scipy.org>
Author: cdavid
Date: 2008-01-07 08:59:16 -0600 (Mon, 07 Jan 2008)
New Revision: 4703
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/linalg/SConstruct
Log:
Change write_info imports, put in top numscons namespace
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-07 02:48:27 UTC (rev 4702)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-07 14:59:16 UTC (rev 4703)
@@ -8,7 +8,7 @@
from numscons import get_python_inc, get_pythonlib_dir
from numscons import GetNumpyEnvironment
from numscons import CheckCBLAS
-from numscons.configuration import write_info
+from numscons import write_info
from scons_support import CheckBrokenMathlib, define_no_smp, \
generate_config_header, generate_config_header_emitter
Modified: branches/build_with_scons/numpy/linalg/SConstruct
===================================================================
--- branches/build_with_scons/numpy/linalg/SConstruct 2008-01-07 02:48:27 UTC (rev 4702)
+++ branches/build_with_scons/numpy/linalg/SConstruct 2008-01-07 14:59:16 UTC (rev 4703)
@@ -9,7 +9,7 @@
from numscons import GetNumpyEnvironment, scons_get_paths, \
scons_get_mathlib
from numscons import CheckF77LAPACK
-from numscons.configuration import write_info
+from numscons import write_info
env = GetNumpyEnvironment(ARGUMENTS)
env.Append(CPPPATH = scons_get_paths(env['include_bootstrap']))
From numpy-svn at scipy.org Mon Jan 7 16:20:09 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Mon, 7 Jan 2008 15:20:09 -0600 (CST)
Subject: [Numpy-svn] r4704 - trunk/numpy/core/src
Message-ID: <20080107212009.908AA39C0A4@new.scipy.org>
Author: oliphant
Date: 2008-01-07 15:20:06 -0600 (Mon, 07 Jan 2008)
New Revision: 4704
Modified:
trunk/numpy/core/src/scalartypes.inc.src
Log:
Fix scalar __array_interface__ by making sure to retain a reference the 0-d array created in the returned dictionary.
Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src 2008-01-07 14:59:16 UTC (rev 4703)
+++ trunk/numpy/core/src/scalartypes.inc.src 2008-01-07 21:20:06 UTC (rev 4704)
@@ -863,6 +863,7 @@
arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
if (arr == NULL) return NULL;
inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__");
+ if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr);
Py_DECREF(arr);
return inter;
}
From numpy-svn at scipy.org Tue Jan 8 00:50:41 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Mon, 7 Jan 2008 23:50:41 -0600 (CST)
Subject: [Numpy-svn] r4705 - branches/build_with_scons/numpy/core/src
Message-ID: <20080108055041.44E4D39C102@new.scipy.org>
Author: cdavid
Date: 2008-01-07 23:50:36 -0600 (Mon, 07 Jan 2008)
New Revision: 4705
Modified:
branches/build_with_scons/numpy/core/src/scalartypes.inc.src
Log:
Merged revisions 4677-4704 from http://svn.scipy.org/svn/numpy/trunk
Modified: branches/build_with_scons/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/build_with_scons/numpy/core/src/scalartypes.inc.src 2008-01-07 21:20:06 UTC (rev 4704)
+++ branches/build_with_scons/numpy/core/src/scalartypes.inc.src 2008-01-08 05:50:36 UTC (rev 4705)
@@ -863,6 +863,7 @@
arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
if (arr == NULL) return NULL;
inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__");
+ if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr);
Py_DECREF(arr);
return inter;
}
From numpy-svn at scipy.org Tue Jan 8 07:18:52 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 06:18:52 -0600 (CST)
Subject: [Numpy-svn] r4706 - branches/build_with_scons/numpy/core
Message-ID: <20080108121852.3AA9439C15C@new.scipy.org>
Author: cdavid
Date: 2008-01-08 06:18:46 -0600 (Tue, 08 Jan 2008)
New Revision: 4706
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/scons_support.py
Log:
Refactor the check for m library + functions in numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 05:50:36 UTC (rev 4705)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 12:18:46 UTC (rev 4706)
@@ -1,4 +1,4 @@
-# Last Change: Sun Jan 06 10:00 PM 2008 J
+# Last Change: Tue Jan 08 09:00 PM 2008 J
# vim:syntax=python
import os
import sys
@@ -11,7 +11,8 @@
from numscons import write_info
from scons_support import CheckBrokenMathlib, define_no_smp, \
- generate_config_header, generate_config_header_emitter
+ generate_config_header, generate_config_header_emitter, \
+ check_mlib, check_mlibs
env = GetNumpyEnvironment(ARGUMENTS)
env.Append(CPPPATH = [get_python_inc()])
@@ -26,7 +27,7 @@
#=======================
# XXX: separate env for configuration
config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib,
- 'CheckCBLAS' : CheckCBLAS})
+ 'CheckCBLAS' : CheckCBLAS}, config_h = 'scons_config.h')
# Convention: list of tuples (definition, value). value:
# - 0: #undef definition
@@ -86,16 +87,9 @@
mathlib = os.environ.get('MATHLIB')
if mathlib:
mlibs.insert(0, mathlib)
-for mlib in mlibs:
- st = config.CheckBrokenMathlib(mlib)
- if st:
- break
-if not st:
- import SCons
- raise SCons.Errors.UserError("No usable mathlib was found: chose another "\
- "one using the MATHLIB env variable, eg "\
- "'MATHLIB=m python setup.py build'")
+mlib = check_mlibs(config, mlibs)
+
# XXX: this is ugly: mathlib has nothing to do in a public header file
config_sym.append(('MATHLIB', ','.join(mlib)))
@@ -103,7 +97,7 @@
"""Check that f is available in mlib, and add the symbol appropriately.
f is expected to be a tuble (symbol, cpp define)."""
- st = config.CheckLibWithHeader(mlib, 'math.h', language = 'C', call = '%s;' % f[0], autoadd = autoadd)
+ st = config.CheckFunc(f[0], language = 'C')
if st:
config_sym.append((f[1], 1))
else:
Modified: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 05:50:36 UTC (rev 4705)
+++ branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 12:18:46 UTC (rev 4706)
@@ -1,4 +1,4 @@
-#! Last Change: Sun Jan 06 09:00 PM 2008 J
+#! Last Change: Tue Jan 08 08:00 PM 2008 J
__docstring__ = """Code to support special facilities to scons which are only
useful for numpy.core, hence not put into numpy.distutils.scons"""
@@ -18,6 +18,7 @@
from numscons.core.utils import rsplit, isstring
import SCons.Node
+import SCons
def split_ext(string):
sp = rsplit(string, '.', 1)
@@ -160,6 +161,31 @@
context.Result(' No !')
return st[0]
+def check_mlib(config, mlib):
+ """Return 1 if mlib is available and usable by numpy, 0 otherwise.
+
+ mlib can be a string (one library), or a list of libraries."""
+ # Check the libraries in mlib are linkable
+ if len(mlib) > 0:
+ # XXX: put an autoadd argument to 0 here and add an autoadd argument to
+ # CheckBroekenMathlib (otherwise we may add bogus libraries, the ones
+ # which do not path the CheckBrokenMathlib test).
+ st = config.CheckLib(mlib)
+ if not st:
+ return 0
+ # Check the mlib is usable by numpy
+ return config.CheckBrokenMathlib(mlib)
+
+def check_mlibs(config, mlibs):
+ for mlib in mlibs:
+ if check_mlib(config, mlib):
+ return mlib
+
+ # No mlib was found.
+ raise SCons.Errors.UserError("No usable mathlib was found: chose another "\
+ "one using the MATHLIB env variable, eg "\
+ "'MATHLIB=m python setup.py build'")
+
def define_no_smp():
"""Returns True if we should define NPY_NOSMP, False otherwise."""
#--------------------------------
From numpy-svn at scipy.org Tue Jan 8 07:45:16 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 06:45:16 -0600 (CST)
Subject: [Numpy-svn] r4707 - branches/build_with_scons/numpy/core
Message-ID: <20080108124516.5D40439C046@new.scipy.org>
Author: cdavid
Date: 2008-01-08 06:45:12 -0600 (Tue, 08 Jan 2008)
New Revision: 4707
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Add PyOS_ascii_strtod test for automatic config header generation
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 12:18:46 UTC (rev 4706)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 12:45:12 UTC (rev 4707)
@@ -110,6 +110,13 @@
#-------------------------------------------------------
# Define the function PyOS_ascii_strod if not available
#-------------------------------------------------------
+if not config.CheckDeclaration('PyOS_ascii_strtod',
+ includes = "#include "):
+ if config.CheckFunc('strtod'):
+ config.Define('PyOS_ascii_strtod', 'strtod',
+ "Define to a function to use as a replacement for "\
+ "PyOS_ascii_strtod if not available in python header")
+
# XXX: would be better to check for PyOS_ascii_strod instead of version
if sys.version[:3] < '2.4':
if config.CheckFunc('strtod'):
From numpy-svn at scipy.org Tue Jan 8 08:10:55 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 07:10:55 -0600 (CST)
Subject: [Numpy-svn] r4708 - branches/build_with_scons/numpy/core
Message-ID: <20080108131055.C7362C7C023@new.scipy.org>
Author: cdavid
Date: 2008-01-08 07:10:52 -0600 (Tue, 08 Jan 2008)
New Revision: 4708
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
More work on automatic generation of config.h (not ready yet)
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 12:45:12 UTC (rev 4707)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:10:52 UTC (rev 4708)
@@ -1,4 +1,4 @@
-# Last Change: Tue Jan 08 09:00 PM 2008 J
+# Last Change: Tue Jan 08 10:00 PM 2008 J
# vim:syntax=python
import os
import sys
@@ -93,7 +93,7 @@
# XXX: this is ugly: mathlib has nothing to do in a public header file
config_sym.append(('MATHLIB', ','.join(mlib)))
-def check_lib(f, autoadd = 0):
+def check_func(f):
"""Check that f is available in mlib, and add the symbol appropriately.
f is expected to be a tuble (symbol, cpp define)."""
@@ -103,9 +103,8 @@
else:
config_sym.append((f[1], 0))
-check_lib(mfuncs[0], autoadd = 1)
-for f in mfuncs[1:]:
- check_lib(f)
+for f in mfuncs:
+ check_func(f)
#-------------------------------------------------------
# Define the function PyOS_ascii_strod if not available
@@ -124,16 +123,23 @@
if define_no_smp():
config_sym.append(('NPY_NOSMP', '1'))
+ config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
else:
config_sym.append(('NPY_NOSMP', '0'))
+ config.Define('NPY_NOSMP', 0, "define to 1 to disable SMP support ")
# XXX: this is ugly
+distutils_use_sdk = 0
if sys.platform=='win32' or os.name=='nt':
from distutils.msvccompiler import get_build_architecture
a = get_build_architecture()
print 'BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % (a, os.name, sys.platform)
if a == 'AMD64':
- moredefs.append(('DISTUTILS_USE_SDK', 1))
+ distutils_use_sdk = 1
+if distutils_use_sdk:
+ moredefs.append(('DISTUTILS_USE_SDK', 1))
+config.Define('DISTUTILS_USE_SDK', distutils_use_sdk,
+ "define to 1 to disable SMP support ")
#--------------
# Checking Blas
From numpy-svn at scipy.org Tue Jan 8 08:31:25 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 07:31:25 -0600 (CST)
Subject: [Numpy-svn] r4709 - branches/build_with_scons/numpy/core
Message-ID: <20080108133125.86D71C7C031@new.scipy.org>
Author: cdavid
Date: 2008-01-08 07:31:21 -0600 (Tue, 08 Jan 2008)
New Revision: 4709
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Add groupe of math functions availability in generated config header
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:10:52 UTC (rev 4708)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:31:21 UTC (rev 4709)
@@ -82,6 +82,9 @@
('rint', 'HAVE_RINT'),
]
+# Set value to 1 for each defined function (in math lib)
+mfuncs_defined = dict([(f[0], 0) for f in mfuncs])
+
# TODO: checklib vs checkfunc ?
mlibs = [[], ['m'], ['cpml']]
mathlib = os.environ.get('MATHLIB')
@@ -102,10 +105,27 @@
config_sym.append((f[1], 1))
else:
config_sym.append((f[1], 0))
+ mfuncs_defined[f[0]] = 1
for f in mfuncs:
check_func(f)
+if mfuncs_defined['expl'] == 1:
+ config.Define('HAVE_LONGDOUBLE_FUNCS', 1,
+ 'Define to 1 if long double funcs are available')
+if mfuncs_defined['expf'] == 1:
+ config.Define('HAVE_FLOAT_FUNCS', 1,
+ 'Define to 1 if long double funcs are available')
+if mfuncs_defined['asinh'] == 1:
+ config.Define('HAVE_INVERSE_HYPERBOLIC', 1,
+ 'Define to 1 if inverse hyperbolic funcs are available')
+if mfuncs_defined['atanhf'] == 1:
+ config.Define('HAVE_INVERSE_HYPERBOLIC_FLOAT', 1,
+ 'Define to 1 if inverse hyperbolic float funcs are available')
+if mfuncs_defined['atanhl'] == 1:
+ config.Define('HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE', 1,
+ 'Define to 1 if inverse hyperbolic long double funcs are available')
+
#-------------------------------------------------------
# Define the function PyOS_ascii_strod if not available
#-------------------------------------------------------
From numpy-svn at scipy.org Tue Jan 8 08:46:51 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 07:46:51 -0600 (CST)
Subject: [Numpy-svn] r4710 - branches/build_with_scons/numpy/core
Message-ID: <20080108134651.A557A39C112@new.scipy.org>
Author: cdavid
Date: 2008-01-08 07:46:46 -0600 (Tue, 08 Jan 2008)
New Revision: 4710
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/scons_support.py
Log:
Now we use automatically generated config header instead of old kludge taken
from setup.py.
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:31:21 UTC (rev 4709)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:46:46 UTC (rev 4710)
@@ -12,7 +12,7 @@
from scons_support import CheckBrokenMathlib, define_no_smp, \
generate_config_header, generate_config_header_emitter, \
- check_mlib, check_mlibs
+ check_mlib, check_mlibs, is_npy_no_signal
env = GetNumpyEnvironment(ARGUMENTS)
env.Append(CPPPATH = [get_python_inc()])
@@ -27,7 +27,7 @@
#=======================
# XXX: separate env for configuration
config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib,
- 'CheckCBLAS' : CheckCBLAS}, config_h = 'scons_config.h')
+ 'CheckCBLAS' : CheckCBLAS}, config_h = pjoin(env['build_dir'], 'config.h'))
# Convention: list of tuples (definition, value). value:
# - 0: #undef definition
@@ -64,7 +64,9 @@
#----------------------
# Checking signal stuff
#----------------------
-# TODO
+if is_npy_no_signal():
+ config_sym.append(('NPY_NOSMP', '1'))
+ config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
#------------------------------------------
# Checking the mathlib and its capabilities
@@ -157,9 +159,9 @@
if a == 'AMD64':
distutils_use_sdk = 1
if distutils_use_sdk:
- moredefs.append(('DISTUTILS_USE_SDK', 1))
-config.Define('DISTUTILS_USE_SDK', distutils_use_sdk,
- "define to 1 to disable SMP support ")
+ moredefs.append('DISTUTILS_USE_SDK')
+ config.Define('DISTUTILS_USE_SDK', distutils_use_sdk,
+ "define to 1 to disable SMP support ")
#--------------
# Checking Blas
@@ -228,7 +230,7 @@
# option ?)
from os.path import join as pjoin
-config_header = env.GenerateConfigHeader(pjoin(env['build_dir'], 'config.h'), [])
+#config_header = env.GenerateConfigHeader(pjoin(env['build_dir'], 'config.h'), [])
scalartypes_src = env.GenerateFromTemplate(
pjoin(env['build_dir'], 'src', 'scalartypes'),
Modified: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 13:31:21 UTC (rev 4709)
+++ branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 13:46:46 UTC (rev 4710)
@@ -1,4 +1,4 @@
-#! Last Change: Tue Jan 08 08:00 PM 2008 J
+#! Last Change: Tue Jan 08 10:00 PM 2008 J
__docstring__ = """Code to support special facilities to scons which are only
useful for numpy.core, hence not put into numpy.distutils.scons"""
@@ -186,6 +186,12 @@
"one using the MATHLIB env variable, eg "\
"'MATHLIB=m python setup.py build'")
+
+def is_npy_no_signal():
+ """Return True if the NPY_NO_SIGNAL symbol must be defined in configuration
+ header."""
+ return sys.platform == 'win32'
+
def define_no_smp():
"""Returns True if we should define NPY_NOSMP, False otherwise."""
#--------------------------------
From numpy-svn at scipy.org Tue Jan 8 08:49:43 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 07:49:43 -0600 (CST)
Subject: [Numpy-svn] r4711 - branches/build_with_scons/numpy/core
Message-ID: <20080108134943.6819539C112@new.scipy.org>
Author: cdavid
Date: 2008-01-08 07:49:39 -0600 (Tue, 08 Jan 2008)
New Revision: 4711
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/scons_support.py
Log:
Remove deprecated builder for config.h
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:46:46 UTC (rev 4710)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:49:39 UTC (rev 4711)
@@ -11,7 +11,6 @@
from numscons import write_info
from scons_support import CheckBrokenMathlib, define_no_smp, \
- generate_config_header, generate_config_header_emitter, \
check_mlib, check_mlibs, is_npy_no_signal
env = GetNumpyEnvironment(ARGUMENTS)
@@ -213,14 +212,10 @@
umath_bld = Builder(action = generate_umath,
emitter = generate_umath_emitter)
-config_h_bld = Builder(action = generate_config_header,
- emitter = generate_config_header_emitter)
-
env.Append(BUILDERS = {'GenerateMultiarrayApi' : array_api_gen_bld,
'GenerateUfuncApi' : ufunc_api_gen_bld,
'GenerateFromTemplate' : template_bld,
- 'GenerateUmath' : umath_bld,
- 'GenerateConfigHeader' : config_h_bld})
+ 'GenerateUmath' : umath_bld})
#------------------------
# Generate generated code
@@ -230,8 +225,6 @@
# option ?)
from os.path import join as pjoin
-#config_header = env.GenerateConfigHeader(pjoin(env['build_dir'], 'config.h'), [])
-
scalartypes_src = env.GenerateFromTemplate(
pjoin(env['build_dir'], 'src', 'scalartypes'),
pjoin(env['src_dir'], 'src', 'scalartypes.inc.src'))
Modified: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 13:46:46 UTC (rev 4710)
+++ branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 13:49:39 UTC (rev 4711)
@@ -93,43 +93,6 @@
t = str(target[0]) + '.c'
return ([t], source)
-#-------------------
-# Generate config.h
-#-------------------
-def generate_config_header(target, source, env):
- t = open(str(target[0]), 'w')
- if not env.has_key('CONFIG_H_GEN'):
- # XXX
- assert 0 == 1
- sym = env['CONFIG_H_GEN']
- def write_symbol(define, value):
- if value == 1:
- return "#define %s\n\n" % define
- elif value == 0:
- return "/* #undef %s */\n\n" % define
- elif isstring(value):
- return "#define %s %s\n\n" % (define, value)
- else:
- return "#define %s %s\n\n" % (define, ','.join(value))
- t.writelines([write_symbol(i[0], i[1]) for i in sym])
- t.write('\n')
- t.close()
-
- print 'File: %s' % target[0]
- target_f = open(str(target[0]))
- print target_f.read()
- target_f.close()
- print 'EOF'
- return 0
-
-def generate_config_header_emitter(target, source, env):
- """Add dependency from config list CONFIG_H_GEN to target. Returns
- original target, source tuple unchanged. """
- from SCons.Script import Depends
- d = deepcopy(env['CONFIG_H_GEN']) # copy it
- Depends(target, SCons.Node.Python.Value(d))
- return target, source
-
#-----------------------------------------
# Other functions related to configuration
#-----------------------------------------
From numpy-svn at scipy.org Tue Jan 8 08:54:17 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 07:54:17 -0600 (CST)
Subject: [Numpy-svn] r4712 - branches/build_with_scons/numpy/core
Message-ID: <20080108135417.7D84A39C112@new.scipy.org>
Author: cdavid
Date: 2008-01-08 07:54:13 -0600 (Tue, 08 Jan 2008)
New Revision: 4712
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Simplify math funcs check in SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:49:39 UTC (rev 4711)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:54:13 UTC (rev 4712)
@@ -71,20 +71,11 @@
# Checking the mathlib and its capabilities
#------------------------------------------
# Function to check:
-mfuncs = [('expl', 'HAVE_LONGDOUBLE_FUNCS'),
- ('expf', 'HAVE_FLOAT_FUNCS'),
- ('log1p', 'HAVE_LOG1P'),
- ('expm1', 'HAVE_EXPM1'),
- ('asinh', 'HAVE_INVERSE_HYPERBOLIC'),
- ('atanhf', 'HAVE_INVERSE_HYPERBOLIC_FLOAT'),
- ('atanhl', 'HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE'),
- ('isnan', 'HAVE_ISNAN'),
- ('isinf', 'HAVE_ISINF'),
- ('rint', 'HAVE_RINT'),
- ]
+mfuncs = ('expl', 'expf', 'log1p', 'expm1', 'asinh', 'atanhf', 'atanhl',
+ 'isnan', 'isinf', 'rint')
# Set value to 1 for each defined function (in math lib)
-mfuncs_defined = dict([(f[0], 0) for f in mfuncs])
+mfuncs_defined = dict([(f, 0) for f in mfuncs])
# TODO: checklib vs checkfunc ?
mlibs = [[], ['m'], ['cpml']]
@@ -101,12 +92,12 @@
"""Check that f is available in mlib, and add the symbol appropriately.
f is expected to be a tuble (symbol, cpp define)."""
- st = config.CheckFunc(f[0], language = 'C')
+ st = config.CheckFunc(f, language = 'C')
if st:
- config_sym.append((f[1], 1))
+ config_sym.append((f, 1))
else:
- config_sym.append((f[1], 0))
- mfuncs_defined[f[0]] = 1
+ config_sym.append((f, 0))
+ mfuncs_defined[f] = 1
for f in mfuncs:
check_func(f)
From numpy-svn at scipy.org Tue Jan 8 09:02:10 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 08:02:10 -0600 (CST)
Subject: [Numpy-svn] r4713 - branches/build_with_scons/numpy/core
Message-ID: <20080108140210.0A78239C046@new.scipy.org>
Author: cdavid
Date: 2008-01-08 08:02:05 -0600 (Tue, 08 Jan 2008)
New Revision: 4713
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
More cleaning of numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 13:54:13 UTC (rev 4712)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 14:02:05 UTC (rev 4713)
@@ -32,7 +32,7 @@
# - 0: #undef definition
# - 1: #define definition
# - string: #define definition value
-config_sym = []
+numpyconfig_sym = []
#---------------
# Checking Types
@@ -41,25 +41,16 @@
st = config.CheckTypeSize(type, includes = include)
type = type.replace(' ', '_')
if st:
- config_sym.append(('SIZEOF_%s' % type.upper(), '%d' % st))
+ numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), '%d' % st))
else:
- config_sym.append(('SIZEOF_%s' % type.upper(), 0))
+ numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), 0))
-check_type('short')
-check_type('int')
-check_type('long')
-check_type('float')
-check_type('double')
-check_type('long double')
-check_type('Py_intptr_t', include = "#include \n")
-check_type('PY_LONG_LONG', include = "#include \n")
+for type in ('short', 'int', 'long', 'float', 'double', 'long double'):
+ check_type(type)
-# TODO: check python extension can be built (in root or here ?)
+for type in ('Py_intptr_t', 'PY_LONG_LONG'):
+ check_type(type, include = "#include \n")
-#-----------------------
-# Checking configuration
-#-----------------------
-
#----------------------
# Checking signal stuff
#----------------------
@@ -67,17 +58,19 @@
config_sym.append(('NPY_NOSMP', '1'))
config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
-#------------------------------------------
-# Checking the mathlib and its capabilities
-#------------------------------------------
-# Function to check:
-mfuncs = ('expl', 'expf', 'log1p', 'expm1', 'asinh', 'atanhf', 'atanhl',
- 'isnan', 'isinf', 'rint')
+#---------------------
+# Checking SMP option
+#---------------------
+if define_no_smp():
+ config_sym.append(('NPY_NOSMP', '1'))
+ config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
+else:
+ config_sym.append(('NPY_NOSMP', '0'))
+ config.Define('NPY_NOSMP', 0, "define to 1 to disable SMP support ")
-# Set value to 1 for each defined function (in math lib)
-mfuncs_defined = dict([(f, 0) for f in mfuncs])
-
-# TODO: checklib vs checkfunc ?
+#----------------------
+# Checking the mathlib
+#----------------------
mlibs = [[], ['m'], ['cpml']]
mathlib = os.environ.get('MATHLIB')
if mathlib:
@@ -88,15 +81,22 @@
# XXX: this is ugly: mathlib has nothing to do in a public header file
config_sym.append(('MATHLIB', ','.join(mlib)))
+#----------------------------------
+# Checking the math funcs available
+#----------------------------------
+# Function to check:
+mfuncs = ('expl', 'expf', 'log1p', 'expm1', 'asinh', 'atanhf', 'atanhl',
+ 'isnan', 'isinf', 'rint')
+
+# Set value to 1 for each defined function (in math lib)
+mfuncs_defined = dict([(f, 0) for f in mfuncs])
+
+# TODO: checklib vs checkfunc ?
def check_func(f):
"""Check that f is available in mlib, and add the symbol appropriately.
f is expected to be a tuble (symbol, cpp define)."""
st = config.CheckFunc(f, language = 'C')
- if st:
- config_sym.append((f, 1))
- else:
- config_sym.append((f, 0))
mfuncs_defined[f] = 1
for f in mfuncs:
@@ -128,30 +128,18 @@
"Define to a function to use as a replacement for "\
"PyOS_ascii_strtod if not available in python header")
-# XXX: would be better to check for PyOS_ascii_strod instead of version
-if sys.version[:3] < '2.4':
- if config.CheckFunc('strtod'):
- config_sym.append(('PyOS_ascii_strtod', 'strtod'))
-
-if define_no_smp():
- config_sym.append(('NPY_NOSMP', '1'))
- config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
-else:
- config_sym.append(('NPY_NOSMP', '0'))
- config.Define('NPY_NOSMP', 0, "define to 1 to disable SMP support ")
-
+#------------------------------------
+# DISTUTILS Hack on AMD64 on windows
+#------------------------------------
# XXX: this is ugly
-distutils_use_sdk = 0
if sys.platform=='win32' or os.name=='nt':
from distutils.msvccompiler import get_build_architecture
a = get_build_architecture()
print 'BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % (a, os.name, sys.platform)
if a == 'AMD64':
distutils_use_sdk = 1
-if distutils_use_sdk:
- moredefs.append('DISTUTILS_USE_SDK')
- config.Define('DISTUTILS_USE_SDK', distutils_use_sdk,
- "define to 1 to disable SMP support ")
+ config.Define('DISTUTILS_USE_SDK', distutils_use_sdk,
+ "define to 1 to disable SMP support ")
#--------------
# Checking Blas
@@ -173,7 +161,7 @@
#---------------------------------------
config_dict = {}
# XXX: this is ugly, make the API for config.h and numpyconfig.h similar
-for key, value in config_sym:
+for key, value in numpyconfig_sym:
config_dict['@%s@' % key] = str(value)
env['SUBST_DICT'] = config_dict
@@ -181,7 +169,7 @@
env.SubstInFile(pjoin(env['build_dir'], 'numpyconfig.h'),
pjoin(env['src_dir'], include_dir, 'numpyconfig.h.in'))
-env['CONFIG_H_GEN'] = config_sym
+env['CONFIG_H_GEN'] = numpyconfig_sym
#---------------------------
# Builder for generated code
From numpy-svn at scipy.org Tue Jan 8 09:11:58 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 08:11:58 -0600 (CST)
Subject: [Numpy-svn] r4714 - branches/build_with_scons/numpy/core
Message-ID: <20080108141158.3A7CA39C046@new.scipy.org>
Author: cdavid
Date: 2008-01-08 08:11:53 -0600 (Tue, 08 Jan 2008)
New Revision: 4714
Modified:
branches/build_with_scons/numpy/core/SConstruct
branches/build_with_scons/numpy/core/scons_support.py
Log:
Trivial cleanings in numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 14:02:05 UTC (rev 4713)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 14:11:53 UTC (rev 4714)
@@ -24,10 +24,12 @@
#=======================
# Starting Configuration
#=======================
-# XXX: separate env for configuration
config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib,
'CheckCBLAS' : CheckCBLAS}, config_h = pjoin(env['build_dir'], 'config.h'))
+# numpyconfig_sym will keep the values of some configuration variables, the one
+# needed for the public numpy API.
+
# Convention: list of tuples (definition, value). value:
# - 0: #undef definition
# - 1: #define definition
Modified: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 14:02:05 UTC (rev 4713)
+++ branches/build_with_scons/numpy/core/scons_support.py 2008-01-08 14:11:53 UTC (rev 4714)
@@ -1,7 +1,7 @@
#! Last Change: Tue Jan 08 10:00 PM 2008 J
-__docstring__ = """Code to support special facilities to scons which are only
-useful for numpy.core, hence not put into numpy.distutils.scons"""
+"""Code to support special facilities to scons which are only useful for
+numpy.core, hence not put into numpy.distutils.scons"""
import sys
import os
@@ -181,4 +181,3 @@
except KeyError:
nosmp = 0
return nosmp == 1
-
From numpy-svn at scipy.org Tue Jan 8 10:48:43 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 09:48:43 -0600 (CST)
Subject: [Numpy-svn] r4715 - branches/build_with_scons/numpy/core
Message-ID: <20080108154843.49B9039C275@new.scipy.org>
Author: cdavid
Date: 2008-01-08 09:48:36 -0600 (Tue, 08 Jan 2008)
New Revision: 4715
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Fix typo in numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 14:11:53 UTC (rev 4714)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 15:48:36 UTC (rev 4715)
@@ -1,4 +1,4 @@
-# Last Change: Tue Jan 08 10:00 PM 2008 J
+# Last Change: Wed Jan 09 12:00 AM 2008 J
# vim:syntax=python
import os
import sys
@@ -57,17 +57,17 @@
# Checking signal stuff
#----------------------
if is_npy_no_signal():
- config_sym.append(('NPY_NOSMP', '1'))
+ numpyconfig_sym.append(('NPY_NOSMP', '1'))
config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
#---------------------
# Checking SMP option
#---------------------
if define_no_smp():
- config_sym.append(('NPY_NOSMP', '1'))
+ numpyconfig_sym.append(('NPY_NOSMP', '1'))
config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
else:
- config_sym.append(('NPY_NOSMP', '0'))
+ numpyconfig_sym.append(('NPY_NOSMP', '0'))
config.Define('NPY_NOSMP', 0, "define to 1 to disable SMP support ")
#----------------------
@@ -81,7 +81,7 @@
mlib = check_mlibs(config, mlibs)
# XXX: this is ugly: mathlib has nothing to do in a public header file
-config_sym.append(('MATHLIB', ','.join(mlib)))
+numpyconfig_sym.append(('MATHLIB', ','.join(mlib)))
#----------------------------------
# Checking the math funcs available
From numpy-svn at scipy.org Tue Jan 8 10:56:51 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 09:56:51 -0600 (CST)
Subject: [Numpy-svn] r4716 - branches/build_with_scons/numpy/core
Message-ID: <20080108155651.2A35D39C07F@new.scipy.org>
Author: cdavid
Date: 2008-01-08 09:56:46 -0600 (Tue, 08 Jan 2008)
New Revision: 4716
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Trivial cleaning of numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-08 15:48:36 UTC (rev 4715)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-08 15:56:46 UTC (rev 4716)
@@ -63,12 +63,9 @@
#---------------------
# Checking SMP option
#---------------------
-if define_no_smp():
- numpyconfig_sym.append(('NPY_NOSMP', '1'))
- config.Define('NPY_NOSMP', 1, "define to 1 to disable SMP support ")
-else:
- numpyconfig_sym.append(('NPY_NOSMP', '0'))
- config.Define('NPY_NOSMP', 0, "define to 1 to disable SMP support ")
+st = define_no_smp():
+numpyconfig_sym.append(('NPY_NOSMP', st))
+config.Define('NPY_NOSMP', st, "define to 1 to disable SMP support ")
#----------------------
# Checking the mathlib
From numpy-svn at scipy.org Tue Jan 8 18:59:57 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Tue, 8 Jan 2008 17:59:57 -0600 (CST)
Subject: [Numpy-svn] r4717 - trunk/numpy/core
Message-ID: <20080108235957.B4B6E39C062@new.scipy.org>
Author: jarrod.millman
Date: 2008-01-08 17:59:54 -0600 (Tue, 08 Jan 2008)
New Revision: 4717
Modified:
trunk/numpy/core/numeric.py
Log:
typo
Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py 2008-01-08 15:56:46 UTC (rev 4716)
+++ trunk/numpy/core/numeric.py 2008-01-08 23:59:54 UTC (rev 4717)
@@ -667,7 +667,7 @@
fname can be a filename or a file handle. Support for gzipped files is
automatic, if the filename ends in .gz
- See scipy.loadmat to read and write matfiles.
+ See scipy.io.loadmat to read and write matfiles.
Example usage:
From numpy-svn at scipy.org Thu Jan 10 10:52:42 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Thu, 10 Jan 2008 09:52:42 -0600 (CST)
Subject: [Numpy-svn] r4718 - in branches/maskedarray/numpy/ma: . tests
Message-ID: <20080110155242.EA8FD39C1B8@new.scipy.org>
Author: stefan
Date: 2008-01-10 09:52:25 -0600 (Thu, 10 Jan 2008)
New Revision: 4718
Modified:
branches/maskedarray/numpy/ma/core.py
branches/maskedarray/numpy/ma/tests/test_core.py
Log:
Apply patch by Pierre. Move tests from __main__ to the tests directory.
fix_invalid - change the default to copy=True
_MaskedUnaryOperation - make sure the result gets updated from the
input (for subclasses)
_MaskedBinaryOperation - make sure the result gets updated from the
inputs (for subclasses)
_DomainedBinaryOperation - make sure the result gets updated from the
inputs (for subclasses)
MaskedArray.__new__ - added the ndmin keyword
MaskedArray.__getitem__ - works with fields, using the global mask
MaskedArray.__setitem__ - works with fields. The global mask is NOT
updated
MaskedArray.ids - fixed when nomask
MaskedArray.min/.max - force masked to be returned when the whole
array is masked
array - added the ndmin keyword
Modified: branches/maskedarray/numpy/ma/core.py
===================================================================
--- branches/maskedarray/numpy/ma/core.py 2008-01-08 23:59:54 UTC (rev 4717)
+++ branches/maskedarray/numpy/ma/core.py 2008-01-10 15:52:25 UTC (rev 4718)
@@ -14,47 +14,42 @@
:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
-:version: $Id: core.py 3639 2007-12-13 03:39:17Z pierregm $
"""
-__author__ = "Pierre GF Gerard-Marchant ($Author: pierregm $)"
-__version__ = '1.0'
-__revision__ = "$Revision: 3639 $"
-__date__ = '$Date: 2007-12-13 05:39:17 +0200 (Thu, 13 Dec 2007) $'
-
+__author__ = "Pierre GF Gerard-Marchant"
__docformat__ = "restructuredtext en"
__all__ = ['MAError', 'MaskType', 'MaskedArray',
'bool_', 'complex_', 'float_', 'int_', 'object_',
'abs', 'absolute', 'add', 'all', 'allclose', 'allequal', 'alltrue',
- 'amax', 'amin', 'anom', 'anomalies', 'any', 'arange',
- 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2',
- 'arctanh', 'argmax', 'argmin', 'argsort', 'around',
- 'array', 'asarray','asanyarray',
+ 'amax', 'amin', 'anom', 'anomalies', 'any', 'arange',
+ 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2',
+ 'arctanh', 'argmax', 'argmin', 'argsort', 'around',
+ 'array', 'asarray','asanyarray',
'bitwise_and', 'bitwise_or', 'bitwise_xor',
'ceil', 'choose', 'compressed', 'concatenate', 'conjugate',
- 'cos', 'cosh', 'count',
+ 'cos', 'cosh', 'count',
'default_fill_value', 'diagonal', 'divide', 'dump', 'dumps',
'empty', 'empty_like', 'equal', 'exp',
'fabs', 'fmod', 'filled', 'floor', 'floor_divide','fix_invalid',
'getmask', 'getmaskarray', 'greater', 'greater_equal', 'hypot',
'ids', 'inner', 'innerproduct',
- 'isMA', 'isMaskedArray', 'is_mask', 'is_masked', 'isarray',
+ 'isMA', 'isMaskedArray', 'is_mask', 'is_masked', 'isarray',
'left_shift', 'less', 'less_equal', 'load', 'loads', 'log', 'log10',
- 'logical_and', 'logical_not', 'logical_or', 'logical_xor',
+ 'logical_and', 'logical_not', 'logical_or', 'logical_xor',
'make_mask', 'make_mask_none', 'mask_or', 'masked',
- 'masked_array', 'masked_equal', 'masked_greater',
- 'masked_greater_equal', 'masked_inside', 'masked_less',
- 'masked_less_equal', 'masked_not_equal', 'masked_object',
- 'masked_outside', 'masked_print_option', 'masked_singleton',
- 'masked_values', 'masked_where', 'max', 'maximum', 'mean', 'min',
- 'minimum', 'multiply',
+ 'masked_array', 'masked_equal', 'masked_greater',
+ 'masked_greater_equal', 'masked_inside', 'masked_less',
+ 'masked_less_equal', 'masked_not_equal', 'masked_object',
+ 'masked_outside', 'masked_print_option', 'masked_singleton',
+ 'masked_values', 'masked_where', 'max', 'maximum', 'mean', 'min',
+ 'minimum', 'multiply',
'negative', 'nomask', 'nonzero', 'not_equal',
'ones', 'outer', 'outerproduct',
'power', 'product', 'ptp', 'put', 'putmask',
'rank', 'ravel', 'remainder', 'repeat', 'reshape', 'resize',
- 'right_shift', 'round_',
+ 'right_shift', 'round_',
'shape', 'sin', 'sinh', 'size', 'sometrue', 'sort', 'sqrt', 'std',
- 'subtract', 'sum', 'swapaxes',
+ 'subtract', 'sum', 'swapaxes',
'take', 'tan', 'tanh', 'transpose', 'true_divide',
'var', 'where',
'zeros']
@@ -63,7 +58,7 @@
import types
import cPickle
import operator
-#
+
import numpy
from numpy.core import bool_, complex_, float_, int_, object_, str_
@@ -76,22 +71,9 @@
from numpy import array as narray
import warnings
-class NoMask(ndarray):
- def __new__(subtype):
- narray(False)
- return narray(False).view(subtype)
- def no_op(self,*args,**kwargs):
- return self
-
- def __array_finalize__(self,obj):
- obj.flags['WRITEABLE'] = False
-
- def copy(self):
- return self
-
MaskType = bool_
-nomask = NoMask()
+nomask = MaskType(0)
divide_tolerance = 1.e-35
numpy.seterr(all='ignore')
@@ -417,8 +399,10 @@
#
def __call__ (self, a, *args, **kwargs):
"Execute the call behavior."
+ #
m = getmask(a)
d1 = get_data(a)
+ #
if self.domain is not None:
dm = narray(self.domain(d1), copy=False)
m = numpy.logical_or(m, dm)
@@ -429,14 +413,17 @@
# Take care of the masked singletong first ...
if not m.ndim and m:
return masked
- # Get the result..............................
+ # Get the result class .......................
if isinstance(a, MaskedArray):
- result = self.f(d1, *args, **kwargs).view(type(a))
+ subtype = type(a)
else:
- result = self.f(d1, *args, **kwargs).view(MaskedArray)
+ subtype = MaskedArray
+ # Get the result as a view of the subtype ...
+ result = self.f(d1, *args, **kwargs).view(subtype)
# Fix the mask if we don't have a scalar
if result.ndim > 0:
result._mask = m
+ result._update_from(a)
return result
#
def __str__ (self):
@@ -475,6 +462,10 @@
if m is not nomask:
result._mask = make_mask_none(result.shape)
result._mask.flat = m
+ if isinstance(a,MaskedArray):
+ result._update_from(a)
+ if isinstance(b,MaskedArray):
+ result._update_from(b)
elif m:
return masked
return result
@@ -586,6 +577,10 @@
result = self.f(d1, d2).view(get_masked_subclass(a,b))
if result.ndim > 0:
result._mask = m
+ if isinstance(a,MaskedArray):
+ result._update_from(a)
+ if isinstance(b,MaskedArray):
+ result._update_from(b)
return result
def __str__ (self):
@@ -1020,7 +1015,6 @@
cls = type(self.obj)
result = getattr(data, methodname)(*args, **params).view(cls)
result._update_from(self.obj)
- #result._shrinkmask = self.obj._shrinkmask
if result.ndim:
if not self._onmask:
result.__setmask__(mask)
@@ -1064,7 +1058,7 @@
Construction:
x = MaskedArray(data, mask=nomask, dtype=None, copy=True,
- fill_value=None, mask = nomask, fill_value=None, shrink=True)
+ fill_value=None, keep_mask=True, hard_mask=False, shrink=True)
*Parameters*:
data : {var}
@@ -1080,6 +1074,11 @@
copy : {boolean}
Whether to copy the input data (True), or to use a
reference instead. Note: data are NOT copied by default.
+ subok : {True, boolean}
+ Whether to return a subclass of MaskedArray (if possible)
+ or a plain MaskedArray.
+ ndmin : {0, int}
+ Minimum number of dimensions
fill_value : {var}
Value used to fill in the masked values when necessary. If
None, a default based on the datatype is used.
@@ -1089,9 +1088,9 @@
hard_mask : {False, boolean}
Whether to use a hard mask or not. With a hard mask,
masked values cannot be unmasked.
- subok : {True, boolean}
- Whether or not to return a subclass of MaskedArray (if
- possible) or a plain MaskedArray.
+ shrink : {True, boolean}
+ Whether to force compression of an empty mask.
+
"""
@@ -1101,8 +1100,9 @@
_baseclass = numeric.ndarray
def __new__(cls, data=None, mask=nomask, dtype=None, copy=False,
- fill_value=None, keep_mask=True, hard_mask=False, flag=None,
- subok=True, **options):
+ subok=True, ndmin=0, fill_value=None,
+ keep_mask=True, hard_mask=False, flag=None,shrink=True,
+ **options):
"""Create a new masked array from scratch.
Note: you can also create an array with the .view(MaskedArray)
@@ -1114,7 +1114,7 @@
DeprecationWarning)
shrink = flag
# Process data............
- _data = narray(data, dtype=dtype, copy=copy, subok=True)
+ _data = narray(data, dtype=dtype, copy=copy, subok=True, ndmin=ndmin)
_baseclass = getattr(data, '_baseclass', type(_data))
_basedict = getattr(data, '_basedict', getattr(data, '__dict__', None))
if not isinstance(data, MaskedArray) or not subok:
@@ -1128,7 +1128,10 @@
# Process mask ...........
if mask is nomask:
if not keep_mask:
- _data._mask = nomask
+ if shrink:
+ _data._mask = nomask
+ else:
+ _data._mask = make_mask_none(_data)
if copy:
_data._mask = _data._mask.copy()
_data._sharedmask = False
@@ -1183,7 +1186,7 @@
return
#........................
def __array_finalize__(self,obj):
- """Finalize the masked array.
+ """Finalizes the masked array.
"""
# Get main attributes .........
self._mask = getattr(obj, '_mask', nomask)
@@ -1195,7 +1198,6 @@
# Finalize the mask ...........
if self._mask is not nomask:
self._mask.shape = self.shape
-# self._data = self.view(self._baseclass)
return
#..................................
def __array_wrap__(self, obj, context=None):
@@ -1266,7 +1268,10 @@
dout._update_from(self)
# Update the mask if needed
if m is not nomask:
- dout._mask = ndarray.__getitem__(m, indx).reshape(dout.shape)
+ if isinstance(indx, basestring):
+ dout._mask = m.reshape(dout.shape)
+ else:
+ dout._mask = ndarray.__getitem__(m, indx).reshape(dout.shape)
# Note: Don't try to check for m.any(), that'll take too long...
# mask = ndarray.__getitem__(m, indx).reshape(dout.shape)
# if self._shrinkmask and not m.any():
@@ -1287,6 +1292,10 @@
# if getmask(indx) is not nomask:
# msg = "Masked arrays must be filled before they can be used as indices!"
# raise IndexError, msg
+ if isinstance(indx, basestring):
+ ndarray.__setitem__(self._data,indx, getdata(value))
+ warnings.warn("The mask is NOT affected!")
+ return
#....
if value is masked:
m = self._mask
@@ -1794,6 +1803,8 @@
#............................................
def ids (self):
"""Return the addresses of the data and mask areas."""
+ if self._mask is nomask:
+ return (self.ctypes.data, id(nomask))
return (self.ctypes.data, self._mask.ctypes.data)
#............................................
def all(self, axis=None, out=None):
@@ -2282,7 +2293,10 @@
mask = umath.logical_and.reduce(mask.flat)
else:
mask = umath.logical_and.reduce(mask, axis=axis)
- # Get the fil value ...........
+ # Skip if all masked ..........
+ if not mask.ndim and mask:
+ return masked
+ # Get the fill value ...........
if fill_value is None:
fill_value = minimum_fill_value(self)
# Get the data ................
@@ -2290,6 +2304,13 @@
if result.ndim > 0:
result._mask = mask
return result
+
+ def mini(self, axis=None):
+ if axis is None:
+ return minimum(self)
+ else:
+ return minimum.reduce(self, axis)
+
#........................
def max(self, axis=None, fill_value=None):
"""Return the maximum/a along the given axis.
@@ -2315,6 +2336,9 @@
mask = umath.logical_and.reduce(mask.flat)
else:
mask = umath.logical_and.reduce(mask, axis=axis)
+ # Skip if all masked ..........
+ if not mask.ndim and mask:
+ return masked
# Get the fill value ..........
if fill_value is None:
fill_value = maximum_fill_value(self)
@@ -2469,10 +2493,13 @@
masked_array = MaskedArray
-def array(data, dtype=None, copy=False, order=False, mask=nomask, subok=True,
- keep_mask=True, hard_mask=False, fill_value=None, shrink=True):
- """array(data, dtype=None, copy=True, order=False, mask=nomask,
- keep_mask=True, shrink=True, fill_value=None)
+def array(data, dtype=None, copy=False, order=False,
+ mask=nomask, fill_value=None,
+ keep_mask=True, hard_mask=False, shrink=True, subok=True, ndmin=0,
+ ):
+ """array(data, dtype=None, copy=False, order=False, mask=nomask,
+ fill_value=None, keep_mask=True, hard_mask=False, shrink=True,
+ subok=True, ndmin=0)
Acts as shortcut to MaskedArray, with options in a different order
for convenience. And backwards compatibility...
@@ -2481,7 +2508,7 @@
#TODO: we should try to put 'order' somwehere
return MaskedArray(data, mask=mask, dtype=dtype, copy=copy, subok=subok,
keep_mask=keep_mask, hard_mask=hard_mask,
- fill_value=fill_value)
+ fill_value=fill_value, ndmin=ndmin, shrink=shrink)
array.__doc__ = masked_array.__doc__
def is_masked(x):
@@ -2745,8 +2772,9 @@
return data
# OK, so we have to concatenate the masks
dm = numpy.concatenate([getmaskarray(a) for a in arrays], axis)
- shrink = numpy.logical_or.reduce([getattr(a,'_shrinkmask',True) for a in arrays])
- if shrink and not dm.any():
+# shrink = numpy.logical_or.reduce([getattr(a,'_shrinkmask',True) for a in arrays])
+# if shrink and not dm.any():
+ if not dm.any():
data._mask = nomask
else:
data._mask = dm.reshape(d.shape)
@@ -3179,42 +3207,3 @@
"Load a pickle from the current string."""
return cPickle.loads(strg)
-
-
-
-###############################################################################
-#
-if __name__ == '__main__':
- from maskedarray.testutils import assert_equal, assert_almost_equal
-
- if 1:
- x = array([1,2,3,4,5,6])
- mx = array(x, mask=[0,0,0,1,1,1])
- mask = [0,0,1,0,0,1]
- if 1:
- # w/o mask, w/o masked values
- xx = x.copy()
- putmask(xx, mask, 99)
- assert_equal(xx, [1,2,99,4,5,99])
- # w/ mask, w/o masked values
- mxx = mx.copy()
- putmask(mxx, mask, 99)
- assert_equal(mxx._data, [1,2,99,4,5,99])
- assert_equal(mxx._mask, [0,0,0,1,1,0])
- # w/o mask, w/ masked values
- values = array([10,20,30,40,50,60],mask=[1,1,1,0,0,0])
- xx = x.copy()
- putmask(xx, mask, values)
- assert_equal(xx._data, [1,2,30,4,5,60])
- assert_equal(xx._mask, [0,0,1,0,0,0])
- # w/ mask, w/ masked values
- mxx = mx.copy()
- putmask(mxx, mask, values)
- assert_equal(mxx._data, [1,2,30,4,5,60])
- assert_equal(mxx._mask, [0,0,1,1,1,0])
- # w/ mask, w/ masked values + hardmask
- mxx = mx.copy()
- mxx.harden_mask()
- putmask(mxx, mask, values)
- assert_equal(mxx, [1,2,30,4,5,60])
-
Modified: branches/maskedarray/numpy/ma/tests/test_core.py
===================================================================
--- branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-08 23:59:54 UTC (rev 4717)
+++ branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-10 15:52:25 UTC (rev 4718)
@@ -16,6 +16,7 @@
import numpy
import numpy.core.fromnumeric as fromnumeric
from numpy.testing import NumpyTest, NumpyTestCase
+from numpy.testing import set_local_path, restore_path
from numpy.testing.utils import build_err_msg
from numpy import array as narray
@@ -27,7 +28,9 @@
pi = numpy.pi
+set_local_path()
from test_old_ma import *
+restore_path()
class TestNoMask(NumpyTestCase):
def test_no_inplace(self):
@@ -63,7 +66,7 @@
xm.set_fill_value(1.e+20)
self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf)
#........................
- def check_basic1d(self):
+ def test_basic1d(self):
"Test of basic array creation and properties in 1 dimension."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
assert(not isMaskedArray(x))
@@ -81,7 +84,7 @@
assert_array_equal(filled(xm, 1.e20), xf)
assert_array_equal(x, xm)
#........................
- def check_basic2d(self):
+ def test_basic2d(self):
"Test of basic array creation and properties in 2 dimensions."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
for s in [(4,3), (6,2)]:
@@ -101,7 +104,7 @@
assert_equal(filled(xm, 1.e20), xf)
assert_equal(x, xm)
#........................
- def check_basic_arithmetic (self):
+ def test_basic_arithmetic (self):
"Test of basic arithmetic."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
a2d = array([[1,2],[0,4]])
@@ -136,14 +139,14 @@
assert_equal(numpy.multiply(x,y), multiply(xm, ym))
assert_equal(numpy.divide(x,y), divide(xm, ym))
#........................
- def check_mixed_arithmetic(self):
+ def test_mixed_arithmetic(self):
"Tests mixed arithmetics."
na = narray([1])
ma = array([1])
self.failUnless(isinstance(na + ma, MaskedArray))
self.failUnless(isinstance(ma + na, MaskedArray))
#........................
- def check_inplace_arithmetic(self):
+ def test_inplace_arithmetic(self):
"""Test of inplace operations and rich comparisons"""
# addition
x = arange(10)
@@ -256,7 +259,7 @@
#..........................
- def check_scalararithmetic(self):
+ def test_scalararithmetic(self):
"Tests some scalar arithmetics on MaskedArrays."
xm = array(0, mask=1)
assert((1/array(0)).mask)
@@ -270,7 +273,7 @@
assert_equal(x.filled().ctypes.data, x.ctypes.data)
assert_equal(str(xm), str(masked_print_option))
#.........................
- def check_basic_ufuncs (self):
+ def test_basic_ufuncs (self):
"Test various functions such as sin, cos."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
assert_equal(numpy.cos(x), cos(xm))
@@ -296,7 +299,7 @@
assert_equal(numpy.greater_equal(x,y), greater_equal(xm, ym))
assert_equal(numpy.conjugate(x), conjugate(xm))
#........................
- def check_count_func (self):
+ def test_count_func (self):
"Tests count"
ott = array([0.,1.,2.,3.], mask=[1,0,0,0])
assert( isinstance(count(ott), int))
@@ -310,7 +313,7 @@
assert getmask(count(ott,0)) is nomask
assert_equal([1,2],count(ott,0))
#........................
- def check_minmax_func (self):
+ def test_minmax_func (self):
"Tests minimum and maximum."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
xr = numpy.ravel(x) #max doesn't work if shaped
@@ -333,7 +336,7 @@
x[-1,-1] = masked
assert_equal(maximum(x), 2)
- def check_minmax_methods(self):
+ def test_minmax_methods(self):
"Additional tests on max/min"
(_, _, _, _, _, xm, _, _, _, _) = self.d
xm.shape = (xm.size,)
@@ -350,7 +353,7 @@
assert(xm[0].ptp(0) is masked)
assert(xm[0].ptp(-1) is masked)
#........................
- def check_addsumprod (self):
+ def test_addsumprod (self):
"Tests add, sum, product."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
assert_equal(numpy.add.reduce(x), add.reduce(x))
@@ -371,7 +374,7 @@
assert_equal(numpy.sum(x,1), sum(x,1))
assert_equal(numpy.product(x,1), product(x,1))
#.........................
- def check_concat(self):
+ def test_concat(self):
"Tests concatenations."
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
# basic concatenation
@@ -388,7 +391,7 @@
assert_equal(numpy.concatenate((x,y),1), xmym)
assert_equal(numpy.concatenate((xm.mask,ym.mask),1), xmym._mask)
#........................
- def check_indexing(self):
+ def test_indexing(self):
"Tests conversions and indexing"
x1 = numpy.array([1,2,4,3])
x2 = array(x1, mask=[1,0,0,0])
@@ -438,7 +441,7 @@
assert_equal(s1, s2)
assert x1[1:1].shape == (0,)
#........................
- def check_copy(self):
+ def test_copy(self):
"Tests of some subtle points of copying and sizing."
n = [0,0,1,0,0]
m = make_mask(n)
@@ -506,7 +509,7 @@
assert_not_equal(y._data.ctypes.data, x._data.ctypes.data)
assert_not_equal(y._mask.ctypes.data, x._mask.ctypes.data)
#........................
- def check_where(self):
+ def test_where(self):
"Test the where function"
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
d = where(xm>2,xm,-9)
@@ -547,7 +550,7 @@
assert z[9] is masked
#........................
- def check_oddfeatures_1(self):
+ def test_oddfeatures_1(self):
"Test of other odd features"
x = arange(20)
x = x.reshape(4,5)
@@ -576,7 +579,7 @@
assert_equal(x,z)
#
#........................
- def check_oddfeatures_2(self):
+ def test_oddfeatures_2(self):
"Tests some more features."
x = array([1.,2.,3.,4.,5.])
c = array([1,1,1,0,0])
@@ -606,14 +609,14 @@
z = where(c, 1, masked)
assert_equal(z, [99, 1, 1, 99, 99, 99])
#........................
- def check_oddfeatures_3(self):
+ def test_oddfeatures_3(self):
"""Tests some generic features."""
atest = ones((10,10,10), dtype=float_)
btest = zeros(atest.shape, MaskType)
ctest = masked_where(btest,atest)
assert_equal(atest,ctest)
#........................
- def check_maskingfunctions(self):
+ def test_maskingfunctions(self):
"Tests masking functions."
x = array([1.,2.,3.,4.,5.])
x[2] = masked
@@ -632,7 +635,7 @@
assert_equal(masked_not_equal(array([2,2,1,2,1], mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,1])
assert_equal(masked_where([1,1,0,0,0], [1,2,3,4,5]), [99,99,3,4,5])
#........................
- def check_TakeTransposeInnerOuter(self):
+ def test_TakeTransposeInnerOuter(self):
"Test of take, transpose, inner, outer products"
x = arange(24)
y = numpy.arange(24)
@@ -652,7 +655,7 @@
assert t[1] == 2
assert t[2] == 3
#.......................
- def check_maskedelement(self):
+ def test_maskedelement(self):
"Test of masked element"
x = arange(6)
x[1] = masked
@@ -665,7 +668,7 @@
#self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)
#self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)
#........................
- def check_scalar(self):
+ def test_scalar(self):
"Checks masking a scalar"
x = masked_array(0)
assert_equal(str(x), '0')
@@ -674,7 +677,7 @@
x = masked_array(0, mask=False)
assert_equal(str(x), '0')
#........................
- def check_usingmasked(self):
+ def test_usingmasked(self):
"Checks that there's no collapsing to masked"
x = masked_array([1,2])
y = x * masked
@@ -687,7 +690,7 @@
assert_equal(y._mask, [True, True])
#........................
- def check_topython(self):
+ def test_topython(self):
"Tests some communication issues with Python."
assert_equal(1, int(array(1)))
assert_equal(1.0, float(array(1)))
@@ -704,7 +707,7 @@
#TODO: self.failIf(bool(array([0,0])))
#TODO: self.failIf(bool(array([0,0],mask=[0,0])))
#........................
- def check_arraymethods(self):
+ def test_arraymethods(self):
"Tests some MaskedArray methods."
a = array([1,3,2])
b = array([1,3,2], mask=[1,0,1])
@@ -723,7 +726,7 @@
assert_equal(a.take([1,2]), a.data.take([1,2]))
assert_equal(m.transpose(), m.data.transpose())
#........................
- def check_basicattributes(self):
+ def test_basicattributes(self):
"Tests some basic array attributes."
a = array([1,3,2])
b = array([1,3,2], mask=[1,0,1])
@@ -734,7 +737,7 @@
assert_equal(a.shape, (3,))
assert_equal(b.shape, (3,))
#........................
- def check_single_element_subscript(self):
+ def test_single_element_subscript(self):
"Tests single element subscripts of Maskedarrays."
a = array([1,3,2])
b = array([1,3,2], mask=[1,0,1])
@@ -742,7 +745,7 @@
assert_equal(b[0].shape, ())
assert_equal(b[1].shape, ())
#........................
- def check_maskcreation(self):
+ def test_maskcreation(self):
"Tests how masks are initialized at the creation of Maskedarrays."
data = arange(24, dtype=float_)
data[[3,6,15]] = masked
@@ -753,7 +756,7 @@
dma_3 = MaskedArray(dma_1, mask=[1,0,0,0]*6)
fail_if_equal(dma_3.mask, dma_1.mask)
- def check_pickling(self):
+ def test_pickling(self):
"Tests pickling"
import cPickle
a = arange(10)
@@ -770,26 +773,26 @@
assert_equal(a_pickled, a)
assert(isinstance(a_pickled._data,numpy.matrix))
#
- def check_fillvalue(self):
+ def test_fillvalue(self):
"Check that we don't lose the fill_value"
data = masked_array([1,2,3],fill_value=-999)
series = data[[0,2,1]]
assert_equal(series._fill_value, data._fill_value)
#
- def check_asarray(self):
+ def test_asarray(self):
(x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
xmm = asarray(xm)
assert_equal(xmm._data, xm._data)
assert_equal(xmm._mask, xm._mask)
#
- def check_fix_invalid(self):
+ def test_fix_invalid(self):
"Checks fix_invalid."
data = masked_array(numpy.sqrt([-1., 0., 1.]), mask=[0,0,1])
data_fixed = fix_invalid(data)
assert_equal(data_fixed._data, [data.fill_value, 0., 1.])
assert_equal(data_fixed._mask, [1., 0., 1.])
#
- def check_imag_real(self):
+ def test_imag_real(self):
xx = array([1+10j,20+2j], mask=[1,0])
assert_equal(xx.imag,[10,2])
assert_equal(xx.imag.filled(), [1e+20,2])
@@ -807,7 +810,7 @@
self.d = (array([1.0, 0, -1, pi/2]*2, mask=[0,1]+[0]*6),
array([1.0, 0, -1, pi/2]*2, mask=[1,0]+[0]*6),)
- def check_testUfuncRegression(self):
+ def test_testUfuncRegression(self):
"Tests new ufuncs on MaskedArrays."
for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate',
'sin', 'cos', 'tan',
@@ -897,7 +900,7 @@
self.d = (x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX)
#------------------------------------------------------
- def check_trace(self):
+ def test_trace(self):
"Tests trace on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
mXdiag = mX.diagonal()
@@ -905,7 +908,7 @@
assert_almost_equal(mX.trace(),
X.trace() - sum(mXdiag.mask*X.diagonal(),axis=0))
- def check_clip(self):
+ def test_clip(self):
"Tests clip on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
clipped = mx.clip(2,8)
@@ -913,7 +916,7 @@
assert_equal(clipped.data,x.clip(2,8))
assert_equal(clipped.data,mx.data.clip(2,8))
- def check_ptp(self):
+ def test_ptp(self):
"Tests ptp on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
(n,m) = X.shape
@@ -927,7 +930,7 @@
assert_equal(mX.ptp(0),cols)
assert_equal(mX.ptp(1),rows)
- def check_swapaxes(self):
+ def test_swapaxes(self):
"Tests swapaxes on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
mXswapped = mX.swapaxes(0,1)
@@ -935,7 +938,7 @@
mXXswapped = mXX.swapaxes(0,2)
assert_equal(mXXswapped.shape,(2,2,3,3))
- def check_cumsumprod(self):
+ def test_cumsumprod(self):
"Tests cumsum & cumprod on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
mXcp = mX.cumsum(0)
@@ -948,7 +951,7 @@
mXcp = mX.cumprod(1)
assert_equal(mXcp.data,mX.filled(1).cumprod(1))
- def check_varstd(self):
+ def test_varstd(self):
"Tests var & std on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
assert_almost_equal(mX.var(axis=None),mX.compressed().var())
@@ -961,7 +964,7 @@
assert_almost_equal(mXvar0[k],mX[:,k].compressed().var())
assert_almost_equal(numpy.sqrt(mXvar0[k]), mX[:,k].compressed().std())
- def check_argmin(self):
+ def test_argmin(self):
"Tests argmin & argmax on MaskedArrays."
(x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d
#
@@ -984,7 +987,7 @@
assert_equal(mX.argmax(1), [2,4,1,1,4,1])
assert_equal(m2X.argmax(1), [2,4,1,1,1,1])
- def check_put(self):
+ def test_put(self):
"Tests put."
d = arange(5)
n = [0,0,0,1,1]
@@ -1015,7 +1018,7 @@
assert_array_equal(x, [0,1,2,3,4,5,6,7,8,9,])
assert_equal(x.mask, [1,0,0,0,1,1,0,0,0,0])
- def check_put_hardmask(self):
+ def test_put_hardmask(self):
"Tests put on hardmask"
d = arange(5)
n = [0,0,0,1,1]
@@ -1024,7 +1027,7 @@
xh.put([4,2,0,1,3],[1,2,3,4,5])
assert_equal(xh._data, [3,4,2,4,5])
- def check_take(self):
+ def test_take(self):
"Tests take"
x = masked_array([10,20,30,40],[0,1,0,1])
assert_equal(x.take([0,0,3]), masked_array([10, 10, 40], [0,0,1]) )
@@ -1038,7 +1041,7 @@
assert_equal(take(x, [0,2], axis=1),
array([[10,30],[40,60]], mask=[[0,1],[1,0]]))
#........................
- def check_anyall(self):
+ def test_anyall(self):
"""Checks the any/all methods/functions."""
x = numpy.array([[ 0.13, 0.26, 0.90],
[ 0.28, 0.33, 0.63],
@@ -1086,7 +1089,7 @@
assert_equal(mXsmall.any(0), numpy.matrix([True, True, False]))
assert_equal(mXsmall.any(1), numpy.matrix([True, True, False]).T)
- def check_keepmask(self):
+ def test_keepmask(self):
"Tests the keep mask flag"
x = masked_array([1,2,3], mask=[1,0,0])
mx = masked_array(x)
@@ -1099,7 +1102,7 @@
mx = masked_array(x, mask=[0,1,0])
assert_equal(mx.mask, [1,1,0])
- def check_hardmask(self):
+ def test_hardmask(self):
"Test hard_mask"
d = arange(5)
n = [0,0,0,1,1]
@@ -1166,7 +1169,7 @@
xh[0:1] = 999
assert_equal(xh._data,[999,1,2,3,4])
- def check_smallmask(self):
+ def test_smallmask(self):
"Checks the behaviour of _smallmask"
a = arange(10)
a[1] = masked
@@ -1179,7 +1182,7 @@
assert_equal(a._mask, zeros(10))
- def check_sort(self):
+ def test_sort(self):
"Test sort"
x = array([1,4,2,3],mask=[0,1,0,0],dtype=numpy.uint8)
#
@@ -1212,7 +1215,7 @@
assert_equal(sortedx._data, [1,2,-2,-1,0])
assert_equal(sortedx._mask, [1,1,0,0,0])
- def check_sort_2d(self):
+ def test_sort_2d(self):
"Check sort of 2D array."
# 2D array w/o mask
a = masked_array([[8,4,1],[2,0,9]])
@@ -1253,7 +1256,7 @@
assert_equal(am, an)
- def check_ravel(self):
+ def test_ravel(self):
"Tests ravel"
a = array([[1,2,3,4,5]], mask=[[0,1,0,0,0]])
aravel = a.ravel()
@@ -1269,7 +1272,7 @@
a = array([1,2,3,4],mask=[0,0,0,0],shrink=False)
assert_equal(a.ravel()._mask, [0,0,0,0])
- def check_reshape(self):
+ def test_reshape(self):
"Tests reshape"
x = arange(4)
x[0] = masked
@@ -1279,7 +1282,7 @@
assert_equal(x.shape, (4,))
assert_equal(x._mask.shape, (4,))
- def check_compressed(self):
+ def test_compressed(self):
"Tests compressed"
a = array([1,2,3,4],mask=[0,0,0,0])
b = a.compressed()
@@ -1290,7 +1293,7 @@
assert_equal(b._data, [2,3,4])
assert_equal(b._mask, nomask)
- def check_tolist(self):
+ def test_tolist(self):
"Tests to list"
x = array(numpy.arange(12))
x[[1,-2]] = masked
@@ -1305,7 +1308,7 @@
assert_equal(xlist[1],[4,5,6,7])
assert_equal(xlist[2],[8,9,None,11])
- def check_squeeze(self):
+ def test_squeeze(self):
"Check squeeze"
data = masked_array([[1,2,3]])
assert_equal(data.squeeze(), [1,2,3])
@@ -1315,7 +1318,7 @@
data = masked_array([[1]], mask=True)
assert(data.squeeze() is masked)
- def check_putmask(self):
+ def test_putmask(self):
x = arange(6)+1
mx = array(x, mask=[0,0,0,1,1,1])
mask = [0,0,1,0,0,1]
@@ -1345,7 +1348,25 @@
putmask(mxx, mask, values)
assert_equal(mxx, [1,2,30,4,5,60])
+ def test_ndmin(self):
+ x = array([1,2,3],mask=[1,0,0], ndmin=2)
+ assert_equal(x.shape,(1,3))
+ assert_equal(x._data,[[1,2,3]])
+ assert_equal(x._mask,[[1,0,0]])
+ def test_sumprod_masked(self):
+ x = masked_array([1,2,3], mask=True)
+ z = x.min()
+ assert(x.sum() is masked)
+ assert(x.prod() is masked)
+
+ def test_fancy_dtype(self):
+ mtype = [('f',float_),('s','|S3')]
+ x = array([(1,'a'),(2,'b'),(numpy.pi,'pi')], dtype=mtype)
+ x[1] = masked
+ x['f'] = 17
+
+
#..............................................................................
###############################################################################
From numpy-svn at scipy.org Thu Jan 10 14:09:51 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Thu, 10 Jan 2008 13:09:51 -0600 (CST)
Subject: [Numpy-svn] r4719 - branches/maskedarray/numpy/ma/tests
Message-ID: <20080110190951.DA5E439C04A@new.scipy.org>
Author: stefan
Date: 2008-01-10 13:09:35 -0600 (Thu, 10 Jan 2008)
New Revision: 4719
Modified:
branches/maskedarray/numpy/ma/tests/test_core.py
Log:
Fix inplace test.
Modified: branches/maskedarray/numpy/ma/tests/test_core.py
===================================================================
--- branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-10 15:52:25 UTC (rev 4718)
+++ branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-10 19:09:35 UTC (rev 4719)
@@ -35,9 +35,9 @@
class TestNoMask(NumpyTestCase):
def test_no_inplace(self):
x = nomask
- def iadd(x):
- x += 1
- self.failUnlessRaises(ValueError,iadd,x)
+ y = x
+ x += 1
+ assert x != y
def test_no_copy(self):
x = nomask
From numpy-svn at scipy.org Thu Jan 10 14:33:27 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Thu, 10 Jan 2008 13:33:27 -0600 (CST)
Subject: [Numpy-svn] r4720 - in branches/maskedarray/numpy/ma: . tests
Message-ID: <20080110193327.8633B39C260@new.scipy.org>
Author: stefan
Date: 2008-01-10 13:33:10 -0600 (Thu, 10 Jan 2008)
New Revision: 4720
Modified:
branches/maskedarray/numpy/ma/core.py
branches/maskedarray/numpy/ma/tests/test_core.py
Log:
Fix concatenation. Closes ticket #642.
Modified: branches/maskedarray/numpy/ma/core.py
===================================================================
--- branches/maskedarray/numpy/ma/core.py 2008-01-10 19:09:35 UTC (rev 4719)
+++ branches/maskedarray/numpy/ma/core.py 2008-01-10 19:33:10 UTC (rev 4720)
@@ -2769,6 +2769,7 @@
for x in arrays:
if getmask(x) is not nomask:
break
+ else:
return data
# OK, so we have to concatenate the masks
dm = numpy.concatenate([getmaskarray(a) for a in arrays], axis)
Modified: branches/maskedarray/numpy/ma/tests/test_core.py
===================================================================
--- branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-10 19:09:35 UTC (rev 4719)
+++ branches/maskedarray/numpy/ma/tests/test_core.py 2008-01-10 19:33:10 UTC (rev 4720)
@@ -1366,7 +1366,19 @@
x[1] = masked
x['f'] = 17
+ def test_concat(self):
+ x=zeros(2)
+ y=array(ones(2),mask=[False,True])
+ z = concatenate((x,y))
+ assert_array_equal(z,[0,0,1,1])
+ assert_array_equal(z.mask,[False,False,False,True])
+
+ z = concatenate((y,x))
+ assert_array_equal(z,[1,1,0,0])
+ assert_array_equal(z.mask,[False,True,False,False])
+
+
#..............................................................................
###############################################################################
From numpy-svn at scipy.org Sun Jan 13 02:42:06 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 13 Jan 2008 01:42:06 -0600 (CST)
Subject: [Numpy-svn] r4721 - branches/build_with_scons/numpy/core
Message-ID: <20080113074206.69CA6C7C00A@new.scipy.org>
Author: cdavid
Date: 2008-01-13 01:41:46 -0600 (Sun, 13 Jan 2008)
New Revision: 4721
Modified:
branches/build_with_scons/numpy/core/numeric.py
Log:
Merge revisions 4706:4720 from the trunk
Modified: branches/build_with_scons/numpy/core/numeric.py
===================================================================
--- branches/build_with_scons/numpy/core/numeric.py 2008-01-10 19:33:10 UTC (rev 4720)
+++ branches/build_with_scons/numpy/core/numeric.py 2008-01-13 07:41:46 UTC (rev 4721)
@@ -667,7 +667,7 @@
fname can be a filename or a file handle. Support for gzipped files is
automatic, if the filename ends in .gz
- See scipy.loadmat to read and write matfiles.
+ See scipy.io.loadmat to read and write matfiles.
Example usage:
From numpy-svn at scipy.org Sun Jan 13 02:44:57 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Sun, 13 Jan 2008 01:44:57 -0600 (CST)
Subject: [Numpy-svn] r4722 - branches/build_with_scons/numpy/core
Message-ID: <20080113074457.C251EC7C00A@new.scipy.org>
Author: cdavid
Date: 2008-01-13 01:44:53 -0600 (Sun, 13 Jan 2008)
New Revision: 4722
Modified:
branches/build_with_scons/numpy/core/SConstruct
Log:
Typo in numpy.core SConstruct
Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct 2008-01-13 07:41:46 UTC (rev 4721)
+++ branches/build_with_scons/numpy/core/SConstruct 2008-01-13 07:44:53 UTC (rev 4722)
@@ -1,4 +1,4 @@
-# Last Change: Wed Jan 09 12:00 AM 2008 J
+# Last Change: Sun Jan 13 04:00 PM 2008 J
# vim:syntax=python
import os
import sys
@@ -63,7 +63,7 @@
#---------------------
# Checking SMP option
#---------------------
-st = define_no_smp():
+st = define_no_smp()
numpyconfig_sym.append(('NPY_NOSMP', st))
config.Define('NPY_NOSMP', st, "define to 1 to disable SMP support ")
From numpy-svn at scipy.org Fri Jan 18 01:24:17 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 00:24:17 -0600 (CST)
Subject: [Numpy-svn] r4723 - branches/build_with_scons
Message-ID: <20080118062417.606DAC7C062@new.scipy.org>
Author: cdavid
Date: 2008-01-18 00:24:13 -0600 (Fri, 18 Jan 2008)
New Revision: 4723
Added:
branches/build_with_scons/test.sh
Log:
Add simple test script to build/test numpy
Added: branches/build_with_scons/test.sh
===================================================================
--- branches/build_with_scons/test.sh 2008-01-13 07:44:53 UTC (rev 4722)
+++ branches/build_with_scons/test.sh 2008-01-18 06:24:13 UTC (rev 4723)
@@ -0,0 +1,18 @@
+# PREFIX=$PWD
+# rm -rf $PREFIX/build
+# rm -rf $PREFIX/tmp
+# MKL=None python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp
+# (cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()")
+
+PREFIX=$PWD
+rm -rf $PREFIX/build
+rm -rf $PREFIX/tmp
+python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp
+(cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()")
+
+# PREFIX=$PWD
+# #rm -rf $PREFIX/build
+# #rm -rf $PREFIX/tmp
+# MKL=None python setupscons.py scons --jobs=4 --silent=2 install --prefix=$PREFIX/tmp
+# (cd $PREFIX/tmp/lib/python2.5/site-packages/numpy/distutils/scons/tests/f2pyext/ && \
+# PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python setup.py scons)
From numpy-svn at scipy.org Fri Jan 18 04:37:33 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 03:37:33 -0600 (CST)
Subject: [Numpy-svn] r4724 - in branches/cleanconfig_rtm/numpy/core: . src
Message-ID: <20080118093733.1DD60C7C0E9@new.scipy.org>
Author: cdavid
Date: 2008-01-18 03:37:27 -0600 (Fri, 18 Jan 2008)
New Revision: 4724
Modified:
branches/cleanconfig_rtm/numpy/core/setup.py
branches/cleanconfig_rtm/numpy/core/src/multiarraymodule.c
Log:
Replace NPY_NO_SIGNAL CPP symbol by __NPY_PRIVATE_NO_SIGNAL for internal code, to avoid clash between public and private config files
Modified: branches/cleanconfig_rtm/numpy/core/setup.py
===================================================================
--- branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 06:24:13 UTC (rev 4723)
+++ branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:37:27 UTC (rev 4724)
@@ -107,7 +107,7 @@
moredefs.append(defsymbol)
if is_npy_no_signal():
- moredefs.append('NPY_NO_SIGNAL')
+ moredefs.append('__NPY_PRIVATE_NO_SIGNAL')
if sys.platform=='win32' or os.name=='nt':
from distutils.msvccompiler import get_build_architecture
Modified: branches/cleanconfig_rtm/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/cleanconfig_rtm/numpy/core/src/multiarraymodule.c 2008-01-18 06:24:13 UTC (rev 4723)
+++ branches/cleanconfig_rtm/numpy/core/src/multiarraymodule.c 2008-01-18 09:37:27 UTC (rev 4724)
@@ -7268,7 +7268,7 @@
}
-#ifndef NPY_NO_SIGNAL
+#ifndef __NPY_PRIVATE_NO_SIGNAL
SIGJMP_BUF _NPY_SIGINT_BUF;
From numpy-svn at scipy.org Fri Jan 18 04:47:45 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 03:47:45 -0600 (CST)
Subject: [Numpy-svn] r4725 - in branches/cleanconfig_rtm/numpy/core: .
include/numpy
Message-ID: <20080118094745.ACA8239C145@new.scipy.org>
Author: cdavid
Date: 2008-01-18 03:47:38 -0600 (Fri, 18 Jan 2008)
New Revision: 4725
Modified:
branches/cleanconfig_rtm/numpy/core/include/numpy/ndarrayobject.h
branches/cleanconfig_rtm/numpy/core/setup.py
Log:
numpy.core: nosmp logic is only needed in public header
Modified: branches/cleanconfig_rtm/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/cleanconfig_rtm/numpy/core/include/numpy/ndarrayobject.h 2008-01-18 09:37:27 UTC (rev 4724)
+++ branches/cleanconfig_rtm/numpy/core/include/numpy/ndarrayobject.h 2008-01-18 09:47:38 UTC (rev 4725)
@@ -16,7 +16,7 @@
#include "numpyconfig.h"
/* Only use thread if configured in config and python supports it */
-#if defined WITH_THREAD && !NPY_NOSMP
+#if defined WITH_THREAD && !NPY_NO_SMP
#define NPY_ALLOW_THREADS 1
#else
#define NPY_ALLOW_THREADS 0
Modified: branches/cleanconfig_rtm/numpy/core/setup.py
===================================================================
--- branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:37:27 UTC (rev 4724)
+++ branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:47:38 UTC (rev 4725)
@@ -23,6 +23,31 @@
header."""
return sys.platform == 'win32'
+def is_npy_no_smp():
+ """Return True if the NPY_NO_SMP symbol must be defined in public
+ header (when SMP support cannot be reliably enabled)."""
+ # Python 2.3 causes a segfault when
+ # trying to re-acquire the thread-state
+ # which is done in error-handling
+ # ufunc code. NPY_ALLOW_C_API and friends
+ # cause the segfault. So, we disable threading
+ # for now.
+ if sys.version[:5] < '2.4.2':
+ nosmp = 1
+ else:
+ # Perhaps a fancier check is in order here.
+ # so that threads are only enabled if there
+ # are actually multiple CPUS? -- but
+ # threaded code can be nice even on a single
+ # CPU so that long-calculating code doesn't
+ # block.
+ try:
+ nosmp = os.environ['NPY_NOSMP']
+ nosmp = 1
+ except KeyError:
+ nosmp = 0
+ return nosmp == 1
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration,dot_join
from numpy.distutils.system_info import get_info, default_lib_dirs
@@ -58,26 +83,6 @@
raise SystemError,"Failed to test configuration. "\
"See previous error messages for more information."
- # Python 2.3 causes a segfault when
- # trying to re-acquire the thread-state
- # which is done in error-handling
- # ufunc code. NPY_ALLOW_C_API and friends
- # cause the segfault. So, we disable threading
- # for now.
- if sys.version[:5] < '2.4.2':
- nosmp = 1
- else:
- # Perhaps a fancier check is in order here.
- # so that threads are only enabled if there
- # are actually multiple CPUS? -- but
- # threaded code can be nice even on a single
- # CPU so that long-calculating code doesn't
- # block.
- try:
- nosmp = os.environ['NPY_NOSMP']
- nosmp = 1
- except KeyError:
- nosmp = 0
moredefs = []
#
mathlibs = []
@@ -127,12 +132,6 @@
target_f.write('#define %s\n' % (d))
else:
target_f.write('#define %s %s\n' % (d[0],d[1]))
- # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
- # support thread support reliably
- if nosmp:
- target_f.write('#define NPY_NOSMP 1\n')
- else:
- target_f.write('#define NPY_NOSMP 0\n')
target_f.close()
print 'File:',target
target_f = open(target)
@@ -399,8 +398,7 @@
('NPY_SIZEOF_FLOAT', 'SIZEOF_FLOAT'),
('NPY_SIZEOF_DOUBLE', 'SIZEOF_DOUBLE'),
('NPY_SIZEOF_LONGDOUBLE', 'SIZEOF_LONG_DOUBLE'),
- ('NPY_SIZEOF_PY_INTPTR_T', 'SIZEOF_PY_INTPTR_T'),
- ('NPY_NOSMP', 'NPY_NOSMP'),]
+ ('NPY_SIZEOF_PY_INTPTR_T', 'SIZEOF_PY_INTPTR_T')]
testcode = ["""
#include
@@ -427,6 +425,13 @@
if is_npy_no_signal():
testcode.append(r' fprintf(f, "\n#define NPY_NO_SIGNAL\n");')
+ # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
+ # support thread support reliably
+ if is_npy_no_smp():
+ target_f.write('#define NPY_NO_SMP 1\n')
+ else:
+ target_f.write('#define NPY_NO_SMP 0\n')
+
tmpcode = r"""
#ifdef PY_LONG_LONG
fprintf(f, "\n#define %s %%d \n", %s);
From numpy-svn at scipy.org Fri Jan 18 04:50:08 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 03:50:08 -0600 (CST)
Subject: [Numpy-svn] r4726 - branches/cleanconfig_rtm/numpy/core
Message-ID: <20080118095008.2C51639C145@new.scipy.org>
Author: cdavid
Date: 2008-01-18 03:50:04 -0600 (Fri, 18 Jan 2008)
New Revision: 4726
Modified:
branches/cleanconfig_rtm/numpy/core/setup.py
Log:
Fix typo
Modified: branches/cleanconfig_rtm/numpy/core/setup.py
===================================================================
--- branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:47:38 UTC (rev 4725)
+++ branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:50:04 UTC (rev 4726)
@@ -428,9 +428,9 @@
# Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
# support thread support reliably
if is_npy_no_smp():
- target_f.write('#define NPY_NO_SMP 1\n')
+ targetcode.append(r'#define NPY_NO_SMP 1')
else:
- target_f.write('#define NPY_NO_SMP 0\n')
+ targetcode.write(r'#define NPY_NO_SMP 0')
tmpcode = r"""
#ifdef PY_LONG_LONG
From numpy-svn at scipy.org Fri Jan 18 04:51:30 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 03:51:30 -0600 (CST)
Subject: [Numpy-svn] r4727 - branches/cleanconfig_rtm/numpy/core
Message-ID: <20080118095130.E0092C7C0F3@new.scipy.org>
Author: cdavid
Date: 2008-01-18 03:51:21 -0600 (Fri, 18 Jan 2008)
New Revision: 4727
Modified:
branches/cleanconfig_rtm/numpy/core/setup.py
Log:
Fix more typo
Modified: branches/cleanconfig_rtm/numpy/core/setup.py
===================================================================
--- branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:50:04 UTC (rev 4726)
+++ branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:51:21 UTC (rev 4727)
@@ -428,9 +428,9 @@
# Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
# support thread support reliably
if is_npy_no_smp():
- targetcode.append(r'#define NPY_NO_SMP 1')
+ testcode.append(r'#define NPY_NO_SMP 1')
else:
- targetcode.write(r'#define NPY_NO_SMP 0')
+ testcode.write(r'#define NPY_NO_SMP 0')
tmpcode = r"""
#ifdef PY_LONG_LONG
From numpy-svn at scipy.org Fri Jan 18 04:59:45 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 03:59:45 -0600 (CST)
Subject: [Numpy-svn] r4728 - branches/cleanconfig_rtm/numpy/core
Message-ID: <20080118095945.3C4C939C145@new.scipy.org>
Author: cdavid
Date: 2008-01-18 03:59:41 -0600 (Fri, 18 Jan 2008)
New Revision: 4728
Modified:
branches/cleanconfig_rtm/numpy/core/setup.py
Log:
Correct logic to write NPY_NO_SMP symbol in config file
Modified: branches/cleanconfig_rtm/numpy/core/setup.py
===================================================================
--- branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:51:21 UTC (rev 4727)
+++ branches/cleanconfig_rtm/numpy/core/setup.py 2008-01-18 09:59:41 UTC (rev 4728)
@@ -428,9 +428,9 @@
# Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
# support thread support reliably
if is_npy_no_smp():
- testcode.append(r'#define NPY_NO_SMP 1')
+ testcode.append(r' fprintf(f, "#define NPY_NO_SMP 1\n");')
else:
- testcode.write(r'#define NPY_NO_SMP 0')
+ testcode.append(r' fprintf(f, "#define NPY_NO_SMP 0\n");')
tmpcode = r"""
#ifdef PY_LONG_LONG
From numpy-svn at scipy.org Fri Jan 18 05:05:12 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 04:05:12 -0600 (CST)
Subject: [Numpy-svn] r4729 - in branches/build_with_scons/numpy/core: .
include/numpy src
Message-ID: <20080118100512.3348E39C145@new.scipy.org>
Author: cdavid
Date: 2008-01-18 04:04:48 -0600 (Fri, 18 Jan 2008)
New Revision: 4729
Modified:
branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h
branches/build_with_scons/numpy/core/setup.py
branches/build_with_scons/numpy/core/src/multiarraymodule.c
Log:
Merge changes in cleanconfig_rtm
Modified: branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h 2008-01-18 09:59:41 UTC (rev 4728)
+++ branches/build_with_scons/numpy/core/include/numpy/ndarrayobject.h 2008-01-18 10:04:48 UTC (rev 4729)
@@ -16,7 +16,7 @@
#include "numpyconfig.h"
/* Only use thread if configured in config and python supports it */
-#if defined WITH_THREAD && !NPY_NOSMP
+#if defined WITH_THREAD && !NPY_NO_SMP
#define NPY_ALLOW_THREADS 1
#else
#define NPY_ALLOW_THREADS 0
Modified: branches/build_with_scons/numpy/core/setup.py
===================================================================
--- branches/build_with_scons/numpy/core/setup.py 2008-01-18 09:59:41 UTC (rev 4728)
+++ branches/build_with_scons/numpy/core/setup.py 2008-01-18 10:04:48 UTC (rev 4729)
@@ -23,6 +23,31 @@
header."""
return sys.platform == 'win32'
+def is_npy_no_smp():
+ """Return True if the NPY_NO_SMP symbol must be defined in public
+ header (when SMP support cannot be reliably enabled)."""
+ # Python 2.3 causes a segfault when
+ # trying to re-acquire the thread-state
+ # which is done in error-handling
+ # ufunc code. NPY_ALLOW_C_API and friends
+ # cause the segfault. So, we disable threading
+ # for now.
+ if sys.version[:5] < '2.4.2':
+ nosmp = 1
+ else:
+ # Perhaps a fancier check is in order here.
+ # so that threads are only enabled if there
+ # are actually multiple CPUS? -- but
+ # threaded code can be nice even on a single
+ # CPU so that long-calculating code doesn't
+ # block.
+ try:
+ nosmp = os.environ['NPY_NOSMP']
+ nosmp = 1
+ except KeyError:
+ nosmp = 0
+ return nosmp == 1
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration,dot_join
from numpy.distutils.system_info import get_info, default_lib_dirs
@@ -58,26 +83,6 @@
raise SystemError,"Failed to test configuration. "\
"See previous error messages for more information."
- # Python 2.3 causes a segfault when
- # trying to re-acquire the thread-state
- # which is done in error-handling
- # ufunc code. NPY_ALLOW_C_API and friends
- # cause the segfault. So, we disable threading
- # for now.
- if sys.version[:5] < '2.4.2':
- nosmp = 1
- else:
- # Perhaps a fancier check is in order here.
- # so that threads are only enabled if there
- # are actually multiple CPUS? -- but
- # threaded code can be nice even on a single
- # CPU so that long-calculating code doesn't
- # block.
- try:
- nosmp = os.environ['NPY_NOSMP']
- nosmp = 1
- except KeyError:
- nosmp = 0
moredefs = []
#
mathlibs = []
@@ -107,7 +112,7 @@
moredefs.append(defsymbol)
if is_npy_no_signal():
- moredefs.append('NPY_NO_SIGNAL')
+ moredefs.append('__NPY_PRIVATE_NO_SIGNAL')
if sys.platform=='win32' or os.name=='nt':
from distutils.msvccompiler import get_build_architecture
@@ -127,12 +132,6 @@
target_f.write('#define %s\n' % (d))
else:
target_f.write('#define %s %s\n' % (d[0],d[1]))
- # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
- # support thread support reliably
- if nosmp:
- target_f.write('#define NPY_NOSMP 1\n')
- else:
- target_f.write('#define NPY_NOSMP 0\n')
target_f.close()
print 'File:',target
target_f = open(target)
@@ -399,8 +398,7 @@
('NPY_SIZEOF_FLOAT', 'SIZEOF_FLOAT'),
('NPY_SIZEOF_DOUBLE', 'SIZEOF_DOUBLE'),
('NPY_SIZEOF_LONGDOUBLE', 'SIZEOF_LONG_DOUBLE'),
- ('NPY_SIZEOF_PY_INTPTR_T', 'SIZEOF_PY_INTPTR_T'),
- ('NPY_NOSMP', 'NPY_NOSMP'),]
+ ('NPY_SIZEOF_PY_INTPTR_T', 'SIZEOF_PY_INTPTR_T')]
testcode = ["""
#include
@@ -427,6 +425,13 @@
if is_npy_no_signal():
testcode.append(r' fprintf(f, "\n#define NPY_NO_SIGNAL\n");')
+ # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
+ # support thread support reliably
+ if is_npy_no_smp():
+ testcode.append(r' fprintf(f, "#define NPY_NO_SMP 1\n");')
+ else:
+ testcode.append(r' fprintf(f, "#define NPY_NO_SMP 0\n");')
+
tmpcode = r"""
#ifdef PY_LONG_LONG
fprintf(f, "\n#define %s %%d \n", %s);
Modified: branches/build_with_scons/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/build_with_scons/numpy/core/src/multiarraymodule.c 2008-01-18 09:59:41 UTC (rev 4728)
+++ branches/build_with_scons/numpy/core/src/multiarraymodule.c 2008-01-18 10:04:48 UTC (rev 4729)
@@ -7267,7 +7267,7 @@
}
-#ifndef NPY_NO_SIGNAL
+#ifndef __NPY_PRIVATE_NO_SIGNAL
SIGJMP_BUF _NPY_SIGINT_BUF;
From numpy-svn at scipy.org Fri Jan 18 18:35:15 2008
From: numpy-svn at scipy.org (numpy-svn at scipy.org)
Date: Fri, 18 Jan 2008 17:35:15 -0600 (CST)
Subject: [Numpy-svn] r4730 - in branches/maskedarray: . benchmarks numpy
numpy/core numpy/core/code_generators numpy/core/src
numpy/core/tests numpy/distutils numpy/distutils/command
numpy/distutils/fcompiler numpy/doc numpy/doc/html
numpy/doc/swig/test numpy/f2py numpy/f2py/lib/parser
numpy/fft/tests numpy/lib numpy/lib/src numpy/lib/tests
numpy/linalg numpy/numarray numpy/oldnumeric
numpy/random/tests numpy/testing numpy/tests
Message-ID: <20080118233515.D84B639C0BA@new.scipy.org>
Author: stefan
Date: 2008-01-18 17:25:32 -0600 (Fri, 18 Jan 2008)
New Revision: 4730
Added:
branches/maskedarray/numpy/lib/_datasource.py
branches/maskedarray/numpy/lib/format.py
branches/maskedarray/numpy/lib/io.py
branches/maskedarray/numpy/lib/tests/test_format.py
Modified:
branches/maskedarray/
branches/maskedarray/benchmarks/benchmark.py
branches/maskedarray/benchmarks/creating.py
branches/maskedarray/benchmarks/simpleindex.py
branches/maskedarray/benchmarks/sorting.py
branches/maskedarray/numpy/__init__.py
branches/maskedarray/numpy/_import_tools.py
branches/maskedarray/numpy/add_newdocs.py
branches/maskedarray/numpy/core/code_generators/generate_umath.py
branches/maskedarray/numpy/core/code_generators/multiarray_api_order.txt
branches/maskedarray/numpy/core/defmatrix.py
branches/maskedarray/numpy/core/numeric.py
branches/maskedarray/numpy/core/records.py
branches/maskedarray/numpy/core/src/arrayobject.c
branches/maskedarray/numpy/core/src/arraytypes.inc.src
branches/maskedarray/numpy/core/src/multiarraymodule.c
branches/maskedarray/numpy/core/src/scalartypes.inc.src
branches/maskedarray/numpy/core/src/umathmodule.c.src
branches/maskedarray/numpy/core/tests/test_multiarray.py
branches/maskedarray/numpy/core/tests/test_regression.py
branches/maskedarray/numpy/core/tests/test_scalarmath.py
branches/maskedarray/numpy/core/tests/test_ufunc.py
branches/maskedarray/numpy/core/tests/test_umath.py
branches/maskedarray/numpy/distutils/command/build_src.py
branches/maskedarray/numpy/distutils/exec_command.py
branches/maskedarray/numpy/distutils/fcompiler/intel.py
branches/maskedarray/numpy/distutils/interactive.py
branches/maskedarray/numpy/distutils/log.py
branches/maskedarray/numpy/doc/DISTUTILS.txt
branches/maskedarray/numpy/doc/HOWTO_DOCUMENT.txt
branches/maskedarray/numpy/doc/example.py
branches/maskedarray/numpy/doc/html/epydoc.css
branches/maskedarray/numpy/doc/html/epydoc.js
branches/maskedarray/numpy/doc/html/example-module.html
branches/maskedarray/numpy/doc/html/example-pysrc.html
branches/maskedarray/numpy/doc/html/help.html
branches/maskedarray/numpy/doc/html/identifier-index.html
branches/maskedarray/numpy/doc/html/module-tree.html
branches/maskedarray/numpy/doc/html/toc-everything.html
branches/maskedarray/numpy/doc/html/toc-example-module.html
branches/maskedarray/numpy/doc/html/toc.html
branches/maskedarray/numpy/doc/swig/test/testArray.py
branches/maskedarray/numpy/doc/swig/test/testFarray.py
branches/maskedarray/numpy/doc/swig/test/testMatrix.py
branches/maskedarray/numpy/doc/swig/test/testTensor.py
branches/maskedarray/numpy/doc/swig/test/testVector.py
branches/maskedarray/numpy/f2py/f90mod_rules.py
branches/maskedarray/numpy/f2py/lib/parser/block_statements.py
branches/maskedarray/numpy/fft/tests/test_fftpack.py
branches/maskedarray/numpy/lib/__init__.py
branches/maskedarray/numpy/lib/arraysetops.py
branches/maskedarray/numpy/lib/getlimits.py
branches/maskedarray/numpy/lib/index_tricks.py
branches/maskedarray/numpy/lib/scimath.py
branches/maskedarray/numpy/lib/src/_compiled_base.c
branches/maskedarray/numpy/lib/tests/test_arraysetops.py
branches/maskedarray/numpy/lib/tests/test_getlimits.py
branches/maskedarray/numpy/lib/tests/test_polynomial.py
branches/maskedarray/numpy/lib/utils.py
branches/maskedarray/numpy/linalg/info.py
branches/maskedarray/numpy/linalg/linalg.py
branches/maskedarray/numpy/matlib.py
branches/maskedarray/numpy/numarray/functions.py
branches/maskedarray/numpy/oldnumeric/functions.py
branches/maskedarray/numpy/oldnumeric/typeconv.py
branches/maskedarray/numpy/random/tests/test_random.py
branches/maskedarray/numpy/testing/numpytest.py
branches/maskedarray/numpy/testing/utils.py
branches/maskedarray/numpy/tests/test_ctypeslib.py
branches/maskedarray/setup.py
Log:
Merge maskedarray branch up to r4729.
Property changes on: branches/maskedarray
___________________________________________________________________
Name: svnmerge-integrated
- /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
+ /branches/build_with_scons:1-4676 /branches/cleanconfig_rtm:1-4610 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871
Modified: branches/maskedarray/benchmarks/benchmark.py
===================================================================
--- branches/maskedarray/benchmarks/benchmark.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/benchmarks/benchmark.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -17,7 +17,7 @@
modules = [module]
for m in modules:
- setup_str = 'import %s; import %s as N; ' % (m,m) \
+ setup_str = 'import %s; import %s as np; ' % (m,m) \
+ setup_str
self.module_test[m] = Timer(test_str, setup_str)
Modified: branches/maskedarray/benchmarks/creating.py
===================================================================
--- branches/maskedarray/benchmarks/creating.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/benchmarks/creating.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -7,8 +7,8 @@
title='Creating %s zeros.' % N,
runs=3,reps=10000)
-b['numpy'] = ('a=N.zeros(shape,type)', 'shape=%s;type=float' % N)
-b['Numeric'] = ('a=N.zeros(shape,type)', 'shape=%s;type=N.Float' % N)
-b['numarray'] = ('a=N.zeros(shape,type)', "shape=%s;type=N.Float" % N)
+b['numpy'] = ('a=np.zeros(shape,type)', 'shape=%s;type=float' % N)
+b['Numeric'] = ('a=np.zeros(shape,type)', 'shape=%s;type=np.Float' % N)
+b['numarray'] = ('a=np.zeros(shape,type)', "shape=%s;type=np.Float" % N)
b.run()
Modified: branches/maskedarray/benchmarks/simpleindex.py
===================================================================
--- branches/maskedarray/benchmarks/simpleindex.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/benchmarks/simpleindex.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -5,21 +5,25 @@
# in the first place.
N = 30
+
code2 = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k,l].item() + a[l,k].item()
""" % (N,N)
+
code3 = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k][l] + a[l][k]
""" % (N,N)
+
code = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k,l] + a[l,k]
""" % (N,N)
+
setup3 = r"""
import random
a = [[None for k in xrange(%d)] for l in xrange(%d)]
@@ -27,16 +31,19 @@
for l in xrange(%d):
a[k][l] = random.random()
""" % (N,N,N,N)
-t1 = timeit.Timer(code, 'import numpy as N; a = N.random.rand(%d,%d)' % (N,N))
-t2 = timeit.Timer(code, 'import MLab as N; a=N.rand(%d,%d)' % (N,N))
-t3 = timeit.Timer(code, 'import numarray.mlab as N; a=N.rand(%d,%d)' % (N,N))
-t4 = timeit.Timer(code2, 'import numpy as N; a = N.random.rand(%d,%d)' % (N,N))
-t5 = timeit.Timer(code3, setup3)
-t6 = timeit.Timer("res = a + a.transpose()","import numpy as N; a=N.random.rand(%d,%d)" % (N,N))
+
+numpy_timer1 = timeit.Timer(code, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
+numeric_timer = timeit.Timer(code, 'import MLab as np; a=np.rand(%d,%d)' % (N,N))
+numarray_timer = timeit.Timer(code, 'import numarray.mlab as np; a=np.rand(%d,%d)' % (N,N))
+numpy_timer2 = timeit.Timer(code2, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
+python_timer = timeit.Timer(code3, setup3)
+numpy_timer3 = timeit.Timer("res = a + a.transpose()","import numpy as np; a=np.random.rand(%d,%d)" % (N,N))
+
print "shape = ", (N,N)
-print "NumPy 1: ", t1.repeat(3,100)
-print "NumPy 2: ", t4.repeat(3,100)
-print "Numeric: ", t2.repeat(3,100)
-print "Numarray: ", t3.repeat(3,100)
-print "Python: ", t5.repeat(3,100)
-print "Optimized: ", t6.repeat(3,100)
+print "NumPy 1: ", numpy_timer1.repeat(3,100)
+print "NumPy 2: ", numpy_timer2.repeat(3,100)
+print "Numeric: ", numeric_timer.repeat(3,100)
+print "Numarray: ", numarray_timer.repeat(3,100)
+print "Python: ", python_timer.repeat(3,100)
+print "Optimized: ", numpy_timer3.repeat(3,100)
+
Modified: branches/maskedarray/benchmarks/sorting.py
===================================================================
--- branches/maskedarray/benchmarks/sorting.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/benchmarks/sorting.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -5,21 +5,21 @@
N = 10000
b.title = 'Sorting %d elements' % N
-b['numarray'] = ('a=N.array(None,shape=%d,typecode="i");a.sort()'%N,'')
-b['numpy'] = ('a=N.empty(shape=%d, dtype="i");a.sort()'%N,'')
-b['Numeric'] = ('a=N.empty(shape=%d, typecode="i");N.sort(a)'%N,'')
+b['numarray'] = ('a=np.array(None,shape=%d,typecode="i");a.sort()'%N,'')
+b['numpy'] = ('a=np.empty(shape=%d, dtype="i");a.sort()'%N,'')
+b['Numeric'] = ('a=np.empty(shape=%d, typecode="i");np.sort(a)'%N,'')
b.run()
N1,N2 = 100,100
b.title = 'Sorting (%d,%d) elements, last axis' % (N1,N2)
-b['numarray'] = ('a=N.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'')
-b['numpy'] = ('a=N.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'')
-b['Numeric'] = ('a=N.empty(shape=(%d,%d),typecode="i");N.sort(a)'%(N1,N2),'')
+b['numarray'] = ('a=np.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'')
+b['numpy'] = ('a=np.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'')
+b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a)'%(N1,N2),'')
b.run()
N1,N2 = 100,100
b.title = 'Sorting (%d,%d) elements, first axis' % (N1,N2)
-b['numarray'] = ('a=N.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'')
-b['numpy'] = ('a=N.empty(shape=(%d,%d),dtype="i");N.sort(a,0)'%(N1,N2),'')
-b['Numeric'] = ('a=N.empty(shape=(%d,%d),typecode="i");N.sort(a,0)'%(N1,N2),'')
+b['numarray'] = ('a=np.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'')
+b['numpy'] = ('a=np.empty(shape=(%d,%d),dtype="i");np.sort(a,0)'%(N1,N2),'')
+b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a,0)'%(N1,N2),'')
b.run()
Modified: branches/maskedarray/numpy/__init__.py
===================================================================
--- branches/maskedarray/numpy/__init__.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/__init__.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1,4 +1,4 @@
-"""\
+"""
NumPy
==========
@@ -7,25 +7,29 @@
http://www.trelgol.com
-It is being distributed for a fee for only a few years to
+It is being distributed for a fee until Oct. 2010 to
cover some of the costs of development. After the restriction period
it will also be freely available.
-Additional documentation is available in the docstrings and at
+Documentation is available in the docstrings and at
http://www.scipy.org.
"""
+# We first need to detect if we're being called as part of the numpy setup
+# procedure itself in a reliable manner.
try:
- from numpy.__config__ import show as show_config
-except ImportError:
- show_config = None
+ __NUMPY_SETUP__
+except NameError:
+ __NUMPY_SETUP__ = False
-if show_config is None:
+
+if __NUMPY_SETUP__:
import sys as _sys
print >> _sys.stderr, 'Running from numpy source directory.'
del _sys
else:
+ from numpy.__config__ import show as show_config
from version import version as __version__
from _import_tools import PackageLoader
@@ -34,6 +38,7 @@
loader = PackageLoader(infunc=True)
return loader(*packages, **options)
+ pkgload.__doc__ = PackageLoader.__call__.__doc__
import testing
from testing import ScipyTest, NumpyTest
import core
@@ -80,8 +85,8 @@
Global symbols from subpackages
-------------------------------
-core --> *
-lib --> *
+core --> * (use numpy.* not numpy.core.*)
+lib --> * (use numpy.* not numpy.lib.*)
testing --> NumpyTest
"""
@@ -95,7 +100,7 @@
import add_newdocs
- __all__.extend(['add_newdocs','test'])
+ __all__.extend(['add_newdocs'])
if __doc__ is not None:
__doc__ += """
Modified: branches/maskedarray/numpy/_import_tools.py
===================================================================
--- branches/maskedarray/numpy/_import_tools.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/_import_tools.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -131,8 +131,6 @@
def __call__(self,*packages, **options):
"""Load one or more packages into parent package top-level namespace.
- Usage:
-
This function is intended to shorten the need to import many
subpackages, say of scipy, constantly with statements such as
@@ -152,22 +150,19 @@
If a name which doesn't exist in scipy's namespace is
given, a warning is shown.
- Inputs:
+ Parameters
+ ----------
+ *packges : arg-tuple
+ the names (one or more strings) of all the modules one
+ wishes to load into the top-level namespace.
+ verbose= : integer
+ verbosity level [default: -1].
+ verbose=-1 will suspend also warnings.
+ force= : bool
+ when True, force reloading loaded packages [default: False].
+ postpone= : bool
+ when True, don't load packages [default: False]
- - the names (one or more strings) of all the numpy modules one
- wishes to load into the top-level namespace.
-
- Optional keyword inputs:
-
- - verbose - integer specifying verbosity level [default: -1].
- verbose=-1 will suspend also warnings.
- - force - when True, force reloading loaded packages
- [default: False].
- - postpone - when True, don't load packages [default: False]
-
- If no input arguments are given, then all of scipy's subpackages
- are imported.
-
"""
frame = self.parent_frame
self.info_modules = {}
Modified: branches/maskedarray/numpy/add_newdocs.py
===================================================================
--- branches/maskedarray/numpy/add_newdocs.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/add_newdocs.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1,3 +1,7 @@
+# This is only meant to add docs to
+# objects defined in C-extension modules.
+# The purpose is to allow easier editing of the
+# docstrings without requiring a re-compile.
from lib import add_newdoc
add_newdoc('numpy.core','dtype',
@@ -132,30 +136,37 @@
Return an array from object with the specified date-type.
- Inputs:
- object - an array, any object exposing the array interface, any
- object whose __array__ method returns an array, or any
- (nested) sequence.
- dtype - The desired data-type for the array. If not given, then
- the type will be determined as the minimum type required
- to hold the objects in the sequence. This argument can only
- be used to 'upcast' the array. For downcasting, use the
- .astype(t) method.
- copy - If true, then force a copy. Otherwise a copy will only occur
- if __array__ returns a copy, obj is a nested sequence, or
- a copy is needed to satisfy any of the other requirements
- order - Specify the order of the array. If order is 'C', then the
- array will be in C-contiguous order (last-index varies the
- fastest). If order is 'FORTRAN', then the returned array
- will be in Fortran-contiguous order (first-index varies the
- fastest). If order is None, then the returned array may
- be in either C-, or Fortran-contiguous order or even
- discontiguous.
- subok - If True, then sub-classes will be passed-through, otherwise
- the returned array will be forced to be a base-class array
- ndmin - Specifies the minimum number of dimensions that the resulting
- array should have. 1's will be pre-pended to the shape as
- needed to meet this requirement.
+ Parameters
+ ----------
+ object : array-like
+ an array, any object exposing the array interface, any
+ object whose __array__ method returns an array, or any
+ (nested) sequence.
+ dtype : data-type
+ The desired data-type for the array. If not given, then
+ the type will be determined as the minimum type required
+ to hold the objects in the sequence. This argument can only
+ be used to 'upcast' the array. For downcasting, use the
+ .astype(t) method.
+ copy : bool
+ If true, then force a copy. Otherwise a copy will only occur
+ if __array__ returns a copy, obj is a nested sequence, or
+ a copy is needed to satisfy any of the other requirements
+ order : {'C', 'F', 'A' (None)}
+ Specify the order of the array. If order is 'C', then the
+ array will be in C-contiguous order (last-index varies the
+ fastest). If order is 'FORTRAN', then the returned array
+ will be in Fortran-contiguous order (first-index varies the
+ fastest). If order is None, then the returned array may
+ be in either C-, or Fortran-contiguous order or even
+ discontiguous.
+ subok : bool
+ If True, then sub-classes will be passed-through, otherwise
+ the returned array will be forced to be a base-class array
+ ndmin : int
+ Specifies the minimum number of dimensions that the resulting
+ array should have. 1's will be pre-pended to the shape as
+ needed to meet this requirement.
""")
@@ -220,14 +231,17 @@
add_newdoc('numpy.core.multiarray','fromfile',
"""fromfile(file=, dtype=float, count=-1, sep='') -> array.
- Required arguments:
- file -- open file object or string containing file name.
+ Parameters
+ ----------
+ file : file or string
+ open file object or string containing file name.
+ dtype : data-type
+ data type of the returned array
+ count : int
+ number of items to read (-1 mean 'all')
+ sep : string
+ separater between items if file is a text file (default "")
- Keyword arguments:
- dtype -- type and order of the returned array (default float)
- count -- number of items to input (default all)
- sep -- separater between items if file is a text file (default "")
-
Return an array of the given data type from a text or binary file. The
'file' argument can be an open file or a string with the name of a file to
read from. If 'count' == -1 the entire file is read, otherwise count is the
@@ -236,7 +250,6 @@
the separator between elements in a text file. The 'dtype' value is also
used to determine the size and order of the items in binary files.
-
Data written using the tofile() method can be conveniently recovered using
this function.
@@ -268,8 +281,8 @@
The tuple of sequences (a1, a2, ...) are joined along the given axis
(default is the first one) into a single numpy array.
- Example:
-
+ Examples
+ --------
>>> concatenate( ([0,1,2], [5,6,7]) )
array([0, 1, 2, 5, 6, 7])
@@ -343,26 +356,29 @@
Return elements from `x` or `y`, depending on `condition`.
- *Parameters*:
- condition : array of bool
- When True, yield x, otherwise yield y.
- x,y : 1-dimensional arrays
- Values from which to choose.
+ Parameters
+ ----------
+ condition : array of bool
+ When True, yield x, otherwise yield y.
+ x,y : 1-dimensional arrays
+ Values from which to choose.
- *Notes*
- This is equivalent to
+ Notes
+ -----
+ This is equivalent to
- [xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
+ [xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
- The result is shaped like `condition` and has elements of `x`
- or `y` where `condition` is respectively True or False.
+ The result is shaped like `condition` and has elements of `x`
+ or `y` where `condition` is respectively True or False.
- In the special case, where only `condition` is given, the
- tuple condition.nonzero() is returned, instead.
+ In the special case, where only `condition` is given, the
+ tuple condition.nonzero() is returned, instead.
- *Examples*
- >>> where([True,False,True],[1,2,3],[4,5,6])
- array([1, 5, 3])
+ Examples
+ --------
+ >>> where([True,False,True],[1,2,3],[4,5,6])
+ array([1, 5, 3])
""")
@@ -379,36 +395,36 @@
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
+ ----------
+ keys : (k,N) array or tuple of (N,) sequences
+ Array containing values that the returned indices should sort.
- keys : (k,N) array or tuple of (N,) sequences
- Array containing values that the returned indices should sort.
+ axis : integer
+ Axis to be indirectly sorted. Default is -1 (i.e. last axis).
- axis : integer
- Axis to be indirectly sorted. Default is -1 (i.e. last axis).
+ Returns
+ -------
+ indices : (N,) integer array
+ Array of indices that sort the keys along the specified axis.
- *Returns*:
+ See Also
+ --------
+ argsort : indirect sort
+ sort : inplace sort
- indices : (N,) integer array
- Array of indices that sort the keys along the specified axis.
+ Examples
+ --------
+ >>> a = [1,5,1,4,3,6,7]
+ >>> b = [9,4,0,4,0,4,3]
+ >>> ind = lexsort((b,a))
+ >>> print ind
+ [2 0 4 3 1 5 6]
+ >>> print take(a,ind)
+ [1 1 3 4 5 6 7]
+ >>> print take(b,ind)
+ [0 9 0 4 4 4 3]
- *See Also*:
-
- `argsort` : indirect sort
- `sort` : inplace sort
-
- *Examples*
-
- >>> a = [1,5,1,4,3,6,7]
- >>> b = [9,4,0,4,0,4,3]
- >>> ind = lexsort((b,a))
- >>> print ind
- [2 0 4 3 1 5 6]
- >>> print take(a,ind)
- [1 1 3 4 5 6 7]
- >>> print take(b,ind)
- [0 9 0 4 4 4 3]
-
""")
add_newdoc('numpy.core.multiarray','can_cast',
@@ -623,12 +639,13 @@
Return a copy of the array.
- Argument:
- order -- Order of returned copy (default 'C')
- If order is 'C' (False) then the result is contiguous (default).
- If order is 'Fortran' (True) then the result has fortran order.
- If order is 'Any' (None) then the result has fortran order
- only if m is already in fortran order.;
+ Parameters
+ ----------
+ order : {'C', 'F', 'A'}
+ If order is 'C' (False) then the result is contiguous (default).
+ If order is 'Fortran' (True) then the result has fortran order.
+ If order is 'Any' (None) then the result has fortran order
+ only if m is already in fortran order.;
"""))
@@ -650,16 +667,19 @@
add_newdoc('numpy.core.multiarray', 'ndarray', ('__setstate__',
- """a.__setstate__(version, shape, typecode, isfortran, rawdata)
+ """a.__setstate__(version, shape, dtype, isfortran, rawdata)
For unpickling.
- Arguments:
- version -- optional pickle version. If omitted defaults to 0.
- shape -- a tuple giving the shape
- typecode -- a typecode
- isFortran -- a bool stating if Fortran or no
- rawdata -- a binary string with the data (or a list if Object array)
+ Parameters
+ ----------
+ version : int
+ optional pickle version. If omitted defaults to 0.
+ shape : tuple
+ dtype : data-type
+ isFortran : bool
+ rawdata : string or list
+ a binary string with the data (or a list if 'a' is an object array)
"""))
@@ -695,34 +715,32 @@
by the kind keyword. It returns an array of indices of the same shape as
'a' that index data along the given axis in sorted order.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis to be indirectly sorted. None indicates that the flattened
+ array should be used. Default is -1.
+ kind : string
+ Sorting algorithm to use. Possible values are 'quicksort',
+ 'mergesort', or 'heapsort'. Default is 'quicksort'.
+ order : list type or None
+ When a is an array with fields defined, this argument specifies
+ which fields to compare first, second, etc. Not all fields need be
+ specified.
- axis : integer
- Axis to be indirectly sorted. None indicates that the flattened
- array should be used. Default is -1.
+ Returns
+ -------
+ indices : integer array
+ Array of indices that sort 'a' along the specified axis.
- kind : string
- Sorting algorithm to use. Possible values are 'quicksort',
- 'mergesort', or 'heapsort'. Default is 'quicksort'.
+ SeeAlso
+ -------
+ lexsort : indirect stable sort with multiple keys
+ sort : inplace sort
- order : list type or None
- When a is an array with fields defined, this argument specifies
- which fields to compare first, second, etc. Not all fields need be
- specified.
+ Notes
+ -----
- :Returns:
-
- indices : integer array
- Array of indices that sort 'a' along the specified axis.
-
- :SeeAlso:
-
- - lexsort : indirect stable sort with multiple keys
- - sort : inplace sort
-
- :Notes:
- ------
-
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
@@ -803,12 +821,13 @@
Return a copy of the array.
- Argument:
- order -- Order of returned copy (default 'C')
- If order is 'C' (False) then the result is contiguous (default).
- If order is 'Fortran' (True) then the result has fortran order.
- If order is 'Any' (None) then the result has fortran order
- only if m is already in fortran order.;
+ Parameters
+ ----------
+ order : Order of returned copy (default 'C')
+ If order is 'C' (False) then the result is contiguous (default).
+ If order is 'Fortran' (True) then the result has fortran order.
+ If order is 'Any' (None) then the result has fortran order
+ only if m is already in fortran order.;
"""))
@@ -835,30 +854,32 @@
be determined by removing axis1 and axis2 and appending an index to the
right equal to the size of the resulting diagonals.
- :Parameters:
- offset : integer
- Offset of the diagonal from the main diagonal. Can be both positive
- and negative. Defaults to main diagonal.
- axis1 : integer
- Axis to be used as the first axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to first index.
- axis2 : integer
- Axis to be used as the second axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to second index.
+ Parameters
+ ----------
+ offset : integer
+ Offset of the diagonal from the main diagonal. Can be both positive
+ and negative. Defaults to main diagonal.
+ axis1 : integer
+ Axis to be used as the first axis of the 2-d subarrays from which
+ the diagonals should be taken. Defaults to first index.
+ axis2 : integer
+ Axis to be used as the second axis of the 2-d subarrays from which
+ the diagonals should be taken. Defaults to second index.
- :Returns:
- array_of_diagonals : same type as original array
- If a is 2-d, then a 1-d array containing the diagonal is returned.
- If a is n-d, n > 2, then an array of diagonals is returned.
+ Returns
+ -------
+ array_of_diagonals : same type as original array
+ If a is 2-d, then a 1-d array containing the diagonal is returned.
+ If a is n-d, n > 2, then an array of diagonals is returned.
- :SeeAlso:
- - diag : matlab workalike for 1-d and 2-d arrays.
- - diagflat : creates diagonal arrays
- - trace : sum along diagonals
+ SeeAlso
+ -------
+ diag : matlab workalike for 1-d and 2-d arrays.
+ diagflat : creates diagonal arrays
+ trace : sum along diagonals
Examples
--------
-
>>> a = arange(4).reshape(2,2)
>>> a
array([[0, 1],
@@ -943,39 +964,36 @@
Returns the average of the array elements. The average is taken over the
flattened array by default, otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the means are computed. The default is
+ to compute the standard deviation of the flattened array.
+ dtype : type
+ Type to use in computing the means. For arrays of
+ integer type the default is float32, for arrays of float types it
+ is the same as the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must have
+ the same shape as the expected output but the type will be cast if
+ necessary.
- axis : integer
- Axis along which the means are computed. The default is
- to compute the standard deviation of the flattened array.
+ Returns
+ -------
+ mean : The return type varies, see above.
+ A new array holding the result is returned unless out is specified,
+ in which case a reference to out is returned.
- dtype : type
- Type to use in computing the means. For arrays of
- integer type the default is float32, for arrays of float types it
- is the same as the array type.
+ SeeAlso
+ -------
+ var : variance
+ std : standard deviation
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
-
- :Returns:
-
- mean : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
-
- :SeeAlso:
-
- - var : variance
- - std : standard deviation
-
Notes
-----
+ The mean is the sum of the elements along the axis divided by the
+ number of elements.
- The mean is the sum of the elements along the axis divided by the
- number of elements.
-
"""))
@@ -1070,14 +1088,17 @@
add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
- """a.round(decimals=0, out=None) -> out (a). Rounds to 'decimals' places.
+ """a.round(decimals=0, out=None) -> out (new). Rounds to 'decimals' places.
- Keyword arguments:
- decimals -- number of decimals to round to (default 0). May be negative.
- out -- existing array to use for output (default a).
+ Parameters
+ ----------
+ decimals : integer
+ number of decimals to round to. May be negative.
+ out : existing array to use for output (default new array).
- Return:
- Reference to out, where None specifies the original array a.
+ Returns
+ -------
+ Reference to out, where None specifies a new array.
Round to the specified number of decimals. When 'decimals' is negative it
specifies the number of positions to the left of the decimal point. The
@@ -1085,9 +1106,10 @@
is done if the array is not of float type and 'decimals' is >= 0.
The keyword 'out' may be used to specify a different array to hold the
- result rather than the default 'a'. If the type of the array specified by
- 'out' differs from that of 'a', the result is cast to the new type,
- otherwise the original type is kept. Floats round to floats by default.
+ result rather than the default new array. If the type of the array
+ specified by 'out' differs from that of 'a', the result is cast to the
+ new type, otherwise the original type is kept. Floats round to floats
+ by default.
Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to
0.0, etc. Results may also be surprising due to the inexact representation
@@ -1107,31 +1129,28 @@
is out of bounds, then the length of a is returned, i.e., the key would
need to be appended. The returned index array has the same shape as v.
- :Parameters:
+ Parameters
+ ----------
+ v : array or list type
+ Array of keys to be searched for in a.
+ side : string
+ Possible values are : 'left', 'right'. Default is 'left'. Return
+ the first or last index where the key could be inserted.
- v : array or list type
- Array of keys to be searched for in a.
+ Returns
+ -------
+ indices : integer array
+ The returned array has the same shape as v.
- side : string
- Possible values are : 'left', 'right'. Default is 'left'. Return
- the first or last index where the key could be inserted.
-
- :Returns:
-
- indices : integer array
- The returned array has the same shape as v.
-
- :SeeAlso:
-
- - sort
- - histogram
-
- :Notes:
+ SeeAlso
-------
+ sort
+ histogram
- The array a must be 1-d and is assumed to be sorted in ascending order.
- Searchsorted uses binary search to find the required insertion points.
-
+ Notes
+ -----
+ The array a must be 1-d and is assumed to be sorted in ascending order.
+ Searchsorted uses binary search to find the required insertion points.
"""))
@@ -1154,34 +1173,28 @@
Perform an inplace sort along the given axis using the algorithm specified
by the kind keyword.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis to be sorted along. None indicates that the flattened array
+ should be used. Default is -1.
+ kind : string
+ Sorting algorithm to use. Possible values are 'quicksort',
+ 'mergesort', or 'heapsort'. Default is 'quicksort'.
+ order : list type or None
+ When a is an array with fields defined, this argument specifies
+ which fields to compare first, second, etc. Not all fields need be
+ specified.
- axis : integer
- Axis to be sorted along. None indicates that the flattened array
- should be used. Default is -1.
+ SeeAlso
+ -------
+ argsort : indirect sort
+ lexsort : indirect stable sort on multiple keys
+ searchsorted : find keys in sorted array
- kind : string
- Sorting algorithm to use. Possible values are 'quicksort',
- 'mergesort', or 'heapsort'. Default is 'quicksort'.
+ Notes
+ -----
- order : list type or None
- When a is an array with fields defined, this argument specifies
- which fields to compare first, second, etc. Not all fields need be
- specified.
-
- :Returns:
-
- None
-
- :SeeAlso:
-
- - argsort : indirect sort
- - lexsort : indirect stable sort on multiple keys
- - searchsorted : find keys in sorted array
-
- :Notes:
- ------
-
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
@@ -1195,10 +1208,9 @@
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
- All the sort algorithms make temporary copies of the data when the sort is not
- along the last axis. Consequently, sorts along the last axis are faster and use
- less space than sorts along other axis.
-
+ All the sort algorithms make temporary copies of the data when the sort is
+ not along the last axis. Consequently, sorts along the last axis are faster
+ and use less space than sorts along other axis.
"""))
@@ -1215,41 +1227,38 @@
spread of a distribution. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the standard deviation is computed. The default is
+ to compute the standard deviation of the flattened array.
+ dtype : type
+ Type to use in computing the standard deviation. For arrays of
+ integer type the default is float32, for arrays of float types it
+ is the same as the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must have
+ the same shape as the expected output but the type will be cast if
+ necessary.
- axis : integer
- Axis along which the standard deviation is computed. The default is
- to compute the standard deviation of the flattened array.
+ Returns
+ -------
+ standard deviation : The return type varies, see above.
+ A new array holding the result is returned unless out is specified,
+ in which case a reference to out is returned.
- dtype : type
- Type to use in computing the standard deviation. For arrays of
- integer type the default is float32, for arrays of float types it
- is the same as the array type.
+ SeeAlso
+ -------
+ var : variance
+ mean : average
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
-
- :Returns:
-
- standard deviation : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
-
- :SeeAlso:
-
- - var : variance
- - mean : average
-
Notes
-----
+ The standard deviation is the square root of the average of the squared
+ deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The
+ computed standard deviation is biased, i.e., the mean is computed by
+ dividing by the number of elements, N, rather than by N-1.
- The standard deviation is the square root of the average of the squared
- deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The
- computed standard deviation is biased, i.e., the mean is computed by
- dividing by the number of elements, N, rather than by N-1.
-
"""))
@@ -1270,8 +1279,8 @@
Warning: The arithmetic is modular and no error is raised on overflow.
- Examples:
-
+ Examples
+ --------
>>> array([0.5, 1.5]).sum()
2.0
>>> array([0.5, 1.5]).sum(dtype=int32)
@@ -1282,7 +1291,6 @@
array([1, 5])
>>> ones(128, dtype=int8).sum(dtype=int8) # overflow!
-128
-
"""))
@@ -1304,13 +1312,15 @@
add_newdoc('numpy.core.multiarray', 'ndarray', ('tofile',
"""a.tofile(fid, sep="", format="%s") -> None. Write the data to a file.
- Required arguments:
- file -- an open file object or a string containing a filename
+ Parameters
+ ----------
+ fid : file or string
+ an open file object or a string containing a filename
+ sep : string
+ separation for text output. Write binary if this is empty.
+ format : string
+ format string for text file output
- Keyword arguments:
- sep -- separator for text output. Write binary if empty (default "")
- format -- format string for text file output (default "%s")
-
A convenience function for quick storage of array data. Information on
endianess and precision is lost, so this method is not a good choice for
files intended to archive data or transport data between machines with
@@ -1341,8 +1351,10 @@
add_newdoc('numpy.core.multiarray', 'ndarray', ('tostring',
"""a.tostring(order='C') -> raw copy of array data as a Python string.
- Keyword arguments:
- order -- order of the data item in the copy {"C","F","A"} (default "C")
+ Parameters
+ ----------
+ order : {'C', 'F', 'A', None}
+ order of the data item in the copy
Construct a Python string containing the raw bytes in the array. The order
of the data in arrays with ndim > 1 is specified by the 'order' keyword and
@@ -1373,7 +1385,8 @@
array, this is the usual matrix transpose. If axes are given,
they describe how the axes are permuted.
- Example:
+ Examples
+ --------
>>> a = array([[1,2],[3,4]])
>>> a
array([[1, 2],
@@ -1398,41 +1411,38 @@
distribution. The variance is computed for the flattened array by default,
otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the variance is computed. The default is to
+ compute the variance of the flattened array.
+ dtype : data-type
+ Type to use in computing the variance. For arrays of integer type
+ the default is float32, for arrays of float types it is the same as
+ the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must have
+ the same shape as the expected output but the type will be cast if
+ necessary.
- axis : integer
- Axis along which the variance is computed. The default is to
- compute the variance of the flattened array.
+ Returns
+ -------
+ variance : The return type varies, see above.
+ A new array holding the result is returned unless out is specified,
+ in which case a reference to out is returned.
- dtype : type
- Type to use in computing the variance. For arrays of integer type
- the default is float32, for arrays of float types it is the same as
- the array type.
+ SeeAlso
+ -------
+ std : standard deviation
+ mean: average
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
-
- :Returns:
-
- variance : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
-
- :SeeAlso:
-
- - std : standard deviation
- - mean: average
-
Notes
-----
+ The variance is the average of the squared deviations from the mean, i.e.
+ var = mean((x - x.mean())**2). The computed variance is biased, i.e.,
+ the mean is computed by dividing by the number of elements, N, rather
+ than by N-1.
- The variance is the average of the squared deviations from the mean, i.e.
- var = mean((x - x.mean())**2). The computed variance is biased, i.e.,
- the mean is computed by dividing by the number of elements, N, rather
- than by N-1.
-
"""))
@@ -1442,3 +1452,31 @@
Type can be either a new sub-type object or a data-descriptor object
"""))
+
+add_newdoc('numpy.core.umath','geterrobj',
+ """geterrobj()
+
+ Used internally by `geterr`.
+
+ Returns
+ -------
+ errobj : list
+ Internal numpy buffer size, error mask, error callback function.
+
+ """)
+
+add_newdoc('numpy.core.umath','seterrobj',
+ """seterrobj()
+
+ Used internally by `seterr`.
+
+ Parameters
+ ----------
+ errobj : list
+ [buffer_size, error_mask, callback_func]
+
+ See Also
+ --------
+ seterrcall
+
+ """)
Modified: branches/maskedarray/numpy/core/code_generators/generate_umath.py
===================================================================
--- branches/maskedarray/numpy/core/code_generators/generate_umath.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/code_generators/generate_umath.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -5,6 +5,16 @@
None_ = "PyUFunc_None"
class TypeDescription(object):
+ """Type signature for a ufunc
+
+ Attributes
+ ----------
+
+ type: character representing the type
+ func_data:
+ in_:
+ out:
+ """
def __init__(self, type, f=None, in_=None, out=None):
self.type = type
self.func_data = f
@@ -55,6 +65,17 @@
return tds
class Ufunc(object):
+ """Description of a ufunc.
+
+ Attributes
+ ----------
+
+ nin: number of input arguments
+ nout: number of output arguments
+ identity: identity element for a two-argument function
+ docstring: docstring for the ufunc
+ type_descriptions: list of TypeDescription objects
+ """
def __init__(self, nin, nout, identity, docstring,
*type_descriptions):
self.nin = nin
@@ -69,7 +90,7 @@
for td in self.type_descriptions:
td.finish_signature(self.nin, self.nout)
-#each entry in defdict is
+#each entry in defdict is a Ufunc object.
#name: [string of chars for which it is defined,
# string of characters using func interface,
@@ -304,6 +325,16 @@
TD(ints),
TD(O, f='PyNumber_Rshift'),
),
+'degrees' :
+ Ufunc(1, 1, None,
+ 'converts angle from radians to degrees',
+ TD(fltsM, f='degrees'),
+ ),
+'radians' :
+ Ufunc(1, 1, None,
+ 'converts angle from degrees to radians',
+ TD(fltsM, f='radians'),
+ ),
'arccos' :
Ufunc(1, 1, None,
'inverse cosine elementwise.',
Modified: branches/maskedarray/numpy/core/code_generators/multiarray_api_order.txt
===================================================================
--- branches/maskedarray/numpy/core/code_generators/multiarray_api_order.txt 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/code_generators/multiarray_api_order.txt 2008-01-18 23:25:32 UTC (rev 4730)
@@ -81,3 +81,4 @@
PyArray_DescrAlignConverter
PyArray_DescrAlignConverter2
PyArray_SearchsideConverter
+PyArray_CheckAxis
Modified: branches/maskedarray/numpy/core/defmatrix.py
===================================================================
--- branches/maskedarray/numpy/core/defmatrix.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/defmatrix.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -49,6 +49,34 @@
class matrix(N.ndarray):
+ """mat = matrix(data, dtype=None, copy=True)
+
+ Returns a matrix from an array-like object, or a string of
+ data. A matrix is a specialized 2-d array that retains
+ it's 2-d nature through operations and where '*' means matrix
+ multiplication and '**' means matrix power.
+
+ Parameters
+ ----------
+ data : array-like or string
+ If data is a string, then interpret the string as a matrix
+ with commas or spaces separating columns and semicolons
+ separating rows.
+ If data is array-like than convert the array to a matrix.
+ dtype : data-type
+ Anything that can be interpreted as a NumPy datatype.
+ copy : bool
+ If data is already an ndarray, then this flag determines whether
+ or not the data will be copied
+
+ Examples
+ --------
+ >>> import numpy as np
+ >>> a = np.matrix('1 2; 3 4')
+ >>> print a
+ [[1 2]
+ [3 4]]
+ """
__array_priority__ = 10.0
def __new__(subtype, data, dtype=None, copy=True):
if isinstance(data, matrix):
@@ -244,39 +272,37 @@
Returns the average of the array elements. The average is taken over
the flattened array by default, otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the means are computed. The default is
+ to compute the standard deviation of the flattened array.
- axis : integer
- Axis along which the means are computed. The default is
- to compute the standard deviation of the flattened array.
+ dtype : type
+ Type to use in computing the means. For arrays of integer type
+ the default is float32, for arrays of float types it is the
+ same as the array type.
- dtype : type
- Type to use in computing the means. For arrays of integer type
- the default is float32, for arrays of float types it is the
- same as the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must
+ have the same shape as the expected output but the type will be
+ cast if necessary.
- out : ndarray
- Alternative output array in which to place the result. It must
- have the same shape as the expected output but the type will be
- cast if necessary.
+ Returns
+ -------
+ mean : The return type varies, see above.
+ A new array holding the result is returned unless out is
+ specified, in which case a reference to out is returned.
- :Returns:
+ SeeAlso
+ -------
+ var : variance
+ std : standard deviation
- mean : The return type varies, see above.
- A new array holding the result is returned unless out is
- specified, in which case a reference to out is returned.
-
- :SeeAlso:
-
- - var : variance
- - std : standard deviation
-
Notes
-----
-
- The mean is the sum of the elements along the axis divided by the
- number of elements.
-
+ The mean is the sum of the elements along the axis divided by the
+ number of elements.
"""
return N.ndarray.mean(self, axis, out)._align(axis)
@@ -287,43 +313,41 @@
spread of a distribution. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the standard deviation is computed. The
+ default is to compute the standard deviation of the flattened
+ array.
- axis : integer
- Axis along which the standard deviation is computed. The
- default is to compute the standard deviation of the flattened
- array.
+ dtype : type
+ Type to use in computing the standard deviation. For arrays of
+ integer type the default is float32, for arrays of float types
+ it is the same as the array type.
- dtype : type
- Type to use in computing the standard deviation. For arrays of
- integer type the default is float32, for arrays of float types
- it is the same as the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must
+ have the same shape as the expected output but the type will be
+ cast if necessary.
- out : ndarray
- Alternative output array in which to place the result. It must
- have the same shape as the expected output but the type will be
- cast if necessary.
+ Returns
+ -------
+ standard deviation : The return type varies, see above.
+ A new array holding the result is returned unless out is
+ specified, in which case a reference to out is returned.
- :Returns:
+ SeeAlso
+ -------
+ var : variance
+ mean : average
- standard deviation : The return type varies, see above.
- A new array holding the result is returned unless out is
- specified, in which case a reference to out is returned.
-
- :SeeAlso:
-
- - var : variance
- - mean : average
-
Notes
- -----
-
- The standard deviation is the square root of the average of the
- squared deviations from the mean, i.e. var = sqrt(mean((x -
- x.mean())**2)). The computed standard deviation is biased, i.e., the
- mean is computed by dividing by the number of elements, N, rather
- than by N-1.
-
+ -----
+ The standard deviation is the square root of the
+ average of the squared deviations from the mean, i.e. var =
+ sqrt(mean((x - x.mean())**2)). The computed standard
+ deviation is biased, i.e., the mean is computed by dividing by
+ the number of elements, N, rather than by N-1.
"""
return N.ndarray.std(self, axis, dtype, out)._align(axis)
@@ -334,41 +358,38 @@
a distribution. The variance is computed for the flattened array by
default, otherwise over the specified axis.
- :Parameters:
+ Parameters
+ ----------
+ axis : integer
+ Axis along which the variance is computed. The default is to
+ compute the variance of the flattened array.
+ dtype : data-type
+ Type to use in computing the variance. For arrays of integer
+ type the default is float32, for arrays of float types it is
+ the same as the array type.
+ out : ndarray
+ Alternative output array in which to place the result. It must
+ have the same shape as the expected output but the type will be
+ cast if necessary.
- axis : integer
- Axis along which the variance is computed. The default is to
- compute the variance of the flattened array.
+ Returns
+ -------
+ variance : depends, see above
+ A new array holding the result is returned unless out is
+ specified, in which case a reference to out is returned.
- dtype : type
- Type to use in computing the variance. For arrays of integer
- type the default is float32, for arrays of float types it is
- the same as the array type.
+ SeeAlso
+ -------
+ std : standard deviation
+ mean : average
- out : ndarray
- Alternative output array in which to place the result. It must
- have the same shape as the expected output but the type will be
- cast if necessary.
-
- :Returns:
-
- variance : depends, see above
- A new array holding the result is returned unless out is
- specified, in which case a reference to out is returned.
-
- :SeeAlso:
-
- - std : standard deviation
- - mean : average
-
Notes
-----
- The variance is the average of the squared deviations from the mean,
- i.e. var = mean((x - x.mean())**2). The computed variance is
- biased, i.e., the mean is computed by dividing by the number of
- elements, N, rather than by N-1.
-
+ The variance is the average of the squared deviations from the
+ mean, i.e. var = mean((x - x.mean())**2). The computed
+ variance is biased, i.e., the mean is computed by dividing by
+ the number of elements, N, rather than by N-1.
"""
return N.ndarray.var(self, axis, dtype, out)._align(axis)
@@ -458,14 +479,16 @@
def bmat(obj, ldict=None, gdict=None):
"""Build a matrix object from string, nested sequence, or array.
- Ex: F = bmat('A, B; C, D')
- F = bmat([[A,B],[C,D]])
- F = bmat(r_[c_[A,B],c_[C,D]])
+ Example
+ --------
+ F = bmat('A, B; C, D')
+ F = bmat([[A,B],[C,D]])
+ F = bmat(r_[c_[A,B],c_[C,D]])
- all produce the same Matrix Object [ A B ]
- [ C D ]
+ all produce the same Matrix Object [ A B ]
+ [ C D ]
- if A, B, C, and D are appropriately shaped 2-d arrays.
+ if A, B, C, and D are appropriately shaped 2-d arrays.
"""
if isinstance(obj, str):
if gdict is None:
Modified: branches/maskedarray/numpy/core/numeric.py
===================================================================
--- branches/maskedarray/numpy/core/numeric.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/numeric.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -40,10 +40,11 @@
# from Fernando Perez's IPython
def zeros_like(a):
- """Return an array of zeros of the shape and typecode of a.
+ """Return an array of zeros of the shape and data-type of a.
If you don't explicitly need the array to be zeroed, you should instead
- use empty_like(), which is faster as it only allocates memory."""
+ use empty_like(), which is faster as it only allocates memory.
+ """
try:
return zeros(a.shape, a.dtype, a.flags.fnc)
except AttributeError:
@@ -58,7 +59,7 @@
return res
def empty_like(a):
- """Return an empty (uninitialized) array of the shape and typecode of a.
+ """Return an empty (uninitialized) array of the shape and data-type of a.
Note that this does NOT initialize the returned array. If you require
your array to be initialized, you should use zeros_like().
@@ -147,6 +148,29 @@
return array(a, dtype, copy=False, order='F', ndmin=1)
def require(a, dtype=None, requirements=None):
+ """Return an ndarray of the provided type that satisfies requirements.
+
+ This function is useful to be sure that an array with the correct flags
+ is returned for passing to compiled code (perhaps through ctypes).
+
+ Parameters
+ ----------
+ a : array-like
+ The object to be converted to a type-and-requirement satisfying array
+ dtype : data-type
+ The required data-type (None is the default data-type -- float64)
+ requirements : list of strings
+ The requirements list can be any of the
+ 'ENSUREARRAY' ('E') - ensure that a base-class ndarray
+ 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
+ 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
+ 'ALIGNED' ('A') - ensure a data-type aligned array
+ 'WRITEABLE' ('W') - ensure a writeable array
+ 'OWNDATA' ('O') - ensure an array that owns its own data
+
+ The returned array will be guaranteed to have the listed requirements
+ by making a copy if needed.
+ """
if requirements is None:
requirements = []
else:
@@ -252,11 +276,13 @@
try:
# importing this changes the dot function for basic 4 types
# to blas-optimized versions.
- from _dotblas import dot, vdot, inner, alterdot, restoredot
+ from _dotblas import dot, vdot, inner, alterdot, restoredot
except ImportError:
def alterdot():
+ "Does Nothing"
pass
def restoredot():
+ "Does Nothing"
pass
@@ -641,7 +667,7 @@
fname can be a filename or a file handle. Support for gzipped files is
automatic, if the filename ends in .gz
- See scipy.loadmat to read and write matfiles.
+ See scipy.io.loadmat to read and write matfiles.
Example usage:
@@ -847,6 +873,9 @@
return all(less_equal(absolute(x-y), atol + rtol * absolute(y)))
def array_equal(a1, a2):
+ """Returns True if a1 and a2 have identical shapes
+ and all elements equal and False otherwise.
+ """
try:
a1, a2 = asarray(a1), asarray(a2)
except:
@@ -856,6 +885,10 @@
return logical_and.reduce(equal(a1,a2).ravel())
def array_equiv(a1, a2):
+ """Returns True if a1 and a2 are shape consistent
+ (mutually broadcastable) and have all elements equal and False
+ otherwise.
+ """
try:
a1, a2 = asarray(a1), asarray(a2)
except:
Modified: branches/maskedarray/numpy/core/records.py
===================================================================
--- branches/maskedarray/numpy/core/records.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/records.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -43,10 +43,40 @@
return dup
class format_parser:
+ """Class to convert formats, names, titles description to a dtype
+
+ After constructing the format_parser object, the dtype attribute is
+ the converted data-type.
+
+ dtype = format_parser(formats, names, titles).dtype
+
+ Parameters
+ ----------
+ formats : string or list
+ comma-separated format descriptions --- 'f8, i4, a5'
+ list of format description strings --- ['f8', 'i4', 'a5']
+ names : string or (list or tuple of strings)
+ comma-separated field names --- 'col1, col2, col3'
+ list or tuple of field names
+ titles : sequence
+ sequence of title strings or unicode
+ aligned : bool
+ align the fields by padding as the C-compiler would
+ byteorder :
+ If specified, all the fields will be changed to the
+ provided byteorder. Otherwise, the default byteorder is
+ used.
+
+ Returns
+ -------
+ object
+ A Python object whose dtype attribute is a data-type.
+ """
def __init__(self, formats, names, titles, aligned=False, byteorder=None):
self._parseFormats(formats, aligned)
self._setfieldnames(names, titles)
self._createdescr(byteorder)
+ self.dtype = self._descr
def _parseFormats(self, formats, aligned=0):
""" Parse the field formats """
@@ -115,6 +145,8 @@
self._descr = descr
class record(nt.void):
+ """A data-type scalar that allows field access as attribute lookup.
+ """
def __repr__(self):
return self.__str__()
@@ -182,6 +214,29 @@
# the fields (and any subfields)
class recarray(ndarray):
+ """recarray(shape, dtype=None, buf=None, **kwds)
+
+ Subclass of ndarray that allows field access using attribute lookup.
+
+ Parameters
+ ----------
+ shape : tuple
+ shape of record array
+ dtype : data-type or None
+ The desired data-type. If this is None, then the data-type is determined
+ by the *formats*, *names*, *titles*, *aligned*, and *byteorder* keywords.
+ buf : [buffer] or None
+ If this is None, then a new array is created of the given shape and data-type
+ If this is an object exposing the buffer interface, then the array will
+ use the memory from an existing buffer. In this case, the *offset* and
+ *strides* keywords can also be used.
+
+ See Also
+ --------
+ format_parser : determine a data-type from formats, names, titles
+ record : fundamental data-type for recarray
+
+ """
def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None,
formats=None, names=None, titles=None,
byteorder=None, aligned=False):
Modified: branches/maskedarray/numpy/core/src/arrayobject.c
===================================================================
--- branches/maskedarray/numpy/core/src/arrayobject.c 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/src/arrayobject.c 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1691,6 +1691,12 @@
return 0;
}
+
+/* XXX: FIXME --- add ordering argument to
+ Allow Fortran ordering on write
+ This will need the addition of a Fortran-order iterator.
+ */
+
/*OBJECT_API
To File
*/
@@ -3139,16 +3145,7 @@
static Py_ssize_t
array_getcharbuf(PyArrayObject *self, Py_ssize_t segment, constchar **ptrptr)
{
- if (self->descr->type_num == PyArray_STRING || \
- self->descr->type_num == PyArray_UNICODE || \
- self->descr->elsize == 1)
- return array_getreadbuf(self, segment, (void **) ptrptr);
- else {
- PyErr_SetString(PyExc_TypeError,
- "non-character (or 8-bit) array cannot be "\
- "interpreted as character buffer");
- return -1;
- }
+ return array_getreadbuf(self, segment, (void **) ptrptr);
}
static PyBufferProcs array_as_buffer = {
@@ -4835,8 +4832,12 @@
return result;
}
+
+/*MULTIARRAY_API
+ PyArray_CheckAxis
+*/
static PyObject *
-_check_axis(PyArrayObject *arr, int *axis, int flags)
+PyArray_CheckAxis(PyArrayObject *arr, int *axis, int flags)
{
PyObject *temp1, *temp2;
int n = arr->nd;
@@ -4878,6 +4879,8 @@
return temp2;
}
+#define _check_axis PyArray_CheckAxis
+
#include "arraymethods.c"
/* Lifted from numarray */
Modified: branches/maskedarray/numpy/core/src/arraytypes.inc.src
===================================================================
--- branches/maskedarray/numpy/core/src/arraytypes.inc.src 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/src/arraytypes.inc.src 2008-01-18 23:25:32 UTC (rev 4730)
@@ -2059,7 +2059,7 @@
@name at _fastclip(@type@ *in, intp ni, @type@ *min, @type@ *max, @type@ *out)
{
register npy_intp i;
- @type@ max_val, min_val;
+ @type@ max_val = 0, min_val = 0;
if (max != NULL)
max_val = *max;
Modified: branches/maskedarray/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/maskedarray/numpy/core/src/multiarraymodule.c 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/src/multiarraymodule.c 2008-01-18 23:25:32 UTC (rev 4730)
@@ -2231,7 +2231,6 @@
return NULL;
}
-
/*MULTIARRAY_API
*/
static PyObject *
Modified: branches/maskedarray/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/maskedarray/numpy/core/src/scalartypes.inc.src 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/src/scalartypes.inc.src 2008-01-18 23:25:32 UTC (rev 4730)
@@ -547,14 +547,19 @@
Py_DECREF(arr);
return ret;
}
+/**begin repeat
+#name=float, double, longdouble#
+#NAME=FLOAT, DOUBLE, LONGDOUBLE#
+#PREFIX=NPY_,NPY_,#
+*/
static void
-format_longdouble(char *buf, size_t buflen, longdouble val,
+format_ at name@(char *buf, size_t buflen, @name@ val,
unsigned int precision)
{
char *cp;
- PyOS_snprintf(buf, buflen, "%.*" LONGDOUBLE_FMT, precision, val);
+ PyOS_snprintf(buf, buflen, "%.*" @PREFIX@@NAME at _FMT, precision, val);
cp = buf;
if (*cp == '-')
cp++;
@@ -568,6 +573,7 @@
*cp++ = '\0';
}
}
+/**end repeat**/
/* over-ride repr and str of array-scalar strings and unicode to
remove NULL bytes and then call the corresponding functions
@@ -602,43 +608,58 @@
}
/**end repeat**/
+/* These values are finfo.precision + 2 */
+#define FLOATPREC_REPR 8
+#define DOUBLEPREC_REPR 17
-
#if SIZEOF_LONGDOUBLE == SIZEOF_DOUBLE
-#define PREC_REPR 17
-#define PREC_STR 17
-#else
-#define PREC_REPR 21
-#define PREC_STR 21
+#define LONGDOUBLEPREC_REPR DOUBLEPREC_REPR
+#define LONGDOUBLEPREC_STR DOUBLEPREC_REPR
+#else /* More than probably needed on Intel FP */
+#define LONGDOUBLEPREC_REPR 22
+#define LONGDOUBLEPREC_STR 22
#endif
+/* floattype_repr */
+/**begin repeat
+
+#name=float, double, longdouble#
+#Name=Float, Double, LongDouble#
+#NAME=FLOAT, DOUBLE, LONGDOUBLE#
+*/
static PyObject *
-longdoubletype_repr(PyObject *self)
+ at name@type_repr(PyObject *self)
{
static char buf[100];
- format_longdouble(buf, sizeof(buf),
- ((PyLongDoubleScalarObject *)self)->obval, PREC_REPR);
+ format_ at name@(buf, sizeof(buf),
+ ((Py at Name@ScalarObject *)self)->obval, @NAME at PREC_REPR);
return PyString_FromString(buf);
}
static PyObject *
-clongdoubletype_repr(PyObject *self)
+c at name@type_repr(PyObject *self)
{
static char buf1[100];
static char buf2[100];
static char buf3[202];
- clongdouble x;
- x = ((PyCLongDoubleScalarObject *)self)->obval;
- format_longdouble(buf1, sizeof(buf1), x.real, PREC_REPR);
- format_longdouble(buf2, sizeof(buf2), x.imag, PREC_REPR);
+ c at name@ x;
+ x = ((PyC at Name@ScalarObject *)self)->obval;
+ format_ at name@(buf1, sizeof(buf1), x.real, @NAME at PREC_REPR);
+ format_ at name@(buf2, sizeof(buf2), x.imag, @NAME at PREC_REPR);
snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2);
return PyString_FromString(buf3);
}
+/**end repeat**/
-#define longdoubletype_str longdoubletype_repr
-#define clongdoubletype_str clongdoubletype_repr
+/**begin repeat
+#name=float, double, longdouble#
+*/
+#define @name at type_str @name at type_repr
+#define c at name@type_str c at name@type_repr
+/**end repeat**/
+
/** Could improve this with a PyLong_FromLongDouble(longdouble ldval)
but this would need some more work...
**/
@@ -842,6 +863,7 @@
arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
if (arr == NULL) return NULL;
inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__");
+ if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr);
Py_DECREF(arr);
return inter;
}
@@ -2537,6 +2559,16 @@
PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash;
#endif
+ /**begin repeat
+#name=repr, str#
+ */
+ PyFloatArrType_Type.tp_ at name@ = floattype_ at name@;
+ PyCFloatArrType_Type.tp_ at name@ = cfloattype_ at name@;
+
+ PyDoubleArrType_Type.tp_ at name@ = doubletype_ at name@;
+ PyCDoubleArrType_Type.tp_ at name@ = cdoubletype_ at name@;
+ /**end repeat**/
+
/* These need to be coded specially because getitem does not
return a normal Python type
*/
Modified: branches/maskedarray/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/maskedarray/numpy/core/src/umathmodule.c.src 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/src/umathmodule.c.src 2008-01-18 23:25:32 UTC (rev 4730)
@@ -413,7 +413,26 @@
#define isfinitef(x) (!(isinff((x)) || isnanf((x))))
#define isfinitel(x) (!(isinfl((x)) || isnanl((x))))
+float degreesf(float x) {
+ return x * (float)(180.0/M_PI);
+}
+double degrees(double x) {
+ return x * (180.0/M_PI);
+}
+longdouble degreesl(longdouble x) {
+ return x * (180.0L/M_PI);
+}
+float radiansf(float x) {
+ return x * (float)(M_PI/180.0);
+}
+double radians(double x) {
+ return x * (M_PI/180.0);
+}
+longdouble radiansl(longdouble x) {
+ return x * (M_PI/180.0L);
+}
+
/* First, the C functions that do the real work */
/* if C99 extensions not available then define dummy functions that use the
Modified: branches/maskedarray/numpy/core/tests/test_multiarray.py
===================================================================
--- branches/maskedarray/numpy/core/tests/test_multiarray.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/tests/test_multiarray.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1,10 +1,9 @@
+import tempfile
+
+import numpy as np
from numpy.testing import *
from numpy.core import *
-from numpy import random
-import numpy as N
-import tempfile
-
class TestFlags(NumpyTestCase):
def setUp(self):
self.a = arange(10)
@@ -357,7 +356,7 @@
class TestArgmax(NumpyTestCase):
def check_all(self):
- a = random.normal(0,1,(4,5,6,7,8))
+ a = np.random.normal(0,1,(4,5,6,7,8))
for i in xrange(a.ndim):
amax = a.max(i)
aargmax = a.argmax(i)
@@ -373,8 +372,8 @@
class TestClip(NumpyTestCase):
def _check_range(self,x,cmin,cmax):
- assert N.all(x >= cmin)
- assert N.all(x <= cmax)
+ assert np.all(x >= cmin)
+ assert np.all(x <= cmax)
def _clip_type(self,type_group,array_max,
clip_min,clip_max,inplace=False,
@@ -384,16 +383,16 @@
if expected_max is None:
expected_max = clip_max
- for T in N.sctypes[type_group]:
+ for T in np.sctypes[type_group]:
if sys.byteorder == 'little':
byte_orders = ['=','>']
else:
byte_orders = ['<','=']
for byteorder in byte_orders:
- dtype = N.dtype(T).newbyteorder(byteorder)
+ dtype = np.dtype(T).newbyteorder(byteorder)
- x = (N.random.random(1000) * array_max).astype(dtype)
+ x = (np.random.random(1000) * array_max).astype(dtype)
if inplace:
x.clip(clip_min,clip_max,x)
else:
@@ -417,46 +416,46 @@
x = self._clip_type('uint',1024,0,0, inplace=inplace)
def check_record_array(self):
- rec = N.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
+ rec = np.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
dtype=[('x', '= 3)
+ assert np.all(x >= 3)
x = val.clip(min=3)
- assert N.all(x >= 3)
+ assert np.all(x >= 3)
x = val.clip(max=4)
- assert N.all(x <= 4)
+ assert np.all(x <= 4)
class TestPutmask(ParametricTestCase):
def tst_basic(self,x,T,mask,val):
- N.putmask(x,mask,val)
- assert N.all(x[mask] == T(val))
+ np.putmask(x,mask,val)
+ assert np.all(x[mask] == T(val))
assert x.dtype == T
def testip_types(self):
- unchecked_types = [str,unicode,N.void,object]
+ unchecked_types = [str, unicode, np.void, object]
- x = N.random.random(1000)*100
+ x = np.random.random(1000)*100
mask = x < 40
tests = []
for val in [-100,0,15]:
- for types in N.sctypes.itervalues():
+ for types in np.sctypes.itervalues():
tests.extend([(self.tst_basic,x.copy().astype(T),T,mask,val)
for T in types if T not in unchecked_types])
return tests
def test_mask_size(self):
- self.failUnlessRaises(ValueError,N.putmask,
- N.array([1,2,3]),[True],5)
+ self.failUnlessRaises(ValueError, np.putmask,
+ np.array([1,2,3]), [True], 5)
def tst_byteorder(self,dtype):
- x = N.array([1,2,3],dtype)
- N.putmask(x,[True,False,True],-1)
+ x = np.array([1,2,3],dtype)
+ np.putmask(x,[True,False,True],-1)
assert_array_equal(x,[-1,2,-1])
def testip_byteorder(self):
@@ -464,46 +463,54 @@
def test_record_array(self):
# Note mixed byteorder.
- rec = N.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
+ rec = np.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
dtype=[('x', 'f8'), ('z', '']:
- for dtype in [float,int,N.complex]:
- dt = N.dtype(dtype).newbyteorder(byteorder)
- x = (N.random.random((4,7))*5).astype(dt)
+ for dtype in [float,int,np.complex]:
+ dt = np.dtype(dtype).newbyteorder(byteorder)
+ x = (np.random.random((4,7))*5).astype(dt)
buf = x.tostring()
tests.append((self.tst_basic,buf,x.flat,{'dtype':dt}))
return tests
class TestResize(NumpyTestCase):
def test_basic(self):
- x = N.eye(3)
+ x = np.eye(3)
x.resize((5,5))
- assert_array_equal(x.flat[:9],N.eye(3).flat)
+ assert_array_equal(x.flat[:9],np.eye(3).flat)
assert_array_equal(x[9:].flat,0)
def test_check_reference(self):
- x = N.eye(3)
+ x = np.eye(3)
y = x
self.failUnlessRaises(ValueError,x.resize,(5,1))
Modified: branches/maskedarray/numpy/core/tests/test_regression.py
===================================================================
--- branches/maskedarray/numpy/core/tests/test_regression.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/tests/test_regression.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -4,14 +4,14 @@
import sys
set_local_path()
-import numpy as N
+import numpy as np
restore_path()
rlevel = 1
def assert_valid_refcount(op):
- a = N.arange(100 * 100)
- b = N.arange(100*100).reshape(100, 100)
+ a = np.arange(100 * 100)
+ b = np.arange(100*100).reshape(100, 100)
c = b
i = 1
@@ -26,15 +26,15 @@
def check_invalid_round(self,level=rlevel):
"""Ticket #3"""
v = 4.7599999999999998
- assert_array_equal(N.array([v]),N.array(v))
+ assert_array_equal(np.array([v]),np.array(v))
def check_mem_empty(self,level=rlevel):
"""Ticket #7"""
- N.empty((1,),dtype=[('x',N.int64)])
+ np.empty((1,),dtype=[('x',np.int64)])
def check_pickle_transposed(self,level=rlevel):
"""Ticket #16"""
- a = N.transpose(N.array([[2,9],[7,0],[3,8]]))
+ a = np.transpose(np.array([[2,9],[7,0],[3,8]]))
f = StringIO()
pickle.dump(a,f)
f.seek(0)
@@ -44,45 +44,45 @@
def check_masked_array_create(self,level=rlevel):
"""Ticket #17"""
- x = N.ma.masked_array([0,1,2,3,0,4,5,6],mask=[0,0,0,1,1,1,0,0])
- assert_array_equal(N.ma.nonzero(x),[[1,2,6,7]])
+ x = np.ma.masked_array([0,1,2,3,0,4,5,6],mask=[0,0,0,1,1,1,0,0])
+ assert_array_equal(np.ma.nonzero(x),[[1,2,6,7]])
def check_poly1d(self,level=rlevel):
"""Ticket #28"""
- assert_equal(N.poly1d([1]) - N.poly1d([1,0]),
- N.poly1d([-1,1]))
+ assert_equal(np.poly1d([1]) - np.poly1d([1,0]),
+ np.poly1d([-1,1]))
def check_typeNA(self,level=rlevel):
"""Ticket #31"""
- assert_equal(N.typeNA[N.int64],'Int64')
- assert_equal(N.typeNA[N.uint64],'UInt64')
+ assert_equal(np.typeNA[np.int64],'Int64')
+ assert_equal(np.typeNA[np.uint64],'UInt64')
def check_dtype_names(self,level=rlevel):
"""Ticket #35"""
- dt = N.dtype([(('name','label'),N.int32,3)])
+ dt = np.dtype([(('name','label'),np.int32,3)])
def check_reduce(self,level=rlevel):
"""Ticket #40"""
- assert_almost_equal(N.add.reduce([1.,.5],dtype=None), 1.5)
+ assert_almost_equal(np.add.reduce([1.,.5],dtype=None), 1.5)
def check_zeros_order(self,level=rlevel):
"""Ticket #43"""
- N.zeros([3], int, 'C')
- N.zeros([3], order='C')
- N.zeros([3], int, order='C')
+ np.zeros([3], int, 'C')
+ np.zeros([3], order='C')
+ np.zeros([3], int, order='C')
def check_sort_bigendian(self,level=rlevel):
"""Ticket #47"""
- a = N.linspace(0, 10, 11)
- c = a.astype(N.dtype('f8')
- b = N.arange(10.,dtype='2) & (a<6))
- xb = N.where((b>2) & (b<6))
+ a = np.arange(10.,dtype='>f8')
+ b = np.arange(10.,dtype='2) & (a<6))
+ xb = np.where((b>2) & (b<6))
ya = ((a>2) & (a<6))
yb = ((b>2) & (b<6))
assert_array_almost_equal(xa,ya.nonzero())
assert_array_almost_equal(xb,yb.nonzero())
- assert(N.all(a[ya] > 0.5))
- assert(N.all(b[yb] > 0.5))
+ assert(np.all(a[ya] > 0.5))
+ assert(np.all(b[yb] > 0.5))
def check_mem_dot(self,level=rlevel):
"""Ticket #106"""
- x = N.random.randn(0,1)
- y = N.random.randn(10,1)
- z = N.dot(x, N.transpose(y))
+ x = np.random.randn(0,1)
+ y = np.random.randn(10,1)
+ z = np.dot(x, np.transpose(y))
def check_arange_endian(self,level=rlevel):
"""Ticket #111"""
- ref = N.arange(10)
- x = N.arange(10,dtype='f8')
+ x = np.arange(10,dtype='>f8')
assert_array_equal(ref,x)
# Longfloat support is not consistent enough across
# platforms for this test to be meaningful.
# def check_longfloat_repr(self,level=rlevel):
# """Ticket #112"""
-# if N.longfloat(0).itemsize > 8:
-# a = N.exp(N.array([1000],dtype=N.longfloat))
+# if np.longfloat(0).itemsize > 8:
+# a = np.exp(np.array([1000],dtype=np.longfloat))
# assert(str(a)[1:9] == str(a[0])[:8])
def check_argmax(self,level=rlevel):
"""Ticket #119"""
- a = N.random.normal(0,1,(4,5,6,7,8))
+ a = np.random.normal(0,1,(4,5,6,7,8))
for i in xrange(a.ndim):
aargmax = a.argmax(i)
def check_matrix_properties(self,level=rlevel):
"""Ticket #125"""
- a = N.matrix([1.0],dtype=float)
- assert(type(a.real) is N.matrix)
- assert(type(a.imag) is N.matrix)
- c,d = N.matrix([0.0]).nonzero()
- assert(type(c) is N.matrix)
- assert(type(d) is N.matrix)
+ a = np.matrix([1.0],dtype=float)
+ assert(type(a.real) is np.matrix)
+ assert(type(a.imag) is np.matrix)
+ c,d = np.matrix([0.0]).nonzero()
+ assert(type(c) is np.matrix)
+ assert(type(d) is np.matrix)
def check_mem_divmod(self,level=rlevel):
"""Ticket #126"""
for i in range(10):
- divmod(N.array([i])[0],10)
+ divmod(np.array([i])[0],10)
def check_hstack_invalid_dims(self,level=rlevel):
"""Ticket #128"""
- x = N.arange(9).reshape((3,3))
- y = N.array([0,0,0])
- self.failUnlessRaises(ValueError,N.hstack,(x,y))
+ x = np.arange(9).reshape((3,3))
+ y = np.array([0,0,0])
+ self.failUnlessRaises(ValueError,np.hstack,(x,y))
def check_squeeze_type(self,level=rlevel):
"""Ticket #133"""
- a = N.array([3])
- b = N.array(3)
- assert(type(a.squeeze()) is N.ndarray)
- assert(type(b.squeeze()) is N.ndarray)
+ a = np.array([3])
+ b = np.array(3)
+ assert(type(a.squeeze()) is np.ndarray)
+ assert(type(b.squeeze()) is np.ndarray)
def check_add_identity(self,level=rlevel):
"""Ticket #143"""
- assert_equal(0,N.add.identity)
+ assert_equal(0,np.add.identity)
def check_binary_repr_0(self,level=rlevel):
"""Ticket #151"""
- assert_equal('0',N.binary_repr(0))
+ assert_equal('0',np.binary_repr(0))
def check_rec_iterate(self,level=rlevel):
"""Ticket #160"""
- descr = N.dtype([('i',int),('f',float),('s','|S3')])
- x = N.rec.array([(1,1.1,'1.0'),
+ descr = np.dtype([('i',int),('f',float),('s','|S3')])
+ x = np.rec.array([(1,1.1,'1.0'),
(2,2.2,'2.0')],dtype=descr)
x[0].tolist()
[i for i in x[0]]
def check_unicode_string_comparison(self,level=rlevel):
"""Ticket #190"""
- a = N.array('hello',N.unicode_)
- b = N.array('world')
+ a = np.array('hello',np.unicode_)
+ b = np.array('world')
a == b
def check_tostring_FORTRANORDER_discontiguous(self,level=rlevel):
"""Fix in r2836"""
# Create discontiguous Fortran-ordered array
- x = N.array(N.random.rand(3,3),order='F')[:,:2]
- assert_array_almost_equal(x.ravel(),N.fromstring(x.tostring()))
+ x = np.array(np.random.rand(3,3),order='F')[:,:2]
+ assert_array_almost_equal(x.ravel(),np.fromstring(x.tostring()))
def check_flat_assignment(self,level=rlevel):
"""Correct behaviour of ticket #194"""
- x = N.empty((3,1))
- x.flat = N.arange(3)
+ x = np.empty((3,1))
+ x.flat = np.arange(3)
assert_array_almost_equal(x,[[0],[1],[2]])
- x.flat = N.arange(3,dtype=float)
+ x.flat = np.arange(3,dtype=float)
assert_array_almost_equal(x,[[0],[1],[2]])
def check_broadcast_flat_assignment(self,level=rlevel):
"""Ticket #194"""
- x = N.empty((3,1))
- def bfa(): x[:] = N.arange(3)
- def bfb(): x[:] = N.arange(3,dtype=float)
+ x = np.empty((3,1))
+ def bfa(): x[:] = np.arange(3)
+ def bfb(): x[:] = np.arange(3,dtype=float)
self.failUnlessRaises(ValueError, bfa)
self.failUnlessRaises(ValueError, bfb)
def check_unpickle_dtype_with_object(self,level=rlevel):
"""Implemented in r2840"""
- dt = N.dtype([('x',int),('y',N.object_),('z','O')])
+ dt = np.dtype([('x',int),('y',np.object_),('z','O')])
f = StringIO()
pickle.dump(dt,f)
f.seek(0)
@@ -325,107 +325,107 @@
def check_mem_array_creation_invalid_specification(self,level=rlevel):
"""Ticket #196"""
- dt = N.dtype([('x',int),('y',N.object_)])
+ dt = np.dtype([('x',int),('y',np.object_)])
# Wrong way
- self.failUnlessRaises(ValueError, N.array, [1,'object'], dt)
+ self.failUnlessRaises(ValueError, np.array, [1,'object'], dt)
# Correct way
- N.array([(1,'object')],dt)
+ np.array([(1,'object')],dt)
def check_recarray_single_element(self,level=rlevel):
"""Ticket #202"""
- a = N.array([1,2,3],dtype=N.int32)
+ a = np.array([1,2,3],dtype=np.int32)
b = a.copy()
- r = N.rec.array(a,shape=1,formats=['3i4'],names=['d'])
+ r = np.rec.array(a,shape=1,formats=['3i4'],names=['d'])
assert_array_equal(a,b)
assert_equal(a,r[0][0])
def check_zero_sized_array_indexing(self,level=rlevel):
"""Ticket #205"""
- tmp = N.array([])
- def index_tmp(): tmp[N.array(10)]
+ tmp = np.array([])
+ def index_tmp(): tmp[np.array(10)]
self.failUnlessRaises(IndexError, index_tmp)
def check_unique_zero_sized(self,level=rlevel):
"""Ticket #205"""
- assert_array_equal([], N.unique(N.array([])))
+ assert_array_equal([], np.unique(np.array([])))
def check_chararray_rstrip(self,level=rlevel):
"""Ticket #222"""
- x = N.chararray((1,),5)
+ x = np.chararray((1,),5)
x[0] = 'a '
x = x.rstrip()
assert_equal(x[0], 'a')
def check_object_array_shape(self,level=rlevel):
"""Ticket #239"""
- assert_equal(N.array([[1,2],3,4],dtype=object).shape, (3,))
- assert_equal(N.array([[1,2],[3,4]],dtype=object).shape, (2,2))
- assert_equal(N.array([(1,2),(3,4)],dtype=object).shape, (2,2))
- assert_equal(N.array([],dtype=object).shape, (0,))
- assert_equal(N.array([[],[],[]],dtype=object).shape, (3,0))
- assert_equal(N.array([[3,4],[5,6],None],dtype=object).shape, (3,))
+ assert_equal(np.array([[1,2],3,4],dtype=object).shape, (3,))
+ assert_equal(np.array([[1,2],[3,4]],dtype=object).shape, (2,2))
+ assert_equal(np.array([(1,2),(3,4)],dtype=object).shape, (2,2))
+ assert_equal(np.array([],dtype=object).shape, (0,))
+ assert_equal(np.array([[],[],[]],dtype=object).shape, (3,0))
+ assert_equal(np.array([[3,4],[5,6],None],dtype=object).shape, (3,))
def check_mem_around(self,level=rlevel):
"""Ticket #243"""
- x = N.zeros((1,))
+ x = np.zeros((1,))
y = [0]
decimal = 6
- N.around(abs(x-y),decimal) <= 10.0**(-decimal)
+ np.around(abs(x-y),decimal) <= 10.0**(-decimal)
def check_character_array_strip(self,level=rlevel):
"""Ticket #246"""
- x = N.char.array(("x","x ","x "))
+ x = np.char.array(("x","x ","x "))
for c in x: assert_equal(c,"x")
def check_lexsort(self,level=rlevel):
"""Lexsort memory error"""
- v = N.array([1,2,3,4,5,6,7,8,9,10])
- assert_equal(N.lexsort(v),0)
+ v = np.array([1,2,3,4,5,6,7,8,9,10])
+ assert_equal(np.lexsort(v),0)
def check_pickle_dtype(self,level=rlevel):
"""Ticket #251"""
import pickle
- pickle.dumps(N.float)
+ pickle.dumps(np.float)
def check_masked_array_multiply(self,level=rlevel):
"""Ticket #254"""
- a = N.ma.zeros((4,1))
- a[2,0] = N.ma.masked
- b = N.zeros((4,2))
+ a = np.ma.zeros((4,1))
+ a[2,0] = np.ma.masked
+ b = np.zeros((4,2))
a*b
b*a
def check_swap_real(self, level=rlevel):
"""Ticket #265"""
- assert_equal(N.arange(4,dtype='>c8').imag.max(),0.0)
- assert_equal(N.arange(4,dtype='c8').real.max(),3.0)
- assert_equal(N.arange(4,dtype='c8').imag.max(),0.0)
+ assert_equal(np.arange(4,dtype='c8').real.max(),3.0)
+ assert_equal(np.arange(4,dtype=' 1 and x['two'] > 2)
@@ -440,7 +440,7 @@
funcs2 = ['compress', 'take', 'repeat']
for func in funcs1:
- arr = N.random.rand(8,7)
+ arr = np.random.rand(8,7)
arr2 = arr.copy()
if isinstance(func, tuple):
func_meth = func[1]
@@ -448,15 +448,15 @@
else:
func_meth = func
res1 = getattr(arr, func_meth)()
- res2 = getattr(N, func)(arr2)
+ res2 = getattr(np, func)(arr2)
if res1 is None:
assert abs(arr-res2).max() < 1e-8, func
else:
assert abs(res1-res2).max() < 1e-8, func
for func in funcs2:
- arr1 = N.random.rand(8,7)
- arr2 = N.random.rand(8,7)
+ arr1 = np.random.rand(8,7)
+ arr2 = np.random.rand(8,7)
res1 = None
if func == 'compress':
arr1 = arr1.ravel()
@@ -465,219 +465,219 @@
arr2 = (15*arr2).astype(int).ravel()
if res1 is None:
res1 = getattr(arr1, func)(arr2)
- res2 = getattr(N, func)(arr1, arr2)
+ res2 = getattr(np, func)(arr1, arr2)
assert abs(res1-res2).max() < 1e-8, func
def check_mem_lexsort_strings(self, level=rlevel):
"""Ticket #298"""
lst = ['abc','cde','fgh']
- N.lexsort((lst,))
+ np.lexsort((lst,))
def check_fancy_index(self, level=rlevel):
"""Ticket #302"""
- x = N.array([1,2])[N.array([0])]
+ x = np.array([1,2])[np.array([0])]
assert_equal(x.shape,(1,))
def check_recarray_copy(self, level=rlevel):
"""Ticket #312"""
- dt = [('x',N.int16),('y',N.float64)]
- ra = N.array([(1,2.3)], dtype=dt)
- rb = N.rec.array(ra, dtype=dt)
+ dt = [('x',np.int16),('y',np.float64)]
+ ra = np.array([(1,2.3)], dtype=dt)
+ rb = np.rec.array(ra, dtype=dt)
rb['x'] = 2.
assert ra['x'] != rb['x']
def check_rec_fromarray(self, level=rlevel):
"""Ticket #322"""
- x1 = N.array([[1,2],[3,4],[5,6]])
- x2 = N.array(['a','dd','xyz'])
- x3 = N.array([1.1,2,3])
- N.rec.fromarrays([x1,x2,x3], formats="(2,)i4,a3,f8")
+ x1 = np.array([[1,2],[3,4],[5,6]])
+ x2 = np.array(['a','dd','xyz'])
+ x3 = np.array([1.1,2,3])
+ np.rec.fromarrays([x1,x2,x3], formats="(2,)i4,a3,f8")
def check_object_array_assign(self, level=rlevel):
- x = N.empty((2,2),object)
+ x = np.empty((2,2),object)
x.flat[2] = (1,2,3)
assert_equal(x.flat[2],(1,2,3))
def check_ndmin_float64(self, level=rlevel):
"""Ticket #324"""
- x = N.array([1,2,3],dtype=N.float64)
- assert_equal(N.array(x,dtype=N.float32,ndmin=2).ndim,2)
- assert_equal(N.array(x,dtype=N.float64,ndmin=2).ndim,2)
+ x = np.array([1,2,3],dtype=np.float64)
+ assert_equal(np.array(x,dtype=np.float32,ndmin=2).ndim,2)
+ assert_equal(np.array(x,dtype=np.float64,ndmin=2).ndim,2)
def check_mem_vectorise(self, level=rlevel):
"""Ticket #325"""
- vt = N.vectorize(lambda *args: args)
- vt(N.zeros((1,2,1)), N.zeros((2,1,1)), N.zeros((1,1,2)))
- vt(N.zeros((1,2,1)), N.zeros((2,1,1)), N.zeros((1,1,2)), N.zeros((2,2)))
+ vt = np.vectorize(lambda *args: args)
+ vt(np.zeros((1,2,1)), np.zeros((2,1,1)), np.zeros((1,1,2)))
+ vt(np.zeros((1,2,1)), np.zeros((2,1,1)), np.zeros((1,1,2)), np.zeros((2,2)))
def check_mem_axis_minimization(self, level=rlevel):
"""Ticket #327"""
- data = N.arange(5)
- data = N.add.outer(data,data)
+ data = np.arange(5)
+ data = np.add.outer(data,data)
def check_mem_float_imag(self, level=rlevel):
"""Ticket #330"""
- N.float64(1.0).imag
+ np.float64(1.0).imag
def check_dtype_tuple(self, level=rlevel):
"""Ticket #334"""
- assert N.dtype('i4') == N.dtype(('i4',()))
+ assert np.dtype('i4') == np.dtype(('i4',()))
def check_dtype_posttuple(self, level=rlevel):
"""Ticket #335"""
- N.dtype([('col1', '()i4')])
+ np.dtype([('col1', '()i4')])
def check_mgrid_single_element(self, level=rlevel):
"""Ticket #339"""
- assert_array_equal(N.mgrid[0:0:1j],[0])
- assert_array_equal(N.mgrid[0:0],[])
+ assert_array_equal(np.mgrid[0:0:1j],[0])
+ assert_array_equal(np.mgrid[0:0],[])
def check_numeric_carray_compare(self, level=rlevel):
"""Ticket #341"""
- assert_equal(N.array([ 'X' ], 'c'),'X')
+ assert_equal(np.array([ 'X' ], 'c'),'X')
def check_string_array_size(self, level=rlevel):
"""Ticket #342"""
self.failUnlessRaises(ValueError,
- N.array,[['X'],['X','X','X']],'|S1')
+ np.array,[['X'],['X','X','X']],'|S1')
def check_dtype_repr(self, level=rlevel):
"""Ticket #344"""
- dt1=N.dtype(('uint32', 2))
- dt2=N.dtype(('uint32', (2,)))
+ dt1=np.dtype(('uint32', 2))
+ dt2=np.dtype(('uint32', (2,)))
assert_equal(dt1.__repr__(), dt2.__repr__())
def check_reshape_order(self, level=rlevel):
"""Make sure reshape order works."""
- a = N.arange(6).reshape(2,3,order='F')
+ a = np.arange(6).reshape(2,3,order='F')
assert_equal(a,[[0,2,4],[1,3,5]])
- a = N.array([[1,2],[3,4],[5,6],[7,8]])
+ a = np.array([[1,2],[3,4],[5,6],[7,8]])
b = a[:,1]
assert_equal(b.reshape(2,2,order='F'), [[2,6],[4,8]])
def check_repeat_discont(self, level=rlevel):
"""Ticket #352"""
- a = N.arange(12).reshape(4,3)[:,2]
+ a = np.arange(12).reshape(4,3)[:,2]
assert_equal(a.repeat(3), [2,2,2,5,5,5,8,8,8,11,11,11])
def check_array_index(self, level=rlevel):
"""Make sure optimization is not called in this case."""
- a = N.array([1,2,3])
- a2 = N.array([[1,2,3]])
- assert_equal(a[N.where(a==3)], a2[N.where(a2==3)])
+ a = np.array([1,2,3])
+ a2 = np.array([[1,2,3]])
+ assert_equal(a[np.where(a==3)], a2[np.where(a2==3)])
def check_object_argmax(self, level=rlevel):
- a = N.array([1,2,3],dtype=object)
+ a = np.array([1,2,3],dtype=object)
assert a.argmax() == 2
def check_recarray_fields(self, level=rlevel):
"""Ticket #372"""
- dt0 = N.dtype([('f0','i4'),('f1','i4')])
- dt1 = N.dtype([('f0','i8'),('f1','i8')])
- for a in [N.array([(1,2),(3,4)],"i4,i4"),
- N.rec.array([(1,2),(3,4)],"i4,i4"),
- N.rec.array([(1,2),(3,4)]),
- N.rec.fromarrays([(1,2),(3,4)],"i4,i4"),
- N.rec.fromarrays([(1,2),(3,4)])]:
+ dt0 = np.dtype([('f0','i4'),('f1','i4')])
+ dt1 = np.dtype([('f0','i8'),('f1','i8')])
+ for a in [np.array([(1,2),(3,4)],"i4,i4"),
+ np.rec.array([(1,2),(3,4)],"i4,i4"),
+ np.rec.array([(1,2),(3,4)]),
+ np.rec.fromarrays([(1,2),(3,4)],"i4,i4"),
+ np.rec.fromarrays([(1,2),(3,4)])]:
assert(a.dtype in [dt0,dt1])
def check_random_shuffle(self, level=rlevel):
"""Ticket #374"""
- a = N.arange(5).reshape((5,1))
+ a = np.arange(5).reshape((5,1))
b = a.copy()
- N.random.shuffle(b)
- assert_equal(N.sort(b, axis=0),a)
+ np.random.shuffle(b)
+ assert_equal(np.sort(b, axis=0),a)
def check_refcount_vectorize(self, level=rlevel):
"""Ticket #378"""
def p(x,y): return 123
- v = N.vectorize(p)
+ v = np.vectorize(p)
assert_valid_refcount(v)
def check_poly1d_nan_roots(self, level=rlevel):
"""Ticket #396"""
- p = N.poly1d([N.nan,N.nan,1], r=0)
- self.failUnlessRaises(N.linalg.LinAlgError,getattr,p,"r")
+ p = np.poly1d([np.nan,np.nan,1], r=0)
+ self.failUnlessRaises(np.linalg.LinAlgError,getattr,p,"r")
def check_refcount_vdot(self, level=rlevel):
"""Changeset #3443"""
- assert_valid_refcount(N.vdot)
+ assert_valid_refcount(np.vdot)
def check_startswith(self, level=rlevel):
- ca = N.char.array(['Hi','There'])
+ ca = np.char.array(['Hi','There'])
assert_equal(ca.startswith('H'),[True,False])
def check_noncommutative_reduce_accumulate(self, level=rlevel):
"""Ticket #413"""
- tosubtract = N.arange(5)
- todivide = N.array([2.0, 0.5, 0.25])
- assert_equal(N.subtract.reduce(tosubtract), -10)
- assert_equal(N.divide.reduce(todivide), 16.0)
- assert_array_equal(N.subtract.accumulate(tosubtract),
- N.array([0, -1, -3, -6, -10]))
- assert_array_equal(N.divide.accumulate(todivide),
- N.array([2., 4., 16.]))
+ tosubtract = np.arange(5)
+ todivide = np.array([2.0, 0.5, 0.25])
+ assert_equal(np.subtract.reduce(tosubtract), -10)
+ assert_equal(np.divide.reduce(todivide), 16.0)
+ assert_array_equal(np.subtract.accumulate(tosubtract),
+ np.array([0, -1, -3, -6, -10]))
+ assert_array_equal(np.divide.accumulate(todivide),
+ np.array([2., 4., 16.]))
def check_mem_polymul(self, level=rlevel):
"""Ticket #448"""
- N.polymul([],[1.])
+ np.polymul([],[1.])
def check_convolve_empty(self, level=rlevel):
"""Convolve should raise an error for empty input array."""
- self.failUnlessRaises(AssertionError,N.convolve,[],[1])
- self.failUnlessRaises(AssertionError,N.convolve,[1],[])
+ self.failUnlessRaises(AssertionError,np.convolve,[],[1])
+ self.failUnlessRaises(AssertionError,np.convolve,[1],[])
def check_multidim_byteswap(self, level=rlevel):
"""Ticket #449"""
- r=N.array([(1,(0,1,2))], dtype="i2,3i2")
+ r=np.array([(1,(0,1,2))], dtype="i2,3i2")
assert_array_equal(r.byteswap(),
- N.array([(256,(0,256,512))],r.dtype))
+ np.array([(256,(0,256,512))],r.dtype))
def check_string_NULL(self, level=rlevel):
"""Changeset 3557"""
- assert_equal(N.array("a\x00\x0b\x0c\x00").item(),
+ assert_equal(np.array("a\x00\x0b\x0c\x00").item(),
'a\x00\x0b\x0c')
def check_mem_string_concat(self, level=rlevel):
"""Ticket #469"""
- x = N.array([])
- N.append(x,'asdasd\tasdasd')
+ x = np.array([])
+ np.append(x,'asdasd\tasdasd')
def check_matrix_multiply_by_1d_vector(self, level=rlevel) :
"""Ticket #473"""
def mul() :
- N.mat(N.eye(2))*N.ones(2)
+ np.mat(np.eye(2))*np.ones(2)
self.failUnlessRaises(ValueError,mul)
def check_junk_in_string_fields_of_recarray(self, level=rlevel):
"""Ticket #483"""
- r = N.array([['abc']], dtype=[('var1', '|S20')])
+ r = np.array([['abc']], dtype=[('var1', '|S20')])
assert str(r['var1'][0][0]) == 'abc'
def check_take_output(self, level=rlevel):
"""Ensure that 'take' honours output parameter."""
- x = N.arange(12).reshape((3,4))
- a = N.take(x,[0,2],axis=1)
- b = N.zeros_like(a)
- N.take(x,[0,2],axis=1,out=b)
+ x = np.arange(12).reshape((3,4))
+ a = np.take(x,[0,2],axis=1)
+ b = np.zeros_like(a)
+ np.take(x,[0,2],axis=1,out=b)
assert_array_equal(a,b)
def check_array_str_64bit(self, level=rlevel):
"""Ticket #501"""
- s = N.array([1, N.nan],dtype=N.float64)
- errstate = N.seterr(all='raise')
+ s = np.array([1, np.nan],dtype=np.float64)
+ errstate = np.seterr(all='raise')
try:
- sstr = N.array_str(s)
+ sstr = np.array_str(s)
finally:
- N.seterr(**errstate)
+ np.seterr(**errstate)
def check_frompyfunc_endian(self, level=rlevel):
"""Ticket #503"""
from math import radians
- uradians = N.frompyfunc(radians, 1, 1)
- big_endian = N.array([83.4, 83.5], dtype='>f8')
- little_endian = N.array([83.4, 83.5], dtype='f4','0)]=1.0
self.failUnlessRaises(ValueError,ia,x,s)
def check_mem_scalar_indexing(self, level=rlevel):
"""Ticket #603"""
- x = N.array([0],dtype=float)
- index = N.array(0,dtype=N.int32)
+ x = np.array([0],dtype=float)
+ index = np.array(0,dtype=np.int32)
x[index]
+ def check_binary_repr_0_width(self, level=rlevel):
+ assert_equal(np.binary_repr(0,width=3),'000')
if __name__ == "__main__":
NumpyTest().run()
Modified: branches/maskedarray/numpy/core/tests/test_scalarmath.py
===================================================================
--- branches/maskedarray/numpy/core/tests/test_scalarmath.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/tests/test_scalarmath.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1,14 +1,12 @@
from numpy.testing import *
-set_package_path()
import numpy.core.umath as ncu
from numpy import array
-import numpy as N
-restore_path()
+import numpy as np
-types = [N.bool_, N.byte, N.ubyte, N.short, N.ushort, N.intc, N.uintc,
- N.int_, N.uint, N.longlong, N.ulonglong,
- N.single, N.double, N.longdouble, N.csingle,
- N.cdouble, N.clongdouble]
+types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
+ np.int_, np.uint, np.longlong, np.ulonglong,
+ np.single, np.double, np.longdouble, np.csingle,
+ np.cdouble, np.clongdouble]
# This compares scalarmath against ufuncs.
@@ -40,13 +38,13 @@
class TestPower(NumpyTestCase):
def check_small_types(self):
- for t in [N.int8, N.int16]:
+ for t in [np.int8, np.int16]:
a = t(3)
b = a ** 4
assert b == 81, "error with %r: got %r" % (t,b)
def check_large_types(self):
- for t in [N.int32, N.int64, N.float32, N.float64, N.longdouble]:
+ for t in [np.int32, np.int64, np.float32, np.float64, np.longdouble]:
a = t(51)
b = a ** 4
assert b == 6765201, "error with %r: got %r" % (t,b)
@@ -55,12 +53,20 @@
def test_int_from_long(self):
l = [1e6, 1e12, 1e18, -1e6, -1e12, -1e18]
li = [10**6, 10**12, 10**18, -10**6, -10**12, -10**18]
- for T in [None,N.float64,N.int64]:
- a = N.array(l,dtype=T)
+ for T in [None, np.float64, np.int64]:
+ a = np.array(l,dtype=T)
assert_equal(map(int,a), li)
- a = N.array(l[:3],dtype=N.uint64)
+ a = np.array(l[:3], dtype=np.uint64)
assert_equal(map(int,a), li[:3])
+#class TestRepr(NumpyTestCase):
+# def check_repr(self):
+# for t in types:
+# val = t(1197346475.0137341)
+# val_repr = repr(val)
+# val2 = eval(val_repr)
+# assert_equal( val, val2 )
+
if __name__ == "__main__":
NumpyTest().run()
Modified: branches/maskedarray/numpy/core/tests/test_ufunc.py
===================================================================
--- branches/maskedarray/numpy/core/tests/test_ufunc.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/tests/test_ufunc.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -1,15 +1,12 @@
+import numpy as np
from numpy.testing import *
-set_package_path()
-import numpy as N
-restore_path()
-
class TestUfunc(NumpyTestCase):
def test_reduceat_shifting_sum(self):
L = 6
- x = N.arange(L)
- idx = N.array(zip(N.arange(L-2),N.arange(L-2)+2)).ravel()
- assert_array_equal(N.add.reduceat(x,idx)[::2],
+ x = np.arange(L)
+ idx = np.array(zip(np.arange(L-2), np.arange(L-2)+2)).ravel()
+ assert_array_equal(np.add.reduceat(x,idx)[::2],
[1,3,5,7])
if __name__ == "__main__":
Modified: branches/maskedarray/numpy/core/tests/test_umath.py
===================================================================
--- branches/maskedarray/numpy/core/tests/test_umath.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/core/tests/test_umath.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -2,7 +2,7 @@
set_package_path()
from numpy.core.umath import minimum, maximum, exp
import numpy.core.umath as ncu
-from numpy import zeros, ndarray, array, choose
+from numpy import zeros, ndarray, array, choose, pi
restore_path()
class TestDivision(NumpyTestCase):
@@ -61,6 +61,16 @@
def check_floating_point(self):
assert_equal(ncu.FLOATING_POINT_SUPPORT, 1)
+def TestDegrees(NumpyTestCase):
+ def check_degrees(self):
+ assert_almost_equal(ncu.degrees(pi), 180.0)
+ assert_almost_equal(ncu.degrees(-0.5*pi), -90.0)
+
+def TestRadians(NumpyTestCase):
+ def check_radians(self):
+ assert_almost_equal(ncu.radians(180.0), pi)
+ assert_almost_equal(ncu.degrees(-90.0), -0.5*pi)
+
class TestSpecialMethods(NumpyTestCase):
def test_wrap(self):
class with_wrap(object):
Modified: branches/maskedarray/numpy/distutils/command/build_src.py
===================================================================
--- branches/maskedarray/numpy/distutils/command/build_src.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/distutils/command/build_src.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -4,6 +4,7 @@
import os
import re
import sys
+import shlex
from distutils.command import build_ext
from distutils.dep_util import newer_group, newer
@@ -24,7 +25,6 @@
appendpath, is_string, is_sequence
from numpy.distutils.from_template import process_file as process_f_file
from numpy.distutils.conv_template import process_file as process_c_file
-from numpy.distutils.exec_command import splitcmdline
class build_src(build_ext.build_ext):
@@ -94,7 +94,7 @@
if self.f2py_opts is None:
self.f2py_opts = []
else:
- self.f2py_opts = splitcmdline(self.f2py_opts)
+ self.f2py_opts = shlex.split(self.f2py_opts)
if self.swigflags:
if self.swig_opts:
@@ -106,7 +106,7 @@
if self.swig_opts is None:
self.swig_opts = []
else:
- self.swig_opts = splitcmdline(self.swig_opts)
+ self.swig_opts = shlex.split(self.swig_opts)
# use options from build_ext command
build_ext = self.get_finalized_command('build_ext')
Modified: branches/maskedarray/numpy/distutils/exec_command.py
===================================================================
--- branches/maskedarray/numpy/distutils/exec_command.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/distutils/exec_command.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -11,7 +11,6 @@
Provides functions:
exec_command --- execute command in a specified directory and
in the modified environment.
- splitcmdline --- inverse of ' '.join(argv)
find_executable --- locate a command using info from environment
variable PATH. Equivalent to posix `which`
command.
@@ -50,6 +49,7 @@
import os
import sys
+import shlex
from numpy.distutils.misc_util import is_sequence, make_temp_file
from numpy.distutils import log
@@ -59,8 +59,6 @@
fo.close()
return name
-############################################################
-
def get_pythonexe():
pythonexe = sys.executable
if os.name in ['nt','dos']:
@@ -70,58 +68,12 @@
assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
return pythonexe
-############################################################
-
def splitcmdline(line):
- """ Inverse of ' '.join(sys.argv).
- """
- log.debug('splitcmdline(%r)' % (line))
- lst = []
- flag = 0
- s,pc,cc = '','',''
- for nc in line+' ':
- if flag==0:
- flag = (pc != '\\' and \
- ((cc=='"' and 1) or (cc=="'" and 2) or \
- (cc==' ' and pc!=' ' and -2))) or flag
- elif flag==1:
- flag = (cc=='"' and pc!='\\' and nc==' ' and -1) or flag
- elif flag==2:
- flag = (cc=="'" and pc!='\\' and nc==' ' and -1) or flag
- if flag!=-2:
- s += cc
- if flag<0:
- flag = 0
- s = s.strip()
- if s:
- lst.append(s)
- s = ''
- pc,cc = cc,nc
- else:
- s = s.strip()
- if s:
- lst.append(s)
- log.debug('splitcmdline -> %r' % (lst))
- return lst
+ import warnings
+ warnings.warn('splitcmdline is deprecated; use shlex.split',
+ DeprecationWarning)
+ return shlex.split(line)
-def test_splitcmdline():
- l = splitcmdline('a b cc')
- assert l==['a','b','cc'], repr(l)
- l = splitcmdline('a')
- assert l==['a'], repr(l)
- l = splitcmdline('a " b cc"')
- assert l==['a','" b cc"'], repr(l)
- l = splitcmdline('"a bcc" -h')
- assert l==['"a bcc"','-h'], repr(l)
- l = splitcmdline(r'"\"a \" bcc" -h')
- assert l==[r'"\"a \" bcc"','-h'], repr(l)
- l = splitcmdline(" 'a bcc' -h")
- assert l==["'a bcc'",'-h'], repr(l)
- l = splitcmdline(r"'\'a \' bcc' -h")
- assert l==[r"'\'a \' bcc'",'-h'], repr(l)
-
-############################################################
-
def find_executable(exe, path=None, _cache={}):
"""Return full path of a executable or None.
@@ -379,7 +331,7 @@
if is_sequence(command):
argv = command[:]
else:
- argv = splitcmdline(command)
+ argv = shlex.split(command)
if hasattr(os,'spawnvpe'):
spawn_command = os.spawnvpe
@@ -632,7 +584,6 @@
if __name__ == "__main__":
- test_splitcmdline()
test(use_tee=0)
test(use_tee=1)
test_execute_in(use_tee=0)
Modified: branches/maskedarray/numpy/distutils/fcompiler/intel.py
===================================================================
--- branches/maskedarray/numpy/distutils/fcompiler/intel.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/distutils/fcompiler/intel.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -114,7 +114,7 @@
opt.remove('-shared')
except ValueError:
idx = 0
- opt[idx:idx] = ['-dynamiclib', '-Wl,-undefined,dynamic_lookup']
+ opt[idx:idx] = ['-dynamiclib', '-Wl,-undefined,dynamic_lookup', '-Wl,-framework,Python']
return opt
class IntelItaniumFCompiler(IntelFCompiler):
Modified: branches/maskedarray/numpy/distutils/interactive.py
===================================================================
--- branches/maskedarray/numpy/distutils/interactive.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/distutils/interactive.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -50,7 +50,7 @@
""" % (ccompiler, fcompiler, argv)
-from exec_command import splitcmdline
+import shlex
def edit_argv(*args):
argv = args[0]
@@ -62,7 +62,7 @@
except EOFError:
return
if s:
- argv[1:] = splitcmdline(s)
+ argv[1:] = shlex.split(s)
return
def interactive_sys_argv(argv):
Modified: branches/maskedarray/numpy/distutils/log.py
===================================================================
--- branches/maskedarray/numpy/distutils/log.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/distutils/log.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -18,9 +18,13 @@
def _log(self, level, msg, args):
if level >= self.threshold:
if args:
- print _global_color_map[level](msg % _fix_args(args))
- else:
- print _global_color_map[level](msg)
+ msg = msg % _fix_args(args)
+ if 0:
+ if msg.startswith('copying ') and msg.find(' -> ') != -1:
+ return
+ if msg.startswith('byte-compiling '):
+ return
+ print _global_color_map[level](msg)
sys.stdout.flush()
def good(self, msg, *args):
Modified: branches/maskedarray/numpy/doc/DISTUTILS.txt
===================================================================
--- branches/maskedarray/numpy/doc/DISTUTILS.txt 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/doc/DISTUTILS.txt 2008-01-18 23:25:32 UTC (rev 4730)
@@ -399,7 +399,6 @@
---------------------------------------
+ ``get_pythonexe()``
-+ ``splitcmdline(line)``
+ ``find_executable(exe, path=None)``
+ ``exec_command( command, execute_in='', use_shell=None, use_tee=None, **env )``
Modified: branches/maskedarray/numpy/doc/HOWTO_DOCUMENT.txt
===================================================================
--- branches/maskedarray/numpy/doc/HOWTO_DOCUMENT.txt 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/doc/HOWTO_DOCUMENT.txt 2008-01-18 23:25:32 UTC (rev 4730)
@@ -17,8 +17,14 @@
Use a code checker:
* `pylint `__
+ * `pyflakes` easy_install pyflakes
* `pep8.py `__
+Common import standards::
+
+ import numpy as np
+ import scipy as sp
+
Docstring Standard
------------------
@@ -27,7 +33,8 @@
of the object (``object.__doc__``) and, for consistency, is surrounded by
triple double quotes.
-It is highly desireable that both NumPy and SciPy_ follow a common
+It is highly desireable that both NumPy and SciPy_ and scikits to
+follow a common
convention for docstrings that provide for consistency while also
allowing epydoc_ to produce nicely-formatted reference guides. This
document describes the current community consensus for this standard.
@@ -36,30 +43,28 @@
Our docstring standard uses `reST
`__ syntax and is rendered
-using epydoc_. The markup in this proposal is as basic as possible
-and, in particular, avoids the use of epydoc consolidated fields. This
-is both because there are a limited number of such fields, inadequate
-to our current needs, and because epydoc moves the fields to the end
-of the documentation, messing up the ordering. Standard definition
-lists are used instead. Likewise, epydoc moves headings and have an
-unwelcome size in the default style sheet, therefore they are also
-avoided.
+using something like epydoc_ (+ a pre-processor which understands the
+particular documentation style we are using). The markup in this
+proposal is as basic as possible which still looks reasonable when the
+text is just printed. In particular, it avoids too much cruft in the
+reST syntax and other epydoc_-isms.
+The guiding principle is that human readers of the text itself are
+given precedence over contorting the docstring so that epydoc_
+produces nice output. In order to improve the rendered output we
+should work on making pre-processor tools to assist epydoc_ or another
+similar tool, rather than making human readers conform to a particular
+computer-imposed style.
Status
------
-We are currently trying to:
+We are currently trying to convert existing docstrings to the new
+format and write them for those that currently lack docstrings.
-1. Agree on docstring standards.
+We are also trying to improve the rendered output either using a
+pre-processor to epydoc or another tool similar to epydoc.
-2. Work with Ed loper to ensure that epydoc_ provides the functionality
- we need.
-
-3. Convert existing docstrings to the new format and write them for
- those that currently lack docstrings.
-
-
Sections
--------
@@ -84,7 +89,11 @@
functions with a large number of keyword argument can still be well
documented without cluttering the main parameters' list.
-6. **See also:**
+6. **Raises:**
+ An optional section detailing which errors get raised under what
+ conditions.
+
+7. **See also:**
An optional section used to refer to related code. This section
can be very useful, but should be used judiciously. The goal is to
direct users to other functions they may not be aware of, or have
@@ -92,17 +101,17 @@
example). Routines whose docstrings further explain parameters
used by this function are good candidates.
-7. **Notes:**
+8. **Notes:**
An optional section that provides additional information about the
code, possibly including a discussion of the algorithm. This
section may include mathematical equations, possibly written in
`LaTeX `__.
-8. **Examples:**
+9. **Examples:**
An optional section for examples, using the `doctest
`__ format. It
can provide an inline mini-tutorial as well as additional
- regression testing. While optional, this section is strongly
+ regression testing. While optional, this section is very strongly
encouraged. You can run the tests by doing::
>>> import doctest
@@ -123,15 +132,6 @@
Common reST concepts
--------------------
-A reST-documented module should define::
-
- __docformat__ = 'restructuredtext en'
-
-at the top level in accordance with `PEP 258
-`__. Note that the
-``__docformat__`` variable in a package's ``__init__.py`` file does
-not apply to objects defined in subpackages and submodules.
-
For paragraphs, indentation is significant and indicates indentation in the
output. New paragraphs are marked with blank line.
@@ -159,8 +159,9 @@
sudo python setup.py install
The appearance of some elements can be changed in the epydoc.css
-style sheet. The list headings, i.e. *Parameters*:, are emphasized text, so
-their appearance is controlled by the definition of the
+style sheet.
+
+Emphasized text appearance can be controlled by the definition of the
tag. For instance, to make them bold, insert::
em {font-weight: bold;}
@@ -201,10 +202,10 @@
Then, run epydoc::
- $ epydoc example.txt
+ $ epydoc example.py
The output is placed in ``./html``, and may be viewed by loading the
-``index.html`` file into your browser.
+``index.html`` file into your browser.
This document itself was written in ReStructuredText, and may be converted to
HTML using::
Modified: branches/maskedarray/numpy/doc/example.py
===================================================================
--- branches/maskedarray/numpy/doc/example.py 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/doc/example.py 2008-01-18 23:25:32 UTC (rev 4730)
@@ -15,64 +15,59 @@
import scipy as sp # imports should be at the top of the module
import matplotlib as mpl # imports should usually be on separate lines
-
-__docformat__ = "restructuredtext en"
-
-
def foo(var1, var2, long_var_name='hi') :
"""One-line summary or signature.
Several sentences providing an extended description. You can put
text in mono-spaced type like so: ``var``.
- *Parameters*:
+ Parameters
+ ----------
+ var1 : array_like
+ Array_like means all those objects -- lists, nested lists, etc. --
+ that can be converted to an array.
+ var2 : integer
+ Write out the full type
+ long_variable_name : {'hi', 'ho'}, optional
+ Choices in brackets, default first when optional.
- var1 : {array_like}
- Array_like means all those objects -- lists, nested lists, etc. --
- that can be converted to an array.
- var2 : {integer}
- Write out the full type
- long_variable_name : {'hi', 'ho'}, optional
- Choices in brackets, default first when optional.
+ Returns
+ -------
+ named : type
+ Explanation
+ list
+ Explanation
+ of
+ Explanation
+ outputs
+ even more explaining
- *Returns*:
+ Other Parameters
+ ----------------
+ only_seldom_used_keywords : type
+ Explanation
+ common_parametrs_listed_above : type
+ Explanation
- named : {type}
- Explanation
- list
- Explanation
- of
- Explanation
- outputs
- even more explaining
+ See Also
+ --------
+ otherfunc : relationship (optional)
+ newfunc : relationship (optional)
- *Other Parameters*:
+ Notes
+ -----
+ Notes about the implementation algorithm (if needed).
- only_seldom_used_keywords : type
- Explanation
- common_parametrs_listed_above : type
- Explanation
+ This can have multiple paragraphs as can all sections.
- *See Also*:
+ Examples
+ --------
+ examples in doctest format
- `otherfunc` : relationship (optional)
+ >>> a=[1,2,3]
+ >>> [x + 3 for x in a]
+ [4, 5, 6]
- `newfunc` : relationship (optional)
-
- *Notes*
-
- Notes about the implementation algorithm (if needed).
-
- This can have multiple paragraphs as can all sections.
-
- *Examples*
-
- examples in doctest format
-
- >>> a=[1,2,3]
- >>> [x + 3 for x in a]
- [4, 5, 6]
-
"""
pass
Modified: branches/maskedarray/numpy/doc/html/epydoc.css
===================================================================
--- branches/maskedarray/numpy/doc/html/epydoc.css 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/doc/html/epydoc.css 2008-01-18 23:25:32 UTC (rev 4730)
@@ -28,6 +28,8 @@
h3 { font-size: +110%; font-style: italic;
font-weight: normal; }
code { font-size: 100%; }
+/* N.B.: class, not pseudoclass */
+a.link { font-family: monospace; }
/* Page Header & Footer
* - The standard page header consists of a navigation bar (with
@@ -158,6 +160,11 @@
.summary-sig-arg { color: #006040; }
.summary-sig-default { color: #501800; }
+/* Subclass list
+ */
+ul.subclass-list { display: inline; }
+ul.subclass-list li { display: inline; }
+
/* To render variables, classes etc. like functions */
table.summary .summary-name { color: #006080; font-weight: bold;
font-family: monospace; }
Modified: branches/maskedarray/numpy/doc/html/epydoc.js
===================================================================
--- branches/maskedarray/numpy/doc/html/epydoc.js 2008-01-18 10:04:48 UTC (rev 4729)
+++ branches/maskedarray/numpy/doc/html/epydoc.js 2008-01-18 23:25:32 UTC (rev 4730)
@@ -17,8 +17,11 @@
if (elts[i].className == "private") {
elts[i].style.display = ((cmd && cmd.substr(0,4)=="hide")?"none":"block");
}
+ else if (elts[i].className == "public") {
+ elts[i].style.display = ((cmd && cmd.substr(0,4)=="hide")?"block":"none");
+ }
}
- // Update all table rowss containing private objects. Note, we
+ // Update all table rows containing private objects. Note, we
// use "" instead of "block" becaue IE & firefox disagree on what
// this should be (block vs table-row), and "" just gives the
// default for both browsers.
@@ -33,7 +36,7 @@
for(var i=0; i
Module example
source code
This is the docstring for the example.py module. Modules names should
-have short, all-lowercase names. The module name may have underscores if
-this improves readability.
-Every module should have a docstring at the very top of the file. The
-module's docstring may extend over multiple lines. If your docstring does
-extend over multiple lines, the closing three quotation marks must be on
-a line by itself, preferably preceeded by a blank line.
+ have short, all-lowercase names. The module name may have underscores if
+ this improves readability.
+ Every module should have a docstring at the very top of the file. The
+ module's docstring may extend over multiple lines. If your docstring
+ does extend over multiple lines, the closing three quotation marks must
+ be on a line by itself, preferably preceeded by a blank line.
@@ -166,63 +166,63 @@
source code
|
-
+
- One-line summary or signature.
-Several sentences providing an extended description. You can put
-text in mono-spaced type like so: var.
-Parameters:
-
-
-- var1 : {array_like}
-- Array_like means all those objects -- lists, nested lists, etc. --
-that can be converted to an array.
-- var2 : {integer}
-- Write out the full type
-- long_variable_name : {'hi', 'ho'}, optional
-- Choices in brackets, default first when optional.
-
-
-Returns:
-
-
-- named : {type}
-- Explanation
-- list
-- Explanation
-- of
-- Explanation
-- outputs
-- even more explaining
-
-
-Other Parameters:
-
-
-- only_seldom_used_keywords : type
-- Explanation
-- common_parametrs_listed_above : type
-- Explanation
-
-
-See Also:
-
-otherfunc : relationship (optional)
-newfunc : relationship (optional)
-
-Notes
-
-Notes about the implementation algorithm (if needed).
-This can have multiple paragraphs as can all sections.
-
-Examples
-
-examples in doctest format
-
->>> a=[1,2,3]
->>> [x + 3 for x in a]
-[4, 5, 6]
-
+
+One-line summary or signature.
+
+Several sentences providing an extended description. You can put
+text in mono-spaced type like so: ``var``.
+
+Parameters
+----------
+var1 : array_like
+ Array_like means all those objects -- lists, nested lists, etc. --
+ that can be converted to an array.
+var2 : integer
+ Write out the full type
+long_variable_name : {'hi', 'ho'}, optional
+ Choices in brackets, default first when optional.
+
+Returns
+-------
+named : type
+ Explanation
+list
+ Explanation
+of
+ Explanation
+outputs
+ even more explaining
+
+Other Parameters
+----------------
+only_seldom_used_keywords : type
+ Explanation
+common_parametrs_listed_above : type
+ Explanation
+
+See Also
+--------
+otherfunc : relationship (optional)
+newfunc : relationship (optional)
+
+Notes
+-----
+Notes about the implementation algorithm (if needed).
+
+This can have multiple paragraphs as can all sections.
+
+Examples
+--------
+
+examples in doctest format
+
+>>> a=[1,2,3]
+>>> [x + 3 for x in a]
+[4, 5, 6]
+
+
@@ -239,10 +239,10 @@
source code
|
-
+
Do nothing.
-I never saw a purple cow.
+ I never saw a purple cow.
@@ -259,10 +259,10 @@
source code
|
-
+
Do nothing.
-I never hope to see one.
+ I never hope to see one.
@@ -294,10 +294,11 @@
@@ -308,9 +309,8 @@
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
- checkCookie()
+ checkCookie();
// -->
-