ó
àÆ÷Xc           @  sÈ   d  Z  d d l m Z d Z d Z d d l Z e j d ƒ Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l m Z d „  Z d	 „  Z d
 „  Z d e f d „  ƒ  YZ e d k rÄ e ƒ  n  d S(   sÅ  
This script should behave the same as the `nosetests` command.

The reason for its existence is that on some systems, it may not be obvious to
find where nosetests is installed in order to run it in a different process.

It is also used to load the KnownFailure plugin, in order to hide
KnownFailureTests error messages. Use --without-knownfailure to
disable that plugin.

`run_tests_in_batch.py` will in turn call back this script in another process.
iÿÿÿÿ(   t   print_functions.   Olivier Delalleau, Pascal Lamblin, Eric Larsens   delallea@iroNs   theano.bin.theano-nose(   t   Pluginc       	   C  sq  d t  j k rD t  j j d ƒ }  d d  l } | j d t  j |  <n  t j j d ƒ sŸ y2 d d l m } | j	 d k r‡ t
 d ƒ ‚ n  WqŸ t k
 r› qŸ Xn  g  t  j D] } | j d ƒ r© | ^ q© } x | D] } t  j j | ƒ qÑ Wd  } t | ƒ rct | ƒ d	 k rt j d
 ƒ n  | d } | j d d	 ƒ } t | ƒ d k rct | d	 ƒ } qcn  t } d t  j k rÔ| st d ƒ ‚ n  x# d t  j k r²t  j j d ƒ qWt  j d d d g 7_ t } n  g  t  j D] } | d k rÞ| ^ qÞ}	 x |	 D] } t  j j | ƒ qW|	 s)| rmd d l m }
 |
 j d t j j t ƒ d | d t |	 ƒ d | ƒ Sg  } d t  j k rÊy$ d d l m } | j | ƒ  ƒ WqÚt k
 rÆt j d ƒ qÚXn t  j j d ƒ d t  j k rü| j t  ƒ  ƒ n  y/ | rt! j d | ƒ } n t! j ƒ  } | SWn? t" k
 rl} d | j# k rft j d ƒ t! j ƒ  qm‚  n Xd  S(   Ns   --theanoiÿÿÿÿi    s   theano/__init__.py(   t   configt   cpusÞ   Theano tests must be run with device=cpu. This will also run GPU tests when possible.
 If you want GPU-related tests to run on a specific GPU device, and not the default one, you should use the init_gpu_device theano flag.s   --batchi   sT   Multiple --batch arguments detected, using the last one and ignoring the first ones.t   =i   s   --debug-batchsG   You can only use the --debug-batch argument with the --batch[=n] options	   --verboses   --nocaptures   --detailed-errorss   --time-profile(   t   run_tests_in_batcht   theano_noset
   batch_sizet   time_profilet   display_batch_outputs   --without-knownfailure(   t   KnownFailuresi   KnownFailure plugin from NumPy could not be imported. Use --without-knownfailure to disable this warning.s   --disabdocstringt
   addpluginss/   got an unexpected keyword argument 'addplugins'sy   KnownFailure plugin from NumPy can't be used as nosetests is too old. Use --without-knownfailure to disable this warning.($   t   syst   argvt   indext   theanot   __path__t   ost   patht   existsR   t   devicet
   ValueErrort   ImportErrort
   startswitht   removet   Nonet   lent   _loggert   warnt   splitt   intt   Falset   AssertionErrort   Truet   theano.testsR   t   maint   realpatht   __file__t   boolt   numpy.testing.noseclassesR
   t   appendt   DisabDocStringt   noset	   TypeErrort   message(   t   iR   R   t   argt
   batch_argsR   t	   batch_argt   elemsR	   t   time_prof_argsR   R   R
   t   rett   e(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   main_function   s€    
+

	(	c          C  s   d }  t  t j |  ƒ ƒ d  S(   NsH  
        This script behaves mostly the same as the `nosetests` command.

        The main difference is that it loads automatically the
        KnownFailure plugin, in order to hide KnownFailureTests error
        messages. It also supports executing tests by batches.

        Local options:

            --help, -h: Displays this help.

            --batch[=n]:
                If specified without option '--time-profile', do not run all
                the tests in one run, but split the execution in batches of
                `n` tests each. Default n is 100.

            --time-profile:
                Each test will be run and timed separately and the results will
                be deposited in the files 'timeprof_sort', 'timeprof_nosort'
                and 'timeprof_rawlog' in the current directory. If the
                '--batch[=n]' option is also specified, notification of the
                progresses will be made to standard output after every group of
                n tests. Otherwise, notification will occur after every group
                of 100 tests.

                The files 'timeprof_sort' and 'timeprof_nosort' both contain one
                record for each test and comprise the following fields:
                - test running-time
                - nosetests sequential test number
                - test name
                - name of class to which test belongs (if any), otherwise full
                  information is contained in test name
                - test outcome ('OK', 'SKIPPED TEST', 'FAILED TEST' or
                  'FAILED PARSING')

                In 'timeprof_sort', test records are sorted according to
                running-time whereas in 'timeprof_nosort' records are reported
                according to sequential number. The former classification is the
                main information source for time-profiling. Since tests belonging
                to same or close classes and files have close sequential, the
                latter may be used to identify duration patterns among the tests
                numbers. A full log is also saved as 'timeprof_rawlog'.

            --without-knownfailure: Do not load the KnownFailure plugin.

            --theano: This parameter is replaced with the path to the theano
                      library. As theano-nose is a wrapper to nosetests, it
                      expects a path to the tests to run.
                      If you do not know where theano is installed, use this
                      option to have it inserted automatically.

            --debug-batch:
                Use this parameter to run nosetests with options '--verbose',
                '--nocapture' and '--detailed-errors' and show the output of
                nosetests during batch execution.  This can be useful to debug
                situations where re-running only the failed tests after batch
                execution is not working properly. This option can only be used
                in conjunction with the '--batch=[n]' argument.

        The other options will be passed to nosetests, see ``nosetests -h``.
        (   t   printt   textwrapt   dedent(   t   help_msg(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   help‰   s    =c          C  sB   d t  j k s d t  j k r( t ƒ  n t ƒ  }  t  j |  ƒ d  S(   Ns   --helps   -h(   R   R   R:   R5   t   exit(   t   result(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyR#   Ë   s    
	R)   c           B  s>   e  Z d  Z e Z d Z d „  Z d „  Z d „  Z d „  Z	 RS(   su  
    When activated, a custom Nosetests plugin created through this class
    will preclude automatic replacement in display of the name of the test
    by the first line in its documentation string.

    Sources:
    http://nose.readthedocs.org/en/latest/developing.html
    http://nose.readthedocs.org/en/latest/further_reading.html
    http://www.siafoo.net/article/54
    https://github.com/nose-devs/nose/issues/294
    http://python-nose.googlecode.com/svn/trunk/nose/plugins/base.py
    Nat Williams:
    https://github.com/Merino/nose-description-fixer-plugin/commit/
        df94596f29c04fea8001713dd9b04bf3720aebf4
    iÐ  c         C  sY   |  j  d  k r' |  j j j ƒ  |  _  n  |  j d  k rU d |  j  j d d ƒ |  _ n  d  S(   Ns   enable_plugin_%st   -t   _(   t   nameR   t	   __class__t   __name__t   lowert	   enableOptt   replace(   t   self(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   __init__è   s
    c         C  sh   d |  j  j ƒ  } | j d |  j  d d d |  j d | j | ƒ d d |  j j |  j ƒ  | f ƒd  S(	   Ns   NOSE_WITH_%ss   --%st   actiont
   store_truet   destt   defaultR:   s   Enable plugin %s: %s [%s](   R?   t   uppert
   add_optionRC   t   getR@   RA   R:   (   RE   t   parsert   envt   env_opt(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   optionsð   s    		c         C  s"   | |  _  t | |  j ƒ |  _ d  S(   N(   t   conft   getattrRC   t   enabled(   RE   RQ   RR   (    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt	   configure  s    	c         C  s   t  S(   N(   R   (   RE   t   test(    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   describeTest  s    (
   RA   t
   __module__t   __doc__R   RT   t   scoreRF   RQ   RU   RW   (    (    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyR)   Ó   s   			t   __main__(   RY   t
   __future__R    t   __authors__t   __contact__t   loggingt	   getLoggerR   R   R*   R7   R   t   nose.pluginsR   R5   R:   R#   R)   RA   (    (    (    s/   /tmp/pip-build-X4mzal/theano/bin/theano_nose.pyt   <module>   s    	m	B	9