Returns a graph of the distribution of jobs in a sorted set
765226
def get_sorted_graph(
            self,
            start=0,
            stop=100,
            slices=100,
            include_inf=False,
            exact=False):
        

        if not self.is_sorted:
            raise Exception("Not a sorted queue")

        with context.connections.redis.pipeline(transaction=exact) as pipe:
            interval = old_div(float(stop - start), slices)
            for i in range(0, slices):
                pipe.zcount(self.redis_key,
                            (start + i * interval),
                            "(%s" % (start + (i + 1) * interval))
            if include_inf:
                pipe.zcount(self.redis_key, stop, "+inf")
                pipe.zcount(self.redis_key, "-inf", "(%s" % start)
            data = pipe.execute()

        if include_inf:
            return data[-1:] + data[:-1]

        return data
998107
def get_jids_filter(count, filter_find_job=True):
    '''
    
    '''
    keys = []
    ret = []
    for jid, job, _, _ in _walk_through(_job_dir()):
        job = salt.utils.jid.format_jid_instance_ext(jid, job)
        if filter_find_job and job['Function'] == 'saltutil.find_job':
            continue
        i = bisect.bisect(keys, jid)
        if len(keys) == count and i == 0:
            continue
        keys.insert(i, jid)
        ret.insert(i, job)
        if len(keys) > count:
            del keys[0]
            del ret[0]
    return ret
1220853
def laplacian_reordering(G):
  ''''''
  L = G.laplacian()
  vals, vecs = np.linalg.eigh(L)
  min_positive_idx = np.argmax(vals == vals[vals>0].min())
  vec = vecs[:, min_positive_idx]
  return permute_graph(G, np.argsort(vec))
359565
def _calc_q_h0(n, x, h, nt, n_jobs=1, verbose=0, random_state=None):
    
    rng = check_random_state(random_state)
    par, func = parallel_loop(_calc_q_statistic, n_jobs, verbose)
    q = par(func(rng.permutation(x.T).T, h, nt) for _ in range(n))
    
    return np.array(q)
1002247
def _job_sorting_key(self, job):
        

        if self._base_graph is None:
            # we don't do sorting if there is no base_graph
            return 0

        MAX_JOBS = 1000000

        if job.addr not in self._node_addr_visiting_order:
            return MAX_JOBS

        return self._node_addr_visiting_order.index(job.addr)
1304245
private List<Job> getJobs(final Jedis jedis, final String queueName, final long jobOffset, final long jobCount) throws Exception {
        final String key = key(QUEUE, queueName);
        final List<Job> jobs = new ArrayList<>();
        if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZRANGEWITHSCORES
            final Set<Tuple> elements = jedis.zrangeWithScores(key, jobOffset, jobOffset + jobCount - 1);
            for (final Tuple elementWithScore : elements) {
                final Job job = ObjectMapperFactory.get().readValue(elementWithScore.getElement(), Job.class);
                job.setRunAt(elementWithScore.getScore());
                jobs.add(job);
            }
        } else { // Else, use LRANGE
            final List<String> elements = jedis.lrange(key, jobOffset, jobOffset + jobCount - 1);
            for (final String element : elements) {
                jobs.add(ObjectMapperFactory.get().readValue(element, Job.class));
            }
        }
        return jobs;
    }
450042
private static void dumpHadoopCounters(PigStats pigStats) {
    try {
      if (props.getBoolean(PIG_DUMP_HADOOP_COUNTER_PROPERTY, false)) {
        if (pigStats != null) {
          JobGraph jGraph = pigStats.getJobGraph();
          Iterator<JobStats> iter = jGraph.iterator();
          while (iter.hasNext()) {
            JobStats jobStats = iter.next();
            System.out.println("\n === Counters for job: "
                + jobStats.getJobId() + " ===");
            Counters counters = jobStats.getHadoopCounters();
            if (counters != null) {
              for (Counters.Group group : counters) {
                System.out.println(" Counter Group: " + group.getDisplayName()
                    + " (" + group.getName() + ")");
                System.out.println("  number of counters in this group: "
                    + group.size());
                for (Counters.Counter counter : group) {
                  System.out.println("  - " + counter.getDisplayName() + ": "
                      + counter.getCounter());
                }
              }
            } else {
              System.out.println("There are no counters");
            }
          }
        } else {
          System.out.println("pigStats is null, can't dump Hadoop counters");
        }
      }
    } catch (Exception e) {
      System.out.println("Unexpected error: " + e.getMessage());
      e.printStackTrace(System.out);
    }
  }
