o
    1ήc                     @   sP  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yM   dZY nw 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,d3d4 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Z6G dGdH dHeZ7G dIdJ dJeZ8G dKdL dLeZ9G dMdN dNeZ:z e;  e<dO ddl=Z=W d   n	1 sw   Y  W n ey   dZ>Y nw dZ>ej?j@e> dPdQG dRdS dSeZAG dTdU dUeZBG dVdW dWeZCG dXdY dYeZDG dZd[ d[eZEG d\d] d]eZFe	Gd^jHe	Gd^jId_d` dad` dbZJej?jKdceJL eJddG dedf dfeZMG dgdh dheZNG didj djeZOG dkdl dleZPG dmdn dneZQG dodp dpeZRG dqdr dreZSdS )sz
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   I/tmp/pip-target-vg8gfxp4/lib/python/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   sv  d}g | j dd< |tju r| jf}z	||i | W n |r!tnt y)   Y nw d}	| j D ]}
|
j| ju r<|	d7 }	q/|sItd| jj|
jf q/|durm|	|krmdt	| j |f }dd | j D }td	
|g| t @ tjd
| j| jd z||i | |t krtdW n |y   |t krtdY n	w W d   dS W d   dS 1 sw   Y  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       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_othersfunction_fails
exceptionsargskwargs__tracebackhide__	num_foundwarningmsglstr   r   r   assert_deprecated4   s\   !






	"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)r3   r4   r6   r7   r8   N)r>   r-   )r   r2   r7   r8   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@   rA   r*   VisibleDeprecationWarningr   r   r   r   r   rC      s    
rC   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 ]I}| j|tdg fd tjddd}| j|||d d fd d tjdtg dgtd}tjdtg dgtd}| j|||fd d qd S )	N   r7   zi,idtyper7   r3   r"   r"      rF   )operatoreqner>   r*   zerosarrayobject)r   opabr   r   r   test_normal_types   s   z,TestComparisonDeprecations.test_normal_typesc                    sD   t ddg t g d}ttdd  | tt fdd d S )NrU   rV   )rU   rV   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   rU   r   r   r[      r\   )r*   rR   r   
ValueErrorr   FutureWarning)r   rV   r   r]   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 r   )	TypeErrorr   r   r   r   	__array__      zXTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.NotArray.__array__c                 S   s   t S r   )NotImplemented)r   otherr   r   r   __ne__   rc   zUTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.NotArray.__ne__N)r/   r@   rA   rb   rf   r   r   r   r   NotArray   s    rg   c                      s   t d  kS NrM   r*   aranger   rg   r   r   r[          zNTestComparisonDeprecations.test_void_dtype_equality_failures.<locals>.<lambda>c                      s   t d  kS rh   ri   r   rk   r   r   r[      rl   r>   r   r   rk   r   !test_void_dtype_equality_failures   s   z<TestComparisonDeprecations.test_void_dtype_equality_failuresc                 C   s8  t tdd  t tdd  t 3 td ttddk  ttddk ttddk  ttddk W d    n1 sHw   Y  t	dtdfD ]B}tj
ddd	}|dfD ]4}tjtjtjtjfD ]'}t }td
 tt||| t|  W d    n1 sw   Y  qpqdqWd S )Nc                   S   s   t ddkS NrM   rU   ri   r   r   r   r   r[          zTTestComparisonDeprecations.test_array_richcompare_legacy_weirdness.<locals>.<lambda>c                   S   s   t ddkS ro   ri   r   r   r   r   r[      rp   r)   r   rU   rM   zi4,i4rH   r   )r   r_   r   r   r   r   r*   rR   int16asarrayrQ   rN   ltlegtger   ra   )r   arg1structarg2flr   r   r   'test_array_richcompare_legacy_weirdness   s,   



