Current File : //proc/self/root/proc/self/root/lib64/python2.7/site-packages/numpy/testing/utils.pyc
�
E�`Qc@s�dZddlZddlZddlZddlZddlZddlZddlmZdddddd	d
ddd
dddddddddddddddgZ	dZ
dd�Zd �Zd!�Z
d"�Zd#�Zejd$ d%kr*d&ej�gd'�Zd&ej�d(�Zngd)�Zd*�Zejd+kr�ejd, d-kr�ddddd.�Zd/dd0�Znd1edUd4�Zded5�Zd6�Zd7ded8�Zd7ded9�Zdedd:�Zded;�Zd<ded=�Z ded>�Z!d?�Z"d@�Z#dedA�Z$dB�Z%dC�Z&ddD�Z'dEddF�Z(dG�Z)dHddedI�Z*dEdJ�Z+dEddK�Z,ddL�Z-dM�Z.dN�Z/dOe0fdP��YZ1dQe0fdR��YZ2dS�Z3dT�Z4dS(Vs)
Utility function to facilitate testing.
i����N(timport_nosetassert_equaltassert_almost_equaltassert_approx_equaltassert_array_equaltassert_array_lesstassert_string_equaltassert_array_almost_equalt
assert_raisest
build_err_msgtdecorate_methodstjiffiestmemusagetprint_assert_equaltraisestrandtrundocst	runstringtverbosetmeasuretassert_tassert_array_almost_equal_nulptassert_array_max_ulptassert_warnstassert_no_warningstassert_allcloseitcCs|st|��ndS(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(tAssertionError(tvaltmsg((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRs
cCsAddlm}||�}t|tj�r=td��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����(tisnans!isnan not supported for this type(t
numpy.coreRt
isinstancettypestNotImplementedTypet	TypeError(txRtst((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytgisnan%s
cCshddlm}m}|dd�}z1||�}t|tj�rUtd��nWd||�X|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����(tisfinitetseterrtinvalidtignores$isfinite not supported for this typeN(RR'R(R R!R"R#(R$R'R(terrR%((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt	gisfinite6scCshddlm}m}|dd�}z1||�}t|tj�rUtd��nWd||�X|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����(tisinfR(R)R*s!isinf not supported for this typeN(RR-R(R R!R"R#(R$R-R(R+R%((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytgisinfKscGskddl}ddlm}m}|||�}|j}x*tt|��D]}|j�||<qMW|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(tzerostfloat64(trandomRR/R0tflattrangetlen(targsR1R/R0tresultstfti((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR`s	itlinuxs
/proc/%s/statcCs�ddl}|s(|j|j��ny@t|d�}|j�jd�}|j�t|d�SWn td|j�|d�SXdS(sx Return number of jiffies (1/100ths of a second) that this
    process has been scheduled in user mode. See man 5 proc. i����Ntrt i
idi(ttimetappendtopentreadlinetsplittclosetint(t_proc_pid_statt
_load_timeR<R7tl((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRns
cCsOy@t|d�}|j�jd�}|j�t|d�SWndSXdS(sD Return virtual memory size in bytes of the running python.
        R:R;iN(R>R?R@RARB(RCR7RE((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR}s
cCsDddl}|s(|j|j��ntd|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����Nidi(R<R=RB(RDR<((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�scCs
t�dS(s9 Return memory usage of running python. [Not implemented]N(tNotImplementedError(((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�stntis2.3cCs�ddl}|dkr$|j}n|j|||d||f�}|j�}zT|j||�}	z-|j|�|j|	|�\}
}|SWd|j|	�XWd|j	|�XdS(Ni����(
twin32pdhtNonetPDH_FMT_LONGtMakeCounterPatht	OpenQueryt
AddCountertCollectQueryDatatGetFormattedCounterValuet
RemoveCountert
CloseQuery(tobjecttcountertinstancetinumtformattmachineRHtpaththqthcttypeR((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytGetPerformanceAttributes�s
!
tpythoncCs(ddl}tdd|||jd�S(Ni����tProcesss
Virtual Bytes(RHR\RJRI(tprocessNameRTRH((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s	sItems are not equal:tACTUALtDESIREDc	Csd|g}|rl|jd�dkr\t|�dt|�kr\|dd|g}ql|j|�n|rx�t|�D]�\}}yt|�}Wn
d}nX|jd�dkr�dj|j�d �}|d7}n|jd	|||f�qWndj|�S(
Ns
i����iOiR;s
[repr failed]is...s %s: %s(tfindR4R=t	enumeratetreprtcounttjoint
splitlines(	tarraysterr_msgtheaderRtnamesRR8taR:((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR	�s 
1

"c
Cs�t|t�r�t|t�s9ttt|����ntt|�t|�||�x`|j�D]R\}}||kr�tt|���nt||||d||f|�qeWdSt|tt	f�rNt|tt	f�rNtt|�t|�||�x?t
t|��D]+}t||||d||f|�qWdSddlm}m
}m}ddlm}	m}
m}t||�s�t||�r�t||||�St||g|d|�}y|	|�p�|	|�}
Wntk
rt}
nX|
r�|	|�r5|
|�}||�}n|}d}|	|�rh|
|�}||�}n|}d}yt||�t||�Wq�tk
r�t|��q�Xny�||�||�kr�t|��nt|�o�t|�sXt|�}t|�}|s|r9|o$|sTt|��qTn||ksTt|��ndS|dkr�|dkr�||�||�ks�t|��q�nWntttfk
r�nX||kr�t|��ndS(	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����(tndarraytisscalartsignbit(tiscomplexobjtrealtimagRi(R tdictRRdR[RR4titemstlistttupleR3RRmRnRot	numpy.libRpRqRrRR	t
ValueErrortFalseR,R&R#RF(tactualtdesiredRiRtkR8RmRnRoRpRqRrRt
usecomplextactualrtactualitdesiredrtdesireditisdesnantisactnan((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�st#)*)



cCs�ddl}||ks�ddl}|j�}|j|�|jd�|j||�|jd�|j||�t|j���ndS(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: 
(tpprintt	cStringIOtStringIOtwriteRtgetvalue(ttest_stringRzR{R�R�R((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR
<s


ic	CsLddlm}ddlm}m}m}y||�pD||�}	Wntk
rat}	nXt||g|d|dd|�}
|	r@||�r�||�}||�}n|}d}||�r�||�}
||�}n|}
d}y*t	||
d|�t	||d|�Wq@t
k
r<t
|
��q@Xnt||tt
f�spt||tt
f�r�t||||�Sy}t|�o�t|�s�t|�s�t|�r�t|�o�t|�s�t
|
��q�n||ks�t
|
��nd	SWnttfk
rnXtt||�|�dkrHt
|
��nd	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����(Rm(RpRqRrRRjs*Arrays are not almost equal to %d decimalsitdecimalN(RRmRwRpRqRrRxRyR	RRR RvRuRR,R&RFR#troundtabs(RzR{R�RiRRmRpRqRrR}RR~RR�R�((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRdsN=



cCs�ddl}tt||f�\}}||kr7dS|jdd�}zHd|j|�|j|�}|jd|j|j|���}Wd|j|�Xy||}Wntk
r�d}nXy||}	Wntk
r�d}	nXt	||g|dd	|d
|�}
y}t
|�o/t
|�s�t|�sJt|�rtt|�o_t|�s�t|
��q�n||ks�t|
��ndSWnt
tfk
r�nX|j||	�|jd|d�kr�t|
��ndS(
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����NR)R*g�?i
gRjs-Items are not equal to %d significant digits:Rg$@i(tnumpytmaptfloatR(R�tpowertfloortlog10tZeroDivisionErrorR	R,R&RR#RF(RzR{tsignificantRiRtnpR+tscalet
sc_desiredt	sc_actualR((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�sB8 (



	*cs�ddlm}m}m}m}	m}
m}|�dtdt��|�dtdt��d�}d�����fd�}
y��j	dkp��j	dkp��j	�j	k}|st
��g�d�j	�j	fd	�d
�dd�}|st|��qn|��rQ|��rQ|��|��}}|��|��}}|	|�ss|	|�r�|
||dd�n|	|�s�|	|�r�|
�|
k�|
kdd�|
�|k�|kdd�n||}}||O}||O}|
|�rdS|	|�r?|�|�|�}q`|���}n|���}t|t
�r�|}dg}n$|j�}|j�}|j�}|sdd|jd�t|�}t
��g�d|fd	�d
�dd�}|st|��qnWnntk
r�}ddl}|j�}d|�f�t
��g�d	�d
�dd�}t|��nXdS(Ni����(tarrayRR-tanytalltinftcopytsubokcSs|jjdkS(Ns?bhilqpBHILQPefdgFDG(tdtypetchar(R$((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytisnumber?stnanc
sdyt||�WnLtk
r_t��g�d|d�d�dd�}t|��nXdS(	sTHandling nan/inf: check that x and y have the nan/inf at the same
        locations.s
x and y %s location mismatch:RRjRkR$tyN(R$R�(RRR	(tx_idty_idthasvalR(RiRjRR$R�(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytchk_same_positionBs
	s
(shapes %s, %s mismatch)RRjRkR$R�R�s+infs-infiidgY@is
(mismatch %s%%)serror during assertion:

%s

%s(((R$R�(R$R�(R$R�(RR�RR-R�R�R�RytTruetshapeR	RR tbooltravelttolistReR4Rxt	tracebackt
format_exc(t
comparisonR$R�RiRRjR�RR-R�R�R�R�R�tcondRtx_isnanty_isnantx_isinfty_isinfR�R�RtreducedtmatchteR�tefmt((RiRjRR$R�s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytassert_array_compare9sn.	0		!$


!		c
Cs)ttj||d|d|dd�dS(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)

    RiRRjsArrays are not equalN(R�toperatort__eq__(R$R�RiR((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s?ics�ddlm�m�m�ddlm�ddlm�������fd�}t|||d|d|dd	��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����(taroundtnumbertfloat_(t
issubdtype(R�cs�y��t|��s'�t|��r�t|�}t|�}||ksOtS|j|jkoldknr{||kS||}||}nWnttfk
r�nXt||�}�|j��s�|j��}n�|��d�kS(Nig$@(R.RytsizeR#RFR�R�tastype(R$R�txinfidtyinfidtz(R�R�R�R�tnpanyR�(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytcompares $"
RiRRjs*Arrays are not almost equal to %d decimalsN(	RR�R�R�tnumpy.core.numerictypesR�tnumpy.core.fromnumericR�R�(R$R�R�RiRR�((R�R�R�R�R�R�s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�sEc
Cs)ttj||d|d|dd�dS(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])

    RiRRjsArrays are not less-orderedN(R�R�t__lt__(R$R�RiR((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR.sAcBs||UdS(N((tastrRs((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRssc
Cs*ddl}t|t�s1tt|�
��nt|t�sVtt|�
��ntjd|d|tj�rzdSt|j	�j
|jd�|jd���}g}x5|r�|jd�}|j
d�r�q�n|j
d�r�|g}|jd�}|j
d	�r2|j|�|jd�}n|j
d
�sQt|
��n|j|�|jd�}|j
d	�r�|j|�n|jd|�tjd|dd|d�r�q�n|j|�q�nt|
��q�W|s�dSdd
j|�j�}	||kr&t|	��ndS(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\Ziis  s- s? s+ isDifferences in strings:
%sR(tdifflibR tstrRR[treR�tMRutDifferR�Rgtpopt
startswithR=tinserttextendRftrstrip(
RzR{R�tdifft	diff_listtd1REtd2td3R((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRvsH 0		

"
cscddl}ddl}|dkrCtjd�}|jd}ntjjtjj	|��d}tjj
|�g}|j||�\}}}	z|j||||	�}
Wd|j
�X|j�j|
�}|jdt�}g�|r�fd�}
nd}
x!|D]}|j|d|
�qW|jdkr_|r_td	d
j����ndS(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����Nit__file__iRcs
�j|�S(N(R=(ts(R(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt<lambda>�stoutsSome doctests failed:
%ss
(tdoctesttimpRItsyst	_getframet	f_globalstosRXtsplitexttbasenametdirnametfind_moduletload_moduleRAt
DocTestFinderRbt
DocTestRunnerRytruntfailuresRRf(tfilenametraise_on_errorR�R�R7tnameRXtfiletpathnametdescriptiontmtteststrunnerR�ttest((Rs9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s("
cOst�}|jj||�S(N(RttoolsR(R5tkwargstnose((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s	cOst�}|jj||�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.

    (RR�R(R5R�R�((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s	cCs�|dkr%tjdtj�}ntj|�}|j}ddlm}t||j	��}x�|D]}}y(t
|d�r�|j}n	|j}Wnt
k
r�qinX|j|�ri|jd�rit||||��qiqiWdS(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
isfunctiontcompat_func_namet_N(RIR�tcompileR�tsept__dict__tinspectR�tfiltertvaluesthasattrR�t__name__tAttributeErrortsearchR�tsetattr(tclst	decoratort	testmatchtcls_attrR�tmethodstfunctiontfuncname((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR
�s 	


ic	Bs�ejd�}|j|j}}e|d|d�}d}e�}x$||krm|d7}|||UqJWe�|}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

    isTest name: %s texecig{�G�z�?(R�R�tf_localsR�R�R(	tcode_strttimestlabeltframetlocstglobstcodeR8telapsed((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR,s!		

c	Cs�ddl}|jd�}|jd�jdd�}|}d}tj|�}x#td�D]}|||�}q^Wttj|�|k�dS(sg
    Check that ufuncs don't mishandle refcount of object `1`.
    Used in a few regression tests.
    i����Nidiii'i'(R�tarangetreshapeR�tgetrefcountR3R(	topR�RltbtcR8trctjtd((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt_assert_valid_refcount[sgH�����z>c
s|ddl����fd�}�j|��j|�}}d��f}t|||dt|�d|d|�dS(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)``.

    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����Ncs�j||d�d��S(Ntrtoltatol(tallclose(R$R�(R$R�R#(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR��ss'Not equal to tolerance rtol=%g, atol=%gRiRRj(R�t
asanyarrayR�R�(RzR{R#R$RiRR�Rj((R$R�R#s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRms(c	Cs�ddl}|j|�}|j|�}||j|j||k||��}|j|j||�|k�s�|j|�s�|j|�r�d|}n(|jt||��}d||f}t|��ndS(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����NsX and Y are not equal to %d ULPs+X and Y are not equal to %d ULP (max is %g)(	R�R�tspacingtwhereR�Rptmaxt	nulp_diffR(	R$R�tnulpR�taxtaytrefRtmax_nulp((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s2("
cCsJddl}t|||�}|j||k�sFtd|��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(RlRtmaxulpR�R�tret((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s$
cs.ddl�|r?�j|d|�}�j|d|�}n�j|�}�j|�}�j||�}�j|�s��j|�r�td��n�j|d|�}�j|d|�}|j|jks�td|j|jf��n�fd�}t|�}t|�}||||�S(sDFor 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 - %scs&�j||d|�}�j|�S(NR�(R�R�(trxtrytvdtR�(R�(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt_diff1s(R�R�tcommon_typeRpRFR�Rxtinteger_repr(R$R�R�ttR5R2R3((R�s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR*s$cCs\|j|�}|jdks?|||dk||dk<n|dkrX||}n|S(Nii(tviewR�(R$R4tcompR2((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt
_integer_repr9s!
cCsddl}|j|jkr:t||j|jd��S|j|jkrht||j|jd
��Std|j��dS(sQReturn the signed-magnitude interpretation of the binary representation of
    x.i����Niii?sUnsupported dtype %sI�i�ll����(R�R�tfloat32R;tint32R0tint64Rx(R$R�((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR7GstWarningMessagecBs,eZdZd	Zd
d
d�Zd�ZRS(s�
    Holds the result of a single showwarning() call.

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

    tmessagetcategoryR�tlinenoR�tlinec	CsSt�}x%|jD]}t||||�qW|rF|j|_n	d|_dS(N(tlocalst_WARNING_DETAILSRRt_category_nameRI(	tselfR@RAR�RBR�RCtlocal_valuestattr((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt__init__cs	cCs&d|j|j|j|j|jfS(NsD{message : %r, category : %r, filename : %r, lineno : %s, line : %r}(R@RFR�RBRC(RG((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt__str__ms(smessagescategorysfilenameslinenosfileslineN(Rt
__module__t__doc__RERIRJRK(((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR?Ts
	tWarningManagercBs/eZdZedd�Zd�Zd�ZRS(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.

    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.

    cCs>||_|dkr(tjd|_n	||_t|_dS(Ntwarnings(t_recordRIR�tmodulest_moduleRyt_entered(RGtrecordtmodule((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRJ�s
		cs�|jrtd|��nt|_|jj|_|j|j_|jj|_|jr�g��fd�}||j_�SdSdS(NsCannot enter %r twicecs�jt||��dS(N(R=R?(R5R�(tlog(s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pytshowwarning�s(
RStRuntimeErrorR�RRtfilterst_filtersRWt_showwarningRPRI(RGRW((RVs9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt	__enter__�s			cCs>|jstd|��n|j|j_|j|j_dS(Ns%Cannot exit %r without entering first(RSRXRZRRRYR[RW(RG((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt__exit__�s	N(RRLRMRyRIRJR\R](((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyRNrs	cOs�tdt�}|j�}tjd�zq|||�}t|�dksbtd|j��n|dj|k	r�td|j||df��nWd|j	�X|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.

    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`.

    RTtalwaysis!No warning raised when calling %ss(First warning for %s is not a %s( is %s)N(
RNR�R\ROtsimplefilterR4RRRAR](t
warning_classtfuncR5tkwtctxREtresult((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s
!cOs{tdt�}|j�}tjd�zA|||�}t|�dkrhtd|j|f��nWd|j�X|S(sK
    Fail if the given callable produces any warnings.

    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`.

    RTR^is Got warnings when calling %s: %sN(	RNR�R\ROR_R4RRR](RaR5RbRcRERd((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyR�s
(R`Ra(5RMR�R�R�R�R!ROt
nosetesterRt__all__RRR&R,R.RtplatformtgetpidRRR�tversionRIR\R�R	RR
RRR�RRRRRRRRR
RR"RRRR*R;R7RRR?RNRR(((s9/usr/lib64/python2.7/site-packages/numpy/testing/utils.pyt<module>s|					
				

	"o	(sbUB]E		B2		//	/>+3		
4	+