def check_n_jobs(n_jobs, allow_cuda=False):
 if (not isinstance(n_jobs, int)):
  if (not allow_cuda):
   raise ValueError('n_jobs must be an integer')
  elif ((not isinstance(n_jobs, string_types)) or (n_jobs != 'cuda')):
   raise ValueError('n_jobs must be an integer, or "cuda"')
 elif _force_serial:
  n_jobs = 1
  logger.info('... MNE_FORCE_SERIAL set. Processing in forced serial mode.')
 elif (n_jobs <= 0):
  try:
   import multiprocessing
   n_cores = multiprocessing.cpu_count()
   n_jobs = min(((n_cores + n_jobs) + 1), n_cores)
   if (n_jobs <= 0):
    raise ValueError(("If n_jobs has a negative value it must not be less than the number of CPUs present. You've got %s CPUs" % n_cores))
  except ImportError:
   if (n_jobs != 1):
    warn('multiprocessing not installed. Cannot run in parallel.')
    n_jobs = 1
 return n_jobs

def check_n_jobs ( n_jobs , allow_cuda = False ) : if ( not isinstance ( n_jobs , int ) ) : if ( not allow_cuda ) : raise ValueError ( 'n_jobs must be an integer' ) elif ( ( not isinstance ( n_jobs , string_types ) ) or ( n_jobs != 'cuda' ) ) : raise ValueError ( 'n_jobs must be an integer, or "cuda"' ) elif _force_serial : n_jobs = 1 logger . info ( '... MNE_FORCE_SERIAL set. Processing in forced serial mode.' ) elif ( n_jobs <= 0 ) : try : import multiprocessing n_cores = multiprocessing . cpu_count ( ) n_jobs = min ( ( ( n_cores + n_jobs ) + 1 ) , n_cores ) if ( n_jobs <= 0 ) : raise ValueError ( ( "If n_jobs has a negative value it must not be less than the number of CPUs present. You've got %s CPUs" % n_cores ) ) except ImportError : if ( n_jobs != 1 ) : warn ( 'multiprocessing not installed. Cannot run in parallel.' ) n_jobs = 1 return n_jobs
check n_jobs in particular for negative values .