U
    #c                  	   @   s  d Z ddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZmZmZmZmZmZmZ ddlmZ zddlZdZW n ek
r   dZY nX G dd dZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd dZG dd deZG dd deZ G dd deZ!G dd deZ"G dd  d eZ#G d!d" d"eZ$G d#d$ d$eZ%G d%d& d&eZ&G d'd( d(eZ'G d)d* d*eZ(G d+d, d,eZ)G d-d. d.eZ*G d/d0 d0eZ+G d1d2 d2eZ,G d3d4 d4eZ-G d5d6 d6eZ.G d7d8 d8eZ/G d9d: d:eZ0G d;d< d<eZ1G d=d> d>eZ2G d?d@ d@eZ3G dAdB dBeZ4G dCdD dDeZ5G dEdF dFeZ6z*e7  e8dG ddl9Z9W 5 Q R X W n ek
r   dZ:Y nX dZ:ej;j<e: dHdIG dJdK dKeZ=G dLdM dMeZ>G dNdO dOeZ?e	@dPjAe	@dPjBdQdR dSdR dTZCej;jDdUeCE eCdVG dWdX dXeZFG dYdZ dZeZGG d[d\ d\eZHG d]d^ d^eZIG d_d` d`eZJG dadb dbeZKG dcdd ddeZLG dedf dfeZMG dgdh dheZNej;Ddidjdkdldmdndogdpdq ZOdS )rz
Tests related to deprecation warnings. Also a convenient place
to document how deprecations should eventually be turned into errors.

    N)assert_raisesassert_warnsassert_assert_array_equalSkipTestKnownFailureExceptionbreak_cyclesfromstring_null_term_c_apiTFc                   @   sJ   e Zd ZdZeZdd Zdd Zdddej	di fd	d
Z
di fddZdS )_DeprecationTestCase c                 C   sB   t jdd| _| j | _t jd| jd t jd| j| jd d S )NTrecordalways)categorymessager   )warningscatch_warningswarn_ctx	__enter__logfilterwarningswarning_clsr   self r   F/tmp/pip-unpacked-wheel-b2rbor69/numpy/core/tests/test_deprecations.pysetup_method#   s    
z!_DeprecationTestCase.setup_methodc                 C   s   | j   d S N)r   __exit__r   r   r   r   teardown_method1   s    z$_DeprecationTestCase.teardown_method   Fr   c              	   C   sR  d}g | j dd< |tjkr$| jf}z||| W n |r>tnt k
rP   Y nX d}	| j D ]4}
|
j| jkrv|	d7 }	q\|s\td| jj|
jf q\|dk	r|	|krdt	| j |f }dd | j D }td	
|g| t h tjd
| j| jd z"||| |t krtdW n* |k
rB   |t kr>tdY nX W 5 Q R X dS )a  Test 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`
        TNr   r"   zexpected %s but got: %sz"%i warnings found but %i expected.c                 S   s   g | ]}t |qS r   )str).0wr   r   r   
<listcomp>m   s     z:_DeprecationTestCase.assert_deprecated.<locals>.<listcomp>
errorr   z$No error raised during function callz!Error raised during function call)r   np_NoValuer   	Exceptiontupler   AssertionError__name__lenjoinr   r   r   r   )r   functionnumignore_othersZfunction_fails
exceptionsargskwargsZ__tracebackhide__Z	num_foundwarningmsglstr   r   r   assert_deprecated4   sJ    !





z&_DeprecationTestCase.assert_deprecatedc                 C   s   | j |ddt ||d dS )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)
        r   T)r2   r3   r4   r5   r6   N)r:   r,   )r   r1   r5   r6   r   r   r   assert_not_deprecated}   s
    
  z*_DeprecationTestCase.assert_not_deprecatedN)r.   
__module____qualname__r   DeprecationWarningr   r   r!   r)   r*   r:   r;   r   r   r   r   r      s    
Ir   c                   @   s   e Zd ZejZdS )_VisibleDeprecationTestCaseN)r.   r<   r=   r)   ZVisibleDeprecationWarningr   r   r   r   r   r?      s   r?   c                   @   s4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )TestComparisonDeprecationsaP  This 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; .*c                 C   s   t jt jfD ]}| j|tdg fd tjddd}| j|||d d fd d tjdtdddggtd}tjdtdddggtd}| j|||fd d qd S )	N   r5   zi,idtyper5   r2   r"      )operatoreqner:   r)   zerosarrayobject)r   opabr   r   r   test_normal_types   s    z,TestComparisonDeprecations.test_normal_typesc                    sF   t ddg t dddg}ttdd  | tt fdd d S )NrO   rP   cc                 S   s   | |kS r   r   )xyr   r   r   <lambda>       z8TestComparisonDeprecations.test_string.<locals>.<lambda>c                      s    g kS r   r   r   rO   r   r   rU      rV   )r)   rL   r   FutureWarning)r   rP   r   rW   r   test_string   s    z&TestComparisonDeprecations.test_stringc                    s6   G dd d |   fdd |   fdd d S )Nc                   @   s   e Zd Zdd Zdd ZdS )zNTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.NotArrayc                 S   s   t d S r   )	TypeErrorr   r   r   r   	__array__   s    zXTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.NotArray.__array__c                 S   s   t S r   )NotImplemented)r   otherr   r   r   __ne__   s    zUTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.NotArray.__ne__N)r.   r<   r=   r[   r^   r   r   r   r   NotArray   s   r_   c                      s   t d  kS NrG   r)   aranger   r_   r   r   rU      rV   zNTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.<lambda>c                      s   t d  kS r`   ra   r   rc   r   r   rU      rV   r:   r   r   rc   r   !test_void_dtype_equality_failures   s    z<TestComparisonDeprecations.test_void_dtype_equality_failuresc                 C   s  t tdd  t tdd  t \ td ttddk  ttddk ttddk  ttddk W 5 Q R X t	dtdfD ]p}tj
ddd	}|dfD ]T}tjtjtjtjfD ]:}t (}td
 tt||| t|  W 5 Q R X qqqd S )Nc                   S   s   t ddkS NrG   rO   ra   r   r   r   r   rU      rV   zTTestComparisonDeprecations.test_array_richcompare_legacy_weirdness.<locals>.<lambda>c                   S   s   t ddkS rf   ra   r   r   r   r   rU      rV   r(   r   rO   rG   zi4,i4rC   r   )r   rX   r   r   r   r   r)   rL   int16ZasarrayrK   rH   ltlegtger   rZ   )r   Zarg1structZarg2flr   r   r   'test_array_richcompare_legacy_weirdness   s     



