original_docstring: 
      A decorator for nosetests test functions that manages rng seeds.
  
      Parameters
      ----------
  
      seed : the seed to pass to np.random and mx.random
  
  
      This tests decorator sets the np, mx and python random seeds identically
      prior to each test, then outputs those seeds if the test fails or
      if the test requires a fixed seed (as a reminder to make the test
      more robust against random data).
  
      @with_seed()
      def test_ok_with_random_data():
          ...
  
      @with_seed(1234)
      def test_not_ok_with_random_data():
          ...
  
      Use of the @with_seed() decorator for all tests creates
      tests isolation and reproducability of failures.  When a
      test fails, the decorator outputs the seed used.  The user
      can then set the environment variable MXNET_TEST_SEED to
      the value reported, then rerun the test with:
  
          nosetests --verbose -s <test_module_name.py>:<failing_test>
  
      To run a test repeatedly, set MXNET_TEST_COUNT=<NNN> in the environment.
      To see the seeds of even the passing tests, add '--logging-level=DEBUG' to nosetests.
      
docstring: A decorator for nosetests test functions that manages rng seeds.
  Parameters
  
  seed : the seed to pass to np.random and mx.random
  
  This tests decorator sets the np, mx and python random seeds identically
  prior to each test, then outputs those seeds if the test fails or
  if the test requires a fixed seed (as a reminder to make the test
  more robust against random data).
  
  
  
  
  
  Use of the @with_seed() decorator for all tests creates
  tests isolation and reproducability of failures.  When a
  test fails, the decorator outputs the seed used.  The user
  can then set the environment variable MXNET_TEST_SEED to
  the value reported, then rerun the test with.
  
  -verbose -s :
  
  To run a test repeatedly, set MXNET_TEST_COUNT= in the environment.
  To see the seeds of even the passing tests, add '--logging-level=DEBUG' to nosetests.
docstring_tokens: A decorator for nosetests test functions that manages rng seeds . Parameters seed : the seed to pass to np . random and mx . random This tests decorator sets the np mx and python random seeds identically prior to each test then outputs those seeds if the test fails or if the test requires a fixed seed ( as a reminder to make the test more robust against random data ) . Use of the @with_seed () decorator for all tests creates tests isolation and reproducability of failures . When a test fails the decorator outputs the seed used . The user can then set the environment variable MXNET_TEST_SEED to the value reported then rerun the test with . - verbose - s : To run a test repeatedly set MXNET_TEST_COUNT = in the environment . To see the seeds of even the passing tests add ' -- logging - level = DEBUG ' to nosetests .
code: def with_seed(seed=None):
      """
      A decorator for nosetests test functions that manages rng seeds.
  
      Parameters
      ----------
  
      seed : the seed to pass to np.random and mx.random
  
  
      This tests decorator sets the np, mx and python random seeds identically
      prior to each test, then outputs those seeds if the test fails or
      if the test requires a fixed seed (as a reminder to make the test
      more robust against random data).
  
      @with_seed()
      def test_ok_with_random_data():
          ...
  
      @with_seed(1234)
      def test_not_ok_with_random_data():
          ...
  
      Use of the @with_seed() decorator for all tests creates
      tests isolation and reproducability of failures.  When a
      test fails, the decorator outputs the seed used.  The user
      can then set the environment variable MXNET_TEST_SEED to
      the value reported, then rerun the test with:
  
          nosetests --verbose -s <test_module_name.py>:<failing_test>
  
      To run a test repeatedly, set MXNET_TEST_COUNT=<NNN> in the environment.
      To see the seeds of even the passing tests, add '--logging-level=DEBUG' to nosetests.
      """
      def test_helper(orig_test):
          @make_decorator(orig_test)
          def test_new(*args, **kwargs):
              test_count = int(os.getenv('MXNET_TEST_COUNT', '1'))
              env_seed_str = os.getenv('MXNET_TEST_SEED')
              for i in range(test_count):
                  if seed is not None:
                      this_test_seed = seed
                      log_level = logging.INFO
                  elif env_seed_str is not None:
                      this_test_seed = int(env_seed_str)
                      log_level = logging.INFO
                  else:
                      this_test_seed = np.random.randint(0, np.iinfo(np.int32).max)
                      log_level = logging.DEBUG
                  post_test_state = np.random.get_state()
                  np.random.seed(this_test_seed)
                  mx.random.seed(this_test_seed)
                  random.seed(this_test_seed)
                  logger = default_logger()
                  # 'nosetests --logging-level=DEBUG' shows this msg even with an ensuing core dump.
                  test_count_msg = '{} of {}: '.format(i+1,test_count) if test_count > 1 else ''
                  test_msg = ('{}Setting test np/mx/python random seeds, use MXNET_TEST_SEED={}'
                              ' to reproduce.').format(test_count_msg, this_test_seed)
                  logger.log(log_level, test_msg)
                  try:
                      orig_test(*args, **kwargs)
                  except:
                      # With exceptions, repeat test_msg at INFO level to be sure it's seen.
                      if log_level < logging.INFO:
                          logger.info(test_msg)
                      raise
                  finally:
                      np.random.set_state(post_test_state)
          return test_new
      return test_helper
