[Numpy-svn] r5812 - in branches/clean_math_config: . doc doc/neps numpy/core numpy/core/include/numpy/fenv numpy/core/src numpy/core/tests numpy/distutils/command numpy/distutils/tests numpy/f2py numpy/fft/tests numpy/lib numpy/lib/tests numpy/ma numpy/ma/tests numpy/numarray numpy/testing numpy/tests

numpy-svn@scip... numpy-svn@scip...
Sat Sep 13 02:05:52 CDT 2008


Author: cdavid
Date: 2008-09-13 02:04:41 -0500 (Sat, 13 Sep 2008)
New Revision: 5812

Added:
   branches/clean_math_config/doc/neps/datetime-proposal3.rst
Removed:
   branches/clean_math_config/doc/neps/datetime.rst
Modified:
   branches/clean_math_config/
   branches/clean_math_config/doc/HOWTO_BUILD_DOCS.txt
   branches/clean_math_config/doc/HOWTO_DOCUMENT.txt
   branches/clean_math_config/numpy/core/fromnumeric.py
   branches/clean_math_config/numpy/core/include/numpy/fenv/fenv.h
   branches/clean_math_config/numpy/core/numeric.py
   branches/clean_math_config/numpy/core/src/ufuncobject.c
   branches/clean_math_config/numpy/core/tests/test_regression.py
   branches/clean_math_config/numpy/core/tests/test_scalarmath.py
   branches/clean_math_config/numpy/core/tests/test_umath.py
   branches/clean_math_config/numpy/distutils/command/scons.py
   branches/clean_math_config/numpy/distutils/tests/test_misc_util.py
   branches/clean_math_config/numpy/f2py/crackfortran.py
   branches/clean_math_config/numpy/fft/tests/test_fftpack.py
   branches/clean_math_config/numpy/fft/tests/test_helper.py
   branches/clean_math_config/numpy/lib/arraysetops.py
   branches/clean_math_config/numpy/lib/io.py
   branches/clean_math_config/numpy/lib/tests/test__datasource.py
   branches/clean_math_config/numpy/lib/tests/test_function_base.py
   branches/clean_math_config/numpy/lib/tests/test_io.py
   branches/clean_math_config/numpy/ma/core.py
   branches/clean_math_config/numpy/ma/tests/test_core.py
   branches/clean_math_config/numpy/ma/tests/test_old_ma.py
   branches/clean_math_config/numpy/ma/tests/test_subclassing.py
   branches/clean_math_config/numpy/numarray/alter_code2.py
   branches/clean_math_config/numpy/numarray/functions.py
   branches/clean_math_config/numpy/numarray/numerictypes.py
   branches/clean_math_config/numpy/numarray/session.py
   branches/clean_math_config/numpy/numarray/util.py
   branches/clean_math_config/numpy/testing/decorators.py
   branches/clean_math_config/numpy/testing/noseclasses.py
   branches/clean_math_config/numpy/testing/nosetester.py
   branches/clean_math_config/numpy/testing/utils.py
   branches/clean_math_config/numpy/tests/test_ctypeslib.py
Log:
Merged revisions 5762-5811 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

........
  r5768 | ptvirtan | 2008-09-05 03:04:35 +0900 (Fri, 05 Sep 2008) | 1 line
  
  Ufunc docstrings: show the 'out' arguments in a more standard way
........
  r5769 | alan.mcintyre | 2008-09-05 03:23:48 +0900 (Fri, 05 Sep 2008) | 4 lines
  
  Replaced numpy.testing.decorators.skipknownfailure with knownfailureif, 
  which allows flagging tests as known failures rather than skips.
  Updated test_umath to use knownfailureif.
........
  r5770 | alan.mcintyre | 2008-09-05 06:13:29 +0900 (Fri, 05 Sep 2008) | 2 lines
  
  Renamed classes to conform to PEP 8.
........
  r5771 | alan.mcintyre | 2008-09-05 07:06:01 +0900 (Fri, 05 Sep 2008) | 2 lines
  
  Fix link to example.py.
........
  r5772 | alan.mcintyre | 2008-09-05 10:20:09 +0900 (Fri, 05 Sep 2008) | 2 lines
  
  Remove debugging code.
........
  r5788 | dhuard | 2008-09-05 22:58:00 +0900 (Fri, 05 Sep 2008) | 1 line
  
  Applied patch from R. May fixing ticket #905 (loadtxt). Fixed other bug occurring when both usecols and converters are provided. Added related regression tests.
........
  r5789 | oliphant | 2008-09-05 23:06:02 +0900 (Fri, 05 Sep 2008) | 1 line
  
  Add final date-time proposal.
