Get all pledged delegates for a candidate in this election.
543087
def get_candidate_delegates(self, candidate):
        
        candidate_election = CandidateElection.objects.get(
            candidate=candidate, election=self
        )

        return candidate_election.delegates.all()
288216
def get_candidate_votes(self, candidate):
        
        candidate_election = CandidateElection.objects.get(
            candidate=candidate, election=self
        )

        return candidate_election.votes.all()
153855
function delegate (root, filter, fn) {
  if (delegates[fn._dd]) {
    return delegates[fn._dd];
  }
  fn._dd = Date.now();
  delegates[fn._dd] = delegator;
  function delegator (e) {
    var el = e.target;
    while (el && el !== root) {
      if (api.matches(el, filter)) {
        fn.apply(this, arguments); return;
      }
      el = el.parentElement;
    }
  }
  return delegator;
}
1311851
def on_created(self, event):
        """"""
        for delegate in self.delegates:
            if hasattr(delegate, "on_created"):
                delegate.on_created(event)
1162311
public void applyToDelegates (DelegateOp op)
    {
        if (_delegates != null) {
            for (int ii = 0, ll = _delegates.size(); ii < ll; ii++) {
                PlaceManagerDelegate delegate = _delegates.get(ii);
                if (op.shouldApply(delegate)) {
                    op.apply(delegate);
                }
            }
        }
    }
65953
def GetCampaignFeeds(client, feed, placeholder_type):
  
  campaign_feed_service = client.GetService('CampaignFeedService', 'v201809')

  campaign_feeds = []
  more_pages = True

  selector = {
      'fields': ['CampaignId', 'MatchingFunction', 'PlaceholderTypes'],
      'predicates': [
          {
              'field': 'Status',
              'operator': 'EQUALS',
              'values': ['ENABLED']
          },
          {
              'field': 'FeedId',
              'operator': 'EQUALS',
              'values': [feed['id']]
          },
          {
              'field': 'PlaceholderTypes',
              'operator': 'CONTAINS_ANY',
              'values': [placeholder_type]
          }
      ],
      'paging': {
          'startIndex': 0,
          'numberResults': PAGE_SIZE
      }
  }

  while more_pages:
    page = campaign_feed_service.get(selector)

    if 'entries' in page:
      campaign_feeds.extend(page['entries'])

    selector['paging']['startIndex'] += PAGE_SIZE
    more_pages = selector['paging']['startIndex'] < int(page['totalNumEntries'])

  return campaign_feeds
994659
def get_candidate_notional_votes(self, candidate_aggregates, adjustment):
        ""
        continuing = self.get_continuing_candidates(candidate_aggregates)
        candidates_notional = {}
        by_votes = self.get_votes_to_candidates(continuing, candidate_aggregates)
        total = adjustment
        for votes, candidates in sorted(by_votes.items(), key=lambda x: x[0]):
            for candidate_id in candidates:
                candidates_notional[candidate_id] = total + votes
            total += votes * len(candidates)
        return candidates_notional
1097648
private void genGetAllMethod(SourceWriter sw, JMethod[] methods,
      TreeLogger treeLogger) {
    sw.println("public DeferredSelector[] getAllSelectors() {return ds;}");
    sw.println("private final DeferredSelector[] ds = new DeferredSelector[] {");
    sw.indent();
    for (JMethod m : methods) {
      Selector selectorAnnotation = m.getAnnotation(Selector.class);
      if (selectorAnnotation == null) {
        continue;
      }
      String selector = selectorAnnotation.value();

      sw.println("new DeferredSelector() {");
      sw.indent();
      sw
          .println("public String getSelector() { return \"" + selector
              + "\"; }");
      sw
          .println("public NodeList<Element> runSelector(Node ctx) { return " +
              (m.getName() + (m.getParameters().length == 0 ? "()" : "(ctx)")) +
              ("NodeList".equals(m.getReturnType().getSimpleSourceName()) ? "" : ".get()") + ";}"
          );
      sw.outdent();
      sw.println("},");
    }
    sw.outdent();
    sw.println("};");
  }