zBTestComparisonDeprecations.test_array_richcompare_legacy_weirdnessN)	r.   r<   r=   __doc__r   rQ   rY   re   ro   r   r   r   r   r@      s   r@   c                   @   s2   e Zd ZdZdd Zejje dddd Z	dS )	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.
    c                 C   s$   | j tjdd | j tjdd d S )N)z2000-01-01T00+01rB   )z2000-01-01T00Z)r:   r)   
datetime64r   r   r   r   rY      s    z"TestDatetime64Timezone.test_stringz!The pytz module is not available.reasonc                 C   s6   t d}tjddddd|d}| jtj|fd d S )Nz
US/Easterni  r"   r   )tzinforB   )pytztimezonedatetimer:   r)   rr   )r   tzdtr   r   r   test_datetime   s    
z$TestDatetime64Timezone.test_datetimeN)
r.   r<   r=   rp   rY   pytestmarkskipif	_has_pytzr{   r   r   r   r   rq      s   
rq   c                   @   s   e Zd ZdZdd ZdS )+TestArrayDataAttributeAssignmentDeprecationaS  Assigning 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.
    c                 C   s8   t d}t ddd}d| _| j|jd|jfd d S )N
   r   r"   zcAssigning the 'data' attribute is an inherently unsafe operation and will be removed in the future.datarB   )r)   rb   Zlinspacer   r:   __setattr__r   )r   rO   rP   r   r   r   test_data_attr_assignment   s    
zETestArrayDataAttributeAssignmentDeprecation.test_data_attr_assignmentN)r.   r<   r=   rp   r   r   r   r   r   r      s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )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.
    c                 C   s(   d}ddi}d| _ | jtj||d d S )N)r   widthrG   QInsufficient bit width provided. This behavior will raise an error in the future.r5   r6   r   r:   r)   Zbinary_reprr   r5   r6   r   r   r    test_insufficient_width_positive  s    zZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_positivec                 C   s(   d}ddi}d| _ | jtj||d d S )N)r   rG   r   r   r   r   r   r   r    test_insufficient_width_negative  s    zZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_negativeN)r.   r<   r=   rp   r   r   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdd ZdS )$TestDTypeAttributeIsDTypeDeprecationz.*`.dtype` attributec                    sl   G dd d G dd dt j|  fdd |  fdd | fdd | fd	d d S )
Nc                   @   s   e Zd ZdZdS )zZTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.dtZf8Nr.   r<   r=   rD   r   r   r   r   rz     s   rz   c                   @   s   e Zd ZdZdS )z[TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.vdtzf,fNr   r   r   r   r   vdt   s   r   c                      s
   t  S r   r)   rD   r   rz   r   r   rU   #  rV   z`TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.<lambda>c                      s   t   S r   r   r   r   r   r   rU   $  rV   c                      s
   t  S r   r   r   r   r   r   rU   %  rV   c                      s   t  dS Nr"   r   r   r   r   r   rU   &  rV   )r)   voidr:   r   r   )rz   r   r   )test_deprecation_dtype_attribute_is_dtype  s    zNTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtypeN)r.   r<   r=   r   r   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )TestTestDeprecatedc                 C   s>   t  }|  tt|jdd  dd }|| |  d S )Nc                   S   s   d S r   r   r   r   r   r   rU   /  rV   z;TestTestDeprecated.test_assert_deprecated.<locals>.<lambda>c                   S   s   t jdtdd d S )NfoorG   )r   
stacklevelr   warnr>   r   r   r   r   r   1  s    z6TestTestDeprecated.test_assert_deprecated.<locals>.foo)r   r   r   r-   r:   r!   )r   Ztest_case_instancer   r   r   r   test_assert_deprecated*  s    
z)TestTestDeprecated.test_assert_deprecatedN)r.   r<   r=   r   r   r   r   r   r   )  s   r   c                   @   s   e Zd ZdZdd ZdS )TestNonNumericConjugatez
    Deprecate no-op behavior of ndarray.conjugate on non-numeric dtypes,
    which conflicts with the error behavior of np.conjugate.
    c                 C   sh   t dt dfD ]}| |j qt dt ddt ddtfdtfgfD ]}| |j qRd S )	N   y              @sZ2016M)r"   rG   rO   rP   )r)   rL   r;   	conjugateintr:   )r   rO   r   r   r   test_conjugate=  s    z&TestNonNumericConjugate.test_conjugateN)r.   r<   r=   rp   r   r   r   r   r   r   8  s   r   c                   @   s   e Zd Zdd ZdS )TestNPY_CHARc                 C   s(   ddl m} | | t| dk d S )Nr   )npy_char_deprecationZS1)numpy.core._multiarray_testsr   r:   r   )r   r   r   r   r   test_npy_char_deprecationG  s    