........
  r5791 | pierregm | 2008-09-06 08:38:44 +0900 (Sat, 06 Sep 2008) | 1 line
  
  * fixed deepcopy of masked arrays (bug #906)
........
  r5793 | cdavid | 2008-09-07 16:16:28 +0900 (Sun, 07 Sep 2008) | 8 lines
  
  scons command: fix one more issue related to build dir.
  
  The distutils installation directory relative to the scons build directory was
  not always computed right. The relative position on the fs does not depend on
  the source directory (in out-of-place builds), but on the package *name*
  translated to a directly only.
........
  r5796 | pearu | 2008-09-09 19:55:30 +0900 (Tue, 09 Sep 2008) | 1 line
  
  Fix typo.
........
  r5797 | stefan | 2008-09-09 22:38:34 +0900 (Tue, 09 Sep 2008) | 2 lines
  
  FIX: Loadtxt raises on empty input (closes #908).
........
  r5799 | alan.mcintyre | 2008-09-10 02:48:47 +0900 (Wed, 10 Sep 2008) | 2 lines
  
  Removed unused imports.
........
  r5800 | pierregm | 2008-09-10 03:25:15 +0900 (Wed, 10 Sep 2008) | 1 line
  
  * make sure that minimum & maximum actually return a MaskedArray
........
  r5803 | pierregm | 2008-09-12 04:54:31 +0900 (Fri, 12 Sep 2008) | 1 line
  
  * fixed view for MaskedArrays w/ flexible dtype
........
  r5804 | jarrod.millman | 2008-09-13 04:20:26 +0900 (Sat, 13 Sep 2008) | 2 lines
  
  FIX: broken links
........
  r5805 | jarrod.millman | 2008-09-13 04:23:20 +0900 (Sat, 13 Sep 2008) | 2 lines
  
  FIX: broken links
........
  r5806 | alan.mcintyre | 2008-09-13 11:53:53 +0900 (Sat, 13 Sep 2008) | 2 lines
  
  Fix failing doctests.
........
  r5807 | alan.mcintyre | 2008-09-13 11:56:33 +0900 (Sat, 13 Sep 2008) | 2 lines
  
  Remove unused imports.
........
  r5808 | alan.mcintyre | 2008-09-13 12:40:57 +0900 (Sat, 13 Sep 2008) | 7 lines
  
  Removed unused/duplicate imports.
  Removed repeated members of __all__.
  Fixed reference to undefined "out" in functions.py:take function.
  Fixed references to undefined "N" in functions.py.
  Rewrapped lines to conform to PEP8.
  Fixed references to undefined FPE_* constants (from numpy) in util.py.
........
  r5809 | cdavid | 2008-09-13 15:03:30 +0900 (Sat, 13 Sep 2008) | 6 lines
  
  Fix cygwin compilation
  
  Recent version of binutils (2.18.50) do not accept 4 bytes operand for some
  opcodes like fnstsw (which always expected a 2 bytes operand). Replace the type
  of the argument from unsigned 2 bytes to unsigned 4 bytes unsigned integer.
........
  r5810 | cdavid | 2008-09-13 15:27:46 +0900 (Sat, 13 Sep 2008) | 1 line
  
  Tag ctypes load library tests as known failures on cygwin.
........



Property changes on: branches/clean_math_config
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5257 /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 /branches/vs_longstring:1-5656 /cleaned_math_config:1-5731 /trunk:1-5761
   + /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5257 /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 /branches/vs_longstring:1-5656 /cleaned_math_config:1-5731 /trunk:1-5811

Modified: branches/clean_math_config/doc/HOWTO_BUILD_DOCS.txt
===================================================================
--- branches/clean_math_config/doc/HOWTO_BUILD_DOCS.txt	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/doc/HOWTO_BUILD_DOCS.txt	2008-09-13 07:04:41 UTC (rev 5812)
@@ -50,13 +50,13 @@
 Example
 -------
 Here is a short example module,
-`plain text <http://svn.scipy.org/svn/numpy/trunk/numpy/doc/example.py>`_
+`plain text <http://svn.scipy.org/svn/numpy/trunk/doc/example.py>`_
 or
 `rendered <http://www.scipy.org/doc/example>`_ in HTML.
 
 To try this yourself, simply download the example.py::
 
-  svn co http://svn.scipy.org/svn/numpy/trunk/numpy/doc/example.py .
+  svn co http://svn.scipy.org/svn/numpy/trunk/doc/example.py .
 
 Then, run epydoc::
 

Modified: branches/clean_math_config/doc/HOWTO_DOCUMENT.txt
===================================================================
--- branches/clean_math_config/doc/HOWTO_DOCUMENT.txt	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/doc/HOWTO_DOCUMENT.txt	2008-09-13 07:04:41 UTC (rev 5812)
@@ -7,7 +7,7 @@
 .. Note::
 
    For an accompanying example, see `example.py
-   <http://svn.scipy.org/svn/numpy/trunk/numpy/doc/example.py>`_.
+   <http://svn.scipy.org/svn/numpy/trunk/doc/example.py>`_.
 
 Overview
 --------
@@ -413,10 +413,10 @@
 ----------
 
 `An example
-<http://svn.scipy.org/svn/numpy/trunk/numpy/doc/example.py>`_ of the
+<http://svn.scipy.org/svn/numpy/trunk/doc/example.py>`_ of the
 format shown here is available.  Refer to `How to Build API/Reference
 Documentation
-<http://svn.scipy.org/svn/numpy/trunk/numpy/doc/HOWTO_BUILD_DOCS.txt>`_
+<http://svn.scipy.org/svn/numpy/trunk/doc/HOWTO_BUILD_DOCS.txt>`_
 on how to use epydoc_ or sphinx_ to construct a manual and web page.
 
 This document itself was written in ReStructuredText, and may be converted to

Copied: branches/clean_math_config/doc/neps/datetime-proposal3.rst (from rev 5810, trunk/doc/neps/datetime-proposal3.rst)

Deleted: branches/clean_math_config/doc/neps/datetime.rst
===================================================================
--- branches/clean_math_config/doc/neps/datetime.rst	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/doc/neps/datetime.rst	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,354 +0,0 @@
-====================================================================
- A (second) proposal for implementing some date/time types in NumPy
-====================================================================
-
-:Author: Francesc Alted i Abad
-:Contact: faltet@pytables.com
-:Author: Ivan Vilata i Balaguer
-:Contact: ivan@selidor.net
-:Date: 2008-07-16
-
-
-Executive summary
-=================
-
-A date/time mark is something very handy to have in many fields where
-one has to deal with data sets.  While Python has several modules that
-define a date/time type (like the integrated ``datetime`` [1]_ or
-``mx.DateTime`` [2]_), NumPy has a lack of them.
-
-In this document, we are proposing the addition of a series of date/time
-types to fill this gap.  The requirements for the proposed types are
-two-folded: 1) they have to be fast to operate with and 2) they have to
-be as compatible as possible with the existing ``datetime`` module that
-comes with Python.
-
-
-Types proposed
-==============
-
-To start with, it is virtually impossible to come up with a single
-date/time type that fills the needs of every case of use.  So, after
-pondering about different possibilities, we have stick with *two*
-different types, namely ``datetime64`` and ``timedelta64`` (these names
-are preliminary and can be changed), that can have different resolutions
-so as to cover different needs.
-
-**Important note:** the resolution is conceived here as a metadata that
-  *complements* a date/time dtype, *without changing the base type*.
-
-Now it goes a detailed description of the proposed types.
-
-
-``datetime64``
---------------
-
-It represents a time that is absolute (i.e. not relative).  It is
-implemented internally as an ``int64`` type.  The internal epoch is
-POSIX epoch (see [3]_).
-
-Resolution
-~~~~~~~~~~
-
-It accepts different resolutions and for each of these resolutions, it
-will support different time spans.  The table below describes the
-resolutions supported with its corresponding time spans.
-
-+----------------------+----------------------------------+
-|     Resolution       |         Time span (years)        |
-+----------------------+----------------------------------+
-|  Code |   Meaning    |                                  |
-+======================+==================================+
-|   Y   |  year        |      [9.2e18 BC, 9.2e18 AC]      |
-|   Q   |  quarter     |      [3.0e18 BC, 3.0e18 AC]      |
-|   M   |  month       |      [7.6e17 BC, 7.6e17 AC]      |
-|   W   |  week        |      [1.7e17 BC, 1.7e17 AC]      |
-|   d   |  day         |      [2.5e16 BC, 2.5e16 AC]      |
-|   h   |  hour        |      [1.0e15 BC, 1.0e15 AC]      |
-|   m   |  minute      |      [1.7e13 BC, 1.7e13 AC]      |
-|   s   |  second      |      [ 2.9e9 BC,  2.9e9 AC]      |
-|   ms  |  millisecond |      [ 2.9e6 BC,  2.9e6 AC]      |
-|   us  |  microsecond |      [290301 BC, 294241 AC]      |
-|   ns  |  nanosecond  |      [  1678 AC,   2262 AC]      |
-+----------------------+----------------------------------+
-
-Building a ``datetime64`` dtype
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The proposed way to specify the resolution in the dtype constructor
-is:
-
-Using parameters in the constructor::
-
-  dtype('datetime64', res="us")  # the default res. is microseconds
-
-Using the long string notation::
-
-  dtype('datetime64[us]')   # equivalent to dtype('datetime64')
-
-Using the short string notation::
-
-  dtype('T8[us]')   # equivalent to dtype('T8')
-
-Compatibility issues
-~~~~~~~~~~~~~~~~~~~~
-
-This will be fully compatible with the ``datetime`` class of the
-``datetime`` module of Python only when using a resolution of
-microseconds.  For other resolutions, the conversion process will
-loose precision or will overflow as needed.
-
-
-``timedelta64``
----------------
-
-It represents a time that is relative (i.e. not absolute).  It is
-implemented internally as an ``int64`` type.
-
-Resolution
-~~~~~~~~~~
-
-It accepts different resolutions and for each of these resolutions, it
-will support different time spans.  The table below describes the
-resolutions supported with its corresponding time spans.
-
-+----------------------+--------------------------+
-|     Resolution       |         Time span        |
-+----------------------+--------------------------+
-|  Code |   Meaning    |                          |
-+======================+==========================+
-|   W   |  week        |      +- 1.7e17 years     |
-|   D   |  day         |      +- 2.5e16 years     |
-|   h   |  hour        |      +- 1.0e15 years     |
-|   m   |  minute      |      +- 1.7e13 years     |
-|   s   |  second      |      +- 2.9e12 years     |
-|   ms  |  millisecond |      +- 2.9e9 years      |
-|   us  |  microsecond |      +- 2.9e6 years      |
-|   ns  |  nanosecond  |      +- 292 years        |
-|   ps  |  picosecond  |      +- 106 days         |
-|   fs  |  femtosecond |      +- 2.6 hours        |
-|   as  |  attosecond  |      +- 9.2 seconds      |
-+----------------------+--------------------------+
-
-Building a ``timedelta64`` dtype
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The proposed way to specify the resolution in the dtype constructor
-is:
-
-Using parameters in the constructor::
-
-  dtype('timedelta64', res="us")  # the default res. is microseconds
-
-Using the long string notation::
-
-  dtype('timedelta64[us]')   # equivalent to dtype('datetime64')
-
-Using the short string notation::
-
-  dtype('t8[us]')   # equivalent to dtype('t8')
-
-Compatibility issues
-~~~~~~~~~~~~~~~~~~~~
-
-This will be fully compatible with the ``timedelta`` class of the
-``datetime`` module of Python only when using a resolution of
-microseconds.  For other resolutions, the conversion process will
-loose precision or will overflow as needed.
-
-
-Example of use
-==============
-
-Here it is an example of use for the ``datetime64``::
-
-  In [10]: t = numpy.zeros(5, dtype="datetime64[ms]")
-
-  In [11]: t[0] = datetime.datetime.now()  # setter in action
-
-  In [12]: t[0]
-  Out[12]: '2008-07-16T13:39:25.315'   # representation in ISO 8601 format
-
-  In [13]: print t
-  [2008-07-16T13:39:25.315  1970-01-01T00:00:00.0
-  1970-01-01T00:00:00.0  1970-01-01T00:00:00.0  1970-01-01T00:00:00.0]
-
-  In [14]: t[0].item()     # getter in action
-  Out[14]: datetime.datetime(2008, 7, 16, 13, 39, 25, 315000)
-
-  In [15]: print t.dtype
-  datetime64[ms]
-
-And here it goes an example of use for the ``timedelta64``::
-
-  In [8]: t1 = numpy.zeros(5, dtype="datetime64[s]")
-
-  In [9]: t2 = numpy.ones(5, dtype="datetime64[s]")
-
-  In [10]: t = t2 - t1
-
-  In [11]: t[0] = 24  # setter in action (setting to 24 seconds)
-
-  In [12]: t[0]
-  Out[12]: 24       # representation as an int64
-
-  In [13]: print t
-  [24  1  1  1  1]
-
-  In [14]: t[0].item()     # getter in action
-  Out[14]: datetime.timedelta(0, 24)
-
-  In [15]: print t.dtype
-  timedelta64[s]
-
-
-Operating with date/time arrays
-===============================
-
-``datetime64`` vs ``datetime64``
---------------------------------
-
-The only operation allowed between absolute dates is the subtraction::
-
-  In [10]: numpy.ones(5, "T8") - numpy.zeros(5, "T8")
-  Out[10]: array([1, 1, 1, 1, 1], dtype=timedelta64[us])
-
-But not other operations::
-
-  In [11]: numpy.ones(5, "T8") + numpy.zeros(5, "T8")
-  TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'numpy.ndarray'
-
-``datetime64`` vs ``timedelta64``
----------------------------------
-
-It will be possible to add and subtract relative times from absolute
-dates::
-
-  In [10]: numpy.zeros(5, "T8[Y]") + numpy.ones(5, "t8[Y]")
-  Out[10]: array([1971, 1971, 1971, 1971, 1971], dtype=datetime64[Y])
-
-  In [11]: numpy.ones(5, "T8[Y]") - 2 * numpy.ones(5, "t8[Y]")
-  Out[11]: array([1969, 1969, 1969, 1969, 1969], dtype=datetime64[Y])
-
-But not other operations::
-
-  In [12]: numpy.ones(5, "T8[Y]") * numpy.ones(5, "t8[Y]")
-  TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'numpy.ndarray'
-
-``timedelta64`` vs anything
----------------------------
-
-Finally, it will be possible to operate with relative times as if they
-were regular int64 dtypes *as long as* the result can be converted back
-into a ``timedelta64``::
-
-  In [10]: numpy.ones(5, 't8')
-  Out[10]: array([1, 1, 1, 1, 1], dtype=timedelta64[us])
-
-  In [11]: (numpy.ones(5, 't8[M]') + 2) ** 3
-  Out[11]: array([27, 27, 27, 27, 27], dtype=timedelta64[M])
-
-But::
-
-  In [12]: numpy.ones(5, 't8') + 1j
-  TypeError: The result cannot be converted into a ``timedelta64``
-
-
-dtype/resolution conversions
-============================
-
-For changing the date/time dtype of an existing array, we propose to use
-the ``.astype()`` method.  This will be mainly useful for changing
-resolutions.
-
-For example, for absolute dates::
-
-  In[10]: t1 = numpy.zeros(5, dtype="datetime64[s]")
-
-  In[11]: print t1
-  [1970-01-01T00:00:00  1970-01-01T00:00:00  1970-01-01T00:00:00
-   1970-01-01T00:00:00  1970-01-01T00:00:00]
-
-  In[12]: print t1.astype('datetime64[d]')
-  [1970-01-01  1970-01-01  1970-01-01  1970-01-01  1970-01-01]
-
-For relative times::
-
-  In[10]: t1 = numpy.ones(5, dtype="timedelta64[s]")
-
-  In[11]: print t1
-  [1 1 1 1 1]
-
-  In[12]: print t1.astype('timedelta64[ms]')
-  [1000 1000 1000 1000 1000]
-
-Changing directly from/to relative to/from absolute dtypes will not be
-supported::
-
-  In[13]: numpy.zeros(5, dtype="datetime64[s]").astype('timedelta64')
-  TypeError: data type cannot be converted to the desired type
-
-
-Final considerations
-====================
-
-Why the ``origin`` metadata disappeared
----------------------------------------
-
-During the discussion of the date/time dtypes in the NumPy list, the
-idea of having an ``origin`` metadata that complemented the definition
-of the absolute ``datetime64`` was initially found to be useful.
-
-However, after thinking more about this, Ivan and me find that the
-combination of an absolute ``datetime64`` with a relative
-``timedelta64`` does offer the same functionality while removing the
-need for the additional ``origin`` metadata.  This is why we have
-removed it from this proposal.
-
-
-Resolution and dtype issues
----------------------------
-
-The date/time dtype's resolution metadata cannot be used in general as
-part of typical dtype usage.  For example, in::
-
-  numpy.zeros(5, dtype=numpy.datetime64)
-
-we have to found yet a sensible way to pass the resolution.  Perhaps the
-next would work::
-
-  numpy.zeros(5, dtype=numpy.datetime64(res='Y'))
-
-but we are not sure if this would collide with the spirit of the NumPy
-dtypes.
-
-At any rate, one can always do::
-
-  numpy.zeros(5, dtype=numpy.dtype('datetime64', res='Y'))
-
-BTW, prior to all of this, one should also elucidate whether::
-
-  numpy.dtype('datetime64', res='Y')
-
-or::
-
-   numpy.dtype('datetime64[Y]')
-   numpy.dtype('T8[Y]')
-
-would be a consistent way to instantiate a dtype in NumPy.  We do really
-think that could be a good way, but we would need to hear the opinion of
-the expert.  Travis?
-
-
-
-.. [1] http://docs.python.org/lib/module-datetime.html
-.. [2] http://www.egenix.com/products/python/mxBase/mxDateTime
-.. [3] http://en.wikipedia.org/wiki/Unix_time
-
-
-.. Local Variables:
-.. mode: rst
-.. coding: utf-8
-.. fill-column: 72
-.. End:
-

