query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Returns zero or more Member instances associated with mid, where mid is the sha1 digest of a member public key. As we are using only 20 bytes to represent the actual member public key, this method may return multiple possible Member instances. In this case, other ways must be used to figure
def get_members_from_id(self, mid, cache=True): assert isinstance(mid, str), type(mid) assert len(mid) == 20, len(mid) assert isinstance(cache, bool), type(cache) if cache: try: return [MemberFromId(mid)] except LookupError: pass ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_members_and_keyholders():\n\n\t# Read members and prospectives file\n\twith open(members_path) as f:\n\t\tlines = f.readlines()\n\n\t# Get non-commented lines\n\treal_lines = [line for line in lines if len(line.strip()) and line.strip()[0] != '#']\n\n\tmembers = set()\n\tkeyholders = set()\n\t# Maps aliase...
[ "0.5774914", "0.5575566", "0.5575566", "0.5575566", "0.5575566", "0.5560494", "0.5526328", "0.55139184", "0.5487642", "0.5398351", "0.5363364", "0.5348796", "0.5312354", "0.5238109", "0.5209607", "0.5141394", "0.51253897", "0.5112496", "0.5111838", "0.50747883", "0.5009765", ...
0.75268173
0
Returns a Member instance associated with DATABASE_ID or None when this row identifier is not available.
def get_member_from_database_id(self, database_id, cache=True): assert isinstance(database_id, (int, long)), type(database_id) assert isinstance(cache, bool), type(cache) if cache: try: return MemberFromDatabaseId(database_id) except LookupError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def member(self, uid):\n try:\n member = self.search(uid=uid)[0]\n except IndexError:\n return None\n\n if self.objects:\n return member\n\n return member[1]", "def get_member(did):\n conn = create_connection(db_location)\n c = conn.cursor()\n ...
[ "0.6241487", "0.619927", "0.5873967", "0.5857099", "0.58348066", "0.58169246", "0.58169246", "0.57388496", "0.57003343", "0.56690556", "0.56584615", "0.56384265", "0.55967486", "0.5588798", "0.54879296", "0.54699194", "0.5454944", "0.5447959", "0.53877306", "0.5385781", "0.53...
0.67721516
0
Add a community to the Dispersy instance. Each community must be known to Dispersy, otherwise an incoming message will not be able to be passed along to it's associated community. In general this method is called from the Community.__init__(...) method.
def attach_community(self, community): if __debug__: from .community import Community assert isinstance(community, Community) if __debug__: dprint(community.cid.encode("HEX"), " ", community.get_classification()) assert not community.cid in self._communities assert no...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def community(self, community):\n\n self._community = community", "def set_community(self, community):\n assert community is None or isinstance(community, Community), type(community)\n self._community = community\n if community:\n self._dispersy = community.dispersy", "de...
[ "0.66487974", "0.6411453", "0.60780495", "0.59311634", "0.5903593", "0.57783663", "0.5659524", "0.5643145", "0.5609838", "0.5570506", "0.5549704", "0.5501872", "0.54274434", "0.52420706", "0.52355367", "0.51256007", "0.5091495", "0.5078886", "0.5069313", "0.5055437", "0.50341...
0.7048054
0
Remove an attached community from the Dispersy instance. Once a community is detached it will no longer receive incoming messages. When the community is marked as auto_load it will be loaded, using community.load_community(...), when a message for this community is received.
def detach_community(self, community): if __debug__: from .community import Community assert isinstance(community, Community) if __debug__: dprint(community.cid.encode("HEX"), " ", community.get_classification()) assert community.cid in self._communities assert self._...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def undefine_auto_load(self, community):\n if __debug__:\n from .community import Community\n assert issubclass(community, Community)\n assert community.get_classification() in self._auto_load_communities\n del self._auto_load_communities[community.get_classification()]", "...
[ "0.64172685", "0.6363585", "0.57910657", "0.5749061", "0.55890065", "0.55707276", "0.55502415", "0.53582335", "0.5352705", "0.5348267", "0.530504", "0.5287003", "0.52779645", "0.5268385", "0.5193233", "0.5169167", "0.5147842", "0.5117046", "0.5086342", "0.5071314", "0.5048803...
0.7982268
0
Change a community classification. Each community has a classification that dictates what source code is handling this community. By default the classification of a community is the unicode name of the class in the source code.
def reclassify_community(self, source, destination): if __debug__: from .community import Community assert isinstance(source, (Community, Member)) assert issubclass(destination, Community) destination_classification = destination.get_classification() if isinstance(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_classification(net_id, classification):\n if classification not in ('Freshman', 'Sophomore', 'Junior', 'Senior'):\n raise AttributeError(\"Classification must be in ('Freshman', 'Sophomore', 'Junior', 'Senior')\")\n connection = get_connection()\n cursor = connection.cursor()\n sql_strin...
[ "0.6117072", "0.57503664", "0.5652314", "0.56260604", "0.5617704", "0.55788165", "0.5496485", "0.5494127", "0.54204065", "0.5279724", "0.51765084", "0.5169475", "0.5162665", "0.5136268", "0.51278895", "0.5107297", "0.50984573", "0.50902253", "0.50658965", "0.50602496", "0.504...
0.6635776
0
Returns True when there is a community CID.
def has_community(self, cid): return cid in self._communities
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_cid(self):\n return hasattr(self, 'cid')", "def is_community(self):\n context = aq_inner(self.context)\n for obj in aq_chain(context):\n if ICommunity.providedBy(obj):\n return True\n\n return False", "def in_community(self, community, now):\n ...
[ "0.7440429", "0.71921057", "0.591156", "0.5911467", "0.5907175", "0.5868453", "0.5854539", "0.5812818", "0.5802776", "0.57998383", "0.5794959", "0.5789906", "0.57788044", "0.57630473", "0.5743571", "0.5729656", "0.57255054", "0.57232493", "0.5700302", "0.5661624", "0.56448257...
0.77872753
0
Returns a community by its community id. The community id, or cid, is the binary representation of the public key of the master member for the community. When the community is available but not currently loaded it will be automatically loaded when (a) the load parameter is True or (b) the auto_load parameter is True an...
def get_community(self, cid, load=False, auto_load=True): assert isinstance(cid, str) assert isinstance(load, bool), type(load) assert isinstance(auto_load, bool) try: return self._communities[cid] except KeyError: try: # have we joined t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_community(self, cid: str) -> list:\n\n t, cid = cid.split(\"_\")\n coms = self.get_clustering_at(int(t))\n return coms.communities[int(cid)]", "def get_community_info(self, id=None):\n req = GetCommunityInfoRequest(self)\n req.id = id\n return req", "def commun...
[ "0.6616548", "0.6296869", "0.57073843", "0.5679254", "0.56006247", "0.5571744", "0.55416775", "0.5370173", "0.5316421", "0.5302592", "0.5277218", "0.52687943", "0.52574444", "0.52477765", "0.5213965", "0.51790583", "0.51602703", "0.5157216", "0.51541334", "0.5092255", "0.5088...
0.7828242
0
Returns a list with all known Community instances.
def get_communities(self): return self._communities.values()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_communities(self):\n return self.__communities", "def list_instances():\n js = _get_jetstream_conn()\n il = js.compute.instances.list()\n if not il:\n msg = \"You don't have any instances available.\"\n else:\n msg = (\"You have {0} instances available. Here are up to 3 most...
[ "0.6412077", "0.6339403", "0.63041407", "0.6269389", "0.6268164", "0.6221965", "0.621458", "0.6171568", "0.6129162", "0.60234106", "0.60203457", "0.5990177", "0.5944194", "0.5930868", "0.59298915", "0.58919096", "0.588977", "0.5887995", "0.58856153", "0.5885263", "0.5843029",...
0.6381629
1
Returns a Member.Implementation instance uniquely identified by its community, member, and global_time. Returns None if this message is not in the local database.
def get_message(self, community, member, global_time): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(member, Member) assert isinstance(global_time, (int, long)) try: packet, = self._database.execut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_message(self, community, member, global_time, verify=False):\n try:\n packet_id, packet = self._database.execute(u\"SELECT id, packet FROM sync WHERE community = ? AND member = ? AND global_time = ? LIMIT 1\",\n (community.database_id...
[ "0.5548046", "0.5322457", "0.5322457", "0.5285301", "0.50067997", "0.49508438", "0.48288608", "0.48115468", "0.47980577", "0.47936746", "0.4782795", "0.4758392", "0.47158805", "0.47115543", "0.47096148", "0.46865866", "0.46496072", "0.4641114", "0.4630295", "0.46300074", "0.4...
0.6425271
0
Add one vote and possibly redetermine our wan address. Our wan address is determined by majority voting. Each time when we receive a message that contains anothers opinion about our wan address, we take this into account. The address with the most votes wins. Usually these votes are received through dispersycandidatere...
def wan_address_vote(self, address, voter): assert isinstance(address, tuple) assert len(address) == 2 assert isinstance(address[0], str) assert isinstance(address[1], int) assert isinstance(voter, Candidate), type(voter) if self._wan_address[0] in (voter.wan_address[0], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wan_address_unvote(self, voter):\n assert isinstance(voter, Candidate)\n for vote, voters in self._wan_address_votes.iteritems():\n if voter.sock_addr in voters:\n if __debug__: dprint(\"removing vote for \", vote, \" made by \", voter)\n voters.remove(vot...
[ "0.5737099", "0.56554604", "0.5580307", "0.5512087", "0.5299306", "0.5254543", "0.524516", "0.51219904", "0.4993753", "0.49792337", "0.49469453", "0.49442416", "0.49296096", "0.49157956", "0.49065036", "0.48983163", "0.48824322", "0.4846997", "0.4845622", "0.48381773", "0.477...
0.7261466
0
Returns True when this message is a duplicate, otherwise the message must be processed.
def _is_duplicate_sync_message(self, message): community = message.community # fetch the duplicate binary packet from the database try: have_packet, undone = self._database.execute(u"SELECT packet, undone FROM sync WHERE community = ? AND member = ? AND global_time = ?", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deduplicate_message(self, message):\n\n key = (message.remote, message.mid)\n if key in self._recent_messages:\n if message.mtype is CON:\n if self._recent_messages[key] is not None:\n self.log.info('Duplicate CON received, sending old response again'...
[ "0.7582035", "0.718433", "0.6632222", "0.65484715", "0.6452502", "0.62928617", "0.61890024", "0.6047644", "0.60145295", "0.5990938", "0.59627473", "0.59265596", "0.59142953", "0.59075934", "0.589519", "0.5861441", "0.5849016", "0.58262265", "0.58185387", "0.5797181", "0.57899...
0.75062656
1
Ensure that we do not yet have the messages and that, if sequence numbers are enabled, we are not missing any previous messages. This method is called when a batch of messages with the FullSyncDistribution policy is received. Duplicate messages will yield DropMessage. And if enable_sequence_number is True, missing mess...
def _check_full_sync_distribution_batch(self, messages): assert isinstance(messages, list) assert len(messages) > 0 assert all(isinstance(message, Message.Implementation) for message in messages) assert all(message.community == messages[0].community for message in messages) asser...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_missing_sequence(self, messages):\n community = messages[0].community\n sources = defaultdict(lambda: defaultdict(set))\n\n if __debug__: dprint(\"received \", len(messages), \" missing-sequence message for community \", community.database_id)\n\n # we know that there are buggy c...
[ "0.6232251", "0.6212188", "0.59579796", "0.5562325", "0.5516771", "0.52591234", "0.5213447", "0.5031532", "0.49940863", "0.49808553", "0.49647236", "0.49332228", "0.49289382", "0.49196616", "0.49003825", "0.48974237", "0.48643488", "0.48571083", "0.4856272", "0.47853947", "0....
0.6481791
0
Check that the messages do not violate any database consistency rules. This method is called when a batch of messages with the LastSyncDistribution policy is
def _check_last_sync_distribution_batch(self, messages): assert isinstance(messages, list) assert len(messages) > 0 assert all(isinstance(message, Message.Implementation) for message in messages) assert all(message.community == messages[0].community for message in messages) asser...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_full_sync_distribution_batch(self, messages):\n assert isinstance(messages, list)\n assert len(messages) > 0\n assert all(isinstance(message, Message.Implementation) for message in messages)\n assert all(message.community == messages[0].community for message in messages)\n ...
[ "0.7456831", "0.6486123", "0.6404818", "0.6097382", "0.59396446", "0.5766605", "0.5659643", "0.55288124", "0.5517824", "0.5508465", "0.55079055", "0.54995584", "0.549227", "0.5475219", "0.5450629", "0.5440776", "0.5433046", "0.5427334", "0.5419136", "0.5392122", "0.5385879", ...
0.74235934
1
The member + global_time combination must always be unique in the database
def check_member_and_global_time(unique, times, message): assert isinstance(unique, set) assert isinstance(times, dict) assert isinstance(message, Message.Implementation) assert isinstance(message.distribution, LastSyncDistribution.Implementation) key = (mess...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_double_member_and_global_time(unique, times, message):\n assert isinstance(unique, set)\n assert isinstance(times, dict)\n assert isinstance(message, Message.Implementation)\n assert isinstance(message.authentication, DoubleMemberAuthentication.Implementation)\...
[ "0.67136973", "0.5991879", "0.53225464", "0.52694285", "0.52496547", "0.5195429", "0.51390326", "0.51110387", "0.50426316", "0.5031116", "0.49915156", "0.49647325", "0.49557114", "0.49463534", "0.48971474", "0.48936635", "0.4877466", "0.48634028", "0.48546457", "0.48461753", ...
0.7537584
0
No other message may exist with this message.authentication.members / global_time combination, regardless of the ordering of the members
def check_double_member_and_global_time(unique, times, message): assert isinstance(unique, set) assert isinstance(times, dict) assert isinstance(message, Message.Implementation) assert isinstance(message.authentication, DoubleMemberAuthentication.Implementation) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_member_and_global_time(unique, times, message):\n assert isinstance(unique, set)\n assert isinstance(times, dict)\n assert isinstance(message, Message.Implementation)\n assert isinstance(message.distribution, LastSyncDistribution.Implementation)\n\n ...
[ "0.7058149", "0.58589244", "0.57128143", "0.54181445", "0.53505", "0.533485", "0.52964324", "0.5272761", "0.52655447", "0.52499914", "0.5225997", "0.5136334", "0.51352876", "0.5130324", "0.5117838", "0.5108764", "0.5097162", "0.5085471", "0.5049671", "0.5039262", "0.5018551",...
0.6415252
1
Returns the messages in the correct processing order. This method is called when a message with the DirectDistribution policy is received. This message is not stored and hence we will not be able to see if we have already received this message. Receiving the same DirectDistribution multiple times indicates that the sen...
def _check_direct_distribution_batch(self, messages): # sort the messages by their (1) global_time and (2) binary packet messages = sorted(messages, lambda a, b: cmp(a.distribution.global_time, b.distribution.global_time) or cmp(a.packet, b.packet)) # direct messages tell us what other people b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_messages(self, messages):\n\n return messages", "def gather_full_dist(self):\n full_dist = dict()\n for ind, msg in enumerate(self.messages):\n dist = self.build_distribution(ind)\n for p in dist:\n if p in full_dist:\n full...
[ "0.587765", "0.57139283", "0.5709758", "0.56773865", "0.56646246", "0.5534571", "0.5534571", "0.5532468", "0.5502764", "0.54847085", "0.544048", "0.544048", "0.544048", "0.543922", "0.5438162", "0.53758454", "0.53497356", "0.5328717", "0.53265804", "0.5306408", "0.5306408", ...
0.64688593
0
Returns an existing candidate object or None 1. returns an existing candidate from self._candidates, or 2. returns a bootstrap candidate from self._bootstrap_candidates, or 3. returns an existing candidate with the same host on a different port if this candidate is marked as a symmetric NAT. When replace is True, the e...
def get_candidate(self, sock_addr, replace=True, lan_address=("0.0.0.0", 0)): # use existing (bootstrap) candidate candidate = self._candidates.get(sock_addr) or self._bootstrap_candidates.get(sock_addr) if __debug__: dprint("%s:%d" % sock_addr, " -> ", candidate) if candidate is None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def candidate(self):\n return Candidate(self.lan_address, self.tunnel)", "def dispersy_get_introduce_candidate(self, exclude_candidate=None):\n assert all(not sock_address in self._candidates for sock_address in self._dispersy._bootstrap_candidates.iterkeys()), \"none of the bootstrap candidates ma...
[ "0.62933093", "0.59328455", "0.5159952", "0.5094868", "0.49158758", "0.47003642", "0.46874285", "0.4528907", "0.45159185", "0.45021084", "0.44526976", "0.44438568", "0.4419853", "0.4395862", "0.43700793", "0.4347747", "0.43462446", "0.43425733", "0.43398228", "0.43374267", "0...
0.7942359
0
A node told us its LAN and WAN address, it is possible that we can now determine that we already have CANDIDATE in our candidate list. When we learn that a candidate happens to be behind a symmetric NAT we must remove all other candidates that have the same host.
def _filter_duplicate_candidate(self, candidate): wan_address = candidate.wan_address lan_address = candidate.lan_address # find existing candidates that are likely to be the same candidate others = [other for other in self._candidates.itervalues() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_public_relays(state, bridges):\n IPs = map(lambda addr: addr.split(':',1)[0], bridges['all'])\n both = set(state.routers.values()).intersection(IPs)\n\n if len(both) > 0:\n try:\n updated = map(lambda node: remove_node_from_list(node), both)\n log.debug(\"Bridges in...
[ "0.56262094", "0.56224483", "0.5357528", "0.534161", "0.53390986", "0.53210354", "0.5312591", "0.5290346", "0.5266423", "0.52598774", "0.5235924", "0.52296966", "0.51859176", "0.5177623", "0.51334554", "0.51319873", "0.5125175", "0.5115486", "0.5111411", "0.51085454", "0.5106...
0.6698403
0
Returns the message identified by community, member, and global_time. Each message is uniquely identified by the community that it is created in, the member it is created by and the global time when it is created. Using these three parameters we return the associated the Message.Implementation instance. None is returne...
def load_message(self, community, member, global_time, verify=False): try: packet_id, packet = self._database.execute(u"SELECT id, packet FROM sync WHERE community = ? AND member = ? AND global_time = ? LIMIT 1", (community.database_id, member.d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_message(self, community, member, global_time):\n if __debug__:\n from .community import Community\n assert isinstance(community, Community)\n assert isinstance(member, Member)\n assert isinstance(global_time, (int, long))\n try:\n packet, = self._dat...
[ "0.7560784", "0.6131421", "0.5522916", "0.5457676", "0.544803", "0.54177594", "0.5407532", "0.53771245", "0.53771245", "0.52493477", "0.52139395", "0.520249", "0.51955056", "0.5191237", "0.5129372", "0.5117377", "0.5116885", "0.51142484", "0.5104956", "0.5095738", "0.5095354"...
0.6723358
1
Returns the Message.Implementation representing the packet or None when no conversion is possible.
def convert_packet_to_message(self, packet, community=None, load=True, auto_load=True, candidate=None, verify=True): if __debug__: from .community import Community assert isinstance(packet, str), type(packet) assert community is None or isinstance(community, Community), type(communit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_packet_to_meta_message(self, packet, community=None, load=True, auto_load=True):\n if __debug__:\n from .community import Community\n assert isinstance(packet, str)\n assert isinstance(community, (type(None), Community))\n assert isinstance(load, bool)\n as...
[ "0.62651646", "0.61438984", "0.5956532", "0.5800738", "0.579719", "0.5761721", "0.5700318", "0.5687235", "0.56867707", "0.56155825", "0.55790013", "0.5497677", "0.5497677", "0.5485392", "0.5456449", "0.5453435", "0.54247653", "0.5388365", "0.5337122", "0.53364253", "0.532003"...
0.63151425
0
Returns a list with messages representing each packet or None when no conversion is possible.
def convert_packets_to_messages(self, packets, community=None, load=True, auto_load=True, candidate=None, verify=True): assert isinstance(packets, (list, tuple)), type(packets) assert all(isinstance(packet, str) for packet in packets), [type(packet) for packet in packets] return [self.convert_pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_packet(self):\n msg_type = ''\n msg = ''\n try:\n msg_type = self.sock.recv(4)\n data = self.sock.recv(4)\n msg_len = int(struct.unpack('!L', data)[0])\n\n while len(msg) != msg_len:\n data = self.sock.recv(min(2048, msg_len - ...
[ "0.6500954", "0.6090966", "0.6077756", "0.60521275", "0.6030444", "0.6030444", "0.5890792", "0.5768347", "0.57548904", "0.567872", "0.56321037", "0.55689216", "0.5553569", "0.55175006", "0.5502669", "0.5493365", "0.546829", "0.5461899", "0.5451955", "0.5437608", "0.5427018", ...
0.6476944
1
Start processing a batch of messages once the cache timeout occurs. This method is called meta.batch.max_window seconds after the first message in this batch arrived. All messages in this batch have been 'cached' together in self._batch_cache[meta]. Hopefully the delay caused the batch to collect as many messages as po...
def _on_batch_cache_timeout(self, meta, timestamp, batch): assert isinstance(meta, Message) assert isinstance(timestamp, float) assert isinstance(batch, list) assert len(batch) > 0 if __debug__: dprint("processing ", len(batch), "x ", meta.name, " batched messages") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self, batch_size=20):\n logging.info('%s: Starting.'% (self.__class__.__name__))\n deferred.defer(self._continue, None, batch_size, _queue=self.QUEUE)", "def poll(self) -> None:\n assert not self.__closed\n\n if self.__batch is not None and (\n len(self.__batch.resu...
[ "0.5931057", "0.58922255", "0.5763866", "0.55823773", "0.54906666", "0.5470494", "0.54347605", "0.5420364", "0.53826874", "0.53566414", "0.53120905", "0.5252952", "0.5252308", "0.5251197", "0.51757944", "0.51708746", "0.5169629", "0.51668245", "0.5164838", "0.5144473", "0.512...
0.6143433
0
Process one batch of messages. This method is called to process one or more Message.Implementation instances that all have the same meta message. This occurs when new packets are received, to attempt to process previously delayed messages, or when a member explicitly creates a message to process. The last option should...
def on_message_batch(self, messages): assert isinstance(messages, list) assert len(messages) > 0 assert all(isinstance(message, Message.Implementation) for message in messages) assert all(message.community == messages[0].community for message in messages) assert all(message.meta ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_messages(self):\n pass", "def _on_batch_cache(self, meta, batch):\n # 21/03/12 Boudewijn: we can not filter all packets this way. i.e. when multiple people\n # send us missing-identity messages some of them will be dropped\n #\n # def unique(batch):\n # ...
[ "0.6711117", "0.6532513", "0.64450914", "0.6189673", "0.6070675", "0.6065218", "0.6041779", "0.5994877", "0.5986435", "0.5909568", "0.5902761", "0.5825511", "0.5801476", "0.5792036", "0.57790595", "0.5717557", "0.56965697", "0.56932205", "0.5564562", "0.55624497", "0.553448",...
0.665377
1
Convert a list with one or more (candidate, data) tuples into a list with zero or more (Message, (candidate, packet, conversion)) tuples using a generator.
def _convert_packets_into_batch(self, packets): assert isinstance(packets, (tuple, list)) assert len(packets) > 0 assert all(isinstance(packet, tuple) for packet in packets) assert all(len(packet) == 2 for packet in packets) assert all(isinstance(packet[0], Candidate) for packet ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self):\n gen = self.v6_gen() # read from workers\n gen = self.tuple_gen(gen) # convert v6->tuple\n gen = self.batch_gen(gen) # assemble into batches\n for b in gen:\n yield b", "def converters(self) -> Iterator[Tuple[str, Type[ConverterAPI]]]:", "def ex_list(...
[ "0.54471076", "0.54320705", "0.53508997", "0.5333612", "0.5313191", "0.5255215", "0.5207062", "0.51712805", "0.51251054", "0.5091828", "0.4997564", "0.4984758", "0.4984758", "0.49804822", "0.4980481", "0.4972588", "0.49557304", "0.49478143", "0.49431786", "0.49149483", "0.491...
0.6198686
0
Store a message in the database. Messages with the Last or FullSyncDistribution policies need to be stored in the database to allow them to propagate to other members. Messages with the LastSyncDistribution policy may also cause an older message to be removed from the database. Messages created by a member that we have...
def _store(self, messages): assert isinstance(messages, list) assert len(messages) > 0 assert all(isinstance(message, Message.Implementation) for message in messages) assert all(message.community == messages[0].community for message in messages) assert all(message.meta == message...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_msg(self, event: Dict) -> None:\n logger.debug('got event to store: %s', str(event))\n\n try:\n\n msgs_table = self.db.table('msgs')\n\n if event['content']['msgtype'] == 'm.text':\n\n all_sender_msgs = msgs_table.search(\n self.stored...
[ "0.60849106", "0.5867789", "0.57263374", "0.5722782", "0.56453985", "0.56379056", "0.55190384", "0.54243857", "0.54073215", "0.5406028", "0.54053354", "0.54040575", "0.53867334", "0.53521097", "0.53393006", "0.5326517", "0.5317134", "0.52832514", "0.52645254", "0.5260779", "0...
0.72389275
0
We received a dispersyintroductionrequest message.
def check_introduction_request(self, messages): for message in messages: # 25/01/12 Boudewijn: during all DAS2 NAT node314 often sends requests to herself. This # results in more candidates (all pointing to herself) being added to the candidate # list. This converges to onl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dispersy_introduction_response(self, destination, source_lan, source_wan, introduction_lan, introduction_wan, connection_type, tunnel, identifier, global_time):\n assert isinstance(destination, Candidate), type(destination)\n assert isinstance(source_lan, tuple), type(source_lan)\n ...
[ "0.54514676", "0.54287654", "0.5286921", "0.5159254", "0.5124823", "0.51035523", "0.5023194", "0.49206224", "0.48850718", "0.4882511", "0.48558718", "0.48317847", "0.48197636", "0.48013508", "0.47955197", "0.47877073", "0.47822514", "0.47733882", "0.47696838", "0.47662705", "...
0.5790471
0
Send a list of messages to a list of candidates. If no candidates are specified or endpoint reported a failure this method will return False.
def _send(self, candidates, messages, debug = False): assert isinstance(candidates, (tuple, list, set)), type(candidates) # 04/03/13 boudewijn: CANDIDATES should contain candidates, never None # candidates = [candidate for candidate in candidates if candidate] assert all(isinstance(candi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _forward(self, messages):\n assert isinstance(messages, (tuple, list))\n assert len(messages) > 0\n assert all(isinstance(message, Message.Implementation) for message in messages)\n assert all(message.community == messages[0].community for message in messages)\n assert all(me...
[ "0.6511673", "0.59067327", "0.5669184", "0.5577342", "0.55101633", "0.5478973", "0.53971684", "0.5345019", "0.5339688", "0.53198415", "0.52802485", "0.5261085", "0.52073544", "0.51799864", "0.51777554", "0.514372", "0.5126518", "0.512633", "0.51141053", "0.51141053", "0.51124...
0.7952246
0
Provide one or more signed messages that prove that the creator is malicious. The messages are stored separately as proof that MEMBER is malicious, furthermore, all other messages that MEMBER created are removed from the dispersy database (limited to one community) to prevent further spreading of its data. Furthermore,...
def declare_malicious_member(self, member, packets): if __debug__: assert isinstance(member, Member) assert not member.must_blacklist, "must not already be blacklisted" assert isinstance(packets, list) assert len(packets) > 0 assert all(isinstance(pack...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def immobilized(self, owner):\n messages = []\n immobilized = False\n \n if self.checkOver(owner, messages):\n immobilized = False\n \n elif self.confused(random.randint(0, 1)):\n self.doDamage(owner, messages)\n immobilized = True\n ...
[ "0.560744", "0.54863155", "0.53898233", "0.5378846", "0.53392255", "0.5169327", "0.5165224", "0.5162627", "0.5114723", "0.5078857", "0.5056753", "0.5036645", "0.5034213", "0.50226235", "0.50063187", "0.50056523", "0.49994028", "0.4988176", "0.49846014", "0.49702302", "0.49673...
0.58881
0
If we have proof that MEMBER is malicious in COMMUNITY, usually in the form of one or more signed messages, then send this proof to CANDIDATE.
def send_malicious_proof(self, community, member, candidate): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(member, Member) assert member.must_blacklist, "must be blacklisted" assert isinstance...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_missing_proof(self):\n node, other = self.create_nodes(2)\n node.send_identity(other)\n\n # permit NODE\n authorize = self._mm.create_authorize([(node.my_member, self._community.get_meta_message(u\"protected-full-sync-text\"), u\"permit\"),\n ...
[ "0.5979632", "0.58954275", "0.5831629", "0.547747", "0.54369456", "0.54368544", "0.5430229", "0.539677", "0.5319999", "0.52388877", "0.5189469", "0.51365006", "0.51142085", "0.5064334", "0.5058228", "0.50538737", "0.50243837", "0.50109917", "0.49985176", "0.49912623", "0.4989...
0.62697965
0
Returns True when ADDRESS is valid. ADDRESS must be supplied as a (HOST string, PORT integer) tuple.
def is_valid_address(self, address): assert isinstance(address, tuple), type(address) assert len(address) == 2, len(address) assert isinstance(address[0], str), type(address[0]) assert isinstance(address[1], int), type(address[1]) if address[0] == "": return False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_address(address:str) -> bool:\r\n return True", "def is_valid_address(address: str) -> bool:\n try:\n Account.validate_address(address)\n except ValueError:\n return False\n return True", "def is_valid_port_address(address):\n try:\n port_add...
[ "0.7473058", "0.73003846", "0.7180927", "0.71750265", "0.7098824", "0.707144", "0.6999426", "0.69086385", "0.68105793", "0.67972875", "0.67850333", "0.6775836", "0.6736245", "0.67007226", "0.6674696", "0.6606567", "0.654157", "0.6520244", "0.65088004", "0.65078056", "0.650357...
0.73339736
1
Create a dispersyidentity message for self.my_member. The dispersyidentity message contains the public key of a community member. In the future other data can be included in this message, however, it must consist of data that does not change over time as this message is only transferred on demand, and not during the sy...
def create_identity(self, community, sign_with_master=False, store=True, update=True): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(store, bool) meta = community.get_meta_message(u"dispersy-identity") # 13/0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dispersy_identity(self, global_time):\n assert isinstance(global_time, (int, long))\n meta = self._community.get_meta_message(u\"dispersy-identity\")\n return meta.impl(authentication=(self._my_member,), distribution=(global_time,))", "def test_outgoing_missing_identity(self):\n ...
[ "0.6501615", "0.6067713", "0.58043027", "0.56935877", "0.5691578", "0.5654484", "0.5455619", "0.5437993", "0.5413395", "0.5358063", "0.52574086", "0.51735467", "0.5128698", "0.5101254", "0.50999695", "0.506703", "0.50351095", "0.5032361", "0.5016808", "0.5008522", "0.50072294...
0.6862749
0
We received dispersymissingidentity messages. The message contains the mid of a member. The sender would like to obtain one or more associated dispersyidentity messages.
def on_missing_identity(self, messages): meta = messages[0].community.get_meta_message(u"dispersy-identity") for message in messages: # we are assuming that no more than 10 members have the same sha1 digest. sql = u"SELECT packet FROM sync JOIN member ON member.id = sync.member W...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_incoming_missing_identity(self):\n community = DebugCommunity.create_community(self._dispersy, self._my_member)\n\n missing = DebugNode(community)\n missing.init_socket()\n missing.init_my_member()\n\n node = DebugNode(community)\n node.init_socket()\n node...
[ "0.6264212", "0.5925865", "0.5924089", "0.5450922", "0.5286037", "0.52569693", "0.5163726", "0.5105806", "0.50717926", "0.5012507", "0.49699667", "0.49681836", "0.4965853", "0.4963381", "0.4941886", "0.49259216", "0.49184424", "0.49180079", "0.49137166", "0.48865473", "0.4862...
0.7384179
0
Create a dispersysignaturerequest message. The dispersysignaturerequest message contains a submessage that is to be signed by another member. The submessage must use the DoubleMemberAuthentication policy in order to store the two members and their signatures. If the other member decides to add their signature she will ...
def create_signature_request(self, community, message, response_func, response_args=(), timeout=10.0, forward=True): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(message, Message.Implementation) assert isinstance(mes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dispersy_signature_request(self, identifier, message, global_time):\n assert isinstance(message, Message.Implementation)\n assert isinstance(global_time, (int, long))\n meta = self._community.get_meta_message(u\"dispersy-signature-request\")\n return meta.impl(distribution=(g...
[ "0.6429564", "0.5921053", "0.5311035", "0.5291809", "0.5088938", "0.5082473", "0.50073636", "0.4974629", "0.48992577", "0.4898646", "0.4850188", "0.48363703", "0.474859", "0.47260234", "0.47235936", "0.46779138", "0.46759245", "0.46544033", "0.4650043", "0.4632776", "0.455529...
0.6682872
0
We received a dispersysignaturerequest message. This message contains a submessage (message.payload.message) that the message creator would like to have us sign. We can choose for ourselves if we want to add our signature to the submessage or not. Once we have determined that we could provide a signature and that the s...
def on_signature_request(self, messages): meta = messages[0].community.get_meta_message(u"dispersy-signature-response") responses = [] for message in messages: assert isinstance(message, Message.Implementation), type(message) assert isinstance(message.payload.message, Mes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dispersy_signature_request(self, identifier, message, global_time):\n assert isinstance(message, Message.Implementation)\n assert isinstance(global_time, (int, long))\n meta = self._community.get_meta_message(u\"dispersy-signature-request\")\n return meta.impl(distribution=(g...
[ "0.6193661", "0.6060058", "0.60464835", "0.60155225", "0.59518707", "0.5774324", "0.5714632", "0.5674083", "0.5670356", "0.5594815", "0.5543016", "0.55423427", "0.55320096", "0.55244434", "0.5522477", "0.55197597", "0.5504144", "0.5490606", "0.5452332", "0.53725237", "0.53233...
0.68072623
0
Handle one or more dispersysignatureresponse messages. We sent out a dispersysignaturerequest, through the create_signature_request method, and have now received a dispersysignatureresponse in reply. If the signature is valid, we will call response_func with submessage, where submessage is the message parameter given t...
def on_signature_response(self, messages): for message in messages: # get cache object linked to this request and stop timeout from occurring cache = self._request_cache.pop(message.payload.identifier, SignatureRequestCache) old_submsg = cache.request.payload.message ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_signature_request(self, messages):\n meta = messages[0].community.get_meta_message(u\"dispersy-signature-response\")\n responses = []\n for message in messages:\n assert isinstance(message, Message.Implementation), type(message)\n assert isinstance(message.payload....
[ "0.67749465", "0.5771967", "0.57298756", "0.57298756", "0.56339025", "0.5500101", "0.5492523", "0.54872686", "0.5409447", "0.53828686", "0.53723246", "0.5368455", "0.5266012", "0.5229861", "0.5183501", "0.5183501", "0.5154976", "0.5149699", "0.5146295", "0.5115391", "0.510772...
0.66214716
1
We received a dispersymissingsequence message. The message contains a member and a range of sequence numbers. We will send the messages, up to a certain limit, in this range back to the sender. To limit the amount of bandwidth used we will not sent back more data after a certain amount has been sent. This magic number ...
def on_missing_sequence(self, messages): community = messages[0].community sources = defaultdict(lambda: defaultdict(set)) if __debug__: dprint("received ", len(messages), " missing-sequence message for community ", community.database_id) # we know that there are buggy clients out ther...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_missing(self):\n community = DebugCommunity.create_community(self._dispersy, self._my_member)\n node = DebugNode(community)\n node.init_socket()\n node.init_my_member()\n\n messages = [node.create_sequence_text(\"Sequence message #%d\" % sequence, sequence + 10, sequence...
[ "0.6455917", "0.567411", "0.54838", "0.5470095", "0.5419593", "0.54125786", "0.5403741", "0.5395253", "0.537422", "0.53487664", "0.5226882", "0.51932585", "0.5129617", "0.50815284", "0.50794387", "0.5071999", "0.506206", "0.5058144", "0.5052442", "0.5034501", "0.50069886", ...
0.7021626
0
Grant permissions to members in a community. This method will generate a message that grants the permissions in permission_triplets. Each item in permission_triplets contains (Member, Message, permission) where permission is either u'permit', u'authorize', or u'revoke'. By default, community.my_member is doing the auth...
def create_authorize(self, community, permission_triplets, sign_with_master=False, store=True, update=True, forward=True): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(permission_triplets, (tuple, list)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grant_permission(self, extra_permission=None):\n permission_list = self.get_permission()\n if extra_permission is not None:\n permission_list += (\n extra_permission\n if isinstance(extra_permission, (tuple, list))\n else [extra_permission]\...
[ "0.6025507", "0.5636996", "0.554352", "0.54446584", "0.5390684", "0.53430897", "0.5322043", "0.5212583", "0.5206149", "0.51909906", "0.5155831", "0.5155831", "0.51522297", "0.5107447", "0.5058053", "0.49885848", "0.49268436", "0.4910338", "0.48574647", "0.48447388", "0.483482...
0.70346814
0
Process a dispersyauthorize message. This method is called to process a dispersyauthorize message. This message is either received from a remote source or locally generated.
def on_authorize(self, messages, initializing=False): for message in messages: if __debug__: dprint(message) message.community.timeline.authorize(message.authentication.member, message.distribution.global_time, message.payload.permission_triplets, message) # this might be a resp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _handleRequestAuthorization(self, data):\r\n print(\"\\\"Request Authorization\\\" received\")\r\n message = self.whitebeet.v2gParseRequestAuthorization(data)\r\n timeout = int(message['timeout'] / 1000) - 1\r\n # Promt for authorization status\r\n auth_str = input(\"Authoriz...
[ "0.5575368", "0.5441344", "0.53204054", "0.52610075", "0.5213013", "0.49779373", "0.49696052", "0.4883401", "0.48675758", "0.48326406", "0.48249972", "0.48157874", "0.48142064", "0.4800637", "0.47625577", "0.47248402", "0.46933508", "0.46533492", "0.46469092", "0.46202874", "...
0.5705393
0
Revoke permissions from a members in a community. This method will generate a message that revokes the permissions in permission_triplets. Each item in permission_triplets contains (Member, Message, permission) where permission is either u'permit', u'authorize', or u'revoke'. By default, community.my_member is doing th...
def create_revoke(self, community, permission_triplets, sign_with_master=False, store=True, update=True, forward=True): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(permission_triplets, (tuple, list)) for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revoke_role(self, role, principal_ids):", "def on_revoke(self, messages, initializing=False):\n for message in messages:\n message.community.timeline.revoke(message.authentication.member, message.distribution.global_time, message.payload.permission_triplets, message)\n\n # this might...
[ "0.6274646", "0.5743438", "0.5395397", "0.52913", "0.5267083", "0.525595", "0.52518684", "0.52147895", "0.51700276", "0.51221967", "0.5067122", "0.50592595", "0.5046118", "0.50200045", "0.49786526", "0.48940107", "0.48599315", "0.48529854", "0.48435703", "0.48359647", "0.4833...
0.73960763
0
Process a dispersyrevoke message. This method is called to process a dispersyrevoke message. This message is either received from an external source or locally generated.
def on_revoke(self, messages, initializing=False): for message in messages: message.community.timeline.revoke(message.authentication.member, message.distribution.global_time, message.payload.permission_triplets, message) # this might be a response to a dispersy-missing-sequence self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt_message(self):\r\n\r\n\t\t#Will not let user input useless messages that cannot be decrypted.\r\n\t\twhile True:\r\n\t\t\tself.message = input(\"Please enter a message you would like to decrypt. --> \")\r\n\t\t\tif self.message != \"\" and len(self.message) > 4:\r\n\t\t\t\tbreak\r\n\t\t#Decrypts messag...
[ "0.5653151", "0.5474099", "0.54268736", "0.5392073", "0.53738827", "0.53645235", "0.5344789", "0.52221036", "0.52190113", "0.5214114", "0.52132314", "0.5207129", "0.5177481", "0.5153544", "0.5143529", "0.51283956", "0.51259995", "0.51043737", "0.5101875", "0.5101358", "0.5096...
0.55935955
1
Create a dispersyundoown or dispersyundoother message to undo MESSAGE. A dispersyundoown message is created when MESSAGE.authentication.member is COMMUNITY.my_member and SIGN_WITH_MASTER is False. Otherwise a dispersyundoother message is created. As a safeguard, when MESSAGE is already marked as undone in the database,...
def create_undo(self, community, message, sign_with_master=False, store=True, update=True, forward=True): if __debug__: from .community import Community assert isinstance(community, Community) assert isinstance(message, Message.Implementation) assert isinstance(si...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dispersy_undo_own(self, message, global_time, sequence_number):\n assert message.authentication.member == self._my_member, \"use create_dispersy_undo_other\"\n meta = self._community.get_meta_message(u\"dispersy-undo-own\")\n return meta.impl(authentication=(self._my_member,),\n ...
[ "0.6338618", "0.63200015", "0.5097709", "0.50658184", "0.48416996", "0.48067334", "0.47472677", "0.47222126", "0.46609572", "0.4625949", "0.45731887", "0.45691597", "0.45656106", "0.4554412", "0.4500357", "0.44823703", "0.4480006", "0.44645083", "0.4455984", "0.44132933", "0....
0.72097266
0
Check everything we can about a community. Note that messages that are disabled, i.e. not included in community.get_meta_messages(), will NOT be checked. the dispersyidentity for my member must be in the database the dispersyidentity must be in the database for each member that has one or more messages in the database ...
def sanity_check(self, community, test_identity=True, test_undo_other=True, test_binary=False, test_sequence_number=True, test_last_sync=True): def select(sql, bindings): assert isinstance(sql, unicode) assert isinstance(bindings, tuple) limit = 1000 for offset in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initiate_meta_messages(self, community):\n if __debug__:\n from .community import Community\n assert isinstance(community, Community)\n messages = [Message(community, u\"dispersy-identity\", MemberAuthentication(encoding=\"bin\"), PublicResolution(), LastSyncDistribution(synchro...
[ "0.61633706", "0.6144215", "0.58035326", "0.565734", "0.565183", "0.5622298", "0.5613788", "0.5593255", "0.55435157", "0.55201066", "0.5497558", "0.5492735", "0.54398715", "0.5424265", "0.54217803", "0.5418511", "0.5407562", "0.53691614", "0.5350547", "0.5321938", "0.5303166"...
0.66730285
0
Tries to guess the most recent sequence number used by the master member for META in COMMUNITY. This is a risky method because sequence numbers must be unique, however, we can not guarantee that two peers do not claim a sequence number for the master member at around the same time. Unfortunately we can not overcome thi...
def _claim_master_member_sequence_number(self, community, meta): assert isinstance(meta.distribution, FullSyncDistribution), "currently only FullSyncDistribution allows sequence numbers" sequence_number, = self._database.execute(u"SELECT COUNT(*) FROM sync WHERE member = ? AND sync.meta_message = ?", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSequence(self):\n if self.sequence != None: # a sequence has been assigned\n return self.sequence\n elif self.seqscores != None: # inferred by parsimony but not yet assigned\n return None # determine most parsimonous sequence, not yet implemented", "def _find_last_se...
[ "0.5846389", "0.58385175", "0.5712841", "0.5638536", "0.5616841", "0.5612507", "0.5424975", "0.535834", "0.534", "0.53367084", "0.5312183", "0.53064", "0.5301774", "0.52814233", "0.52638984", "0.5194946", "0.5186961", "0.51849806", "0.51849806", "0.51849806", "0.51849806", ...
0.6831175
0
Periodically called to flush changes to disk, most importantly, it will catch the GeneratorExit exception when it is thrown to properly shutdown the database.
def _watchdog(self): while True: try: # Arno, 2012-07-12: apswtrace detects 7 s commits with yield 5 min, so reduce yield 60.0 # flush changes to disk every 1 minutes self._database.commit() except Exception: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _catchup(self, generator): \n\n dbmanager = self.engine.db_binder.get_manager(self.data_binding)\n # Find out when the database was last updated.\n lastgood_ts = dbmanager.lastGoodStamp()\n\n try:\n # Now ask the console for any new records since then.\n # (Not...
[ "0.6582041", "0.64136004", "0.64059615", "0.6379652", "0.6338447", "0.6338447", "0.6338447", "0.6338447", "0.63339627", "0.6296306", "0.62916476", "0.6282373", "0.6253019", "0.6244317", "0.62441635", "0.6222089", "0.62132865", "0.6188086", "0.61843765", "0.6118883", "0.610290...
0.7263658
0
Periodically remove Candidate instance where all communities are obsolete.
def _periodically_cleanup_candidates(self): while True: yield 5 * 60.0 now = time() for key, candidate in [(key, candidate) for key, candidate in self._candidates.iteritems() if candidate.is_all_obsolete(now)]: if __debug__: dprint("removing obsolete candidat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_candidate(self, user):\n self.assignment_related_users.filter(user=user).delete()\n inform_changed_data(self)", "def remove_training_reserves():\n reserves = TrainingReserve.objects.all()\n now = timezone.now()\n for reserve in reserves:\n if reserve.date < now:\n ...
[ "0.6012138", "0.5691339", "0.55501235", "0.5529244", "0.5514077", "0.5444481", "0.54411054", "0.5420822", "0.5419682", "0.54025346", "0.5363974", "0.5348055", "0.53480005", "0.5342857", "0.52997303", "0.52685153", "0.5260117", "0.5259349", "0.525612", "0.52475077", "0.5242473...
0.68201804
0
Return a dict representation of a feed entry, with less fields.
def entry_dict(cls, feed_entry): return { 'id': feed_entry['id'], 'link': feed_entry['link'], 'published': pd.to_datetime(feed_entry['published']), 'title': feed_entry['title'], }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feed_entries(self):\n date_format = \"%Y-%m-%dT%H:%M:%SZ\"\n entries = self.mapper.list_entries(limit=10)\n if entries:\n updated = max([e.updated for e in entries]).strftime(date_format)\n else:\n updated = datetime.utcnow().strftime(date_format)\n retu...
[ "0.6642052", "0.6582269", "0.65137154", "0.64207214", "0.63807756", "0.6370539", "0.63104665", "0.6301081", "0.6182454", "0.6181975", "0.6112994", "0.6052598", "0.60043633", "0.5998319", "0.59744674", "0.5951254", "0.5943518", "0.5918743", "0.5903946", "0.59024304", "0.589388...
0.81624085
0
Store the feed headlines in the provided datastore.
def store(self): articles = [] for entry in self.feed(): key = self.datastore_client.key(self.DATASTORE_KIND, entry['id']) article = datastore.Entity(key=key) article.update(entry) articles.append(article) self.datastore_client.put_multi(articles)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_headlines():\n for outlet in outlets:\n articles = get_headlines(outlet)\n connect_db.store_headlines(articles,outlet)", "def store(self):\n print(\"Please take a break, this will take a while :).\")\n\n wiki_db = GenericLookup(\n \"entity_word_embedding\",\n ...
[ "0.7043585", "0.54580647", "0.5294727", "0.52859986", "0.5170264", "0.51221025", "0.50447166", "0.49978557", "0.49910846", "0.4942567", "0.49095592", "0.49095592", "0.49081028", "0.482959", "0.48057124", "0.4776231", "0.47539622", "0.47485977", "0.47432706", "0.4723064", "0.4...
0.6918986
1
Fail if there are JAX primitives that are not implemented.
def test_primitive_coverage(self): # Harvest primitives from XLA translation tables all_primitives = (set(xla.translations) | set(xla.backend_specific_translations['cpu']) | set(xla.backend_specific_translations['gpu']) | set(xla.backend_specific...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_supported_features(self):", "def test_is_primitive_returns_true(self):\n for primitive_type in (535, \"test_string\", False, 12.45, u\"test_unicode_stirng\"):\n is_primitive = self.tested_class._is_primitive(primitive_type)\n self.assertTrue(is_primitive)", "def _notYetIm...
[ "0.58405584", "0.5428893", "0.5349161", "0.5346887", "0.53357565", "0.532798", "0.5327949", "0.51908416", "0.51886314", "0.5188596", "0.51387537", "0.5138101", "0.51373935", "0.51183134", "0.5109311", "0.50856274", "0.5083305", "0.5080892", "0.5073027", "0.5070451", "0.502961...
0.5471267
1
Decorate an objective function Converts an objective function using the typical sklearn metrics signature so that it is usable with ``xgboost.training.train``
def _objective_decorator(func): def inner(preds, dmatrix): """internal function""" labels = dmatrix.get_label() return func(labels, preds) return inner
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def objective_function(x):\n return x * 1 # change this to our actual function", "def objective_function(self, y_true, y_predicted, X=None):", "def custom_method(*args, **kwargs):\n return objective_return", "def custom_method(*args, **kwargs):\n return objective_return", "def obj...
[ "0.6188091", "0.6157492", "0.61521256", "0.61521256", "0.60107756", "0.60107756", "0.5842717", "0.5732868", "0.56493115", "0.56375515", "0.55854857", "0.5517811", "0.55051154", "0.5480425", "0.5480068", "0.5442854", "0.5397331", "0.5397331", "0.53870296", "0.53700745", "0.536...
0.7355156
0
Get the underlying xgboost Booster of this model. This will raise an exception when fit was not called Returns
def get_booster(self): if self._Booster is None: raise XGBoostError('need to call fit or load_model beforehand') return self._Booster
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_xgboost(cls, booster):\n handle = ctypes.c_void_p()\n # attempt to load xgboost\n try:\n import xgboost\n except ImportError:\n raise TreeliteError('xgboost module must be installed to read from '+\\\n '`xgboost.Booster` object')\n if not isinstance(booste...
[ "0.62060666", "0.6174047", "0.5837586", "0.5779983", "0.56247324", "0.5622425", "0.54732335", "0.5463808", "0.5413526", "0.538696", "0.5379228", "0.5371575", "0.53456545", "0.533556", "0.5315803", "0.5311693", "0.5277914", "0.52730113", "0.526538", "0.5261913", "0.5224007", ...
0.8257933
0
Gets the number of xgboost boosting rounds.
def get_num_boosting_rounds(self): return self.n_estimators
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_num_gratings(self):\r\n msg = struct.pack('>2B', 56, 13)\r\n response = self.query(msg)\r\n return response[1]", "def count_one_round(self):\n\t\tself.round_count+=1\n\t\treturn self.round_count", "def getNumFluxBounds(self):\n return _libsbml.FbcModelPlugin_getNumFluxBounds...
[ "0.64653987", "0.62677133", "0.62584245", "0.62469226", "0.61951655", "0.61848617", "0.6102562", "0.60919344", "0.6038753", "0.6017248", "0.59922975", "0.5987341", "0.5970989", "0.59494334", "0.5899165", "0.5883482", "0.5879722", "0.5879606", "0.58764595", "0.58758515", "0.58...
0.78578055
0
Load the model from a file. The model is loaded from an XGBoost internal binary format which is universal among the various XGBoost interfaces. Auxiliary attributes of the Python Booster object (such as feature names) will not be loaded. Label encodings (text labels to numeric labels) will be also lost. If you are usin...
def load_model(self, fname): if self._Booster is None: self._Booster = Booster({'nthread': self.n_jobs}) self._Booster.load_model(fname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_model(self, file_name):\n with open(file_name, 'rb') as file:\n self.lin_reg = pickle.load(file)", "def load(model_file):\n return pickle.load(open(model_file))", "def load_model(self, filename):\r\n pass", "def load_model(self, filename):\n\n with open(filename, 'rb')...
[ "0.7331196", "0.73237056", "0.7300292", "0.72718865", "0.7270069", "0.7117655", "0.7088148", "0.7046383", "0.69970965", "0.6990235", "0.69634134", "0.69634134", "0.69634134", "0.6918024", "0.69025797", "0.68860584", "0.688266", "0.687393", "0.6857411", "0.6846126", "0.6843733...
0.7463586
0
Return the evaluation results. If eval_set is passed to the `fit` function, you can call ``evals_result()`` to get evaluation results for all passed eval_sets. When eval_metric is also passed to the `fit` function, the evals_result will contain the eval_metrics passed to the `fit` function. Returns
def evals_result(self): if self.evals_result_: evals_result = self.evals_result_ else: raise XGBoostError('No results.') return evals_result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self) -> Dict[str, float]:\n eval_dataloader = self.get_eval_dataloader()\n\n output = self._prediction_loop(eval_dataloader, description=\"Evaluation\")\n return output.metrics", "def evaluate(self, csls, evals, mode=\"csls\"):\n metrics = {}\n for eval_func in ev...
[ "0.6620927", "0.6559421", "0.63603014", "0.63391876", "0.62897426", "0.60869324", "0.60701704", "0.6069634", "0.6049112", "0.60447854", "0.6023711", "0.6015113", "0.6012249", "0.60083205", "0.5962003", "0.59610075", "0.5954775", "0.5935323", "0.591444", "0.5910966", "0.588405...
0.6693977
1
Return the evaluation results. If eval_set is passed to the `fit` function, you can call ``evals_result()`` to get evaluation results for all passed eval_sets. When eval_metric is also passed to the `fit` function, the evals_result will contain the eval_metrics passed to the `fit` function. Returns
def evals_result(self): if self.evals_result_: evals_result = self.evals_result_ else: raise XGBoostError('No results.') return evals_result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self) -> Dict[str, float]:\n eval_dataloader = self.get_eval_dataloader()\n\n output = self._prediction_loop(eval_dataloader, description=\"Evaluation\")\n return output.metrics", "def evaluate(self, csls, evals, mode=\"csls\"):\n metrics = {}\n for eval_func in ev...
[ "0.662151", "0.65604186", "0.6359906", "0.63397086", "0.62905097", "0.608761", "0.60717255", "0.6069498", "0.6049144", "0.6044212", "0.60239065", "0.6015631", "0.6011513", "0.6008537", "0.59633106", "0.59612614", "0.5954257", "0.5936408", "0.5915028", "0.5910866", "0.5884813"...
0.66939914
0
Tests if a string is a valid silk type
def is_valid_silktype(type_name, permit_array=False): if not type_name.replace("_", "x").isalnum(): return False if not type_name[0].isupper(): return False if len(type_name) > 1 and type_name == type_name.upper(): return False if permit_array: array_depth = 0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strtype(x):\n if type(x) == str:\n return True\n if type(x) == unicode:\n return True\n return False", "def isString(s):\r\n try:\r\n return isinstance(s, unicode) or isinstance(s, basestring)\r\n except NameError:\r\n return isinstance(s, str)", "def is_my_type(t...
[ "0.69701934", "0.6942007", "0.69073087", "0.68592864", "0.68538857", "0.68175155", "0.68133545", "0.6744831", "0.67343795", "0.6702579", "0.66869265", "0.66726637", "0.66681784", "0.66564006", "0.6655341", "0.6651943", "0.6630338", "0.658477", "0.65845793", "0.65524256", "0.6...
0.74222136
0
Abstract method applying a filter on the image passed as parameter.
def apply_filter(self, image): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter(image, filter):\n filteredImage = create_image(image)\n # Apply Filter:\n # FIXME!\n \n return filteredImage", "def apply_filter(image: np.ndarray) -> np.ndarray:\n # choose filters to apply\n return clahe(image)", "def custom_filter(image: Image) -> Image:\n im...
[ "0.82875824", "0.77260727", "0.7703948", "0.7388308", "0.7294774", "0.7212332", "0.71315414", "0.70947236", "0.69251555", "0.68920493", "0.6842183", "0.6837126", "0.6810681", "0.68029267", "0.673414", "0.6666993", "0.66306055", "0.6615687", "0.6612078", "0.6549975", "0.654154...
0.89909905
0
Applies a difference of gaussian filter (bandpass) on the image.
def apply_filter(self, image): gauss_low = cv2.GaussianBlur(image, ksize=(0,0), sigmaX=self._sigma_low , sigmaY=self._sigma_low) gauss_high = cv2.GaussianBlur(image, ksize=(0,0), sigmaX=self._sigma_high, sigmaY=self._sigma_high) filtered_image = gauss_low - gauss_high return normalize...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def differenceOfGausssians(image,sigma0, sigma1,window_size, roi, out = None):\n return (vigra.filters.gaussianSmoothing(image,sigma0,window_size=window_size,roi = roi)-vigra.filters.gaussianSmoothing(image,sigma1,window_size=window_size,roi = roi))", "def find_difference_of_gaussian_blur(image, k1, k2, *args...
[ "0.68816376", "0.63723445", "0.63372576", "0.62918264", "0.6184185", "0.61841756", "0.6165197", "0.61583704", "0.61153054", "0.61050576", "0.6103328", "0.60380554", "0.6013822", "0.5979641", "0.5937425", "0.59201074", "0.5914985", "0.5904962", "0.58926266", "0.5833204", "0.58...
0.69949657
0
Constructor of DenoiserImageProcessingMethod. Initialises the variables describing the Denoising filter strength.
def __init__(self, denoiser_strength): self._strength = denoiser_strength
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, input_dim):\n super(ps_FNNDenoiser, self).__init__()\n\n self._input_dim = input_dim\n\n self.fnn_enc = Linear(self._input_dim, int(self._input_dim / 2))\n self.fnn_dec = Linear(int(self._input_dim / 2), self._input_dim)\n\n self.initialize_module()", "def __...
[ "0.6367458", "0.63344586", "0.63035595", "0.60392046", "0.6019234", "0.5945961", "0.58763665", "0.5809447", "0.57781184", "0.577237", "0.5768741", "0.5767068", "0.5758271", "0.5747164", "0.5742086", "0.5729025", "0.5724371", "0.5718335", "0.57000214", "0.56992126", "0.5690762...
0.63912785
0
Returns new list with booleans replaced with 'P' or 'N'.
def _replace_boolean(data): output_data = deepcopy(data) for row in output_data: for i, element in enumerate(row): if element is True: element = 'P' elif element is False: element = 'N' row[i] = element return output_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __convert_boolean_list(boolean_list):\n return ['0' if b else '1' for b in boolean_list]", "def get_list_of_bool2(self):\n pass", "def boollist(lst):\n return (', '.join(map(lambda x: str(bool(x)), lst))).lower()", "def make_removal_bool(*bools):\n return(np.invert([np.any(f) for f in...
[ "0.65647674", "0.64018404", "0.61075115", "0.59592813", "0.5727216", "0.5601529", "0.55128574", "0.5490461", "0.54734", "0.53854305", "0.5381356", "0.5347806", "0.53430605", "0.5221677", "0.51772606", "0.51315314", "0.5126396", "0.5066871", "0.5047082", "0.50347006", "0.50177...
0.726674
0
Creates output file, based on desired file extension(format). If file with generated name already exists, generated data will be appended to existing file.
def generate_output_file(data, extension, headers): output_data = _replace_boolean(data) output_name = _generate_output_name(extension) with open(output_name, 'a', newline='') as file: _file_writer(file, extension, output_data, headers)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_file_name_maker(args):\n log.debug(\"Entering output_file_name_maker()\")\n path = os.getcwd() + '/out_files/'\n if not os.path.isdir(path):\n os.mkdir(path)\n\n if args.output is None:\n out_file_name = path + args.input[:-4] + '_' + args.type + '_' + args.layer\n else:\n ...
[ "0.688348", "0.6569752", "0.65074295", "0.63284576", "0.6293775", "0.62781996", "0.62701577", "0.6268859", "0.62617457", "0.6260558", "0.625713", "0.6245951", "0.62429255", "0.62371254", "0.6198365", "0.61868316", "0.6183687", "0.6159675", "0.6105735", "0.61001354", "0.608727...
0.7465083
0
Online estimation of the GelmanRubin diagnostic.
def online_gelman_rubin() -> Tuple[str, Callable, Callable]: metric_name = "worst_rhat" w_init, w_update, w_covariance = welford_algorithm(True) def init(init_state) -> GelmanRubinState: """Initialise the online gelman/rubin estimator Parameters ---------- num_chains: int ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gelman_rubin(x):\n if np.shape(x) < (2,):\n raise ValueError(\n 'Gelman-Rubin diagnostic requires multiple chains of the same length.')\n\n try:\n m, n = np.shape(x)\n except ValueError:\n print(\"Bad shape for the chains\")\n return\n\n # Calculate between-ch...
[ "0.63978714", "0.560082", "0.55212474", "0.546197", "0.54514706", "0.5391044", "0.5365765", "0.5357661", "0.53559643", "0.534991", "0.5347676", "0.5340379", "0.5333364", "0.5326659", "0.53191304", "0.53162605", "0.5300197", "0.52969295", "0.5294041", "0.5287778", "0.52789485"...
0.63816273
1
Loads data to a csv file and stores it under dest_path.
def _load(df_vouchers: pd.DataFrame, dest_path: str) -> str: if dest_path is None: dest_path = "./" else: dest_path = sanitize_path(dest_path) file_path: str = f"{dest_path}vouchers.{current_time()}.csv" df_vouchers.to_csv(file_path, index=False) return file_path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv(self, destination_path):\n # todo - test for single and duplicate base cases\n to_csv(self._axl_data, destination_path)", "def loadCSV(input_file):", "def load_CSV_data(path):\n return np.genfromtxt(os.path.join('data/traffic_data', path))", "def import_data(self, src_filename, colum...
[ "0.6888042", "0.6277713", "0.62316996", "0.61440474", "0.60710883", "0.60263604", "0.60150874", "0.59695256", "0.5928388", "0.59268904", "0.58436733", "0.5833807", "0.5806386", "0.58039343", "0.58010757", "0.5784977", "0.5772898", "0.5729425", "0.57237065", "0.5710944", "0.57...
0.6743006
1
generate anchors of one scale at all aspect_ratios
def generate_anchors(scales=(32,), aspect_ratios=(0.5, 1, 2), dtype=np.float32): scales = np.array(scales) aspect_ratios = np.array(aspect_ratios, dtype=dtype) h_ratios = np.sqrt(aspect_ratios) w_ratios = 1 / h_ratios ws = (w_ratios[:, None] * scales[None, :]).reshape(-1) hs = (h_ratios[:, None...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_anchors(base_size, scales, aspect_ratios):\n anchor = np.array([1, 1, base_size, base_size], dtype=np.float) - 0.5\n anchors = _ratio_enum(anchor, aspect_ratios)\n anchors = np.vstack(\n [_scale_enum(anchors[i, :], scales) for i in range(anchors.shape[0])]\n )\n return torch.fro...
[ "0.8082869", "0.76463455", "0.7565648", "0.7543432", "0.7447532", "0.744453", "0.7424722", "0.7424722", "0.7262211", "0.70700175", "0.70170045", "0.6962589", "0.6888735", "0.688725", "0.6823718", "0.67506444", "0.67125916", "0.65764946", "0.65681225", "0.65681225", "0.6550616...
0.79542905
1
parse output string with AnswerSetManager and return the manager
def parseGeneratedProblems(self, json_output): # set stdin to be json_output # NOTE: eqn_viz.AnswerSetManager can only read from file or from stdin, so # we save output to a temporary file and set it to stdin old_stdin = sys.stdin temp_file = tempfile.TemporaryFile(mode='w+') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_output(self, output, error):\n return ClingoAnswerSets(output, error)", "def get_answer_sets_string(self):\n return self._output", "def parse_answers(dns_resp: str, session_cache):\n\n ID = dns_resp[:4]\n other_flags = dns_resp[4:8]\n questions_count = dns_resp[8:12]...
[ "0.5953442", "0.5496168", "0.54211426", "0.5300385", "0.52503484", "0.523621", "0.5234014", "0.51823366", "0.5129332", "0.502874", "0.50246847", "0.500458", "0.50002414", "0.49928126", "0.49877262", "0.49618128", "0.496163", "0.49584866", "0.4949401", "0.494256", "0.48906523"...
0.59529203
1
Converts a label (int or string) into the corresponding emoji code (string) ready to be printed
def label_to_emoji(label): return emoji.emojize(emoji_dictionary[str(label)], use_aliases=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def label_to_emoji(label):\n return emoji.emojize(emoji_dictionary[str(label)], use_aliases=True)", "def enlabel(mi_, ma_):\n\treturn \"Unicode characters from {} to {} codepoints\".format(mi_, ma_)", "def encode_label(label: str) -> int:\n\tif not label:\n\t\treturn 0\n\t# part after letter if it has a...
[ "0.727385", "0.69124043", "0.671142", "0.66231465", "0.6572562", "0.6372932", "0.63420016", "0.62908775", "0.6271043", "0.6254556", "0.62525135", "0.62295246", "0.6195827", "0.61652017", "0.61167014", "0.60740083", "0.5974666", "0.5970056", "0.5956409", "0.5914948", "0.589891...
0.7411243
1
Return all games of this pool, normal, finals, and subpools
def all_games(self): return sorted(self.games + list(g for sp in self.sub_pools for g in sp.games) + self.finals, key=lambda g: (g.datetime, g.pitch.rank))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_free_games(self) -> List[Game]:", "def get_all_games():\n games = brain.get_all_games()\n return games", "async def fetch_games(self):\n return await self.http.get_game_list()", "def as_games(self):\n self._assert_no_aggregate()\n\n self._sort_tables = [types.Game]\n ...
[ "0.6906494", "0.68691814", "0.6295891", "0.6261945", "0.6187605", "0.604185", "0.5937383", "0.59333384", "0.58365124", "0.5780108", "0.57791203", "0.57616854", "0.575287", "0.5737332", "0.56886965", "0.5657821", "0.56510615", "0.56444657", "0.5634835", "0.5608298", "0.5603748...
0.7823409
0
Convert self.tags values from strings into their 'natural type' (int, float, etc.)
def _make_natural_type(self): for tag in self.tags: if self.tags[tag] is None or str(self.tags[tag]).strip() == "": self.tags[tag] = None else: if tag.lower() in VASP_TAG_INT_LIST: try: self.tags[tag] = int(self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convertType(self, s):\n for func in (int, float):\n try:\n n = func(s)\n return n\n except:\n pass\n return s", "def str2type(raw_val):\n try:\n return int(raw_val)\n except ValueError:\n pas...
[ "0.6122019", "0.6096812", "0.58197117", "0.5805016", "0.5756191", "0.57524294", "0.5702444", "0.5660094", "0.5640691", "0.56322366", "0.56258076", "0.56190556", "0.55436754", "0.55436754", "0.5533796", "0.5510357", "0.55060124", "0.5485581", "0.5449976", "0.5423919", "0.54070...
0.76923037
0
Check that stringvalued tags are allowed values
def _check_string_tag(self,tag,value): if tag.lower() == 'prec': if value.lower() not in ['low' ,'medium' ,'high' ,'normal' ,'single' ,'accurate']: raise IncarError("Unknown 'prec' value: '" + value) elif tag.lower() == 'algo': if value.lower() not in ['normal','v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_string_values(self):\n valid_xml = '{\"foo\": \"<b>Bar</b>\", \"baz\": true}'\n eq_(validate_xml(valid_xml), valid_xml)", "def is_tag(value):\r\n tag_names = parse_tag_input(value)\r\n if len(tag_names) > 1:\r\n raise ValidationError(_('Multiple tags were given.'))\r\n ...
[ "0.6827241", "0.65821975", "0.6519894", "0.6485389", "0.64529824", "0.6430218", "0.63962024", "0.63349634", "0.6223701", "0.6183873", "0.6181378", "0.6123407", "0.61139095", "0.6086454", "0.60844916", "0.6077193", "0.6058368", "0.59735143", "0.59726495", "0.59646773", "0.5947...
0.69822365
0
Check that only allowed INCAR tags are in self.tags
def _verify_tags(self): for tag in self.tags: if tag.lower() in VASP_TAG_LIST: continue else: print(("Warning: unknown INCAR tag '" + tag + "' with value '" + str(self.tags[tag]) + "'"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _canProcessTags(self, grammar, pos_tags):\n badTags = []\n for tag in pos_tags:\n if tag not in grammar.tags:\n badTags.append(tag)\n logger.debug(\"Grammar can't handle tag:\" + tag)\n if badTags:\n return False\n else:\n ...
[ "0.6774265", "0.65963537", "0.63586843", "0.63130444", "0.63031954", "0.6138437", "0.6108099", "0.6065835", "0.6065835", "0.60520315", "0.60268587", "0.601338", "0.58681035", "0.5847401", "0.5813634", "0.5811468", "0.5803957", "0.57694745", "0.5748742", "0.5701099", "0.569190...
0.7914606
0
Validate `node_color_by` and `G` when `color_by` has a special value.
def validate_color_by( G: nx.Graph, color_by: Hashable, node_color_by: Hashable, ) -> None: if color_by in ("source_node_color", "target_node_color"): if not isinstance(G, nx.DiGraph): raise ValueError( "Special values of `color_by`, can only be set for directed graph...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_rbtree_colors(node, parent_color=BLACK):\n if node is None:\n return True\n if node.color == RED and parent_color == RED:\n return False\n return valid_rbtree_colors(node.L, node.color) and \\\n valid_rbtree_colors(node.R, node.color)", "def CheckProperColoring(G):\r\n ...
[ "0.6134997", "0.6131663", "0.599443", "0.59113634", "0.58538246", "0.57898504", "0.5664353", "0.5661821", "0.5581701", "0.5560058", "0.55422676", "0.5541176", "0.55016965", "0.5484223", "0.5461343", "0.5396346", "0.53376204", "0.5331944", "0.5326135", "0.5323236", "0.5289655"...
0.87289196
0
Takes behaviour policy from 'policy_path' and create dataset of trajectories. Saved in 'data/' folder + output path
def dataset_me(policy_path, output_path, num_traj= 1000, max_t=200, init_state=None): agent = Agent(state_size=3, action_size=1, random_seed=2) agent.actor_local.load_state_dict(torch.load(policy_path)) dataset = [] for i in range(num_traj): if init_state==None: state = env.rese...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, data, options={}):\n # same as train except run python policy_agent.py $relation test\n dir_name = list(data.keys())[0]\n relations = data[dir_name]\n if \"relation\" in options :\n relations = [options[\"relation\"]]\n set_data_path(dir_name)\n ...
[ "0.6416428", "0.61549985", "0.5828855", "0.57680494", "0.5766369", "0.57627046", "0.5752179", "0.5743254", "0.5660502", "0.56597704", "0.5553803", "0.5488288", "0.54880255", "0.5479636", "0.5479636", "0.5475223", "0.5471815", "0.54702204", "0.54577047", "0.54457223", "0.54348...
0.721294
0
Generate the documentation case, section by section.
def case_sections(self, case, response): formatted = self.format_response_for_docs(response, case) base_path = os.path.join(self.raw_dir, case['name']) for phase in ('request', 'response'): is_json = ( 'Content-Type: application/vnd.api+json' in format...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_docs(self, sections):\n for docs, code in sections:\n yield docs + code", "def generate_documentation(self):\n self.generate_api_docs()\n build.main([\n self.SOURCE_DIR,\n self.BUILD_DIR,\n ])", "def _write_member_documentation_pages(\n ...
[ "0.75519264", "0.6220106", "0.6203306", "0.5909851", "0.58698714", "0.57865393", "0.57822955", "0.56876594", "0.56830186", "0.5678887", "0.56474566", "0.5642664", "0.56418234", "0.56404626", "0.55771303", "0.5573259", "0.55540687", "0.55479276", "0.554734", "0.5506205", "0.54...
0.65040797
1
Add an ending newline, if needed.
def ensure_ending_newline(self, text): if text and text[-1] != '\n': return text + '\n' else: return text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lf(self):\n self._write('\\n')", "def _newline(self):\n if prettyprint:\n return '\\n' + self._indent_spaces()\n else:\n return ''", "def insert_newline():\r\n insert_char(\"\\n\")", "def maybe_eol(self):\n if self.current == CR:\n self.next()...
[ "0.7629914", "0.76006377", "0.7524252", "0.7401863", "0.73827267", "0.72100276", "0.70967597", "0.7035373", "0.698317", "0.6800482", "0.6709806", "0.6669955", "0.6629523", "0.6567795", "0.65458256", "0.6457586", "0.64334375", "0.64208364", "0.64178926", "0.6378259", "0.637059...
0.8013998
0
Format a requests response for documentation.
def format_response_for_docs(self, response, case): parsed = self.parse_response(response, case) formatted = { 'request': {'body': parsed['request']['body']}, 'response': {'body': parsed['response']['body']} } request = parsed['request'] headers = request...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_response_for_display(self, response, case):\n out_bits = []\n parsed = self.parse_response(response, case)\n\n request = parsed['request']\n out_bits.append(request['request_line'])\n for header, value in request['headers'].items():\n out_bits.append('%s: %s...
[ "0.6580887", "0.651959", "0.62884516", "0.60309654", "0.6000146", "0.58808404", "0.5811387", "0.58015925", "0.57907987", "0.57267165", "0.5695614", "0.567432", "0.56306", "0.5585933", "0.5576628", "0.5565839", "0.555188", "0.5549786", "0.55445445", "0.54956186", "0.54901165",...
0.81623507
0
Format a requests response for display.
def format_response_for_display(self, response, case): out_bits = [] parsed = self.parse_response(response, case) request = parsed['request'] out_bits.append(request['request_line']) for header, value in request['headers'].items(): out_bits.append('%s: %s' % (header,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format(self, response):\n\n res = self._prepare_response(response)\n res.content = self._format_data(res.content, self.charset)\n return self._finalize_response(res)", "def format_response(response):\n start_line = _format_status_line(response.status, response.reason)\n msg = _form...
[ "0.750141", "0.73746365", "0.71931225", "0.6706523", "0.65774786", "0.65318406", "0.643178", "0.6424558", "0.6397981", "0.63421637", "0.62704474", "0.6248415", "0.6239191", "0.6201922", "0.6135184", "0.6124427", "0.609853", "0.6073496", "0.60647094", "0.6063283", "0.6042415",...
0.79958725
0
Parse and reformat a requests response.
def parse_response(self, response, case): request = response.request parsed = { 'request': { 'method': request.method, 'url': request.url, 'body': request.body, }, 'response': { 'headers': OrderedDict(), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_response(self, resp):\n p, u = self.getparser()\n\n if hasattr(resp, 'text'):\n # modern requests will do this for us\n text = resp.text # this is unicode(py2)/str(py3)\n else:\n\n encoding = requests.utils.get_encoding_from_headers(resp.headers)\n ...
[ "0.6987392", "0.692319", "0.6773708", "0.6711232", "0.66490734", "0.66068614", "0.6593378", "0.65837854", "0.65747625", "0.6527578", "0.65266913", "0.6517364", "0.6487692", "0.6456611", "0.642243", "0.6416484", "0.6377781", "0.634903", "0.6338582", "0.62498236", "0.6216274", ...
0.7107651
0
given a scaffold and nt position, snp2gene will determine if the nt is within a gene, and if so, whether it is within an exon or intron
def snp2gene(scaffold, pos, gff=dbpaths['gff']): geneid = 'intergenic' geneloc = 'non-coding' fobj = open(gff, 'rb') for line in fobj: col = line.split() if col[0] == scaffold: if col[2] == "mRNA": if int(col[3])<=int(col[4]): if float(co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_transcript_sgrnas(target_region_seq_df, context_len, pam_start, pam_len,\n sgrna_start, sgrna_len, pams, sg_positions):\n sgrna_df_list = []\n meta_columns = ['object_type', 'strand', 'transcript_id', 'seq_region_name', 'region_id', 'start', 'end']\n for i, row in target_r...
[ "0.5512942", "0.5444935", "0.5389595", "0.5257709", "0.521737", "0.5214818", "0.5205589", "0.5167892", "0.5112356", "0.5073349", "0.50532997", "0.5014644", "0.50105494", "0.50024086", "0.49806327", "0.49746072", "0.49728215", "0.49354753", "0.49168587", "0.49098632", "0.49021...
0.7245567
0
For each locus as defined by the three input lists, locus2gene() will pull out the overlapping genes from the OGS gff file. If an additional list of corresponding data is provided, it will be appended to the results dictionary.
def locus2gene(scaflist, gbeglist, gendlist, gdatalist=False, gff=dbpaths['gff'], comprehensive=True ): cuffgenes = {} for result in range(len(scaflist)): if result % 1000 == 0: print "%d genes matched of %d" % (result, len(scaflist)) cur_scaf = scaflist[result] cur_gbeg = g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gff3_parsed (gff3_file, sam_dic):\n\n #A special type of dictionary in which the values were saved in a list\n gff_dic = defaultdict(list)\n\n gff3_file = open(arg.gff3_infile)\n gff3_dic = {}\n\n gene_dic = {}\n exon_list = []\n gene_idx = 1\n\n counter_1 = 0\n counter_2 = 0\n co...
[ "0.6109402", "0.5813848", "0.56766325", "0.5630648", "0.56278354", "0.56097996", "0.56022763", "0.5599682", "0.5568689", "0.55632704", "0.55523854", "0.54970545", "0.5487645", "0.548709", "0.5436917", "0.542399", "0.5405749", "0.539836", "0.5389372", "0.5368671", "0.5334919",...
0.71473604
0
Takes the cuffdiff results file (from fname), and compares it with the current C.biroi gff file, returning as a dictionary any genes that overlap the cuffdiff result.
def findgene(fname, dbpaths=dbpaths): scaf = [] gbeg = [] gend = [] gfor = [] gsta = [] gdif = [] cuffgenes = {} fobj = open(fname) for line in fobj: col = line.split() scaf.append( re.search('[sCcafold]*[0-9]+', col[3]).group() ) gbeg.append( int(re.search('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gendictgf(fname):\n \n cibopen = {}\n npumps = {}\n \n f = open(fname)\n f.next()\n \n for l in f:\n movie, f1, f2, cond, cib, npump = l.split(',')[0:6]\n condition = cond\n #condition = c.strip('')\n \n if condition not in cibopen:\n cibope...
[ "0.6301842", "0.6174319", "0.5772087", "0.5672939", "0.5638178", "0.55527586", "0.548225", "0.54185665", "0.540845", "0.54082096", "0.53937024", "0.538709", "0.5359057", "0.53400826", "0.5315513", "0.5310812", "0.5228215", "0.52122337", "0.51946896", "0.51944745", "0.51757807...
0.66373605
0
extracts sequence of geneID from the current annotations. type is cds, pep or fasta.
def extractseq(geneID, db=dbpaths['cds'], startpos=0, endpos=-1): #fname = dbpaths[type] geneseq = "" fobj = open(db, 'rb') for line in fobj: if line[0] == '>': query = re.search( geneID + '[\s]', line) if query: thisline = fobj.next() while thisline[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_annotation_gene_types(args):\n ref_mgr = ReferenceManager(args.reference_path)\n tss = BedTool(ref_mgr.tss_track)\n if tss.field_count() == 7:\n return TRANSCRIPT_ANNOTATION_GENE_TYPES\n else:\n return None", "def cellannotation2ID(self, annotation_type):\n annotations = ...
[ "0.5662214", "0.54267174", "0.53648776", "0.5334028", "0.5317295", "0.5313579", "0.5258759", "0.5245655", "0.5237802", "0.5233585", "0.5167605", "0.51283205", "0.5126109", "0.51074994", "0.50516504", "0.50449187", "0.50252074", "0.50071573", "0.500155", "0.49981478", "0.49958...
0.5907434
0
For a given genelist, determines which KEGG modules are significantly enriched. Returns both module enrichment Pvalues, and upperlevel classification Pvalues (as dictionaries). NB will not likely show many, as modules are very small. Better to use BRITE pathways instead (via kegg_pathway_enrichment() ).
def kegg_module_enrichment(genelist, dbpaths=dbpaths): size, kegglist = cbir_to_kegg(genelist) #print "Creating Kegg module library" ## create Kegg module dictionary: kmod_h = open(dbpaths['kegg'], 'rb') kmodlist = [] kmodd = {} kmodcount = 0 kmcount = {} kmod = 'none' kgroupb...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enrichment_kegg(**kwargs):\n logger.setLevel(kwargs[\"logger\"])\n\n keggname = kwargs[\"kegg_name\"]\n params = {\n \"padj\": kwargs[\"padj_cutoff\"],\n \"log2_fc\": kwargs[\"log2_foldchange_cutoff\"],\n \"mapper\": kwargs[\"biomart\"],\n \"nmax\": kwargs[\"max_pathways\"]...
[ "0.5427188", "0.5255649", "0.512951", "0.50554824", "0.50527394", "0.5014638", "0.49931002", "0.49858072", "0.49409455", "0.49037877", "0.48558858", "0.48175046", "0.47957835", "0.47608057", "0.47515637", "0.47494304", "0.4746394", "0.47415534", "0.47069296", "0.4693003", "0....
0.7382094
0
For a given list of differentially expressed genes (and the background of non differentially expressed genes), determines which KEGG pathways are significantly enriched. Returns both module enrichment Pvalues, and upperlevel classification Pvalues (as dictionaries).
def kegg_pathway_enrichment(degs, negs, dbpaths=dbpaths, show_all=True, pthresh=0.01): deg_num_ko, deg_keggs = cbir_to_kegg(degs) neg_num_ko, neg_keggs = cbir_to_kegg(negs) print "%-4d kegg pathways from %d DEGs" % (len(deg_keggs), len(degs) ) print "%-4d kegg pathways from %d nonDEGs" % (len(neg_kegg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kegg_module_enrichment(genelist, dbpaths=dbpaths):\n size, kegglist = cbir_to_kegg(genelist)\n\n #print \"Creating Kegg module library\"\n ## create Kegg module dictionary:\n kmod_h = open(dbpaths['kegg'], 'rb')\n\n kmodlist = []\n kmodd = {}\n kmodcount = 0\n kmcount = {}\n kmod = '...
[ "0.6040878", "0.5553813", "0.54275095", "0.53700346", "0.53404963", "0.5267292", "0.52258474", "0.5169173", "0.5151302", "0.5096797", "0.5087131", "0.5079126", "0.5077725", "0.50745064", "0.5032692", "0.50323516", "0.5028554", "0.50272876", "0.5015276", "0.50111157", "0.50043...
0.6303385
0
A string describing the inheritance cycles starting from this class if any or None if there is no cycle.
def cycles(self) -> str: if self.inheritanceCycles: return ( ', '.join( ('<'.join(c.name for c in cycle)) for cycle in self.inheritanceCycles)) else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__ (self):\n cycles = []\n for cycle in self._getcycles():\n cycles.append(' '.join(str(x) for x in cycle).join('()'))\n return ''.join(cycles)", "def find_cycle(self):\n # from guido's blog :\n # http://neopythonic.blogspot.com/2009/01/detecting-cycles-in-d...
[ "0.5980431", "0.55569005", "0.5521167", "0.53105307", "0.5302094", "0.5212952", "0.51823485", "0.50752133", "0.5070178", "0.5048585", "0.50355005", "0.50105894", "0.50064045", "0.49571663", "0.49405968", "0.49329773", "0.4925252", "0.49217385", "0.48992538", "0.4894424", "0.4...
0.79429716
0
List of all {id} attributes.
def idPrint(self) -> List['Attribute']: return [ a for a in self.attributes if a.isId]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id(self) -> str:\n return self._attributes", "def get_attributes(cls):\r\n return []", "def get_all_attrs():\n cursor = Biometa.objects.aggregate(*[\n {'$unwind': '$sample_attributes'},\n {\n '$project': {'_id': '$sample_attributes.name'}\n }\n ])\n\n ...
[ "0.6729202", "0.63389975", "0.6328424", "0.63080233", "0.6262241", "0.62042797", "0.61801535", "0.6120017", "0.6118703", "0.6087975", "0.606026", "0.60305756", "0.5995175", "0.5986143", "0.5968085", "0.5963127", "0.5963127", "0.5957077", "0.5955799", "0.5954634", "0.59495574"...
0.84537935
0
Fragmentary keys, Check if available! You should check fragmentary_room before use new room!
def has_fragmentary(self): for key_level in self.available_level: room_names = self.fragmentary_room.get(key_level) if room_names: room_name = self.do_it(key_level) return room_name return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_keys(self):", "def can_visit_all(rooms):\n total = len(rooms)\n visited = [False] * total\n visited[0] = True\n todo = [0]\n while todo:\n n = todo.pop()\n print(f'visit room {n}')\n for key in rooms[n]:\n if 0 <= key < total and not visited[key]:\n ...
[ "0.5994254", "0.52481997", "0.5236829", "0.5042838", "0.501464", "0.499029", "0.4944708", "0.49395654", "0.48868716", "0.48667347", "0.48374262", "0.4819509", "0.4778107", "0.47724113", "0.47631082", "0.47348255", "0.47270638", "0.47258195", "0.47237712", "0.47216544", "0.471...
0.6819539
0
Make X from features in a model description.
def make_X_from_features(conf): X = None for mat_info in conf['features']: # dict format if isinstance(mat_info, dict): mat_fn = mat_info['file'] mat_name = mat_info['name'] X = hstack_mat(X, mat_fn, mat_name, conf=mat_info) # string format eli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xx(x):\r\n return Feature(x, \"XX\")", "def FeatureExtractor(X):\n crfutils.apply_templates(X, templates)\n \n Featurizer(X)\n if X:\n X[0]['F'].append('__BOS__') # BOS feature\n X[-1]['F'].append('__EOS__') # EOS feature", "def _make_features(self, x):\n\t\tx = x.unsqueez...
[ "0.64031756", "0.6226813", "0.6178122", "0.61536413", "0.5931776", "0.59246016", "0.59088266", "0.5907819", "0.5895605", "0.5880753", "0.5868644", "0.5843248", "0.58000445", "0.5793275", "0.57900906", "0.5790066", "0.57775575", "0.57624465", "0.57101125", "0.5707101", "0.5706...
0.6791879
0
Initialize the video sender object with a socket address and a source
def __init__(self, source, ip='localhost', port=12345): self.ip = ip self.port = port self.frame = 1 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.frame_buffer = PriorityQueue() self.capture_thread = Thread(target=self.capture_video) self.send...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.PORT = 2222\n # connect on construction,\n # use for duration of a game,\n # close connection on destruction later\n self.sock.connect((\"192.168.43.180\", self.PORT))", "def __ini...
[ "0.65700054", "0.6555027", "0.6445784", "0.64453626", "0.63967216", "0.62988293", "0.6265022", "0.624829", "0.622044", "0.621927", "0.61813885", "0.61753327", "0.61642927", "0.615512", "0.61324394", "0.61324394", "0.61151", "0.6112155", "0.60887194", "0.60606354", "0.6052786"...
0.7445592
0
Stop the capture thread and stop sending video
def stop(self): self.capturing = False self.source.kill() self.capture_thread.join() print "Capture joined" self.sending_thread.join() self.sock.close() print "Sending joined"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _device_stop_capture(self):\n\n # TODO: we may want to provide an option to flush the SDRam buffer here before capture stops?\n self._stop_capture_to_ram()\n self._stop_streaming_ram_to_host()", "def capture_video(self):\n while self.capturing:\n nparray = self.source.g...
[ "0.7657235", "0.74697804", "0.7456464", "0.7437331", "0.7424658", "0.73689306", "0.729612", "0.7276712", "0.72750276", "0.71454704", "0.70706284", "0.70697325", "0.70554036", "0.70124567", "0.7011697", "0.6973442", "0.6963443", "0.695482", "0.69460785", "0.6934222", "0.693138...
0.80185586
0
Send a single frame over the TCP connection
def send_frame(self): frame = self.frame_buffer.get() result, jpeg = cv2.imencode(".jpg", frame.nparray)#, self.encode_param) data = numpy.array(jpeg) string_data = data.tostring() self.sock.send(str(len(string_data)).ljust(16)) self.sock.send(string_data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _send(self, frame):\n \n self.device.write(frame)", "def send(self):\n self.spi.send(self.startframe + self.buffer)", "def send_frame(self, frame: np.ndarray) -> None:\n self.sink.putFrame(frame)", "def _send_frame(self, dest, data):\n self._log.debug(\"write {} to {}\"...
[ "0.7440695", "0.72168064", "0.71327406", "0.6800066", "0.6653065", "0.65493464", "0.64847547", "0.647867", "0.6448575", "0.6437831", "0.6436651", "0.63713276", "0.6361239", "0.62642664", "0.62619805", "0.62471753", "0.62396896", "0.62338746", "0.62152886", "0.620691", "0.6196...
0.7548461
0
Performs a product ID search using the ASF SearchAPI
def product_search( product_list: Iterable[str], host: str = INTERNAL.SEARCH_API_HOST, cmr_token: str = None, cmr_provider: str = None ) -> ASFSearchResults: kwargs = locals() data = dict((k,v) for k,v in kwargs.items() if v is not None and v != '') return search(**data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_product_search(self):\n\n flag = \"user\"\n api = \"product.product.update\"\n current_page = 1\n search_info = json.dumps({\n 'id': 6,\n 'name': '一点都不可爱的蓝牙',\n 'alias': \"捣乱哟\"\n })\n print('start------------------------>update')\...
[ "0.68516034", "0.66907626", "0.6675715", "0.66495204", "0.662088", "0.64129543", "0.6374241", "0.6075743", "0.60233986", "0.60182554", "0.60016066", "0.5964345", "0.5944576", "0.5936196", "0.5897327", "0.5885905", "0.58347887", "0.58322", "0.5825085", "0.5803015", "0.57881725...
0.67406386
1
Return a Profile object, as the result of merging a potentially existing Profile file and the args commandline arguments
def from_cli_args(self, profiles, settings, options, conf, cwd): if conf and any(CORE_CONF_PATTERN.match(c) for c in conf): raise ConanException("[conf] 'core.*' configurations are not allowed in profiles.") result = Profile() for p in profiles: tmp = self.load_profile(p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_profile_args(profile_file, parsed_args):\n profile = yaml.safe_load(open(profile_file).read())\n\n # don't overwrite CLI arguments\n for k, v in profile.items():\n if k not in parsed_args:\n parsed_args[k] = int(v) if isinstance(v, str) and v.isdigit() else v\n\n # whe...
[ "0.654649", "0.64650846", "0.6102357", "0.5914738", "0.57453126", "0.5679104", "0.5525721", "0.5517511", "0.54476", "0.53765345", "0.5370309", "0.5303598", "0.52974707", "0.52893806", "0.52580214", "0.52532095", "0.5235531", "0.52199", "0.52014035", "0.5190361", "0.51855165",...
0.6736779
0
Parse and return a Profile object from a text config like representation. cwd is needed to be able to load the includes
def _recurse_load_profile(self, text, profile_path): try: inherited_profile = Profile() cwd = os.path.dirname(os.path.abspath(profile_path)) if profile_path else None profile_parser = _ProfileParser(text) # Iterate the includes and call recursive to get the profil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_config(self, config=None):\r\n # TODO: Load user configuration from the file\r\n # self._current_user_name = get_from_conf(\r\n # config, \"user_name\", self._current_user_name\r\n # )\r\n pass", "def get(self):\n config = self.user_file.parseString(self.c...
[ "0.61702585", "0.60736066", "0.6052238", "0.59705997", "0.59114933", "0.59040225", "0.58818215", "0.5876489", "0.5869841", "0.5850259", "0.57397336", "0.56753075", "0.56726015", "0.5663142", "0.56124836", "0.55889195", "0.5549775", "0.5513324", "0.5512882", "0.5508824", "0.54...
0.6312514
0
Return object with primitive functions mapped to its slots.
def get_primitives(): primitives = Object() # add_primitive_fn(primitives, "primitiveInt", lambda x: PrimitiveIntObject(x), ["literal"]) # add_primitive_fn(primitives, "primitiveStr", lambda x: PrimitiveStrObject(x), ["literal"]) primitives.meta_add_slot("nil", PrimitiveNilObject()) primitives.me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primitives(self):\n for p in self._primitives:\n boundp = p.bind( self.matrix, self.materialnodebysymbol )\n yield boundp", "def __init__(self):\n self.map = {} #key: val, val, idx\n self.slot = []", "def primitive(self):\n K = self.domain\n elements...
[ "0.5674892", "0.5524813", "0.5464314", "0.5418169", "0.539179", "0.539179", "0.5375461", "0.53168595", "0.5225043", "0.52237844", "0.5213066", "0.51942736", "0.5123724", "0.5118563", "0.51124704", "0.50634706", "0.50349385", "0.5002842", "0.49887308", "0.49826604", "0.4970238...
0.635673
0
Smooths data for growth factor
def smooth(inputdata, w, imax): data = 1.0*inputdata data = data.replace(np.nan, 1) data = data.replace(np.inf, 1) smoothed = 1.0*data normalization = 1 for i in range(-imax, imax+1): if i==0: continue smoothed += (w**abs(i))*data.shift(i, axis=0) normali...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _smooth(self):\n self.te = self._spline(self.rho_in, self.te_in, self.rho)\n self.ne = self._spline(self.rho_in, self.ne_in, self.rho)\n self.ti = self._spline(self.rho_in, self.ti_in, self.rho)\n self.vt = self._spline(self.rho_in, self.vt_in, self.rho)\n for i in range(self...
[ "0.5950241", "0.5883062", "0.58223027", "0.5803491", "0.5770945", "0.5753398", "0.5690127", "0.5668608", "0.56679505", "0.56380224", "0.5582488", "0.5554847", "0.5545554", "0.5525283", "0.548151", "0.5446027", "0.5426985", "0.53749406", "0.5309708", "0.53047043", "0.5303405",...
0.6099886
0
return ip addr version
def ip_version(addr: object): # pyre-fixme[6]: For 1st param expected `Union[bytes, int, IPv4Address, # IPv6Address, str]` but got `object`. return ipaddress.ip_address(addr).version
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ip_version(network):\r\n if netaddr.IPNetwork(network).version == 6:\r\n return \"IPv6\"\r\n elif netaddr.IPNetwork(network).version == 4:\r\n return \"IPv4\"", "def get_ip_version(network):\n if netaddr.IPNetwork(network).version == 6:\n return \"IPv6\"\n elif netaddr.IP...
[ "0.7549233", "0.74758", "0.70347553", "0.6886913", "0.68564236", "0.6837816", "0.67826015", "0.6716019", "0.669485", "0.6612927", "0.65697706", "0.6533525", "0.6515953", "0.64914024", "0.6486355", "0.6452278", "0.64519984", "0.6439111", "0.6426393", "0.6400904", "0.6400277", ...
0.7628922
0
Check whether two given addresses belong to the same subnet
def is_same_subnet(addr1, addr2, subnet) -> bool: if ipaddress.ip_network((addr1, subnet), strict=False) == ipaddress.ip_network( (addr2, subnet), strict=False, ): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_subnet_of(a, b) -> bool:\n\n if a.network_address != b.network_address:\n return False\n\n return a.prefixlen >= b.prefixlen", "def isNetConflict(ip_addr1, mask1, ip_addr2, mask2):\n subnet1 = calcSubnet(ip_addr1, mask1)\n if not subnet1:\n return False\n\n subnet2 = calcSubne...
[ "0.785994", "0.7536182", "0.69985723", "0.6919763", "0.68106437", "0.6745513", "0.6576054", "0.6550743", "0.6532463", "0.6469993", "0.64509344", "0.62942696", "0.62459624", "0.6176482", "0.6171225", "0.61619943", "0.61407", "0.6126018", "0.6110254", "0.60865057", "0.6035526",...
0.8587581
0
Check whether given addr is link local or not
def is_link_local(addr: object): # pyre-fixme[6]: For 1st param expected `Union[bytes, int, IPv4Address, # IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network, str]` but # got `object`. return ipaddress.ip_network(addr).is_link_local
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pg_is_local(self) -> bool:\n query = queries.get(\"get_pga_inet_addresses\")\n ret = pg.fetchone(self.pg_conn, query)\n if ret[\"inet_server_addr\"] == ret[\"inet_client_addr\"]:\n return True\n return False", "def checklan(ipaddr, network):\n return True", "def ip...
[ "0.6798575", "0.6638275", "0.6382398", "0.6332938", "0.6316086", "0.62714803", "0.61401224", "0.6127522", "0.6111855", "0.6088483", "0.6064209", "0.6057602", "0.60432446", "0.6034438", "0.601089", "0.5975604", "0.59582657", "0.5930283", "0.5925948", "0.5917037", "0.59017444",...
0.8344466
0
Check if networkb is subnet of networka
def is_subnet_of(a, b) -> bool: if a.network_address != b.network_address: return False return a.prefixlen >= b.prefixlen
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_same_subnet(addr1, addr2, subnet) -> bool:\n\n if ipaddress.ip_network((addr1, subnet), strict=False) == ipaddress.ip_network(\n (addr2, subnet),\n strict=False,\n ):\n return True\n\n return False", "def ipcalc(self, ipaddr, subnet):\n if IPNetwork(ipaddr) in IPNetwork...
[ "0.7314672", "0.67398316", "0.66275626", "0.6493872", "0.64450306", "0.6399496", "0.6264905", "0.6262054", "0.6249586", "0.62314355", "0.6194749", "0.61642396", "0.6151925", "0.614704", "0.6145494", "0.6113166", "0.60746807", "0.60489863", "0.6030356", "0.6029712", "0.5949608...
0.7961914
0
Utility function to check if prefix contain any of the prefixes/ips
def contain_any_prefix(prefix, ip_networks) -> bool: if ip_networks is None: return True prefix = ipaddress.ip_network(prefix) return any(is_subnet_of(prefix, net) for net in ip_networks)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stillLookingForPrefix(self, prefix):\n return prefix in self._prefixToIdentifiers", "def has_prefix_some(s, prefix_set):\n\tfor prefix in prefix_set:\n\t\tif s.find(prefix, 0) != -1:\n\t\t\treturn True\n\treturn False", "def has_prefix(x: list):\n for val in x:\n if len(list(filter(val.startsw...
[ "0.78274727", "0.77501935", "0.72341454", "0.7208901", "0.6980612", "0.6968101", "0.6951476", "0.6915833", "0.6905945", "0.68688935", "0.6824134", "0.6792586", "0.67827976", "0.67482597", "0.67436284", "0.67426485", "0.67411697", "0.6731886", "0.6718521", "0.67160827", "0.670...
0.8043875
0
Checks if a string is a valid IPv4 or IPv6 address, If Strict is set to True, will return False if there's mask/host bits
def is_ip_addr(addr: str, strict: bool = True) -> bool: try: ipaddress.ip_network(addr, strict=strict) return True except ValueError: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_ipv6_address(ip_str):\r\n # We need to have at least one ':'.\r\n if ':' not in ip_str:\r\n return False\r\n\r\n # We can only have one '::' shortener.\r\n if ip_str.count('::') > 1:\r\n return False\r\n\r\n # '::' should be encompassed by start, digits or end.\r\n if '...
[ "0.68733555", "0.68192065", "0.67628306", "0.6565539", "0.6563497", "0.6529403", "0.6526627", "0.64721215", "0.643483", "0.6419949", "0.639468", "0.63764536", "0.6351981", "0.6301522", "0.6300975", "0.6291368", "0.6261778", "0.6239463", "0.6231528", "0.62232095", "0.6184009",...
0.7063161
0