o
    1ήch                     @   s   d Z ddlZddlZddlmZmZmZ G dd dZG dd dZ	G dd	 d	Z
ejejejejejgZejejejejejgZejejejejgZejejejgZG d
d dZ dS )z;
Test the scalar constructors, which also do type-coercion
    N)assert_equalassert_almost_equalassert_warnsc                   @      e Zd Zdd Zdd ZdS )TestFromStringc                 C   s@   t d}t d}t d}t|d t|d t|d d S )Nz1.234gX9v?)npsingledouble
longdoubler   )selffsinglefdoubleflongdouble r   I/tmp/pip-target-vg8gfxp4/lib/python/numpy/core/tests/test_scalar_ctors.pytest_floating   s   




zTestFromString.test_floatingc                 C   s   t d}t|t j t d}t|t j t d}t|t j ttt jd}t|t j t d}t|t j  t d}t|t j  t d}t|t j  ttt jd}t|t j  dS )z6 Strings containing an unrepresentable float overflow 1e10000z-1e10000N)	r   halfr   infr   r	   r   RuntimeWarningr
   )r   fhalfr   r   r   r   r   r   test_floating_overflow   s    





z%TestFromString.test_floating_overflowN)__name__
__module____qualname__r   r   r   r   r   r   r      s    	r   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestExtraArgsc                 C   s   t jddd}|dksJ t dd}|dksJ tt t jddd W d    n1 s0w   Y  tt t dd W d    n1 sKw   Y  t ddksYJ d S )Ns   \x61zunicode-escape)encodingas   \xxs   -2)r   str_pytestraisesUnicodeDecodeErrorbytes_)r   sr   r   r   test_superclass+   s   zTestExtraArgs.test_superclassc                 C   s\   t dd}t |dksJ tt t jddd W d    d S 1 s'w   Y  d S )Nz2000-01)M   2000Tgarbage)r   
datetime64datetime_datar    r!   	TypeError)r   dtr   r   r   test_datetime;   s
   "zTestExtraArgs.test_datetimec                 C   >   t t tjddd W d    d S 1 sw   Y  d S )NFTr)   )r    r!   r-   r   bool_r   r   r   r   	test_boolB      "zTestExtraArgs.test_boolc                 C   r0   )Ns   testTr)   )r    r!   r-   r   voidr2   r   r   r   	test_voidF   r4   zTestExtraArgs.test_voidN)r   r   r   r%   r/   r3   r6   r   r   r   r   r   *   s
    r   c                   @   r   )TestFromIntc                 C   s   t dtd d S )Ni   )r   r   intpr2   r   r   r   	test_intpL   s   zTestFromInt.test_intpc                 C   s   t tdtd d S )Nr   l    )r   r   uint64r2   r   r   r   test_uint64_from_negativeP   s   z%TestFromInt.test_uint64_from_negativeN)r   r   r   r9   r;   r   r   r   r   r7   K   s    r7   c                   @   s   e Zd ZdZdd Zejdee	 ejdee	 dg dd Z
ejdeejdedg d	d
 Zejdeejdedg dd ZdS )TestArrayFromScalarz
 gh-15467 c                 C   sF   |d}t j||d}|d u r|jj|u sJ d S |jj|u s!J d S )Nr'   )dtype)r   arrayr=   type)r   t1t2xarrr   r   r   _do_test]   s
   zTestArrayFromScalar._do_testr@   rA   Nc                 C      |  ||S NrD   r   r@   rA   r   r   r   test_integersf      z!TestArrayFromScalar.test_integersc                 C   rE   rF   rG   rH   r   r   r   
test_realsk   rJ   zTestArrayFromScalar.test_realsc                 C   rE   rF   rG   rH   r   r   r   test_complexp   rJ   z TestArrayFromScalar.test_complex)r   r   r   __doc__rD   r    markparametrize	int_types
uint_typesrI   float_typesrK   cfloat_typesrL   r   r   r   r   r<   Z   s    	r<   )!rM   r    numpyr   numpy.testingr   r   r   r   r   r7   byteshortintcint_longlongrP   ubyteushortuintcuint	ulonglongrQ   r   r   r	   r
   rR   csinglecdoubleclongdoublerS   r<   r   r   r   r   <module>   s    !	