z&TestNPY_CHAR.test_npy_char_deprecationN)r.   r<   r=   r   r   r   r   r   r   E  s   r   c                   @   s   e Zd Zdd ZdS )TestPyArray_AS1Dc                 C   s   ddl m} tt| d S )Nr   )npy_pyarrayas1d_deprecation)r   r   r   NotImplementedError)r   r   r   r   r    test_npy_pyarrayas1d_deprecationN  s    z1TestPyArray_AS1D.test_npy_pyarrayas1d_deprecationN)r.   r<   r=   r   r   r   r   r   r   M  s   r   c                   @   s   e Zd Zdd ZdS )TestPyArray_AS2Dc                 C   s   ddl m} tt| d S )Nr   )npy_pyarrayas2d_deprecation)r   r   r   r   )r   r   r   r   r    test_npy_pyarrayas2d_deprecationT  s    z1TestPyArray_AS2D.test_npy_pyarrayas2d_deprecationN)r.   r<   r=   r   r   r   r   r   r   S  s   r   c                   @   s   e Zd Zdd ZdS )TestDatetimeEventc                 C   sj   t jt jfD ]X}| j|dd | j|dd | j|dd | j|dd | j|dd | j|dd qd S )N)r"   )msrG   rB   )r"   )r   rG   r"   N)r"   )r   rG   event)r"   )r   rG   ?   )r"   )r   rG   r"   r   )r"   )r   rG   r"   r   )r)   rr   Ztimedelta64r;   r:   )r   clsr   r   r   test_3_tuple[  s    zTestDatetimeEvent.test_3_tupleN)r.   r<   r=   r   r   r   r   r   r   Y  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )TestTruthTestingEmptyArraysz..*truth value of an empty array is ambiguous.*c                 C   s   | j ttg fd d S NrB   )r:   boolr)   rL   r   r   r   r   test_1dm  s    z#TestTruthTestingEmptyArrays.test_1dc                 C   sF   | j ttdfd | j ttdfd | j ttdfd d S )N)r"   r   rB   )r   r"   r   r   )r:   r   r)   rK   r   r   r   r   test_2dp  s    z#TestTruthTestingEmptyArrays.test_2dN)r.   r<   r=   r   r   r   r   r   r   r   r   i  s   r   c                   @   s   e Zd Zdd ZdS )TestBincountc                 C   s   |  dd  d S )Nc                   S   s   t jdddgd dS )Nr"   rG   rA   )Z	minlength)r)   Zbincountr   r   r   r   rU   y  rV   z6TestBincount.test_bincount_minlength.<locals>.<lambda>rd   r   r   r   r   test_bincount_minlengthx  s    z$TestBincount.test_bincount_minlengthN)r.   r<   r=   r   r   r   r   r   r   v  s   r   c                   @   s   e Zd Zdd ZdS )TestGeneratorSumc                 C   s$   | j tjdd tdD fd d S )Nc                 s   s   | ]
}|V  qd S r   r   )r$   ir   r   r   	<genexpr>  s     z6TestGeneratorSum.test_generator_sum.<locals>.<genexpr>r   rB   )r:   r)   sumranger   r   r   r   test_generator_sum  s    z#TestGeneratorSum.test_generator_sumN)r.   r<   r=   r   r   r   r   r   r   }  s   r   c                   @   s   e Zd Zdd ZdS )TestPositiveOnNonNumericalc                 C   s   | j tjtdfd d S )Nr   rB   )r:   rH   posr)   rL   r   r   r   r   test_positive_on_non_number  s    z6TestPositiveOnNonNumerical.test_positive_on_non_numberN)r.   r<   r=   r   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )TestFromstringc                 C   s   | j tjdd d S )N)zP                                                                                rB   )r:   r)   
fromstringr   r   r   r   test_fromstring  s    zTestFromstring.test_fromstringN)r.   r<   r=   r   r   r   r   r   r     s   r   c                   @   sD   e Zd ZdZejdddgdd Zejdddgdd Zd	S )
 TestFromStringAndFileInvalidDataz+string or file could not be read to its endinvalid_strz,invalid_dataZinvalid_sepc              
      s   t jddddgtd}tjdd |j dd	d
  |  d |  fdd  d |  fdd t	
 6 t	dt  d t j ddd}t|| W 5 Q R X W 5 Q R X d S )N)\(?rG   Gz@   rC   r%   mode,z%.2f)sepformatr   c                      s   t j ddS Nr   )r   r)   fromfiler   rm   r   r   rU     rV   zVTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_file.<locals>.<lambda>c                      s   t j dddS Nr   r   r   countr   r   r   r   r   rU     rV   r(   r   )r)   rL   floattempfileTemporaryFileZtofilewriteseekr:   r   r   simplefilterr>   r   r   r   r   rS   resr   r   r   #test_deprecate_unparsable_data_file  s    




zDTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_filec              	      s   t jddddgtd}d|| fdd | fd	d d
 |  fdd tt( t jddd}t	|d d | W 5 Q R X t
 , t
dt t jddd}t	|| W 5 Q R X d S )Nr   rG   r   r   rC   z1.51,2,3.51,4{}c                      s   t j ddS r   r)   r   r   x_strr   r   rU     rV   zSTestFromStringAndFileInvalidData.test_deprecate_unparsable_string.<locals>.<lambda>c                      s   t j dddS r   r   r   r   r   r   rU     rV   asciic                      s   t  S r   r	   r   )bytestrr   r   rU     rV   r   r   r   rE   r(   )r)   rL   r   r   r:   encoder   r>   r   r   r   r   r   r   r   )r   r   r    test_deprecate_unparsable_string  s    



zATestFromStringAndFileInvalidData.test_deprecate_unparsable_stringN)	r.   r<   r=   r   r|   r}   parametrizer   r   r   r   r   r   r     s
   
r   c                   @   s   e Zd Zdd ZdS )Test_GetSet_NumericOpsc                 C   s>   ddl m} | j|dd | jtji d tttjdd d S )Nr   )getset_numericopsrG   r2   )r6   abc)add)r   r   r:   r)   Zset_numeric_opsr   
ValueError)r   r   r   r   r   test_get_numeric_ops  s    z+Test_GetSet_NumericOps.test_get_numeric_opsN)r.   r<   r=   r   r   r   r   r   r     s   r   c                   @   s   e Zd ZeZdd ZdS )TestShape1Fieldsc                 C   s   | j tjdtdfgfd d S )NrO   r"   rB   )r:   r)   rD   r   r   r   r   r   test_shape_1_fields  s    z$TestShape1Fields.test_shape_1_fieldsN)r.   r<   r=   rX   r   r   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )TestNonZeroc                 C   s    |  dd  |  dd  d S )Nc                   S   s   t t dS )Nr   r)   ZnonzerorL   r   r   r   r   rU     rV   z(TestNonZero.test_zerod.<locals>.<lambda>c                   S   s   t t dS r   r   r   r   r   r   rU     rV   rd   r   r   r   r   
test_zerod  s    zTestNonZero.test_zerodN)r.   r<   r=   r   r   r   r   r   r     s   r   c                   @   s&   e Zd ZedZdd Zdd ZdS )TestToStringz0tostring() is deprecated. Use tobytes() instead.c                 C   s$   t jtdt jd}| |j d S Ns   testrC   )r)   rL   listuint8r:   tostring)r   arrr   r   r   test_tostring  s    zTestToString.test_tostringc              	   C   sH   t jtdt jd}| }tt | }W 5 Q R X ||ksDtd S r   )	r)   rL   r   r   tobytesr   r>   r   r-   )r   r   rP   r   r   r   r   test_tostring_matches_tobytes  s
    
