For each follower, let Z be the total number of brands they follow.
    Return a dictionary of 1. / log(Z), for each follower.
776313
def compute_log_degrees(brands, exemplars):
    
    counts = Counter()
    for followers in brands.values():  # + exemplars.values():  # Include exemplars in these counts? No, don't want to penalize people who follow many exemplars.
        counts.update(followers)
    counts.update(counts.keys())  # Add 1 to each count.
    for k in counts:
        counts[k] = 1. / math.log(counts[k])
    return counts
502843
def constructTotalCounts(self, logger):
        '''
        
        '''
        self.totalSize = self.bwt.shape[0]
        
        abtFN = self.dirName+'/totalCounts.p'
        if os.path.exists(abtFN):
            fp = open(abtFN, 'r')
            self.totalCounts = pickle.load(fp)
            fp.close()
        else:
            chunkSize = 2**20
            if logger != None:
                logger.info('First time calculation of \'%s\'' % abtFN)
            
            #figure out the counts using the standard counting techniques, one chunk at a time
            self.totalCounts = [0]*self.vcLen
            i = 0
            while i*chunkSize < self.bwt.shape[0]:
                self.totalCounts = np.add(self.totalCounts, np.bincount(self.bwt[i*chunkSize:(i+1)*chunkSize], minlength=self.vcLen))
                i += 1
            
            #save the total count to '<DIR>/totalCounts.p'
            fp = open(abtFN, 'w+')
            pickle.dump(self.totalCounts, fp)
            fp.close()
1259827
def constructTotalCounts(self, logger):
        '''
        
        '''
        self.letterBits = 3
        self.numberBits = 8-self.letterBits
        self.numPower = 2**self.numberBits
        self.mask = 255 >> self.numberBits
        
        abtFN = self.dirName+'/totalCounts.p'
        if os.path.exists(abtFN):
            fp = open(abtFN, 'r')
            self.totalCounts = pickle.load(fp)
            fp.close()
        else:
            if logger != None:
                logger.info('First time calculation of \'%s\'' % abtFN)
            
            self.totalCounts = [0]*self.vcLen
            
            binSize = 2**15
            end = 0
            
            while end < self.bwt.shape[0]:
                start = end
                end = end + binSize
                if end > self.bwt.shape[0]:
                    end = self.bwt.shape[0]
                
                #find a clean break in the characters
                while end < self.bwt.shape[0] and ((self.bwt[end] & self.mask) == (self.bwt[end-1] & self.mask)):
                    end += 1
                
                letters = np.bitwise_and(self.bwt[start:end], self.mask)
                counts = np.right_shift(self.bwt[start:end], self.letterBits, dtype='<u8')
                powers = np.zeros(dtype='<u8', shape=(end-start,))
                
                #solve the actual powers
                i = 1
                same = (letters[0:-1] == letters[1:])
                while np.sum(same) > 0:
                    (powers[i:])[same] += 1
                    i += 1
                    same = np.bitwise_and(same[0:-1], same[1:])
                
                #each letter has a variable 'weight' which is the runlength of that region
                self.totalCounts += np.bincount(letters, np.multiply(counts, self.numPower**powers), minlength=self.vcLen)
                
            fp = open(abtFN, 'w+')
            pickle.dump(self.totalCounts, fp)
            fp.close()
        
        self.totalSize = int(np.sum(self.totalCounts))
1209507
def We(self):
        
        We = trapz_loglog(self._gam * self._nelec, self._gam * mec2)
        return We
88454
def _get_ngram_counter(ids, n):
  
  # Remove zero IDs used to pad the sequence.
  ids = [token_id for token_id in ids if token_id != 0]
  ngram_list = [tuple(ids[i:i + n]) for i in range(len(ids) + 1 - n)]
  ngrams = set(ngram_list)
  counts = collections.Counter()
  for ngram in ngrams:
    counts[ngram] = 1
  return counts
976335
def count(self, *args, **kw):
        
        obj = args[0]
        try:
            memo_dict = obj._memo[self.method_name]
        except KeyError:
            self.miss = self.miss + 1
        else:
            key = self.keymaker(*args, **kw)
            if key in memo_dict:
                self.hit = self.hit + 1
            else:
                self.miss = self.miss + 1
