U
    #c                     @   sV  d dl Z d dlZd dlZd dlmZ ejejdfejej	dfej
ejdfejejdfejejdfejejdfgZe jd	d
dgedd Ze jd	d
dgedd Ze jd	d
dgee jddddddddge jdddgdd Ze jd	d
dgee jdddddgdd Ze jdd d!ge jd"ejd# d$d% ZdS )&    N)assert_array_equalz==z!=<z<=>z>=opufuncsymc              	   C   sp   t jddgdd}t jddgdd}tjtdd ||| W 5 Q R X tjtdd ||| W 5 Q R X d S )	NabSdtypecUzdid not contain a loop)match)nparraypytestZraises	TypeError)r   r   r   
arr_stringarr_unicode r   A/tmp/pip-unpacked-wheel-b2rbor69/numpy/core/tests/test_strings.py(test_mixed_string_comparison_ufuncs_fail   s    r   c                 C   sl   t jddgdd}t jddgdd}|||ddd	}|||d
dd	}| |d|}t|| t|| d S )Nr   r	   r
   r   r   r   zUU->?Zunsafe)	signatureZcastingzSS->?)r   r   astyper   )r   r   r   r   r   Zres1Zres2expectedr   r   r   .test_mixed_string_comparisons_ufuncs_with_cast   s    
r   dtypes)S2r   )r   ZS10)<U1r   )r   >U1)r    r    )r   z<U10)r   z>U10alignedTFc           
         s@  t |d d}t d||d }|sft j|jd t jddd  |d }||d< |}|j|d dd}t j	
| |d |d<  fd	d
t| | D }	t |||	 t||||	 tt |||d|	  fdd
t| | D }	t |||	 t||||	 tt |||d|	 d S )Nr   =i      r   .T)copyc                    s   g | ]\}} ||qS r   r   .0d1Zd2r   r   r   
<listcomp>@   s     z+test_string_comparisons.<locals>.<listcomp>Fc                    s   g | ]\}} ||qS r   r   r%   r(   r   r   r)   E   s     )r   r   ZnewbyteorderZarangeviewr   zerosnbytesZuint8randomshuffleziptolistr   compare_chararrays)
r   r   r   r   r!   Z	native_dtarrnewarr2r   r   r(   r   test_string_comparisons,   s"    (  r5   c                 C   sx   t jd|d d}t jd|d d}t jt |j|jtd}t| ||| t|||| tt |||d| d S )N)r#   r   r#      r   r   )d   r#   r   r#   r#   F)r   emptyZbroadcast_shapesshapeboolr   r1   )r   r   r   r   r2   r4   r   r   r   r   test_string_comparisons_emptyK   s    r;   str_dtr
   r   float_dtZAllFloatc                 C   s   t |}t |}t jt jt jt j |j|jg|d}dddt|jt|jg}|j	dkrjdd |D }|
| }t|t j|| d d S )Nr   naninfz-infr   c                 S   s   g | ]}d | dqS )(z+0j)r   )r&   rr   r   r   r)   `   s     z-test_float_to_string_cast.<locals>.<listcomp>)r   r   Zfinfor   r>   r?   maxminreprkindr   r   )r<   r=   fir2   r   resr   r   r   test_float_to_string_castX   s    

$

rH   )r   operatorZnumpyr   Znumpy.testingr   eqequalne	not_equalltZlessleZ
less_equalgtZgreatergeZgreater_equalZCOMPARISONSmarkZparametrizer   r   r5   r;   Z	typecodesrH   r   r   r   r   <module>   sJ   



       