z*TestToString.test_tostring_matches_tobytesN)r.   r<   r=   reescaper   r   r   r   r   r   r   r     s   
r   c                
   @   sT   e Zd ZdZejejejejej	ej
ejejejejg
Zdd Zdd Zdd ZdS )	TestDTypeCoercionz(Converting .* to a dtype .*is deprecatedc                 C   s"   | j D ]}| jtj|fd qd S r   )deprecated_typesr:   r)   rD   r   scalar_typer   r   r   test_dtype_coercion  s    
z%TestDTypeCoercion.test_dtype_coercionc                 C   s$   | j D ]}| jtjg |fd qd S r   )r  r:   r)   rL   r  r   r   r   test_array_construction  s    
z)TestDTypeCoercion.test_array_constructionc                 C   sT   t j D ] }|D ]}| jt j|fd qq
ttttfD ]}| jt j|fd q8d S r   )	r)   Zsctypesvaluesr;   rD   typedictr   r,   )r   groupr  r   r   r   test_not_deprecated  s
    z%TestDTypeCoercion.test_not_deprecatedN)r.   r<   r=   r   r)   ZgenericZflexiblenumberZinexactZfloatingZcomplexfloatingintegerZunsignedintegerZsignedinteger	characterr  r  r  r  r   r   r   r   r    s         	r  c                   @   s\   e Zd ZejejejgZejej	ej
ejejejejejejejejgZdd Zdd ZdS )BuiltInRoundComplexDTypec                 C   sP   | j D ]D}|d}| jt|fd | jt|dfd | jt|fddid qd S Nr   rB   ndigitsr   )r  r:   roundr   r  scalarr   r   r   test_deprecated  s
    
z(BuiltInRoundComplexDType.test_deprecatedc                 C   sP   | j D ]D}|d}| jt|fd | jt|dfd | jt|fddid qd S r  )not_deprecated_typesr;   r  r  r   r   r   r    s
    
z,BuiltInRoundComplexDType.test_not_deprecatedN)r.   r<   r=   r)   ZcsingleZcdoubleZclongdoubler  Zint8rg   Zint32int64r   Zuint16Zuint32Zuint64Zfloat16Zfloat32Zfloat64r  r  r  r   r   r   r   r    s           r  c                   @   sD   e Zd ZdZejdddgfddgddgfgdd Zdd Zd	S )
)TestIncorrectAdvancedIndexWithEmptyResultz7Out of bound index found. This was previously ignored.*indexrA   r   c                 C   st   t d}| j|j|fd | j|j|dfd t d}tddf| }| j|j|fd | j|j|dfd d S )N)rG   rG   r   rB           )rG   rG   r"   r   )r)   onesr:   __getitem____setitem__slice)r   r  r   Zarr2index2r   r   r   test_empty_subspace)  s    

z=TestIncorrectAdvancedIndexWithEmptyResult.test_empty_subspacec                 C   sJ   t d}dgdggg f}| j|j|fd | j|j|t dfd d S )N)rG   rG   rG   rA   rG   rB   )rG   r   rG   )r)   r  r;   r  r  empty)r   r   r  r   r   r   )test_empty_index_broadcast_not_deprecated7  s    
zSTestIncorrectAdvancedIndexWithEmptyResult.test_empty_index_broadcast_not_deprecatedN)	r.   r<   r=   r   r|   r}   r   r!  r#  r   r   r   r   r  %  s   "
r  c                   @   s   e Zd Zdd ZdS )TestNonExactMatchDeprecationc                    sB   t dddgdddgg |  fdd |  fdd d S )	NrA      r   r   r"   c                      s   t j dddS )N)   r%  ZCilpr   )r)   Zravel_multi_indexr   r   r   r   rU   E  rV   zCTestNonExactMatchDeprecation.test_non_exact_match.<locals>.<lambda>c                      s   t j d dddS )Nr   r   Random)Zside)r)   Zsearchsortedr   r'  r   r   rU   G  rV   )r)   rL   r:   r   r   r'  r   test_non_exact_matchB  s    z1TestNonExactMatchDeprecation.test_non_exact_matchN)r.   r<   r=   r)  r   r   r   r   r$  @  s   r$  c                   @   s   e Zd ZdZdd ZdS )TestMatrixInOuterzCadd.outer\(\) was passed a numpy matrix as (first|second) argument.c                 C   s   t dddg}t dddgt j}| jt jj||fdd | jt jj||fd | jt jj||fd | jt jj||fd d S )Nr"   rG   rA   rF   rB   )r)   rL   viewZmatrixr:   r   outerr;   )r   r   mr   r   r   r  O  s    z!TestMatrixInOuter.test_deprecatedNr.   r<   r=   r   r  r   r   r   r   r*  J  s   r*  c                   @   s    e Zd ZdZdd Zdd ZdS )FlatteningConcatenateUnsafeCastz7concatenate with `axis=None` will use same-kind castingc              	   C   s4   | j tjdgdgfftd tjdtjddd d S )Nr        ?rG   rC   )axisoutr   )r:   r)   concatenater
  r"  r  r   r   r   r   r  \  s    z/FlatteningConcatenateUnsafeCast.test_deprecatedc              	   C   sl   | j tjdgdgffd tjdtjdddd tt* tjdgdgftjdtjddd	 W 5 Q R X d S )