Modified: branches/clean_math_config/numpy/core/fromnumeric.py
===================================================================
--- branches/clean_math_config/numpy/core/fromnumeric.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/fromnumeric.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1617,12 +1617,14 @@
 
     >>> x = np.array([1, 2, 3], dtype=np.uint8)
     >>> np.prod(x).dtype == np.uint
+    True
 
     If `x` is of a signed integer type, then the output type
     is the default platform integer:
 
     >>> x = np.array([1, 2, 3], dtype=np.int8)
     >>> np.prod(x).dtype == np.int
+    True
 
     """
     try:

Modified: branches/clean_math_config/numpy/core/include/numpy/fenv/fenv.h
===================================================================
--- branches/clean_math_config/numpy/core/include/numpy/fenv/fenv.h	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/include/numpy/fenv/fenv.h	2008-09-13 07:04:41 UTC (rev 5812)
@@ -91,7 +91,7 @@
 static __inline int
 fegetexceptflag(fexcept_t *__flagp, int __excepts)
 {
-	int __status;
+	__uint16_t __status;
 
 	__fnstsw(&__status);
 	*__flagp = __status & __excepts;
@@ -123,7 +123,7 @@
 static __inline int
 fetestexcept(int __excepts)
 {
-	int __status;
+	__uint16_t __status;
 
 	__fnstsw(&__status);
 	return (__status & __excepts);
@@ -187,7 +187,7 @@
 static __inline int
 feupdateenv(const fenv_t *__envp)
 {
-	int __status;
+	__uint16_t __status;
 
 	__fnstsw(&__status);
 	__fldenv(*__envp);

Modified: branches/clean_math_config/numpy/core/numeric.py
===================================================================
--- branches/clean_math_config/numpy/core/numeric.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/numeric.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -765,7 +765,7 @@
     >>> b = np.arange(24.).reshape(4,3,2)
     >>> c = np.tensordot(a,b, axes=([1,0],[0,1]))
     >>> c.shape
-    (5,2)
+    (5, 2)
     >>> c
     array([[ 4400.,  4730.],
            [ 4532.,  4874.],
@@ -774,7 +774,7 @@
            [ 4928.,  5306.]])
 
     >>> # A slower but equivalent way of computing the same...
-    >>> c = zeros((5,2))
+    >>> c = np.zeros((5,2))
     >>> for i in range(5):
     ...   for j in range(2):
     ...     for k in range(3):

Modified: branches/clean_math_config/numpy/core/src/ufuncobject.c
===================================================================
--- branches/clean_math_config/numpy/core/src/ufuncobject.c	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/src/ufuncobject.c	2008-09-13 07:04:41 UTC (rev 5812)
@@ -4046,19 +4046,20 @@
    y1,y2,...,yn
 */
 static PyObject *
-_makeargs(int num, char *ltr)
+_makeargs(int num, char *ltr, int null_if_none)
 {
     PyObject *str;
     int i;
     switch (num) {
     case 0:
+        if (null_if_none) return NULL;
         return PyString_FromString("");
     case 1:
         return PyString_FromString(ltr);
     }
-    str = PyString_FromFormat("%s1,%s2", ltr, ltr);
+    str = PyString_FromFormat("%s1, %s2", ltr, ltr);
     for(i = 3; i <= num; ++i) {
-        PyString_ConcatAndDel(&str, PyString_FromFormat(",%s%d", ltr, i));
+        PyString_ConcatAndDel(&str, PyString_FromFormat(", %s%d", ltr, i));
     }
     return str;
 }
@@ -4082,17 +4083,26 @@
     /* to automate the first part of it */
     /* the doc string shouldn't need the calling convention */
     /* construct
-       y1,y2,,... = name(x1,x2,...) __doc__
+       name(x1, x2, ...,[ out1, out2, ...])
+       
+       __doc__
     */
     PyObject *outargs, *inargs, *doc;
-    outargs = _makeargs(self->nout, "y");
-    inargs = _makeargs(self->nin, "x");
-    doc = PyString_FromFormat("%s = %s(%s)\n\n%s",
-                              PyString_AS_STRING(outargs),
-                              self->name,
-                              PyString_AS_STRING(inargs),
-                              self->doc);
-    Py_DECREF(outargs);
+    outargs = _makeargs(self->nout, "out", 1);
+    inargs = _makeargs(self->nin, "x", 0);
+    if (outargs == NULL) {
+        doc = PyString_FromFormat("%s(%s)\n\n%s",
+                                  self->name,
+                                  PyString_AS_STRING(inargs),
+                                  self->doc);
+    } else {
+        doc = PyString_FromFormat("%s(%s[, %s])\n\n%s",
+                                  self->name,
+                                  PyString_AS_STRING(inargs),
+                                  PyString_AS_STRING(outargs),
+                                  self->doc);
+        Py_DECREF(outargs);
+    }
     Py_DECREF(inargs);
     return doc;
 }

Modified: branches/clean_math_config/numpy/core/tests/test_regression.py
===================================================================
--- branches/clean_math_config/numpy/core/tests/test_regression.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/tests/test_regression.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -87,7 +87,6 @@
 
     def test_char_dump(self,level=rlevel):
         """Ticket #50"""
