
    g-&                     <   d dl Zd dlmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZmZmZ 	 d dlmZ  e	j&                         Z ej*                  ej,                        e_        ej,                  ddd f   j/                  e      Zej,                  ddddf   Zej4                  j7                  ed      ej4                  j8                  d	               Zej4                  j<                  ej4                  j8                  d
               Zej4                  j7                  ed      ej4                  j<                  ej4                  j8                  d                      Z ej4                  j7                  ed      ej4                  j<                  ej4                  j8                  d                      Z!ej4                  j7                  ed      ej4                  j<                  ej4                  j8                  d                      Z"ej4                  j7                  ed      ej4                  j<                  ej4                  j8                  d                      Z#ej4                  j7                  ed      ej4                  j8                  d               Z$ej4                  j7                  ed      ej4                  j<                  ej4                  j8                  d                      Z%d Z&d Z'ej4                  j8                  d        Z(y# e$ r Y w xY w)    N)assert_almost_equalassert_equal)PYTHON_IMPL_WASM)elnino)	banddepthfboxplot
hdrboxplotrainbowplot   z0Multiprocessing is not supported in WASM/Pyodide)reasonc                    	 t        t        t        d      \  }}t        |j                        dk(  sJ g d}t        |j                  |d       t        j                  |j                  |j                  |j                  g      }t        j                  g dg dg d	g d
g dg dg dg dg      }t        ||d       t        j                  t        j                  t        |j                        j                  t        j                        d      }t        |   }t!        g d|       t!        t        |j"                     |       y # t$        $ r t'        j(                  d       Y y w xY w)N90  )labelsseedr   gZd;?8@g     9@gX99@g9v8@gS7@gZd;OM6@gB`";5@gV-]4@g^I+4@gvo4@g#~j5@gCL6@   decimal)g\(\8@gQk9@ffffff9@g(\8@g(\58@gY7@g     6@gp=
5@g
ףp=
6@gzG6@gR8@gp=
9@)g     @;@g{G:<@g<@R<@gQ^<@gGzn;@g{G9@gzG7@(\B6@gQ86@g(\56@gq=
ף07@)g333337@gGz:@gQ+;@g=
ףp:@gQ:@gfffff&:@gףp=
9@g333338@gq=
ף8@gp=
ף8@g9@gGz;@)gQ<@r   g=
ףp==@g33333s<@g\(\;@gq=
ף09@g\(7@gQE6@(\O5@gQ^5@g5@g(\6@)g{Gz9@g=
ףp:@g(\;@g
ףp=
;@{G::@gq=
ף8@gq=
ף7@gQ6@r   p=
ף6@gGzT7@gq=
ףp8@)g\(7@g     8@g)\8@gq=
ףp7@g=
ףp5@gGz4@gGz3@gףp=
2@g(\2@g=
ףp2@g)\3@g\(4@)gףp=
8@r   gQ:@gGz9@gQ8@gR7@g(\u6@g33333s5@g(\B5@gR5@gp=
#6@g)\h7@)gQ7@皙9@gףp=
W9@gQ88@g=
ףp6@gQ5@gffffff4@g(\3@gzG3@gQ3@gQ^4@g(\5@r   axis)        0Multiprocess randomly crashes in Windows testing)r	   datar   lenextra_quantilesr   mediannpvstackoutliershdr_90hdr_50allisinreshapeshaper   outliers_idxOSErrorpytestxfail)close_figures_hdrmedian_tquantquant_t
labels_posr)   s           ]/var/www/html/venv/lib/python3.12/site-packages/statsmodels/graphics/tests/test_functional.pytest_hdr_basicr<      s:   $IDe<33&&'1,,,D 	CJJ!<		3<<SZZ@A)) HHHHHHHHI J" 	E7A6VVBGGD#,,7??

K!"$
*%-x8VC,,-x8 IGHIs   E
E E.-E.c                     	 t        t        dt        d      \  }}t        |j                        dk(  sJ g d}t        |j                  |d       y # t        $ r t        j                  d       Y y w xY w)Nr   T)ncompr   	use_bruter   r   r   r"   )
r	   r#   r   r$   r%   r   r&   r1   r2   r3   )r4   reset_randomstater5   r6   r7   s        r;   test_hdr_basic_bruterA   G   sm    ID&DI33&&'1,,,D 	CJJ!< IGHI   AA A43A4c                    t        j                         }|j                  d      }	 t        t        t
        j                         |dd       |j                  d       |j                  d       |j                  t        j                  dd	      dz
         |j                  g d
       |j                  ddg       y # t        $ r t        j                   d       Y y w xY w)No   r   r   )r   ax	thresholdr   zMonth of the yearzSea surface temperature (C)      )step) MarJunSepDecgɿgffffff&@r"   )pltfigureadd_subplotr	   r#   r   tolist
set_xlabel
set_ylabel
set_xticksr'   arangeset_xticklabelsset_xlimr1   r2   r3   )r4   figrE   s      r;   test_hdr_plotrZ   U   s     **,C		B
I4B!	 	)*
34
bii+a/0
;<
T4L! IGHIs   BB? ?C C c                     	 t        t        dgd      \  }}t        j                  g dg dg      }t	        |j
                  |d       y # t        $ r t        j                  d       Y y w xY w)	Ngffffff?r   alphar   )r   g     :@g      ;@gffffff:@r   g8@g      7@g      6@g333335@g6@g333336@g7@)gffffff7@g8@g      9@gfffff7@ffffff6@g5@g      4@gL3@g3333333@gffffff3@g4@gL5@r   r   r"   )	r	   r#   r'   r(   r   r%   r1   r2   r3   r4   r5   r6   extra_quant_ts       r;   test_hdr_alphara   l   so    	IDE:3		 $H$H#I J 	C//J IGHIs   A	A A-,A-c                     	 t        t        ddgd      \  }}g dg dg dg dg}t        |j                  t	        j
                  |      d	
       y # t        $ r t        j                  d       Y y w xY w)Ng?gq=