Nr  r0  rG   rC   Zunsafe)r1  r2  castingr   Z	same_kind)r2  r4  )r;   r)   r3  r"  r  r   rZ   r   r   r   r   r  a  s    
z3FlatteningConcatenateUnsafeCast.test_not_deprecatedN)r.   r<   r=   r   r  r  r   r   r   r   r/  X  s   r/  c                   @   s$   e Zd ZeZdZdd Zdd ZdS )-TestDeprecateSubarrayDTypeDuringArrayCoercionz6(creating|casting) an array (with|to) a subarray dtypec              	      s   t ddg |  fdd tt  d}W 5 Q R X t|ddgddgg |  fdd tt t j dd}W 5 Q R X t|ddgddgg tt t jdd	g gdd}W 5 Q R X t|ddgddggddgddggg d S )
Nr"   rG   c                      s
     dS )N(2)i,)astyper   r'  r   r   rU   u  rV   zUTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_array.<locals>.<lambda>r6  c                      s   t j ddS )Nr6  rC   r)   rL   r   r'  r   r   rU   {  rV   rC   )r"   )rG   )r)   rL   r:   r|   warnsrX   r7  r   )r   r   r   r'  r   test_deprecated_arrayq  s     zCTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_arrayc                    sB   t ddd  fdd}| |  fdd}| | d S )Nr   r   rG   c                	      s$   t t  d W 5 Q R X d S )N(2,2)f)r|   raisesr   r7  r   r'  r   r   check  s    zVTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_error.<locals>.checkc                	      s(   t t tj dd W 5 Q R X d S )Nr;  rC   )r|   r<  r   r)   rL   r   r'  r   r   r=    s    )r)   rb   Zreshaper:   )r   r=  r   r'  r   test_deprecated_and_error  s
    
zGTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_errorN)r.   r<   r=   rX   r   r   r:  r>  r   r   r   r   r5  m  s   r5  c                   @   s   e Zd ZeZdZejddddgdd Z	ejddddgdd	 Z
ejddddgd
d Zejddddgdd Zejddddgdd ZdS )%TestFutureWarningArrayLikeNotIterablez,The input object of type.*but not a sequenceprotocolr[   Z__array_interface__Z__array_struct__c                    s6   t d}tdd|t||i |  fdd dS )a  Test 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 amended
              when this deprecation expired.
        r   MyArrr   c                      s   t j  gtdS NrC   r)   rL   rM   r   rA  r   r   rU     rV   zGTestFutureWarningArrayLikeNotIterable.test_deprecated.<locals>.<lambda>N)r)   rb   r	  getattrr:   )r   r@  	blueprintr   rD  r   r    s    
z5TestFutureWarningArrayLikeNotIterable.test_deprecatedc                    sl   t d}tdd|t||i}|  |  fdd t j gtd}t jdtd} |d< t|| d S )	Nr0  rA  r   c                      s   t j gtdS rB  rC  r   myarrr   r   rU     rV   zNTestFutureWarningArrayLikeNotIterable.test_0d_not_deprecated.<locals>.<lambda>rC   r"   r   )r)   rL   r	  rE  r;   rM   r"  r   )r   r@  rF  rA  r   expectedr   rG  r   test_0d_not_deprecated  s    
z<TestFutureWarningArrayLikeNotIterable.test_0d_not_deprecatedc                    sP   t d}tdd|t||i}|  |  fdd t  }t|| d S )Nr   rA  r   c                      s
   t  S r   r8  r   rG  r   r   rU     rV   zTTestFutureWarningArrayLikeNotIterable.test_unnested_not_deprecated.<locals>.<lambda>)r)   rb   r	  rE  r;   rL   r   )r   r@  rF  rA  r   r   rG  r   test_unnested_not_deprecated  s    

zBTestFutureWarningArrayLikeNotIterable.test_unnested_not_deprecatedc              	   C   s   t dd}tdd|t||ddd i}| }tjt| jd t 	|gg}W 5 Q R X |j
d	kslt|jdkszt|d
 dkstdS )zThe old code would actually use the dtype from the array, but
        then end up not using the array (for dimension discovery)
        r   f4rA  r   	__float__c                 S   s   dS N      ?r   _r   r   r   rU     rV   zSTestFutureWarningArrayLikeNotIterable.test_strange_dtype_handling.<locals>.<lambda>match)r"   r"   r   rO  N)r)   rb   r7  r	  rE  r|   r9  rX   r   rL   shaper-   rD   )r   r@  rF  rA  rH  r   r   r   r   test_strange_dtype_handling  s     zATestFutureWarningArrayLikeNotIterable.test_strange_dtype_handlingc                    s   t dd}tdd|t||ddd i}|  t jdtd	 fd