zBTestComparisonDeprecations.test_array_richcompare_legacy_weirdnessN)	r/   r@   rA   __doc__r   rW   r`   rn   r|   r   r   r   r   rE      s    rE   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+01rG   )z2000-01-01T00Z)r>   r*   
datetime64r   r   r   r   r`      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   )tzinforG   )pytztimezonedatetimer>   r*   r   )r   tzdtr   r   r   test_datetime   s   
z$TestDatetime64Timezone.test_datetimeN)
r/   r@   rA   r}   r`   pytestmarkskipif	_has_pytzr   r   r   r   r   r~      s    
r~   c                   @      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.datarG   )r*   rj   linspacer   r>   __setattr__r   )r   rU   rV   r   r   r   test_data_attr_assignment   s   
zETestArrayDataAttributeAssignmentDeprecation.test_data_attr_assignmentN)r/   r@   rA   r}   r   r   r   r   r   r      s    r   c                   @       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   (   d}ddi}d| _ | jtj||d d S )N)r   widthrM   QInsufficient bit width provided. This behavior will raise an error in the future.r7   r8   r   r>   r*   binary_reprr   r7   r8   r   r   r    test_insufficient_width_positive     zZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_positivec                 C   r   )N)r   rM   r   r   r   r   r   r   r    test_insufficient_width_negative  r   zZTestBinaryReprInsufficientWidthParameterForRepresentation.test_insufficient_width_negativeN)r/   r@   rA   r}   r   r   r   r   r   r   r      s    r   c                   @   r   )$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                   @      e Zd ZdZdS )zZTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.dtf8Nr/   r@   rA   rI   r   r   r   r   r         r   c                   @   r   )z[TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.vdtzf,fNr   r   r   r   r   vdt   r   r   c                      
   t  S r   r*   rI   r   r   r   r   r[   #     
 z`TestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtype.<locals>.<lambda>c                      s   t   S r   r   r   r   r   r   r[   $      c                      r   r   r   r   r   r   r   r[   %  r   c                      s   t  dS Nr"   r   r   r   r   r   r[   &  rp   )r*   voidr>   r   r   )r   r   r   )test_deprecation_dtype_attribute_is_dtype  s   zNTestDTypeAttributeIsDTypeDeprecation.test_deprecation_dtype_attribute_is_dtypeN)r/   r@   rA   r   r   r   r   r   r   r         r   c                   @      e Zd Zdd ZdS )TestTestDeprecatedc                 C   s>   t  }|  tt|jdd  dd }|| |  d S )Nc                   S      d S r   r   r   r   r   r   r[   /      z;TestTestDeprecated.test_assert_deprecated.<locals>.<lambda>c                   S   s   t jdtdd d S )NfoorM   )r   
stacklevelr   warnrB   r   r   r   r   r   1     z6TestTestDeprecated.test_assert_deprecated.<locals>.foo)r   r   r   r.   r>   r!   )r   test_case_instancer   r   r   r   test_assert_deprecated*  s   
z)TestTestDeprecated.test_assert_deprecatedN)r/   r@   rA   r   r   r   r   r   r   )      r   c                   @   r   )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 q)d S )	N   y              @s2016M)r"   rM   rU   rV   )r*   rR   r?   	conjugateintr>   )r   rU   r   r   r   test_conjugate=  s   z&TestNonNumericConjugate.test_conjugateN)r/   r@   rA   r}   r   r   r   r   r   r   8  s    r   c                   @   r   )TestNPY_CHARc                 C   s(   ddl m} | | t| dk d S )Nr   )npy_char_deprecation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@   rA   r   r   r   r   r   r   E      r   c                   @   r   )TestPyArray_AS1Dc                 C      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     z1TestPyArray_AS1D.test_npy_pyarrayas1d_deprecationN)r/   r@   rA   r   r   r   r   r   r   M  r   r   c                   @   r   )TestPyArray_AS2Dc                 C   r   )Nr   )npy_pyarrayas2d_deprecation)r   r   r   r   )r   r   r   r   r    test_npy_pyarrayas2d_deprecationT  r   z1TestPyArray_AS2D.test_npy_pyarrayas2d_deprecationN)r/   r@   rA   r   r   r   r   r   r   S  r   r   c                   @   r   )TestDatetimeEventc                 C   sj   t jt jfD ],}| j|dd | j|dd | j|dd | j|dd | j|dd | j|dd qd S )N)r"   )msrM   rG   )r"   )r   rM   r"   N)r"   )r   rM   event)r"   )r   rM   ?   )r"   )r   rM   r"   r   )r"   )r   rM   r"   r   )r*   r   timedelta64r?   r>   )r   clsr   r   r   test_3_tuple[  s   zTestDatetimeEvent.test_3_tupleN)r/   r@   rA   r   r   r   r   r   r   Y  r   r   c                   @   r   )TestTruthTestingEmptyArraysz..*truth value of an empty array is ambiguous.*c                 C   s   | j ttg fd d S NrG   )r>   boolr*   rR   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   rG   )r   r"   r   r   )r>   r   r*   rQ   r   r   r   r   test_2dp  s   z#TestTruthTestingEmptyArrays.test_2dN)r/   r@   rA   r   r   r   r   r   r   r   r   i  s    r   c                   @   r   )TestBincountc                 C      |  dd  d S )Nc                   S   s   t jg dd dS )NrL   )	minlength)r*   bincountr   r   r   r   r[   y      z6TestBincount.test_bincount_minlength.<locals>.<lambda>rm   r   r   r   r   test_bincount_minlengthx     z$TestBincount.test_bincount_minlengthN)r/   r@   rA   r   r   r   r   r   r   v  r   r   c                   @   r   )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   rG   )r>   r*   sumranger   r   r   r   test_generator_sum  s   $z#TestGeneratorSum.test_generator_sumN)r/   r@   rA   r   r   r   r   r   r   }  r   r   c                   @   r   )TestPositiveOnNonNumericalc                 C   s   | j tjtdfd d S )Nr   rG   )r>   rN   posr*   rR   r   r   r   r   test_positive_on_non_number  s   z6TestPositiveOnNonNumerical.test_positive_on_non_numberN)r/   r@   rA   r   r   r   r   r   r     r   r   c                   @   r   )TestFromstringc                 C   s   | j tjdd d S )N)zP                                                                                rG   )r>   r*   
fromstringr   r   r   r   test_fromstring  r   zTestFromstring.test_fromstringN)r/   r@   rA   r   r   r   r   r   r     r   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_datainvalid_sepc              	      s   t jg dtd}tjddf |j ddd  |  d |  fd	d
  d |  fdd
 t	
   t	dt  d t j ddd}t|| W d    n1 s`w   Y  W d    d S W d    d S 1 sxw   Y  d S )Ng)\(?rM   gGz@   rH   r%   mode,z%.2f)sepformatr   c                         t j ddS Nr   )r   r*   fromfiler   rz   r   r   r[     rp   zVTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_file.<locals>.<lambda>c                         t j dddS Nr   r   r   countr   r   r  r   r   r[     rl   r)   r   r  )r*   rR   floattempfileTemporaryFiletofilewriteseekr>   r   r   simplefilterrB   r  r   r   r   rY   resr   r  r   #test_deprecate_unparsable_data_file  s"   




	"zDTestFromStringAndFileInvalidData.test_deprecate_unparsable_data_filec                    s   t jg dtd}d|| fdd | fdd d |  fdd tt t jd	d
d}t	|d d | W d    n1 sNw   Y  t
  t
dt t jd	dd}t	|| W d    d S 1 svw   Y  d S )Nr   rH   z1.51,2,3.51,4{}c                      r   r   r*   r   r   x_strr   r   r[     rp   zSTestFromStringAndFileInvalidData.test_deprecate_unparsable_string.<locals>.<lambda>c                      r  r  r  r   r  r   r   r[     rl   asciic                      s   t  S r   r	   r   )bytestrr   r   r[     r\   r   r   r  rJ   r)   r   )r*   rR   r  r   r>   encoder   rB   r   r   r   r   r  r  r   )r  r  r    test_deprecate_unparsable_string  s   



"zATestFromStringAndFileInvalidData.test_deprecate_unparsable_stringN)	r/   r@   rA   r   r   r   parametrizer  r  r   r   r   r   r     s    
r   c                   @   r   )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_numericopsrM   r3   )r8   abc)add)r   r  r>   r*   set_numeric_opsr   r^   )r   r  r   r   r   test_get_numeric_ops  s   z+Test_GetSet_NumericOps.test_get_numeric_opsN)r/   r@   rA   r  r   r   r   r   r    r   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 )NrU   r"   rG   )r>   r*   rI   r   r   r   r   r   test_shape_1_fields  s   z$TestShape1Fields.test_shape_1_fieldsN)r/   r@   rA   r_   r   r!  r   r   r   r   r     s    r   c                   @   r   )TestNonZeroc                 C       |  dd  |  dd  d S )Nc                   S      t t dS )Nr   r*   nonzerorR   r   r   r   r   r[     rl   z(TestNonZero.test_zerod.<locals>.<lambda>c                   S   r$  r   r%  r   r   r   r   r[     rl   rm   r   r   r   r   
test_zerod     zTestNonZero.test_zerodN)r/   r@   rA   r'  r   r   r   r   r"    r   r"  c                  C   sF   dddgg} t tj t|  W d    d S 1 sw   Y  d S )Nr"   rM   rF   )r   r*   rD   rR   )argr   r   r   test_deprecate_ragged_arrays  s   "r*  c                   @   s   e Zd ZedZdd ZdS )TestTooDeepDeprecationz3Creating an ndarray from nested sequences exceedingc                 C   sd   dg}t tjd D ]}|g}q
| jtj|fd | jtj|fttdd | jtj|gfd d S )Nr"   rG   rH   r   )r   r*   MAXDIMSr?   rR   dictrS   r>   )r   nestedr   r   r   r   test_deprecation  s   z'TestTooDeepDeprecation.test_deprecationN)r/   r@   rA   reescaper   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   testrH   )r*   rR   listuint8r>   tostring)r   arrr   r   r   test_tostring  s   zTestToString.test_tostringc                 C   s\   t jtdt jd}| }tt | }W d    n1 s!w   Y  ||ks,J d S r3  )r*   rR   r4  r5  tobytesr   rB   r6  )r   r7  rV   r   r   r   r   test_tostring_matches_tobytes  s   

z*TestToString.test_tostring_matches_tobytesN)r/   r@   rA   r0  r1  r   r8  r:  r   r   r   r   r2    s    
r2  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*   rI   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*   rR   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 qd S r   )	r*   sctypesvaluesr?   rI   typer-  r4  r-   )r   groupr>  r   r   r   test_not_deprecated  s   z%TestDTypeCoercion.test_not_deprecatedN)r/   r@   rA   r   r*   genericflexiblenumberinexactfloatingcomplexfloatingintegerunsignedintegersignedinteger	characterr<  r?  r@  rE  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   P   | j D ]"}|d}| jt|fd | jt|dfd | jt|fddid qd S Nr   rG   ndigitsr   )r<  r>   roundr   r>  scalarr   r   r   test_deprecated2     
z(BuiltInRoundComplexDType.test_deprecatedc                 C   rQ  rR  )not_deprecated_typesr?   rT  rU  r   r   r   rE  9  rX  z,BuiltInRoundComplexDType.test_not_deprecatedN)r/   r@   rA   r*   csinglecdoubleclongdoubler<  int8rq   int32int64r5  uint16uint32uint64float16float32float64rY  rW  rE  r   r   r   r   rP  )  s    rP  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.*indexrF   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)rM   rM   r   rG           )rM   rM   r"   r   )r*   onesr>   __getitem____setitem__slice)r   rg  r7  arr2index2r   r   r   test_empty_subspaceE  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)rM   rM   rM   rF   rM   rG   )rM   r   rM   )r*   ri  r?   rj  rk  empty)r   r7  rg  r   r   r   )test_empty_index_broadcast_not_deprecatedS  s   

zSTestIncorrectAdvancedIndexWithEmptyResult.test_empty_index_broadcast_not_deprecatedN)	r/   r@   rA   r   r   r   r  ro  rq  r   r   r   r   rf  A  s
    "
rf  c                   @   r   )TestNonExactMatchDeprecationc                    s>   t g dg dg |  fdd |  fdd d S )N)rF      rs  )r   r   r"   c                      r  )N)   rs  Cilpr   )r*   ravel_multi_indexr   r7  r   r   r[   a  rl   zCTestNonExactMatchDeprecation.test_non_exact_match.<locals>.<lambda>c                      s   t j d dddS )Nr   r   Random)side)r*   searchsortedr   rw  r   r   r[   c  r'   )r*   rR   r>   r   r   rw  r   test_non_exact_match^  s   z1TestNonExactMatchDeprecation.test_non_exact_matchN)r/   r@   rA   r{  r   r   r   r   rr  \  r   rr  c                   @   r   )TestDeprecatedGlobalsc                 C   s   |  dd  |  dd  |  dd  |  dd  |  dd  |  dd  |  dd  |  d	d  |  d
d  d S )Nc                   S   
   t dS NT)r*   r   r   r   r   r   r[   j  r   z9TestDeprecatedGlobals.test_type_aliases.<locals>.<lambda>c                   S   r}  r   )r*   r   r   r   r   r   r[   k  r   c                   S   r}  r   )r*   r  r   r   r   r   r[   l  r   c                   S   r}  r   )r*   complexr   r   r   r   r[   m  r   c                   S   s   t  S r   )r*   rS   r   r   r   r   r[   n  r\   c                   S   r}  Nr  )r*   r#   r   r   r   r   r[   o  r   c                   S   r}  r   )r*   longr   r   r   r   r[   r  r   c                   S   r}  r  )r*   unicoder   r   r   r   r[   s  r   c                   S      t jS r   )r*   typeDictr   r   r   r   r[   v      rm   r   r   r   r   test_type_aliasesh  s   z'TestDeprecatedGlobals.test_type_aliasesN)r/   r@   rA   r  r   r   r   r   r|  f  r   r|  c                   @   r   )TestMatrixInOuterzCadd.outer\(\) was passed a numpy matrix as (first|second) argument.c                 C   s   t g d}t g d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 )NrL   rM   rK   rG   )r*   rR   viewmatrixr>   r  outerr?   )r   r7  mr   r   r   rW  ~  s   z!TestMatrixInOuter.test_deprecatedNr/   r@   rA   r   rW  r   r   r   r   r  y  s    r  c                   @   r   )TestRaggedArrayz(setting an array element with a sequencec                    sV   t d |  fdd |  fdd |  fdd |  fdd d S )Nr"   r"   c                      s   t j dgt jdS Nr   rH   r*   rR   re  r   rw  r   r   r[     r'   z1TestRaggedArray.test_deprecated.<locals>.<lambda>c                      s   t jd gt jdS r  r  r   rw  r   r   r[     r'   c                      s   t j dggt jdS r  r  r   rw  r   r   r[         c                      s   t jdg gt jdS r  r  r   rw  r   r   r[     r  )r*   ri  r>   r   r   rw  r   rW    s
   
zTestRaggedArray.test_deprecatedNr  r   r   r   r   r    r   r  c                   @   r   )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 )Nrh        ?rM   rH   )axisoutr   )r>   r*   concatenater-  rp  r_  r   r   r   r   rW    s   
z/FlatteningConcatenateUnsafeCast.test_deprecatedc                 C   s   | 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 d    d S 1 s:w   Y  d S )
Nrh  r  rM   rH   unsafe)r  r  castingr   	same_kind)r  r  )r?   r*   r  rp  r_  r   ra   r   r   r   r   rE    s   
"z3FlatteningConcatenateUnsafeCast.test_not_deprecatedNr/   r@   rA   r   rW  rE  r   r   r   r   r        r  c                   @   $   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                    s4  t ddg |  fdd tt  d}W d    n1 s%w   Y  t|ddgddgg |  fdd tt t j dd}W d    n1 sUw   Y  t|ddgddgg tt t jdd	g gdd}W d    n1 sw   Y  t|ddgddggddgddggg d S )
Nr"   rM   c                      s
     dS )N(2)i,)astyper   rw  r   r   r[     r   zUTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_array.<locals>.<lambda>r  c                      r   )Nr  rH   r*   rR   r   rw  r   r   r[     rp   rH   )r"   )rM   )r*   rR   r>   r   warnsr_   r  r   )r   r  r   rw  r   test_deprecated_array  s   *zCTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_arrayc                    sB   t ddd  fdd}| |  fdd}| | d S )Nr   r   rM   c                      s:   t t  d W d    d S 1 sw   Y  d S )N(2,2)f)r   raisesr^   r  r   rw  r   r   check  s   "zVTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_error.<locals>.checkc                      s>   t t tj dd W d    d S 1 sw   Y  d S )Nr  rH   )r   r  r^   r*   rR   r   rw  r   r   r    s   ")r*   rj   reshaper>   )r   r  r   rw  r   test_deprecated_and_error  s
   
zGTestDeprecateSubarrayDTypeDuringArrayCoercion.test_deprecated_and_errorN)r/   r@   rA   r_   r   r   r  r  r   r   r   r   r    s
    r  c                   @   s   e Zd ZeZdZejdg ddd Z	ejdg ddd Z
ejdg ddd	 Zejdg dd
d Zejdg ddd ZdS )%TestFutureWarningArrayLikeNotIterablez,The input object of type.*but not a sequenceprotocol)rb   __array_interface____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 NrH   r*   rR   rS   r   r  r   r   r[     r   zGTestFutureWarningArrayLikeNotIterable.test_deprecated.<locals>.<lambda>N)r*   rj   rC  getattrr>   )r   r  	blueprintr   r  r   rW    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 )	Nr  r  r   c                      s   t j gtdS r  r  r   myarrr   r   r[     rl   zNTestFutureWarningArrayLikeNotIterable.test_0d_not_deprecated.<locals>.<lambda>rH   r"   r   )r*   rR   rC  r  r?   rS   rp  r   )r   r  r  r  r  expectedr   r  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   r  r   c                      r   r   r  r   r  r   r   r[     r   zTTestFutureWarningArrayLikeNotIterable.test_unnested_not_deprecated.<locals>.<lambda>)r*   rj   rC  r  r?   rR   r   )r   r  r  r  r  r   r  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 d	   n1 s4w   Y  |j
d
ks@J |jdksGJ |d dksOJ 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   f4r  r   	__float__c                 S      dS N      ?r   _r   r   r   r[   
  r   zSTestFutureWarningArrayLikeNotIterable.test_strange_dtype_handling.<locals>.<lambda>matchNr  r   r  )r*   rj   r  rC  r  r   r  r_   r   rR   shaperI   )r   r  r  r  r  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  u s5J d  u s=J d  u sEJ d S )Nr   r  r  r   r  c                 S   r  r  r   r  r   r   r   r[     r   zVTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated.<locals>.<lambda>rF   rH   c                      s      gd d < d S r   r   r   r  r  r   r   set"  s   zQTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecated.<locals>.setr   r"   rM   )r*   rj   r  rC  r  rp  rS   r?   )r   r  r  r  r  r   r  r   test_assignment_not_deprecated  s   
zDTestFutureWarningArrayLikeNotIterable.test_assignment_not_deprecatedN)r/   r@   rA   r_   r   r   r   r   r  rW  r  r  r  r  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   ctorr   r   r[   5  rl   zDTestDeprecatedUnpickleObjectScalar.test_deprecated.<locals>.<lambda>)r*   core
multiarrayrV  r>   r   r   r  r   rW  3     
z2TestDeprecatedUnpickleObjectScalar.test_deprecatedN)r/   r@   rA   r}   r   rW  r   r   r   r   r  *  s    r  r   z
Needs noser   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@   rA   r   r   r   r   DidntSkipExceptionC  s    r  c                 C      dd }|  | d S )Nc                  S   s    t jjjdd } t| j d S )Nc                 S   r   r   r   )rY   rZ   zr   r   r   	slow_funcH     zMTestNoseDecoratorsDeprecated.test_slow.<locals>._test_slow.<locals>.slow_func)r*   testingdecslowr   )r  r   r   r   
_test_slowG  s   
z:TestNoseDecoratorsDeprecated.test_slow.<locals>._test_slowrm   )r   r  r   r   r   	test_slowF  s   z&TestNoseDecoratorsDeprecated.test_slowc                 C      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   r   r   r   r]   r   r   r   	f_defaultQ  r  zWTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_defaultTc                 S   r   r   r   r]   r   r   r   f_istestU  r  zVTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_istestFc                 S   r   r   r   r]   r   r   r   f_isnottestY  r  zYTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastest.<locals>.f_isnottest)r*   r  r  	setastestr   __test__)r  r  r  r   r   r   _test_setastestP  s   





zDTestNoseDecoratorsDeprecated.test_setastest.<locals>._test_setastestrF   r  rm   )r   r  r   r   r   test_setastestO  s   z+TestNoseDecoratorsDeprecated.test_setastestc                        fdd} j |dd d S )Nc                     s   t jjd fdd} z| d W n  jy   td t jy)   Y nw t jjd fdd}z|d W d S   jyI   Y d S  t jyU   td	w )
NTc                        j r   r  rY   r   r   r   f1d     znTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcoded.<locals>.f1rU   Failed to skipFc                    r  r   r  r  r   r   r   f2o  r  znTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcoded.<locals>.f2Skipped when not expected tor*   r  r  r   r  r,   r   	__class__)r  r  r   r   r   _test_skip_functions_hardcodedc  s$   zbTestNoseDecoratorsDeprecated.test_skip_functions_hardcoded.<locals>._test_skip_functions_hardcodedrM   r  rm   )r   r  r   r   r   test_skip_functions_hardcodedb  s   z:TestNoseDecoratorsDeprecated.test_skip_functions_hardcodedc                    r  )Nc                     s    fdd} t jj| fdd}zd |d W n jy'   td t jy1   Y nw t jj| fdd	}z	d
 |d W d S  jyS   Y d S  t jy_   tdw )Nc                          dkS Nskip me!r   r   	skip_flagr   r   skip_tester}     zuTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.skip_testerc                    r  r   r  r  r   r   r   r    r  zlTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.f1r  rU   r  c                    r  r   r  r  r   r   r   r    r  zlTestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callable.<locals>.f2zfive is right out!r  r  )r  r  r  r   r  r   _test_skip_functions_callable|  s*   z`TestNoseDecoratorsDeprecated.test_skip_functions_callable.<locals>._test_skip_functions_callablerM   r  rm   )r   r  r   r   r   test_skip_functions_callable{  s   z9TestNoseDecoratorsDeprecated.test_skip_functions_callablec                    r  )Nc                     s   t jjdddd } z| dD ]}qW td t jy#   Y nw t jjdd fd	d
}z
|dD ]}q7W d S  t jyI   td  jyS   Y d S w )NTThis test is known to failc                 s       t | E d H  d S r   r   r  r   r   r   g1     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       t | E d H   dNFAILr   r  r  r   r   r   g2     
zpTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.<locals>._test_skip_generators_hardcoded.<locals>.g2#Marked incorrectly as known failurer*   r  r  knownfailureifr   r  r,   r  )r  jr   r   r   r   _test_skip_generators_hardcoded  s*   
zdTestNoseDecoratorsDeprecated.test_skip_generators_hardcoded.<locals>._test_skip_generators_hardcodedrM   r  rm   )r   r  r   r   r   test_skip_generators_hardcoded  s   z;TestNoseDecoratorsDeprecated.test_skip_generators_hardcodedc                    r  )Nc                     s    fdd} t jj| ddd }zd |dD ]}qW td t jy+   Y nw t jj| d	fd
d}zd |dD ]}qAW d S  t jyS   td jy]   Y d S w )Nc                      r  r  r   r   r  r   r   r    r  zwTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.skip_testerr  c                 s   r  r   r  r  r   r   r   r    r  znTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.g1r  r   r  r  c                 3   r  r  r  r  r   r   r   r     r  znTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callable.<locals>.g2zdo not skipr  r  )r  r  r  r   r   r  r   _test_skip_generators_callable  s0   
zbTestNoseDecoratorsDeprecated.test_skip_generators_callable.<locals>._test_skip_generators_callablerM   r  rm   )r   r  r   r   r   test_skip_generators_callable  s   z:TestNoseDecoratorsDeprecated.test_skip_generators_callablec                 C   r  )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 d    d S 1 sRw   Y  d S )NTc                   S   r   r   r   r   r   r   r   non_deprecated_func  r  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Nr   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*   r  r  
deprecatedr   r.   r   r   r  r^   )r
  r  r  r  r   r   r   _test_deprecated  s   