827773
def followed_columns(self):
        
        from .column import Column
        if self.url is None:
            return
        if self.followed_column_num > 0:
            tag = self.soup.find('div', class_='zm-profile-side-columns')
            if tag is not None:
                for a in tag.find_all('a'):
                    yield Column(a['href'], a.img['alt'],
                                 session=self._session)
            if self.followed_column_num > 7:
                offset = 7
                gotten_data_num = 20
                while gotten_data_num == 20:
                    params = {
                        'hash_id': self.hash_id,
                        'limit': 20,
                        'offset': offset
                    }
                    data = {
                        'method': 'next',
                        '_xsrf': self.xsrf,
                        'params': json.dumps(params)
                    }
                    j = self._session.post(Author_Get_More_Follow_Column_URL,
                                           data=data).json()
                    gotten_data_num = len(j['msg'])
                    offset += gotten_data_num
                    for msg in map(BeautifulSoup, j['msg']):
                        name = msg.strong.text
                        url = msg.a['href']
                        post_num = int(re_get_number.match(
                            msg.span.text).group(1))
                        yield Column(url, name, post_num=post_num,
                                     session=self._session)
1221801
def count(self):
        ""
        if self._nodes is None:
            return 1
        return sum(i.count() for i in self._nodes)
893760
def _lognl(self):
        
        try:
            return self.__lognl
        except AttributeError:
            det_lognls = {}
            for (det, d) in self._data.items():
                kmin = self._kmin
                kmax = self._kmax
                det_lognls[det] = -0.5 * d[kmin:kmax].inner(d[kmin:kmax]).real
            self.__det_lognls = det_lognls
            self.__lognl = sum(det_lognls.values())
            return self.__lognl
685695
def follower_num(self):
        
        href = re_collection_url_split.match(self.url).group(1)
        return int(self.soup.find('a', href=href + 'followers').text)
1320539
def get_likes_count(self):
        
        response = self._session.fetch('likes.getList', count=1, type='post', owner_id=self.from_id, item_id=self.id)
        likes_count = response.get('count')
        return likes_count
829924
def getCountGT(self, item):
        """"""
        index = bisect.bisect_right(self._list, item)
        return len(self._list) - index
943659
def count(self):
        
        total = len(self.children)
        for child in self.children:
            total += child.count()
        return total
1138684
def iter_follower_file(fname):
    
    with open(fname, 'rt') as f:
        for line in f:
            parts = line.split()
            if len(parts) > 3:
                yield parts[1].lower(), set(int(x) for x in parts[2:])
848441
def loglike(self):
        '''
        
        '''
        sum = logp_of_set(self.children)
        if self.verbose > 2:
            print_('\t' + self._id + ' Current log-likelihood ', sum)
        return sum
55027
def _get_demand_graph(self):
        """"""
        # The number of clusters
        K = self.origins.shape[0]

        # Set the number of accounts in each cluster to be the same
        # as for the nearest neighbor solution
        demand = self.nearest_targets.groupby('origin_id')['geometry'].count().to_dict()

        # Set up the graph so we can extract and initialize the node labels.
        # For each iteration, we're going to sort all our data by their origin
        # label assignments in order to properly index our nodes.
        self.targets = self.targets.sort_values('labels').reset_index(drop=True)

        # Add target nodes
        g = nx.DiGraph()
        g.add_nodes_from(self.targets['target_id'], demand=-1)

        # Add origin nodes
        for idx in demand:
            g.add_node(int(idx), demand=demand[idx])

        # Dictionary of labels (corresponding to the sales rep) for
        # each med center node.
        dict_M = {
            i: (
                self.targets[self.targets['target_id'] == i]['labels'].values
                if i in self.targets.target_id.values
                else np.array([demand[i]])
            )
            for i in g.nodes
        }
        logging.info('Graph and demand dictionary created')
        return dict_M, demand
812007
def get_followers_following(username)
      {
        following: @octokit.following(username).length,
        followers: @octokit.followers(username).length
      }
    end