ó
£áSc           @` sŒ  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 m Z d d l m Z m Z m Z e j d d k r° d d l m Z n d d l m Z d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" g Z d Z d# d$ „ Z d% „  Z d& „  Z d' „  Z d( „  Z e j d)  d* k r�d+ e j ƒ  g  d, „ Z d+ e j ƒ  d- „ Z n g  d. „ Z d/ „  Z e j d0 k ríe j d  d1 k ríd d2 d d d3 „ Z! d4 d d5 „ Z n  d6 e" d] d9 „ Z# d# e" d: „ Z$ d; „  Z% d< d# e" d= „ Z& d< d# e" d> „ Z' d# e" d# d? „ Z( d# e" d@ „ Z) dA d# e" dB „ Z* d# e" dC „ Z+ dD „  Z, dE „  Z- d e" dF „ Z. dG „  Z/ dH „  Z0 d dI „ Z1 d d dJ „ Z2 dK „  Z3 dL d d# e" dM „ Z4 d dN „ Z5 d d dO „ Z6 d dP „ Z7 dQ „  Z8 dR „  Z9 dS e: f dT „  ƒ  YZ; dU e: f dV „  ƒ  YZ< dW „  Z= dX „  Z> e dY dZ d[ „ Z? d" e@ f d\ „  ƒ  YZA d S(^   s*   
Utility function to facilitate testing.

i    (   t   divisiont   absolute_importt   print_functionNi   (   t   import_nose(   t   float32t   emptyt   arangei   (   t   StringIOt   assert_equalt   assert_almost_equalt   assert_approx_equalt   assert_array_equalt   assert_array_lesst   assert_string_equalt   assert_array_almost_equalt   assert_raisest   build_err_msgt   decorate_methodst   jiffiest   memusaget   print_assert_equalt   raisest   randt   rundocst	   runstringt   verboset   measuret   assert_t   assert_array_almost_equal_nulpt   assert_array_max_ulpt   assert_warnst   assert_no_warningst   assert_allcloset   IgnoreExceptiont    c         C` s   |  s t  | ƒ ‚ n  d S(   s  
    Assert that works in release mode.

    The Python built-in ``assert`` does not work when executing code in
    optimized mode (the ``-O`` flag) - no byte-code is generated for it.

    For documentation on usage, refer to the Python documentation.

    N(   t   AssertionError(   t   valt   msg(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   !   s    
c         C` sD   d d l  m } | |  ƒ } t | t t ƒ ƒ r@ t d ƒ ‚ n  | S(   s�  like isnan, but always raise an error if type not supported instead of
    returning a TypeError object.

    Notes
    -----
    isnan and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.

    This should be removed once this problem is solved at the Ufunc level.i    (   t   isnans!   isnan not supported for this type(   t
   numpy.coreR&   t
   isinstancet   typet   NotImplementedt	   TypeError(   t   xR&   t   st(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   gisnan.   s
    c         C` s`   d d l  m } m } | d d ƒ �5 | |  ƒ } t | t t ƒ ƒ rV t d ƒ ‚ n  Wd QX| S(   s‡  like isfinite, but always raise an error if type not supported instead of
    returning a TypeError object.

    Notes
    -----
    isfinite and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.

    This should be removed once this problem is solved at the Ufunc level.i    (   t   isfinitet   errstatet   invalidt   ignores$   isfinite not supported for this typeN(   R'   R/   R0   R(   R)   R*   R+   (   R,   R/   R0   R-   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt	   gisfinite?   s    c         C` s`   d d l  m } m } | d d ƒ �5 | |  ƒ } t | t t ƒ ƒ rV t d ƒ ‚ n  Wd QX| S(   s�  like isinf, but always raise an error if type not supported instead of
    returning a TypeError object.

    Notes
    -----
    isinf and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.

    This should be removed once this problem is solved at the Ufunc level.i    (   t   isinfR0   R1   R2   s!   isinf not supported for this typeN(   R'   R4   R0   R(   R)   R*   R+   (   R,   R4   R0   R-   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   gisinfQ   s    c          G` sk   d d l  } d d l m } m } | |  | ƒ } | j } x* t t | ƒ ƒ D] } | j  ƒ  | | <qM W| S(   s�   Returns an array of random numbers with the given shape.

    This only uses the standard library, so it is useful for testing purposes.
    i    N(   t   zerost   float64(   t   randomR'   R6   R7   t   flatt   ranget   len(   t   argsR8   R6   R7   t   resultst   ft   i(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   c   s    	i   t   linuxs   /proc/%s/statc         C` s�   d d l  } | s( | j | j  ƒ  ƒ n  y@ t |  d ƒ } | j ƒ  j d ƒ } | j ƒ  t | d ƒ SWn  t d | j  ƒ  | d ƒ SXd S(   sx    Return number of jiffies (1/100ths of a second) that this
    process has been scheduled in user mode. See man 5 proc. i    Nt   rt    i   id   (   t   timet   appendt   opent   readlinet   splitt   closet   int(   t   _proc_pid_statt
   _load_timeRC   R>   t   l(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   q   s    
c         C` sO   y@ t  |  d ƒ } | j ƒ  j d ƒ } | j ƒ  t | d ƒ SWn d SXd S(   sD    Return virtual memory size in bytes of the running python.
        RA   RB   i   N(   RE   RF   RG   RH   RI   (   RJ   R>   RL   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   €   s    
c         C` sD   d d l  } |  s( |  j | j  ƒ  ƒ n  t d | j  ƒ  |  d ƒ S(   s„    Return number of jiffies (1/100ths of a second) that this
    process has been scheduled in user mode. [Emulation with time.time]. i    Nid   (   RC   RD   RI   (   RK   RC   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   Ž   s    c           C` s
   t  ‚ d S(   s9    Return memory usage of running python. [Not implemented]N(   t   NotImplementedError(    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   •   s    t   nts   2.3iÿÿÿÿc         C` sº   d d  l  } | d  k r$ | j } n  | j | |  | d  | | f ƒ } | j ƒ  } zT | j | | ƒ }	 z- | j | ƒ | j |	 | ƒ \ }
 } | SWd  | j |	 ƒ XWd  | j	 | ƒ Xd  S(   Ni    (
   t   win32pdht   Nonet   PDH_FMT_LONGt   MakeCounterPatht	   OpenQueryt
   AddCountert   CollectQueryDatat   GetFormattedCounterValuet   RemoveCountert
   CloseQuery(   t   objectt   countert   instancet   inumt   formatt   machineRO   t   patht   hqt   hcR)   R$   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   GetPerformanceAttributes›   s    
 !t   pythonc         C` s(   d d  l  } t d d |  | | j d  ƒ S(   Ni    t   Processs   Virtual Bytes(   RO   Rb   RQ   RP   (   t   processNameR[   RO   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ´   s    	s   Items are not equal:t   ACTUALt   DESIREDc   	      C` s  d | g } | rl | j  d ƒ d k r\ t | ƒ d t | ƒ k  r\ | d d | g } ql | j | ƒ n  | rx“ t |  ƒ D]‚ \ } } y t | ƒ } Wn d } n X| j d ƒ d k ræ d j | j ƒ  d  ƒ } | d 7} n  | j d	 | | | f ƒ q Wn  d j | ƒ S(
   Ns   
iÿÿÿÿiO   i    RB   s   [repr failed]i   s   ...s    %s: %s(   t   findR;   RD   t	   enumeratet   reprt   countt   joint
   splitlines(	   t   arrayst   err_msgt   headerR   t   namesR%   R?   t   aRA   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   »   s     1
"c         C` s×  t  | t ƒ r¿ t  |  t ƒ s9 t t t |  ƒ ƒ ƒ ‚ n  t t |  ƒ t | ƒ | | ƒ x` | j ƒ  D]R \ } } | |  k r’ t t | ƒ ƒ ‚ n  t |  | | | d | | f | ƒ qe Wd St  | t t	 f ƒ rNt  |  t t	 f ƒ rNt t |  ƒ t | ƒ | | ƒ x? t
 t | ƒ ƒ D]+ } t |  | | | d | | f | ƒ qWd Sd d l m } m } m } d d l m }	 m }
 m } t  |  | ƒ s¤t  | | ƒ r·t |  | | | ƒ St |  | g | d | ƒ} y |	 |  ƒ pê|	 | ƒ } Wn t k
 rt } n X| rµ|	 |  ƒ r5|
 |  ƒ } | |  ƒ } n |  } d } |	 | ƒ rh|
 | ƒ } | | ƒ } n | } d } y t | | ƒ t | | ƒ Wqµt k
 r±t | ƒ ‚ qµXn  yæ | | ƒ | |  ƒ k rßt | ƒ ‚ n  t | ƒ oôt |  ƒ sXt | ƒ } t |  ƒ } | s| r9| o$| sTt | ƒ ‚ qTn | |  k sTt | ƒ ‚ n  d S| d k rš|  d k rš| | ƒ | |  ƒ k sšt | ƒ ‚ qšn  Wn t t t f k
 r·n X| |  k rÓt | ƒ ‚ n  d S(   s[  
    Raise an assertion if two objects are not equal.

    Given two objects (scalars, lists, tuples, dictionaries or numpy arrays),
    check that all elements of these objects are equal. An exception is raised
    at the first conflicting values.

    Parameters
    ----------
    actual : array_like
        The object to check.
    desired : array_like
        The expected object.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
        If actual and desired are not equal.

    Examples
    --------
    >>> np.testing.assert_equal([4,5], [4,6])
    ...
    <type 'exceptions.AssertionError'>:
    Items are not equal:
    item=1
     ACTUAL: 5
     DESIRED: 6

    s	   key=%r
%sNs
   item=%r
%si    (   t   ndarrayt   isscalart   signbit(   t   iscomplexobjt   realt   imagR   (   R(   t   dictR#   Rj   R)   R   R;   t   itemst   listt   tupleR:   R'   Rs   Rt   Ru   t	   numpy.libRv   Rw   Rx   R   R   t
   ValueErrort   FalseR3   R.   R+   RM   (   t   actualt   desiredRo   R   t   kR?   Rs   Rt   Ru   Rv   Rw   Rx   R%   t
   usecomplext   actualrt   actualit   desiredrt   desiredit   isdesnant   isactnan(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   Ð   st    #)*)
c         C` s�   d d l  } | | k s} t ƒ  } | j |  ƒ | j d ƒ | j  | | ƒ | j d ƒ | j  | | ƒ t | j ƒ  ƒ ‚ n  d S(   sµ  
    Test if two objects are equal, and print an error message if test fails.

    The test is performed with ``actual == desired``.

    Parameters
    ----------
    test_string : str
        The message supplied to AssertionError.
    actual : object
        The object to test for equality against `desired`.
    desired : object
        The expected result.

    Examples
    --------
    >>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 1])
    >>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 2])
    Traceback (most recent call last):
    ...
    AssertionError: Test XYZ of func xyz failed
    ACTUAL:
    [0, 1]
    DESIRED:
    [0, 2]

    i    Ns    failed
ACTUAL: 
s
   DESIRED: 
(   t   pprintR   t   writeR#   t   getvalue(   t   test_stringR€   R�   RŠ   R%   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ?  s    	i   c         C` sL  d d l  m } d d l m } m } m } y | |  ƒ pD | | ƒ }	 Wn t k
 ra t }	 n Xt |  | g | d | d d | ƒ}
 |	 r@| |  ƒ r´ | |  ƒ } | |  ƒ } n |  } d } | | ƒ rç | | ƒ } | | ƒ } n | } d } y* t	 | | d | ƒt	 | | d | ƒWq@t
 k
 r<t
 |
 ƒ ‚ q@Xn  t |  | t t f ƒ spt | | t t f ƒ rƒt |  | | | ƒ Sy} t | ƒ o›t |  ƒ sÿt | ƒ s¶t |  ƒ ràt | ƒ oËt |  ƒ sût
 |
 ƒ ‚ qûn | |  k sût
 |
 ƒ ‚ n  d SWn t t f k
 rn Xt t | |  ƒ | ƒ d k rHt
 |
 ƒ ‚ n  d S(	   sð  
    Raise an assertion if two items are not equal up to desired precision.

    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.

    The test is equivalent to ``abs(desired-actual) < 0.5 * 10**(-decimal)``.

    Given two objects (numbers or ndarrays), check that all elements of these
    objects are almost equal. An exception is raised at conflicting values.
    For ndarrays this delegates to assert_array_almost_equal

    Parameters
    ----------
    actual : array_like
        The object to check.
    desired : array_like
        The expected object.
    decimal : int, optional
        Desired precision, default is 7.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
      If actual and desired are not equal up to specified precision.

    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

    Examples
    --------
    >>> import numpy.testing as npt
    >>> npt.assert_almost_equal(2.3333333333333, 2.33333334)
    >>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
    ...
    <type 'exceptions.AssertionError'>:
    Items are not equal:
     ACTUAL: 2.3333333333333002
     DESIRED: 2.3333333399999998

    >>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]),
    ...                         np.array([1.0,2.33333334]), decimal=9)
    ...
    <type 'exceptions.AssertionError'>:
    Arrays are not almost equal
    <BLANKLINE>
    (mismatch 50.0%)
     x: array([ 1.        ,  2.33333333])
     y: array([ 1.        ,  2.33333334])

    i    (   Rs   (   Rv   Rw   Rx   R   Rp   s*   Arrays are not almost equal to %d decimalst   decimalN(   R'   Rs   R}   Rv   Rw   Rx   R~   R   R   R	   R#   R(   R|   R{   R   R3   R.   RM   R+   t   roundt   abs(   R€   R�   RŽ   Ro   R   Rs   Rv   Rw   Rx   Rƒ   R%   R„   R…   R†   R‡   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR	   f  sN    =
c   
   	   C` sÝ  d d l  } t t |  | f ƒ \ }  } | |  k r7 d S| j d d ƒ �I d | j | ƒ | j |  ƒ } | j d | j | j | ƒ ƒ ƒ } Wd QXy | | } Wn t k
 r» d } n Xy |  | } Wn t k
 rã d } n Xt	 |  | g | d d	 | d
 | ƒ}	 y} t
 | ƒ o!t
 |  ƒ s…t | ƒ s<t |  ƒ rft | ƒ oQt |  ƒ s�t |	 ƒ ‚ q�n | |  k s�t |	 ƒ ‚ n  d SWn t t f k
 rŸn X| j | | ƒ | j d | d ƒ k rÙt |	 ƒ ‚ n  d S(   sK  
    Raise an assertion if two items are not equal up to significant digits.

    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.

    Given two numbers, check that they are approximately equal.
    Approximately equal is defined as the number of significant digits
    that agree.

    Parameters
    ----------
    actual : scalar
        The object to check.
    desired : scalar
        The expected object.
    significant : int, optional
        Desired precision, default is 7.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
      If actual and desired are not equal up to specified precision.

    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

    Examples
    --------
    >>> np.testing.assert_approx_equal(0.12345677777777e-20, 0.1234567e-20)
    >>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345671e-20,
                                       significant=8)
    >>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345672e-20,
                                       significant=8)
    ...
    <type 'exceptions.AssertionError'>:
    Items are not equal to 8 significant digits:
     ACTUAL: 1.234567e-021
     DESIRED: 1.2345672000000001e-021

    the evaluated condition that raises the exception is

    >>> abs(0.12345670e-20/1e-21 - 0.12345672e-20/1e-21) >= 10**-(8-1)
    True

    i    NR1   R2   g      à?i
   g        Rp   s-   Items are not equal to %d significant digits:R   g      $@i   (   t   numpyt   mapt   floatR0   R�   t   powert   floort   log10t   ZeroDivisionErrorR   R3   R.   R#   R+   RM   (
   R€   R�   t   significantRo   R   t   npt   scalet
   sc_desiredt	   sc_actualR%   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR
   Ù  s>    8 *

	*c      
   ` sŒ  d d l  m } m } m } m }	 m }
 m } | ˆ d t d t ƒ‰ | ˆ d t d t ƒ‰ d „  } d ‡  ‡ ‡ ‡ ‡ f d † } y’ˆ j	 d k pµ ˆ j	 d k pµ ˆ j	 ˆ j	 k } | st
 ˆ ˆ g ˆ  d ˆ j	 ˆ j	 f d	 ˆ d
 ˆ d d ƒ} | st | ƒ ‚ qn  | ˆ ƒ rQ| ˆ ƒ rQ| ˆ ƒ | ˆ ƒ } } | ˆ ƒ | ˆ ƒ } } |	 | ƒ ss|	 | ƒ r‰| | | d d ƒn  |	 | ƒ s¡|	 | ƒ ræ| ˆ | 