"zFTestNoseDecoratorsDeprecated.test_deprecated.<locals>._test_deprecatedr   r  rm   )r   r  r   r   r   rW    s   z,TestNoseDecoratorsDeprecated.test_deprecatedc                 C   r  )Nc                  S   sX   t jjdg ddd } d}|  D ]}|d |dd    |d7 }qt|dk d S )Nzbase, power, expected))r"   r"   r"   )rM   r"   rM   )rM   rM   r   c                 S   s   t | | |k d S r   )r   )basepowerr  r   r   r   check_parametrize  s   zcTestNoseDecoratorsDeprecated.test_parametrize.<locals>._test_parametrize.<locals>.check_parametrizer   r"   rF   )r*   r  r  r  r   )r  r  testr   r   r   _test_parametrize  s   



zHTestNoseDecoratorsDeprecated.test_parametrize.<locals>._test_parametrizerm   )r   r  r   r   r   test_parametrize  s   z-TestNoseDecoratorsDeprecated.test_parametrizeN)r/   r@   rA   r,   r  r  r  r  r  r  r	  rW  r  r   r   r   r   r  A  s    	!"r  c                   @   r   )TestSingleElementSignaturezThe use of a length 1c                 C   r#  )Nc                   S      t jddddS )Nr"   rM   d)	signaturer*   r  r   r   r   r   r[     rl   z<TestSingleElementSignature.test_deprecated.<locals>.<lambda>c                   S   s   t jddt dfdS )Nr"   rM   r{   sig)r*   r  rI   r   r   r   r   r[     s    rm   r   r   r   r   rW    r(  z*TestSingleElementSignature.test_deprecatedNr  r   r   r   r   r    r   r  c                   @   r   )TestComparisonBadDTypez0using `dtype=` in comparisons is only useful forc                 C   r#  )Nc                   S   s   t jddt jdS Nr"   rH   )r*   equalr_  r   r   r   r   r[     r   z8TestComparisonBadDType.test_deprecated.<locals>.<lambda>c                   S   s   t jddddS )Nr"   )NNr{   r  )r*   r#  r   r   r   r   r[     rl   rm   r   r   r   r   rW    s   z&TestComparisonBadDType.test_deprecatedc                 C   s:   t jddtd t jddtdd t jd gdgtd d S )	NTFrH   rF   r   r  )rI   r  r   )r*   r#  r   rS   r   r   r   r   rE    s   z*TestComparisonBadDType.test_not_deprecatedNr  r   r   r   r   r!    r  r!  c                   @   s   e Zd ZdZeZdd ZdS )TestComparisonBadObjectDTypez5using `dtype=object` \(or equivalent signature\) willc                 C   r#  )Nc                   S   s   t jddtdS r"  r*   r#  rS   r   r   r   r   r[   )  rl   z>TestComparisonBadObjectDType.test_deprecated.<locals>.<lambda>c                   S   s   t jddd d tfdS )Nr"   r  r%  r   r   r   r   r[   +  r  rm   r   r   r   r   rW  (  s   z,TestComparisonBadObjectDType.test_deprecatedN)r/   r@   rA   r   r_   r   rW  r   r   r   r   r$  #  s    r$  c                   @   sf   e Zd ZeZedgjZej	
dg ddeddfddZej	
dg ddeddfd	d
ZdS )TestCtypesGetterr"   name)get_data	get_shapeget_stridesget_as_parameterreturnNc                    s"   t | j| |  fdd d S )Nc                      s     S r   r   r   funcr   r   r[   8  r  z2TestCtypesGetter.test_deprecated.<locals>.<lambda>)r  ctypesr>   r   r'  r   r-  r   rW  3  s   z TestCtypesGetter.test_deprecated)r   r  strides_as_parameter_c                    s     fdd d S )Nc                      s   t j S r   )r  r/  r   r'  r   r   r   r[   >  r   z6TestCtypesGetter.test_not_deprecated.<locals>.<lambda>r?   r0  r   r3  r   rE  :  s   z$TestCtypesGetter.test_not_deprecated)r/   r@   rA   rB   r   r*   rR   r/  r   r   r  r#   rW  rE  r   r   r   r   r&  .  s    r&  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestUFuncForcedDTypeWarningz?The `dtype` and `signature` arguments to ufuncs only select thec                    sD   dd l }td}||| | usJ |  fdd d S )Nr   r_  c                      s   t jdd dS )NrF   r   rH   r  r   int64_2r   r   r[   K  rl   zATestUFuncForcedDTypeWarning.test_not_deprecated.<locals>.<lambda>)pickler*   rI   loadsdumpsr?   )r   r8  r_  r   r6  r   rE  D  s
   