1094368
function _requestVotes () {
    let { host, coordinationPort } = node.settings
    let message = {
      type: 'voteRequest',
      data: {}
    }
    return new Promise((resolve, reject) => {
      let resolveStart = Date.now()
      dns.resolve4(host, (err, addresses) => {
        if (err) {
          debug(`cannot resolve host '${host}'. Check DNS infrastructure.`)
          return reject(err)
        }
        debug(`resolved ${addresses.length} IP(s) for host '${host}' in ${Date.now() - resolveStart} ms`)
        debug(`requesting votes from ${addresses.length} nodes`)
        Promise.all(
          addresses.map(address => new Promise((resolve, reject) => {
            let voteRequestTime = Date.now()
            let messenger = zmq.socket('req')
            messenger.connect(`tcp://${address}:${coordinationPort}`)
            messenger.send(JSON.stringify({
              ...message,
              toAddress: address,
              from: node.name
            }))

            let _resolved = false
            function onEnd (candidateBuffer) {
              if (_resolved) return
              _resolved = true
              messenger.removeListener('message', onEnd)
              messenger.close()

              let candidate = candidateBuffer && JSON.parse(candidateBuffer)
              if (candidate) {
                let elapsed = Date.now() - voteRequestTime
                candidate.candidate && debug(`received vote by ${candidate.name === node.name ? 'myself' : candidate.name}${candidate.isMaster ? ' (master)' : ''} in ${elapsed} ms`)
              } else {
                debug(`missed vote by peer at ${address}`)
              }
              resolve(candidate)
            }

            messenger.on('message', onEnd)
            setTimeout(onEnd, node.settings.voteTimeout)
          }))
        )
        .then(nodes => compact(nodes))
        .then(nodes => resolve(nodes.filter(({candidate}) => candidate)))
      })
    })
  }
316542
public function fetchAll() {
		if ($this->selection) {
			/** @var ActiveRow $entity */
			foreach ($this->selection as $entity) {
				$this->createEntity($entity);
			}
		}

		return $this->rows;
	}
1016785
def get_candidate_electoral_votes(self, candidate):
        
        candidate_election = CandidateElection.objects.get(
            candidate=candidate, election=self
        )

        return candidate_election.electoral_votes.all()
906733
public double getFitness(T candidate, List<? extends T> population)
    {
        Double fitness = cache.get(candidate);
        if (fitness == null)
        {
            fitness = delegate.getFitness(candidate, population);
            cache.put(candidate, fitness);
        }
        return fitness;
    }
337229
def _filter_candidates(self, tokens, candidates):
        """"""
        results = []
        for abbr_span, long_span in candidates:
            abbr = tokens[abbr_span[0]:abbr_span[1]]
            long = tokens[long_span[0]:long_span[1]]
            if not all(a in long for a in abbr) and len(''.join(long)) > len(''.join(abbr)):
                results.append((abbr_span, long_span))
        return results
499249
def get_all(self, path, data=None, limit=100):
        """"""
        return ListResultSet(path=path, data=data or {}, limit=limit)
773512
public static Method[] candidateMethods(Class<?> clazz, String name, Object[] args) {
        return candidateMethods(collectMethods(clazz, name), args);
    }
500220
protected function electCandidate(Candidate $candidate)
    {
        $this->logger->notice("Electing a candidate: $candidate");

        $candidate->setState(Candidate::ELECTED);
        ++$this->electedCandidates;
        --$this->candidatesToElect;

        if ($this->electedCandidates < $this->election->getWinnersCount()) {
            $surplus = $candidate->getVotes() - $this->quota;
            if ($surplus > 0) {
                $this->transferSurplusVotes($surplus, $candidate);
            } else {
                $this->logger->notice("No surplus votes from $candidate to reallocate");
            }
        }

        return;
    }
130921
def get_candidates_by_party(self):
        
        candidate_elections = CandidateElection.objects.filter(election=self)

        return {
            ce.candidate.party.slug: ce.candidate for ce in candidate_elections
        }