o cݱ@sdZddlZddlZddlZddlZddlZddlZddlZddlZ ddl m Z m Z m Z mZmZmZddlmZzddlZdZWn eyKdZYnwGdddZGd d d eZGd d d ZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddZGdddeZ GdddeZ!Gdd d eZ"Gd!d"d"eZ#Gd#d$d$eZ$Gd%d&d&eZ%Gd'd(d(eZ&Gd)d*d*eZ'Gd+d,d,eZ(Gd-d.d.eZ)Gd/d0d0eZ*Gd1d2d2eZ+Gd3d4d4eZ,Gd5d6d6eZ-Gd7d8d8eZ.Gd9d:d:eZ/d;d<Z0Gd=d>d>eZ1Gd?d@d@eZ2GdAdBdBeZ3GdCdDdDeZ4GdEdFdFeZ5GdGdHdHeZ6GdIdJdJeZ7GdKdLdLeZ8GdMdNdNeZ9GdOdPdPeZ:GdQdRdReZ;GdSdTdTeZe?dWddl@Z@Wdn 1swYWn eydZAYnwdZAejBjCeA dXdYGdZd[d[eZDGd\d]d]eZEGd^d_d_eZFGd`dadaeZGGdbdcdceZHGdddedeeZIGdfdgdgeZJdS)hz Tests related to deprecation warnings. Also a convenient place to document how deprecations should eventually be turned into errors. N) assert_raises assert_warnsassert_assert_array_equalSkipTestKnownFailureExceptionfromstring_null_term_c_apiTFc@sJeZdZdZeZddZddZdddej difd d Z difd d Z d S)_DeprecationTestCasecCsBtjdd|_|j|_tjd|jdtjd|j|jddS)NTrecordalways)categorymessager)warningscatch_warningswarn_ctx __enter__logfilterwarnings warning_clsrselfrD/usr/lib/python3/dist-packages/numpy/core/tests/test_deprecations.pysetup"s    z_DeprecationTestCase.setupcCs|jdSN)r__exit__rrrrteardown0sz_DeprecationTestCase.teardownFrc Csvd}g|jdd<|tjur|jf}z ||i|Wn|r!tnty)Ynwd} |jD]} | j|jur<| d7} q/|sItd|jj| jfq/|durm| |krmdt |j|f} dd|jD} td | g| t @t j d |j|jd z||i||tkrtd Wn|y|tkrtd Yn wWddSWddS1swYdS)aTest if DeprecationWarnings are given and raised. This first checks if the function when called gives `num` DeprecationWarnings, after that it tries to raise these DeprecationWarnings and compares them with `exceptions`. The exceptions can be different for cases where this code path is simply not anticipated and the exception is replaced. Parameters ---------- function : callable The function to test num : int Number of DeprecationWarnings to expect. This should normally be 1. ignore_others : bool Whether warnings of the wrong type should be ignored (note that the message is not checked) function_fails : bool If the function would normally fail, setting this will check for warnings inside a try/except block. exceptions : Exception or tuple of Exceptions Exception to expect when turning the warnings into an error. The default checks for DeprecationWarnings. If exceptions is empty the function is expected to run successfully. args : tuple Arguments for `function` kwargs : dict Keyword arguments for `function` TNrr!zexpected %s but got: %sz"%i warnings found but %i expected.cSsg|]}t|qSr)str).0wrrr lz:_DeprecationTestCase.assert_deprecated.. errorrz$No error raised during function callz!Error raised during function call)rnp_NoValuer ExceptiontuplerAssertionError__name__lenjoinrrrr) rfunctionnum ignore_othersfunction_fails exceptionsargskwargs__tracebackhide__ num_foundwarningmsglstrrrassert_deprecated3s\!           "z&_DeprecationTestCase.assert_deprecatedcCs|j|ddt||ddS)zTest that warnings are not raised. This is just a shorthand for: self.assert_deprecated(function, num=0, ignore_others=True, exceptions=tuple(), args=args, kwargs=kwargs) rT)r2r3r5r6r7N)r=r,)rr1r6r7rrrassert_not_deprecated|s  z*_DeprecationTestCase.assert_not_deprecatedN) r. __module__ __qualname__rDeprecationWarningrrr r)r*r=r>rrrrr s Ir c@seZdZejZdS)_VisibleDeprecationTestCaseN)r.r?r@r)VisibleDeprecationWarningrrrrrrBs rBc@eZdZddZdS)TestNonTupleNDIndexDeprecationcCstd}tGtdtt|jddgddggtt|jtdgtdt t|jddgddggt t|jtdg|ddgWddS1sSwYdS)N)rFrrr!r() r)zerosrrrr FutureWarning __getitem__slicerrarrr test_basics    "z)TestNonTupleNDIndexDeprecation.test_basicN)r.r?r@rMrrrrrE rEc@s4eZdZdZdZddZddZddZd d Zd S) TestComparisonDeprecationsaPThis tests the deprecation, for non-element-wise comparison logic. This used to mean that when an error occurred during element-wise comparison (i.e. broadcasting) NotImplemented was returned, but also in the comparison itself, False was given instead of the error. Also test FutureWarning for the None comparison. z#elementwise.* comparison failed; .*cCstjtjfD]I}|j|tdgfdtjddd}|j|||ddfddtjdtgdgtd}tjdtgdgtd}|j|||fddqdS) Nr6zi,idtyper6r2r!r!rP)operatoreqner=r)rGarrayobject)roprLbrrrtest_normal_typessz,TestComparisonDeprecations.test_normal_typescsDtddgtgd}ttdd|ttfdddS)NrLr^)rLr^ccSs||kSrr)xyrrrz8TestComparisonDeprecations.test_string..csgkSrrrrLrrrcrd)r)r[r ValueErrorrrH)rr^rrer test_stringsz&TestComparisonDeprecations.test_stringcsGddd|fdd|fddtjdddtjdd dttfd dttfd dttfd dttfd ddS)Nc@seZdZddZddZdS)zNTestComparisonDeprecations.test_void_dtype_equality_failures..NotArraycSstr) TypeErrorrrrr __array__zXTestComparisonDeprecations.test_void_dtype_equality_failures..NotArray.__array__cSstSr)NotImplemented)rotherrrr__ne__rjzUTestComparisonDeprecations.test_void_dtype_equality_failures..NotArray.__ne__N)r.r?r@rirmrrrrNotArrays rncstdkSNrWr)arangerrnrrrczNTestComparisonDeprecations.test_void_dtype_equality_failures..cstdkSrorprrrrrrcrsrWi4,i4rRzi4,i4,i4cdkSNr!rrstruct1rrrcrdcskSrrrrxstruct2rrrcrdcsdkSrvrrrwrrrcrdcskSrrrryrrrcrd)r=r)rGrrHrr)rnrxrzr!test_void_dtype_equality_failuressz.cSstddkSr|rprrrrrcr}r(rrLrWrtrRr)rrHrrrrr)r[int16asarrayrGrXltlegtgerrh)rarg1structarg2flrrr'test_array_richcompare_legacy_weirdnesss,      zBTestComparisonDeprecations.test_array_richcompare_legacy_weirdnessN) r.r?r@__doc__rr_rgr{rrrrrrOs  rOc@s2eZdZdZddZejje ddddZ dS) TestDatetime64Timezonea{Parsing of datetime64 with timezones deprecated in 1.11.0, because datetime64 is now timezone naive rather than UTC only. It will be quite a while before we can remove this, because, at the very least, a lot of existing code uses the 'Z' modifier to avoid conversion from local time to UTC, even if otherwise it handles time in a timezone naive fashion. cCs$|jtjdd|jtjdddS)N)z2000-01-01T00+01rQ)z2000-01-01T00Z)r=r) datetime64rrrrrgsz"TestDatetime64Timezone.test_stringz!The pytz module is not available.reasoncCs6td}tjddddd|d}|jtj|fddS)Nz US/Easternir!r)tzinforQ)pytztimezonedatetimer=r)r)rtzdtrrr test_datetimes z$TestDatetime64Timezone.test_datetimeN) r.r?r@rrgpytestmarkskipif _has_pytzrrrrrrs rc@eZdZdZddZdS)!TestNonCContiguousViewDeprecationaIView of non-C-contiguous arrays deprecated in 1.11.0. The deprecation will not be raised for arrays that are both C and F contiguous, as C contiguous is dominant. There are more such arrays with relaxed stride checking than without so the deprecation is not as visible with relaxed stride checking in force. cCs:|jtdjjtfd|jtdjjtjfddS)N)rWrWrQ)r=r)onesTviewcomplexint8rrrrtest_fortran_contiguous s z9TestNonCContiguousViewDeprecation.test_fortran_contiguousN)r.r?r@rrrrrrrs rc@r)+TestArrayDataAttributeAssignmentDeprecationaSAssigning the 'data' attribute of an ndarray is unsafe as pointed out in gh-7093. Eventually, such assignment should NOT be allowed, but in the interests of maintaining backwards compatibility, only a Deprecation- Warning will be raised instead for the time being to give developers time to refactor relevant code. cCs8td}tddd}d|_|j|jd|jfddS)N rr!zcAssigning the 'data' attribute is an inherently unsafe operation and will be removed in the future.datarQ)r)rqlinspacerr= __setattr__r)rrLr^rrrtest_data_attr_assignments zETestArrayDataAttributeAssignmentDeprecation.test_data_attr_assignmentN)r.r?r@rrrrrrrs rc@ eZdZdZddZddZdS)9TestBinaryReprInsufficientWidthParameterForRepresentationa If a 'width' parameter is passed into ``binary_repr`` that is insufficient to represent the number in base 2 (positive) or 2's complement (negative) form, the function used to silently ignore the parameter and return a representation using the minimal number of bits needed for the form in question. Such behavior is now considered unsafe from a user perspective and will raise an error in the future. cC(d}ddi}d|_|jtj||ddS)N)rwidthrWQInsufficient bit width provided. This behavior will raise an error in the future.r6r7rr=r) binary_reprrr6r7rrr test_insufficient_width_positive,zZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_positivecCr)N)rrWrrrrrrr test_insufficient_width_negative4rzZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_negativeN)r.r?r@rrrrrrrr#s rc@r)$TestDTypeAttributeIsDTypeDeprecationz.*`.dtype` attributecslGdddGdddtj|fdd|fdd|fdd|fd ddS) Nc@eZdZdZdS)zZTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype..dtf8Nr.r?r@rSrrrrrBrc@r)z[TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype..vdtzf,fNrrrrrvdtErrc tSrr)rSrrrrrcH z`TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype..cs tSrrrrrrrcI crrrrrrrrcJrcstdSrvrrrrrrcKr})r)voidr=rr)rrr)test_deprecation_dtype_attribute_is_dtypeAs zNTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtypeN)r.r?r@rrrrrrr= rc@rD)TestTestDeprecatedcCs>t}|tt|jdddd}|||dS)NcSdSrrrrrrrcTz;TestTestDeprecated.test_assert_deprecated..cSstjdtdddS)NfoorW)r stacklevelrwarnrArrrrrVz6TestTestDeprecated.test_assert_deprecated..foo)r rrr-r=r )rtest_case_instancerrrrtest_assert_deprecatedOs  z)TestTestDeprecated.test_assert_deprecatedN)r.r?r@rrrrrrNrNrc@r)TestNonNumericConjugatez Deprecate no-op behavior of ndarray.conjugate on non-numeric dtypes, which conflicts with the error behavior of np.conjugate. cCshtdtdfD]}||jq tdtddtddtfdtfgfD]}||jq)dS) NrFy@s2016M)r!rWrLr^)r)r[r> conjugateintr=rKrrrtest_conjugatebsz&TestNonNumericConjugate.test_conjugateN)r.r?r@rrrrrrr] rc@rD) TestNPY_CHARcCs(ddlm}||t|dkdS)Nr)npy_char_deprecationS1)numpy.core._multiarray_testsrr=r)rrrrrtest_npy_char_deprecationls  z&TestNPY_CHAR.test_npy_char_deprecationN)r.r?r@rrrrrrj rc@rD)TestPyArray_AS1DcCddlm}tt|dS)Nr)npy_pyarrayas1d_deprecation)rrrNotImplementedError)rrrrr test_npy_pyarrayas1d_deprecations z1TestPyArray_AS1D.test_npy_pyarrayas1d_deprecationN)r.r?r@rrrrrrrrNrc@rD)TestPyArray_AS2DcCr)Nr)npy_pyarrayas2d_deprecation)rrrr)rrrrr test_npy_pyarrayas2d_deprecationyrz1TestPyArray_AS2D.test_npy_pyarrayas2d_deprecationN)r.r?r@rrrrrrxrNrc@r)Test_UPDATEIFCOPYzh v1.14 deprecates creating an array with the UPDATEIFCOPY flag, use WRITEBACKIFCOPY instead cCs8ddlm}tddd}|j}|j||fddS)Nr)npy_updateifcopy_deprecation rPrQ)rrr)rqreshaperr=)rrarrvrrr!test_npy_updateifcopy_deprecations z3Test_UPDATEIFCOPY.test_npy_updateifcopy_deprecationN)r.r?r@rrrrrrr~rrc@rD)TestDatetimeEventcCsjtjtjfD],}|j|dd|j|dd|j|dd|j|dd|j|dd|j|ddqdS)N)r!)msrWrQ)r!)rrWr!N)r!)rrWevent)r!)rrW?)r!)rrWr!r)r!)rrWr!r)r)r timedelta64r>r=)rclsrrr test_3_tupleszTestDatetimeEvent.test_3_tupleN)r.r?r@rrrrrrrrc@r)TestTruthTestingEmptyArraysz..*truth value of an empty array is ambiguous.*cCs|jttgfddSNrQ)r=boolr)r[rrrrtest_1dsz#TestTruthTestingEmptyArrays.test_1dcCsF|jttdfd|jttdfd|jttdfddS)N)r!rrQ)rr!rr)r=rr)rGrrrrtest_2dsz#TestTruthTestingEmptyArrays.test_2dN)r.r?r@rrrrrrrrs rc@rD) TestBincountcC|dddS)NcSstjgdddS)NrV) minlength)r)bincountrrrrrcz6TestBincount.test_bincount_minlength..r=rrrrtest_bincount_minlengthz$TestBincount.test_bincount_minlengthN)r.r?r@rrrrrrrrc@rD)TestAlencCr)NcSsttgdS)NrV)r)alenr[rrrrrcr&z$TestAlen.test_alen..rrrrr test_alenrzTestAlen.test_alenN)r.r?r@rrrrrrrrc@rD)TestGeneratorSumcCs$|jtjddtdDfddS)Ncss|]}|VqdSrr)r#irrr sz6TestGeneratorSum.test_generator_sum..rFrQ)r=r)sumrangerrrrtest_generator_sums$z#TestGeneratorSum.test_generator_sumN)r.r?r@r rrrrrrrc@rD)TestPositiveOnNonNumericalcCs|jtjtdfddS)NrrQ)r=rXposr)r[rrrrtest_positive_on_non_numbersz6TestPositiveOnNonNumerical.test_positive_on_non_numberN)r.r?r@r rrrrr rr c@rD)TestFromstringcCs|jtjdddS)N)zPrQ)r=r) fromstringrrrrtest_fromstringrzTestFromstring.test_fromstringN)r.r?r@rrrrrr rr c@sDeZdZdZejdddgddZejdddgddZd S) TestFromStringAndFileInvalidDataz+string or file could not be read to its end invalid_strz ,invalid_data invalid_sepc stjgdtd}tjddf|jddd|d|fd d d|fd d t t d t dtj dd d}t||Wdn1s`wYWddSWddS1sxwYdS)Ng)\(?rWgGz @rRr$mode,z%.2f)sepformatrctjddSNr)rr)fromfilerrrrrcr}zVTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_file..ctjdddSNrrFrcountrrrrrrcrsr(rr!)r)r[floattempfile TemporaryFiletofilewriteseekr=rr simplefilterrArrrrraresrrr#test_deprecate_unparsable_data_files"        "zDTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_filecstjgdtd}d||fdd|fddd|fddtttjd d d }t |dd |Wdn1sNwYt t d ttjd dd }t ||WddS1svwYdS)NrrRz1.51,2,3.51,4{}crrr)rrx_strrrrcr}zSTestFromStringAndFileInvalidData.test_deprecate_unparsable_string..crr r-rr.rrrcrsasciicstSrrr)bytestrrrrcrdrrFr!rTr(r) r)r[r#rr=encoderrArrrrr)r*r)r1r/r test_deprecate_unparsable_strings      "zATestFromStringAndFileInvalidData.test_deprecate_unparsable_stringN) r.r?r@rrr parametrizer,r3rrrrrs  rc@rD)Test_GetSet_NumericOpscCs>ddlm}|j|dd|jtjidtttjdddS)Nr)getset_numericopsrWr2)r7abc)add)rr6r=r)set_numeric_opsrrf)rr6rrrtest_get_numeric_opss z+Test_GetSet_NumericOps.test_get_numeric_opsN)r.r?r@r;rrrrr5rr5c@seZdZeZddZdS)TestShape1FieldscCs|jtjdtdfgfddS)NrLr!rQ)r=r)rSrrrrrtest_shape_1_fields sz$TestShape1Fields.test_shape_1_fieldsN)r.r?r@rHrr=rrrrr<s r<c@rD) TestNonZerocC |dd|dddS)NcSttdS)Nrr)nonzeror[rrrrrcrsz(TestNonZero.test_zerod..cSr@rvrArrrrrcrsrrrrr test_zerodzTestNonZero.test_zerodN)r.r?r@rCrrrrr> rr>cCsFdddgg}ttjt|WddS1swYdS)Nr!rWrP)rr)rCr[)argrrrtest_deprecate_ragged_arrayss   "rFc@seZdZedZddZdS)TestTooDeepDeprecationz3Creating an ndarray from nested sequences exceedingcCsddg}ttjdD]}|g}q |jtj|fd|jtj|fttdd|jtj|gfddS)Nr!rQrRr)rr)MAXDIMSr>r[dictr\r=)rnestedrrrrtest_deprecation%s z'TestTooDeepDeprecation.test_deprecationN)r.r?r@reescaperrKrrrrrG s  rGc@s&eZdZedZddZddZdS) TestToStringz0tostring() is deprecated. Use tobytes() instead.cCs$tjtdtjd}||jdSNstestrR)r)r[listuint8r=tostring)rrrrr test_tostring4szTestToString.test_tostringcCs\tjtdtjd}|}tt |}Wdn1s!wY||ks,JdSrO)r)r[rPrQtobytesrrArR)rrr^rrrrtest_tostring_matches_tobytes8s   z*TestToString.test_tostring_matches_tobytesN)r.r?r@rLrMrrSrUrrrrrN0s  rNc @sTeZdZdZejejejejej ej ej ej ej ejg ZddZddZddZdS) TestDTypeCoercionz(Converting .* to a dtype .*is deprecatedcCs"|jD] }|jtj|fdqdSr)deprecated_typesr=r)rSr scalar_typerrrtest_dtype_coercionLs z%TestDTypeCoercion.test_dtype_coercioncCs$|jD] }|jtjg|fdqdSr)rWr=r)r[rXrrrtest_array_constructionPs z)TestDTypeCoercion.test_array_constructioncCsTtjD]}|D] }|jtj|fdq qttttfD] }|jtj|fdqdSr) r)sctypesvaluesr>rStyperIrPr,)rgrouprYrrrtest_not_deprecatedTsz%TestDTypeCoercion.test_not_deprecatedN)r.r?r@rr)genericflexiblenumberinexactfloatingcomplexfloatingintegerunsignedinteger signedinteger characterrWrZr[r`rrrrrV@s     rVc @s\eZdZejejejgZejej ej ej ej ej ejejejejejg ZddZddZdS)BuiltInRoundComplexDTypecCP|jD]"}|d}|jt|fd|jt|dfd|jt|fddidqdSNrrQndigitsr)rWr=roundrrYscalarrrrtest_deprecatedh z(BuiltInRoundComplexDType.test_deprecatedcCrlrm)not_deprecated_typesr>rorprrrr`orsz,BuiltInRoundComplexDType.test_not_deprecatedN)r.r?r@r)csinglecdouble clongdoublerWrr~int32int64rQuint16uint32uint64float16float32float64rtrrr`rrrrrk_s  rkc@sDeZdZdZejdddgfddgddgfgddZddZd S) )TestIncorrectAdvancedIndexWithEmptyResultz7Out of bound index found. This was previously ignored.*indexrPrcCsttd}|j|j|fd|j|j|dfdtd}tddf|}|j|j|fd|j|j|dfddS)N)rWrWrrQ)rWrWr!r)r)rr=rI __setitem__rJ)rrrarr2index2rrrtest_empty_subspace{s  z=TestIncorrectAdvancedIndexWithEmptyResult.test_empty_subspacecCsJtd}dgdgggf}|j|j|fd|j|j|tdfddS)N)rWrWrWrPrWrQ)rWrrW)r)rr>rIrempty)rrrrrr)test_empty_index_broadcast_not_deprecateds   zSTestIncorrectAdvancedIndexWithEmptyResult.test_empty_index_broadcast_not_deprecatedN) r.r?r@rrrr4rrrrrrrws "  rc@rD)TestNonExactMatchDeprecationcs>tgdgdg|fdd|fdddS)N)rPr)rrFr!cr)N)rCilpr)r)ravel_multi_indexrrrrrcrszCTestNonExactMatchDeprecation.test_non_exact_match..cstjddddS)NrrRandom)side)r) searchsortedrrrrrcr&)r)r[r=rrrrtest_non_exact_matchsz1TestNonExactMatchDeprecation.test_non_exact_matchN)r.r?r@rrrrrrrrc@s*eZdZejjejdkddddZdS)TestDeprecatedGlobals)rPrz&module-level __getattr__ not supportedrcCs|dd|dd|dd|dd|dd|dd|dd|d d|d ddS) NcS tdS)NT)r)rrrrrrcrz9TestDeprecatedGlobals.test_type_aliases..cSrrv)r)rrrrrrcrcSrrv)r)r#rrrrrcrcSrrv)r)rrrrrrcrcSstSr)r)r\rrrrrcrdcSrNr8)r)r"rrrrrcrcSrrv)r)longrrrrrcrcSrr)r)unicoderrrrrcrcSstjSr)r)typeDictrrrrrcrrrrrtest_type_aliasessz'TestDeprecatedGlobals.test_type_aliasesN) r.r?r@rrrsys version_inforrrrrrs rc@r)TestMatrixInOuterzCadd.outer\(\) was passed a numpy matrix as (first|second) argument.cCstgd}tgdtj}|jtjj||fdd|jtjj||fd|jtjj||fd|jtjj||fddS)NrVrWrUrQ)r)r[rmatrixr=r9outerr>)rrmrrrrrs z!TestMatrixInOuter.test_deprecatedNr.r?r@rrrrrrrrs rc@r)TestRaggedArrayz(setting an array element with a sequencecsVtd|fdd|fdd|fdd|fdddS)Nr!r!cstjdgtjdSNrrRr)r[rrrrrrcr&z1TestRaggedArray.test_deprecated..cstjdgtjdSrrrrrrrcr&cstjdggtjdSrrrrrrrccstjdggtjdSrrrrrrrcr)r)rr=rrrrrrs zTestRaggedArray.test_deprecatedNrrrrrrrrc@r)FlatteningConcatenateUnsafeCastz7concatenate with `axis=None` will use same-kind castingc Cs4|jtjdgdgfftdtjdtjddddS)Nr?rWrR)axisoutr)r=r) concatenaterIrryrrrrrrs  z/FlatteningConcatenateUnsafeCast.test_deprecatedcCs|jtjdgdgffdtjdtjddddtttjdgdgftjdtjddd WddS1s:wYdS) NrrrWrRunsafe)rrcastingr same_kind)rr)r>r)rrryrrhrrrrr`s  "z3FlatteningConcatenateUnsafeCast.test_not_deprecatedNr.r?r@rrrr`rrrrr rc@s$eZdZeZdZddZddZdS)-TestDeprecateSubarrayDTypeDuringArrayCoercionz6(creating|casting) an array (with|to) a subarray dtypecs4tddg|fddtt d}Wdn1s%wYt|ddgddgg|fddtttjdd}Wdn1sUwYt|ddgddggtttjdd ggdd}Wdn1swYt|ddgddggddgddgggdS) Nr!rWcs dS)N(2)i,)astyperrrrrcrzUTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_array..rcr)NrrRr)r[rrrrrcr}rR)r!)rW)r)r[r=rwarnsrHrr)rr+rrrtest_deprecated_arrays    *zCTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_arraycsBtdddfdd}||fdd}||dS)NrrFrWcs:ttdWddS1swYdS)N(2,2)f)rraisesrfrrrrrchecks  "zVTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_error..checkcs>tttjddWddS1swYdS)NrrR)rrrfr)r[rrrrrs ")r)rqrr=)rrrrrtest_deprecated_and_errors    zGTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_errorN)r.r?r@rHrrrrrrrrrs  rc@seZdZeZdZejdgdddZ ejdgdddZ ejdgddd Z ejdgdd d Z ejdgdd d Z dS)%TestFutureWarningArrayLikeNotIterablez,The input object of type.*but not a sequenceprotocol)ri__array_interface____array_struct__cs6td}tdd|t||i|fdddS)aTest that these objects give a warning since they are not 0-D, not coerced at the top level `np.array(obj)`, but nested, and do *not* define the sequence protocol. NOTE: Tests for the versions including __len__ and __getitem__ exist in `test_array_coercion.py` and they can be modified or ammended when this deprecation expired. rMyArrrcstjgtdSNrRr)r[r\rrrrrcrzGTestFutureWarningArrayLikeNotIterable.test_deprecated..N)r)rqr^getattrr=)rr blueprintrrrrrs z5TestFutureWarningArrayLikeNotIterable.test_deprecatedcsltd}tdd|t||i}||fddtjgtd}tjdtd}|d<t||dS) NrrrcstjgtdSrrrmyarrrrrc*rszNTestFutureWarningArrayLikeNotIterable.test_0d_not_deprecated..rRr!r)r)r[r^rr>r\rr)rrrrr+expectedrrrtest_0d_not_deprecated!s z.)r)rqr^rr>r[r)rrrrr+rrrtest_unnested_not_deprecated0s  zBTestFutureWarningArrayLikeNotIterable.test_unnested_not_deprecatedcCstdd}tdd|t||dddi}|}tjt|jdt |gg}Wd n1s4wY|j d ks@J|j dksGJ|d d ksOJd S) zThe old code would actually use the dtype from the array, but then end up not using the array (for dimension discovery) rf4rr __float__cSdSN?r_rrrrcCrzSTestFutureWarningArrayLikeNotIterable.test_strange_dtype_handling..matchNrrr) r)rqrr^rrrrHrr[shaperS)rrrrrr+rrrtest_strange_dtype_handling;szATestFutureWarningArrayLikeNotIterable.test_strange_dtype_handlingcstdd}tdd|t||dddi}|tjdtd fd d }||d us5Jd us=JdusEJdS)NrrrrrcSrrrrrrrrcWrzVTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated..rPrRcsgdd<dSrrrrr+rrset[szQTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated..setrr!rW)r)rqrr^rrr\r>)rrrrrrrrtest_assignment_not_deprecatedNs zDTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecatedN)r.r?r@rHrrrrr4rrrrrrrrrrr s.       rc@seZdZdZdZddZdS)"TestDeprecatedUnpickleObjectScalarz Technically, it should be impossible to create numpy object scalars, but there was an unpickle path that would in theory allow it. That path is invalid and must lead to the warning. z4Unpickling a scalar with object dtype is deprecated.cs tjjj|fdddS)NcstddS)NOr!rrctorrrrcnrszDTestDeprecatedUnpickleObjectScalar.test_deprecated..)r)core multiarrayrqr=rrrrrrls z2TestDeprecatedUnpickleObjectScalar.test_deprecatedN)r.r?r@rrrrrrrrrcs rrz Needs noserc@s\eZdZGdddeZddZddZddZd d Zd d Z d dZ ddZ ddZ dS)TestNoseDecoratorsDeprecatedc@s eZdZdS)z/TestNoseDecoratorsDeprecated.DidntSkipExceptionN)r.r?r@rrrrDidntSkipException|srcCdd}||dS)NcSs tjjjdd}t|jdS)NcSrrr)rarbzrrr slow_funczMTestNoseDecoratorsDeprecated.test_slow.._test_slow..slow_func)r)testingdecslowr)rrrr _test_slows z:TestNoseDecoratorsDeprecated.test_slow.._test_slowr)rrrrr test_slowsz&TestNoseDecoratorsDeprecated.test_slowcCdd}|j|dddS)NcSsdtjjdd}tjjddd}tjjddd}t|jt|jt|j dS) NcSrrrrerrr f_defaultrzWTestNoseDecoratorsDeprecated.test_setastest.._test_setastest..f_defaultTcSrrrrerrrf_istestrzVTestNoseDecoratorsDeprecated.test_setastest.._test_setastest..f_istestFcSrrrrerrr f_isnottestrzYTestNoseDecoratorsDeprecated.test_setastest.._test_setastest..f_isnottest)r)rr setastestr__test__)rrrrrr_test_setastests        zDTestNoseDecoratorsDeprecated.test_setastest.._test_setastestrPr7r)rrrrrtest_setastestsz+TestNoseDecoratorsDeprecated.test_setastestcfdd}j|dddS)Ncstjjdfdd}z|dWnjytdtjy)Ynwtjjdfdd}z|dWdSjyIYdStjyUtd w) NTcjrrrarrrf1znTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.._test_skip_functions_hardcoded..f1rLFailed to skipFcrrrrrrrf2rznTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.._test_skip_functions_hardcoded..f2Skipped when not expected tor)rrrrr+r __class__)rrrrr_test_skip_functions_hardcodeds$   zbTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.._test_skip_functions_hardcodedrWr7r)rrrrrtest_skip_functions_hardcodeds z:TestNoseDecoratorsDeprecated.test_skip_functions_hardcodedcr)Ncsfdd}tjj|fdd}zd|dWnjy'tdtjy1Ynwtjj|fdd }z d |dWdSjySYdStjy_td w) NcruNskip me!rr skip_flagrr skip_testerzuTestNoseDecoratorsDeprecated.test_skip_functions_callable.._test_skip_functions_callable..skip_testercrrrrrrrrrzlTestNoseDecoratorsDeprecated.test_skip_functions_callable.._test_skip_functions_callable..f1rrLrcrrrrrrrrrzlTestNoseDecoratorsDeprecated.test_skip_functions_callable.._test_skip_functions_callable..f2zfive is right out!rr)rrrrrr_test_skip_functions_callables*    z`TestNoseDecoratorsDeprecated.test_skip_functions_callable.._test_skip_functions_callablerWr7r)rrrrrtest_skip_functions_callables z9TestNoseDecoratorsDeprecated.test_skip_functions_callablecr)Ncstjjdddd}z |dD]}qWtdtjy#Ynwtjjddfd d }z |dD]}q7WdStjyItd jySYdSw) NTThis test is known to failcst|EdHdSrrrrrrg1zpTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.._test_skip_generators_hardcoded..g1rFailed to mark as known failureFThis test is NOT known to failc3t|EdHdNFAILrrrrrrg2 zpTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.._test_skip_generators_hardcoded..g2#Marked incorrectly as known failurer)rrknownfailureifrrr+r)r jrrrr_test_skip_generators_hardcodeds*   zdTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.._test_skip_generators_hardcodedrWr7r)rrrrrtest_skip_generators_hardcodeds z;TestNoseDecoratorsDeprecated.test_skip_generators_hardcodedcr)Ncsfdd}tjj|ddd}zd|dD]}qWtdtjy+Ynwtjj|d fd d }z d |dD]}qAWdStjyStd jy]YdSw)NcrurrrrrrrrzwTestNoseDecoratorsDeprecated.test_skip_generators_callable.._test_skip_generators_callable..skip_testerrcsrrrrrrrr r znTestNoseDecoratorsDeprecated.test_skip_generators_callable.._test_skip_generators_callable..g1rrr r c3r rrrrrrrrznTestNoseDecoratorsDeprecated.test_skip_generators_callable.._test_skip_generators_callable..g2z do not skiprr)rr rrrrr_test_skip_generators_callables0    zbTestNoseDecoratorsDeprecated.test_skip_generators_callable.._test_skip_generators_callablerWr7r)rrrrrtest_skip_generators_callables z:TestNoseDecoratorsDeprecated.test_skip_generators_callablecCr)NcSstjjddd}tjjdd}tjjdd}tjjdd }tt||tjdd td tt |tt|WddS1sRwYdS) NTcSrrrrrrrnon_deprecated_funcrzcTestNoseDecoratorsDeprecated.test_deprecated.._test_deprecated..non_deprecated_funccSsddl}|jdtdddS)NrzTEST: deprecated funcr!rrrrrrdeprecated_funcsz_TestNoseDecoratorsDeprecated.test_deprecated.._test_deprecated..deprecated_funccSsddl}|jdddtNrAHHHHr!r)rrrfrrrrdeprecated_func2sz`TestNoseDecoratorsDeprecated.test_deprecated.._test_deprecated..deprecated_func2cSsddl}|jddddSr)rrrrrrdeprecated_func3 sz`TestNoseDecoratorsDeprecated.test_deprecated.._test_deprecated..deprecated_func3r r) r)rr deprecatedrr-rrr)rf)rrr!r"rrr_test_deprecateds            "zFTestNoseDecoratorsDeprecated.test_deprecated.._test_deprecatedrr7r)rr$rrrrrsz,TestNoseDecoratorsDeprecated.test_deprecatedcCr)NcSsXtjjdgddd}d}|D]}|d|dd|d7}qt|dkdS)Nzbase, power, expected))r!r!r!)rWr!rW)rWrWrcSst|||kdSr)r)basepowerrrrrcheck_parametrize6szcTestNoseDecoratorsDeprecated.test_parametrize.._test_parametrize..check_parametrizerr!rP)r)rrr4r)r'r"testrrr_test_parametrize2s    zHTestNoseDecoratorsDeprecated.test_parametrize.._test_parametrizer)rr)rrrtest_parametrize1sz-TestNoseDecoratorsDeprecated.test_parametrizeN) r.r?r@r+rrrrrrrrrr*rrrrrzs ! "rc@r)TestSingleElementSignaturezThe use of a length 1cCr?)NcStjddddS)Nr!rWd) signaturer)r9rrrrrcJrsz.cSstjddtdfdS)Nr!rWrsig)r)r9rSrrrrrcKsrrrrrrrIrDz*TestSingleElementSignature.test_deprecatedNrrrrrr+Err+c@r)TestComparisonBadDTypez0using `dtype=` in comparisons is only useful forcCr?)NcSstjddtjdSNr!rR)r)equalryrrrrrcSrz8TestComparisonBadDType.test_deprecated..cSstjddddS)Nr!)NNrr0)r)r4rrrrrcUrsrrrrrrrRsz&TestComparisonBadDType.test_deprecatedcCs:tjddtdtjddtddtjdgdgtddS) NTFrRrPrFr)rSrr)r)r4rr\rrrrr`Wsz*TestComparisonBadDType.test_not_deprecatedNrrrrrr2Nrr2c@seZdZdZeZddZdS)TestComparisonBadObjectDTypez5using `dtype=object` \(or equivalent signature\) willcCr?)NcSstjddtdSr3r)r4r\rrrrrcbrsz>TestComparisonBadObjectDType.test_deprecated..cSstjddddtfdS)Nr!r0r6rrrrrcdrrrrrrrrasz,TestComparisonBadObjectDType.test_deprecatedN)r.r?r@rrHrrrrrrrr5\s r5c@s4eZdZdZGdddZGdddZddZdS) !TestSpecialAttributeLookupFailurez5An exception was ignored while fetching the attributec@eZdZeddZdS)z0TestSpecialAttributeLookupFailure.WeirdArrayLikecCtdNzoops! RuntimeErrorrrrrrikz:TestSpecialAttributeLookupFailure.WeirdArrayLike.__array__N)r.r?r@propertyrirrrrWeirdArrayLikejr?c@r8)z5TestSpecialAttributeLookupFailure.WeirdArrayInterfacecCr9r:r;rrrrrpr=zITestSpecialAttributeLookupFailure.WeirdArrayInterface.__array_interface__N)r.r?r@r>rrrrrWeirdArrayInterfaceor@rAcs(fddfdddS)NctSr)r)r[r?rrrrrcur}zCTestSpecialAttributeLookupFailure.test_deprecated..crBr)r)r[rArrrrrcvr}rrrrrrrtsz1TestSpecialAttributeLookupFailure.test_deprecatedN)r.r?r@rr?rArrrrrrr7gs  r7c@sfeZdZeZedgjZej dgdde ddfddZ ej dgdde ddfd d Z dS) TestCtypesGetterr!name)get_data get_shape get_stridesget_as_parameterreturnNcs"t|j||fdddS)NcsSrrrfuncrrrcrz2TestCtypesGetter.test_deprecated..)rctypesr=rrDrrJrrr~s z TestCtypesGetter.test_deprecated)rrstrides_as_parameter_csfdddS)Ncs tjSr)rrLrrDrrrrcrz6TestCtypesGetter.test_not_deprecated..)r>rMrrPrr`sz$TestCtypesGetter.test_not_deprecated)r.r?r@rArr)r[rLrrr4r"rrr`rrrrrCysrCc@s(eZdZdZddZddZddZdS) TestUFuncForcedDTypeWarningz?The `dtype` and `signature` arguments to ufuncs only select thecsDddl}td}||||usJ|fdddS)NrrycstjdddS)NrPrrRr/rint64_2rrrcrszATestUFuncForcedDTypeWarning.test_not_deprecated..)pickler)rSloadsdumpsr>)rrTryrrRrr`s   z/TestUFuncForcedDTypeWarning.test_not_deprecatedcs.td|fdd|dddS)NrycstjdddS)NrPrFrR)r)r9 newbyteorderrryrrrcr&z>TestUFuncForcedDTypeWarning.test_deprecation..cSr,)NrPrFm8[ns]rRr/rrrrrcrs)r)rSr=rrrXrrKs z,TestUFuncForcedDTypeWarning.test_deprecationcCsbtd}tjddd}tjt|jdtjdd|dWdn1s)wYtjt|jdtjddddWdn1sIwYtjt|jdtj||ddWdn1siwYtjt|jdtj ||ddWdn1swYtjt|jdtj j |ddWddS1swYdS) Nryrzm8[s]rRrrPrFrY) r)rSrqrrrArr9rWmaximumreduce)rryrrrrtest_behaviours" "z*TestUFuncForcedDTypeWarning.test_behaviourN)r.r?r@rr`rKr\rrrrrQs  rQ)KrrrXrrr$rLrnumpyr) numpy.testingrrrrrrrr rr ImportErrorr rBrErOrrrrrrrrrrrrrrrrr r rr5r<r>rFrGrNrVrkrrrrrrrrrrr)nose HAVE_NOSErrrr+r2r5r7rCrQrrrrs   lR   4   *V   K