1034334
public Set<AllocationID> getAllocationIdsPerJob(JobID jobId) {
		final Set<AllocationID> allocationIds = slotsPerJob.get(jobId);

		if (allocationIds == null) {
			return Collections.emptySet();
		} else {
			return Collections.unmodifiableSet(allocationIds);
		}
	}
884997
def visualise(seq, sort=lambda x: x[0]):
    """"""
    frmt = "{:6} {:8,d} {}"
    if isinstance(seq, dict):
        seq = seq.items()
    if sort:
        seq = sorted(seq, key=sort)
    mx, mn = max([i[1] for i in seq]), min([i[1] for i in seq])  
    range = mx - mn
    for i in seq:
        v = int((i[1] * 100) / range)
        print (frmt.format(i[0], i[1], "*" * v))
994365
function graph(g) {
    init(g);

    var xs = [upperLeft(g), upperRight(g), lowerRight(g), lowerLeft(g)];

    g.nodes().forEach(function(u) {
      var xArray = [];
      for (var i = 0; i < xs.length; ++i) {
        xArray.push(xs[i][u]);
      }
      xArray.sort();
      g.node(u).x = (xArray[1] + xArray[2]) / 2;
    });
  }
1017518
def results( self ):
        """"""
        rs = []
        for k in self._results.keys():
            # filter out pending job ids, which can be anything except dicts
            ars = [ res for res in self._results[k] if isinstance(res, dict) ]
            rs.extend(ars)
        return rs
3580
def _job_statistics(self):
        """"""
        statistics = self._properties.get("statistics", {})
        return statistics.get(self._JOB_TYPE, {})
969539
def current_jobs(self):
    

    jobs = []
    with synchronized(self.__queue):
      for worker in self.__threads:
        with synchronized(worker):
          if worker.current:
            jobs.append(worker.current)
    return jobs
888035
def count_waiting_jobs(cls, names):
        
        return sum([queue.waiting.llen() for queue in cls.get_all(names)])
52463
def _job_sorting_key(self, job):
        

        MAX_BLOCKS_PER_FUNCTION = 1000000

        task_functions = list(reversed(
            list(task.function_address for task in self._task_stack if isinstance(task, FunctionAnalysis))
            ))
        try:
            function_pos = task_functions.index(job.func_addr)
        except ValueError:
            # not in the list
            # it might be because we followed the wrong path, or there is a bug in the traversal algorithm
            # anyways, do it first
            l.warning('Function address %#x is not found in task stack.', job.func_addr)
            return 0

        try:
            block_in_function_pos = self._ordered_node_addrs(job.func_addr).index(job.addr)
        except ValueError:
            # block not found. what?
            block_in_function_pos = min(job.addr - job.func_addr, MAX_BLOCKS_PER_FUNCTION - 1)

        return block_in_function_pos + MAX_BLOCKS_PER_FUNCTION * function_pos
199015
def getnjobs(self, key, **kwargs):
        

        return self.get(key, cast_func=parse_n_jobs, **kwargs)
1170492
def _makeJobGraphs(self, jobGraph, jobStore):
        
        jobsToJobGraphs = {self:jobGraph}
        for successors in (self._followOns, self._children):
            jobs = [successor._makeJobGraphs2(jobStore, jobsToJobGraphs) for successor in successors]
            jobGraph.stack.append(jobs)
        return jobsToJobGraphs