-        import tempfile
         f = StringIO()
         ca = np.char.array(np.arange(1000,1010),itemsize=4)
         ca.dump(f)

Modified: branches/clean_math_config/numpy/core/tests/test_scalarmath.py
===================================================================
--- branches/clean_math_config/numpy/core/tests/test_scalarmath.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/tests/test_scalarmath.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,5 +1,4 @@
 from numpy.testing import *
-import numpy.core.umath as ncu
 import numpy as np
 
 types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
@@ -77,7 +76,6 @@
 
 class TestRepr(TestCase):
     def test_float_repr(self):
-        from numpy import nan, inf
         for t in [np.float32, np.float64, np.longdouble]:
             if t is np.longdouble: # skip it for now.
                 continue

Modified: branches/clean_math_config/numpy/core/tests/test_umath.py
===================================================================
--- branches/clean_math_config/numpy/core/tests/test_umath.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/core/tests/test_umath.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,8 +1,6 @@
 from numpy.testing import *
 import numpy.core.umath as ncu
 import numpy as np
-import nose
-from numpy import inf, nan, pi
 
 class TestDivision(TestCase):
     def test_division_int(self):
@@ -229,6 +227,7 @@
         yield _check_branch_cut, np.arccosh, [-2j, 2j, 2], [1,  1,  1j], 1, 1
         yield _check_branch_cut, np.arctanh, [-2j, 2j, 0], [1,  1,  1j], 1, 1
 
+    @dec.knownfailureif(True, "These branch cuts are known to fail")
     def test_branch_cuts_failing(self):
         # XXX: signed zeros are not OK for sqrt or for the arc* functions
         yield _check_branch_cut, np.sqrt,  -0.5, 1j, 1, -1, True
@@ -238,7 +237,6 @@
         yield _check_branch_cut, np.arcsinh, [-2j,  2j], [-1,   1], -1, 1, True
         yield _check_branch_cut, np.arccosh, [ -1, 0.5], [1j,  1j], 1, -1, True
         yield _check_branch_cut, np.arctanh, [ -2,   2], [1j, -1j], 1, -1, True
-    test_branch_cuts_failing = dec.skipknownfailure(test_branch_cuts_failing)
 
     def test_against_cmath(self):
         import cmath, sys
@@ -271,7 +269,7 @@
     def test_attributes(self):
         add = ncu.add
         assert_equal(add.__name__, 'add')
-        assert add.__doc__.startswith('y = add(x1,x2)\n\n')
+        assert add.__doc__.startswith('add(x1, x2[, out])\n\n')
         self.failUnless(add.ntypes >= 18) # don't fail if types added
         self.failUnless('ii->i' in add.types)
         assert_equal(add.nin, 2)

Modified: branches/clean_math_config/numpy/distutils/command/scons.py
===================================================================
--- branches/clean_math_config/numpy/distutils/command/scons.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/distutils/command/scons.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -44,11 +44,12 @@
     from numscons import get_scons_path
     return get_scons_path()
 
-def get_distutils_libdir(cmd, sconscript_path):
+def get_distutils_libdir(cmd, pkg):
     """Returns the path where distutils install libraries, relatively to the
     scons build directory."""
     from numscons import get_scons_build_dir
