`L itdZddlZddlmZddlZddlZddlmZm Z ddl m Z ddl m Z gdZejd d Zejd d Zd Zd ZdZdZdZdZy)avThis test for the LFW require medium-size data downloading and processing If the data has not been already downloaded by running the examples, the tests won't run (skipped). If the test are run, the first execution will be long (typically a bit more than a couple of minutes) but as the dataset loader is leveraging joblib, successive runs will be fast (less than 200ms). N)partial)fetch_lfw_pairsfetch_lfw_people)check_return_X_y)assert_array_equal)Abdelatif_Smith Abhati_Kepler Camara_Alvaro Chen_DupontJohn_Lee Lin_Bauman Onur_Lopezmodule)scopec#6K|jd}|yw)Nscikit_learn_empty_test)mktemp)tmp_path_factorydata_dirs e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/datasets/tests/test_lfw.pymock_empty_data_homer s&&'@AH Nsc #Ktjd}|jd}|dz }|jddt j d}t jjd}i}tD]}|dz |z }|jdd|jdd } | ||<t| D]`} ||d | zzz } |jd d d } |j| jt j} | j| b|dz dz jdt!|dz d5}|j#d|j%Dcgc] \}}|dk\s |}}}td D]Y} |j'|}|j)t||d\}}|j#d|||fzj+[td D]} |j)td\}}|j't j,||}|j't j,||}|j#d||||fzj+ ddd|dz jd|dz jd|ycc}}w#1swY?H*$H NN4$N/==$L YY " "2 &FF  /$6 $6..A&t w A#tkAo'=>InnQ-n@G//'..":;C HHY    ,999 h,,d 3q 17N+$5A:N Nq GA&&}5D(//fTl0CQGME6 GG^tUF&;;CCE F G q A&2&9&9*a&H #J  -- &2D(EFK!==6+3F)GHL GG&!; \JK&(   &""//1 (()RS N-Os7EK%K- J<;J<?DK5K<KK Kcztjt5t|ddddy#1swYyxYwNF data_homedownload_if_missing)r'raisesOSErrorrrs rtest_load_empty_lfw_peoplerZbs2 w T#7USTTT1:c"t|dd}|jjdk(sJ|jjdk(sJt |j gdgd}t |j |t|dddd }|jjd k(sJ|jjd sJt |j gd t |j gd tt|dddd }t||y)Nr#FrUmin_faces_per_personrV) >/)r_ib ) r&rrrr&rr&rrr&)Abdelatif Smith Abhati Kepler Onur LopezTrUresizeslice_colorrV)r"r"r#&.. _labeled_faces_in_the_wild_dataset:)rrrr rkr#rkrr#rkrr&r rr&)rbrcz Camara Alvaroz Chen DupontzJohn Leez Lin Baumanrd) rimagesshapedatartarget target_namesDESCR startswithrr)rQ lfw_peopleexpected_classes fetch_funcs rtest_load_fake_lfw_peoplerwgs! qeJ    " "l 22 2 ?? J .. .z((*HIJz..0@A" ! J    " "&7 77 7    & &'O PP PN   ! JZ,c|tjt5t|dddddy#1swYyxYw)NdFr])r'rW ValueErrorr)rQs r)test_load_fake_lfw_people_too_restrictiver|s4 z " $!$ %    s2;cztjt5t|ddddy#1swYyxYwrS)r'rWrXrrYs rtest_load_empty_lfw_pairsr~s2 w S"6ERSSSr[ct|d}|jjdk(sJt|jgdddg}t|j |t|dddd}|jjd k(sJt|jgdt|j ||j jd sJy) NFrT)r_r&r`ra) rrrrrrrrrrzDifferent personsz Same personTre)r_r&r"r"r#rj)rpairsrnrrprqrrrs)rQlfw_pairs_trainrus rtest_load_fake_lfw_pairsrs% eO  & &/ 99 9--/MN,];335EF& ! O  & &*> >> >--/MN335EF  + +,T UU Urxctddtddf}t|ddd|}|jd j|d j|d j z |d j|d j z fk(sJy) zCheck that we properly crop the images. Non-regression test for: https://github.com/scikit-learn/scikit-learn/issues/24942 FNr#FN)rUr^rVrfrgrr)slicerrmrnstopstart)rQrglfws r'test_fetch_lfw_people_internal_croppingrsBneBn -F  !  C ::a=  q (q (#  rx)__doc__r* functoolsrnumpyr,r'sklearn.datasetsrr"sklearn.datasets.tests.test_commonrsklearn.utils._testingrr.fixturerrQrZrwr|r~rrrxrrs >?5 h  h7 7tT 7-t S VDrx