ףp?r   r\   )gʡE9@gZd;O;@gt;@g333333;@gx):@gh|?8@g$7@gT㥛`6@g     @6@r   gFx7@g/$8@)g+6@g-阮8@gS㥛8@g+W7@g r5@gHz4@g     3@g3@gZd;2@gw/2@gQ3@g(\4@)gn8@g r:@g"~j:@g/$9@g+N8@gMbX6@gv5@g 4@gS{4@g/5@gK7A5@gp=
6@)gsh|7@g"^9@gn9@g/ݤ8@gZd;O-7@g?5^I5@g"~4@gp=
4@gOn3@g~jt3@gZd;4@gS5@r   r   r"   )	r	   r#   r   r%   r'   r(   r1   r2   r3   r_   s       r;   test_hdr_multiple_alpharc      sw    IDd%@3::::; 	C//=1I$%	' IGHIrB   c                 V   	 t        t        dgdd      \  }}t        j                  t        j                  t        |j
                        j                  t        j                        d      }t        |   }t        g d|       y # t        $ r t        j                  d       Y y w xY w)	Ng?g(\?r   )r]   rF   r   r   r   )i  r   r   r    r!   r"   )r	   r#   r'   r,   r-   r)   r.   r/   r   r   r1   r2   r3   )r4   r5   r6   r:   r)   s        r;   test_hdr_thresholdre      s    ID!&(3VVBGGD#,,7??

K!"$
*%3X> IGHIs   BB B('B(c                     	 t        t        dd      \  }}g d}t        |j                  |d       y # t        $ r t        j                  d       Y y w xY w)Ncv_mlr   )bwr   )g     @8@gp=
ף9@g=
ףp9@g
ףp=
9@g(\µ7@zGa6@r   gq=
ףp4@g=
ףp=4@g(\4@gq=
ף05@ri   r   r   r"   r	   r#   r   r&   r1   r2   r3   r4   r5   r6   r7   s       r;   test_hdr_bwrl      sQ    IDW593> 	CJJ!< IGHI   14 AAc                     	 t        t        dd      \  }}g d}t        |j                  |d       y # t        $ r t        j                  d       Y y w xY w)NrH   r   )r>   r   )gGzT8@g(\µ9@g
ףp=
:@gGz9@g=
ףp7@r^   gRQ5@g33333s4@g     @4@gHz4@g3333335@gp=
c6@r   r   r"   rj   rk   s       r;   test_hdr_ncompro      sO    ID63>CJJ!< IGHIrm   c                     t        j                  d      dz  } ddt        j                  |       z  z   }dt        j                  | t         j                  dz  z         z   }dt        j                  | t         j                  dz  z         z   }ddt        j                  | t         j                  dz  z         z  z   }t        j
                  ||||g      }t        |d	
      }g d}t        ||       y )Ni  g     b@r         ?g333333?   g      BD2method)rq   竪?rw   rq   )r'   rV   sinpicosasarrayr   r   xxy1y2y3y4r#   depthexpected_depths           r;   test_banddepth_BD2r      s    	3$	B	
S266":	B	rvvb2557l#	#B	rBEE!G|$	$B	cBFF2a<((	(B::r2r2&'Dd5)E+N~.    c                  z   t        j                  d      dz  } t        j                  | j                        }d| z  dz
  }t        j                  | j                        dz  }t        j                  | j                        dz  }t        j
                  ||||g      }t        |d      }g d	}t        ||d
       y )Ni  g     @r   r   rq   g      пMBDru   )rw         ?g?r      r   )r'   rV   zerosr/   onesr{   r   r   r|   s           r;   test_banddepth_MBDr      s    	45	 B	"((	B	
R!B		S	 B		U	"B::r2r2&'Dd5)EEN~q9r   c                 l   d }t         j                  j                  d       t        j                  ddt         j                  z  d      }t        d      D cg c]
  } ||       }}t        j                         }|j                  d      }t        |d|      \  }}}}	t        j                  g d	      }
t        ||
       t        j                  g d
      }t        |	|       t        j                  |d   j                        }t        |||t        j                  j                         }y c c}w )Nc                 F   t        t        j                  j                         dkD        }t        j                  j                         dz  }t        j                  j                         dz  }dt        j                  j                         z  dz   }dt        j                  j                         z  dz   }d|z
  |t        j                  |       z  |t        j                  |       z  z   z  ||t        j                  |       z  |t        j                  |       z  z   z  z   }|S )z3Test function, combination of a few harmonic terms.g?g?g?g?r   )intr'   randomrx   rz   )tcia1ia2ib1ib2ifuncs          r;   harmfuncz+test_fboxplot_rainbowplot.<locals>.harmfunc   s     !!#c)*ii 4'ii 4'RYY--//#5RYY--//#5B3?S266!9_<=#q	/C"&&)O345 r   i r   r         rD   )wfactorrE   )rG   r            rr   rH      	      r      r               
   r      )r   r   r   r   )xdatar   cmap)r'   r   r   linspacery   rangerO   rP   rQ   r   arrayr   rV   sizer
   cmrainbow)r4   r   r   r5   r#   rY   rE   r   ix_depthix_outliersix_expectedix_expected2r   s                r;   test_fboxplot_rainbowplotr      s     IINN7
Aq255y#&A!&r+AHQK+D+ **,C		B&.tQ2&F#Auh(( 7 8K;'88O,Ll+ IId1gll#E
d%u366>>
JC ,s   D1))numpyr'   numpy.testingr   r   r2   statsmodels.compat.pythonr   statsmodels.datasetsr   statsmodels.graphics.functionalr   r   r	   r
   matplotlib.pyplotpyplotrO   ImportErrorloadr#   r{   raw_dataastyper   r   markskipif
matplotlibr<   slowrA   rZ   ra   rc   re   rl   ro   r   r   r    r   r;   <module>r      s$    ;  6 ' 	#
 v{{}

4==)	q!t		#	#C	(}}QU =   %I 	
%IP 	I  	I =   I  	I" =   
I  	
I =   I  	I, =   	I  		I =   	I 	
	I =   I  	I
/,
: "K "KE  		s   L LL