z/TestUFuncForcedDTypeWarning.test_not_deprecatedc                    s.   t d |  fdd | dd  d S )Nr_  c                      s   t jdd  dS )NrF   r   rH   )r*   r  newbyteorderr   r_  r   r   r[   O  r'   z>TestUFuncForcedDTypeWarning.test_deprecation.<locals>.<lambda>c                   S   r  )NrF   r   m8[ns]rH   r  r   r   r   r   r[   P  rl   )r*   rI   r>   r   r   r<  r   r/  M  s   
z,TestUFuncForcedDTypeWarning.test_deprecationc                 C   sb  t d}t jddd}tjt| jd t jdd| d W d    n1 s)w   Y  tjt| jd t jdddd W d    n1 sIw   Y  tjt| jd t j||dd W d    n1 siw   Y  tjt| jd t j	||dd W d    n1 sw   Y  tjt| jd t j	j
|dd W d    d S 1 sw   Y  d S )	Nr_  r   zm8[s]rH   r  rF   r   r=  )r*   rI   rj   r   r  rB   r   r  r;  maximumreduce)r   r_  r7  r   r   r   test_behaviourR  s"   
"z*TestUFuncForcedDTypeWarning.test_behaviourN)r/   r@   rA   r   rE  r/  r@  r   r   r   r   r5  A  s
    	r5  r   c                 C      t t d| S Nr   )r*   	partitionrj   kthr   r   r   r[   e  r   r[   c                 C   rA  rB  )r*   argpartitionrj   rD  r   r   r   r[   f  r   )zpartition methodzargpartition methodzpartition functionzargpartition functionr.  )idsc                   @   r  )TestPartitionBoolIndexz1Passing booleans as partition index is deprecatedc                    (   |   fdd |   fdd d S )Nc                          dS r~  r   r   r-  r   r   r[   q  r\   z8TestPartitionBoolIndex.test_deprecated.<locals>.<lambda>c                          ddgS )NFTr   r   r-  r   r   r[   r  r   rm   r   r.  r   r-  r   rW  p     z&TestPartitionBoolIndex.test_deprecatedc                    rI  )Nc                      rJ  r   r   r   r-  r   r   r[   u  r\   z<TestPartitionBoolIndex.test_not_deprecated.<locals>.<lambda>c                      rK  )Nr   r"   r   r   r-  r   r   r[   v  r   r4  rL  r   r-  r   rE  t  rM  z*TestPartitionBoolIndex.test_not_deprecatedN)r/   r@   rA   rB   r   r   rW  rE  r   r   r   r   rH  j  s
    rH  c                   @   s(   e Zd ZeZdd Zdd Zdd ZdS )
