]f`{ddlZddlZddlZddlZddlmZddlmZmZddl m Z m Z m Z m Z mZmZmZmZmZddl mZmZmZddlmZmZmZmZmZmZGddZdS) N)Path)NamedTemporaryFile TemporaryFile) memmapsumaverageprodndarrayisscalaraddsubtractmultiply)arangeallcloseasarray)assert_ assert_equalassert_array_equalsuppress_warningsIS_PYPY break_cyclesceZdZdZdZdZdZdZdZdZ dZ d Z e j ejd kd d ZdZdZdZdZdZdZdZdZdZdZdZdS) TestMemmapctd|_d|_d|_t d|j|_|j|jdS)Nmmap)prefix)float32 dtype)rtmpfpshaper"rdataresizeselfs p/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/numpy/core/tests/test_memmap.py setup_methodzTestMemmap.setup_methodsV'v666   2TZ000  $$$$$c|jd|_trt t dSdS)N)r#closer%rrr's r)teardown_methodzTestMemmap.teardown_methodsE    NNN NNNNN  r+cZt|j|jd|j}|jdd|dd<~t|j|jd|j}t t |j|t|j|t|j j ddS)Nw+r"moder$rF) rr#r"r$r%rrrrflags writeable)r(fpnewfps r)test_roundtripzTestMemmap.test_roundtrip s DJdjt*&&& !!! 111 tz#!Z)))E**+++49e,,,U[*E22222r+ct|dz }t||jd|j}|jdd|dd<~dS)Nrr0r1)rr"r$r%)r(tmp_pathtmpnamer6s r)test_open_with_filenamez"TestMemmap.test_open_with_filename.sKV# G4:D!Z))) !!! 111 BBr+ct5}t||j|j}~ddddS#1swxYwYdSNr"r$)rrr"r$)r(fr6s r)test_unnamed_filezTestMemmap.test_unnamed_file5s __ 4:>>>B                  s :>>cd}d}t|j|j||j|}t ||jt ||j~dS)Nr0)r"r2r$offset)rr#r"r$rrDr2)r(rDr2r6s r)test_attributeszTestMemmap.test_attributes:s\ DJdjt*V555VRY'''T27### BBr+c6|dz }t||jd|j}ttj|}|jdd|dd<t||j |dd}t||j ~~dSNrr0r1rC) rr"r$rospathabspathr%rfilenamer(r:r;r6rJbs r) test_filenamezTestMemmap.test_filenameCsV# G4:D!Z)))rww//00 !!! 111Wbk*** rrFWaj))) BBr+c|dz }tt||jd|j}t t|}|jdd|dd<t|t |j|dd}t|t |j~~dSrG) rrr"r$strresolver%rrKrLs r) test_pathzTestMemmap.test_pathOsV# DMM$!Z))) d7mm++--.. !!! 111Wc"+"5"5"7"788999 rrFWc!*"4"4"6"677888 BBr+ct|j|jd|j}t |j|jjdS)Nr0r1)rr#r"r$rrKnamer(r6s r)test_filename_fileobjz TestMemmap.test_filename_fileobj^sA DJdjt*&&&R[$*/22222r+gnu0zKnown to fail on hurd)reasonct|j|jd|j}|jdd|dd<t |d|jd|dS)Nr0r1r)rr#r"r$r%rflushrUs r) test_flushzTestMemmap.test_flushcsiDJdjt*&&& !!! 111RUDIaL)))  r+ct|j|jd|j}d|d<|dd}t |dd~t |ddd|d<t |dddS)Nr0r1rrC)rr#r"r$r)r(fp_basefp_views r)test_delzTestMemmap.test_dells4:D*&&& !A#,WQZ###  WQZ### WQZ#####r+ct|j|jd|j}|dz}t |trt |j|judSdS)Nr0r1 rr#r"r$ isinstancer_mmapr(r6tmps r) test_arithmetic_drops_referencesz+TestMemmap.test_arithmetic_drops_referenceszsg DJdjt*&&&Bw c6 " " / CIRX- . . . . . / /r+ct|j|jd|j}|d}t |trt |j|judSdS)Nr0r1))rC)rkrrdrgs r)test_indexing_drops_referencesz)TestMemmap.test_indexing_drops_referencessh DJdjt*&&&  c6 " " / CIRX- . . . . . / /r+ct|j|jd|j}t |ddddfj|judS)Nr0r1rk)rr#r"r$rrfrUs r)test_slicing_keeps_referencesz(TestMemmap.test_slicing_keeps_referencessS DJdjt*&&&2A2rr6  BH,-----r+c:t|j|j|j}|}|}t |j|ut |j|ut|}t |j|udSr>)rr#r"r$viewrbaser)r(r6new1new2 new_arrays r) test_viewzTestMemmap.test_views DJdj C C Cwwyyyy{{ R    R   BKK  "$%%%%%r+ct|j|j|j}|j|dd<t 5}|tdtttfD]}||}tt|t|j |jdj ut||dj tut||dj tu dddn #1swxYwYtt t"fD]{}t|||jj tut||j|j tut|||j tu||dz }|j tusJt|d||j tusJdS)Nr?z&np.average currently does not preserve)rrraxisrC)out)rr#r"r$r%rfilter FutureWarningrrr rr __class__r r r r)r(r6supunary_opresult binary_ops r)test_ufunc_return_ndarrayz$TestMemmap.test_ufunc_return_ndarrays* DJdj C C C 111   CC JJ}&N O O O '40 C C!"(()))(DIdO,EEFFF!,,,6'ABBB!,,,6'ABBBB  C C C C C C C C C C C C C C C Cx2 < .MemmapSubClassN)__name__ __module__ __qualname__r+r)MemmapSubClassrs Dr+rr?rrwrCr)rr#r"r$r%rrr|)r(rr6s r)test_memmap_subclasszTestMemmap.test_memmap_subclasss     V   ^DJdj K K K 111 BQ)^;<<<B!^3444122ss7 %78881a&z#~555555r+cdtjz}tjdz}t|j|d|}t |j|kdS)Nr]rCr0)r$r2rD)rALLOCATIONGRANULARITYrr#rrD)r(sizerDr6s r)4test_mmap_offset_greater_than_allocation_granularityz?TestMemmap.test_mmap_offset_greater_than_allocation_granularitysO4--+a/ DJdf E E E V#$$$$$r+c|jdt|jd}t|jddS)Nsaaaaaaaaaaaaaaaafloat64r!)rk)r#writerrr$)r(mms r) test_no_shapezTestMemmap.test_no_shapesD !!! DJi 0 0 0RXt$$$$$r+ctjtd5t|jdddddn #1swxYwY|jdt|jdddS)Nz empty file)match)rrr0)r$r2)pytestraises ValueErrorrr#rr's r)test_empty_arrayzTestMemmap.test_empty_arrays ]:\ : : : 7 7 4:U 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7  tzT222222sAAAN)rrrr*r.r8r<rArErNrRrVrmarkskipifsysplatformr[rarirlrnrurrrrrrrr+r)rrs%%% 3 3 3       333  [ .68888 $ $ $//////... &&&'''0111 7 7 7%%% %%% 33333r+r)rrHrrpathlibrtempfilerrnumpyrrrr r r r r rrrr numpy.testingrrrrrrrrr+r)rs 66666666LLLLLLLLLLLLLLLLLLLLLL,+++++++++ F3F3F3F3F3F3F3F3F3F3r+