d}| | d  ksjtd  ksztd  kstd S )Nr   rL  rA  r   rM  c                 S   s   dS rN  r   rP  r   r   r   rU     rV   zVTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated.<locals>.<lambda>rA   rC   c                      s      gd d < d S r   r   r   rH  r   r   r   set  s    zQTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated.<locals>.setr   r"   rG   )	r)   rb   r7  r	  rE  r"  rM   r;   r-   )r   r@  rF  rA  rW  r   rV  r   test_assignment_not_deprecated  s     
zDTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecatedN)r.   r<   r=   rX   r   r   r|   r}   r   r  rJ  rK  rU  rX  r   r   r   r   r?    s,   


	
r?  c                   @   s   e Zd ZdZdZdd ZdS )"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.c                    s    t jjj |  fdd d S )Nc                      s    t ddS )NOr"   r   r   Zctorr   r   rU     rV   zDTestDeprecatedUnpickleObjectScalar.test_deprecated.<locals>.<lambda>)r)   coreZ
multiarrayr  r:   r   r   r[  r   r    s    
z2TestDeprecatedUnpickleObjectScalar.test_deprecatedN)r.   r<   r=   rp   r   r  r   r   r   r   rY    s   rY  r   z
Needs nosers   c                   @   s\   e Zd ZG dd deZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd ZdS )TestNoseDecoratorsDeprecatedc                   @   s   e Zd ZdS )z/TestNoseDecoratorsDeprecated.DidntSkipExceptionN)r.   r<   r=   r   r   r   r   DidntSkipException  s   r^  c                 C   s   dd }|  | d S )Nc                  S   s    t jjjdd } t| j d S )Nc                 S   s   d S r   r   )rS   rT   zr   r   r   	slow_func  s    zMTestNoseDecoratorsDeprecated.test_slow.<locals>._test_slow.<locals>.slow_func)r)   testingdecZslowr   )r`  r   r   r   
_test_slow
  s    
z:TestNoseDecoratorsDeprecated.test_slow.<locals>._test_slowrd   )r   rc  r   r   r   	test_slow	  s    z&TestNoseDecoratorsDeprecated.test_slowc                 C   s   dd }| j |dd d S )Nc                  S   sd   t jj dd } t jjddd }t jjddd }t| j t|j t|j  d S )	Nc                 S   s   d S r   r   rW   r   r   r   	f_default  s    zWTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_defaultTc                 S   s   d S r   r   rW   r   r   r   f_istest  s    zVTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_istestFc                 S   s   d S r   r   rW   r   r   r   f_isnottest  s    zYTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_isnottest)r)   ra  rb  Z	setastestr   Z__test__)re  rf  rg  r   r   r   _test_setastest  s    





zDTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastestrA   r   rd   )r   rh  r   r   r   test_setastest  s    z+TestNoseDecoratorsDeprecated.test_setastestc                    s    fdd} j |dd d S )Nc                     s   t jjd fdd} z| d W n4  jk
rD   tdY n t jk
rZ   Y nX t jjd fdd}z|d W n4  jk
r   Y n  t jk
r   td	Y nX d S )
NTc                    s
    j d S r   r^  rS   r   r   r   f1'  s    znTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcoded.<locals>.f1rO   Failed to skipFc                    s
    j d S r   rj  rk  r   r   r   f22  s    znTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcoded.<locals>.f2Skipped when not expected tor)   ra  rb  r~   r^  r+   r   	__class__)rl  rn  r   r   r   _test_skip_functions_hardcoded&  s     zbTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcodedrG   r   rd   )r   rr  r   r   r   test_skip_functions_hardcoded%  s    z:TestNoseDecoratorsDeprecated.test_skip_functions_hardcodedc                    s    fdd} j |dd d S )Nc                     s    fdd} t jj| fdd}zd |d W n4 jk
rT   tdY n t jk
rj   Y nX t jj| fdd	}zd
 |d W n4 jk
r   Y n  t jk
r   tdY nX d S )Nc                      s    dkS Nskip me!r   r   Z	skip_flagr   r   skip_tester@  s    zuTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.skip_testerc                    s
    j d S r   rj  rk  r   r   r   rl  C  s    zlTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.f1ru  rO   rm  c                    s
    j d S r   rj  rk  r   r   r   rn  O  s    zlTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.f2zfive is right out!ro  rp  )rw  rl  rn  r   rv  r   _test_skip_functions_callable?  s&    z`TestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callablerG   r   rd   )r   rx  r   r   r   test_skip_functions_callable>  s    z9TestNoseDecoratorsDeprecated.test_skip_functions_callablec                    s    fdd} j |dd d S )Nc                     s   t jjdddd } z| dD ]}q"W n t jk
rB   Y n
X tdt jjdd fd	d
}z|dD ]}qrW n4 t jk
r   tdY n  jk
r   Y nX d S )NTThis test is known to failc                 s   s   t | E d H  d S r   r   rk  r   r   r   g1^  s    zpTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.<locals>._test_skip_generators_hardcoded.<locals>.g1r   Failed to mark as known failureFThis test is NOT known to failc                 3   s   t | E d H   dd S NFAILr   r^  rk  r   r   r   g2j  s    zpTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.<locals>._test_skip_generators_hardcoded.<locals>.g2#Marked incorrectly as known failurer)   ra  rb  Zknownfailureifr   rq  r+   r^  )r|  jr  r   r   r   _test_skip_generators_hardcoded]  s"    
zdTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.<locals>._test_skip_generators_hardcodedrG   r   rd   )r   r  r   r   r   test_skip_generators_hardcoded\  s    z;TestNoseDecoratorsDeprecated.test_skip_generators_hardcodedc                    s    fdd} j |dd d S )Nc                     s    fdd} t jj| ddd }zd |dD ]}q2W n t jk
rR   Y n
X tdt jj| d	fd
d}zd |dD ]}qW n4 t jk
r   tdY n jk
r   Y nX d S )Nc                      s    dkS rt  r   r   rv  r   r   rw  z  s    zwTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.skip_testerrz  c                 s   s   t | E d H  d S r   r{  rk  r   r   r   r|  }  s    znTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.g1ru  r   r}  r~  c                 3   s   t | E d H   dd S r  r  rk  r   r   r   r    s    znTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.g2zdo not skipr  r  )rw  r|  r  r  r   rv  r   _test_skip_generators_callabley  s(    
zbTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callablerG   r   rd   )r   r  r   r   r   test_skip_generators_callablex  s    z:TestNoseDecoratorsDeprecated.test_skip_generators_callablec                 C   s   dd }| j |dd d S )Nc               	   S   s   t jjddd } t jj dd }t jj dd }t jj dd	 }tt|  |  tjdd
$ td tt	| tt| W 5 Q R X d S )NTc                   S   s   d S r   r   r   r   r   r   non_deprecated_func  s    zcTestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecated.<locals>.non_deprecated_funcc                  S   s   dd l } | jdtdd d S )Nr   zTEST: deprecated funcr"   r   r   r   r   r   r   deprecated_func  s    z_TestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecated.<locals>.deprecated_funcc                  S   s   dd l } | jddd td S Nr   ZAHHHHr"   r  )r   r   r   r  r   r   r   deprecated_func2  s    z`TestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecated.<locals>.deprecated_func2c                  S   s   dd l } | jddd d S r  )r   r   r  r   r   r   deprecated_func3  s    z`TestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecated.<locals>.deprecated_func3r   r   )
r)   ra  rb  
deprecatedr   r-   r   r   r   r   )r  r  r  r  r   r   r   _test_deprecated  s    









zFTestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecatedr   r   rd   )r   r  r   r   r   r    s    z,TestNoseDecoratorsDeprecated.test_deprecatedc                 C   s   dd }|  | d S )Nc                  S   sZ   t jjddddgdd } d}|  D ] }|d |dd    |d7 }q(t|d	k d S )
Nzbase, power, expected)r"   r"   r"   )rG   r"   rG   )rG   rG   r   c                 S   s   t | | |k d S r   )r   )basepowerrI  r   r   r   check_parametrize  s    zcTestNoseDecoratorsDeprecated.test_parametrize.<locals>._test_parametrize.<locals>.check_parametrizer   r"   rA   )r)   ra  rb  r   r   )r  r   testr   r   r   _test_parametrize  s    



zHTestNoseDecoratorsDeprecated.test_parametrize.<locals>._test_parametrizerd   )r   r  r   r   r   test_parametrize  s    z-TestNoseDecoratorsDeprecated.test_parametrizeN)r.   r<   r=   r+   r^  rd  ri  rs  ry  r  r  r  r  r   r   r   r   r]    s   	!"r]  c                   @   s   e Zd ZdZdd ZdS )TestSingleElementSignaturezThe use of a length 1c                 C   s    |  dd  |  dd  d S )Nc                   S   s   t jddddS )Nr"   rG   d)	signature)r)   r   r   r   r   r   rU     rV   z<TestSingleElementSignature.test_deprecated.<locals>.<lambda>c                   S   s   t jddt dfdS )Nr"   rG   rn   )sig)r)   r   rD   r   r   r   r   rU     rV   rd   r   r   r   r   r    s    z*TestSingleElementSignature.test_deprecatedNr.  r   r   r   r   r    s   r  c                   @   sj   e Zd ZeZedgjZej	
dddddgeddd	d
Zej	
dddddgeddddZdS )TestCtypesGetterr"   nameget_dataZ	get_shapeZget_stridesZget_as_parameterN)r  returnc                    s"   t | j| |  fdd d S )Nc                      s     S r   r   r   funcr   r   rU     rV   z2TestCtypesGetter.test_deprecated.<locals>.<lambda>)rE  ctypesr:   r   r  r   r  r   r    s    z TestCtypesGetter.test_deprecatedr   rT  stridesZ_as_parameter_c                    s     fdd d S )Nc                      s   t j S r   )rE  r  r   r  r   r   r   rU     rV   z6TestCtypesGetter.test_not_deprecated.<locals>.<lambda>r;   r  r   r  r   r    s    z$TestCtypesGetter.test_not_deprecated)r.   r<   r=   r>   r   r)   rL   r  r|   r}   r   r#   r  r  r   r   r   r   r    s    
 
r  r   c                 C   s   t t d| S Nr   )r)   	partitionrb   Zkthr   r   r   rU     rV   rU   c                 C   s   t t d| S r  )r)   argpartitionrb   r  r   r   r   rU     rV   )zpartition methodzargpartition methodzpartition functionzargpartition functionr  )idsc                   @   s$   e Zd ZeZdZdd Zdd ZdS )TestPartitionBoolIndexz1Passing booleans as partition index is deprecatedc                    s(   |   fdd |   fdd d S )Nc                      s    dS )NTr   r   r  r   r   rU     rV   z8TestPartitionBoolIndex.test_deprecated.<locals>.<lambda>c                      s    ddgS )NFTr   r   r  r   r   rU     rV   rd   r   r  r   r  r   r    s    z&TestPartitionBoolIndex.test_deprecatedc                    s(   |   fdd |   fdd d S )Nc                      s    dS r   r   r   r  r   r   rU     rV   z<TestPartitionBoolIndex.test_not_deprecated.<locals>.<lambda>c                      s    ddgS )Nr   r"   r   r   r  r   r   rU     rV   r  r  r   r  r   r    s    z*TestPartitionBoolIndex.test_not_deprecatedN)r.   r<   r=   r>   r   r   r  r  r   r   r   r   r    s   r  c                   @   s    e Zd ZeZdd Zdd ZdS )
TestMachArc                 C   s   |  dd  d S )Nc                   S   s   t tjdS NZmachar)rE  r)   r\  r   r   r   r   rU     rV   z3TestMachAr.test_deprecated_module.<locals>.<lambda>rd   r   r   r   r   test_deprecated_module  s    z!TestMachAr.test_deprecated_modulec                    s    t t |  fdd d S )Nc                      s
   t  dS r  )rE  r   finfor   r   rU     rV   z1TestMachAr.test_deprecated_attr.<locals>.<lambda>)r)   r  r   r:   r   r   r  r   test_deprecated_attr	  s    
zTestMachAr.test_deprecated_attrN)r.   r<   r=   r>   r   r  r  r   r   r   r   r    s   r  c                   @   sX   e Zd Zejdejejej	ej
gdd Zejdejejej	ej
gdd ZdS )$TestQuantileInterpolationDeprecationr  c                    s(   |   fdd |   fdd d S )Nc                      s    ddgdddS )Nr  r0  Zlinearinterpolationr   r   r  r   r   rU     rV   zFTestQuantileInterpolationDeprecation.test_deprecated.<locals>.<lambda>c                      s    ddgdddS )Nr  r0  nearestr  r   r   r  r   r   rU     rV   rd   r  r   r  r   r    s    

z4TestQuantileInterpolationDeprecation.test_deprecatedc              
   C   sN   t  < t dt tt |ddgdddd W 5 Q R X W 5 Q R X d S )Nr   r  r0  r  )r  method)r   r   r   r>   r|   r<  rZ   r  r   r   r   test_both_passed  s    
z5TestQuantileInterpolationDeprecation.test_both_passedN)r.   r<   r=   r|   r}   r   r)   Z
percentileZquantileZnanpercentileZnanquantiler  r  r   r   r   r   r    s   
r  c                   @   s   e Zd Zdd ZdS )TestMemEventHookc              	   C   sl   dd l m  m} tjtdd |  W 5 Q R X td}~t	  tjtdd |
  W 5 Q R X d S )Nr   z$PyDataMem_SetEventHook is deprecatedrR  i  )r   r\  Z_multiarray_testsr|   r9  r>   Z!test_pydatamem_seteventhook_startr)   rK   r   Ztest_pydatamem_seteventhook_end)r   Zma_testsrO   r   r   r   test_mem_seteventhook$  s    