TestMachArc                 C   r   )Nc                   S   r  r   )r*   MachArr   r   r   r   r[   ~  r  z,TestMachAr.test_deprecated.<locals>.<lambda>rm   r   r   r   r   rW  }  r   zTestMachAr.test_deprecatedc                 C   r   )Nc                   S   s   t tjdS Nmachar)r  r*   r  r   r   r   r   r[     r   z3TestMachAr.test_deprecated_module.<locals>.<lambda>rm   r   r   r   r   test_deprecated_module  r   z!TestMachAr.test_deprecated_modulec                    s    t t |  fdd d S )Nc                      s
   t  dS rP  )r  r   finfor   r   r[     r   z1TestMachAr.test_deprecated_attr.<locals>.<lambda>)r*   rT  r  r>   r   r   rS  r   test_deprecated_attr  r  zTestMachAr.test_deprecated_attrN)r/   r@   rA   rB   r   rW  rR  rU  r   r   r   r   rN  y  s
    rN  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                    rI  )Nc                          ddgdddS )Nrh  r  linearinterpolationr   r   r-  r   r   r[     r   zFTestQuantileInterpolationDeprecation.test_deprecated.<locals>.<lambda>c                      rW  )Nrh  r  nearestrY  r   r   r-  r   r   r[     r   rm   rL  r   r-  r   rW    s   

z4TestQuantileInterpolationDeprecation.test_deprecatedc              	   C   s   t  6 t dt tt |ddgdddd W d    n1 s%w   Y  W d    d S W d    d S 1 s=w   Y  d S )Nr   rh  r  r[  )rZ  method)r   r   r  rB   r   r  ra   rL  r   r   r   test_both_passed  s   
"z5TestQuantileInterpolationDeprecation.test_both_passedN)r/   r@   rA   r   r   r  r*   
percentilequantilenanpercentilenanquantilerW  r]  r   r   r   r   rV    s    
rV  c                   @   r   )TestMemEventHookc                 C   s   dd l m  m} tjtdd |  W d    n1 sw   Y  td}~t	  tjtdd |
  W d    d S 1 sDw   Y  d S )Nr   z$PyDataMem_SetEventHook is deprecatedr  i  )r   r  _multiarray_testsr   r  rB   !test_pydatamem_seteventhook_startr*   rQ   r   test_pydatamem_seteventhook_end)r   ma_testsrU   r   r   r   test_mem_seteventhook  s   