code_tokens: def with_seed ( seed = None ) : def test_helper ( orig_test ) : @ make_decorator ( orig_test ) def test_new ( * args , ** kwargs ) : test_count = int ( os . getenv ( 'MXNET_TEST_COUNT' , '1' ) ) env_seed_str = os . getenv ( 'MXNET_TEST_SEED' ) for i in range ( test_count ) : if seed is not None : this_test_seed = seed log_level = logging . INFO elif env_seed_str is not None : this_test_seed = int ( env_seed_str ) log_level = logging . INFO else : this_test_seed = np . random . randint ( 0 , np . iinfo ( np . int32 ) . max ) log_level = logging . DEBUG post_test_state = np . random . get_state ( ) np . random . seed ( this_test_seed ) mx . random . seed ( this_test_seed ) random . seed ( this_test_seed ) logger = default_logger ( ) test_count_msg = '{} of {}: ' . format ( i + 1 , test_count ) if test_count > 1 else '' test_msg = ( '{}Setting test np/mx/python random seeds, use MXNET_TEST_SEED={}' ' to reproduce.' ) . format ( test_count_msg , this_test_seed ) logger . log ( log_level , test_msg ) try : orig_test ( * args , ** kwargs ) except : if log_level < logging . INFO : logger . info ( test_msg ) raise finally : np . random . set_state ( post_test_state ) return test_new return test_helper
short_docstring: A decorator for nosetests test functions that manages rng seeds.
short_docstring_tokens: A decorator for nosetests test functions that manages rng seeds .
comment: """
      A decorator for nosetests test functions that manages rng seeds.
  
      Parameters
      ----------
  
      seed : the seed to pass to np.random and mx.random
  
  
      This tests decorator sets the np, mx and python random seeds identically
      prior to each test, then outputs those seeds if the test fails or
      if the test requires a fixed seed (as a reminder to make the test
      more robust against random data).
  
      @with_seed()
      def test_ok_with_random_data():
          ...
  
      @with_seed(1234)
      def test_not_ok_with_random_data():
          ...
  
      Use of the @with_seed() decorator for all tests creates
      tests isolation and reproducability of failures.  When a
      test fails, the decorator outputs the seed used.  The user
      can then set the environment variable MXNET_TEST_SEED to
      the value reported, then rerun the test with:
  
          nosetests --verbose -s <test_module_name.py>:<failing_test>
  
      To run a test repeatedly, set MXNET_TEST_COUNT=<NNN> in the environment.
      To see the seeds of even the passing tests, add '--logging-level=DEBUG' to nosetests.
      """$SEP$# 'nosetests --logging-level=DEBUG' shows this msg even with an ensuing core dump.$SEP$# With exceptions, repeat test_msg at INFO level to be sure it's seen.