1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
U
O±dmã@sòdZddlZddlmZddlmZddlZddlm    Z    m
Z
m Z ej dfej dfejdfejd    fejd
fejd fejd fejd fejdfejdfejdfejdfejdfejdfejdfejdfejdfejdfgZeeŽ\Z Z!Gdd„dƒZ"dS)z2
Test scalar buffer interface adheres to PEP 3118
éN)Úrational)Úget_buffer_info)Úassert_Ú assert_equalÚ assert_raisesú?ÚbÚhÚiÚlÚqÚBÚHÚIÚLÚQÚeÚfÚdÚgZZfZZdZZgc    @sÎeZdZejjdeeddd„ƒZejjdeeddd„ƒZ    ejjde
eddd    „ƒZ ejjdeedd
d „ƒZ d d „Z dd„Zdd„Zej dejdddejdddejdddg¡dd„ƒZdd„ZdS)ÚTestScalarPEP3118Úscalar)ÚidscCs<|ƒ}tjgt |¡d}t|ƒ}t|ƒ}t|j|jƒdS)N©Údtype)ÚnpÚarrayrÚ
memoryviewrÚformat)ÚselfrÚxÚaÚmv_xÚmv_a©r$úYd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/tests/test_scalarbuffer.pyÚtest_scalar_match_array%s
z)TestScalarPEP3118.test_scalar_match_arraycCsV|ƒ}t|ƒ}t|jt |¡jƒt|jdƒt|jdƒt|jdƒt|jdƒdS)Nrr$)    rrÚitemsizerrÚndimÚshapeÚstridesÚ
suboffsets)rrr r"r$r$r%Útest_scalar_dim-s   z!TestScalarPEP3118.test_scalar_dimz scalar, codecCs<|ƒ}td|jjdd|dd}t|ƒ}| |¡|ks8t‚dS)Nr$rT©r*r'r(r)rÚreadonly)Údictrr'rÚ_as_dictÚAssertionError)rrÚcoder Úexpectedr"r$r$r%Útest_scalar_code_and_properties7s ÿz1TestScalarPEP3118.test_scalar_code_and_propertiesc    Cs0|ƒ}tjtddt|dgƒW5QRXdS)Núscalar buffer is readonly©ÚmatchÚWRITABLE)ÚpytestÚraisesÚ BufferErrorr)rrr r$r$r%Útest_scalar_buffers_readonly@sz.TestScalarPEP3118.test_scalar_buffers_readonlyc    Cs t dtjdfdtjdfg¡}tjd|dd}tt|tjƒƒt|ƒ}dt tjdf¡j    }|d    t tj¡j    7}t
|j    |ƒt
|j d
ƒt
|j dƒt
|j dƒt
|jdƒtjd d g|d}tt|tjƒƒt|ƒ}t
|j    |j    ƒt
|j|jƒtjtd dt|dgƒW5QRXdS)NÚnameéZgrades)é)Zndarray_scalar)g333333ó?g@rr$ér?r)ZSarah)g @ç@)ZJohn)g@rAr5r6r8)rrZunicode_Úfloat64rrÚ
isinstanceZvoidrr'rr(r)r*r+Zndarrayrr9r:r;r)rÚdtr r"Z expected_sizer!r#r$r$r%Ú test_void_scalar_structured_dataFs$     z2TestScalarPEP3118.test_void_scalar_structured_datacCs t|j|j|j|j|j|jdS)N)r*r)r'r(rr.)r/r*r)r'r(rr.)rÚmr$r$r%r0_s
ÿzTestScalarPEP3118._as_dictc    Cs¸t d¡}t d¡}tddddddd}t|ƒ}| |¡|ksBt‚t||ƒ}| |¡|ks`t‚t d    d
g¡}t d|¡}tt    t
ft|d ƒt j t
d d t |dgƒW5QRXdS)Nz
2016-01-01z
2017-01-01)r@r@)ér Tr-)r!Zuint16)rzM8[s]rr5r6r8)rZ
datetime64r/rr0r1rÚemptyrÚ
ValueErrorr;r9r:r)rZdt1Zdt2r3ÚvrDr!r$r$r%Útest_datetime_memoryviewcs
 
 
ÿ  z*TestScalarPEP3118.test_datetime_memoryviewÚsZ22Úascii)Úidu️️zbasic multilingualu💻💻znon-BMPc    Cs„t |¡}tddddddd}t|ƒ}| |¡|ks8t‚tj|dd}t|d    d
„|Dƒƒtj    t
d d t |d gƒW5QRXdS)Nr$rGrZ2wTr-Úi4rcSsg|] }t|ƒ‘qSr$)Úord)Ú.0Úcr$r$r%Ú
<listcomp>Œsz3TestScalarPEP3118.test_str_ucs4.<locals>.<listcomp>r5r6r8) rZstr_r/rr0r1Z
frombufferrr9r:r;r)rrLr3rJZ code_pointsr$r$r%Ú test_str_ucs4zs
 ÿzTestScalarPEP3118.test_str_ucs4c    CsNtdƒ}ttƒt|ƒW5QRXtjtddt|dgƒW5QRXdS)Nr@r5r6r8)rrÚ    TypeErrorrr9r:r;r)rÚrr$r$r%Útest_user_scalar_fails_buffer’s
 
z/TestScalarPEP3118.test_user_scalar_fails_bufferN)Ú__name__Ú
__module__Ú __qualname__r9ÚmarkZ parametrizeÚ scalars_onlyÚ
codes_onlyr&r,Úscalars_and_codesr4r<rEr0rKÚparamrTrWr$r$r$r%r#s$
 
    
 
   ý
r)#Ú__doc__ÚnumpyrZnumpy.core._rational_testsrZnumpy.core._multiarray_testsrr9Z numpy.testingrrrZbool_ÚbyteÚshortZintcÚint_ZlonglongZubyteZushortZuintcZuintZ    ulonglongZhalfZsingleÚdoubleZ
longdoubleZcsingleZcdoubleZ clongdoubler^Úzipr\r]rr$r$r$r%Ú<module>s4  î