
    >hX                         S r SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSK	J
r
  S rS r " S S	5      r\" S
/ SQ5      r " S S\5      r " S S5      rS rSS jrg)z,
Substantially copied from NumpyDoc 1.0pre.
    )
namedtuple)MappingN)
ParseErrorc                 j    [         R                  " SR                  U 5      5      R                  S5      $ )z"Deindent a list of lines maximally
)textwrapdedentjoinsplit)liness    nC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/tools/docstring.pydedent_linesr      s%    ??499U+,22488    c                    U (       a<  U S   R                  5       (       d$  U S	 U (       a  U S   R                  5       (       d  M$  U (       a<  U S   R                  5       (       d$  U S	 U (       a  U S   R                  5       (       d  M$  U $ )z<Remove leading and trailing blank lines from a list of linesr   striplines    r   strip_blank_linesr      sa    
tAw}}G tAw}}
tBx~~''H tBx~~''Kr   c                   ^    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSS jrS rSrg)Reader   z
A line-based string reader.
c                     [        U[        5      (       a  Xl        OUR                  S5      U l        U R	                  5         g)zq
        Parameters
        ----------
        data : str
           String with lines separated by '
'.
        r   N)
isinstancelist_strr   reset)selfdatas     r   __init__Reader.__init__!   s/     dD!!I

4(DI

r   c                      U R                   U   $ N)r   r   ns     r   __getitem__Reader.__getitem__/   s    yy|r   c                     SU l         g )Nr   )	_line_numr   s    r   r   Reader.reset2   s	    r   c                 x    U R                  5       (       d%  X R                     nU =R                  S-  sl        U$ g)N    )eofr*   )r   outs     r   readReader.read5   s/    xxzz~~&CNNaNJr   c                     X R                   S   H/  nUR                  5       (       a    g U =R                   S-  sl         M1     g Nr.   )r*   r   )r   r   s     r   seek_next_non_empty_lineReader.seek_next_non_empty_line=   s2    )*Dzz||!#	 +r   c                 F    U R                   [        U R                  5      :  $ r$   r*   lenr   r+   s    r   r0   
Reader.eofD   s    ~~TYY//r   c                     U R                   nXS   H]  nU" U5      (       a  XU R                    s  $ U =R                   S-  sl         U R                  5       (       d  ML  XU R                   S-    s  $    / $ r5   )r*   r0   )r   condition_funcstartr   s       r   read_to_conditionReader.read_to_conditionG   sg    LDd##DNN33NNaNxxzzDNNQ$677 ! 	r   c                 J    U R                  5         S nU R                  U5      $ )Nc                 ,    U R                  5       (       + $ r$   r   r   s    r   is_empty0Reader.read_to_next_empty_line.<locals>.is_emptyT   s    zz|##r   )r6   r?   )r   rC   s     r   read_to_next_empty_lineReader.read_to_next_empty_lineQ   s&    %%'	$ %%h//r   c                 *    S nU R                  U5      $ )Nc                 z    U R                  5       =(       a%    [        U R                  5       5      [        U 5      :H  $ r$   )r   r:   lstripr   s    r   is_unindented:Reader.read_to_next_unindented_line.<locals>.is_unindentedZ   s'    ::<ES%73t9%DEr   )r?   )r   rJ   s     r   read_to_next_unindented_line#Reader.read_to_next_unindented_lineY   s    	F %%m44r   c                 r    U R                   U-   [        U R                  5      :  a  X R                   U-      $ gNr/   r9   r%   s     r   peekReader.peek_   s0    >>ADII.*++r   c                 ^    SR                  U R                  5      R                  5       (       + $ rO   )r
   r   r   r+   s    r   rC   Reader.is_emptye   s!    77499%++---r   )r*   r   Nr   )__name__
