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 |
|---|---|---|---|---|---|---|
Given TEXTFSM CDP neighbor, checks type of device and runs through corresponding parser function. | def parse(n):
capabilities = n['capabilities']
if n['platform'].__contains__('IP Phone') or capabilities.__contains__('Phone'):
phone_parse(n)
elif capabilities.__contains__('Router') and capabilities.__contains__('Source-Route-Bridge') or \
capabi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_device_from_datagram(\n device_callback: Callable[[SwitcherBase], Any], datagram: bytes\n) -> None:\n parser = DatagramParser(datagram)\n if not parser.is_switcher_originator():\n logger.debug(\"received datagram from an unknown source\")\n else:\n device_type: DeviceType = par... | [
"0.5448138",
"0.5367822",
"0.51965165",
"0.51411146",
"0.5129462",
"0.4950195",
"0.4934969",
"0.49349013",
"0.47787055",
"0.47489983",
"0.4734217",
"0.4636806",
"0.46320385",
"0.46221396",
"0.46014342",
"0.4576387",
"0.4569176",
"0.45680135",
"0.45521274",
"0.45414808",
"0.45... | 0.55118585 | 0 |
Parses CUCM export of phones with fields 'Description', 'Device Name', and 'Directory Number 1' | def cucm_export_parse(file):
phones = {}
while True:
try:
with open(file) as phonelist_csv:
for line in phonelist_csv:
if not line.__contains__('Description,Device Name,Directory Number 1'):
info = line.split(',')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_phone(parsed_data):\n result = []\n known_values = []\n\n contacts = {'registrant_contact': [], 'administrative_contact': [], 'technical_contact': [],\n 'domain_registrar' :[]}\n if 'registrant_contact' in parsed_data:\n contacts['registrant_conta... | [
"0.5697088",
"0.53372353",
"0.5237132",
"0.52135444",
"0.5204209",
"0.5193696",
"0.5180402",
"0.51639044",
"0.5127449",
"0.5107768",
"0.5095245",
"0.5094951",
"0.50657725",
"0.5043901",
"0.50421095",
"0.49992374",
"0.4995149",
"0.49897113",
"0.49766734",
"0.49737394",
"0.4962... | 0.7282722 | 0 |
Return a next index for read client. This function implements a default behavior for get a next read client for masterslave setup. Overwrite this function if you want a specific behavior. | def get_next_client_index(self, write=True):
if write or len(self._server) == 1:
return 0
return random.randint(1, len(self._server) - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __next_index():\n return redis_store.incr(String.__name__.lower() + '-index')",
"def get_client(self, write=True):\r\n index = self.get_next_client_index(write=write)\r\n\r\n if self._clients[index] is None:\r\n self._clients[index] = self.connect(index)\r\n\r\n return ... | [
"0.6373826",
"0.60432035",
"0.57846725",
"0.57057947",
"0.56468946",
"0.5631014",
"0.5614183",
"0.56074053",
"0.56074053",
"0.5567467",
"0.5533405",
"0.5528173",
"0.5506794",
"0.55002165",
"0.5483921",
"0.54825854",
"0.5479725",
"0.54147923",
"0.5399875",
"0.53776383",
"0.534... | 0.72630644 | 0 |
Method that parse a connection string. | def parse_connection_string(self, constring):
try:
host, port, db = constring.split(":")
port = port if host == "unix" else int(port)
db = int(db)
return host, port, db
except (ValueError, TypeError):
raise ImproperlyConfigured("Incorrec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_connection_string(self, connection_string):\n self.host = '127.0.0.1'\n self.port = 3306\n self.db = None\n self.user = None\n self.pwd = None\n for part in connection_string.split(';'):\n part = part.strip()\n if part != '':\n ... | [
"0.8401574",
"0.6616161",
"0.6538914",
"0.6453745",
"0.6397597",
"0.6344282",
"0.6208351",
"0.6030974",
"0.59864354",
"0.57071424",
"0.56045955",
"0.5569482",
"0.5531569",
"0.5472697",
"0.5466513",
"0.5460773",
"0.54534364",
"0.5451783",
"0.5448955",
"0.5406482",
"0.5380559",... | 0.7921391 | 1 |
Given a connection index, returns a new raw redis client/connection instance. Index is used for master/slave setups and indicates that connection string should be used. In normal setups, index is 0. | def connect(self, index=0):
host, port, db = self.parse_connection_string(self._server[index])
return self.connection_factory.connect(host, port, db) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self, index=0, write=True):\r\n master_name, sentinel_hosts, db = self.parse_connection_string(self._connection_string)\r\n\r\n sentinel_timeout = self._options.get('SENTINEL_TIMEOUT', 1)\r\n sentinel = Sentinel(sentinel_hosts, socket_timeout=sentinel_timeout)\r\n\r\n if wri... | [
"0.5969906",
"0.5762544",
"0.5700567",
"0.5463157",
"0.5462497",
"0.5395308",
"0.5355108",
"0.53345335",
"0.5311246",
"0.53111696",
"0.53071743",
"0.5279201",
"0.52436805",
"0.5213795",
"0.52018327",
"0.5171319",
"0.5145463",
"0.5115737",
"0.51155186",
"0.51154757",
"0.510455... | 0.64365077 | 0 |
Adds delta to the cache version for the supplied key. Returns the new version. | def incr_version(self, key, delta=1, version=None, client=None):
if client is None:
client = self.get_client(write=True)
if version is None:
version = self._backend.version
old_key = self.make_key(key, version)
value = self.get(old_key, version=version... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incr(self, key, delta=1):\n try:\n key = self.prepare_key(key)\n return super(CacheClass, self).incr(key, delta)\n except Exception as err:\n return self.warn_or_error(err, delta)",
"def incr(self, key, delta=1, version=None, client=None):\r\n return self... | [
"0.6767568",
"0.6661848",
"0.6260883",
"0.6248231",
"0.6220057",
"0.5948065",
"0.5826451",
"0.56962454",
"0.55747366",
"0.54451704",
"0.53051615",
"0.52766025",
"0.5254437",
"0.52447313",
"0.5226823",
"0.5207911",
"0.52070314",
"0.52013683",
"0.5162349",
"0.5153979",
"0.51407... | 0.73972917 | 0 |
Unpickles the given value. | def unpickle(value):
try:
value = int(value)
except (ValueError, TypeError):
value = smart_bytes(value)
value = pickle.loads(value)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unserialize(val):\n return pickle.loads(val)",
"def _decode_value(self, value):\n return pickle.loads(value.value) if value else value",
"def from_value(value):\n return pickle.dumps(value)",
"def base64unpickle(self, value):\n if value:\n return pickle.loads(self.base64decod... | [
"0.7045012",
"0.7031028",
"0.6841384",
"0.65678066",
"0.6526041",
"0.64857894",
"0.6477095",
"0.61220485",
"0.6111226",
"0.6080982",
"0.6064356",
"0.60208184",
"0.6005177",
"0.5897015",
"0.58008486",
"0.5781338",
"0.57552445",
"0.57470506",
"0.5712168",
"0.56796086",
"0.56617... | 0.7501486 | 0 |
Pickle the given value. | def pickle(self, value):
if isinstance(value, bool) or not isinstance(value, integer_types):
return pickle.dumps(value, self._pickle_version)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_value(value):\n return pickle.dumps(value)",
"def dump_object(self, value):\n return pickle.dumps(value)",
"def _encode_value(self, value):\n return pickle.dumps(value)",
"def unserialize(val):\n return pickle.loads(val)",
"def value(self) -> Any:\n return pickle.loads(self.pi... | [
"0.77703",
"0.7441614",
"0.6958083",
"0.6798523",
"0.6667502",
"0.6574332",
"0.6568599",
"0.6552237",
"0.65478945",
"0.6544326",
"0.65061575",
"0.6471692",
"0.64400285",
"0.6392385",
"0.6310394",
"0.6301115",
"0.6247126",
"0.6234851",
"0.619252",
"0.61067325",
"0.6043083",
... | 0.75480545 | 1 |
Given a connection parameters and return a new or cached connection pool for them. Reimplement this method if you want distinct connection pool instance caching behavior. | def get_or_create_connection_pool(self, params):
key = frozenset((k, repr(v)) for (k, v) in params.items())
if key not in self._pools:
self._pools[key] = self.get_connection_pool(params)
return self._pools[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_connection_pool(self, params):\r\n cp_params = dict(params)\r\n cp_params.update(self.pool_cls_kwargs)\r\n return self.pool_cls(**cp_params)",
"def get_connection(self, params):\r\n return Redis(connection_pool=self.get_or_create_connection_pool(params))",
"def build_connect... | [
"0.7633331",
"0.7093984",
"0.704607",
"0.70299256",
"0.7016528",
"0.6718907",
"0.66587025",
"0.66581637",
"0.66004694",
"0.6494415",
"0.6447045",
"0.641799",
"0.63243353",
"0.6310433",
"0.63036764",
"0.6295449",
"0.6271186",
"0.6250118",
"0.61557645",
"0.61037254",
"0.6043522... | 0.7563619 | 1 |
Given a connection parameters, return a new connection pool for them. Overwrite this method if you want a custom behavior on creating connection pool. | def get_connection_pool(self, params):
cp_params = dict(params)
cp_params.update(self.pool_cls_kwargs)
return self.pool_cls(**cp_params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_or_create_connection_pool(self, params):\r\n key = frozenset((k, repr(v)) for (k, v) in params.items())\r\n if key not in self._pools:\r\n self._pools[key] = self.get_connection_pool(params)\r\n return self._pools[key]",
"def build_connection_pool(conn_details: dict):\n\n ... | [
"0.7737848",
"0.7455023",
"0.7187452",
"0.70865107",
"0.6992813",
"0.69039977",
"0.684276",
"0.672731",
"0.66503847",
"0.6621734",
"0.659866",
"0.6564659",
"0.6443048",
"0.6405981",
"0.63895524",
"0.6246814",
"0.62264544",
"0.615156",
"0.6043402",
"0.6006722",
"0.6000867",
... | 0.79732764 | 0 |
Tests calculating confusion matrix per subpopulation. Tests | def test_confusion_matrix_per_subgroup():
mx1 = np.array([[2, 1, 0], [0, 0, 0], [0, 0, 0]])
mx2 = np.array([[2, 0, 0], [0, 0, 0], [0, 2, 1]])
mx3 = np.array([[2, 0, 1], [0, 2, 0], [1, 0, 1]])
with pytest.warns(UserWarning) as w:
pcmxs, bin_names = fumt.confusion_matrix_per_subgroup(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_classifications(self):\n test_labels = open('./digitdata/testlabels', 'r')\n self.init_confusion_matrix()\n i = 0\n class_stats = {0:[0,0], 1:[0,0], 2:[0,0], 3:[0,0], 4:[0,0], 5:[0,0], 6:[0,0], 7:[0,0], 8:[0,0], 9:[0,0]}\n total_correct = 0\n num_labels = 1000... | [
"0.6618988",
"0.66012615",
"0.65771365",
"0.64746296",
"0.6443359",
"0.6311446",
"0.62488693",
"0.6220614",
"0.6143405",
"0.6113498",
"0.60880667",
"0.60832113",
"0.6033341",
"0.6021256",
"0.6018865",
"0.59884655",
"0.59654135",
"0.59608114",
"0.59072",
"0.5879316",
"0.582956... | 0.68114936 | 0 |
Tests calculating confusion matrix per indexbased subpopulation. Tests | def test_confusion_matrix_per_subgroup_indexed():
incorrect_shape_error_gt = ('The ground_truth parameter should be a '
'1-dimensional numpy array.')
incorrect_shape_error_p = ('The predictions parameter should be a '
'1-dimensional numpy array.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_confusion_matrix_per_subgroup():\n\n mx1 = np.array([[2, 1, 0], [0, 0, 0], [0, 0, 0]])\n mx2 = np.array([[2, 0, 0], [0, 0, 0], [0, 2, 1]])\n mx3 = np.array([[2, 0, 1], [0, 2, 0], [1, 0, 1]])\n\n with pytest.warns(UserWarning) as w:\n pcmxs, bin_names = fumt.confusion_matrix_per_subgroup... | [
"0.66565275",
"0.62798464",
"0.62386554",
"0.6203715",
"0.61975443",
"0.6048215",
"0.5992596",
"0.59676194",
"0.58624643",
"0.5859458",
"0.58580637",
"0.58289576",
"0.58109146",
"0.5807874",
"0.5788835",
"0.5787484",
"0.57719433",
"0.5745471",
"0.5728884",
"0.572269",
"0.5708... | 0.6355921 | 1 |
Returns the number of prizes that will be awarded for this prize. | def num_awarded(self, floor=None):
if self.award_to in ("individual_overall", "floor_overall", "dorm"):
# For overall prizes, it is only possible to award one.
return 1
elif self.award_to in ("floor_dorm", "individual_dorm"):
# For dorm prizes, this is just the number of dorms.
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_pickets(self) -> int:\n return len(self.pickets)",
"def get_num_petals(self):\n return self._num_petals",
"def psizes(self):\n return self._cache.psizes",
"def num_votes(self):\n return sum(self.votes_per_count)",
"def size(self) -> int:\n\n return self.sizes.sum(... | [
"0.65297043",
"0.6438432",
"0.638483",
"0.625789",
"0.61884695",
"0.6187963",
"0.6182225",
"0.6173951",
"0.6150105",
"0.612123",
"0.61027765",
"0.6080633",
"0.6056884",
"0.60247165",
"0.601722",
"0.60013944",
"0.5973453",
"0.5966288",
"0.5964273",
"0.5963277",
"0.59582824",
... | 0.6676239 | 0 |
Adds a ticket from the user if they have one. Throws an exception if they cannot add a ticket. | def add_ticket(self, user):
profile = user.get_profile()
if profile.available_tickets() <= 0:
raise Exception("This user does not have any tickets to allocate.")
ticket = RaffleTicket(raffle_prize=self, user=user)
ticket.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def ticket_add(self, ctx, user: discord.Member):\n guild_settings = await self.config.guild(ctx.guild).all()\n is_admin = await is_admin_or_superior(self.bot, ctx.author) or any(\n [ur.id in guild_settings[\"supportroles\"] for ur in ctx.author.roles]\n )\n must_be_admi... | [
"0.75067663",
"0.65820646",
"0.6444056",
"0.64260346",
"0.6213124",
"0.61979747",
"0.6157786",
"0.60477424",
"0.59763026",
"0.59427506",
"0.58696246",
"0.5796449",
"0.5795518",
"0.579028",
"0.576608",
"0.5748269",
"0.56843877",
"0.56670624",
"0.5599975",
"0.5599003",
"0.55944... | 0.7707899 | 0 |
Removes an allocated ticket. | def remove_ticket(self, user):
# Get the first ticket that matches the query.
ticket = RaffleTicket.objects.filter(raffle_prize=self, user=user)[0]
ticket.delete() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ticket_deleted(self, ticket):\n if 'ticket' not in self.sources:\n return\n gnp = GrowlNotificationPacket(notification='ticket',\n title='Ticket #%d deleted' % ticket.id,\n description=self._ticket_repr(ticket))\... | [
"0.6529886",
"0.62774307",
"0.6127702",
"0.6008233",
"0.59739345",
"0.5789608",
"0.57860637",
"0.57634157",
"0.57043296",
"0.54994345",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
"0.53857934",
... | 0.64663655 | 1 |
Returns the number of tickets allocated to this prize. Takes an optional argument to return the number of tickets allocated by the user. | def allocated_tickets(self, user=None):
query = self.raffleticket_set.filter(raffle_prize=self)
if user:
query = query.filter(user=user)
return query.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_assigned(self):\n return FlicketTicket.query.filter_by(assigned=self.user).count()",
"def num_pickets(self) -> int:\n return len(self.pickets)",
"def num_attendees(self):\r\n n = sum([c.qty for c in self.contribution_set.all()])\r\n return n",
"def num_allocated_resources(... | [
"0.6878064",
"0.62725556",
"0.60077244",
"0.5967526",
"0.59303814",
"0.587535",
"0.5703093",
"0.5699997",
"0.5674289",
"0.56504005",
"0.56465405",
"0.5644256",
"0.5603991",
"0.5569141",
"0.5529344",
"0.55266505",
"0.55215555",
"0.5503645",
"0.54946893",
"0.54946893",
"0.54825... | 0.7432309 | 0 |
Compute the transport plan P in regularization path for any given value of lambda | def compute_transport_plan(lam, lambda_list, Pi_list):
if lam <= lambda_list[0]:
Pi_inter = np.zeros(np.shape(Pi_list[-1]))
elif lam >= lambda_list[-1]:
Pi_inter = Pi_list[-1].toarray()
else:
idx = np.where(lambda_list < lam)[0][-1]
lam_k = lambda_list[idx]
lam_k1 = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_PRP(initial):\n return plan_route((initial[0],initial[1]), initial[2],\n # Goals:\n [(2,3),(3,2)],\n # Allowed locations:\n [(0,0),(0,1),(0,2),(0,3),\n (1,0),(1,1),(1,2),(1,3),\n ... | [
"0.5900887",
"0.58707184",
"0.57448065",
"0.56907046",
"0.5612557",
"0.56111515",
"0.5553134",
"0.5529714",
"0.55141824",
"0.54726917",
"0.5471628",
"0.54607534",
"0.54519314",
"0.5421288",
"0.5413783",
"0.5371945",
"0.5369936",
"0.5324903",
"0.5300132",
"0.52990323",
"0.5296... | 0.70644534 | 0 |
Called when the mapper has finished, to allow for any final work to be done. | def finish(self):
logging.info(str(self) + ' Mapper finished.')
if self.next_mapper is not None:
logging.info(str(self) + ' Next: ' + str(self.next_mapper))
self.next_mapper.run()
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished(self):\n pass",
"def _finished(self) -> None:",
"def finish(self):\n pass",
"def finish(self):\n pass",
"def finished(self):\n raise NotImplementedError()",
"def finished(self):\r\n raise NotImplementedError",
"def finished(self):",
"def finish(self):\r... | [
"0.6983338",
"0.67524016",
"0.6732718",
"0.6732718",
"0.6725664",
"0.6718488",
"0.6698824",
"0.6674772",
"0.6650086",
"0.65816665",
"0.65816665",
"0.6573483",
"0.6461058",
"0.6453406",
"0.6439004",
"0.6439004",
"0.6388175",
"0.63703626",
"0.6352022",
"0.63432056",
"0.6340175"... | 0.8608334 | 0 |
Writes updates and deletes entities in a batch. | def _batch_write(self):
if self.to_put:
db.put(self.to_put)
self.to_put = []
if self.to_delete:
db.delete(self.to_delete)
self.to_delete = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_batch(self, batch):\n for item in batch:\n self.write_buffer.buffer(item)\n key = self.write_buffer.get_key_from_item(item)\n if self.write_buffer.should_write_buffer(key):\n self._write_current_buffer_for_group_key(key)\n self.increment_w... | [
"0.70008594",
"0.68892026",
"0.666511",
"0.65495664",
"0.65008634",
"0.6464048",
"0.635089",
"0.63451797",
"0.6307946",
"0.6263735",
"0.6218856",
"0.6178519",
"0.61136186",
"0.5940264",
"0.59256804",
"0.5848141",
"0.5847394",
"0.5837007",
"0.5814465",
"0.5783356",
"0.5769271"... | 0.76341254 | 0 |
Adds Card entities for the given ids, with the given parent. Adds in batches and requeues itself. | def create_cards(card_ids, box_key):
if len(card_ids) == 0:
return
BATCH_SIZE = 20
batch = card_ids[:BATCH_SIZE]
logging.info("Adding cards for %s (%d remaining). Batch: %s"%(box_key,len(card_ids),batch))
for id_tuple in batch:
key = '-'.join([str(p) for p in id_tuple])
card ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, fetchables, depth=1):\n if fetchables:\n if isinstance(fetchables, collections.Sequence):\n for fetchable in fetchables:\n self.add(fetchable, depth)\n else:\n log.debug(\"Adding to queue: %s (depth=%s)\", fetchables, depth... | [
"0.5433942",
"0.54215556",
"0.5285374",
"0.52513355",
"0.523385",
"0.5209448",
"0.52048165",
"0.5192483",
"0.50542176",
"0.50103396",
"0.49839032",
"0.49836466",
"0.49792188",
"0.49381772",
"0.49187857",
"0.48608288",
"0.48197132",
"0.48139533",
"0.48101467",
"0.4797596",
"0.... | 0.6199333 | 0 |
Make sure the incoming dict is a valid rower data frame, so the out coming data is consistent. Check the validity of the incoming dict fields, make sure all the required fields exists, and the value of each key is in the corresponded data type or format. So the data consumers is guaranteed that the out coming data is i... | def _check_dict_validity(self, incoming_dict: dict):
# check key error
# check value error
for key in incoming_dict.keys():
# check invalid key.
if key not in self.all_valid_keys:
raise IncomingRowerDictInvalidKeyError("Incoming rower data dict has unknow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_required_fields(dataframe):\n\n if dataframe is None:\n raise ValueError(\"It was not provided a valid Dataframe.\")",
"def _validate_row(self, row):\n\n # assume value.\n is_valid = True\n\n # test if each field in @row has the correct data type.\n tests = []\n... | [
"0.6217236",
"0.61962247",
"0.61173457",
"0.611672",
"0.6115982",
"0.60280246",
"0.6014561",
"0.58647096",
"0.58622396",
"0.5823101",
"0.5781498",
"0.5753542",
"0.5747231",
"0.57242537",
"0.57188284",
"0.57178247",
"0.57135326",
"0.56972915",
"0.56814194",
"0.56690544",
"0.56... | 0.7237003 | 0 |
Parses an HTTP Error from the Google API and returns the error message. | def _get_error_message_from_httperror(err):
json_error = json.loads(str(err.content.decode()))
return json_error.get('error', {}).get('message', '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getError(self):\n \n return self.resp[\"error\"]",
"def read_tapis_http_error(http_error_object):\n h = http_error_object\n # extract HTTP response code\n code = -1\n try:\n code = h.response.status_code\n assert isinstance(code, int)\n except Exception:\n # ... | [
"0.6838421",
"0.6793689",
"0.6636548",
"0.6565121",
"0.64546394",
"0.63964623",
"0.63945633",
"0.6299346",
"0.62722117",
"0.6216416",
"0.6203617",
"0.61820084",
"0.6117928",
"0.61079687",
"0.61059207",
"0.6047966",
"0.60429734",
"0.60072476",
"0.60060865",
"0.5990251",
"0.597... | 0.73818463 | 0 |
run the server and wait that it returns | def run(self):
self.rpc_server.serve_forever(0.5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self._server = self._get_server()\n self._server.serve_forever()",
"def run(self):\n self.__server.serve_forever()",
"def run():\n server = current_server()\n server._auto_stop = True\n return start()",
"def run(self):\n self.__rpc_server.run()",
"def m... | [
"0.7389395",
"0.7237915",
"0.72022533",
"0.7041745",
"0.7013421",
"0.69024694",
"0.6892635",
"0.6891861",
"0.68075854",
"0.68056464",
"0.6782797",
"0.6745265",
"0.6696141",
"0.66879743",
"0.66873586",
"0.66545063",
"0.6602608",
"0.6602608",
"0.65958893",
"0.65953624",
"0.6585... | 0.7507121 | 0 |
test if there is something to read on the console | def _check_console_input(self):
if os.name == "nt":
if 0 == ctypes.windll.Kernel32.WaitForSingleObject(self.console_handle, 500):
return True
elif os.name == "posix":
(inputready, abcd, efgh) = select.select([sys.stdin], [], [], 0.5)
if len(i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_interactive():\n\n return sys.stdin.isatty()",
"def hastty():\n try:\n return sys.stdin and sys.stdin.isatty()\n except Exception: # pragma: no cover\n return False # i.e. no isatty method?",
"def chk_stdin(self):\t# check keyboard input\n\t\tdr, dw, de = select([sys.stdin], [],... | [
"0.67703044",
"0.6668972",
"0.6553596",
"0.64391434",
"0.64319617",
"0.63720024",
"0.6358427",
"0.63391805",
"0.61975825",
"0.6152854",
"0.6141509",
"0.6141509",
"0.60947686",
"0.6083325",
"0.6058859",
"0.60456157",
"0.60350746",
"0.5998256",
"0.59890354",
"0.5987575",
"0.597... | 0.7178151 | 0 |
read from the console, transfer to the server and write the answer | def run(self):
while self._go.isSet(): #while app is running
if self._check_console_input(): #if something to read on the console
cmd = sys.stdin.readline() #read it
self.inq.put(cmd) #dispatch it tpo the server
response = self.outq.get(timeout=2.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_command(self, data):\n try:\n self.write(data)\n reply = self.read_line()\n \n if reply == \"{}\":\n pass\n else:\n print \"send_command: received bad reply %s\" % (reply)\n sys.exit(1)\n excep... | [
"0.6864386",
"0.6665979",
"0.6607433",
"0.6399282",
"0.6332425",
"0.63022834",
"0.6229169",
"0.61992306",
"0.6194718",
"0.6157062",
"0.6156837",
"0.6120637",
"0.61120206",
"0.6109998",
"0.6108802",
"0.60982066",
"0.608361",
"0.60783035",
"0.60692763",
"0.60670555",
"0.6063523... | 0.70131034 | 0 |
convert a tuple to a string | def _tuple_to_str(self, the_tuple):
ret = ""
for item in the_tuple:
ret += (" " + str(item))
return ret[1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tupstr(tuple_):\n return ', '.join(list(map(str, tuple_)))",
"def tupleStrFormat(tupl):\n string = \"this is a tuple (\"\n for element in tupl:\n string += str(element) + \", \"\n string += \")\"\n return string",
"def str_tuple(item):\n return \"{}:{}\".format(item[0], item[1])",... | [
"0.8968813",
"0.8027702",
"0.7950681",
"0.78714865",
"0.7861424",
"0.7818346",
"0.780113",
"0.7644711",
"0.74937075",
"0.7376981",
"0.7257783",
"0.7226776",
"0.7204182",
"0.7195983",
"0.71484184",
"0.7052116",
"0.6914404",
"0.68726766",
"0.67629915",
"0.6719136",
"0.66418886"... | 0.8546605 | 1 |
execute the add_slave command | def _do_add_slave(self, args):
bus_type = args[1]
slave_id = int(args[2])
if bus_type == 'rtu':
self.server._servers[0].add_slave(slave_id)
elif bus_type == 'tcp':
self.server._servers[1].add_slave(slave_id)
return "{0}".format(slave_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onSlave(self):",
"def add_slave(self, widget):\n self._slaves.add(widget)\n widget[tkc.STATE] = self._get_slaves_state()",
"def connect_subproc():\n return factory.connect_subproc([sys.executable, \"-u\", SERVER_FILE, \"-q\", \"-m\", \"stdio\"], \n SlaveService)",
"def getSlave(na... | [
"0.66664743",
"0.6366341",
"0.62082016",
"0.6190436",
"0.6048615",
"0.6037338",
"0.5986998",
"0.59091246",
"0.59048486",
"0.573768",
"0.56949824",
"0.5680297",
"0.5538369",
"0.5517972",
"0.54603016",
"0.54316896",
"0.5403584",
"0.53891146",
"0.53774834",
"0.5355592",
"0.53412... | 0.72399515 | 0 |
execute the has_slave command | def _do_has_slave(self, args):
bus_type = args[1]
slave_id = int(args[2])
try:
if bus_type == 'rtu':
self.server._servers[0].get_slave(slave_id)
elif bus_type == 'tcp':
self.server._servers[1].get_slave(slave_id)
except Exce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slaveConnected(slaveName):",
"def slave_status():\n run_mysql_command(\"SHOW SLAVE STATUS\\G;\")",
"def onSlave(self):",
"def query_slave(self, slave_name=\"\"):\n\t\t#using the bus template find the location of the slave folders\n\n\t\t#see if the name matches up to any of the files\n\t\t#\"name\".v ... | [
"0.7264953",
"0.68657476",
"0.6751939",
"0.67488265",
"0.65639305",
"0.63759196",
"0.6268738",
"0.5960661",
"0.5858432",
"0.5852638",
"0.5848737",
"0.58346575",
"0.5781598",
"0.5757251",
"0.5695663",
"0.56429327",
"0.5631435",
"0.56145155",
"0.56121534",
"0.5608739",
"0.55915... | 0.7234994 | 1 |
execute the remove_slave command | def _do_remove_slave(self, args):
bus_type = args[1]
slave_id = int(args[2])
if bus_type == 'rtu':
self.server._servers[0].remove_slave(slave_id)
elif bus_type == 'tcp':
self.server._servers[1].remove_slave(slave_id)
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_remove_block(self, args):\r\n bus_type = args[1]\r\n slave_id = int(args[2])\r\n name = args[3]\r\n if bus_type == 'rtu':\r\n slave = self.server._servers[0].get_slave(slave_id)\r\n elif bus_type == 'tcp':\r\n slave = self.server._servers[1].get_slav... | [
"0.645421",
"0.6409547",
"0.6328437",
"0.62247264",
"0.6103352",
"0.6079856",
"0.5915689",
"0.58712333",
"0.58550864",
"0.5795309",
"0.57882065",
"0.5786015",
"0.56886345",
"0.5667349",
"0.56095004",
"0.55818015",
"0.5518671",
"0.551404",
"0.5513143",
"0.5506423",
"0.5499367"... | 0.758631 | 0 |
execute the add_block command | def _do_add_block(self, args):
bus_type = args[1]
slave_id = int(args[2])
name = args[3]
block_type = int(args[4])
starting_address = int(args[5])
length = int(args[6])
if bus_type == 'rtu':
slave = self.server._servers[0].get_slave(slave_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def add_block(\n self,\n position: typing.Tuple[int, int, int],\n block_name: typing.Union[str, typing.Any],\n immediate=True,\n block_update=True,\n block_update_self=True,\n lazy_setup: typing.Callable[[typing.Any], None] = None,\n check_build_range=T... | [
"0.65428215",
"0.637844",
"0.6291531",
"0.62718385",
"0.62567204",
"0.6255184",
"0.6248362",
"0.62457955",
"0.62122875",
"0.6192997",
"0.6187441",
"0.61778",
"0.6176169",
"0.61067283",
"0.6066772",
"0.60516053",
"0.6045066",
"0.6039789",
"0.6039594",
"0.6026823",
"0.60244447"... | 0.71566474 | 0 |
execute the remove_block command | def _do_remove_block(self, args):
bus_type = args[1]
slave_id = int(args[2])
name = args[3]
if bus_type == 'rtu':
slave = self.server._servers[0].get_slave(slave_id)
elif bus_type == 'tcp':
slave = self.server._servers[1].get_slave(slave_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_block(self, block):\n raise NotImplementedError()",
"async def remove_block(\n self,\n position: typing.Union[\n typing.Tuple[int, int, int],\n typing.Any,\n ],\n immediate: bool = True,\n block_update: bool = True,\n block_update_... | [
"0.7275056",
"0.71058",
"0.7038019",
"0.6806753",
"0.6744042",
"0.6390654",
"0.6365233",
"0.62796766",
"0.6235635",
"0.6175417",
"0.6071809",
"0.60490525",
"0.60421735",
"0.59872586",
"0.5936501",
"0.5895922",
"0.5890499",
"0.5844823",
"0.5836963",
"0.5827584",
"0.57998425",
... | 0.75226086 | 0 |
execute the remove_all_blocks command | def _do_remove_all_blocks(self, args):
bus_type = args[1]
slave_id = int(args[2])
if bus_type == 'rtu':
slave = self.server._servers[0].get_slave(slave_id)
elif bus_type == 'tcp':
slave = self.server._servers[1].get_slave(slave_id)
slave.remove_all_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_blocks(draft):\n for symbol in draft.Blocks:\n if symbol.Name in blocks_to_delete:\n print(\"[-] %s, \\tdeleted\" % symbol.Name)\n symbol.delete()\n\n # for ball in draft.ActiveSheet.Balloons:\n if draft.Balloons:\n for ball in draft.Balloons:\n if... | [
"0.64979184",
"0.64848286",
"0.62811196",
"0.6276664",
"0.6214501",
"0.61948407",
"0.6133304",
"0.60413116",
"0.5981843",
"0.5847182",
"0.5838975",
"0.58206236",
"0.58180887",
"0.5778389",
"0.57099503",
"0.570558",
"0.56985164",
"0.5684649",
"0.5678892",
"0.5661721",
"0.56431... | 0.720971 | 0 |
install a function as a hook | def _do_install_hook(self, args):
hook_name = args[1]
fct_name = args[2]
hooks.install_hook(hook_name, self._hooks_fct[fct_name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hook(callback):\n hooks.append(callback)",
"def hook(self, name):\r\n def wrapper(func):\r\n self.hooks.add(name, func)\r\n return func\r\n return wrapper",
"def install_hook(hook_id, proc):\n handle = user32.SetWindowsHookExA(hook_id, proc, None, 0)\n if not hand... | [
"0.71828526",
"0.69452894",
"0.6812174",
"0.6810592",
"0.6807268",
"0.6787101",
"0.6680161",
"0.6601569",
"0.65442866",
"0.6482846",
"0.6470736",
"0.6468058",
"0.6451436",
"0.63961804",
"0.63879573",
"0.6370445",
"0.6350216",
"0.6326162",
"0.6303307",
"0.63018394",
"0.6298826... | 0.80193776 | 0 |
uninstall a function as a hook. If no function is given, uninstall all functions | def _do_uninstall_hook(self, args):
hook_name = args[1]
try:
hooks.uninstall_hook(hook_name)
except KeyError as exception:
LOGGER.error(str(exception)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uninstall_hook(handle):\n if handle:\n user32.UnhookWindowsHookEx(handle)",
"def _uninstall(package_name, remove_all, app_id, cli, app):\n\n package_manager = _get_package_manager()\n err = package.uninstall(\n package_manager, package_name, remove_all, app_id, cli, app)\n if err is... | [
"0.69406205",
"0.65433",
"0.6514345",
"0.6452318",
"0.631227",
"0.618152",
"0.618152",
"0.6086222",
"0.6082233",
"0.60555613",
"0.6052477",
"0.6052156",
"0.60201836",
"0.6006638",
"0.60027117",
"0.5980151",
"0.5978945",
"0.59783494",
"0.5975453",
"0.5919139",
"0.58928365",
... | 0.73846674 | 0 |
change the verbosity of the server | def _do_set_verbose(self, args):
verbose = int(args[1])
self.server.set_verbose(verbose)
return "%d" % verbose | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbosity(v):\n assert v in [0,1,2] # debug, warn, info\n GLOBAL['VERBOSITY'] = v",
"def set_verbosity():\n\n\tif conf.verbose is None:\n\t\tconf.verbose = 1\n\n\tconf.verbose = int(conf.verbose)\n\n\tif conf.verbose == 0:\n\t\tlogger.setLevel(logging.ERROR)\n\telif conf.verbose == 1:\n\t\tlogger.se... | [
"0.7681478",
"0.72215545",
"0.71093506",
"0.6939538",
"0.6873078",
"0.676105",
"0.67317533",
"0.6667096",
"0.6627816",
"0.65958714",
"0.6590193",
"0.65867203",
"0.65688455",
"0.6464963",
"0.6452119",
"0.6382751",
"0.63656926",
"0.6328291",
"0.63164514",
"0.6315265",
"0.630789... | 0.7388952 | 1 |
Get the current version or exit the process. | def version_or_exit(path):
with cd(path):
versioning_file = join(os.curdir, 'versioning.py')
try:
get_version = run_command(versioning_file)
if get_version.returncode:
abort(colors.red('versioning.py') + ' returned an error.')
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version():\n click.echo(get_current_version_number())",
"def get_current_version(self):\n current_version = self.get_version(self.get_module_and_path(self._main_dir))\n return current_version",
"def latest_version(self) -> AwesomeVersion | None:\n return self.sys_updater.version... | [
"0.781276",
"0.7021756",
"0.69878983",
"0.6981611",
"0.6781809",
"0.67792046",
"0.67674327",
"0.67511374",
"0.67059594",
"0.6689565",
"0.66695756",
"0.66640997",
"0.66595495",
"0.6645535",
"0.6642224",
"0.6629286",
"0.6607862",
"0.6600906",
"0.6595271",
"0.6594787",
"0.656329... | 0.707849 | 1 |
Roll back the tagging that was just done and inform the user. >>> rollback('not_a_tag') | def rollback(tag):
done = run_command(['git', 'tag', '-d', tag])
if done.returncode:
echo.bold(colors.red(str(done)))
sys.exit(done.returncode)
echo.cyan('Done:', done.stdout.strip()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback(self):\n pass",
"def rollback(self):\n self._rollback = True",
"def rollback(self):\n raise NotImplementedError",
"def rollback(self):\n raise TransactionRollback('rollback called outside of transaction')",
"def rollback(self, stage, enodes, exception):",
"def rol... | [
"0.76122165",
"0.75165194",
"0.74412733",
"0.72169214",
"0.71961904",
"0.7160262",
"0.70686543",
"0.70201325",
"0.70071846",
"0.70071536",
"0.70067024",
"0.69872856",
"0.6894638",
"0.6878397",
"0.6830433",
"0.67013144",
"0.6643999",
"0.66095114",
"0.66077113",
"0.66047925",
"... | 0.8277594 | 0 |
Do a release step, possibly rolling back the tagging. >>> do_release_step('true', 'rollback_tag') | def do_release_step(command, tag, no_rollback=None):
echo.cyan('running:', command)
published = run_command(command)
if published.returncode:
echo.bold(colors.red('Failed:'))
echo.yellow(published.stderr)
echo.white(published.stdout)
if no_rollback:
echo.cyan(no_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_command(project_path=None, noop=None):\n\n if not sys.version_info.major == 3:\n noop or abort(colors.bold(\n 'Releases are only compatible with both Python2 and Python3 if done via Python3. Aborting since this is Python2.'\n ))\n\n auto_version = version_or_exit(project_... | [
"0.6151928",
"0.6130211",
"0.6007178",
"0.59868795",
"0.58979225",
"0.5823386",
"0.5756305",
"0.5547832",
"0.5530814",
"0.5437972",
"0.5422568",
"0.53532875",
"0.53283924",
"0.5260167",
"0.5257902",
"0.52491486",
"0.5245861",
"0.5234293",
"0.5214079",
"0.5172153",
"0.5157206"... | 0.7707624 | 0 |
menu menu page logic. displaying all the products in our DB | def menu(request):
cart = cartData(request)
cart_items = cart['cart_items']
# order = cart['order']
# items = cart['items']
# Get all our object
products = BobaProduct.objects.all()
# Dictionary to hold our products
context = {"products": products, "cart_items": cart_items}
return re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __products_menu(self):\n log.debug(\"Displaying __products_menu\")\n # Get the products list from the db\n products = self.session.query(db.Product).filter_by(deleted=False).all()\n # Create a list of product names\n product_names = [product.name for product in products]\n ... | [
"0.73752975",
"0.724429",
"0.69932497",
"0.6988591",
"0.6971659",
"0.692478",
"0.69133264",
"0.688549",
"0.673323",
"0.6712486",
"0.66611415",
"0.6580116",
"0.6567587",
"0.6560556",
"0.6493791",
"0.64319545",
"0.6419612",
"0.63676864",
"0.6316506",
"0.62987536",
"0.6239047",
... | 0.7492175 | 0 |
guestChat If the user is not authenticated, they will be redirected to this site where they can input a guest name and enter the chatbox | def guestChat(request):
form = GuestChat()
if request.method == "POST":
form = GuestChat(request.POST)
if form.is_valid():
guestName = form.cleaned_data.get('guest_name')
return render(request, 'chat/room.html', {"guestName": guestName})
context = {"form"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chat():\n username = request.cookies.get('username')\n\n if username != None and username != \"\":\n return r.renderContent('chat.html', name=username)\n return redirect('/login')",
"def chat():\n name = session.get('name', '')\n room = session.get('room', '')\n if name == '' or room == '... | [
"0.7034232",
"0.6945806",
"0.6945806",
"0.6945806",
"0.62233275",
"0.6180299",
"0.60441524",
"0.60381275",
"0.603254",
"0.5890163",
"0.58691007",
"0.57892066",
"0.57755506",
"0.5752947",
"0.5749893",
"0.57432944",
"0.57223237",
"0.57203776",
"0.5709425",
"0.5697157",
"0.56930... | 0.7114216 | 0 |
Computes the Wasserstein distance of order 2 between two Gaussian distributions | def wass_gaussians(mu1, mu2, Sigma1, Sigma2):
d = mu1.shape[0]
if d == 1:
w2 = (mu1 - mu2)**2 + (np.sqrt(Sigma1) - np.sqrt(Sigma2))**2
else:
prodSigmas = Sigma2**(1/2)*Sigma1*Sigma2**(1/2)
w2 = np.linalg.norm(mu1 - mu2)**2 + np.trace(Sigma1 + Sigma2 - 2*(prodSigmas)**(1/2))
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_distribution_distance(freqs1, freqs2):\n A = np.array([freqs1, freqs2])\n p_value = calculate_chi_square_p_value(A)\n return 1 - p_value",
"def distributions_EMD(d1, d2):\n return ss.wasserstein_distance(d1.get_probs(), d2.get_probs()) / len(d1.get_probs())",
"def dist_sph(w1, w2):\n ... | [
"0.6888003",
"0.6883681",
"0.67507505",
"0.6649754",
"0.6564868",
"0.65519416",
"0.6545447",
"0.6508782",
"0.6508671",
"0.6506747",
"0.64647543",
"0.64203846",
"0.639461",
"0.6382358",
"0.6368685",
"0.6355784",
"0.6326227",
"0.62741095",
"0.6272526",
"0.6272526",
"0.62541515"... | 0.7291682 | 0 |
Computes the Hilbert distance of order p | def hilbert_distance(X, Y, p=2):
# We consider N_X = N_Y
xordered = X[HilbertCode_caller.hilbert_order_(X.T)]
yordered = Y[HilbertCode_caller.hilbert_order_(Y.T)]
hilbert_dist = (np.abs(xordered - yordered) ** p).sum()
hilbert_dist /= X.shape[0]
hilbert_dist = hilbert_dist ** (1/p)
return hi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def HammingDistance(p, q):\r\n if len(p) != len(q):\r\n return -1\r\n dist = 0\r\n #zip(AB,CD) gives (('A','C'),('B','D'))\r\n for first, second in zip(p, q):\r\n if first != second:\r\n dist = dist + 1\r\n return dist",
"def ham_dist(p, q):\n count = 0\n for i in ra... | [
"0.6240977",
"0.6224513",
"0.6224513",
"0.62134373",
"0.61977607",
"0.61486363",
"0.60876817",
"0.608004",
"0.5990324",
"0.59267354",
"0.5843678",
"0.580374",
"0.5779593",
"0.57608706",
"0.56451637",
"0.56375206",
"0.563657",
"0.5633568",
"0.5630969",
"0.5597321",
"0.5574527"... | 0.80400836 | 0 |
Computes the swapping distance | def swap_distance(X, Y, n_sweeps=10000, tol=1e-8, p=2):
# We consider N_X = N_Y
if p == 2:
M = ot.dist(X, Y) # Cost matrix
o1 = HilbertCode_caller.hilbert_order_(X.T)
o2 = HilbertCode_caller.hilbert_order_(Y.T)
permutation = o2[np.argsort(o1)]
total_cost = list(map(lambda k: M[k, permut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch_distance(pair_1, pair_2):\r\n\th1_1=pair_1[0]\r\n\th2_1=pair_2[0]\r\n\th2_2=pair_2[1]\r\n\tcnt_1=0\r\n\tcnt_2=0\r\n\t# print h2_1, h1_1\r\n\tfor i in xrange(0,len(pair_1[0])):\r\n\t\tif h2_1[i]!=h1_1[i]:\r\n\t\t\th2_1, h2_2=switch(h2_1, h2_2, i)\r\n\t\t\t# print h2_1, h2_2, i\r\n\t\t\tcnt_1+=1\r\n\tprin... | [
"0.6582465",
"0.6532841",
"0.63852835",
"0.63033766",
"0.6189577",
"0.6141517",
"0.60874605",
"0.6075062",
"0.60507214",
"0.5982342",
"0.59569436",
"0.59408253",
"0.59205955",
"0.5896892",
"0.5882448",
"0.58802503",
"0.5877402",
"0.58580816",
"0.5843558",
"0.58246493",
"0.581... | 0.69632035 | 0 |
Cleans passed string to either return a valid SVGRGBHEXnotation or an empty string. | def cleanup_passed_color_value(s):
reo = re.compile('[0-9a-f]')
cannotBeCleaned = ''
if s[0] == '#' and len(s) in [4,7] and reo.match(s[1:]):
return s
if s in colorNamesAndCodes:
col = colorNamesAndCodes[s]
if reo.match(col[1:]):
return col
else:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_hex(text): \n return re.sub(r'&.*?;', r'', text)",
"def clean_xml_string(s):\n return VALID_XML_CHARS_REGEX.sub(\"\", s)",
"def clean_str(string):\n #just return string if already cleaned\n return string",
"def stripColor(self, s):\n return _stripColorRe.sub('', s)",
"def clea... | [
"0.60601455",
"0.59946215",
"0.59191805",
"0.58995914",
"0.581662",
"0.5805634",
"0.5798346",
"0.5726138",
"0.57169926",
"0.5714296",
"0.5709046",
"0.5709046",
"0.57067734",
"0.56963587",
"0.56107944",
"0.5573957",
"0.5571539",
"0.5549539",
"0.55424464",
"0.5520134",
"0.55162... | 0.60755706 | 0 |
Prints debugging information when the script encounters an illegal color. | def print_illegal_color_format_screen( enteredBGColor, enteredFGColor, convertedBGColor, convertedFGColor ):
print ""
print "Error: are the passed in colors valid?"
print " - passed in background-color '" + enteredBGColor + "' was converted to '" + convertedBGColor + "'."
print " - passed in foregroun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_err(*vargs, **kwargs):\n _do_print_color(*vargs, colorcode = 31, **kwargs)",
"def print_warn(*vargs, **kwargs):\n _do_print_color(*vargs, colorcode = 33, **kwargs)",
"def error_debug(input):\n print(\"\\033[1;31;40m{}\\033[0m\".format(input))",
"def print_debug(*vargs, **kwargs):\n _do_... | [
"0.68145615",
"0.6723713",
"0.66837156",
"0.64507365",
"0.6412046",
"0.64085376",
"0.6315633",
"0.6304557",
"0.62818974",
"0.61877924",
"0.6137318",
"0.6117421",
"0.6116814",
"0.6102645",
"0.60926074",
"0.6007336",
"0.60038733",
"0.59981924",
"0.5976492",
"0.5952483",
"0.5877... | 0.7021701 | 0 |
If a tfq_simulate op is asked to simulate states given circuits acting on different numbers of qubits, the op should return a tensor padded with zeros up to the size of the largest circuit. The padding should be physically correct, such that samples taken from the padded states still match samples taken from the origin... | def test_simulate_state_output_padding(self, all_n_qubits):
circuit_batch = []
for n_qubits in all_n_qubits:
qubits = cirq.GridQubit.rect(1, n_qubits)
circuit_batch += util.random_circuit_resolver_batch(qubits, 1)[0]
tfq_results = tfq_simulate_ops.tfq_simulate_state(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sampling_output_padding(self, all_n_qubits, n_samples):\n op = tfq_simulate_ops.tfq_simulate_samples\n circuits = []\n expected_outputs = []\n for n_qubits in all_n_qubits:\n this_expected_output = np.zeros((n_samples, max(all_n_qubits)))\n this_expected_o... | [
"0.6290017",
"0.5681582",
"0.5681582",
"0.5676849",
"0.5593831",
"0.5576278",
"0.5497892",
"0.5487373",
"0.5466293",
"0.540858",
"0.54031944",
"0.539102",
"0.5358094",
"0.5357061",
"0.5343899",
"0.5330886",
"0.5322747",
"0.52873987",
"0.52870905",
"0.5285144",
"0.52784127",
... | 0.7703024 | 0 |
Check that the sampling ops pad outputs correctly | def test_sampling_output_padding(self, all_n_qubits, n_samples):
op = tfq_simulate_ops.tfq_simulate_samples
circuits = []
expected_outputs = []
for n_qubits in all_n_qubits:
this_expected_output = np.zeros((n_samples, max(all_n_qubits)))
this_expected_output[:, ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_padding_necessary(self, signal: np.array) -> bool:\n if len(signal) < self.number_expected_samples:\n return True\n else:\n return False",
"def test_pad():\n x = randtool(\"float\", -10, 10, [3, 2, 1, 2])\n pad = [1, 1, 2, 3]\n mode = \"constant\"\n value =... | [
"0.6232269",
"0.6190101",
"0.6067233",
"0.5857253",
"0.5819368",
"0.58028764",
"0.57961124",
"0.57630396",
"0.5727364",
"0.5590215",
"0.55863315",
"0.55732685",
"0.5556439",
"0.55498695",
"0.554983",
"0.55409205",
"0.5534093",
"0.55317795",
"0.55132616",
"0.55058515",
"0.5488... | 0.6402059 | 0 |
Returns new subLightCurve, choosing ndays with maximum RMS variation | def best_sublc(self, ndays, npoints=600, chunksize=300,
flat_order=3, **kwargs):
x_full = self.x_full
y_full = self.y_full
N = len(x_full)
cadence = np.median(x_full[1:] - x_full[:-1])
window = int(ndays / cadence)
stepsize = window//50
i1 = 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sigma_high_low(rate, dt=1 * units.ns, time_window_high_low=5 * units.ns):\n def obj(sigma):\n return get_high_low_rate(sigma, dt=dt, time_window_high_low=time_window_high_low) - rate\n res = opt.brentq(obj, 0, 10)\n return res",
"def lCurve(self): \n\n # ---------------------------... | [
"0.5439135",
"0.52744055",
"0.5117991",
"0.5101039",
"0.5043701",
"0.5000911",
"0.49971765",
"0.49746352",
"0.4958558",
"0.49205273",
"0.48910326",
"0.48699352",
"0.48592845",
"0.48264438",
"0.48117554",
"0.48070383",
"0.48056588",
"0.4789352",
"0.47843328",
"0.47834954",
"0.... | 0.65983933 | 0 |
Pick an agent at random, step it, bump counts. | def step(self):
self.agents[random.randint(self.get_agent_count())].step()
self.steps += 1
self.time += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self):\n\t\tnumpy.random.shuffle(self.agents_list)\n\t\tfor agent in self.agents_list:\n\t\t\tagent.produce()\n\t\tfor agent in self.agents_list:\n\t\t\tagent.charge()\n\t\tfor agent in self.agents_list:\n\t\t\tif agent.strategy == 0: \n\t\t\t\tagent.retribute()\n\t\tfor agent in self.agents_list:\n\t\t\t... | [
"0.6958311",
"0.67038995",
"0.66255635",
"0.6525697",
"0.63827926",
"0.6380983",
"0.6380704",
"0.63505244",
"0.63434833",
"0.6333988",
"0.6211217",
"0.6080819",
"0.600359",
"0.5950171",
"0.59233344",
"0.59233344",
"0.5905067",
"0.5897467",
"0.58860046",
"0.58852065",
"0.58824... | 0.757041 | 0 |
Return agent's spilling state. | def spilling(self):
return self._spilling | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPacmanState( self ):\n return self.data.agentStates[0].copy()",
"def get_agent_state(self):\n return self.world_state",
"def get_state(self):\n\t\treturn Job(SDK.PrlVm_GetState(self.handle)[0])",
"def get_state(self):\n return self.env.sim.get_state()",
"def get_tools_state(self... | [
"0.5813141",
"0.57949114",
"0.5761483",
"0.5691754",
"0.5646033",
"0.562968",
"0.5607904",
"0.5590146",
"0.557208",
"0.5541229",
"0.5484805",
"0.54764456",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454887",
"0.54454... | 0.705317 | 0 |
Agent has been selected and a grain of sand is added to it. If the cell exceeds it capacity it add's itself to the model's spill queue. The model handles distributing the spill to adjacent cells. | def step(self):
self.grains += 1
if self.grains > self.spill_size:
print('spill -> ', self.agent_id)
self.model.spill(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spill(self, agent):\n self.spill_list.append(agent)",
"def step(self):\n self.age += 1\n self.move_agent()\n self.sugar -= self.metabolism\n\n # Eat sugar\n available_sugar = self.get_sugar(self.pos).amount\n self.sugar += available_sugar\n# self.total_... | [
"0.70932084",
"0.61752456",
"0.6172666",
"0.57589626",
"0.55338156",
"0.54990155",
"0.5498288",
"0.5404687",
"0.5382121",
"0.5283981",
"0.5247643",
"0.5209323",
"0.51918066",
"0.5176298",
"0.5169959",
"0.5154262",
"0.51332146",
"0.5123966",
"0.5116275",
"0.508177",
"0.5068731... | 0.70183915 | 1 |
Add agent to model's spill queue. | def spill(self, agent):
self.spill_list.append(agent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_grid_queue(self, agent):\n self.pipes[agent.grid_queue].send(\"add\")\n self.pipes[agent.grid_queue].send(agent)",
"def add_to_simulation(self,agent):\n self.agents[agent.name] = agent\n self.network.add_node(agent)\n \n #agent given a grid queue at initializa... | [
"0.7249907",
"0.724359",
"0.6364773",
"0.6199888",
"0.610778",
"0.59546876",
"0.59015363",
"0.58994764",
"0.5738974",
"0.5690717",
"0.5538615",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
"0.5536676",
... | 0.82388806 | 0 |
Process spill_list and advance the model one step. | def step(self):
for c in self.spill_list:
self._schedule.step() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self):\n\n self.grains += 1\n\n if self.grains > self.spill_size:\n print('spill -> ', self.agent_id)\n self.model.spill(self)",
"def spill(self, agent):\n self.spill_list.append(agent)",
"def step(self, memories):\n return",
"def _preprocess(self, o... | [
"0.5933351",
"0.5655595",
"0.5262983",
"0.5020804",
"0.49819398",
"0.49550286",
"0.49170116",
"0.4878095",
"0.48729232",
"0.486313",
"0.48542383",
"0.4846436",
"0.48377305",
"0.48368984",
"0.48039612",
"0.47895807",
"0.47695318",
"0.47682866",
"0.47671297",
"0.47658867",
"0.4... | 0.6663731 | 0 |
Returns the cost of a particular sequence of actions. If those actions include an illegal move, return 999999. | def getCostOfActions(self, actions):
if actions == None: return 999999
x, y = self.getStartState()
cost = 0
for action in actions:
# Check figure out the next state and see whether its' legal
dx, dy = Actions.directionToVector(action)
x, y = int(x + dx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCostOfActions(self, actions):\n if actions == None: return 999999\n x,y= self.getStartState()\n cost = 0\n for action in actions:\n # Check figure out the next state and see whether its' legal\n dx, dy = Actions.directionToVector(action)\n x, y = ... | [
"0.7820553",
"0.7820553",
"0.78143483",
"0.78090173",
"0.7793637",
"0.778846",
"0.778846",
"0.778846",
"0.7624677",
"0.7528754",
"0.7528754",
"0.750788",
"0.7489202",
"0.7310127",
"0.71119225",
"0.7026165",
"0.6846151",
"0.6645367",
"0.6599338",
"0.65375865",
"0.6534645",
"... | 0.78454506 | 0 |
Your heuristic for the FoodSearchProblem goes here. This heuristic must be consistent to ensure correctness. First, try to come up with an admissible heuristic; almost all admissible heuristics will be consistent as well. If using A ever finds a solution that is worse uniform cost search finds, your heuristic is not co... | def foodHeuristic(state, problem):
position, foodGrid = state
"*** YOUR CODE HERE ***"
"""
Mi heurística consiste en hacer simplemente el máximo de las distancias reales del state a cada nodo con comida
He provado diferentes heurísticas y esta es la que me expande menos nodos, aunque no es la más óp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foodHeuristic(state, problem):\n import itertools\n\n\n\n def manhattan(startPosition, targetPosition):\n xy1 = startPosition\n xy2 = targetPosition\n return abs(xy1[0] - xy2[0]) + abs(xy1[1] - xy2[1])\n\n position, foodGrid = state\n\n return len(foodGrid.asList())\n #\n ... | [
"0.83897704",
"0.830523",
"0.8223044",
"0.6986859",
"0.69107854",
"0.6910324",
"0.6817668",
"0.67753005",
"0.6737241",
"0.67104596",
"0.66949224",
"0.66923463",
"0.6692185",
"0.66603684",
"0.66597563",
"0.66365445",
"0.66059625",
"0.6605135",
"0.65819836",
"0.6560537",
"0.652... | 0.85888267 | 0 |
Returns a path (a list of actions) to the closest dot, starting from gameState. | def findPathToClosestDot(self, gameState):
# Here are some useful elements of the startState
startPosition = gameState.getPacmanPosition()
food = gameState.getFood()
walls = gameState.getWalls()
problem = AnyFoodSearchProblem(gameState)
"*** YOUR CODE HERE ***"
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findPathToClosestDot(self, gameState):\n # Here are some useful elements of the startState\n startPosition = gameState.getPacmanPosition(self.index)\n food = gameState.getFood()\n walls = gameState.getWalls()\n problem = AnyFoodSearchProblem(gameState, self.index)\n\n\n ... | [
"0.7966998",
"0.715944",
"0.7031334",
"0.7026767",
"0.68767905",
"0.6658364",
"0.64656806",
"0.6376818",
"0.6200842",
"0.6165224",
"0.6043223",
"0.60112387",
"0.59972686",
"0.59689665",
"0.5964047",
"0.5963518",
"0.58828336",
"0.5865455",
"0.58330965",
"0.58273715",
"0.580822... | 0.7227898 | 1 |
Returns the maze distance between any two points, using the search functions you have already built. The gameState can be any game state Pacman's position in that state is ignored. | def mazeDistance(point1, point2, gameState):
x1, y1 = point1
x2, y2 = point2
walls = gameState.getWalls()
assert not walls[x1][y1], 'point1 is a wall: ' + str(point1)
assert not walls[x2][y2], 'point2 is a wall: ' + str(point2)
prob = PositionSearchProblem(gameState, start=point1, goal=point2, w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mazeDistance(point1, point2, gameState):\n x1, y1 = int(point1[0]),int(point1[1])\n x2, y2 = int(point2[0]),int(point2[1])\n walls = gameState.getWalls()\n \n assert not walls[x1][y1], 'point1 is a wall: ' + point1\n assert not walls[x2][y2], 'point2 is a wall: ' + str(point2)\n prob = Pos... | [
"0.7405596",
"0.62337524",
"0.6202874",
"0.61033416",
"0.60770017",
"0.5981286",
"0.5948442",
"0.5916513",
"0.58608997",
"0.58241653",
"0.5822506",
"0.5700954",
"0.5659414",
"0.5651273",
"0.56431204",
"0.56091815",
"0.5609093",
"0.56061876",
"0.5589039",
"0.5576174",
"0.55667... | 0.7542628 | 1 |
(file open for reading) > query dictionary Read query_file and return information in the query dictionary format. | def process_query(query_file):
query_data = query_file.readlines()
query_dict = {}
x = 1
search_dict = {}
search_dict['username'] = query_data[x].strip('\n')
x += 1
operation_list = []
while query_data[x] != 'FILTER\n':
operation_list.append(query_data[x].strip('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_query (file):\n\n # initialize all the dictionaries and lists we will be using\n query_data = {}\n query_data ['search'] = {'operations':[]}\n query_data ['filter'] = {}\n query_data ['present'] = {}\n\n temp = ''\n\n file.readline() # for when the file says SEARCH\n\n query_dat... | [
"0.7843726",
"0.7040409",
"0.6731658",
"0.6676415",
"0.65146685",
"0.62667567",
"0.62590575",
"0.6256823",
"0.6215728",
"0.62133837",
"0.61976427",
"0.6147864",
"0.61316043",
"0.61125714",
"0.60755527",
"0.6060231",
"0.6012341",
"0.6004686",
"0.59304434",
"0.5879766",
"0.5842... | 0.80009 | 0 |
(dict, list, str, int) > dict Return a dict with key filter_type of query_data given the index. | def filter_format(filter_dict, query_data, filter_type, index):
filter_list = ''
count = 0
while query_data[index] != 'PRESENT\n':
if filter_type in query_data[index]:
count += 1
filter_keyword = query_data[index].strip(filter_type)
fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __index_data_body(index, doc_type, doc_id, source):\n\n index_data = {\n \"_index\": index,\n \"_type\": doc_type,\n \"_id\": doc_id,\n \"_source\": source\n }\n\n return index_data",
"def fetch_querydict(self):\n query = dict()\n ... | [
"0.5705551",
"0.5667574",
"0.5598227",
"0.55603284",
"0.5518409",
"0.5467773",
"0.54619396",
"0.54030484",
"0.53398377",
"0.532923",
"0.5268471",
"0.5182582",
"0.5160404",
"0.51402986",
"0.51049006",
"0.508951",
"0.5088857",
"0.5058746",
"0.50552565",
"0.50269693",
"0.5026853... | 0.65318596 | 0 |
(Twitterverse dictionary, str) > list of str Return a list of all users following twitter_name in twitter_dict. >>> twitter_file = open('data.txt', 'r') >>> twitter_dictionary = process_data(twitter_file) >>> all_followers(twitter_dictionary, 'NicoleKidman') ['PerezHilton', 'q', 'p', 'tomCruise'] >>> twitter_file = ope... | def all_followers(twitter_dict, twitter_name):
following_list = []
for user in twitter_dict:
f_list = twitter_dict[user]['following']
if twitter_name in f_list:
following_list.append(user)
return following_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_followers (twitter_data, username):\n\n # initialize\n followers = []\n\n for key in twitter_data: # go through every username in twitter_data\n if username in twitter_data [key]['following']: # check each 'following'\n followers.append (key)\n\n followers.sort() # sort the li... | [
"0.83895",
"0.7141314",
"0.680105",
"0.6771905",
"0.6646324",
"0.66039145",
"0.6573563",
"0.6453545",
"0.644731",
"0.63955975",
"0.62907255",
"0.62907255",
"0.62907255",
"0.62907255",
"0.6255389",
"0.6255389",
"0.6255389",
"0.62464976",
"0.6245325",
"0.620537",
"0.6181806",
... | 0.8723968 | 0 |
(Twitterverse dictionary, search specification dictionary) > list of str Return a list of users from twitter_dict that fit the specification declared by search_dict. >>> data_file = open('data.txt', 'r') >>> twitter_dict = process_data(data_file) >>> query_file = open('query3.txt', 'r') >>> query_dict = process_query(q... | def get_search_results(twitter_dict, search_dict):
search_list = [search_dict['username']]
search_specified_list = []
for user in search_list:
search_users_list = [user]
for operation in search_dict['operations']:
search_users_list = search_helper(search_user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filter_results(twitter_dict, username_list, filter_dict):\r\n twitter_handles = username_list \r\n name_filtered_list = []\r\n upper_user = []\r\n \r\n if 'name_includes' in filter_dict: \r\n for user in twitter_handles: \r\n user = user.upper()\r\n upper_user.ap... | [
"0.67444634",
"0.63622165",
"0.61439055",
"0.5823485",
"0.57738215",
"0.56694967",
"0.56202865",
"0.561638",
"0.5604377",
"0.55924684",
"0.557445",
"0.552582",
"0.5494284",
"0.5484312",
"0.5452842",
"0.53725946",
"0.5361354",
"0.5322175",
"0.5318818",
"0.5298553",
"0.5283197"... | 0.7901854 | 0 |
(list of str, str, twitterverse dictionary) > list of str Return the list of users that result from operation having applied to name_list from the twitter_dict. >>> data_file = open('data.txt', 'r') >>> twitter_dict = process_data(data_file) >>> query_file = open('query3.txt', 'r') >>> query_dict = process_query(query_... | def search_helper(name_list, operation, twitter_dict):
return_list = []
for name in name_list:
if operation == 'following':
search_specified_list = twitter_dict[name]['following']
for following_names in search_specified_list:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_search_results(twitter_dict, search_dict):\r\n\r\n search_list = [search_dict['username']] \r\n search_specified_list = []\r\n\r\n for user in search_list:\r\n search_users_list = [user]\r\n \r\n for operation in search_dict['operations']:\r\n search_users_list = se... | [
"0.7890037",
"0.7527938",
"0.7475859",
"0.7460602",
"0.6427471",
"0.5894421",
"0.5808291",
"0.57747966",
"0.576515",
"0.5687546",
"0.56544125",
"0.5608119",
"0.55629736",
"0.55307204",
"0.54812115",
"0.5464305",
"0.5451584",
"0.5441889",
"0.54186994",
"0.5417747",
"0.540404",... | 0.83645403 | 0 |
(Twitterverse dictionary, list of str, filter specification dictionary) > list of str >>> data_file = open('data.txt', 'r') >>> twitter_dict = process_data(data_file) >>> query_file = open('query2.txt', 'r') >>> query_dict = process_query(query_file) >>> username_list = get_search_results(twitter_dict, search_dict) >>>... | def get_filter_results(twitter_dict, username_list, filter_dict):
twitter_handles = username_list
name_filtered_list = []
upper_user = []
if 'name_includes' in filter_dict:
for user in twitter_handles:
user = user.upper()
upper_user.append(user)
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filter_results (twitter_data, search_list, filter_data):\n\n #initialize\n filter_list = []\n\n for operation in filter_data:\n if operation == 'name-includes':\n for username in search_list:\n # since case doesnt matter, eveything is made uppercase and\n ... | [
"0.7434036",
"0.68169296",
"0.63130534",
"0.63128114",
"0.6289486",
"0.6159073",
"0.61330956",
"0.60395426",
"0.6004611",
"0.600197",
"0.5982023",
"0.59766793",
"0.59600365",
"0.59467745",
"0.582324",
"0.58030814",
"0.5769613",
"0.576816",
"0.5756492",
"0.5753108",
"0.5703192... | 0.76796806 | 0 |
(Twitterverse dictionary, list of str, presentation specification dictionary) > str Return final_list of users from twitter_dict in the order and format as indicated by present_dict. >>> data_file = open('data.txt', 'r') >>> twitter_dict = process_data(data_file) >>> query_file = open('query2.txt', 'r') >>> query_dict ... | def get_present_string(twitter_dict, final_list, present_dict):
if present_dict['sort-by'] == 'username':
tweet_sort(twitter_dict, final_list, username_first)
if present_dict['sort-by'] == 'name':
tweet_sort(twitter_dict, final_list, name_first)
if present_di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_present_string (twitter_data, filter_list, present_data):\n\n #initialize\n present_string = ''\n present_list = filter_list\n\n if present_data ['sort-by'] == 'username':\n tweet_sort (twitter_data, present_list, username_first)\n\n elif present_data ['sort-by'] == 'name':\n t... | [
"0.7329098",
"0.6643551",
"0.6021003",
"0.5802761",
"0.56354165",
"0.5613348",
"0.5397948",
"0.5390319",
"0.538293",
"0.53705984",
"0.5061108",
"0.5039742",
"0.50106114",
"0.49880728",
"0.4931404",
"0.4930936",
"0.49084416",
"0.48675862",
"0.48386815",
"0.48338753",
"0.483336... | 0.77881116 | 0 |
(Twitterverse dictionary, list of str, function) > NoneType Sort the results list using the comparison function cmp and the data in twitter_data. >>> twitter_data = {\ | def tweet_sort(twitter_data, results, cmp):
# Insertion sort
for i in range(1, len(results)):
current = results[i]
position = i
while position > 0 and cmp(twitter_data, results[position - 1], current) > 0:
results[position] = results[position - 1]
pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweet_sort(twitter_data, results, cmp):\n\n # Insertion sort\n for i in range(1, len(results)):\n current = results[i]\n position = i\n while position > 0 and cmp(twitter_data, results[position - 1], current) > 0:\n results[position] = results[position - 1]\n po... | [
"0.7567489",
"0.650274",
"0.6290785",
"0.62436324",
"0.623184",
"0.61069995",
"0.60515857",
"0.59873897",
"0.5878488",
"0.5872183",
"0.58214015",
"0.58214015",
"0.57846797",
"0.5771403",
"0.5755637",
"0.57172424",
"0.5692742",
"0.56895584",
"0.56837285",
"0.56682867",
"0.5616... | 0.76030976 | 0 |
(Twitterverse dictionary, str, str) > int Return 1 if user a has more followers than user b, 1 if fewer followers, and the result of sorting by username if they have the same, based on the data in twitter_data. >>> twitter_data = {\ | def more_popular(twitter_data, a, b):
a_popularity = len(all_followers(twitter_data, a))
b_popularity = len(all_followers(twitter_data, b))
if a_popularity > b_popularity:
return -1
if a_popularity < b_popularity:
return 1
return username_first(twitter_data, a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def more_popular(twitter_data, a, b):\n\n a_popularity = len(all_followers(twitter_data, a))\n b_popularity = len(all_followers(twitter_data, b))\n if a_popularity > b_popularity:\n return -1\n if a_popularity < b_popularity:\n return 1\n return username_first(twitter_data, a, b)",
"... | [
"0.7528208",
"0.69588375",
"0.66971797",
"0.65298504",
"0.6497349",
"0.6357412",
"0.63211817",
"0.6200824",
"0.61589175",
"0.61370516",
"0.61224115",
"0.61210734",
"0.60854435",
"0.6016705",
"0.60084724",
"0.59806305",
"0.5883615",
"0.58259416",
"0.57227236",
"0.5703999",
"0.... | 0.7497807 | 1 |
(Twitterverse dictionary, str, str) > int Return 1 if user a has a username that comes after user b's username alphabetically, 1 if user a's username comes before user b's username, and 0 if a tie, based on the data in twitter_data. >>> twitter_data = {\ | def username_first(twitter_data, a, b):
if a < b:
return -1
if a > b:
return 1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username_first(twitter_data, a, b):\n\n if a < b:\n return -1\n if a > b:\n return 1\n return 0",
"def name_first(twitter_data, a, b):\n\n a_name = twitter_data[a][\"name\"]\n b_name = twitter_data[b][\"name\"]\n if a_name < b_name:\n return -1\n if a_name > b_name:\... | [
"0.7257887",
"0.7018444",
"0.69511354",
"0.65835136",
"0.6546135",
"0.6383048",
"0.5989066",
"0.5976186",
"0.565109",
"0.56353337",
"0.5623372",
"0.56220394",
"0.56099427",
"0.55019134",
"0.5429901",
"0.5400648",
"0.52955055",
"0.5273156",
"0.527068",
"0.5203552",
"0.5171498"... | 0.7232197 | 1 |
(Twitterverse dictionary, str, str) > int Return 1 if user a's name comes after user b's name alphabetically, 1 if user a's name comes before user b's name, and the ordering of their usernames if there is a tie, based on the data in twitter_data. >>> twitter_data = {\ | def name_first(twitter_data, a, b):
a_name = twitter_data[a]["name"]
b_name = twitter_data[b]["name"]
if a_name < b_name:
return -1
if a_name > b_name:
return 1
return username_first(twitter_data, a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_first(twitter_data, a, b):\n\n a_name = twitter_data[a][\"name\"]\n b_name = twitter_data[b][\"name\"]\n if a_name < b_name:\n return -1\n if a_name > b_name:\n return 1\n return username_first(twitter_data, a, b)",
"def username_first(twitter_data, a, b):\n\n if a < b:\n... | [
"0.7261839",
"0.6815641",
"0.67782587",
"0.65419745",
"0.6481994",
"0.6463288",
"0.62870765",
"0.6256376",
"0.5890704",
"0.5813191",
"0.5721417",
"0.57102513",
"0.5625274",
"0.55444145",
"0.5516707",
"0.55118585",
"0.5480974",
"0.5467732",
"0.5466456",
"0.5454952",
"0.5449887... | 0.723645 | 1 |
Get the first letter in the message from user if it is not an alpha | def _get_first_letter_in_text(text: str) -> str:
for letter in text:
if letter.isalpha():
return letter
return text[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_message(message):\n alphabet = ''\n for i in range(len(message)):\n if message[i].isalpha():\n alphabet = alphabet + message[i].upper()\n return alphabet\n # Will obtain a str that will only contain alphabets that are uppercase.",
"def Prints_single_letter_string_when_tryi... | [
"0.7021727",
"0.69095814",
"0.6808512",
"0.67910373",
"0.6768156",
"0.6737975",
"0.67040485",
"0.66168314",
"0.65995246",
"0.65331924",
"0.6513524",
"0.64735717",
"0.6369872",
"0.6368524",
"0.63524103",
"0.6332107",
"0.6301702",
"0.6275444",
"0.6264006",
"0.6255922",
"0.62482... | 0.77461845 | 0 |
Convert a Composer checkpoint to a pretrained HF checkpoint folder. Write a ``config.json`` and ``pytorch_model.bin``, like | def write_huggingface_pretrained_from_composer_checkpoint(
checkpoint_path: Union[Path, str],
output_path: Union[Path, str],
output_precision: str = 'fp32',
local_checkpoint_save_location: Optional[Union[Path, str]] = None
) -> Tuple[PretrainedConfig, Optional[PreTrainedTokenizerBase]]:
dtype = {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_checkpoint(huggingface_model_name_or_path, output_path):\n output_dir, _ = os.path.split(output_path)\n tf.io.gfile.makedirs(output_dir)\n\n huggingface_bert_model, huggingface_bert_config = _get_huggingface_bert_model_and_config(\n huggingface_model_name_or_path)\n encoder = _create_fffner_mo... | [
"0.6353711",
"0.6301693",
"0.63011956",
"0.610833",
"0.6077828",
"0.59906185",
"0.59823364",
"0.59694815",
"0.5962135",
"0.5917442",
"0.59148014",
"0.5914448",
"0.5885656",
"0.58622265",
"0.5843601",
"0.5778996",
"0.5778468",
"0.57622725",
"0.5746577",
"0.57425416",
"0.573442... | 0.66567194 | 0 |
Generate a complex layout report with simple elements | def gen_report_complex_no_files() -> dp.Report:
select = dp.Select(blocks=[md_block, md_block], type=dp.SelectType.TABS)
group = dp.Group(md_block, md_block, columns=2)
return dp.Report(
dp.Page(
blocks=[
dp.Group(md_block, md_block, columns=2),
dp.Select... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_layout(self):\n\n pass",
"def create_layout( self ):",
"def display_reports(self, layout): # pylint: disable=arguments-differ",
"def create_html_layout(self):\n page = \"\"\"<!DOCTYPE html>\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta c... | [
"0.69769275",
"0.6473278",
"0.63054246",
"0.60292476",
"0.59565306",
"0.5911801",
"0.5869038",
"0.5819134",
"0.57823735",
"0.5755476",
"0.57442385",
"0.56819475",
"0.56775093",
"0.5628919",
"0.56264186",
"0.5593363",
"0.5590153",
"0.5521933",
"0.55100393",
"0.5480658",
"0.543... | 0.67525214 | 1 |
Test TextReport API and id/naming handling | def test_textreport_gen():
s_df = gen_df()
# Simple
report = dp.TextReport("Text-3")
assert_text_report(report, 1)
# multiple blocks
report = dp.TextReport("Text-1", "Text-2", s_df)
assert_text_report(report, 3)
# empty - raise error
with pytest.raises(DPError):
report = d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_usage(self):\n self._test_reports_helper({}, [\"report.txt\"])",
"def run_test_ner():\n # This note is a fake report\n\n text = \"\"\"\nRecord date: 2063-12-13\n\n\n\n\nNAME: Doe, Jane \nMRN: 98765432\n\nThe patient is here as a walk-in. Her spouse is present.\n\nPatient sa... | [
"0.61058956",
"0.59754026",
"0.59663147",
"0.5875179",
"0.5820495",
"0.5816298",
"0.5780176",
"0.56849706",
"0.5683433",
"0.56673104",
"0.56545895",
"0.5620811",
"0.55447906",
"0.552769",
"0.5513816",
"0.55067",
"0.54996467",
"0.549786",
"0.54872155",
"0.5484214",
"0.5477892"... | 0.63549286 | 0 |
Set required and widgets for fields. | def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
self.fields['first_name'].required = True
self.fields['password'].widget = forms.PasswordInput()
for field in self.fields:
self.fields[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n placeholders = {\n \"first_name\": \"First Name\",\n \"last_name\": \"Last Name\",\n \"default_phone_num\": \"Phone Number\",\n \"default_passport_num\": \"Passport Number\",\n ... | [
"0.6541632",
"0.6453019",
"0.6182293",
"0.613699",
"0.61324316",
"0.61182314",
"0.611023",
"0.6102259",
"0.6014309",
"0.5993374",
"0.5987304",
"0.59669083",
"0.59576404",
"0.59438926",
"0.59405667",
"0.59002674",
"0.58811474",
"0.5862535",
"0.58578044",
"0.58545446",
"0.58465... | 0.6483126 | 1 |
Create the sh script for starting unblur | def create_sh_script(
unblur_path, input_image, output_dir,
input_dir, input_suffix, options
):
strSh = ''
# To make sure it is a bash script
strSh += '#!/bin/bash\n\n'
# Export number of threads
strSh += 'export OMP_NUM_THREADS={:d}\n'.forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n parser = make_arg_parser()\n if len(sys.argv) == 1:\n parser.print_help()\n sys.exit(1)\n args = parser.parse_args()\n deblur_transcripts(args.input, args.cds_fa, args.vblur, args.output)",
"def launchgui(image):\n from filter import launch\n launch(image)",
"def r... | [
"0.6045751",
"0.54544467",
"0.5439029",
"0.534224",
"0.53305626",
"0.5258778",
"0.52516085",
"0.5213264",
"0.5197605",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.51781684",
"0.... | 0.6334928 | 0 |
Creates a dictionary that maps domains to encoded ids. | def _get_domain_mappings(domain_to_intents: Dict) -> Dict:
domain2id = {}
domains = list(domain_to_intents)
for index, domain in enumerate(domains):
domain2id[domain] = index
return domain2id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_intent_mappings(domain_to_intents: Dict) -> Dict:\n domain_to_intent2id = {}\n for domain in domain_to_intents:\n intent_labels = {}\n for index, intent in enumerate(domain_to_intents[domain]):\n intent_labels[intent] = index\n domain_to_intent... | [
"0.68493307",
"0.6190228",
"0.6138264",
"0.6116921",
"0.61143875",
"0.59695417",
"0.5882584",
"0.58567834",
"0.5835327",
"0.58119893",
"0.5768381",
"0.5751803",
"0.5672121",
"0.56632924",
"0.564285",
"0.56324285",
"0.5624405",
"0.56145364",
"0.5583475",
"0.557813",
"0.556828"... | 0.7636259 | 0 |
Creates a dictionary that maps intents to encoded ids. | def _get_intent_mappings(domain_to_intents: Dict) -> Dict:
domain_to_intent2id = {}
for domain in domain_to_intents:
intent_labels = {}
for index, intent in enumerate(domain_to_intents[domain]):
intent_labels[intent] = index
domain_to_intent2id[domain]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_intent_token_dict(intents, intent_split_symbol):\r\n\r\n distinct_tokens = set([token\r\n for intent in intents\r\n for token in intent.split(\r\n intent_split_symbol)])\r\n return {token: i... | [
"0.6695217",
"0.64867634",
"0.6394871",
"0.60963374",
"0.59980714",
"0.5829211",
"0.5791798",
"0.57791173",
"0.56940323",
"0.5672877",
"0.56094426",
"0.5583357",
"0.55793476",
"0.55350786",
"0.5458744",
"0.5416988",
"0.538743",
"0.5383223",
"0.5371814",
"0.53664494",
"0.53332... | 0.7101111 | 0 |
Creates a class label for a set of queries. These labels are used to split queries by type. Labels follow the format of "domain" or "domain|intent". For example, "date|get_date". | def get_class_labels(
tuning_level: list, query_list: ProcessedQueryList
) -> List[str]:
if TuneLevel.INTENT.value in tuning_level:
return [
f"{d}.{i}" for d, i in zip(query_list.domains(), query_list.intents())
]
else:
return [f"{d}" for d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_label(termtype, timeperiod):\n label = 'Graph these comma-separated noun phrases (yearly frequencies):' if termtype == 'Noun phrases' and timeperiod == 'Yearly' \\\n else 'Graph these comma-separated noun phrases (monthly frequencies):' if termtype == 'Noun phrases' and timeperiod == 'Monthly... | [
"0.6051387",
"0.5911016",
"0.58429545",
"0.5480097",
"0.54685163",
"0.5401774",
"0.5383226",
"0.5366071",
"0.5278606",
"0.5277043",
"0.5194852",
"0.5194105",
"0.51914555",
"0.51535213",
"0.5120259",
"0.5098108",
"0.50675786",
"0.5051951",
"0.50454336",
"0.50446814",
"0.503565... | 0.62765896 | 0 |
Removes duplicates in the text queries. | def deduplicate_raw_text_queries(log_queries_iter) -> List[str]:
return list(set(q for q in log_queries_iter)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_duplicates(self):\n self.search_query = remove_duplicates(self.search_query)",
"def remove_duplicates(self, hits):\n\t\tseen = set()\n\t\tkeep = []\n\n\t\tfor i in range(len(hits)):\n\t\t\tif hits[i][\"Text\"] not in seen:\n\t\t\t\tseen.add(hits[i][\"Text\"])\n\t\t\t\tkeep.append(hits[i])\n\n\... | [
"0.7845041",
"0.6695697",
"0.6653341",
"0.65625846",
"0.639675",
"0.6349758",
"0.6328951",
"0.6103831",
"0.6063389",
"0.60107267",
"0.59329724",
"0.5881362",
"0.58800447",
"0.5849684",
"0.5797378",
"0.5773862",
"0.5744445",
"0.57247037",
"0.56726134",
"0.5653875",
"0.562954",... | 0.76712906 | 1 |
Converts text queries to processed queries using an annotator. | def convert_text_queries_to_processed(
self, text_queries: List[str]
) -> List[ProcessedQuery]:
logger.info("Loading a Bootstrap Annotator to process log queries.")
annotator_params = DEFAULT_AUTO_ANNOTATOR_CONFIG
annotator_params["app_path"] = self.app_path
bootstrap_annotat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_analysis(self, query, key=None):\n logger.info(\"Running analysis on query...\")\n core_annotation = Annotation(query, key)\n clf_pipeline = AnalysisPipeline()\n entity_pipeline = AnalysisPipeline()\n clf = self.clf_accessor.get_classification_pipeline('multiclass', 'inte... | [
"0.58529824",
"0.5585822",
"0.5577068",
"0.55282134",
"0.5404479",
"0.53600365",
"0.53220135",
"0.52643645",
"0.52558595",
"0.5248043",
"0.52073747",
"0.5193515",
"0.51917845",
"0.5176019",
"0.5160177",
"0.50877666",
"0.5071344",
"0.50710976",
"0.50638235",
"0.5001331",
"0.49... | 0.70313007 | 0 |
Method to get multiple queries from the QueryCache given a list of query ids. | def get_queries(self, query_ids):
return [
self.resource_loader.query_cache.get(query_id) for query_id in query_ids
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_many(self, queries):\n assert isinstance(queries, list)\n cursor = self._cursor()\n results = []\n for query in queries:\n try:\n cursor.execute(query)\n result = cursor.fetchall()\n except Exception as e:\n pr... | [
"0.722569",
"0.65023124",
"0.64487207",
"0.64159083",
"0.6410242",
"0.635374",
"0.62091815",
"0.6204514",
"0.6176422",
"0.6157128",
"0.61314714",
"0.606496",
"0.59988225",
"0.5957463",
"0.5924632",
"0.5920572",
"0.5903233",
"0.58550835",
"0.5850858",
"0.58000696",
"0.57887274... | 0.8206793 | 0 |
Update the current set of sampled queries by adding the set of newly sampled queries. A new PrcoessedQueryList object is created with the updated set of query ids. | def update_sampled_queries(self, newly_sampled_queries_ids):
sampled_queries_ids = self.sampled_queries.elements + newly_sampled_queries_ids
self.sampled_queries = ProcessedQueryList(
cache=self.resource_loader.query_cache, elements=sampled_queries_ids
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_unsampled_queries(self, remaining_indices):\n remaining_queries_ids = [\n self.unsampled_queries.elements[i] for i in remaining_indices\n ]\n self.unsampled_queries = ProcessedQueryList(\n cache=self.resource_loader.query_cache, elements=remaining_queries_ids\n... | [
"0.68086916",
"0.5676029",
"0.5447187",
"0.5287999",
"0.5281685",
"0.5269392",
"0.5163817",
"0.50805366",
"0.5080143",
"0.50727624",
"0.50701463",
"0.50502145",
"0.50495815",
"0.5037603",
"0.5023451",
"0.4994067",
"0.49848914",
"0.49457482",
"0.49016884",
"0.48877212",
"0.488... | 0.83345515 | 0 |
Update the current set of unsampled queries by removing the set of newly sampled queries. A new PrcoessedQueryList object is created with the updated set of query ids. | def update_unsampled_queries(self, remaining_indices):
remaining_queries_ids = [
self.unsampled_queries.elements[i] for i in remaining_indices
]
self.unsampled_queries = ProcessedQueryList(
cache=self.resource_loader.query_cache, elements=remaining_queries_ids
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_sampled_queries(self, newly_sampled_queries_ids):\n sampled_queries_ids = self.sampled_queries.elements + newly_sampled_queries_ids\n self.sampled_queries = ProcessedQueryList(\n cache=self.resource_loader.query_cache, elements=sampled_queries_ids\n )",
"def clearpredic... | [
"0.75596094",
"0.5790968",
"0.5650789",
"0.55124557",
"0.5401627",
"0.53630894",
"0.5264245",
"0.5239242",
"0.5194279",
"0.5116806",
"0.50995237",
"0.50639457",
"0.5062219",
"0.49259344",
"0.4909404",
"0.4904073",
"0.48995757",
"0.48682117",
"0.48384356",
"0.48304084",
"0.482... | 0.7108111 | 1 |
Establish http routes for the given list of routes containing tuples of the form (route, handler object) | def make_routes(routelist):
return webapp2.WSGIApplication(routelist, debug=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes():\n import urllib.request, urllib.parse, urllib.error\n output = []\n for rule in app.url_map.iter_rules():\n options = {}\n for arg in rule.arguments:\n options[arg] = \"[{0}]\".format(arg)\n methods = ','.join(rule.methods)\n url = url_for(rule.endpoint... | [
"0.65212214",
"0.64429027",
"0.62730944",
"0.61776197",
"0.61614925",
"0.60371983",
"0.60076576",
"0.5969171",
"0.5950606",
"0.5946168",
"0.59317756",
"0.5844661",
"0.58265465",
"0.5787878",
"0.57873255",
"0.57807803",
"0.57449365",
"0.5722084",
"0.5693369",
"0.5688424",
"0.5... | 0.6722308 | 0 |
Replaces all of the ultisnips variables with the corresponding vscode | def _replace_variables(self, string):
conversions = {"VISUAL": "TM_SELECTED_TEXT"}
for old, new in conversions.items():
string = string.replace(old, new)
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_variables(self, text, context):\n text = text.replace('__VENV_DIR__', context.env_dir)\n text = text.replace('__VENV_NAME__', context.env_name)\n text = text.replace('__VENV_PROMPT__', context.prompt)\n text = text.replace('__VENV_BIN_NAME__', context.bin_name)\n text... | [
"0.6394522",
"0.58065987",
"0.5606063",
"0.5557312",
"0.54911727",
"0.5431594",
"0.5424897",
"0.5397946",
"0.5366627",
"0.5284732",
"0.52125996",
"0.51902866",
"0.5151045",
"0.51302266",
"0.5101047",
"0.5086249",
"0.5032191",
"0.50283474",
"0.5023271",
"0.5014109",
"0.5012332... | 0.6078713 | 1 |
Parses out the snippets into JSON form with the following schema { | def parse_snippet(self, ultisnip_file: Path) -> dict:
snippets_dictionary = {}
with open(ultisnip_file, "r") as f:
for line in f:
if line.startswith("snippet"):
snippet = {}
prefix = line.split()[1].strip()
snippet["... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_list(request):\n if request.method == 'GET':\n quickstart = Quickstart.objects.all()\n serializer = QuickstartSerializer(snippets, many=True)\n return JsonResponse(serializer.data, safe=False)\n\n elif request.method == 'POST':\n data = JSONParser().parse(request)\n ... | [
"0.6311338",
"0.6069845",
"0.59527874",
"0.5810302",
"0.5810302",
"0.5762867",
"0.57340497",
"0.55275506",
"0.54961646",
"0.5488228",
"0.5488193",
"0.54133624",
"0.5376377",
"0.533812",
"0.5299759",
"0.5267433",
"0.52651376",
"0.52602667",
"0.5223165",
"0.51634073",
"0.515207... | 0.63587433 | 0 |
This function gets the trial sets for each leaf node in this graph. | def get_trial_sets(graph, leaves, diff = 2):
trialsets = {}
for leaf in leaves:
parents = get_parent_path(graph, leaf)
psizes = [len(graph.node[p]['leaves']) for p in parents]
root = parents[-1]
l1id = 1
while l1id < len(parents) -1 and psizes[l1id] < 5:
l1id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_all_roots(trial):\r\n root_nodes = trial.node_map[0].children.copy()\r\n shuffle(root_nodes)\r\n states = []\r\n for node in root_nodes:\r\n trial_copy = copy.deepcopy(trial)\r\n states.append(trial_copy)\r\n node.observe()\r\n trial_copy = copy.deepcopy(trial)\r\n ... | [
"0.6844502",
"0.6840591",
"0.6083935",
"0.5979716",
"0.59425783",
"0.5910932",
"0.5865636",
"0.5863153",
"0.5837333",
"0.5722749",
"0.57013834",
"0.56999",
"0.5659051",
"0.5631628",
"0.5579923",
"0.5571343",
"0.55593115",
"0.55593115",
"0.55299985",
"0.54905343",
"0.5464976",... | 0.7629318 | 0 |
generate a trial from the given trialset and image maps | def generate_trial(trialset, synset2img, trialtype, num_imgs):
# randomly shuffle the sets.
for s in trialset:
random.shuffle(s)
source = trialset[trialtype]
# sample images
# make sure we have the most specific guy
src_imgs = [random.choice(synset2img[trialset[0][0]])]
for i in rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stim_generate(params,stim_list,train):\n if train:\n stim = list(stim_list.keys())\n shuffled_stim = shuffled_images = []\n #for each run get equal amounts of stim and shuffle\n #can only work if 'trials_per_run' is divisible by number of stims\n for run in range(params['r... | [
"0.6116985",
"0.6031568",
"0.5918441",
"0.5664884",
"0.5622315",
"0.5615459",
"0.5599443",
"0.5529613",
"0.55038154",
"0.54847896",
"0.5482034",
"0.5451923",
"0.5441349",
"0.5423713",
"0.5408815",
"0.5383447",
"0.5371646",
"0.5351493",
"0.53448683",
"0.5335508",
"0.52934724",... | 0.7455843 | 0 |
Calculates the fuzzy match of needle in haystack, using a modified version of the Levenshtein distance algorithm. The function is modified from the levenshtein function in the bktree module by Adam Hupp | def __fuzzy_substring(needle, haystack):
m, n = len(needle), len(haystack)
# base cases
if m == 1:
# return not needle in haystack
row = [len(haystack)] * len(haystack)
row[haystack.find(needle)] = 0
return row
if not n:
return m
row1 = [0] * (n + 1)
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def levenshtein_normalised(str1, str2):\n\treturn levenshtein(str1, str2, normalise=True)",
"def levenshtein(str1, str2, normalise=False):\n\ttmp = Levenshtein.distance(str1, str2)\n\tif(normalise) and (len(str1) + len(str2)): tmp /= max(len(str1), len(str2))\n\treturn tmp",
"def get_closest_levenshtein(word, ... | [
"0.65816826",
"0.64453566",
"0.6444688",
"0.64391017",
"0.63947976",
"0.63769424",
"0.63476413",
"0.6301144",
"0.6251837",
"0.61857057",
"0.6146241",
"0.6121829",
"0.6104246",
"0.6104119",
"0.607645",
"0.60713935",
"0.6024334",
"0.60240644",
"0.60073864",
"0.5990242",
"0.5945... | 0.66017675 | 0 |
Sets the check_revocation of this TypesConsoleCertificateSettings. | def check_revocation(self, check_revocation):
self._check_revocation = check_revocation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_compatibility_check(check_status):\r\n if Config.loaded:\r\n raise Exception(\"compatibility_check must be set before before \" \\\r\n \"using any other functionalities in libclang.\")\r\n\r\n Config.compatibility_check = check_status",
"def svn_client_... | [
"0.50971395",
"0.45247346",
"0.4501634",
"0.44256946",
"0.43760172",
"0.43499175",
"0.43033206",
"0.42995754",
"0.42879218",
"0.42419428",
"0.42351454",
"0.42196298",
"0.41943878",
"0.41834015",
"0.4180629",
"0.4163931",
"0.4148873",
"0.41426238",
"0.41319498",
"0.41168395",
... | 0.7481139 | 0 |
Sets the console_ca_cert of this TypesConsoleCertificateSettings. | def console_ca_cert(self, console_ca_cert):
self._console_ca_cert = console_ca_cert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ca_cert(self, ca_cert):\n\n self._ca_cert = ca_cert",
"def console_custom_cert(self, console_custom_cert):\n\n self._console_custom_cert = console_custom_cert",
"def ca_cert_path(self, ca_cert_path: str):\n\n self._ca_cert_path = ca_cert_path",
"def save_ca():\n cert_file = os... | [
"0.68265325",
"0.65130776",
"0.6440239",
"0.58595866",
"0.5228995",
"0.5037131",
"0.5037131",
"0.5013002",
"0.490777",
"0.48871157",
"0.48593655",
"0.48507708",
"0.48467252",
"0.4803529",
"0.48032707",
"0.47784925",
"0.4713782",
"0.46828216",
"0.46399626",
"0.4594442",
"0.456... | 0.85301137 | 0 |
Sets the console_custom_cert of this TypesConsoleCertificateSettings. | def console_custom_cert(self, console_custom_cert):
self._console_custom_cert = console_custom_cert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def console_ca_cert(self, console_ca_cert):\n\n self._console_ca_cert = console_ca_cert",
"def set_custom_property(self, sNewVmCustomProperty):\n\t\tcall_sdk_function('PrlVmCfg_SetCustomProperty', self.handle, sNewVmCustomProperty)",
"def custom_compliance_domain(self, custom_compliance_domain):\n\n ... | [
"0.6610284",
"0.54055816",
"0.53626394",
"0.52227587",
"0.51395243",
"0.5006331",
"0.49909642",
"0.4988925",
"0.49661958",
"0.49389002",
"0.49314305",
"0.49158552",
"0.489311",
"0.4870659",
"0.48248613",
"0.4814451",
"0.47850242",
"0.4669491",
"0.460155",
"0.4534467",
"0.4508... | 0.8813465 | 0 |
Sets the hpkp of this TypesConsoleCertificateSettings. | def hpkp(self, hpkp):
self._hpkp = hpkp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pssh(self, pssh):\n self._pssh = pssh\n return self",
"def hdp_version(self, hdp_version):\n\n self._hdp_version = hdp_version",
"def set_kp():\n kp = request.params.get(\"kp\", 0, type=float)\n pid = request.params.get(\"pid\", 1, type=int)\n retval = RP_LIB.rp_PIDSetKp(pid, ... | [
"0.56403214",
"0.5224331",
"0.5040199",
"0.50149983",
"0.48443633",
"0.48201424",
"0.48000458",
"0.4754778",
"0.47419602",
"0.4728604",
"0.46491504",
"0.45619443",
"0.45580828",
"0.45580828",
"0.45580828",
"0.4547807",
"0.4547807",
"0.4547807",
"0.4473194",
"0.4460671",
"0.44... | 0.7709247 | 0 |
Generates a unique id which will be used by paynow to refer to the payment initiated | def generate_transaction_id():
return str(int(time.time() * 1000)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_id(self, context):\n tmp = datetime.datetime.now()\n tmp = tmp.strftime('%Y%m%d%H%M%S%f')\n tmp += context.peer()\n m = hashlib.md5()\n m.update(tmp.encode('utf-8'))\n return str(m.hexdigest())",
"def _generate_order_id():\n current_milli_time = str(... | [
"0.75733525",
"0.7475758",
"0.74029607",
"0.7379154",
"0.7355747",
"0.7351507",
"0.7347127",
"0.73232245",
"0.7290395",
"0.72684765",
"0.7227526",
"0.7220504",
"0.7218613",
"0.7189539",
"0.71791047",
"0.71791047",
"0.717642",
"0.71746486",
"0.71354276",
"0.71192765",
"0.71178... | 0.79250395 | 0 |
Reflect the elements of a numpy array along a specified axis about the first element. | def reflect(arr,axis=0,sign=1):
refl_idx = axis * [slice(None)] + [slice(None,0,-1), Ellipsis]
return np.concatenate((arr[tuple(refl_idx)],arr), axis=axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reflect_array(x, axis=1, kind='even'):\n if axis == 0:\n x_sym = np.flipud(x)\n elif axis == 1:\n x_sym = np.fliplr(x)\n else:\n raise NotImplementedError\n\n if kind == 'even':\n fact = 1.0\n elif kind == 'odd':\n fact = -1.0\n else:\n raise NotImple... | [
"0.67617947",
"0.6650867",
"0.61850905",
"0.6083956",
"0.5720959",
"0.57025504",
"0.5559801",
"0.5524613",
"0.55142355",
"0.54787475",
"0.5478125",
"0.5472565",
"0.54558724",
"0.5451142",
"0.53963137",
"0.53875583",
"0.5342568",
"0.5339039",
"0.5313937",
"0.53026325",
"0.5300... | 0.69821197 | 0 |
Returns a list of flows with randomly selected sources and destinations that will saturate the network (i.e. a flow will be admitted provided that it would not cause the utilization of any link in the network to exceed 1. Flows are equally split across the K shortest paths connecting the source node to the destination ... | def compute_path_hopping_flow_allocations(target_graph, K=3):
flow_allocation_seed_number = 0xCAFE_BABE
np.random.seed(flow_allocation_seed_number)
# id_to_dpid = topo_mapper.get_and_validate_onos_topo_x(target_graph)
link_utilization = {(u, v): 0.0 for u, v in target_graph.edges}
node_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_equal_flow_allocations(target_graph, K=3):\n # id_to_dpid = topo_mapper.get_and_validate_onos_topo_x(target_graph)\n flow_allocation_seed_number = 0xDEAD_BEEF\n np.random.seed(flow_allocation_seed_number)\n flows = []\n for node in target_graph.nodes:\n possible_destination_nodes ... | [
"0.6073624",
"0.5772932",
"0.56998974",
"0.5527996",
"0.54848486",
"0.5443951",
"0.5443951",
"0.53789777",
"0.53648436",
"0.53508836",
"0.5280728",
"0.5269755",
"0.5099018",
"0.50866324",
"0.50755084",
"0.50711346",
"0.50711346",
"0.50291127",
"0.5007661",
"0.4996117",
"0.496... | 0.62126094 | 0 |
Returns a list of flows with randomly selected sources and destinations that will saturate the network (i.e. a flow will be addmitted provided that it will not cause the utilization of any link in the network to exceed 1. Flows are split across the K least utilized paths connecting the source node to the destination no... | def compute_greedy_flow_allocations( target_graph
, flow_selection_fn
, seed_number=DEFAULT_SEED_NUMBER):
flow_allocation_seed_number = seed_number
np.random.seed(flow_allocation_seed_number)
link_utilization = {tuple(sorted(link_tup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_path_hopping_flow_allocations(target_graph, K=3):\n flow_allocation_seed_number = 0xCAFE_BABE\n np.random.seed(flow_allocation_seed_number)\n # id_to_dpid = topo_mapper.get_and_validate_onos_topo_x(target_graph)\n link_utilization = {(u, v): 0.0 for u, v in target_graph.edges}\n... | [
"0.6332378",
"0.60935616",
"0.5811239",
"0.560641",
"0.5514502",
"0.5492238",
"0.5380612",
"0.5344111",
"0.5344111",
"0.53399456",
"0.5291331",
"0.5245833",
"0.52410334",
"0.5200011",
"0.51825786",
"0.51523155",
"0.51386243",
"0.51315624",
"0.5101362",
"0.5068613",
"0.5018153... | 0.622782 | 1 |
RETURNS A set of outgoing links and corresponding splitting ratios for flow f at node s | def get_paths_for_flow(F, s, f):
links = [((u, v), split_ratio)
for (flow_id, u, v), split_ratio in F.items()
if flow_id == f and u == s and split_ratio > 0.001]
return links | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse_graph(F, f, s, t, u, sr):\n def get_paths_for_flow(F, s, f):\n \"\"\"\n RETURNS\n A set of outgoing links and corresponding splitting ratios for flow f\n at node s\n \"\"\"\n links = [((u, v), split_ratio) \n for (flow_id, u, v), spli... | [
"0.69459766",
"0.5595106",
"0.5534561",
"0.5483686",
"0.54691195",
"0.5467508",
"0.53494895",
"0.53470665",
"0.53366846",
"0.53234804",
"0.5310389",
"0.52716064",
"0.52382374",
"0.5235263",
"0.52303815",
"0.5227401",
"0.52202076",
"0.5218126",
"0.5190948",
"0.51826143",
"0.51... | 0.7221145 | 1 |
RETURNS A set of outgoing links and corresponding splitting ratios for flow f at node s | def get_paths_for_flow(F, s, f):
links = [((u, v), split_ratio)
for (flow_id, u, v), split_ratio in F.items()
if flow_id == f and u == s and split_ratio > 0.001]
return links | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse_graph(F, f, s, t, u, sr):\n def get_paths_for_flow(F, s, f):\n \"\"\"\n RETURNS\n A set of outgoing links and corresponding splitting ratios for flow f\n at node s\n \"\"\"\n links = [((u, v), split_ratio) \n for (flow_id, u, v), spli... | [
"0.6946733",
"0.5595293",
"0.55341357",
"0.5483804",
"0.54689676",
"0.546619",
"0.53488106",
"0.5347624",
"0.53359586",
"0.5324602",
"0.531136",
"0.527324",
"0.52406126",
"0.52348506",
"0.52295214",
"0.5226473",
"0.5220885",
"0.52176976",
"0.5189963",
"0.5180724",
"0.5178925"... | 0.7221145 | 0 |
To check if a route is feasible using given vehicle type, and return check result and route cost. | def check_violation(route, vehicle_type):
if len(route) == 2: # [0, 0] route
return True, 0, 0, 0
else:
accu_res = [0, 0, 0] # 0-leaving time, 1-accumulated distance, 2-volume
if vehicle_type == 2:
veh_cap = small_veh
elif vehicle_type == 3:
veh_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_type(route):\r\n typ = 2\r\n vol_accu = 0 # accumulated volume\r\n\r\n if len(route) <= 2:\r\n return typ\r\n else:\r\n for i in range(1, len(route) - 1):\r\n cust0 = route[i]\r\n vol_accu += (num_demd[cust0][0] * bskt_vol + num_demd[cust0][1] * trsf_vol +... | [
"0.6641761",
"0.6013915",
"0.5916763",
"0.5848608",
"0.5837383",
"0.5789502",
"0.56984466",
"0.56722516",
"0.56595474",
"0.5631287",
"0.5621344",
"0.5614399",
"0.5525109",
"0.55222577",
"0.55129397",
"0.5479792",
"0.5474687",
"0.5432638",
"0.5411634",
"0.54076946",
"0.5397473... | 0.77047276 | 0 |
Given a route, return the vehicle type of the route. Samll vehicle first, medium second, large last. | def route_type(route):
typ = 2
vol_accu = 0 # accumulated volume
if len(route) <= 2:
return typ
else:
for i in range(1, len(route) - 1):
cust0 = route[i]
vol_accu += (num_demd[cust0][0] * bskt_vol + num_demd[cust0][1] * trsf_vol + (num_demd[cust0][2] +
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vehicle_type():\n pass",
"def vehicle_type(self):\n return 'truck'",
"def vehicle_type(self):\n return 'truck'",
"def vehicle_type(self):\n pass",
"def vehicle_type(self):\n return 'car'",
"def vehicle_type(self):\n return 'car'",
"def vehicle_type(self):\n... | [
"0.6574357",
"0.623225",
"0.623225",
"0.6055304",
"0.59921247",
"0.59921247",
"0.59921247",
"0.57707924",
"0.57326573",
"0.5594481",
"0.5594481",
"0.5594481",
"0.55097127",
"0.53885955",
"0.5273151",
"0.52576345",
"0.52177763",
"0.5201615",
"0.51950127",
"0.5176466",
"0.51732... | 0.77867645 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.