-    scdir = pjoin(get_scons_build_dir(), pdirname(sconscript_path))
+    from numscons.core.utils import pkg_to_path
+    scdir = pjoin(get_scons_build_dir(), pkg_to_path(pkg))
     n = scdir.count(os.sep)
     return pjoin(os.sep.join([os.pardir for i in range(n+1)]), cmd.build_lib)
 
@@ -424,7 +425,7 @@
                 #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib,
                 #                                                    pdirname(sconscript))))
                 cmd.append('distutils_libdir=%s' %
-                             protect_path(get_distutils_libdir(self, sconscript)))
+                             protect_path(get_distutils_libdir(self, pkg_name)))
 
                 if not self._bypass_distutils_cc:
                     cmd.append('cc_opt=%s' % self.scons_compiler)

Modified: branches/clean_math_config/numpy/distutils/tests/test_misc_util.py
===================================================================
--- branches/clean_math_config/numpy/distutils/tests/test_misc_util.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/distutils/tests/test_misc_util.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,10 +1,8 @@
 #!/usr/bin/env python
 
-import os
-import sys
 from numpy.testing import *
 from numpy.distutils.misc_util import appendpath, minrelpath, gpaths, rel_path
-from os.path import join, sep
+from os.path import join, sep, dirname
 
 ajoin = lambda *paths: join(*((sep,)+paths))
 
@@ -35,8 +33,7 @@
 class TestMinrelpath(TestCase):
 
     def test_1(self):
-        import os
-        n = lambda path: path.replace('/',os.path.sep)
+        n = lambda path: path.replace('/',sep)
         assert_equal(minrelpath(n('aa/bb')),n('aa/bb'))
         assert_equal(minrelpath('..'),'..')
         assert_equal(minrelpath(n('aa/..')),'')
@@ -50,11 +47,11 @@
 class TestGpaths(TestCase):
 
     def test_gpaths(self):
-        local_path = minrelpath(os.path.join(os.path.dirname(__file__),'..'))
+        local_path = minrelpath(join(dirname(__file__),'..'))
         ls = gpaths('command/*.py', local_path)
-        assert os.path.join(local_path,'command','build_src.py') in ls,`ls`
+        assert join(local_path,'command','build_src.py') in ls,`ls`
         f = gpaths('system_info.py', local_path)
-        assert os.path.join(local_path,'system_info.py')==f[0],`f`
+        assert join(local_path,'system_info.py')==f[0],`f`
 
 
 if __name__ == "__main__":

Modified: branches/clean_math_config/numpy/f2py/crackfortran.py
===================================================================
--- branches/clean_math_config/numpy/f2py/crackfortran.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/f2py/crackfortran.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -327,7 +327,7 @@
                 if rl[:4].lower()=='f2py': # f2py directive
                     l = l + 4*' '
                     r=commentline.match(rl[4:])
-                    if r: l=l+r('line')
+                    if r: l=l+r.group('line')
                     else: l = l + rl[4:]
         if l.strip()=='': # Skip empty line
             cont=0

Modified: branches/clean_math_config/numpy/fft/tests/test_fftpack.py
===================================================================
--- branches/clean_math_config/numpy/fft/tests/test_fftpack.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/fft/tests/test_fftpack.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,4 +1,3 @@
-import sys
 from numpy.testing import *
 import numpy as np
 

Modified: branches/clean_math_config/numpy/fft/tests/test_helper.py
===================================================================
--- branches/clean_math_config/numpy/fft/tests/test_helper.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/fft/tests/test_helper.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -3,7 +3,6 @@
 """ Test functions for fftpack.helper module
 """
 
-import sys
 from numpy.testing import *
 from numpy.fft import fftshift,ifftshift,fftfreq
 

Modified: branches/clean_math_config/numpy/lib/arraysetops.py
===================================================================
--- branches/clean_math_config/numpy/lib/arraysetops.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/lib/arraysetops.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -35,7 +35,6 @@
 __all__ = ['ediff1d', 'unique1d', 'intersect1d', 'intersect1d_nu', 'setxor1d',
            'setmember1d', 'union1d', 'setdiff1d']
 
-import time
 import numpy as np
 
 def ediff1d(ary, to_end=None, to_begin=None):

Modified: branches/clean_math_config/numpy/lib/io.py
===================================================================
--- branches/clean_math_config/numpy/lib/io.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/lib/io.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -313,6 +313,9 @@
     """
     user_converters = converters
 
+    if usecols is not None:
+        usecols = list(usecols)
+
     if _string_like(fname):
         if fname.endswith('.gz'):
             import gzip
@@ -358,6 +361,8 @@
     first_vals = None
     while not first_vals:
         first_line = fh.readline()
+        if first_line == '': # EOF reached
+            raise IOError('End-of-file reached before encountering data.')
         first_vals = split_line(first_line)
     N = len(usecols or first_vals)
 
@@ -373,7 +378,7 @@
     # By preference, use the converters specified by the user
     for i, conv in (user_converters or {}).iteritems():
         if usecols:
-            i = usecols.find(i)
+            i = usecols.index(i)
         converters[i] = conv
 
     # Parse each line, including the first

Modified: branches/clean_math_config/numpy/lib/tests/test__datasource.py
===================================================================
--- branches/clean_math_config/numpy/lib/tests/test__datasource.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/lib/tests/test__datasource.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,7 +1,4 @@
-
 import os
-import sys
-import struct
 from tempfile import mkdtemp, mkstemp, NamedTemporaryFile
 from shutil import rmtree
 from urlparse import urlparse

Modified: branches/clean_math_config/numpy/lib/tests/test_function_base.py
===================================================================
--- branches/clean_math_config/numpy/lib/tests/test_function_base.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/lib/tests/test_function_base.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,4 +1,3 @@
-import sys
 import warnings
 
 from numpy.testing import *

Modified: branches/clean_math_config/numpy/lib/tests/test_io.py
===================================================================
--- branches/clean_math_config/numpy/lib/tests/test_io.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/lib/tests/test_io.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -140,7 +140,6 @@
         y = np.loadtxt(d, dtype=mydescriptor)
         assert_array_equal(y, b)
 
-
     def test_array(self):
         c = StringIO.StringIO()
         c.write('1 2\n3 4')
@@ -170,7 +169,6 @@
         a = np.array([1,2,3,4], int)
         assert_array_equal(x, a)
 
-
     def test_missing(self):
         c = StringIO.StringIO()
         c.write('1,2,3,,5\n')
@@ -180,6 +178,16 @@
         a = np.array([1,2,3,-999,5], int)
         assert_array_equal(x, a)
 
+    def test_converters_with_usecols(self):
+        c = StringIO.StringIO()
+        c.write('1,2,3,,5\n6,7,8,9,10\n')
+        c.seek(0)
+        x = np.loadtxt(c, dtype=int, delimiter=',', \
+            converters={3:lambda s: int(s or -999)}, \
+            usecols=(1, 3, ))
+        a = np.array([[2,  -999],[7, 9]], int)
+        assert_array_equal(x, a)
+
     def test_comments(self):
         c = StringIO.StringIO()
         c.write('# comment\n1,2,3,5\n')
@@ -221,6 +229,11 @@
         x = np.loadtxt(c, dtype=float, usecols=(1,2))
         assert_array_equal(x, a[:,1:])
 
+        # Testing with arrays instead of tuples.
+        c.seek(0)
+        x = np.loadtxt(c, dtype=float, usecols=np.array([1,2]))
+        assert_array_equal(x, a[:,1:])
+
         # Checking with dtypes defined converters.
         data = '''JOE 70.1 25.3
                 BOB 60.5 27.9
@@ -241,6 +254,9 @@
         a = np.array([(1,(2,3.0)),(4,(5,6.0))], dt)
         assert_array_equal(x, a)
 
+    def test_empty_file(self):
+        c = StringIO.StringIO()
+        assert_raises(IOError, np.loadtxt, c)
 
 class Testfromregex(TestCase):
     def test_record(self):

Modified: branches/clean_math_config/numpy/ma/core.py
===================================================================
--- branches/clean_math_config/numpy/ma/core.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/ma/core.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1257,9 +1257,9 @@
             copy = True
         # Careful, cls might not always be MaskedArray...
         if not isinstance(data, cls) or not subok:
-            _data = _data.view(cls)
+            _data = ndarray.view(_data, cls)
         else:
-            _data = _data.view(type(data))
+            _data = ndarray.view(_data, type(data))
         # Backwards compatibility w/ numpy.core.ma .......
         if hasattr(data,'_mask') and not isinstance(data, ndarray):
             _data._mask = data._mask
@@ -1374,7 +1374,15 @@
         """
         # Get main attributes .........
         self._update_from(obj)
