ó É9Zc @`s dZddlmZmZmZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddlmZmZddlmZddlmZmZmZmZmZdd lmZejdd kr dd lmZndd lmZd d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+g Zd)efd,„ƒYZ e Z!ydd-l"m#Z#WnJe$k rüyddl%Z%e%j#Z#Wqýe$e&fk rødZ#qýXnXdZ(d.d/„Z)d0„Z*d1„Z+d2„Z,ed3d4ƒd5„ƒZ-ej.d6krxdd7ddd8„Z/d9dd:„Z0n5ej1d; d<kr¤d=ej2ƒd>„Z0n d?„Z0ej1d; d<krÜd=ej2ƒgd@„Z3n gdA„Z3dBe4dpdEdF„Z5d.e4dG„Z6dH„Z7dId.e4dJ„Z8dId.e4dK„Z9d.e4d.dLdM„Z:d.e4dN„Z;dLd.e4dO„Z<d.e4dP„Z=dQ„Z>dR„Z?de4dS„Z@dT„ZAdU„ZBdaCddV„ZDddW„ZEdddX„ZFdY„ZGdZdeHd.e4d[„ZIdd\„ZJddd]„ZKdd^„ZLd_„ZMd`„ZNdaeOfdb„ƒYZPdceOfdd„ƒYZQe jRdde„ƒZSdf„ZTe jRddg„ƒZUdh„ZVedidjdk„ZWd&efdl„ƒYZXe jRdm„ƒZYe jRdn„ƒZZd'e j[fdo„ƒYZ\dS(qs* Utility function to facilitate testing. i(tdivisiontabsolute_importtprint_functionN(tpartial(tmkdtemptmkstempi(t import_nose(tfloat32temptytaranget array_reprtndarray(t deprecatei(tStringIOt 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_raises_regextassert_array_max_ulpt assert_warnstassert_no_warningstassert_allclosetIgnoreExceptiontclear_and_catch_warningstSkipTesttKnownFailureExceptionttemppathttempdircB`seZdZRS(s<Raise this exception to mark a test as a known failing test.(t__name__t __module__t__doc__(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR+%s(R*tcC`s@|s<y |ƒ}Wntk r,|}nXt|ƒ‚ndS(sI Assert that works in release mode. Accepts callable msg to allow deferring evaluation until failure. 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 TypeErrortAssertionError(tvaltmsgtsmsg((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR!=s    cC`sDddlm}||ƒ}t|ttƒƒr@tdƒ‚n|S(slike 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.coreR7t isinstancettypetNotImplementedR2(txR7tst((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytgisnanOs  cC`s`ddlm}m}|ddƒ5||ƒ}t|ttƒƒrVtdƒ‚nWdQX|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(tisfiniteterrstatetinvalidtignores$isfinite not supported for this typeN(R8R?R@R9R:R;R2(R<R?R@R=((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt gisfinite`s  cC`s`ddlm}m}|ddƒ5||ƒ}t|ttƒƒrVtdƒ‚nWdQX|S(slike 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@RARBs!isinf not supported for this typeN(R8RDR@R9R:R;R2(R<RDR@R=((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytgisinfrs  tmessagesNnumpy.testing.rand is deprecated in numpy 1.11. Use numpy.random.rand instead.cG`skddl}ddlm}m}|||ƒ}|j}x*tt|ƒƒD]}|jƒ||>> np.testing.assert_equal([4,5], [4,6]) ... : Items are not equal: item=1 ACTUAL: 5 DESIRED: 6 s key=%r %sNs item=%r %si(R tisscalartsignbit(t iscomplexobjtrealtimagR(tTrueR9tdictR3R|R:RRLtitemstlistttupleRKR8R R†R‡t numpy.libRˆR‰RŠRRt ValueErrortFalseRCR>R2Rs(tactualtdesiredRRt__tracebackhide__tkRPR R†R‡RˆR‰RŠR5t usecomplextactualrtactualitdesiredrtdesireditisdesnantisactnan((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR sv# )*)              cC`s‡t}ddl}||ksƒtƒ}|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] iNs failed ACTUAL: s DESIRED: (R‹tpprintR twriteR3tgetvalue(t test_stringR“R”R•RžR5((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRs      ic`sTt}ddlm}ddlm}m}m} y|ˆƒpJ|ˆƒ} Wntk rgt} nX‡‡‡‡‡fd†} | r?|ˆƒr°|ˆƒ} | ˆƒ} n ˆ} d} |ˆƒrã|ˆƒ}| ˆƒ}n ˆ}d}y*t | |dˆƒt | |dˆƒWq?t k r;t | ƒƒ‚q?Xnt ˆ|t t fƒsot ˆ|t t fƒr‚tˆˆˆˆƒSyƒtˆƒoštˆƒstˆƒsµtˆƒrâtˆƒoÊtˆƒst | ƒƒ‚qnˆˆkst | ƒƒ‚ndSWnttfk rnXttˆˆƒˆƒdkrPt | ƒƒ‚ndS(sú Raises an AssertionError 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) ... : 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) ... : Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333333]) y: array([ 1. , 2.33333334]) i(R (RˆR‰RŠc`s)dˆ}tˆˆgˆdˆd|ƒS(Ns*Arrays are not almost equal to %d decimalsRR‚(R(R‚(R“tdecimalR”RR(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_build_err_msgñs R¢N(R‹R8R RRˆR‰RŠR‘R’RR3R9RRŽRRCR>RsR2troundtabs(R“R”R¢RRR•R RˆR‰RŠR—R£R˜R™RšR›((R“R¢R”RRsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR§sN>        c C`sãt}ddl}tt||fƒ\}}||kr=dS|jddƒId|j|ƒ|j|ƒ}|jd|j|j|ƒƒƒ}WdQXy||}Wnt k rÁd}nXy||} Wnt k réd} nXt ||g|dd |d |ƒ} y}t |ƒo't |ƒs‹t |ƒsBt |ƒrlt |ƒoWt |ƒs‡t | ƒ‚q‡n||ks‡t | ƒ‚ndSWnttfk r¥nX|j|| ƒ|jd |d  ƒkrßt | ƒ‚ndS( sU Raises an AssertionError 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) ... : 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 iNRARBgà?i gR‚s-Items are not equal to %d significant digits:Rg$@i(R‹tnumpytmaptfloatR@R¥tpowertfloortlog10tZeroDivisionErrorRRCR>R3R2Rs( R“R”t significantRRR•tnptscalet sc_desiredt sc_actualR5((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRs@9   *      *ic `s´t}ddlm}m} m} m} m} m} |ˆdtdtƒ‰|ˆdtdtƒ‰‡fd†}d„}d‡‡‡‡‡‡fd†}yžˆj dkp͈j dkp͈j ˆj k}|s/t ˆˆgˆd ˆj ˆj fd ˆd ˆd ddˆƒ}|s/t |ƒ‚q/n|ˆƒro|ˆƒro| ˆƒ| ˆƒ}}| ˆƒ| ˆƒ}}| |ƒs‘| |ƒr§|||ddƒn| |ƒs¿| |ƒr|ˆ| kˆ| kddƒ|ˆ| kˆ| kddƒn||}}||O}||O}| |ƒr5dS| |ƒr]|ˆ|ˆ|ƒ}q~|ˆˆƒ}n|ˆˆƒ}t |t ƒrŸ|}dg}n$|jƒ}|jƒ}|jƒ}|s:dd|jdƒt|ƒ}t ˆˆgˆd|fd ˆd ˆd ddˆƒ}|s:t |ƒ‚q:nWnrtk r¯ddl}|jƒ}d|ˆf‰t ˆˆgˆd ˆd ˆd ddˆƒ}t|ƒ‚nXdS(Ni(tarrayR7RDtanytalltinftcopytsubokc`s7tjƒ%tjddtƒˆ||ŽSWdQXdS(NRBtcategory(twarningstcatch_warningstfilterwarningstDeprecationWarning(RMtkwargs(t comparison(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytsafe_comparison†s cS`s|jjdkS(Ns?bhilqpBHILQPefdgFDG(tdtypetchar(R<((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytisnumberstnanc `sjyt||ƒWnRtk retˆˆgˆd|dˆdˆdd dˆƒ}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:RR‚RƒR<tyRyN(R<RÄ(RR3R(tx_idty_idthasvalR5(RR‚RyRR<RÄ(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytchk_same_position s  s (shapes %s, %s mismatch)RR‚RƒR<RÄRyRÇs+infs-infidgY@is (mismatch %s%%)serror during assertion: %s %s(((R<RÄ(R<RÄ(R<RÄ(R‹R8R²R7RDR³R´RµR’tshapeRR3R9tbooltravelttolistR}RLR‘t tracebackt format_exc(R¾R<RÄRRR‚RyR•R²R7RDR³R´RµR¿RÂRÈtcondR5tx_isnanty_isnantx_isinfty_isinfRÅRÆR4treducedtmatchRÍtefmt((R¾RR‚RyRR<RÄsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytassert_array_comparesr. ! 0   !$         !     c C`s)ttj||d|d|ddƒdS(s, Raises an AssertionError 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]) ... : AssertionError: Arrays are not equal (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) RRR‚sArrays are not equalN(R×toperatort__eq__(R<RÄRR((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRís?c `s¢t}ddlm‰m‰m‰m‰m‰ddlm‰ddl m ‰‡‡‡‡‡‡‡‡fd†}t |||d|d|dd ˆd ˆƒd S( s‹ Raises an AssertionError 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) ... : AssertionError: Arrays are not almost equal (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) : ValueError: Arrays are not almost equal x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33333, 5. ]) i(taroundtnumbertfloat_t result_typeR²(t issubdtype(R³c`s(y•ˆt|ƒƒs'ˆt|ƒƒr”t|ƒ}t|ƒ}||ksOtS|j|jkoldknr{||kS||}||}nWnttfk r®nXˆ|dƒ}ˆ|d|dtdtƒ}t||ƒ}ˆ|jˆƒs|jˆƒ}nˆ|ˆƒdˆ kS(Nigð?RÀR¶R·g$@( RER’tsizeR2RsR‹R¥RÀtastype(R<RÄtxinfidtyinfidRÀtz(RÚR²R¢RÜRÞtnpanyRÛRÝ(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytcomparezs$$   "  RRR‚s*Arrays are not almost equal to %d decimalsRyN( R‹R8RÚRÛRÜRÝR²tnumpy.core.numerictypesRÞtnumpy.core.fromnumericR³R×(R<RÄR¢RRR•Rå((RÚR²R¢RÜRÞRäRÛRÝsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR/sF($ c C`s/t}ttj||d|d|ddƒdS(sF Raises an AssertionError 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]) ... : 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) ... : 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]) ... : Arrays are not less-ordered (shapes (3,), (1,) mismatch) x: array([ 1., 2., 3.]) y: array([4]) RRR‚sArrays are not less-orderedN(R‹R×RØt__lt__(R<RÄRRR•((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR™sBcB`s ||UdS(N((tastrRŒ((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRàsc C`sMt}ddl}t|tƒs<ttt|ƒƒƒ‚nt|tƒsfttt|ƒƒƒ‚ntjd|d|tj ƒrŠdSt |j ƒj |j dƒ|j dƒƒƒ}g}xH|r |jdƒ}|jdƒríqÃn|jdƒrõ|g}|jdƒ}|jdƒrB|j|ƒ|jdƒ}n|jd ƒsftt|ƒƒ‚n|j|ƒ|rº|jdƒ} | jdƒr§|j| ƒqº|jd| ƒntjd|d d|d ƒrâqÃn|j|ƒqÃntt|ƒƒ‚qÃW|sdSd d j|ƒjƒ} ||krIt| ƒ‚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 "", line 1, in ... AssertionError: Differences in strings: - abc+ abcd? + iNs\As\Zis s- s? s+ isDifferences in strings: %sR1(R‹tdifflibR9tstrR3R|R:treRÕtMRŽtDifferRåRtpopt startswithRutinserttextendR~trstrip( R“R”R•Rêtdifft diff_listtd1Rrtd2td3R5((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRãsL  0    "  c `sddlm}ddl}|dkrGtjdƒ}|jd}ntjj tjj |ƒƒd}|||ƒ}|j ƒj |ƒ}|j dtƒ}g‰|r½‡fd†} nd} x!|D]} |j| d| ƒqÊW|jdkr|rtd 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(tnpy_load_moduleNit__file__Rc`s ˆj|ƒS(N(Ru(ts(R5(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytLstoutsSome doctests failed: %ss (t numpy.compatRùtdoctestRStsyst _getframet f_globalstosRbtsplitexttbasenamet DocTestFinderRzt DocTestRunnerR’truntfailuresR3R~( tfilenametraise_on_errorRùRÿROtnametmtteststrunnerRýttest((R5sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR)s"  " cO`stƒ}|jj||ŽS(N(RttoolsR(RMR½tnose((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRWs cO`s"t}tƒ}|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. Alternatively, `assert_raises` can be used as a context manager: >>> from numpy.testing import assert_raises >>> with assert_raises(ZeroDivisionError): ... 1 / 0 is equivalent to >>> def div(x, y): ... return x / y >>> assert_raises(ZeroDivisionError, div, 1, 0) (R‹RRR(RMR½R•R((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR\s c`s§t}tƒ}tdkr‘y|jjaWq‘tk ry|jjaWqŽtk r‰dtfd„ƒY‰‡fd†}|aqŽXq‘Xnt|||||ŽS(s5 Fail unless an exception of class exception_class and with message that matches expected_regexp is thrown by callable when invoked with arguments args and keyword arguments kwargs. Name of this function adheres to Python 3.2+ reference, but should work in all versions down to 2.6. t_AssertRaisesContextcB`s5eZdZdd„Zd„Zd„Zd„ZRS(sCA context manager used to implement TestCase.assertRaises* methods.cS`s||_||_dS(N(texpectedtexpected_regexp(tselfRR((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt__init__šs cS`s t|ƒS(N(R3(RR5((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytfailureExceptionžscS`s|S(N((R((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt __enter__¡scS`sô|dkrZy|jj}Wn tk r>t|jƒ}nX|jdj|ƒƒ‚nt||jƒsptS||_ |j dkrŒt S|j }t |t ƒr¶tj|ƒ}n|jt|ƒƒsð|jd|jt|ƒfƒ‚nt S(Ns{0} not raiseds"%s" does not match "%s"(RSRR.tAttributeErrorRëRR`t issubclassR’t exceptionRR‹R9t basestringRìtcompiletsearchtpattern(Rtexc_typet exc_valuettbtexc_nameR((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt__exit__¤s(    N(R.R/R0RSRRRR%(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR—s    c`s=ˆ||ƒ}|dkr|S||||ŽWdQXdS(N(RS(tclstregext callable_objR„tkwtmgr(R(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytimpl¼s  N( R‹Rtassert_raises_regex_implRSRR#Rtassert_raises_regexpR\(texception_classRR(RMR½R•RR+((RsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR#|s     % c C`s|dkr%tjdtjƒ}ntj|ƒ}|j}ddlm}g|jƒD]}||ƒrZ|^qZ}x…|D]}}y(t |dƒr£|j }n |j }Wnt k rÃqnX|j |ƒr|jdƒ rt||||ƒƒqqWdS(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(RSRìRRtsept__dict__tinspectR/tvaluesthasattrR0R.RRRðtsetattr( R&t decoratort testmatchtcls_attrR/t_mtmethodstfunctiontfuncname((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRÈs   +    c B`sƒejdƒ}|j|j}}e|d|dƒ}d}eƒ}x$||krm|d7}|||UqJWeƒ|}d|S(sE 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„?(RRtf_localsRRR( tcode_strttimestlabeltframetlocstglobstcodeRPtelapsed((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR ÷s!    cC`sˆddl}|jdƒjddƒ}|}d}tj|ƒ}x#tdƒD]}|||ƒ}qOWttj|ƒ|kƒ~dS(sg Check that ufuncs don't mishandle refcount of object `1`. Used in a few regression tests. iNidiii'(R¦R treshapeRt getrefcountRKR!(topR®tbtcRPtrctjtd((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_assert_valid_refcount's gH¯¼šò×z>c `s…t}ddl‰‡‡‡‡fd†}ˆj|ƒˆj|ƒ}}dˆˆf} t|||dt|ƒd|d| ƒdS(sq Raises an AssertionError 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. equal_nan : bool, optional. If True, NaNs will compare equal. 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) iNc `s(ˆjjj||dˆdˆdˆƒS(Ntrtoltatolt equal_nan(tcoretnumerictisclose(R<RÄ(RSRTR®RR(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRåis!s'Not equal to tolerance rtol=%g, atol=%gRRR‚(R‹R¦t asanyarrayR×Rë( R“R”RRRSRTRRR•RåR‚((RSRTR®RRsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR'9s- c C`sàt}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(maximum(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) iNsX and Y are not equal to %d ULPs+X and Y are not equal to %d ULP (max is %g)( R‹R¦R¥tspacingtwhereR´Rˆtmaxt nulp_diffR3( R<RÄtnulpR•R®taxtaytrefR5tmax_nulp((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR"rs1 (" cC`sPt}ddl}t|||ƒ}|j||kƒsLtd|ƒ‚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))) iNs(Arrays are not almost equal up to %g ULP(R‹R¦R\R´R3(R„RLtmaxulpRÀR•R®tret((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR$°s$  c`s.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(s¨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 dtype : dtype, optional Data-type to convert `x` and `y` to if given. Default is None. 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 iNRÀ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¥(trxtrytvdtRô(R®(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_diff s(R¦R²t common_typeRˆRsRÉR‘t integer_repr(R<RÄRÀttRgRdRe((R®sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR\Üs$   cC`s\|j|ƒ}|jdks?|||dk||dk||_|dkr(tjd|_n ||_t|_dS(NR¹(t_recordRSRtmodulest_moduleR’t_entered(Rtrecordtmodule((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRes    c`s‰|jrtd|ƒ‚nt|_|jj|_|j|j_|jj|_|jrg‰‡fd†}||j_ˆSdSdS(NsCannot enter %r twicec`sˆjt||ŽƒdS(N(RuRp(RMR½(tlog(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt showwarningws( R~t RuntimeErrorR‹R}tfilterst_filtersR‚t _showwarningR{RS(RR‚((RsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRms    cC`s>|jstd|ƒ‚n|j|j_|j|j_dS(Ns%Cannot exit %r without entering first(R~RƒR…R}R„R†R‚(R((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR%~s N(R.R/R0R’RSRRR%(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRzLs c c`sÇt}tjdtƒ©}tjdƒdVt|ƒdksn|dk rUd|nd}td|ƒ‚n|dj|k r½|dk r—d|nd}td|||dfƒ‚nWdQXdS( NRtalwaysis when calling %sR1sNo warning raiseds%s s#First warning %sis not a %s (is %s)(R‹R¹Rºt simplefilterRLRSR3R¸(t warning_classR R•Rrtname_str((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_assert_warns_context…s cO`sQ|st|ƒS|d}|d}t|d|jƒ|||ŽSWdQXdS(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. If called with all arguments other than the warning class omitted, may be used as a context manager: with assert_warns(SomeWarning): do_something() The ability to be used as a context manager is new in NumPy v1.11.0. .. 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`. iiR N(R‹R.(R‰RMR½tfunc((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR%”s #   cc`s~t}tjdtƒ`}tjdƒdVt|ƒdkrt|dk rUd|nd}td||fƒ‚nWdQXdS(NRR‡is when calling %sR1sGot warnings%s: %s(R‹R¹RºRˆRLRSR3(R R•RrRŠ((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_assert_no_warnings_contextÀs cO`sK|s tƒS|d}|d}td|jƒ|||ŽSWdQXdS(s: Fail if the given callable produces any warnings. If called with all arguments omitted, may be used as a context manager: with assert_no_warnings(): do_something() The ability to be used as a context manager is new in NumPy v1.11.0. .. 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`. iiR N(RR.(RMR½RŒ((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR&Ës   tbinaryic #`sd}d}x tdƒD]ý‰xôtˆdtˆd|ƒƒD]Ò‰|dkr¤‡‡‡fd†}tˆfdˆƒˆ}||ƒ|ˆˆˆˆdffV|ƒ|ƒ|ˆˆˆˆd ffV|d |ƒd |ˆd ˆˆd ˆdffV|d |ƒd |ˆˆd ˆd ˆdffV|ƒd |ƒd |ˆˆd ˆd ˆd ffV|ƒd |ƒd |ˆd ˆˆd ˆd ffVn|d kr@‡‡‡fd†}‡‡‡fd†}tˆfdˆƒˆ}||ƒ|ƒ|ˆˆˆˆˆdffV|ƒ|ƒ|ƒ|ˆˆˆˆˆdffV|ƒ|ƒ|ƒ|ˆˆˆˆˆdffV|d |ƒd |ƒd |ˆd ˆˆˆd ˆdffV|d |ƒd |ƒd |ˆˆd ˆˆd ˆdffV|d |ƒd |ƒd |ˆˆˆd ˆd ˆdffV|ƒd |ƒd |ƒd |ˆd ˆˆˆd ˆd ffV|ƒd |ƒd |ƒd |ˆˆd ˆˆd ˆd ffV|ƒd |ƒd |ƒd |ˆˆˆd ˆd ˆd ffVq@q@WqWdS(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, %ss1binary offset=(%d, %d, %d), size=%d, dtype=%r, %siitunaryc`stˆdˆƒˆS(NRÀ(R ((RÀtoRû(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRü sRÀs out of placesin placeiiÿÿÿÿtaliasedRŽc`stˆdˆƒˆS(NRÀ(R ((RÀRRû(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRüsc`stˆdˆƒˆS(NRÀ(R ((RÀRRû(sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRüss in place1s in place2N(RKR[R( RÀR:tmax_sizetufmttbfmttinpRýtinp1tinp2((RÀRRûsF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyt_gen_alignment_dataïsN' $'   # ###!#!#!cB`seZdZRS(s/Ignoring this exception due to disabled feature(R.R/R0(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR(1sco`s-t||Ž}z |VWdtj|ƒXdS(sContext manager to provide a temporary test folder. All arguments are passed as this to the underlying tempfile.mkdtemp function. N(Rtshutiltrmtree(RMR½ttmpdir((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR-5s co`s@t||Ž\}}tj|ƒz |VWdtj|ƒXdS(séContext manager for temporary files. Context manager that returns the path to a closed temporary file. Its parameters are the same as for tempfile.mkstemp and are passed directly to that function. The underlying file is removed when the context is exited, so it should be closed at that time. Windows does not allow a temporary file to be opened if it is already open, so the underlying file must be closed after opening before it can be opened again. N(RRRotremove(RMR½tfdRb((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR,Cs   cB`s5eZdZdZedd„Zd„Zd„ZRS(s] Context manager that resets warning registry for catching warnings Warnings can be slippery, because, whenever a warning is triggered, Python adds a ``__warningregistry__`` member to the *calling* module. This makes it impossible to retrigger the warning in this module, whatever you put in the warnings filters. This context manager accepts a sequence of `modules` as a keyword argument to its constructor and: * stores and removes any ``__warningregistry__`` entries in given `modules` on entry; * resets ``__warningregistry__`` to its previous state on exit. This makes it possible to trigger any warning afresh inside the context manager without disturbing the state of warnings outside. For compatibility with Python 3.0, please consider all arguments to be keyword-only. Parameters ---------- record : bool, optional 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()``. modules : sequence, optional Sequence of modules for which to reset warnings registry on entry and restore on exit Examples -------- >>> import warnings >>> with clear_and_catch_warnings(modules=[np.core.fromnumeric]): ... warnings.simplefilter('always') ... # do something that raises a warning in np.core.fromnumeric cC`sAt|ƒj|jƒ|_i|_tt|ƒjd|ƒdS(NR(tsettuniont class_modulesR|t_warnreg_copiestsuperR)R(RRR|((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyRs cC`s_xI|jD]>}t|dƒr |j}|jƒ|j|<|jƒq q Wtt|ƒjƒS(Nt__warningregistry__( R|R6R£R¶R¡tclearR¢R)R(Rtmodtmod_reg((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR†s  cG`svtt|ƒj|ŒxY|jD]N}t|dƒrE|jjƒn||jkr |jj|j|ƒq q WdS(NR£( R¢R)R%R|R6R£R¤R¡tupdate(Rtexc_infoR¥((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR%Žs (((R.R/R0R R’RRR%(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pyR)Ys % (RwRx(]R0t __future__RRRRRRìRØR¹t functoolsRR™t contextlibttempfileRRt nosetesterRR8RRR R R tnumpy.lib.utilsR t version_infotioR t__all__t ExceptionR+tKnownFailureTestt unittest.caseR*t ImportErrorRRRSRR!R>RCRERR ReRtplatformtgetpidRR‹RRRRRR×RRRRRRRRR,R#RR RQR’R'R"R$R\RmRiR\RpRztcontextmanagerR‹R%RR&R˜R(R-R,RºR)(((sF/opt/alt/python27/lib64/python2.7/site-packages/numpy/testing/utils.pytsº       (                 r (wamBjG  F.   K /0  8 >, 5   9 , $B