Stats with topics and channels keyed on topic and channel names
969800
def clean_stats(self):
        ''''''
        stats = self.stats()
        if 'topics' in stats:  # pragma: no branch
            topics = stats['topics']
            topics = dict((t.pop('topic_name'), t) for t in topics)
            for topic, data in topics.items():
                if 'channels' in data:  # pragma: no branch
                    channels = data['channels']
                    channels = dict(
                        (c.pop('channel_name'), c) for c in channels)
                    data['channels'] = channels
            stats['topics'] = topics
        return stats
961301
def get_topics(yaml_info):
    ''' 
    '''
    # Pull out the topic info
    names = []
    # Store all of the topics in a dictionary
    topics = yaml_info['topics']
    for topic in topics:
        names.append(topic['topic'])

    return names
931640
def topics(text):
    """"""
    detectors = [
        detector_50_Cent
    ]
    ts = []
    for detector in detectors:
        ts.append(detector(text))

    return [t[0] for t in ts if t[1] > 0.95]
834571
def raw(self):
        ''''''
        topic_keys = (
            'message_count',
            'depth',
            'backend_depth',
            'paused'
        )

        channel_keys = (
            'in_flight_count',
            'timeout_count',
            'paused',
            'deferred_count',
            'message_count',
            'depth',
            'backend_depth',
            'requeue_count'
        )
        
        for host, stats in self.merged.items():
            for topic, stats in stats.get('topics', {}).items():
                prefix = 'host.%s.topic.%s' % (host, topic)
                for key in topic_keys:
                    value = int(stats.get(key, -1))
                    yield (
                        'host.%s.topic.%s.%s' % (host, topic, key),
                        value,
                        False
                    )
                    yield (
                        'topic.%s.%s' % (topic, key),
                        value,
                        True
                    )
                    yield (
                        'topics.%s' % key,
                        value,
                        True
                    )
                
                for chan, stats in stats.get('channels', {}).items():
                    data = {
                        key: int(stats.get(key, -1)) for key in channel_keys
                    }
                    data['clients'] = len(stats.get('clients', []))

                    for key, value in data.items():
                        yield (
                            'host.%s.topic.%s.channel.%s.%s' % (host, topic, chan, key),
                            value,
                            False
                        )
                        yield (
                            'host.%s.topic.%s.channels.%s' % (host, topic, key),
                            value,
                            True
                        )
                        yield (
                            'topic.%s.channels.%s' % (topic, key),
                            value,
                            True
                        )
                        yield (
                            'channels.%s' % key,
                            value,
                            True
                        )
588201
def empty_channel(self, topic, channel):
        """"""
        nsq.assert_valid_topic_name(topic)
        nsq.assert_valid_channel_name(channel)
        return self._request('POST', '/channel/empty',
                             fields={'topic': topic, 'channel': channel})
524009
def topics(self):
        
        topics = self.interface.publishers.copy()
        topics.update(self.interface.subscribers)
        return topics
1239374
def voice_channels(self):
        """"""
        ret = [c for c in self.guild.channels
            if c.category_id == self.id
            and isinstance(c, VoiceChannel)]
        ret.sort(key=lambda c: (c.position, c.id))
        return ret
382393
async def on_raw_332(self, message):
        
        target, channel, topic = message.params
        if not self.in_channel(channel):
            return

        self.channels[channel]['topic'] = topic
442994
def list_(self):
        
        with self.lock:
            self.send('LIST')
            list_ = {}

            while self.readable():
                msg = self._recv(expected_replies=('322', '321', '323'))

                if msg[0] == '322':
                    channel, usercount, modes, topic = msg[2].split(' ', 3)
                    modes = modes.replace(':', '', 1).replace(':', '', 1)
                    modes = modes.replace('[', '').replace( \
                                                    ']', '').replace('+', '')
                    list_[channel] = usercount, modes, topic
                elif msg[0] == '321':
                    pass
                elif msg[0] == '323':
                    break

            return list_
394207
def connect_channels(self, channels):
        """"""
        self.log.info(f"Connecting to channels...")
        for chan in channels:
            chan.connect(self.sock)
            self.log.info(f"\t{chan.channel}")
554450
def bind(topic, signal=None, kind=MIDDLE, nice=-1):
    
    def f(func):
        if not topic in _receivers:
            receivers = _receivers[topic] = []
        else:
            receivers = _receivers[topic]
        
        if nice == -1:
            if kind == MIDDLE:
                n = 500
            elif kind == HIGH:
                n = 100
            else:
                n = 900
        else:
            n = nice
        if callable(func):
            func_name = func.__module__ + '.' + func.__name__
            func = func
        else:
            func_name = func
            func = None
        _f = (n, {'func':func, 'signal':signal, 'func_name':func_name})
        receivers.append(_f)
        return func
    return f
29110
def list_channels(self, owner):
        '''
        '''
        url = '%s/channels/%s' % (self.domain, owner)

        res = self.session.get(url)
        self._check_response(res, [200])
        return res.json()
960124
def channels_info(self, room_id=None, channel=None, **kwargs):
        """"""
        if room_id:
            return self.__call_api_get('channels.info', roomId=room_id, kwargs=kwargs)
        elif channel:
            return self.__call_api_get('channels.info', roomName=channel, kwargs=kwargs)
        else:
            raise RocketMissingParamException('roomId or channel required')
993092
def general_stats(self):
        

        headers = OrderedDict()
        headers['Change_rate'] = {
            'title': 'Change rate',
            'scale': 'RdYlBu-rev',
            'min': 0,
            'format': '{:,.0f}'
        }
        headers['Ts_Tv_ratio'] = {
            'title': 'Ts/Tv',
            'description': 'Transitions / Transversions ratio',
            'format': '{:,.3f}'
        }
        headers['Number_of_variants_before_filter'] = {
            'title': 'M Variants',
            'description': 'Number of variants before filter (millions)',
            'scale': 'PuRd',
            'modify': lambda x: x / 1000000,
            'min': 0,
            'format': '{:,.2f}'
        }
        self.general_stats_addcols(self.snpeff_data, headers)
567441
def _get_all_filtered_channels(self, topics_without_signature):
        
        mpe_address     = self.get_mpe_address()
        event_signature = self.ident.w3.sha3(text="ChannelOpen(uint256,uint256,address,address,address,bytes32,uint256,uint256)").hex()
        topics = [event_signature] + topics_without_signature
        logs = self.ident.w3.eth.getLogs({"fromBlock" : self.args.from_block, "address"   : mpe_address, "topics"    : topics})
        abi           = get_contract_def("MultiPartyEscrow")
        event_abi     = abi_get_element_by_name(abi, "ChannelOpen")
        channels_ids  = [get_event_data(event_abi, l)["args"]["channelId"] for l in logs]
        return channels_ids
1082661
def find_topic(category_name, forum_name, topic_title, options = {})
      forum = self.find_forum(category_name, forum_name, options)
      if forum
        self.topics(forum['id'], options).detect {|t| t['title'] == topic_title}
      end
    end
317632
def find_topics(token_lists, num_topics=10):
    
    dictionary = Dictionary(token_lists)
    print('Number of unique words in original documents:', len(dictionary))

    dictionary.filter_extremes(no_below=2, no_above=0.7)
    print('Number of unique words after removing rare and common words:', len(dictionary))

    corpus = [dictionary.doc2bow(tokens) for tokens in token_lists]
    model = LdaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics, chunksize=100, passes=5, random_state=1)

    print_topics(model)

    return model, dictionary