-        self._mask = getattr(obj, '_mask', nomask)
+        if isinstance(obj, ndarray):
+            odtype = obj.dtype
+            if odtype.names:
+                _mask = getattr(obj, '_mask', make_mask_none(obj.shape, odtype))
+            else:
+                _mask = getattr(obj, '_mask', nomask)
+        else:
+            _mask = nomask
+        self._mask = _mask
         # Finalize the mask ...........
         if self._mask is not nomask:
             self._mask.shape = self.shape
@@ -1425,6 +1433,24 @@
         #....
         return result
     #.............................................
+    def view(self, dtype=None, type=None):
+        if dtype is not None:
+            if type is None:
+                args = (dtype,)
+            else:
+                args = (dtype, type)
+        elif type is None:
+            args = ()
+        else:
+            args = (type,)
+        output = ndarray.view(self, *args)
+        if (getattr(output,'_mask', nomask) is not nomask):
+            mdtype = make_mask_descr(output.dtype)
+            output._mask = self._mask.view(mdtype, ndarray)
+            output._mask.shape = output.shape
+        return output
+    view.__doc__ = ndarray.view.__doc__
+    #.............................................
     def astype(self, newtype):
         """Returns a copy of the array cast to newtype."""
         newtype = np.dtype(newtype)
@@ -1701,7 +1727,7 @@
         underlying data.
 
         """
-        return self.view(self._baseclass)
+        return ndarray.view(self, self._baseclass)
     _data = property(fget=_get_data)
     data = property(fget=_get_data)
 
@@ -3123,6 +3149,14 @@
         return (_mareconstruct,
                 (self.__class__, self._baseclass, (0,), 'b', ),
                 self.__getstate__())
+    #
+    def __deepcopy__(self, memo={}):
+        from copy import deepcopy
+        copied = MaskedArray.__new__(type(self), self, copy=True)
+        memo[id(self)] = copied
+        for (k,v) in self.__dict__.iteritems():
+            copied.__dict__[k] = deepcopy(v, memo)
+        return copied
 
 
 def _mareconstruct(subtype, baseclass, baseshape, basetype,):
@@ -3223,6 +3257,8 @@
             mb = getmaskarray(b)
             m = logical_or.outer(ma, mb)
         result = self.ufunc.outer(filled(a), filled(b))
+        if not isinstance(result, MaskedArray):
+            result = result.view(MaskedArray)
         result._mask = m
         return result
 

Modified: branches/clean_math_config/numpy/ma/tests/test_core.py
===================================================================
--- branches/clean_math_config/numpy/ma/tests/test_core.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/ma/tests/test_core.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -330,6 +330,24 @@
         assert_not_equal(y._mask.ctypes.data, x._mask.ctypes.data)
 
 
+    def test_deepcopy(self):
+        from copy import deepcopy
+        a = array([0,1,2], mask=[False,True,False])
+        copied = deepcopy(a)
+        assert_equal(copied.mask, a.mask)
+        assert_not_equal(id(a._mask), id(copied._mask))
+        #
+        copied[1] = 1
+        assert_equal(copied.mask,[0,0,0])
+        assert_equal(a.mask, [0,1,0])
+        #
+        copied = deepcopy(a)
+        assert_equal(copied.mask, a.mask)
+        copied.mask[1] = False
+        assert_equal(copied.mask,[0,0,0])
+        assert_equal(a.mask, [0,1,0])
+
+
     def test_pickling(self):
         "Tests pickling"
         import cPickle
@@ -638,6 +656,23 @@
         x[-1,-1] = masked
         assert_equal(maximum(x), 2)
 
+    def test_minimummaximum_func(self):
+        a = np.ones((2,2))
+        aminimum = minimum(a,a)
+        assert(isinstance(aminimum, MaskedArray))
+        assert_equal(aminimum, np.minimum(a,a))
+        #
+        aminimum = minimum.outer(a,a)
+        assert(isinstance(aminimum, MaskedArray))
+        assert_equal(aminimum, np.minimum.outer(a,a))
+        #
+        amaximum = maximum(a,a)
+        assert(isinstance(amaximum, MaskedArray))
+        assert_equal(amaximum, np.maximum(a,a))
+        #
+        amaximum = maximum.outer(a,a)
+        assert(isinstance(amaximum, MaskedArray))
+        assert_equal(amaximum, np.maximum.outer(a,a))
 
     def test_minmax_funcs_with_output(self):
         "Tests the min/max functions with explicit outputs"
@@ -2307,6 +2342,34 @@
         assert_equal(getmaskarray(test),
                      np.array([(1, 1) , (1, 1), (1, 1)],
                               dtype=[('a', '|b1'), ('b', '|b1')]))
+    #
+    def test_view(self):
+        "Test view w/ flexible dtype"
+        iterator = zip(np.arange(10), np.random.rand(10))
+        data = np.array(iterator)
+        a = array(iterator, dtype=[('a',float),('b',float)])
+        a.mask[0] = (1,0)
+        controlmask = np.array([1]+19*[0], dtype=bool)
+        #
+        test = a.view(float)
+        assert_equal(test, data.ravel())
+        assert_equal(test.mask, controlmask)
+        #
+        test = a.view((float,2))
+        assert_equal(test, data)
+        assert_equal(test.mask, controlmask.reshape(-1,2))
+        #
+        test = a.view([('A',float),('B',float)])
+        assert_equal(test.mask.dtype.names, ('A', 'B'))
+        assert_equal(test['A'], a['a'])
+        assert_equal(test['B'], a['b'])
+        #
+        test = a.view(np.ndarray)
+        assert_equal(test, a._data)
+        #
+        test = a.view((float,2), np.matrix)
+        assert_equal(test, data)
+        assert(isinstance(test, np.matrix))
 
 
 ###############################################################################

Modified: branches/clean_math_config/numpy/ma/tests/test_old_ma.py
===================================================================
--- branches/clean_math_config/numpy/ma/tests/test_old_ma.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/ma/tests/test_old_ma.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,5 +1,5 @@
 import numpy
-import types, time
+import types
 from numpy.ma import *
 from numpy.core.numerictypes import float32
 from numpy.ma.core import umath

Modified: branches/clean_math_config/numpy/ma/tests/test_subclassing.py
===================================================================
--- branches/clean_math_config/numpy/ma/tests/test_subclassing.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/ma/tests/test_subclassing.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -11,8 +11,6 @@
 __date__     = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $'
 
 import numpy as np
-import numpy.core.numeric as numeric
-
 from numpy.testing import *
 from numpy.ma.testutils import *
 from numpy.ma.core import *

Modified: branches/clean_math_config/numpy/numarray/alter_code2.py
===================================================================
--- branches/clean_math_config/numpy/numarray/alter_code2.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/numarray/alter_code2.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -12,12 +12,9 @@
 warnings.warn("numpy.numarray.alter_code2 is not working yet.")
 import sys
 
-
 import os
-import re
 import glob
 
-
 def makenewfile(name, filestr):
     fid = file(name, 'w')
     fid.write(filestr)

Modified: branches/clean_math_config/numpy/numarray/functions.py
===================================================================
--- branches/clean_math_config/numpy/numarray/functions.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/numarray/functions.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -20,13 +20,13 @@
             'any', 'argmax', 'argmin', 'argsort', 'around', 'array_equal',
             'array_equiv', 'arrayrange', 'array_str', 'array_repr',
             'array2list', 'average', 'choose', 'CLIP', 'RAISE', 'WRAP',
-            'clip', 'compress', 'concatenate', 'copy', 'copy_reg',
+            'clip', 'compress', 'copy', 'copy_reg',
             'diagonal', 'divide_remainder', 'e', 'explicit_type', 'pi',
             'flush_caches', 'fromfile', 'os', 'sys', 'STRICT',
             'SLOPPY', 'WARN', 'EarlyEOFError', 'SizeMismatchError',
             'SizeMismatchWarning', 'FileSeekWarning', 'fromstring',
             'fromfunction', 'fromlist', 'getShape', 'getTypeObject',
-            'identity', 'indices', 'info', 'innerproduct', 'inputarray',
+            'identity', 'info', 'innerproduct', 'inputarray',
             'isBigEndian', 'kroneckerproduct', 'lexsort', 'math',
             'operator', 'outerproduct', 'put', 'putmask', 'rank',
             'repeat', 'reshape', 'resize', 'round', 'searchsorted',
@@ -45,9 +45,9 @@
 import operator
 
 from numpy import dot as matrixmultiply, dot, vdot, ravel, concatenate, all,\
-     allclose, any, around, argsort, array_equal, array_equiv,\
+     allclose, any, argsort, array_equal, array_equiv,\
      array_str, array_repr, CLIP, RAISE, WRAP, clip, concatenate, \
-     diagonal, e, pi, indices, inner as innerproduct, nonzero, \
+     diagonal, e, pi, inner as innerproduct, nonzero, \
      outer as outerproduct, kron as kroneckerproduct, lexsort, putmask, rank, \
      resize, searchsorted, shape, size, sort, swapaxes, trace, transpose
 import numpy as np
@@ -321,7 +321,7 @@
     if type is not None:
         return type
     try:
-        return typefrom(N.array(sequence))
+        return typefrom(np.array(sequence))
     except:
         raise TypeError("Can't determine a reasonable type from sequence")
 
@@ -458,7 +458,7 @@
         res = work[indices]
         if outarr is None:
             return res
-        out[...] = res
+        outarr[...] = res
         return
 
 def tensormultiply(a1, a2):
@@ -466,9 +466,9 @@
     if (a1.shape[-1] != a2.shape[0]):
         raise ValueError("Unmatched dimensions")
     shape = a1.shape[:-1] + a2.shape[1:]
-    return np.reshape(dot(N.reshape(a1, (-1, a1.shape[-1])),
-                         np.reshape(a2, (a2.shape[0],-1))),
-                     shape)
+    return np.reshape(dot(np.reshape(a1, (-1, a1.shape[-1])),
+                          np.reshape(a2, (a2.shape[0],-1))),
+                      shape)
 
 def cumsum(a1, axis=0, out=None, type=None, dim=0):
     return np.asarray(a1).cumsum(axis,dtype=type,out=out)

Modified: branches/clean_math_config/numpy/numarray/numerictypes.py
===================================================================
--- branches/clean_math_config/numpy/numarray/numerictypes.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/numarray/numerictypes.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -54,9 +54,6 @@
 #from typeconv import typeConverters as _typeConverters
 #import numinclude
 #from _numerictype import _numerictype, typeDict
-import types as _types
-import copy as _copy
-import sys as _sys
 
 # Enumeration of numarray type codes
 typeDict = {}

Modified: branches/clean_math_config/numpy/numarray/session.py
===================================================================
--- branches/clean_math_config/numpy/numarray/session.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/numarray/session.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -16,7 +16,6 @@
 to keep the test run free of warnings.
 
 >>> del _PROXY_ALLOWED
->>> del copy
 >>> del __builtins__
 
 By default, save() stores every variable in the caller's namespace:
@@ -76,7 +75,6 @@
 
 __all__ = ['load', 'save']
 
-import copy
 import sys
 import pickle
 

Modified: branches/clean_math_config/numpy/numarray/util.py
===================================================================
--- branches/clean_math_config/numpy/numarray/util.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/numarray/util.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,7 +1,8 @@
-from numpy import geterr
+import os
+import numpy
 
-__all__ = ['MathDomainError', 'UnderflowError', 'NumOverflowError', 'handleError',
-           'get_numarray_include_dirs']
+__all__ = ['MathDomainError', 'UnderflowError', 'NumOverflowError', 
+           'handleError', 'get_numarray_include_dirs']
 
 class MathDomainError(ArithmeticError): pass
 class UnderflowError(ArithmeticError): pass
@@ -9,31 +10,29 @@
 
 def handleError(errorStatus, sourcemsg):
     """Take error status and use error mode to handle it."""
-    modes = geterr()
-    if errorStatus & FPE_INVALID:
+    modes = numpy.geterr()
+    if errorStatus & numpy.FPE_INVALID:
         if modes['invalid'] == "warn":
             print "Warning: Encountered invalid numeric result(s)", sourcemsg
         if modes['invalid'] == "raise":
             raise MathDomainError(sourcemsg)
-    if errorStatus & FPE_DIVIDEBYZERO:
+    if errorStatus & numpy.FPE_DIVIDEBYZERO:
         if modes['dividebyzero'] == "warn":
             print "Warning: Encountered divide by zero(s)", sourcemsg
         if modes['dividebyzero'] == "raise":
             raise ZeroDivisionError(sourcemsg)
-    if errorStatus & FPE_OVERFLOW:
+    if errorStatus & numpy.FPE_OVERFLOW:
         if modes['overflow'] == "warn":
             print "Warning: Encountered overflow(s)", sourcemsg
         if modes['overflow'] == "raise":
             raise NumOverflowError(sourcemsg)
-    if errorStatus & FPE_UNDERFLOW:
+    if errorStatus & numpy.FPE_UNDERFLOW:
         if modes['underflow'] == "warn":
             print "Warning: Encountered underflow(s)", sourcemsg
         if modes['underflow'] == "raise":
             raise UnderflowError(sourcemsg)
 
 
-import os
-import numpy
 def get_numarray_include_dirs():
     base = os.path.dirname(numpy.__file__)
     newdirs = [os.path.join(base, 'numarray')]

Modified: branches/clean_math_config/numpy/testing/decorators.py
===================================================================
--- branches/clean_math_config/numpy/testing/decorators.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/testing/decorators.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -83,12 +83,41 @@
         return nose.tools.make_decorator(f)(skipper)
     return skip_decorator
 
-def skipknownfailure(f):
-    ''' Decorator to raise SkipTest for test known to fail
+def knownfailureif(skip_condition, msg=None):
+    ''' Make function raise KnownFailureTest exception if skip_condition is true
+
+    Parameters
+    ---------
+    skip_condition : bool
+        Flag to determine whether to mark test as known failure (True) 
+        or not (False)
+    msg : string
+        Message to give on raising a KnownFailureTest exception
+
+   Returns
+   -------
+   decorator : function
+       Decorator, which, when applied to a function, causes SkipTest
+       to be raised when the skip_condition was True, and the function
+       to be called normally otherwise.
+
+    Notes
+    -----
+    You will see from the code that we had to further decorate the
+    decorator with the nose.tools.make_decorator function in order to
+    transmit function name, and various other metadata.
     '''
-    # Local import to avoid a hard nose dependency and only incur the
-    # import time overhead at actual test-time.
-    import nose
-    def skipper(*args, **kwargs):
-        raise nose.SkipTest, 'This test is known to fail'
-    return nose.tools.make_decorator(f)(skipper)
+    if msg is None:
+        msg = 'Test skipped due to known failure'
+    def skip_decorator(f):
+        # Local import to avoid a hard nose dependency and only incur the
+        # import time overhead at actual test-time.
+        import nose
+        from noseclasses import KnownFailureTest
+        def skipper(*args, **kwargs):
+            if skip_condition:
+                raise KnownFailureTest, msg
+            else:
+                return f(*args, **kwargs)
+        return nose.tools.make_decorator(f)(skipper)
+    return skip_decorator

Modified: branches/clean_math_config/numpy/testing/noseclasses.py
===================================================================
--- branches/clean_math_config/numpy/testing/noseclasses.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/testing/noseclasses.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -7,6 +7,7 @@
 import doctest
 
 from nose.plugins import doctests as npd
+from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
 from nose.plugins.base import Plugin
 from nose.util import src, tolist
 import numpy
@@ -16,14 +17,14 @@
 _doctest_ignore = ['generate_numpy_api.py', 'scons_support.py',
                    'setupscons.py', 'setup.py']
 
-# All the classes in this module begin with 'numpy' to clearly distinguish them
-# from the plethora of very similar names from nose/unittest/doctest
+# Some of the classes in this module begin with 'Numpy' to clearly distinguish
+# them from the plethora of very similar names from nose/unittest/doctest
 
 
 #-----------------------------------------------------------------------------
 # Modified version of the one in the stdlib, that fixes a python bug (doctests
 # not found in extension modules, http://bugs.python.org/issue3158)
-class numpyDocTestFinder(doctest.DocTestFinder):
+class NumpyDocTestFinder(doctest.DocTestFinder):
 
     def _from_module(self, module, object):
         """