"z&TestMemEventHook.test_mem_seteventhookN)r/   r@   rA   rg  r   r   r   r   rb    r   rb  c                   @   r   )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@   rA   __array_finalize__r   r   r   r   
NoFinalize  r   rj  c                      s   t d S r   )r*   rR   r  r   rj  r   r   r[     rl   zCTestArrayFinalizeNone.test_use_none_is_deprecated.<locals>.<lambda>)r*   ndarrayr>   r   r   rk  r   test_use_none_is_deprecated  s   z1TestArrayFinalizeNone.test_use_none_is_deprecatedN)r/   r@   rA   r   rm  r   r   r   r   rh    s    rh  c                   @   r   )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"   )r  )r*   repeatr,  r   r]   r   r   r[     r   z4TestAxisNotMAXDIMS.test_deprecated.<locals>.<lambda>)r*   rQ   r>   r   r   r]   r   rW    r  z"TestAxisNotMAXDIMS.test_deprecatedNr  r   r   r   r   rn    r   rn  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.*rI   
AllIntegerc                 C   sF   t jt| jd tjdg|d W d    d S 1 sw   Y  d S )Nr  10.5rH   )r   r  rB   r   r*   loadtxt)r   rI   r   r   r   test_deprecated_warning  s   "z4TestLoadtxtParseIntsViaFloat.test_deprecated_warningc                 C   s   t  < t dt z
tjdg|d W n ty/ } zt|jts%J W Y d }~nd }~ww W d    d S W d    d S 1 sCw   Y  d S )Nr)   rr  rH   )	r   r   r  rB   r*   rs  r^   
isinstance	__cause__)r   rI   er   r   r   test_deprecated_raised  s   
"z3TestLoadtxtParseIntsViaFloat.test_deprecated_raisedN)r/   r@   rA   r   r   r   r  r*   	typecodesrt  rx  r   r   r   r   rp    s    
rp  )Tr}   r   rN   r   r   r  r0  sysnumpyr*   numpy.testingr   r   r   r   r   r   r   r   r
   r   r   ImportErrorr   rC   rE   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r"  r*  r+  r2  r;  rP  rf  rr  r|  r  r  r  r  r  r  r   r  nose	HAVE_NOSEr   r   r  r  r!  r$  r&  r5  rj   rC  rF  PARTITION_DICTr  rB  rH  rN  rV  rb  rh  rn  rp  r   r   r   r   <module>   s    $lJ4
*V


 K	
"

	