k ˆ | 
k d d ƒ| ˆ | k ˆ | k d d ƒn  | | } } | | O} | | O} |
 | ƒ rd  S|	 | ƒ r?|  ˆ | ˆ | ƒ } q`|  ˆ ˆ ƒ } n |  ˆ ˆ ƒ } t | t ƒ r�| } d g } n$ | j ƒ  } | j ƒ  } | j ƒ  } | sd d | j d ƒ t | ƒ } t
 ˆ ˆ g ˆ  d | f d	 ˆ d
 ˆ d d ƒ} | st | ƒ ‚ qn  Wnn t k
 r‡} d d  l } | j ƒ  } d | ˆ f ‰ t
 ˆ ˆ g ˆ  d	 ˆ d
 ˆ d d ƒ} t | ƒ ‚ n Xd  S(   Ni    (   t   arrayR&   R4   t   anyt   allt   inft   copyt   subokc         S` s   |  j  j d k S(   Ns   ?bhilqpBHILQPefdgFDG(   t   dtypet   char(   R,   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   isnumber>  s    t   nanc      
   ` sd   y t  |  | ƒ WnL t k
 r_ t ˆ ˆ g ˆ  d | d ˆ d ˆ d d ƒ} t | ƒ ‚ n Xd S(	   sT   Handling nan/inf: check that x and y have the nan/inf at the same
        locations.s   
x and y %s location mismatch:R   Rp   Rq   R,   t   yN(   R,   R§   (   R   R#   R   (   t   x_idt   y_idt   hasvalR%   (   Ro   Rp   R   R,   R§   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   chk_same_positionA  s    	s   
(shapes %s, %s mismatch)R   Rp   Rq   R,   R§   Rª   s   +infs   -infid   g      Y@i   s   
(mismatch %s%%)s   error during assertion:

%s

%s(    (    (   R,   R§   (   R,   R§   (   R,   R§   (   R'   R�   R&   R4   Rž   RŸ   R    R   t   Truet   shapeR   R#   R(   t   boolt   ravelt   tolistRk   R;   R~   t	   tracebackt
   format_exc(   t
   comparisonR,   R§   Ro   R   Rp   R�   R&   R4   Rž   RŸ   R    R¥   R«   t   condR%   t   x_isnant   y_isnant   x_isinft   y_isinfR¨   R©   R$   t   reducedt   matcht   eR±   t   efmt(    (   Ro   Rp   R   R,   R§   sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   assert_array_compare8  sn    .	0		!$

!		c      
   C` s)   t  t j |  | d | d | d d ƒd S(   s&  
    Raise an assertion if two array_like objects are not equal.

    Given two array_like objects, check that the shape is equal and all
    elements of these objects are equal. An exception is raised at
    shape mismatch or conflicting values. In contrast to the standard usage
    in numpy, NaNs are compared like numbers, no assertion is raised if
    both objects have NaNs in the same positions.

    The usual caution for verifying equality with floating point numbers is
    advised.

    Parameters
    ----------
    x : array_like
        The actual object to check.
    y : array_like
        The desired, expected object.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
        If actual and desired objects are not equal.

    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

    Examples
    --------
    The first assert does not raise an exception:

    >>> np.testing.assert_array_equal([1.0,2.33333,np.nan],
    ...                               [np.exp(0),2.33333, np.nan])

    Assert fails with numerical inprecision with floats:

    >>> np.testing.assert_array_equal([1.0,np.pi,np.nan],
    ...                               [1, np.sqrt(np.pi)**2, np.nan])
    ...
    <type 'exceptions.ValueError'>:
    AssertionError:
    Arrays are not equal
    <BLANKLINE>
    (mismatch 50.0%)
     x: array([ 1.        ,  3.14159265,         NaN])
     y: array([ 1.        ,  3.14159265,         NaN])

    Use `assert_allclose` or one of the nulp (number of floating point values)
    functions for these cases instead:

    >>> np.testing.assert_allclose([1.0,np.pi,np.nan],
    ...                            [1, np.sqrt(np.pi)**2, np.nan],
    ...                            rtol=1e-10, atol=0)

    Ro   R   Rp   s   Arrays are not equalN(   R½   t   operatort   __eq__(   R,   R§   Ro   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   Ž  s    ?i   c         ` s„   d d l  m ‰  m ‰ m ‰ d d l m ‰ d d l m ‰ ‡  ‡ ‡ ‡ ‡ ‡ f d †  } t | |  | d | d | d d	 ˆ ƒd
 S(   s�	  
    Raise an assertion if two objects are not equal up to desired precision.

    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.

    The test verifies identical shapes and verifies values with
    ``abs(desired-actual) < 0.5 * 10**(-decimal)``.

    Given two array_like objects, check that the shape is equal and all
    elements of these objects are almost equal. An exception is raised at
    shape mismatch or conflicting values. In contrast to the standard usage
    in numpy, NaNs are compared like numbers, no assertion is raised if
    both objects have NaNs in the same positions.

    Parameters
    ----------
    x : array_like
        The actual object to check.
    y : array_like
        The desired, expected object.
    decimal : int, optional
        Desired precision, default is 6.
    err_msg : str, optional
      The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
        If actual and desired are not equal up to specified precision.

    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

    Examples
    --------
    the first assert does not raise an exception

    >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan],
                                             [1.0,2.333,np.nan])

    >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
    ...                                      [1.0,2.33339,np.nan], decimal=5)
    ...
    <type 'exceptions.AssertionError'>:
    AssertionError:
    Arrays are not almost equal
    <BLANKLINE>
    (mismatch 50.0%)
     x: array([ 1.     ,  2.33333,      NaN])
     y: array([ 1.     ,  2.33339,      NaN])

    >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
    ...                                      [1.0,2.33333, 5], decimal=5)
    <type 'exceptions.ValueError'>:
    ValueError:
    Arrays are not almost equal
     x: array([ 1.     ,  2.33333,      NaN])
     y: array([ 1.     ,  2.33333,  5.     ])

    i    (   t   aroundt   numbert   float_(   t
   issubdtype(   Rž   c         ` sû   y• ˆ t  |  ƒ ƒ s' ˆ t  | ƒ ƒ r” t  |  ƒ } t  | ƒ } | | k sO t S|  j | j k ol d k n r{ |  | k S|  | }  | | } n  Wn t t f k
 r® n Xt |  | ƒ } ˆ | j ˆ ƒ sã | j ˆ ƒ } n  ˆ  | ˆ ƒ d ˆ k S(   Ni   g      $@(   R5   R   t   sizeR+   RM   R�   R£   t   astype(   R,   R§   t   xinfidt   yinfidt   z(   RÀ   RŽ   RÂ   RÃ   t   npanyRÁ   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   compare  s     $"
Ro   R   Rp   s*   Arrays are not almost equal to %d decimalsN(	   R'   RÀ   RÁ   RÂ   t   numpy.core.numerictypesRÃ   t   numpy.core.fromnumericRž   R½   (   R,   R§   RŽ   Ro   R   RÊ   (    (   RÀ   RŽ   RÂ   RÃ   RÉ   RÁ   sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   Ð  s    Ec      
   C` s)   t  t j |  | d | d | d d ƒd S(   s<  
    Raise an assertion if two array_like objects are not ordered by less than.

    Given two array_like objects, check that the shape is equal and all
    elements of the first object are strictly smaller than those of the
    second object. An exception is raised at shape mismatch or incorrectly
    ordered values. Shape mismatch does not raise if an object has zero
    dimension. In contrast to the standard usage in numpy, NaNs are
    compared, no assertion is raised if both objects have NaNs in the same
    positions.



    Parameters
    ----------
    x : array_like
      The smaller object to check.
    y : array_like
      The larger object to compare.
    err_msg : string
      The error message to be printed in case of failure.
    verbose : bool
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
      If actual and desired objects are not equal.

    See Also
    --------
    assert_array_equal: tests objects for equality
    assert_array_almost_equal: test objects for equality up to precision



    Examples
    --------
    >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1.1, 2.0, np.nan])
    >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1, 2.0, np.nan])
    ...
    <type 'exceptions.ValueError'>:
    Arrays are not less-ordered
    (mismatch 50.0%)
     x: array([  1.,   1.,  NaN])
     y: array([  1.,   2.,  NaN])

    >>> np.testing.assert_array_less([1.0, 4.0], 3)
    ...
    <type 'exceptions.ValueError'>:
    Arrays are not less-ordered
    (mismatch 50.0%)
     x: array([ 1.,  4.])
     y: array(3)

    >>> np.testing.assert_array_less([1.0, 2.0, 3.0], [4])
    ...
    <type 'exceptions.ValueError'>:
    Arrays are not less-ordered
    (shapes (3,), (1,) mismatch)
     x: array([ 1.,  2.,  3.])
     y: array([4])

    Ro   R   Rp   s   Arrays are not less-orderedN(   R½   R¾   t   __lt__(   R,   R§   Ro   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   -  s    Ac         B` s   |  | f d  Ud  S(   N(    (   t   astrRy   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   r  s    c   
      C` s>  d d l  } t |  t ƒ s6 t t t |  ƒ ƒ ƒ ‚ n  t | t ƒ s` t t t | ƒ ƒ ƒ ‚ n  t j d | d |  t j ƒ r„ d St	 | j
 ƒ  j |  j d ƒ | j d ƒ ƒ ƒ } g  } x?| rû| j d ƒ } | j d ƒ rç q½ n  | j d ƒ ræ| g } | j d ƒ } | j d ƒ r<| j | ƒ | j d ƒ } n  | j d	 ƒ s`t t | ƒ ƒ ‚ n  | j | ƒ | j d ƒ } | j d ƒ r›| j | ƒ n | j d | ƒ t j d | d
 d | d
 ƒ rÓq½ n  | j | ƒ q½ n  t t | ƒ ƒ ‚ q½ W| sd Sd d j | ƒ j ƒ  }	 |  | k r:t |	 ƒ ‚ n  d S(   sž  
    Test if two strings are equal.

    If the given strings are equal, `assert_string_equal` does nothing.
    If they are not equal, an AssertionError is raised, and the diff
    between the strings is shown.

    Parameters
    ----------
    actual : str
        The string to test for equality against the expected string.
    desired : str
        The expected string.

    Examples
    --------
    >>> np.testing.assert_string_equal('abc', 'abc')
    >>> np.testing.assert_string_equal('abc', 'abcd')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ...
    AssertionError: Differences in strings:
    - abc+ abcd?    +

    i    Ns   \As   \Zi   s     s   - s   ? s   + i   s   Differences in strings:
%sR"   (   t   difflibR(   t   strR#   Rj   R)   t   reRº   t   MR{   t   DifferRÊ   Rm   t   popt
   startswithRD   t   insertt   extendRl   t   rstrip(
   R€   R�   RÏ   t   difft	   diff_listt   d1RL   t   d2t   d3R%   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   u  sH     0		"c         ` sc  d d l  } d d l } |  d k rC t j d ƒ } | j d }  n  t j j t j j	 |  ƒ ƒ d } t j j
 |  ƒ g } | j | | ƒ \ } } }	 z | j | | | |	 ƒ }
 Wd | j ƒ  X| j ƒ  j |
 ƒ } | j d t ƒ } g  ‰  | r‡  f d †  } n d } x! | D] } | j | d | ƒqW| j d k r_| r_t d d	 j ˆ  ƒ ƒ ‚ n  d S(
   sT  
    Run doctests found in the given file.

    By default `rundocs` raises an AssertionError on failure.

    Parameters
    ----------
    filename : str
        The path to the file for which the doctests are run.
    raise_on_error : bool
        Whether to raise an AssertionError when a doctest fails. Default is
        True.

    Notes
    -----
    The doctests can be run by the user/developer by adding the ``doctests``
    argument to the ``test()`` call. For example, to run all tests (including
    doctests) for `numpy.lib`:

    >>> np.lib.test(doctests=True) #doctest: +SKIP
    i    Ni   t   __file__R   c         ` s   ˆ  j  |  ƒ S(   N(   RD   (   t   s(   R%   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   <lambda>à  s    t   outs   Some doctests failed:
%ss   
(   t   doctestt   impRP   t   syst	   _getframet	   f_globalst   osR_   t   splitextt   basenamet   dirnamet   find_modulet   load_moduleRH   t   DocTestFinderRh   t   DocTestRunnerR   t   runt   failuresR#   Rl   (   t   filenamet   raise_on_errorRâ   Rã   R>   t   nameR_   t   filet   pathnamet   descriptiont   mt   testst   runnerRá   t   test(    (   R%   sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ¹  s(    "c          O` s   t  ƒ  } | j j |  | Ž  S(   N(   R   t   toolsR   (   R<   t   kwargst   nose(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ë  s    	c          O` s   t  ƒ  } | j j |  | Ž  S(   s‹  
    assert_raises(exception_class, callable, *args, **kwargs)

    Fail unless an exception of class exception_class is thrown
    by callable when invoked with arguments args and keyword
    arguments kwargs. If a different type of exception is
    thrown, it will not be caught, and the test case will be
    deemed to have suffered an error, exactly as for an
    unexpected exception.

    (   R   Rû   R   (   R<   Rü   Rý   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ï  s    	c   	      C` s  | d k r% t j d t j ƒ } n t j | ƒ } |  j } d d l m } g  | j ƒ  D] } | | ƒ rZ | ^ qZ } x… | D]} } y( t	 | d ƒ r£ | j
 } n	 | j } Wn t k
 rÃ q n X| j | ƒ r | j d ƒ r t |  | | | ƒ ƒ q q Wd S(   s  
    Apply a decorator to all methods in a class matching a regular expression.

    The given decorator is applied to all public methods of `cls` that are
    matched by the regular expression `testmatch`
    (``testmatch.search(methodname)``). Methods that are private, i.e. start
    with an underscore, are ignored.

    Parameters
    ----------
    cls : class
        Class whose methods to decorate.
    decorator : function
        Decorator to apply to methods
    testmatch : compiled regexp or str, optional
        The regular expression. Default value is None, in which case the
        nose default (``re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep)``)
        is used.
        If `testmatch` is a string, it is compiled to a regular expression
        first.

    s   (?:^|[\\b_\\.%s-])[Tt]esti    (   t
   isfunctiont   compat_func_namet   _N(   RP   RÑ   t   compileRç   t   sept   __dict__t   inspectRþ   t   valuest   hasattrRÿ   t   __name__t   AttributeErrort   searchRÕ   t   setattr(	   t   clst	   decoratort	   testmatcht   cls_attrRþ   t   _mt   methodst   functiont   funcname(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   þ  s     	+c   	      B` sŠ   e  j d ƒ } | j | j } } e |  d | d ƒ } d } e ƒ  } x+ | | k  rt | d 7} | | | f d UqJ We ƒ  | } d | S(   sD  
    Return elapsed time for executing code in the namespace of the caller.

    The supplied code string is compiled with the Python builtin ``compile``.
    The precision of the timing is 10 milli-seconds. If the code will execute
    fast on this timescale, it can be executed many times to get reasonable
    timing accuracy.

    Parameters
    ----------
    code_str : str
        The code to be timed.
    times : int, optional
        The number of times the code is executed. Default is 1. The code is
        only compiled once.
    label : str, optional
        A label to identify `code_str` with. This is passed into ``compile``
        as the second argument (for run-time error messages).

    Returns
    -------
    elapsed : float
        Total elapsed time in seconds for executing `code_str` `times` times.

    Examples
    --------
    >>> etime = np.testing.measure('for i in range(1000): np.sqrt(i**2)',
    ...                            times=times)
    >>> print "Time for a single execution : ", etime / times, "s"
    Time for a single execution :  0.005 s

    i   s   Test name: %s t   execi    Ng{®Gáz„?(   Rä   Rå   t   f_localsRæ   R  R   (	   t   code_strt   timest   labelt   framet   locst   globst   codeR?   t   elapsed(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   -  s    !		
c   	      C` s”   d d l  } | j d ƒ } | j d ƒ j d d ƒ } | } d } t j | ƒ } x# t d ƒ D] } |  | | ƒ } q^ Wt t j | ƒ | k ƒ d S(   sg   
    Check that ufuncs don't mishandle refcount of object `1`.
    Used in a few regression tests.
    i    Nid   i   i   i'  i'  (   R‘   R   t   reshapeRä   t   getrefcountR:   R   (	   t   opR™   Rr   t   bt   cR?   t   rct   jt   d(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   _assert_valid_refcount\  s    gH¯¼šò×z>c      
   ` s|   d d l  ‰ ‡  ‡ ‡ f d †  } ˆ j |  ƒ ˆ j | ƒ }  } d ˆ ˆ  f } t | |  | d t | ƒ d | d | ƒd S(   s  
    Raise an assertion if two objects are not equal up to desired tolerance.

    The test is equivalent to ``allclose(actual, desired, rtol, atol)``.
    It compares the difference between `actual` and `desired` to
    ``atol + rtol * abs(desired)``.

    .. versionadded:: 1.5.0

    Parameters
    ----------
    actual : array_like
        Array obtained.
    desired : array_like
        Array desired.
    rtol : float, optional
        Relative tolerance.
    atol : float, optional
        Absolute tolerance.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.

    Raises
    ------
    AssertionError
        If actual and desired are not equal up to specified precision.

    See Also
    --------
    assert_array_almost_equal_nulp, assert_array_max_ulp

    Examples
    --------
    >>> x = [1e-5, 1e-3, 1e-1]
    >>> y = np.arccos(np.cos(x))
    >>> assert_allclose(x, y, rtol=1e-5, atol=0)

    i    Nc         ` s   ˆ j  |  | d ˆ d ˆ  ƒS(   Nt   rtolt   atol(   t   allclose(   R,   R§   (   R'  R™   R&  (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRÊ   ™  s    s'   Not equal to tolerance rtol=%g, atol=%gRo   R   Rp   (   R‘   t
   asanyarrayR½   RÐ   (   R€   R�   R&  R'  Ro   R   RÊ   Rp   (    (   R'  R™   R&  sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR    n  s    *c   	      C` sÚ   d d l  } | j |  ƒ } | j | ƒ } | | j | j | | k | | ƒ ƒ } | j | j |  | ƒ | k ƒ sÖ | j |  ƒ s’ | j | ƒ rŸ d | } n( | j t |  | ƒ ƒ } d | | f } t | ƒ ‚ n  d S(   s  
    Compare two arrays relatively to their spacing.

    This is a relatively robust method to compare two arrays whose amplitude
    is variable.

    Parameters
    ----------
    x, y : array_like
        Input arrays.
    nulp : int, optional
        The maximum number of unit in the last place for tolerance (see Notes).
        Default is 1.

    Returns
    -------
    None

    Raises
    ------
    AssertionError
        If the spacing between `x` and `y` for one or more elements is larger
        than `nulp`.

    See Also
    --------
    assert_array_max_ulp : Check that all items of arrays differ in at most
        N Units in the Last Place.
    spacing : Return the distance between x and the nearest adjacent number.

    Notes
    -----
    An assertion is raised if the following condition is not met::

        abs(x - y) <= nulps * spacing(max(abs(x), abs(y)))

    Examples
    --------
    >>> x = np.array([1., 1e-10, 1e-20])
    >>> eps = np.finfo(x.dtype).eps
    >>> np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)

    >>> np.testing.assert_array_almost_equal_nulp(x, x*eps + x)
    ------------------------------------------------------------
    Traceback (most recent call last):
      ...
    AssertionError: X and Y are not equal to 1 ULP (max is 2)

    i    Ns   X and Y are not equal to %d ULPs+   X and Y are not equal to %d ULP (max is %g)(	   R‘   R�   t   spacingt   whereRŸ   Rv   t   maxt	   nulp_diffR#   (	   R,   R§   t   nulpR™   t   axt   ayt   refR%   t   max_nulp(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ¡  s    2("c         C` sJ   d d l  } t |  | | ƒ } | j | | k ƒ sF t d | ƒ ‚ n  | S(   s£  
    Check that all items of arrays differ in at most N Units in the Last Place.

    Parameters
    ----------
    a, b : array_like
        Input arrays to be compared.
    maxulp : int, optional
        The maximum number of units in the last place that elements of `a` and
        `b` can differ. Default is 1.
    dtype : dtype, optional
        Data-type to convert `a` and `b` to if given. Default is None.

    Returns
    -------
    ret : ndarray
        Array containing number of representable floating point numbers between
        items in `a` and `b`.

    Raises
    ------
    AssertionError
        If one or more elements differ by more than `maxulp`.

    See Also
    --------
    assert_array_almost_equal_nulp : Compare two arrays relatively to their
        spacing.

    Examples
    --------
    >>> a = np.linspace(0., 1., 100)
    >>> res = np.testing.assert_array_max_ulp(a, np.arcsin(np.sin(a)))

    i    Ns(   Arrays are not almost equal up to %g ULP(   R‘   R-  RŸ   R#   (   Rr   R   t   maxulpR£   R™   t   ret(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ß  s    $c         ` s.  d d l  ‰  | r? ˆ  j |  d | ƒ}  ˆ  j | d | ƒ} n ˆ  j |  ƒ }  ˆ  j | ƒ } ˆ  j |  | ƒ } ˆ  j |  ƒ s� ˆ  j | ƒ rœ t d ƒ ‚ n  ˆ  j |  d | ƒ}  ˆ  j | d | ƒ} |  j | j k s÷ t d |  j | j f ƒ ‚ n  ‡  f d †  } t |  ƒ } t | ƒ } | | | | ƒ S(   sE  For each item in x and y, return the number of representable floating
    points between them.

    Parameters
    ----------
    x : array_like
        first input array
    y : array_like
        second input array

    Returns
    -------
    nulp : array_like
        number of representable floating point numbers between each item in x
        and y.

    Examples
    --------
    # By definition, epsilon is the smallest number such as 1 + eps != 1, so
    # there should be exactly one ULP between 1 and 1 + eps
    >>> nulp_diff(1, 1 + np.finfo(x.dtype).eps)
    1.0
    i    NR£   s'   _nulp not implemented for complex arrays+   x and y do not have the same shape: %s - %sc         ` s&   ˆ  j  |  | d | ƒ} ˆ  j | ƒ S(   NR£   (   R�   R�   (   t   rxt   ryt   vdtRÙ   (   R™   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   _diff5  s    (   R‘   R�   t   common_typeRv   RM   R­   R~   t   integer_repr(   R,   R§   R£   t   tR8  R5  R6  (    (   R™   sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR-  
  s$    c         C` s\   |  j  | ƒ } | j d k s? | | | d k  | | d k  <n | d k  rX | | } n  | S(   Ni   i    (   t   viewRÄ   (   R,   R7  t   compR5  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   _integer_repr=  s    !c         C` s   d d l  } |  j | j k r: t |  | j | j d ƒ ƒ S|  j | j k rh t |  | j | j d
 ƒ ƒ St d |  j ƒ ‚ d S(   sQ   Return the signed-magnitude interpretation of the binary representation of
    x.i    Ni   i   i?   s   Unsupported dtype %sl        lýÿÿÿ     l            lûÿÿÿ         (   R‘   R£   R   R>  t   int32R7   t   int64R~   (   R,   R™   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR:  K  s    t   WarningMessagec           B` s,   e  Z d  Z d	 Z d
 d
 d „ Z d „  Z RS(   sè   
    Holds the result of a single showwarning() call.

    Deprecated in 1.8.0

    Notes
    -----
    `WarningMessage` is copied from the Python 2.6 warnings module,
    so it can be used in NumPy with older Python versions.

    t   messaget   categoryRñ   t   linenoRô   t   linec   	      C` sS   t  ƒ  } x% |  j D] } t |  | | | ƒ q W| rF | j |  _ n	 d  |  _ d  S(   N(   t   localst   _WARNING_DETAILSR
  R  t   _category_nameRP   (	   t   selfRB  RC  Rñ   RD  Rô   RE  t   local_valuest   attr(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   __init__i  s    	c         C` s&   d |  j  |  j |  j |  j |  j f S(   NsD   {message : %r, category : %r, filename : %r, lineno : %s, line : %r}(   RB  RH  Rñ   RD  RE  (   RI  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   __str__s  s    (   s   messages   categorys   filenames   linenos   files   lineN(   R  t
   __module__t   __doc__RG  RP   RL  RM  (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRA  X  s    	t   WarningManagerc           B` s/   e  Z d  Z e d d „ Z d „  Z d „  Z RS(   sŸ  
    A context manager that copies and restores the warnings filter upon
    exiting the context.

    The 'record' argument specifies whether warnings should be captured by a
    custom implementation of ``warnings.showwarning()`` and be appended to a
    list returned by the context manager. Otherwise None is returned by the
    context manager. The objects appended to the list are arguments whose
    attributes mirror the arguments to ``showwarning()``.

    The 'module' argument is to specify an alternative module to the module
    named 'warnings' and imported under that name. This argument is only useful
    when testing the warnings module itself.

    Deprecated in 1.8.0

    Notes
    -----
    `WarningManager` is a copy of the ``catch_warnings`` context manager
    from the Python 2.6 warnings module, with slight modifications.
    It is copied so it can be used in NumPy with older Python versions.

    c         C` s>   | |  _  | d  k r( t j d |  _ n	 | |  _ t |  _ d  S(   Nt   warnings(   t   _recordRP   Rä   t   modulest   _moduleR   t   _entered(   RI  t   recordt   module(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRL  �  s
    		c         ` s‰   |  j  r t d |  ƒ ‚ n  t |  _  |  j j |  _ |  j |  j _ |  j j |  _ |  j r� g  ‰  ‡  f d †  } | |  j _ ˆ  Sd  Sd  S(   Ns   Cannot enter %r twicec          ` s   ˆ  j  t |  | Ž  ƒ d  S(   N(   RD   RA  (   R<   Rü   (   t   log(    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   showwarning¡  s    (
   RU  t   RuntimeErrorR¬   RT  t   filterst   _filtersRY  t   _showwarningRR  RP   (   RI  RY  (    (   RX  sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt	   __enter__˜  s    			c         C` s>   |  j  s t d |  ƒ ‚ n  |  j |  j _ |  j |  j _ d  S(   Ns%   Cannot exit %r without entering first(   RU  RZ  R\  RT  R[  R]  RY  (   RI  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   __exit__¨  s    	N(   R  RN  RO  R   RP   RL  R^  R_  (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRP  x  s   	c      
   O` s™   t  j d t ƒ �� } t  j d ƒ | | | Ž  } t | ƒ d k sY t d | j ƒ ‚ n  | d j |  k	 r� t d | j |  | d f ƒ ‚ n  Wd QX| S(   sá  
    Fail unless the given callable throws the specified warning.

    A warning of class warning_class should be thrown by the callable when
    invoked with arguments args and keyword arguments kwargs.
    If a different type of warning is thrown, it will not be caught, and the
    test case will be deemed to have suffered an error.

    .. versionadded:: 1.4.0

    Parameters
    ----------
    warning_class : class
        The class defining the warning that `func` is expected to throw.
    func : callable
        The callable to test.
    \*args : Arguments
        Arguments passed to `func`.
    \*\*kwargs : Kwargs
        Keyword arguments passed to `func`.

    Returns
    -------
    The value returned by `func`.

    RV  t   alwaysi    s!   No warning raised when calling %ss(   First warning for %s is not a %s( is %s)N(   RQ  t   catch_warningsR¬   t   simplefilterR;   R#   R  RC  (   t   warning_classt   funcR<   t   kwRL   t   result(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   ¯  s    #c         O` si   t  j d t ƒ �Q } t  j d ƒ |  | | Ž  } t | ƒ d k r_ t d |  j | f ƒ ‚ n  Wd QX| S(   sd  
    Fail if the given callable produces any warnings.

    .. versionadded:: 1.7.0

    Parameters
    ----------
    func : callable
        The callable to test.
    \*args : Arguments
        Arguments passed to `func`.
    \*\*kwargs : Kwargs
        Keyword arguments passed to `func`.

    Returns
    -------
    The value returned by `func`.

    RV  R`  i    s    Got warnings when calling %s: %sN(   RQ  Ra  R¬   Rb  R;   R#   R  (   Rd  R<   Re  RL   Rf  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR   Õ  s    t   binaryi   c   	      #` s  d } d } xt  d ƒ D]ý‰ xôt  ˆ d t ˆ d | ƒ ƒ D]Ò‰ | d k r¤‡  ‡ ‡ f d †  } t ˆ f d ˆ  ƒˆ } | | ƒ  | ˆ ˆ ˆ ˆ  d f f V| ƒ  | ƒ  | ˆ ˆ ˆ ˆ  d	 f f V| d
 | ƒ  d  | ˆ d
 ˆ ˆ d
 ˆ  d f f V| d  | ƒ  d
 | ˆ ˆ d
 ˆ d
 ˆ  d f f V| ƒ  d  | ƒ  d
 | ˆ ˆ d
 ˆ d
 ˆ  d f f V| ƒ  d
 | ƒ  d  | ˆ d
 ˆ ˆ d
 ˆ  d f f Vn  | d k r@ ‡  ‡ ‡ f d †  } ‡  ‡ ‡ f d †  } t ˆ f d ˆ  ƒˆ } | | ƒ  | ƒ  | ˆ ˆ ˆ ˆ ˆ  d f f V| ƒ  | ƒ  | ƒ  | ˆ ˆ ˆ ˆ ˆ  d f f V| ƒ  | ƒ  | ƒ  | ˆ ˆ ˆ ˆ ˆ  d f f V| d
 | ƒ  d  | ƒ  d  | ˆ d
 ˆ ˆ ˆ d
 ˆ  d f f V| d  | ƒ  d
 | ƒ  d  | ˆ ˆ d
 ˆ ˆ d
 ˆ  d f f V| d  | ƒ  d  | ƒ  d
 | ˆ ˆ ˆ d
 ˆ d
 ˆ  d f f V| ƒ  d
 | ƒ  d  | ƒ  d  | ˆ d
 ˆ ˆ ˆ d
 ˆ  d f f V| ƒ  d  | ƒ  d
 | ƒ  d  | ˆ ˆ d
 ˆ ˆ d
 ˆ  d f f V| ƒ  d  | ƒ  d  | ƒ  d
 | ˆ ˆ ˆ d
 ˆ d
 ˆ  d f f Vq@ q@ Wq Wd S(   sÓ  
    generator producing data with different alignment and offsets
    to test simd vectorization

    Parameters
    ----------
    dtype : dtype
        data type to produce
    type : string
        'unary': create data for unary operations, creates one input
                 and output array
        'binary': create data for unary operations, creates two input
                 and output array
    max_size : integer
        maximum size of data to produce

    Returns
    -------
    if type is 'unary' yields one output, one input array and a message
    containing information on the data
    if type is 'binary' yields one output array, two input array and a message
    containing information on the data

    s,   unary offset=(%d, %d), size=%d, dtype=%r, %ss1   binary offset=(%d, %d, %d), size=%d, dtype=%r, %si   i   t   unaryc           ` s   t  ˆ d ˆ  ƒˆ S(   NR£   (   R   (    (   R£   t   oRß   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRà     s    R£   s   out of places   in placei   iÿÿÿÿt   aliasedRg  c           ` s   t  ˆ d ˆ  ƒˆ S(   NR£   (   R   (    (   R£   Ri  Rß   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRà     s    c           ` s   t  ˆ d ˆ  ƒˆ S(   NR£   (   R   (    (   R£   Ri  Rß   (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyRà     s    s	   in place1s	   in place2N(   R:   R,  R   (	   R£   R)   t   max_sizet   ufmtt   bfmtt   inpRá   t   inp1t   inp2(    (   R£   Ri  Rß   sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   _gen_alignment_dataò  sN    '$'   ####!#!#!c           B` s   e  Z d  Z RS(   s/   Ignoring this exception due to disabled feature(   R  RN  RO  (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyR!   4  s   (   Rf   Rg   (B   RO  t
   __future__R    R   R   Rç   Rä   RÑ   R¾   RQ  t
   nosetesterR   R'   R   R   R   t   version_infot   ioR   t   __all__R   R   R.   R3   R5   R   t   platformt   getpidR   R   Ró   t   versionRP   Rb   R¬   R   R   R   R	   R
   R½   R   R   R   R   R   R   R   R   R   R   R%  R    R   R   R-  R>  R:  RY   RA  RP  R   R   Rq  t	   ExceptionR!   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/utils.pyt   <module>   sˆ   									"o	's_UB]E		D2		//	2>+3		 7	&	B