@@ -113,7 +114,7 @@
                                globs, seen)
 
 
-class numpyDocTestCase(npd.DocTestCase):
+class NumpyDocTestCase(npd.DocTestCase):
     """Proxy for DocTestCase: provides an address() method that
     returns the correct address for the doctest case. Otherwise
     acts as a proxy to the test case. To provide hints for address(),
@@ -137,7 +138,7 @@
 # second-chance checker; if the default comparison doesn't
 # pass, then see if the expected output string contains flags that
 # tell us to ignore the output
-class numpyOutputChecker(doctest.OutputChecker):
+class NumpyOutputChecker(doctest.OutputChecker):
     def check_output(self, want, got, optionflags):
         ret = doctest.OutputChecker.check_output(self, want, got,
                                                  optionflags)
@@ -151,7 +152,7 @@
 # Subclass nose.plugins.doctests.DocTestCase to work around a bug in
 # its constructor that blocks non-default arguments from being passed
 # down into doctest.DocTestCase
-class numpyDocTestCase(npd.DocTestCase):
+class NumpyDocTestCase(npd.DocTestCase):
     def __init__(self, test, optionflags=0, setUp=None, tearDown=None,
                  checker=None, obj=None, result_var='_'):
         self._result_var = result_var
@@ -164,7 +165,7 @@
 
 print_state = numpy.get_printoptions()
 
-class numpyDoctest(npd.Doctest):
+class NumpyDoctest(npd.Doctest):
     name = 'numpydoctest'   # call nosetests with --with-numpydoctest
     enabled = True
 
@@ -175,7 +176,7 @@
         Plugin.configure(self, options, config)
         self.doctest_tests = True
 #        self.extension = tolist(options.doctestExtension)
-        self.finder = numpyDocTestFinder()
+        self.finder = NumpyDocTestFinder()
         self.parser = doctest.DocTestParser()
 
     # Turn on whitespace normalization, set a minimal execution context
@@ -223,15 +224,12 @@
                 p2 = p[-1]
                 test.globs[p2] = __import__(pkg_name, test.globs, {}, [p2])
 
-                print 'additional import for %s: from %s import %s' % (test.filename, p1, p2)
-                print '    (%s): %r' % (pkg_name, test.globs[p2])
-
             # always use whitespace and ellipsis options
             optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
 
-            yield numpyDocTestCase(test,
+            yield NumpyDocTestCase(test,
                                    optionflags=optionflags,
-                                   checker=numpyOutputChecker())
+                                   checker=NumpyOutputChecker())
 
 
     # Add an afterContext method to nose.plugins.doctests.Doctest in order
@@ -246,3 +244,35 @@
         if bn in _doctest_ignore:
             return False
         return npd.Doctest.wantFile(self, file)
+
+
+class KnownFailureTest(Exception):
+    '''Raise this exception to mark a test as a known failing test.'''
+    pass
+
+
+class KnownFailure(ErrorClassPlugin):
+    '''Plugin that installs a KNOWNFAIL error class for the 
+    KnownFailureClass exception.  When KnownFailureTest is raised,
+    the exception will be logged in the knownfail attribute of the
+    result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the
+    exception will not be counted as an error or failure.'''
+    enabled = True
+    knownfail = ErrorClass(KnownFailureTest,
+                           label='KNOWNFAIL',
+                           isfailure=False)
+
+    def options(self, parser, env=os.environ):
+        env_opt = 'NOSE_WITHOUT_KNOWNFAIL'
+        parser.add_option('--no-knownfail', action='store_true',
+                          dest='noKnownFail', default=env.get(env_opt, False),
+                          help='Disable special handling of KnownFailureTest '
+                               'exceptions')
+
+    def configure(self, options, conf):
+        if not self.can_configure:
+            return
+        self.conf = conf
+        disable = getattr(options, 'noKnownFail', False)
+        if disable:
+            self.enabled = False

Modified: branches/clean_math_config/numpy/testing/nosetester.py
===================================================================
--- branches/clean_math_config/numpy/testing/nosetester.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/testing/nosetester.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -266,8 +266,8 @@
 
         # construct list of plugins, omitting the existing doctest plugin
         import nose.plugins.builtin
-        from noseclasses import numpyDoctest
-        plugins = [numpyDoctest()]
+        from noseclasses import NumpyDoctest, KnownFailure
+        plugins = [NumpyDoctest(), KnownFailure()]
         for p in nose.plugins.builtin.plugins:
             plug = p()
             if plug.name == 'doctest':

Modified: branches/clean_math_config/numpy/testing/utils.py
===================================================================
--- branches/clean_math_config/numpy/testing/utils.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/testing/utils.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -241,7 +241,6 @@
 def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
                          header=''):
     from numpy.core import asarray, isnan, any
-    from numpy import isreal, iscomplex
     x = asarray(x)
     y = asarray(y)
 

Modified: branches/clean_math_config/numpy/tests/test_ctypeslib.py
===================================================================
--- branches/clean_math_config/numpy/tests/test_ctypeslib.py	2008-09-13 06:34:25 UTC (rev 5811)
+++ branches/clean_math_config/numpy/tests/test_ctypeslib.py	2008-09-13 07:04:41 UTC (rev 5812)
@@ -1,3 +1,5 @@
+import sys
+
 import numpy as np
 from numpy.ctypeslib import ndpointer, load_library
 from numpy.testing import *
@@ -3,4 +5,5 @@
 
 class TestLoadLibrary(TestCase):
+    @dec.knownfailureif(sys.platform=='cygwin', "This test is known to fail on cygwin")
     def test_basic(self):
         try:
@@ -12,6 +15,7 @@
                   " (import error was: %s)" % str(e)
             print msg
 
+    @dec.knownfailureif(sys.platform=='cygwin', "This test is known to fail on cygwin")
     def test_basic2(self):
         """Regression for #801: load_library with a full library name
         (including extension) does not work."""



More information about the Numpy-svn mailing list