__module____qualname____firstlineno____doc__r!   r'   r   r2   r6   r0   r?   rE   rL   rP   rC   __static_attributes__ r   r   r   r      s>    $005.r   r   	Parameter)nametypedescc                   .   \ rS rSrSr0 SS_SS/_S/ _S/ _S/ _S	/ _S
/ _S/ _S/ _S/ _S/ _S/ _S/ _S/ _S/ _SS_SS_S0 0ErS rS rS rS r	S r
S rS rS rS rSCS jrS rS!rS"rS#\-   \-   S$-   \-   S%-   r\R)                  S&S'5      r\R)                  S(S)5      rS*r\R0                  " S+\-   S,-   5      r\R0                  " S-\-   S.-   \-   S/-   S%-   S0-   \-   5      rS1rS2 rS3 rS4 rS5 rS6 r SDS7 jr!SES8 jr"S9 r#S: r$S; r%S< r&S= r'S> r(S? r)SFS@ jr*SAr+gB)GNumpyDocStringl   zzParses a numpydoc string to an abstract representation

Instances define a mapping from section title to structured data.
	Signaturer/   SummaryExtended Summary
ParametersReturnsYieldsReceivesRaisesWarnsOther Parameters
AttributesMethodsSee AlsoNotesWarnings
ReferencesExamplesindexc                    Un[         R                  " U5      R                  S5      n[        U5      U l        [
        R                  " U R                  5      U l         U R                  5         g ! [         a  nX#l        e S nAff = f)Nr   )r   r	   r   r   _doccopydeepcopysections_parsed_data_parser   	docstring)r   r|   orig_docstringes       r   r!   NumpyDocString.__init__   sg    "OOI.44T:	9%	 MM$--8	KKM 	(K	s   A/ /
B9B  Bc                      U R                   U   $ r$   )rz   )r   keys     r   r'   NumpyDocString.__getitem__   s      %%r   c                 h    XR                   ;  a  U R                  SU-  5        g X R                   U'   g )NzUnknown section %s)rz   _error_location)r   r   vals      r   __setitem__NumpyDocString.__setitem__   s0    '''  !5!;<%(c"r   c                 ,    [        U R                  5      $ r$   )iterrz   r+   s    r   __iter__NumpyDocString.__iter__   s    D%%&&r   c                 ,    [        U R                  5      $ r$   )r:   rz   r+   s    r   __len__NumpyDocString.__len__   s    4$$%%r   c                    U R                   R                  5         U R                   R                  5       (       a  gU R                   R                  5       R	                  5       nUR                  S5      (       a  gU R                   R                  S5      R	                  5       nUR                  S[        U5      -  5      =(       d    UR                  S[        U5      -  5      $ )NF
.. index::Tr.   -=)rv   r6   r0   rP   r   
startswithr:   )r   l1l2s      r   _is_at_sectionNumpyDocString._is_at_section   s    		**,99==??YY^^##%==&&YY^^A$$&}}S3r7]+Kr}}S3r7]/KKr   c                     SnSn[        U5       H  u  p$UR                  5       (       d  M    O   [        US S S2   5       H  u  p4UR                  5       (       d  M    O   X[        U5      U-
   $ )Nr   r   )	enumerater   r:   )r   docijr   s        r   _stripNumpyDocString._strip   sh     ~GAzz|| & !TrT+GAzz|| , s3x!|$$r   c                    U R                   R                  5       nU R                  5       (       d  U R                   R                  5       (       d  U R                   R	                  S5      R                  5       (       d  US/-  nXR                   R                  5       -  nU R                  5       (       d!  U R                   R                  5       (       d  M  U$ )Nr   r/   )rv   rE   r   r0   rP   r   )r   sections     r   _read_to_next_section$NumpyDocString._read_to_next_section   s    ))335%%''		99>>"%++--B4yy88::G	 %%''		 r   c              #   p  #    U R                   R                  5       (       d  U R                  5       nUS   R                  5       nUR	                  S5      (       a	  X!SS  4v   O/[        U5      S:  a	  [        v   OX R                  USS  5      4v   U R                   R                  5       (       d  M  g g 7f)Nr   ..r.      )rv   r0   r   r   r   r:   StopIterationr   )r   r    r]   s      r   _read_sectionsNumpyDocString._read_sections   s     ))--//--/D7==?Dt$$Hn$TQ##KKQR111 ))--//s   B0B64B6c                    [        U5      n/ nUR                  5       (       d  UR                  5       R                  5       nSU;   a  UR	                  S5      S S u  pgOU(       a  SUpvOUSpvUR                  5       n[        U5      n[        U5      nUR                  [        XgU5      5        UR                  5       (       d  M  U$ )N : r   r/   )
r   r0   r2   r   r   rL   r   r   appendr\   )	r   contentsingle_element_is_typerparamsheaderarg_namearg_typer_   s	            r   _parse_param_list NumpyDocString._parse_param_list   s    7O%%''VVX^^%F%+\\%%8!%<"())+Vh)/h113D%D$T*DMM)H=> %%''  r   z:(?P<role>\w+):z'`(?P<name>(?:~\w+\.)?[a-zA-Z0-9_\.-]+)`z(?P<name2>[a-zA-Z0-9_\.-]+)(|)rolerolenextr]   namenextz/(?P<description>\s*:(\s+(?P<desc>\S+.*))?)?\s*$z^\s*z\s*z^\s*(?P<allfuncs>z(?P<morefuncs>([,]\s+z)*)z(?P<trailing>[,\.])?r   c                 @  ^  / nU 4S jn/ nU GH  nUR                  5       (       d  M  T R                  R                  U5      nSnU(       aS  UR                  S5      nUR                  S5      (       a,  U(       a%  T R	                  SUR                  S5      U4-  5        U(       d7  UR                  S5      (       a!  UR                  UR                  5       5        M  U(       a  / nUR                  S5      n	 U	R                  5       (       d  OTU" U	5      u  pnUR                  X45        XS R                  5       n	U	(       a  U	S   S	:X  a  U	S
S R                  5       n	Mj  [        [        SU/5      5      nUR                  X45        GM  [        U S35      e   U$ )z
func_name : Descriptive text
    continued text
another_func_name : Descriptive text
func_name1, func_name2, :meth:`func_name`, func_name3
c                    > TR                   R                  U 5      nU(       d  [        U  S35      eUR                  S5      nU(       a  UR                  S5      OUR                  S5      nX2UR	                  5       4$ )zMatch ':role:`name`' or 'name'. is not a item namer   r]   name2)	_func_rgxmatchr   groupend)textmr   r]   r   s       r   parse_item_name7NumpyDocString._parse_see_also.<locals>.parse_item_name  se    $$T*A D6)<!=>>776?D&*1776?0@Dquuw&&r   Nr_   trailingzGUnexpected comma or period after function list at index %d of line "%s" allfuncsr   ,r.   r   )r   	_line_rgxr   r   r   r   r   r   r   filterr   )r   r   itemsr   restr   
line_matchdescriptionfuncsr   r]   r   	match_ends   `            r   _parse_see_alsoNumpyDocString._parse_see_also  sv    	' D::<<--d3JK(..v6##J//K((",.."<d!CD
 4??3#7#7DJJL)!''
3::<<,;D,A)D	LL$.
+113DQ3#ABx~~/  F4+78e]+ D6)<!=>>= > r   c                 $   S n0 nUR                  S5      n[        U5      S:  a   U" US   R                  S5      5      S   US'   U HD  nUR                  S5      n[        U5      S:  d  M%  U" US   R                  S5      5      XES   '   MF     U$ )	z;
.. index: default
   :refguide: something, else, and more
c                 L    U  Vs/ s H  oR                  5       PM     sn$ s  snf r$   r   )lstss     r   strip_each_in2NumpyDocString._parse_index.<locals>.strip_each_inN  s    '*+s!GGIs+++s   !z::r.   r   r   default:r   )r   r:   )r   r   r   r   r1   r   s         r   _parse_indexNumpyDocString._parse_indexH  s    	, --%w<!*71:+;+;C+@A!DC	ND::c?D4y1},T!W]]3-?@G  
r   c                    U R                  5       (       a  g U R                  R                  5       nSR                  U Vs/ s H  o"R	                  5       PM     sn5      R	                  5       n[
        R                  " S5      nUR                  U5      (       a  X0S'   U R                  5       (       d  M   Ub  XS'   U R                  5       (       d  U R                  5       U S'   ggs  snf )z%Grab signature (if given) and summaryNr   z^([\w., ]+=)?\s*[\w\.]+\(.*\)$rc   rd   re   )	r   rv   rE   r
   r   recompiler   r   )r   summaryr   summary_strcompileds        r   _parse_summaryNumpyDocString._parse_summary[  s       ii779G((w#?w!GGIw#?@FFHKzz"CDH~~k**$/[!**,,%O""$$'+'A'A'CD#$ % $@s   C(c                 *   U R                   R                  5         U R                  5         [        U R	                  5       5      nU VVs1 s H  u  p#UiM	     nnnSU;   nSU;   nU(       a  U(       a  Sn[        U5      eU(       d  SU;   a  Sn[        U5      eU H  u  p#UR                  S5      (       dS  S UR                  S5       5       nSR                  U5      nU R                  U5      (       a  U R                  S	U-  5        US
;   a  U R                  U5      X'   M  US;   a  U R                  USS9X'   M  UR                  S5      (       a  U R                  X#5      U S'   M  US:X  a  U R                  U5      U S'   M  X0U'   M     g s  snnf )Nrg   rh   z5Docstring contains both a Returns and Yields section.ri   z5Docstring contains a Receives section but not Yields.r   c              3   @   #    U  H  oR                  5       v   M     g 7fr$   )
capitalize).0r   s     r   	<genexpr>(NumpyDocString._parse.<locals>.<genexpr>  s     F3Ea<<>>3Es   r   zThe section %s appears twice)rf   rl   rm   rn   )rg   rh   rj   rk   ri   T)r   r   rt   ro   )rv   r   r   r   r   
ValueErrorr   r   r
   getr   r   r   r   )r   ry   r   r   section_nameshas_returns
has_yieldsmsgs           r   r{   NumpyDocString._parseq  s   		++-.9AB%5WB=0.
:ICS/!jM9ICS/!"*W%%d++F7==3EF((7+88G$$((6@    !% 6 6w ?   !% 6 6D !7 ! ##L11 $ 1 1' CWJ&#'#7#7#@Z  'W? #+ Cs   	Fc                     [        U S5      (       a7   [        R                  " U R                  5      nUSU R                   SU S3-   n[        U5      e! [         a    S n N/f = f)N_objz in the docstring of z in .)hasattrinspectgetsourcefiler   	TypeErrorr   )r   r   filenames      r   r   NumpyDocString._error_location  sl    4   "00; '		{$xjBC o    s    A A#"A#c                 "    U[        U5      U-  /$ r$   )r:   )r   r]   symbols      r   _str_headerNumpyDocString._str_header  s    c$i&())r   c                 4    / nU H  nUSU-  U-   /-  nM     U$ )Nr   r[   )r   r   indentr1   r   s        r   _str_indentNumpyDocString._str_indent  s,    DC&L4'((C 
r   c                 P    U S   (       a  U S   R                  SS5      /S/-   $ S/$ )Nrc   *z\*r/   )replacer+   s    r   _str_signatureNumpyDocString._str_signature  s3    %--c59:bTAA4Kr   c                 ,    U S   (       a	  U S   S/-   $ / $ )Nrd   r/   r[   r+   s    r   _str_summaryNumpyDocString._str_summary  s    	?	?bT))Ir   c                 ,    U S   (       a	  U S   S/-   $ / $ )Nre   r/   r[   r+   s    r   _str_extended_summary$NumpyDocString._str_extended_summary  s#    "#*+rd22Ir   c                    / nX   (       a  X R                  U5      -  nX    H  n/ nUR                  (       a  UR                  UR                  5        UR                  (       a  UR                  UR                  5        USR	                  U5      /-  nUR
                  (       d  M  SR	                  UR
                  5      R                  5       (       d  M  X R                  UR
                  5      -  nM     US/-  nU$ )Nr   r/   )r   r]   r   r^   r
   r_   r   r  )r   r]   r1   parampartss        r   _str_param_listNumpyDocString._str_param_list  s    :##D))C::LL,::LL,

5)**:::"''%**"5";";"="=++EJJ77C $ B4KC
r   c                 \    / nX   (       a   X R                  U5      -  nX U   -  nUS/-  nU$ rO   )r   )r   r]   r1   s      r   _str_sectionNumpyDocString._str_section  s;    :##D))C:CB4KC
r   c                    U S   (       d  / $ / nX R                  S5      -  nSnU S    H  u  pE[        U[        5      (       d   e/ nU H=  u  pxU(       a
  SU SU S3n	OU(       a
  SU SU S3n	OSU-  n	UR                  U	5        M?     SR	                  U5      n	X)/-  nU(       a'  X R                  SR	                  U5      /5      -  nSnM  S	nX R                  U R                  /5      -  nM     U(       a  US
/-  nU$ )Nro   Tr   z:``z%s, r   Fr/   )r   r   r   r   r
   r  empty_description)
r   	func_roler1   last_had_descr   r_   linksfuncr   links
             r   _str_see_alsoNumpyDocString._str_see_also  s   JI
++
+KEeT****E#
tfBtfA.DykD63D$;DT" $ 99U#D6MC''$(899 $ %'')?)?(@AA% ,( B4KC
r   c                     U S   n/ nSnUR                  SS5      nU(       a  SnUSU-  /-  nUR                  5        H4  u  pVUS:X  a  M  SnUSR                  USR                  U5      5      /-  nM6     U(       a  U$ g)	Nrt   Fr   r/   Tz.. index:: %sz
   :{}: {}r  )r   r   formatr
   )r   idxr1   output_indexdefault_indexr   
referencess          r   
_str_indexNumpyDocString._str_index  s    7m	2.L-/00#&99;G)#LL'':1FGHHC	 $/
 Jr   c                    / nX R                  5       -  nX R                  5       -  nX R                  5       -  nS H  nX R                  U5      -  nM     X R	                  S5      -  nX R                  U5      -  nS H  nX R	                  U5      -  nM     S H  nX R                  U5      -  nM     X R                  5       -  nSR                  U5      $ )N)rf   rg   rh   ri   rl   rj   rk   rq   )rp   rr   rs   )rm   rn   r   )r  r  r  r  r  r!  r)  r
   )r   r  r1   
param_listr   s        r   __str__NumpyDocString.__str__  s    ""$$  ""))++
J ''
33C
 	  ,,!!),,4A$$Q''C 53J''
33C 4  yy~r   )rv   rz   N)F)r   )   )r/   ),rU   rV   rW   rX   rY   ry   r!   r'   r   r   r   r   r   r   r   r   _role_funcbacktick
_funcplain	_funcnamer  _funcnamenext_descriptionr   r   r   r   r  r   r   r   r{   r   r   r  r  r  r  r  r  r!  r)  r-  rZ   r[   r   r   ra   ra   l   s4   
RB4 	B 	b	
 	2 	" 	B 	" 	 	B 	b 	2 	B 	 	B  	b!" 	B#$ 	%H*&)'&L%	
2J E>M/Ju},t3j@4GI%%fj9M!))&*=MEL

7Y.78I

	
	 #	# 		
 	 	 	 		  
	I 3j&D,0(d* <$r   ra   c                   @    \ rS rSrSrS rS rS rS rSS jr	S r
S	rg
)	Docstringi.  z]
Docstring modification.

Parameters
----------
docstring : str
    The docstring to modify.
c                 F    S U l         Xl        Uc  g [        U5      U l         g r$   )_ds
_docstringra   )r   r|   s     r   r!   Docstring.__init__8  s#    #!),r   c                 P   U R                   c  g[        U[        5      (       a  U/nU R                  S    Vs/ s H  nUR                  U;  d  M  UPM     nn[        U5      [        U5      -   [        U R                  S   5      :w  a  [        S5      eX0R                  S'   gs  snf )z^
Parameters
----------
parameters : str, list[str]
    The names of the parameters to remove.
Nrf   z&One or more parameters were not found.)r:  r   strr9  r]   r:   r   )r   
parametersr  repls       r   remove_parametersDocstring.remove_parameters?  s     ??"j#&&$J ,/
/zz+ / 	 

 t9s:&#dhh|.D*EEEFF!%
s   B#B#c                    U R                   c  g[        U[        5      (       a  U/nUc  X R                  S   -   U R                  S'   gSn[	        U R                  S   5       H  u  pEUR
                  U:X  d  M  US-   n  O   US:  a
  [        5       eU R                  S   SU U-   nX`R                  S   US -  nX`R                  S'   g)z
Parameters
----------
after : {None, str}
    If None, inset the parameters before the first parameter in the
    docstring.
parameters : Parameter, list[Parameter]
    A Parameter of a list of Parameters.
Nrf   r   r.   r   )r:  r   r\   r9  r   r]   r   )r   afterr>  locr   r  r   s          r   insert_parametersDocstring.insert_parametersT  s     ??"j),,$J=%/((<2H%HDHH\"C%dhh|&<=::&a%C > Qw l"XXl+DS1J>Fhh|,ST22F%+HH\"r   c                 r   U R                   c  gSR                  [        [        R                  UR                  S5      5      5      nXR                  ;  a  [        SR                  U5      5      e[        U[        5      (       d%  [        U R                  U   [        5      (       a  U/nX R                  U'   g)z
Parameters
----------
block_name : str
    Name of the block to replace, e.g., 'Summary'.
block : object
    The replacement block. The structure of the replacement block must
    match how the block is stored by NumpyDocString.
Nr   z"{} is not a block in the docstring)r:  r
   mapr=  r   r   r9  r   r$  r   r   )r   
block_nameblocks      r   replace_blockDocstring.replace_blockq  s     ??"XXc#..*2B2B32GHI
XX%7>>zJ  %&&:HHZ $,
 ,
 GE$r   c                    U R                   c  g [        U[        5      (       a  U/nU R                  S    Vs0 s H  o3R                  U_M     nn[        U5      R                  UR                  5       5      nU(       a)  [        SR                  SR                  U5      5      5      eU Vs/ s H  o4U   PM	     nn[        R                  " U R                  5      nU H  nUS:w  a  US:w  a  / O0 Xx'   M  XgU'   M     [        U5      R                  5       n	U(       a  [        R                  " U	SU-  5      n	SR                  U	R!                  S5      SS  5      n	U	$ s  snf s  snf )Nrf   z"{} were not found in the docstringr   rt   r   r   r   )r:  r   r=  r9  r]   set
differencekeysr   r$  r
   rw   rx   r   r   r  r   )
r   r>  r  r  	ds_paramsmissingfinaldsr   r1   s
             r   extract_parametersDocstring.extract_parameters  s4   ??"j#&&$J48HH\4JK4J5ZZ&4J	Kj/,,Y^^-=>"F388G#45  0::ze5!z:]]488$Cl" #w"B3	 
 "gmmo//#sV|4Cii		$+,
' L ;s   E,E!c                 ,    [        U R                  5      $ r$   )r=  r9  r+   s    r   r-  Docstring.__str__  s    488}r   )r:  r9  NrT   )rU   rV   rW   rX   rY   r!   r@  rE  rK  rU  r-  rZ   r[   r   r   r7  r7  .  s%    -&*,:%06r   r7  c                 X    U c  g[        U 5      nUR                  U5        [        U5      $ )z
Parameters
----------
docstring : str
    The docstring to modify.
parameters : str, list[str]
    The names of the parameters to remove.

Returns
-------
str
    The modified docstring.
N)r7  r@  r=  )r|   r>  rT  s      r   r@  r@    s.     	9	B$r7Nr   c                 4    U c  g[         R                  " XUS9$ )a  
Non-protected indent

Parameters
----------
text : {None, str}
    If None, function always returns ""
prefix : str
    Prefix to add to the start of each line
predicate : callable, optional
    If provided, 'prefix' will only be added to the lines
    where 'predicate(line)' is True. If 'predicate' is not provided,
    it will default to adding 'prefix' to all non-empty lines that do not
    consist solely of whitespace characters.

Returns
-------

r/   )	predicate)r   r  )r   prefixr[  s      r   r  r    s    ( |??49==r   r$   )rY   collectionsr   collections.abcr   rw   r   r   r   statsmodels.tools.sm_exceptionsr   r   r   r   r\   ra   r7  r@  r  r[   r   r   <module>r`     sm    # #   	  69
J. J.Z {$<=	W Dw wt*>r   