
    6bi                     4   S r SSKJ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	J
s  Jr  SSKJr  SSKJr  SSKJr  \R                  R&                  R)                  5         SSKr\R,                  r\R.                  " S	SS
5        \R0                  " SSS5        \R.                  " SSS5        \R2                  " S	S/5        \R2                  " SS/5        SrS rS rS r " S S\R<                  R>                  5      r S r!\"S:X  a  \RF                  " 5         gg)zRun doctests for tensorflow.    )absolute_import)division)print_functionN)flags)absltest)keras_doctest_libmodulez$A specific module to run doctest on.listz2List all the modules in the core package imported.filez"A specific file to run doctest on.zkeras.c                      / n [         R                  R                  5        H2  u  pUR                  [        5      (       d  M!  U R                  U5        M4     U $ )zxFinds all the modules in the core package imported.

Returns:
  A list containing all the modules in tensorflow.python.
)sysmodulesitems
startswithPACKAGEappend)
tf_modulesnamer	   s      Z/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/tests/keras_doctest.pyfind_modulesr   3   sG     J))+??7##f% ,     c                 f    U  Vs/ s H  n[         U-   UR                  ;   d  M  UPM      nnU$ s  snf )a  Filters all the modules based on the module flag.

The module flag has to be relative to the core package imported.
For example, if `submodule=keras.layers` then, this function will return
all the modules in the submodule.

Args:
  all_modules: All the modules in the core package.
  submodule: Submodule to filter from all the modules.

Returns:
  All the modules in the submodule.
)r   __name__)all_modules	submodulemodfiltered_moduless       r   filter_on_submodulesr   B   s=      #"g	&9S\\&I{   s   ..c                    [         R                  R                  U 5      n U R                  [        R                  S[         R                  5      5      n[         R                  R                  XS 5      u  p#[        R                  UR                  [         R                  S5         n[        U S5       nUR                  5       nSSS5        WUl        U/$ ! , (       d  f       N= f)zReplaces the docstring of the module with the changed file's content.

Args:
  file_path: Path to the file

Returns:
  A list containing the module changed by the file.
.Nr)ospathabspathfindr   replacesepsplitextr   r   openread__doc__)	file_path	mod_indexfile_mod_name_file_modulefcontents          r   get_module_and_inject_docstringr3   W   s     	*IwsBFF;<Iww''	*(=>M++m33BFFC@AK	i	&&( 
 "K= 
	s   3C
C$c                        \ rS rSrS rS rSrg)
TfTestCasen   c                 $    U R                  5         g N)setUpselfr/   s     r   set_upTfTestCase.set_upo   s    

r   c                 $    U R                  5         g r8   )tearDownr:   s     r   	tear_downTfTestCase.tear_downr   s    r    N)r   
__module____qualname____firstlineno__r<   r@   __static_attributes__rB   r   r   r5   r5   n   s    r   r5   c                    [        5       n[        R                  (       a  [        U[        R                  5      n[        R                  (       a6  [        S5        U H  n[        UR                  5        M     [        S5        U$ [        R                  (       a  [        [        R                  5      nU H  n[        5       nUR                  [        R                  " U[        R                  " SS9[        [        [         S.UR"                  UR$                  [&        R(                  " 5       [        R*                  [        R,                  -  [        R.                  -  [        R0                  -  S95        M     U$ )z4Loads all the tests in the docstrings and runs them.z2**************************************************F)exclude_empty)tfnpr"   )test_finder
extraglobsr9   r?   checkeroptionflags)r   FLAGSr	   r   r
   printr   r   r3   r5   addTestsdoctestDocTestSuiteDocTestFinderrI   rJ   r"   r<   r@   r   KerasDoctestOutputCheckerELLIPSISNORMALIZE_WHITESPACEIGNORE_EXCEPTION_DETAILDONT_ACCEPT_BLANKLINE)unused_loadertestsunused_ignorer   r   r	   testcases          r   
load_testsr^   v   s	    J||)*ellC
zzBCC#,, BCzz4UZZ@
<  #11F"$Bb9oo!++)CCE$$223556 334	
 $ Lr   __main__)$r+   
__future__r   r   r   r"   r   numpyrJ   tensorflow.compat.v2compatv2rI   abslr   absl.testingr   tf_keras.src.testing_infrar   v1enable_v2_behaviorrR   rO   DEFINE_stringDEFINE_booleanmark_flags_as_mutual_exclusiver   r   r   r3   testTestCaser5   r^   r   mainrB   r   r   <module>rp      s    # &  % 	 
  ! !  ! 8 		   !    Hd$J K   
DF   FD"F G  $ $h%7 8  $ $ff%5 6
*.!! $N zMMO r   