
    !g	#                     p   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	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j0                  j2                  d        Zej0                  j6                  ej0                  j2                  d               Zej0                  j6                  ej0                  j2                  d               Zej0                  j6                  ej0                  j2                  d	               Zej0                  j6                  ej0                  j2                  d
               Zej0                  j6                  ej0                  j2                  d               Z ej0                  j2                  d        Z!ej0                  j6                  ej0                  j2                  d               Z"d Z#d Z$ej0                  j2                  d        Z%y# e$ r Y 
w xY w)    N)assert_almost_equalassert_equal)elnino)	banddepthfboxplot
hdrboxplotrainbowplot   c                    	 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           g/var/www/dash_apps/app1/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$   r/   r0   r1   )r2   reset_randomstater3   r4   r5   s        r9   test_hdr_basic_bruter?   B   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_xlimr/   r0   r1   )r2   figrC   s      r9   test_hdr_plotrX   P   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#   r/   r0   r1   r2   r3   r4   extra_quant_ts       r9   test_hdr_alphar_   c   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   rZ   )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&   r/   r0   r1   r]   s       r9   test_hdr_multiple_alphara   r   sw    IDd%@3::::; 	C//=1I$%	' IGHIr@   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[   rD   r   r
   r   )i  r   r   r   r   r    )r   r!   r%   r*   r+   r'   r,   r-   r   r   r/   r0   r1   )r2   r3   r4   r8   r'   s        r9   test_hdr_thresholdrc      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@rg   r   r   r    r   r!   r   r$   r/   r0   r1   r2   r3   r4   r5   s       r9   test_hdr_bwrj      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)NrF   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    rh   ri   s       r9   test_hdr_ncomprm      sO    ID63>CJJ!< IGHIrk   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)ro   竪?ru   ro   )r%   rT   sinpicosasarrayr   r   xxy1y2y3y4r!   depthexpected_depths           r9   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
   ro   g      пMBDrs   )ru         ?g?r      r   )r%   rT   zerosr-   onesry   r   r   rz   s           r9   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%   randomrv   rx   )tcia1ia2ib1ib2ifuncs          r9   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         rB   )wfactorrC   )rE   r            rp   rF      	      r
      r               
   r      )r   r   r   r   )xdatar   cmap)r%   r   r   linspacerw   rangerM   rN   rO   r   arrayr   rT   sizer	   cmrainbow)r2   r   r   r3   r!   rW   rC   r   ix_depthix_outliersix_expectedix_expected2r   s                r9   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   r0   statsmodels.datasetsr   statsmodels.graphics.functionalr   r   r   r	   matplotlib.pyplotpyplotrM   ImportErrorloadr!   ry   raw_dataastyper   r   mark
matplotlibr:   slowr?   rX   r_   ra   rc   rj   rm   r   r   r    r   r9   <module>r      s%    ;  ' 	#
 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M  		s   H, ,H54H5