z&TestMemEventHook.test_mem_seteventhookN)r.   r<   r=   r  r   r   r   r   r  "  s   r  c                   @   s   e Zd ZdZdd ZdS )TestArrayFinalizeNonez!Setting __array_finalize__ = Nonec                    s(   G dd dt j |  fdd d S )Nc                   @   s   e Zd ZdZdS )zETestArrayFinalizeNone.test_use_none_is_deprecated.<locals>.NoFinalizeN)r.   r<   r=   Z__array_finalize__r   r   r   r   
NoFinalize:  s   r  c                      s   t d S r   )r)   rL   r+  r   r  r   r   rU   =  rV   zCTestArrayFinalizeNone.test_use_none_is_deprecated.<locals>.<lambda>)r)   Zndarrayr:   r   r   r  r   test_use_none_is_deprecated8  s    z1TestArrayFinalizeNone.test_use_none_is_deprecatedN)r.   r<   r=   r   r  r   r   r   r   r  5  s   r  c                   @   s   e Zd ZdZdd ZdS )TestAxisNotMAXDIMSz)Using `axis=32` \(MAXDIMS\) is deprecatedc                    s    t d |  fdd d S )N) r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   r"   c                      s   t j dt jdS )Nr"   )r1  )r)   repeatZMAXDIMSr   rW   r   r   rU   E  rV   z4TestAxisNotMAXDIMS.test_deprecated.<locals>.<lambda>)r)   rK   r:   r   r   rW   r   r  C  s    
z"TestAxisNotMAXDIMS.test_deprecatedNr.  r   r   r   r   r  ?  s   r  c                   @   sH   e Zd ZdZejdejd dd Z	ejdejd dd Z
dS )	TestLoadtxtParseIntsViaFloatz;loadtxt\(\): Parsing an integer via a float is deprecated.*rD   
AllIntegerc              	   C   s0   t jt| jd tjdg|d W 5 Q R X d S )NrR  10.5rC   )r|   r9  r>   r   r)   loadtxt)r   rD   r   r   r   test_deprecated_warningQ  s    z4TestLoadtxtParseIntsViaFloat.test_deprecated_warningc                 C   sl   t  Z t dt ztjdg|d W n2 tk
r\ } zt|jtsLt	W 5 d }~X Y nX W 5 Q R X d S )Nr(   r  rC   )
r   r   r   r>   r)   r  r   
isinstance	__cause__r-   )r   rD   er   r   r   test_deprecated_raisedV  s    
z3TestLoadtxtParseIntsViaFloat.test_deprecated_raisedN)r.   r<   r=   r   r|   r}   r   r)   	typecodesr  r  r   r   r   r   r  H  s
   
r  c                   @   s,   e Zd ZdZejdejd dd Z	dS )TestPyIntConversionz,.*stop allowing conversion of out-of-bound.*rD   r  c              	      s   t t dd }dd }dd }|||fD ]d z|  fdd W n tk
rh   Y nX z|  fd	d W q6 tk
r   Y q6X q6d S )
Nc                 S   s   | |  d S r   )r	  valuerD   r   r   r   r  k  s    z:TestPyIntConversion.test_deprecated_scalar.<locals>.scalarc                 S   s    t jdddg|d}| |d< d S )Nr   rC   rG   r8  )r  rD   r   r   r   r   assignn  s    z:TestPyIntConversion.test_deprecated_scalar.<locals>.assignc                 S   s   t j| g|d d S rB  r8  r  r   r   r   creater  s    z:TestPyIntConversion.test_deprecated_scalar.<locals>.createc                      s    j d S r   )minr   Zcreation_funcrD   infor   r   rU   x  rV   z<TestPyIntConversion.test_deprecated_scalar.<locals>.<lambda>c                      s    j d S r   )maxr   r  r   r   rU   ~  rV   )r)   rD   Ziinfor:   OverflowError)r   rD   r  r  r  r   r  r   test_deprecated_scalard  s$    

z*TestPyIntConversion.test_deprecated_scalarN)
r.   r<   r=   r   r|   r}   r   r)   r  r  r   r   r   r   r  a  s   r  c                   @   s   e Zd Zdd ZdS )TestDeprecatedGlobalsc                 C   sX   |  dd  |  dd  |  dd  |  dd  |  dd  |  dd  d S )Nc                   S   s   t jS r   )r)   Zbool8r   r   r   r   rU     rV   z9TestDeprecatedGlobals.test_type_aliases.<locals>.<lambda>c                   S   s   t jS r   )r)   Zint0r   r   r   r   rU     rV   c                   S   s   t jS r   )r)   Zuint0r   r   r   r   rU     rV   c                   S   s   t jS r   )r)   Zbytes0r   r   r   r   rU     rV   c                   S   s   t jS r   )r)   Zstr0r   r   r   r   rU     rV   c                   S   s   t jS r   )r)   Zobject0r   r   r   r   rU     rV   rd   r   r   r   r   test_type_aliases  s    z'TestDeprecatedGlobals.test_type_aliasesN)r.   r<   r=   r  r   r   r   r   r    s   r  r  r   longZulongr#   bytesrM   c              	   C   sV   | t tksttjtd|  d tt| r4tW 5 Q R X t|  | tjk d S )NzIn the future .*rR  )	dirr)   r-   r|   r9  rX   hasattrrD   Z
sctypeDict)r  r   r   r   test_future_scalar_attributes  s    
r  )Prp   rx   rH   r   r|   r   r   sysZnumpyr)   Znumpy.testingr   r   r   r   r   r   r   r   r
   rv   r   ImportErrorr   r?   r@   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r$  r*  r/  r5  r?  rY  r   r   ZnoseZ	HAVE_NOSEr}   r~   r]  r  r  rb   r  r  ZPARTITION_DICTr   r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   s   $
lJ4
*V


 K	


	"