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 |
|---|---|---|---|---|---|---|
Read messages, prints Subject, From, and Date of each email. | def process_messages(imap, messages):
for i in messages:
# fetch the email message by ID
res, msg = imap.fetch(str(i), "(RFC822)")
for response in msg:
if isinstance(response, tuple):
# parse bytes email into a message object
msg = email.message_fr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_basic_email_information(emails, conn):\n for mid in emails:\n (res, data) = conn.fetch(mid, '(ENVELOPE)')\n headers = pattern.match(data[0])\n print 'Date: %s' % headers.group(1)\n print 'Subject: %s' % headers.group(2)\n print 'From: %s <%s@%s>' % (headers.group(3), headers.group(4), he... | [
"0.68606496",
"0.6697399",
"0.6242391",
"0.6167278",
"0.60678244",
"0.5987654",
"0.59242094",
"0.58546776",
"0.58495265",
"0.5796335",
"0.5782215",
"0.57780635",
"0.5763217",
"0.5757804",
"0.5738771",
"0.5679548",
"0.56775135",
"0.5667818",
"0.5658688",
"0.5621258",
"0.557776... | 0.6736609 | 1 |
Retrieves the user data associated with the given user id, only if the uid matches a temporary user. | def get_temp_user(temp_uid):
rows = query_db(GET_TEMP_USER_BY_ID, (temp_uid,))
if (not rows) or (len(rows) == 0):
return None
else:
return rows[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(self, user_id):\n return None # noqa: WPS324",
"def get_user(self, user_id):\n return self.my_get_user(self.get_all_dbusers(), user_id)",
"def get_user(self):\n if \"user\" not in self._data:\n self._data[\"user\"] = User.objects.get(pk=self.kwargs[\"user_id\"])\n ... | [
"0.653152",
"0.64986724",
"0.64938116",
"0.6490214",
"0.6460154",
"0.64446324",
"0.6444477",
"0.6431604",
"0.64265597",
"0.64099985",
"0.64092183",
"0.6406827",
"0.6384698",
"0.63674635",
"0.6348337",
"0.63395566",
"0.63255215",
"0.6324054",
"0.63140005",
"0.62993497",
"0.629... | 0.7075412 | 0 |
Creates a new queue with the defined settings. All settings except qid must exist. | def create_queue(q_settings):
db = get_db()
cursor = db.cursor()
cursor.execute(INSERT_QUEUE)
q_settings['qid'] = cursor.lastrowid
cursor.execute(INSERT_QUEUE_SETTINGS, qsettings_dict_to_db_tuple(q_settings))
cursor.close()
db.commit()
permissions.add_permission_list(get_uids(q_settings[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _queue_create(self, **kwargs):\n name = self.generate_random_name()\n return self.clients(\"zaqar\").queue(name, **kwargs)",
"def create_queue(self):\n queue_name = self.generate_name()\n try:\n queue = self.sqs.create_queue(QueueName=queue_name)\n except Excepti... | [
"0.7581136",
"0.70347965",
"0.69530344",
"0.65396017",
"0.6517988",
"0.650838",
"0.6362824",
"0.63077843",
"0.62122697",
"0.6168579",
"0.61568266",
"0.6059989",
"0.6057603",
"0.59346896",
"0.5918184",
"0.59084517",
"0.58973634",
"0.5895379",
"0.58948785",
"0.58845586",
"0.581... | 0.80698436 | 0 |
Modifies the queue with the qid defined in q_settings to match the q_settings given. If the user's session does not have proper permissions, a PermissionException will be raised. | def modify_queue_settings(q_settings):
db = get_db()
db.execute(UPDATE_QUEUE_SETTINGS, qsettings_dict_to_db_tuple_modify(q_settings))
db.commit()
permissions.update_permissions(q_settings['qid'],
get_uids(q_settings['admins']),
get_ui... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_queue(q_settings):\r\n db = get_db()\r\n cursor = db.cursor()\r\n cursor.execute(INSERT_QUEUE)\r\n q_settings['qid'] = cursor.lastrowid\r\n cursor.execute(INSERT_QUEUE_SETTINGS, qsettings_dict_to_db_tuple(q_settings))\r\n cursor.close()\r\n db.commit()\r\n permissions.add_permission_list... | [
"0.695025",
"0.5967407",
"0.5682562",
"0.5622668",
"0.55358464",
"0.54205173",
"0.52965754",
"0.52623177",
"0.5238731",
"0.5237322",
"0.51202923",
"0.51119876",
"0.5106844",
"0.5067134",
"0.5061601",
"0.5050214",
"0.50273246",
"0.5011243",
"0.49993062",
"0.49826905",
"0.49506... | 0.8353673 | 0 |
Deletes the queue with the given qid. | def delete_queue(qid):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_queue(self, queue_id):\n del self.queue_dict[queue_id]",
"def delete_queue(self, queue_name):\n amqp_session = self.__broker.getAmqpSession()\n amqp_session.queue_delete(queue_name)",
"def delete_queue(client, vhost, queue):\n client.delete_queue(vhost, queue)",
"def delete_qu... | [
"0.80621874",
"0.7392091",
"0.7221345",
"0.6939881",
"0.6921134",
"0.68347037",
"0.681158",
"0.6723165",
"0.6691769",
"0.6668935",
"0.6582468",
"0.6549046",
"0.6486121",
"0.6386816",
"0.638424",
"0.63499683",
"0.6224456",
"0.62072754",
"0.61523956",
"0.6105223",
"0.60679805",... | 0.7482865 | 1 |
Retrieves the queue_settings associated with qid. | def get_queue_settings(qid):
db = get_db()
rows = query_db(GET_QUEUE_SETTINGS_BY_ID, (qid,))
if (not rows) or (len(rows) == 0):
raise sqlite3.Error('The queue does not exist.')
return rows[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getQueueDetails(self, queue_name, project_id=\"\"):\n if project_id == \"\":\n project_id = self.project_id\n url = \"%sprojects/%s/queues/%s?oauth=%s\" % (self.url, project_id,\n queue_name, self.token)\n body = self.__get(url)\n queue = json.loads(body)\n... | [
"0.6426058",
"0.6181275",
"0.60460794",
"0.60399467",
"0.60134006",
"0.6009682",
"0.5998501",
"0.596838",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5869374",
"0.5864781",
"0.57995844",
"0.5773101",
"0.57453996",... | 0.84848475 | 0 |
Gets the next unused color in the colormap. | def getnextcolor(self):
self.usedcc = [line.get_c() for line in self.axes.lines]
for c in self.cc:
if c not in self.usedcc:
return c
# Only gets here if all colors already used...
i = len(self.axes.lines)
numc = len(self.cc)
i = i % numc
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_color(self):\n idx = self._color_indexes.get(self._plotid)\n if idx is not None:\n return COLOR_CYCLE[(idx-1) % len(COLOR_CYCLE)]\n return COLOR_CYCLE[0]",
"def next_color(self):\n if self._color_cycle is None:\n return self._theme.color\n return ... | [
"0.7047926",
"0.70240617",
"0.6406171",
"0.640337",
"0.63254637",
"0.624644",
"0.6140363",
"0.6138365",
"0.608178",
"0.5859143",
"0.5800212",
"0.57992345",
"0.57513505",
"0.57308686",
"0.5720083",
"0.5693726",
"0.56692684",
"0.56692684",
"0.56692684",
"0.56692684",
"0.565848"... | 0.76217306 | 0 |
Checks to see if the figure has been initialized sufficiently. Raises a HKEPlotterNotInitializedError if this check fails. | def _checkfigure(self):
if ((type(self.figure) is Figure) and
(type(self.axes) in (Subplot, Axes))):
return
else:
raise HKEPlotterNotInitializedError(self.figure,
self.axes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_init(self):\n if self.Nlayer > 1:\n raise Exception(\"Nlayer == 1 currently\")",
"def _check_if_fitted(self):\n if not self.fitted:\n raise AssertionError('Model is not fitted! Fit the model to a '\n 'dataset before attempting to plot ... | [
"0.58771706",
"0.58598655",
"0.5789109",
"0.56482935",
"0.55886585",
"0.55830985",
"0.55374056",
"0.55144477",
"0.5482541",
"0.54182714",
"0.5398965",
"0.53605324",
"0.5334684",
"0.5334493",
"0.526229",
"0.5258163",
"0.52408624",
"0.52403283",
"0.5214515",
"0.51683396",
"0.51... | 0.85144806 | 0 |
Add a vertical line corresponding to line at the specified temperature. | def addTcline(self, line, temperature=None):
self._checkfigure()
ld = self._get_linedict(line)
line = ld['line']
if temperature is None:
temperature = ld['Tc']
color = line.get_c()
axvl = self.axes.axvline(temperature, color=color, ls='--')
# self.axvl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vert_lines(self, timestamp: datetime = None) -> None:\n self._logger.debug(\"running\")\n for axes in self.figure.get_axes():\n if timestamp:\n self._vlines.append(timestamp)\n axes.axvline(timestamp)\n self.refresh_self()\n e... | [
"0.6347238",
"0.6204931",
"0.61713815",
"0.6061019",
"0.5882949",
"0.5863026",
"0.57749057",
"0.5748844",
"0.56307054",
"0.5602868",
"0.55812764",
"0.5558648",
"0.55533946",
"0.5510339",
"0.5501377",
"0.542325",
"0.5418261",
"0.5417373",
"0.5402615",
"0.53853005",
"0.536729",... | 0.81121063 | 0 |
Remove a vertical line corresponding to line. | def delTcline(self, line):
self._checkfigure()
ld = self._get_linedict(line)
for vline in ld['vlines']:
vline.remove()
ld['vlines'] = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_line(self, line):\n self._checkfigure()\n ld = self._get_linedict(line)\n self.delTcline(ld)\n line = ld['line']\n line.remove()\n self.lines.remove(ld)",
"def unhighlight_line(self, line):\n self._checkfigure()\n ld = self._get_linedict(line)\n ... | [
"0.78958136",
"0.7021003",
"0.6831549",
"0.68241143",
"0.6732324",
"0.6673958",
"0.65849",
"0.6536107",
"0.6413903",
"0.6360962",
"0.6296874",
"0.62025994",
"0.6155294",
"0.6119225",
"0.60587656",
"0.5982313",
"0.5938441",
"0.5886886",
"0.588464",
"0.5878587",
"0.58415264",
... | 0.81666446 | 0 |
Highlight a line by making its linewidth slightly larger. | def highlight_line(self, line, factor=1.5):
self._checkfigure()
ld = self._get_linedict(line)
ld['highlighted'] = True
ld['highlight factor'] = factor
self.update_lines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hline(self, x, y, width, color):\n self.rect(x, y, width, 1, color, fill=True)",
"def highlight_line(self, line: int):\r\n\r\n # iterate through the stored labels\r\n for i in range(len(self.list_labels)):\r\n # select the label\r\n cur_label = self.list_labels[i]\r... | [
"0.6834912",
"0.6661483",
"0.6593628",
"0.65844816",
"0.64995754",
"0.64967895",
"0.6495246",
"0.64931285",
"0.644155",
"0.6311235",
"0.6303806",
"0.6160309",
"0.61249274",
"0.6121856",
"0.6103676",
"0.6070904",
"0.60629326",
"0.6013031",
"0.6001534",
"0.5995958",
"0.596047",... | 0.7394484 | 0 |
Remove the highlighting of a line by restoring its linewidth to the original size. | def unhighlight_line(self, line):
self._checkfigure()
ld = self._get_linedict(line)
ld['highlighted'] = False
self.update_lines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_line(self, line):\n self._checkfigure()\n ld = self._get_linedict(line)\n self.delTcline(ld)\n line = ld['line']\n line.remove()\n self.lines.remove(ld)",
"def delTcline(self, line):\n self._checkfigure()\n ld = self._get_linedict(line)\n ... | [
"0.6705673",
"0.66501707",
"0.6345694",
"0.6073631",
"0.60523313",
"0.59840494",
"0.5944763",
"0.5901352",
"0.5873407",
"0.5866891",
"0.584564",
"0.58381665",
"0.5835699",
"0.5823243",
"0.57539326",
"0.5734348",
"0.5732146",
"0.5720828",
"0.570929",
"0.5683525",
"0.5675305",
... | 0.7733983 | 0 |
Remove a line and all lines related to it from the figure. | def delete_line(self, line):
self._checkfigure()
ld = self._get_linedict(line)
self.delTcline(ld)
line = ld['line']
line.remove()
self.lines.remove(ld) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delTcline(self, line):\n self._checkfigure()\n ld = self._get_linedict(line)\n for vline in ld['vlines']:\n vline.remove()\n ld['vlines'] = []",
"def erase_plot(self, line_position=0):\n self.axplot.lines.pop(line_position).remove\n self.fig.canvas.draw()\... | [
"0.7875856",
"0.7797177",
"0.73978674",
"0.7305522",
"0.6911539",
"0.68509316",
"0.6705773",
"0.66417044",
"0.6570736",
"0.6451503",
"0.64441305",
"0.641181",
"0.64044476",
"0.6347925",
"0.62704635",
"0.6255358",
"0.6212487",
"0.6195537",
"0.6177298",
"0.6173465",
"0.6164881"... | 0.80190194 | 0 |
Update all of the properties of the lines to match those specified by the lines dictionaries. | def update_lines(self):
self._checkfigure()
for ld in self.lines:
line = ld['line']
color = ld['color']
line.set_color(color)
lw = ld['linewidth']
hlf = ld['highlight factor']
highlight = hlf if ld['highlighted'] else 1.0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_dict(self, lines):\n for line in lines:\n line = line.rstrip()\n split_line = line.split(\"\\t\")\n old_gene_id = split_line[0]\n new_gene_id = split_line[2]\n conv_dict = self.conversion_dict\n conv_dict[old_gene_id] = new_gene_id\n ... | [
"0.6635039",
"0.6558961",
"0.61416423",
"0.6050221",
"0.60437894",
"0.59587663",
"0.59425133",
"0.59164494",
"0.5850133",
"0.5814374",
"0.57916486",
"0.56902176",
"0.5680567",
"0.5630113",
"0.56012625",
"0.5566768",
"0.5527338",
"0.5511613",
"0.54785407",
"0.5465747",
"0.5459... | 0.66452 | 0 |
Change the scale of the x axis. | def xscale(self, newscale, linthreshx=1.e-4):
self._checkfigure()
if newscale == 'symlog':
self.axes.set_xscale(newscale, linthreshx=linthreshx)
else:
self.axes.set_xscale(newscale) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xscale(self, kind):\n self._xscale = str(kind).strip() # remove whitespace eventually\n if self._xscale not in self.xscaling():\n self._xscale = self.xscaling(1)",
"def setScaleX(self,startx,endx):\r\n if startx == endx:\r\n endx += 1\r\n self.scaleLock.acqui... | [
"0.75162244",
"0.749704",
"0.74579763",
"0.7220122",
"0.69459987",
"0.6915198",
"0.6820812",
"0.6799988",
"0.6794418",
"0.6695604",
"0.6602468",
"0.6586427",
"0.653044",
"0.65237784",
"0.6494618",
"0.6494618",
"0.6425369",
"0.64223045",
"0.6365275",
"0.63600373",
"0.63461554"... | 0.7631463 | 0 |
Change the scale of the y axis. | def yscale(self, newscale, linthreshy=1.e-4):
self._checkfigure()
if newscale == 'symlog':
self.axes.set_yscale(newscale, linthreshy=linthreshy)
else:
self.axes.set_yscale(newscale) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yscale(self, value='linear'):\r\n for ax in self._subaxes:\r\n ax.set_yscale(value)\r\n self.figure.canvas.draw()",
"def setScaleY(self,starty,endy):\r\n if starty == endy:# Prevent /0 errors when scaling\r\n endy += 0.1\r\n self.scaleLock.acquire()\r\n ... | [
"0.83540624",
"0.7639247",
"0.76304406",
"0.7609599",
"0.7424399",
"0.7308757",
"0.7259377",
"0.72316325",
"0.7127579",
"0.7097566",
"0.7009638",
"0.6943726",
"0.69134957",
"0.6899598",
"0.6857216",
"0.6814696",
"0.67792916",
"0.6751122",
"0.6750558",
"0.67136586",
"0.6713658... | 0.77396965 | 1 |
Set the x label. | def xlabel(self, xlabel):
self._checkfigure()
self.axes.set_xlabel(xlabel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xlabel(self, xlabel: str):\n\n self.ax.set_xlabel(xlabel)\n self.canvas.draw()",
"def set_label(self, x=None, y=None):\n\n if x:\n self.axes.set_xlabel(x)\n if y:\n self.axes.set_ylabel(y)",
"def xaxis(self,label,units):\r\n if units != \"\": label =... | [
"0.83227915",
"0.78510827",
"0.768761",
"0.763404",
"0.71824145",
"0.71818656",
"0.71470004",
"0.71255195",
"0.7057654",
"0.7001613",
"0.6981948",
"0.6973022",
"0.6868358",
"0.68305385",
"0.68288565",
"0.68243974",
"0.6804483",
"0.67813873",
"0.67813873",
"0.67813873",
"0.676... | 0.8380205 | 0 |
Show and redraw the figure. Generally not useful if HKEPlotter is being used to serve up figures to a different frontend, but is useful for interactive use of HKEPlotter on its own. | def draw(self):
self.figure.show()
self.figure.canvas.draw() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_figure(self):\n\n self.draw()",
"def show_figure(self):\n pylab.show()",
"def redraw(self):\n dummy_figure = plt.figure()\n new_manager = dummy_figure.canvas.manager\n new_manager.canvas.figure = self.figure\n self.figure.set_canvas(new_manager.canvas)\n ... | [
"0.7442054",
"0.72985405",
"0.72740227",
"0.7139864",
"0.7054566",
"0.70101815",
"0.6959752",
"0.6950756",
"0.68631804",
"0.68610996",
"0.68610996",
"0.68610996",
"0.6855939",
"0.66993093",
"0.668948",
"0.668948",
"0.65383893",
"0.64258283",
"0.6350744",
"0.63269967",
"0.6323... | 0.7369711 | 1 |
Parse a string containing a CIGAR string. Converts it into a suitable format for the other functions of this module >>> CIGAR.fromString("5M20I2M5D").toList() [(5, 'M'), (20, 'I'), (2, 'M'), (5, 'D')] >>> CIGAR.fromString("").toList() [''] >>> CIGAR.fromString("").toList() [] >>> CIGAR.fromString("4F") | def fromString(cls, string):
# From SAM specification v1.5, slightly adapted for single-token parsing
pattern = r"^[0-9]+[MIDNSHPX=]"
string = string.strip()
if string == '*':
return CIGAR.fromList(['*'])
parsed = []
s = string
# Parse string token (e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_string_to_listint(string):\n\tstring = string.split()\n\tlength = len(string)\n\tnewlist = []\n\tfirst = int (string[0])\n\tsecond = int (string[1])\n\tthird = int (string[2])\n\tforth = int (string[3])\n\tfifth = int (string[4])\n\tnewlist.append(first)\n\tnewlist.append(second)\n\tnewlist.append(third)... | [
"0.61173743",
"0.5562493",
"0.5561425",
"0.550409",
"0.5474138",
"0.5468441",
"0.54449433",
"0.54384106",
"0.54120386",
"0.54009825",
"0.5395243",
"0.5395102",
"0.535296",
"0.53439724",
"0.52883965",
"0.52763444",
"0.5264064",
"0.52568686",
"0.5254977",
"0.52531236",
"0.52431... | 0.71512187 | 0 |
Join duplicate tokens together. This is done automatically before printing and does not need to be explicitly called in normal operation >>> c = CIGAR.fromList([]) >>> c._tokens = [(2,'M'),(3,'I'),(4,'M'),(3,'M')] >>> c.compact() >>> c._tokens [(2, 'M'), (3, 'I'), (7, 'M')] >>> c = CIGAR.fromList([]) >>> c._tokens = [(... | def compact(self):
if self._changed == False:
return
t = self._tokens
if t in [[], '*']:
return
# Tokens which can be reordered and joined if juxtapoxed.
# E.g. 3I3D3I --> 3D6I
freeToks = ['I','D']
iFirstFree = None
for i in rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CompactTokens(self):\n map = {}\n for token_ in self.tokens_:\n hash_string = token_.EncodeForHash()\n try: map[hash_string].append(token_)\n except KeyError: map[hash_string] = [token_]\n ntokens = []\n keys = map.keys()\n keys.sort()\n for k in keys:\n token_ = map[k][0]... | [
"0.6678322",
"0.59820163",
"0.56799006",
"0.5620844",
"0.5576293",
"0.55237937",
"0.5503982",
"0.52999336",
"0.5281514",
"0.520811",
"0.520811",
"0.520811",
"0.520811",
"0.5125486",
"0.5053332",
"0.5034395",
"0.5030067",
"0.5002936",
"0.49746132",
"0.49096557",
"0.48882848",
... | 0.7703922 | 0 |
Changes the token t1 by an operation t2. Both t1 and t2 are of the format (N, X) where N is an integer and X is a onechar string out of "MIDNSHPX=". Its meaning is that of a CIGAR string 'NX' p is an integer giving the position (relative to t1) where to change the CIGAR string t1 by the operation t2. The function retur... | def _mutateToken(t1, p, t2):
if not isinstance(p, int):
raise ValueError("p must be integer")
if(p < 0):
raise ValueError("p may not be smaller than 0")
if(p > t1[0]-1):
raise ValueError("p may not be larger than t1 length - 1")
x1 = t1[1] # Type o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operationAt(self, op, n, at):\n self._changed = True\n\n bpTokenStart = 0 # in bp (base pairs)\n # iToken and tokenLength are used ouside of loop\n for iStartToken,tokenLength in enumerate(t[0] for t in self._tokens):\n if bpTokenStart + tokenLength > at: break\n ... | [
"0.5909464",
"0.54508114",
"0.5353232",
"0.53109324",
"0.5183065",
"0.5157569",
"0.51135975",
"0.50226814",
"0.4987378",
"0.49470899",
"0.49032512",
"0.48813334",
"0.48719415",
"0.4846766",
"0.48339766",
"0.47886705",
"0.47811374",
"0.47744894",
"0.47724745",
"0.4759226",
"0.... | 0.80241114 | 0 |
Refine table contents with a fit on the image The table is modified in place. | def refine_table(self, image, table):
if table is None or len(table) == 0 or \
not isinstance(image, np.ndarray):
return
x0, y0 = np.mgrid[-self.ncut:self.ncut, -self.ncut:self.ncut]
model_g = models.Gaussian2D(
1.0, self.ncut, self.ncut,
x_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete_images_table(self, table):\r\n # Variable initialization\r\n cmp_double = 0\r\n cmp_img = 0\r\n\r\n # Connection to database\r\n conn, cursor = connection_database(self.db_name, self.host, self.user, self.password, self.local, self.ssl_ca)\r\n\r\n # Get images... | [
"0.5431792",
"0.5344389",
"0.51285285",
"0.5111027",
"0.5101912",
"0.5088771",
"0.5080382",
"0.50031626",
"0.49684134",
"0.4954868",
"0.49354628",
"0.4919202",
"0.4917076",
"0.48899812",
"0.48867348",
"0.48697388",
"0.48675102",
"0.48475635",
"0.4847346",
"0.48268786",
"0.481... | 0.7310207 | 0 |
Initialize the RAMSTKWorkView metaclass. | def __init__(self, controller, **kwargs):
_module = kwargs['module']
gtk.HBox.__init__(self)
ramstk.RAMSTKBaseView.__init__(self, controller, module=_module)
self._module = None
for __, char in enumerate(_module):
if char.isalpha():
self._module = _mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, controller, **kwargs): # pylint: disable=unused-argument\n RAMSTKWorkView.__init__(self, controller, module='Function')\n\n # Initialize private dictionary attributes.\n\n # Initialize private list attributes.\n self._lst_assess_labels[1].append(_(u\"Total Mode Count... | [
"0.6240101",
"0.59596485",
"0.579034",
"0.5773658",
"0.5769354",
"0.5749818",
"0.56876385",
"0.56521547",
"0.5582976",
"0.555983",
"0.55574834",
"0.5523128",
"0.5515693",
"0.5504477",
"0.55011004",
"0.54869395",
"0.5480955",
"0.5474198",
"0.5460474",
"0.54480135",
"0.5437854"... | 0.64453584 | 0 |
Create the gtk.Notebook() page for displaying assessment results. | def _make_assessment_results_page(self):
_hbox = gtk.HBox()
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
# Build the left half of the page. #
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
_fx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_assessment_results_page(self, notebook):\r\n\r\n _hbox = gtk.HBox()\r\n\r\n # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #\r\n # Build the left half of the page. #\r\n # +++++++++++++++++++++++++++++++++++++++++++++... | [
"0.8329622",
"0.7571663",
"0.72755533",
"0.71898496",
"0.7028935",
"0.6892961",
"0.6792773",
"0.6667084",
"0.66336125",
"0.64590913",
"0.64258105",
"0.6100222",
"0.6006352",
"0.59311277",
"0.58841544",
"0.5749062",
"0.5729164",
"0.5685445",
"0.5673195",
"0.5663004",
"0.563122... | 0.76316273 | 1 |
Respond to load the Work View gtk.Notebook() widgets. This method handles the results of the an individual module's _on_select() method. It sets the title of the RAMSTK Work Book and raises an error dialog if needed. | def on_select(self, **kwargs):
_title = kwargs['title']
_error_code = kwargs['error_code']
_user_msg = kwargs['user_msg']
_debug_msg = kwargs['debug_msg']
try:
_workbook = self.get_parent().get_parent()
_workbook.set_title(_title)
except Attribute... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, controller, **kwargs):\n _module = kwargs['module']\n gtk.HBox.__init__(self)\n ramstk.RAMSTKBaseView.__init__(self, controller, module=_module)\n\n self._module = None\n for __, char in enumerate(_module):\n if char.isalpha():\n self.... | [
"0.5903212",
"0.5611034",
"0.5532166",
"0.5440121",
"0.5369993",
"0.5311868",
"0.52511024",
"0.5176978",
"0.51719844",
"0.51626706",
"0.51476216",
"0.5146475",
"0.5130871",
"0.51127416",
"0.50981665",
"0.5091824",
"0.50823027",
"0.5081134",
"0.50551033",
"0.5042717",
"0.50361... | 0.6752174 | 0 |
Respond to the `selectedRevision` signal from pypubsub. | def _on_select_revision(self, **kwargs):
self._revision_id = kwargs['module_id']
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn_notify(self,event):\n # pysvn.wc_notify_action.update_completed\n if event['action'] == pysvn.wc_notify_action.update_completed:\n revision = event['revision']\n self.revision = revision",
"def onSelected(self):\n pass",
"def selection_changed(self):\n ... | [
"0.62416744",
"0.60654837",
"0.59142613",
"0.58489025",
"0.58353555",
"0.5674044",
"0.54842246",
"0.54825467",
"0.5423293",
"0.53679717",
"0.53676856",
"0.5355891",
"0.5354404",
"0.53491926",
"0.53078157",
"0.53046656",
"0.5300872",
"0.5299296",
"0.52821183",
"0.5278814",
"0.... | 0.670077 | 0 |
file chooser for orthomosaic | def choosefilenameortho(self, e):
filename = QFileDialog.getOpenFileName(self.dlg,"Select TIFF file",
"/home", "TIF files (*.tif);;All files (*.*)")
if filename:
self.dlg.leOrthomosaic.setText(filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_file(self):\n pass",
"def fileCmd(self):\n filename = askopenfilename() \n self.cnvImgOrig.displayImage(filename)\n self.cnvImgTest.displayImage(filename)",
"def chooseOpenFile(self):\n fname = QFileDialog.getOpenFileName(self, 'Open file',\n ... | [
"0.68460006",
"0.6781604",
"0.6464207",
"0.6318979",
"0.6274876",
"0.6174504",
"0.6145747",
"0.6051645",
"0.6024273",
"0.6023101",
"0.58995837",
"0.5868736",
"0.5868575",
"0.58656466",
"0.5854936",
"0.58537596",
"0.58488727",
"0.58395654",
"0.58267856",
"0.5804377",
"0.577666... | 0.7535651 | 0 |
Run olevba on the given file and extract the XLM macro code lines. maldoc (str) The fully qualified name of the Excel file to analyze. (str) The XLM macro cells extracted from running olevba on the given file. None will be returned on error. | def _extract_xlm(maldoc):
# Run olevba on the given file.
olevba_out = None
FNULL = open(os.devnull, 'w')
try:
cmd = "timeout 30 olevba -c \"" + str(maldoc) + "\""
olevba_out = subprocess.check_output(cmd, shell=True, stderr=FNULL)
except Exception as e:
color_print.output('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_97(maldoc):\n\n # Run olevba on the file and extract the XLM macro code lines.\n color_print.output('g', \"Analyzing Excel 97 file ...\")\n xlm_code = _extract_xlm(maldoc)\n color_print.output('g', \"Extracted XLM with olevba.\")\n if debug:\n print(\"=========== START RAW ... | [
"0.6144289",
"0.6018125",
"0.57654345",
"0.4963401",
"0.49541065",
"0.48330134",
"0.46645972",
"0.45865145",
"0.45475653",
"0.4467187",
"0.44324526",
"0.4419184",
"0.441069",
"0.44008112",
"0.43970215",
"0.4365387",
"0.43541402",
"0.43446854",
"0.42940488",
"0.42849368",
"0.4... | 0.733833 | 0 |
Guess the sheet containing the XLM macros by finding the sheet with the most unresolved "NAME" cells. workbook (ExcelSheet object) The Excel spreadsheet to check. (str) The name of the sheet that might contain the XLM macros. | def _guess_xlm_sheet(workbook):
# TODO: If plugin_biff.py used by olevba to dump XLM includes sheet names this
# function will no longer be needed.
# Look at each sheet.
xlm_sheet = None
unresolved_count = -1
for curr_sheet_name in workbook.sheet_names():
curr_sheet = workbook.sheet_by... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_2007(maldoc):\n\n # Read in the 2007+ cells.\n color_print.output('g', \"Analyzing Excel 2007+ file ...\")\n workbook_info = XLM.excel2007.read_excel_2007_XLM(maldoc) \n color_print.output('g', \"Extracted XLM from ZIP archive.\")\n if (workbook_info is None):\n return (... | [
"0.6036669",
"0.60088015",
"0.5607725",
"0.56071246",
"0.5354856",
"0.52406216",
"0.518099",
"0.51746696",
"0.50699383",
"0.5010548",
"0.49969032",
"0.49915874",
"0.49154997",
"0.48782837",
"0.48635158",
"0.48627582",
"0.48588476",
"0.48369735",
"0.47476253",
"0.46648648",
"0... | 0.82565725 | 0 |
Merge the given XLM cells into the value cells read from the given Excel file. maldoc (str) The fully qualified name of the Excel file to analyze. xlm_cells (dict) A dict of XLM formula objects (XLM_Object objects) where dict[ROW][COL] gives the XLM cell at (ROW, COL). (tuple) A 3 element tuple where the 1st element is... | def _merge_XLM_cells(maldoc, xlm_cells):
# Read in the Excel workbook data.
color_print.output('g', "Merging XLM macro cells with data cells ...")
workbook = excel.read_excel_sheets(maldoc)
if (workbook is None):
color_print.output('r', "ERROR: Reading in Excel file " + str(maldoc) + " failed."... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_2007(maldoc):\n\n # Read in the 2007+ cells.\n color_print.output('g', \"Analyzing Excel 2007+ file ...\")\n workbook_info = XLM.excel2007.read_excel_2007_XLM(maldoc) \n color_print.output('g', \"Extracted XLM from ZIP archive.\")\n if (workbook_info is None):\n return (... | [
"0.604738",
"0.6008518",
"0.5825835",
"0.5649459",
"0.55426455",
"0.52557373",
"0.48428568",
"0.48080117",
"0.475572",
"0.4632839",
"0.4576498",
"0.45346174",
"0.4532015",
"0.4509528",
"0.44865486",
"0.4460298",
"0.444932",
"0.44257683",
"0.44192648",
"0.44060838",
"0.4393537... | 0.8173978 | 0 |
Read in an Excel 2007+ workbook and the XLM macros in the workbook. maldoc (str) The fully qualified name of the Excel file to analyze. (tuple) A 3 element tuple where the 1st element is the workbook object, the 2nd element is a list of XLM cell indices ((row, column) tuples) and the 3rd element is a sheet element for ... | def _read_workbook_2007(maldoc):
# Read in the 2007+ cells.
color_print.output('g', "Analyzing Excel 2007+ file ...")
workbook_info = XLM.excel2007.read_excel_2007_XLM(maldoc)
color_print.output('g', "Extracted XLM from ZIP archive.")
if (workbook_info is None):
return (None, None, None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_97(maldoc):\n\n # Run olevba on the file and extract the XLM macro code lines.\n color_print.output('g', \"Analyzing Excel 97 file ...\")\n xlm_code = _extract_xlm(maldoc)\n color_print.output('g', \"Extracted XLM with olevba.\")\n if debug:\n print(\"=========== START RAW ... | [
"0.72741294",
"0.7015034",
"0.69145006",
"0.5732033",
"0.5640195",
"0.55930376",
"0.5567607",
"0.556654",
"0.5291013",
"0.5264286",
"0.510124",
"0.5087777",
"0.503987",
"0.50384337",
"0.5029056",
"0.50221443",
"0.5013305",
"0.5012877",
"0.50087535",
"0.49634397",
"0.49184382"... | 0.7939801 | 0 |
Read in an Excel 97 workbook and the XLM macros in the workbook. maldoc (str) The fully qualified name of the Excel file to analyze. (tuple) A 3 element tuple where the 1st element is the workbook object, the 2nd element is a list of XLM cell indices ((row, column) tuples) and the 3rd element is a sheet element for the... | def _read_workbook_97(maldoc):
# Run olevba on the file and extract the XLM macro code lines.
color_print.output('g', "Analyzing Excel 97 file ...")
xlm_code = _extract_xlm(maldoc)
color_print.output('g', "Extracted XLM with olevba.")
if debug:
print("=========== START RAW XLM =============... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_2007(maldoc):\n\n # Read in the 2007+ cells.\n color_print.output('g', \"Analyzing Excel 2007+ file ...\")\n workbook_info = XLM.excel2007.read_excel_2007_XLM(maldoc) \n color_print.output('g', \"Extracted XLM from ZIP archive.\")\n if (workbook_info is None):\n return (... | [
"0.79433113",
"0.72427917",
"0.7036231",
"0.5774751",
"0.57168466",
"0.5638217",
"0.563626",
"0.5588673",
"0.53787875",
"0.5337786",
"0.5189825",
"0.5149428",
"0.51007754",
"0.5068647",
"0.5065638",
"0.5052728",
"0.5047861",
"0.5045103",
"0.5043639",
"0.5033287",
"0.49730438"... | 0.7649732 | 1 |
Emulate the behavior of a given Excel file containing XLM macros. maldoc (str) The fully qualified name of the Excel file to analyze. (tuple) 1st element is a list of 3 element tuples containing the actions performed by the sheet, 2nd element is the human readable XLM code. | def emulate(maldoc):
# Excel 97 file?
if (XLM.utils.is_excel_file_97(maldoc)):
workbook, xlm_cell_indices, xlm_sheet = _read_workbook_97(maldoc)
if (workbook is None):
color_print.output('r', "ERROR: Reading Excel 97 file failed. Emulation aborted.")
return ([], "")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_workbook_2007(maldoc):\n\n # Read in the 2007+ cells.\n color_print.output('g', \"Analyzing Excel 2007+ file ...\")\n workbook_info = XLM.excel2007.read_excel_2007_XLM(maldoc) \n color_print.output('g', \"Extracted XLM from ZIP archive.\")\n if (workbook_info is None):\n return (... | [
"0.6723555",
"0.6653062",
"0.6573594",
"0.5674583",
"0.50879794",
"0.4930489",
"0.49133873",
"0.47957298",
"0.4716508",
"0.4700348",
"0.46856138",
"0.46792737",
"0.46772945",
"0.45869985",
"0.4560465",
"0.45124787",
"0.4482203",
"0.44816422",
"0.44635886",
"0.44590777",
"0.44... | 0.74941033 | 0 |
import settings for websocket client integration from an XML file | def importWebSocketClientSettings(context):
site = context.getSite()
utility = queryUtility(IWebSocketConnectionConfig, context=site)
if utility is None:
logger = context.getLogger('collective.websocketclient')
logger.info('Nothing to import.')
return
if IPersistent.providedBy(ut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_settings(self):\n # Set the default settings. In case in a later version of this script the settings change, new default variables will be added automatically\n self.settings = {\n # Connection settings to OBS Studio websockets plugin\n \"host\": \"localhost\",\... | [
"0.58948606",
"0.57333976",
"0.5718949",
"0.54858726",
"0.54734534",
"0.5444267",
"0.5406738",
"0.53434104",
"0.52570355",
"0.525459",
"0.52514964",
"0.5226953",
"0.5206524",
"0.520246",
"0.5165548",
"0.50997484",
"0.50673604",
"0.50673604",
"0.5064736",
"0.50557166",
"0.5043... | 0.6708304 | 0 |
export settings for websocket client integration as an XML file | def exportWebSocketClientSettings(context):
site = context.getSite()
utility = queryUtility(IWebSocketConnectionConfig, context=site)
if utility is None:
logger = context.getLogger('collective.websocketclient')
logger.info('Nothing to export.')
return
if IPersistent.providedBy(ut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_config_xml_to_broker(self):\n xmlObject = xml.dom.minidom.parse(\"config_setup.xml\")\n pretty_xml_as_string = xmlObject.toprettyxml()\n self.client.publish(\"users/everyone/inbox/server/deviceList\", pretty_xml_as_string)\n print(\"XML config sent.\")",
"def write_config(sel... | [
"0.6345738",
"0.59505016",
"0.5862077",
"0.5750333",
"0.5711413",
"0.566478",
"0.5633414",
"0.55401486",
"0.5536291",
"0.5536282",
"0.5519001",
"0.5490517",
"0.54668343",
"0.54395074",
"0.5418738",
"0.54035866",
"0.5395367",
"0.5363175",
"0.5324485",
"0.5318015",
"0.5297074",... | 0.7233053 | 0 |
A function to react to key being pressed on an image canvas. | def doSomething(imp, keyEvent):
IJ.log("clicked keyCode " + str(keyEvent.getKeyCode()) + " on image " + | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onKeyPress(self, widget, event):\n\t\t#print event.hardware_keycode\n\t\tif event.hardware_keycode in [102,100,98,104] and self.fullscreenToggle:\n\t\t\t# Binding: arrow keys: move image (Fs)\n\t\t\t# Binding: arrow keys+Shift: move image faster (Fs)\n\t\t\tif event.state & gtk.gdk.SHIFT_MASK:\n\t\t\t\tamount... | [
"0.6845082",
"0.68138224",
"0.68048865",
"0.6795043",
"0.6732254",
"0.66485685",
"0.6618535",
"0.65895975",
"0.65495425",
"0.65127254",
"0.64510345",
"0.64482975",
"0.6427912",
"0.6411434",
"0.64104617",
"0.63843274",
"0.6371269",
"0.6336644",
"0.63249564",
"0.63180494",
"0.6... | 0.70632905 | 0 |
Returns whether a metric is considered healthy Function compares the metric mapped to by key it was initialized with | def is_healthy(self, metric_results):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def check_health():\n return {\"healthy\": True}",
"def is_healthy(self) -> bool:\n try:\n self.health()\n except MeiliSearchError:\n return False\n return True",
"def is_healthy(self) -> bool:\n return False",
"def healthy(self) -> bool:\n re... | [
"0.6246055",
"0.6168581",
"0.60983115",
"0.6049883",
"0.6007633",
"0.5973169",
"0.59227043",
"0.5918034",
"0.58422655",
"0.5830914",
"0.5814101",
"0.58081686",
"0.5798145",
"0.5791956",
"0.57410717",
"0.57409346",
"0.56640285",
"0.56574523",
"0.5646705",
"0.56458324",
"0.5634... | 0.67867005 | 0 |
This method will return the closest point index for a given point P from list of points given in centers | def closestCluster(p, centers):
bestIndex = 0
closest = float("+inf")
for i in range(len(centers)):
distance = np.sqrt(np.sum((np.array(p) - centers[i]) ** 2))
if distance < closest:
closest = distance
bestIndex = i
return bestIndex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closestClusterAndDistance(p, centers):\n\tbestIndex = 0\n closest = float(\"+inf\")\n for i in range(len(centers)):\n distance = np.sqrt(np.sum((np.array(p) - centers[i]) ** 2))\n if distance < closest:\n closest = distance\n bestIndex = i\n ... | [
"0.81604385",
"0.7818576",
"0.76468176",
"0.7452406",
"0.7312577",
"0.7209503",
"0.7146841",
"0.7022789",
"0.7015073",
"0.69740677",
"0.69587153",
"0.69570583",
"0.6940364",
"0.6904534",
"0.6889646",
"0.68861485",
"0.685346",
"0.68314093",
"0.6825442",
"0.6790361",
"0.6773268... | 0.8303884 | 0 |
This method will return the closest point index and its ditance for a given point P from list of points given in centers | def closestClusterAndDistance(p, centers):
bestIndex = 0
closest = float("+inf")
for i in range(len(centers)):
distance = np.sqrt(np.sum((np.array(p) - centers[i]) ** 2))
if distance < closest:
closest = distance
bestIndex = i
return (best... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closestCluster(p, centers):\n\tbestIndex = 0\n closest = float(\"+inf\")\n for i in range(len(centers)):\n distance = np.sqrt(np.sum((np.array(p) - centers[i]) ** 2))\n if distance < closest:\n closest = distance\n bestIndex = i\n\treturn bestIn... | [
"0.80020124",
"0.7691775",
"0.7506859",
"0.7360311",
"0.7189735",
"0.71564335",
"0.71380126",
"0.71302176",
"0.69669247",
"0.6954315",
"0.6937151",
"0.6917281",
"0.6860945",
"0.6839078",
"0.67988765",
"0.67920554",
"0.6790271",
"0.6789571",
"0.6771405",
"0.67593086",
"0.67492... | 0.80924296 | 0 |
train method will take dataframe as an input and returns centers using kmeans algorithm with L2 distance | def train(self, data):
epsilon = self.epsilon
tempDist = 1.0
k = self.k
centers = data.rdd.takeSample(False, k, 1)
i = 0
while tempDist > epsilon or self.maxNoOfIteration > i:
i+=1
closest = data.map(lambda p: (closestCluster(p, centers), (np.array(p), 1)))
pointStats = closest.reduceByK... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def k_means_model(df, numOfClusters):\n # Perform scaling on the dataframe containing the selected features\n data = scale(df)\n\n # Train a model\n model = KMeans(init=\"k-means++\", n_clusters=numOfClusters, n_init=20).fit(data)\n return model",
"def calculate_kmeans(df, clusters=10):\r\n kme... | [
"0.71723557",
"0.691053",
"0.6901916",
"0.6852868",
"0.68385345",
"0.68138105",
"0.67475885",
"0.6669792",
"0.65544796",
"0.6422493",
"0.64189833",
"0.6411663",
"0.63902324",
"0.6388245",
"0.63098115",
"0.6305227",
"0.6287323",
"0.6283454",
"0.62477034",
"0.62462896",
"0.6237... | 0.7532827 | 0 |
returns the index of the closest cluster and its distance for a given data point data | def clusterAndDistance(self, data):
return closestClusterAndDistance(data, self.centers) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closestClusterAndDistance(p, centers):\n\tbestIndex = 0\n closest = float(\"+inf\")\n for i in range(len(centers)):\n distance = np.sqrt(np.sum((np.array(p) - centers[i]) ** 2))\n if distance < closest:\n closest = distance\n bestIndex = i\n ... | [
"0.7288707",
"0.7270212",
"0.72385883",
"0.71241885",
"0.7107449",
"0.70917314",
"0.7035779",
"0.6971508",
"0.6815752",
"0.65985656",
"0.65984434",
"0.6574564",
"0.6555377",
"0.6491588",
"0.6482346",
"0.6465322",
"0.6464889",
"0.6460569",
"0.64458454",
"0.64357096",
"0.643149... | 0.8121391 | 0 |
Filter annsets to annotations overlapping candidate. | def filter_to_candidate(self):
filtered = { k: [] for k in self.annsets }
for key, annset in self.annsets.items():
for a in annset:
if a.overlaps(self.candidate):
filtered[key].append(a)
self.annsets = filtered | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlap(annotations1, annotations2):\n return [val for val in annotations1 if val in annotations2]",
"def overlapping_aids(self, gid, region, visible_thresh=0.0):\n overlap_aids = self.isect_index.overlapping_aids(gid, region)\n if visible_thresh > 0 and len(overlap_aids) > 0:\n #... | [
"0.6370355",
"0.58862954",
"0.56585723",
"0.5642055",
"0.5398902",
"0.5389672",
"0.5317603",
"0.5258657",
"0.5253353",
"0.5193474",
"0.5176536",
"0.51494116",
"0.51470774",
"0.5127493",
"0.51185286",
"0.51145107",
"0.5083101",
"0.50759697",
"0.5057774",
"0.50500035",
"0.50029... | 0.77305436 | 0 |
Get collection contents organized by file extension. | def _get_contents_by_ext(self, collection):
contents_by_ext = defaultdict(list)
collection_dir = os.path.join(self.root_dir, collection)
for name in sorted(os.listdir(collection_dir)):
path = os.path.join(collection_dir, name)
if os.path.isfile(path):
root... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_contents_with_ext(self, ext):\n for filename in self.project.namelist():\n if filename.endswith('.'+ext):\n contents = self.project.open(filename, 'r')\n return contents\n return None",
"def content(self, extensionFilter=[]):\r\n\r\n if self.... | [
"0.6799076",
"0.6698243",
"0.62939227",
"0.5981953",
"0.597571",
"0.5942609",
"0.5938336",
"0.5910077",
"0.5861005",
"0.5847813",
"0.58334965",
"0.58313465",
"0.5780494",
"0.5774376",
"0.57720035",
"0.57720035",
"0.57720035",
"0.5757031",
"0.5736017",
"0.5729282",
"0.57288516... | 0.84675837 | 0 |
Since EXPN isn't implemented by aiosmtpd, it raises an exception by default. | async def test_expn_error(
smtp_client: SMTP, smtpd_server: asyncio.AbstractServer
) -> None:
async with smtp_client:
with pytest.raises(SMTPResponseException):
await smtp_client.expn("a-list") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_connect_fail(self):\n with pytest.raises(InstrumentGatewayError):\n with InstrumentGateway(addr='an invalid ip!'):\n pass",
"def test_invalid_host_expression_prop(self):\n block = SNMPBase()\n block._create_data = MagicMock()\n block.execute_request ... | [
"0.5509301",
"0.54383117",
"0.5364098",
"0.5273363",
"0.5237218",
"0.52316636",
"0.5167674",
"0.5159681",
"0.5133844",
"0.51326466",
"0.51005864",
"0.5098053",
"0.5096402",
"0.50824183",
"0.50808847",
"0.5040562",
"0.5016725",
"0.4992853",
"0.49822763",
"0.4979743",
"0.495856... | 0.5898231 | 0 |
Test destination name if valid. | def valid_destination_name(destination):
regex = "^[a-zA-Z0-9_ ]{1,}$"
return re.match(regex, destination) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_name(name):\r\n\tif HOST_NAME != name and len(name) > 0 and ZOOM_PHRASES[0] not in name and name not in WAITING_ROOM:\r\n\t\treturn True\r\n\treturn False",
"def _check_name(self):\n\t\tpass",
"def check_name(self, name: str):\n if name[0] == \"/\" or self.check_end_streaming(name):\n ... | [
"0.6535112",
"0.6483265",
"0.645965",
"0.643167",
"0.64052624",
"0.6389805",
"0.6371145",
"0.6364668",
"0.6258072",
"0.61742145",
"0.61726576",
"0.614411",
"0.61119163",
"0.6093495",
"0.60323554",
"0.60181886",
"0.60100025",
"0.6006968",
"0.59973705",
"0.5990156",
"0.5984307"... | 0.8409464 | 0 |
Load the model, training and evaluation configs for PET from the given command line arguments. | def load_pet_configs(args) -> Tuple[WrapperConfig, pet.TrainConfig, pet.EvalConfig]:
model_cfg = WrapperConfig(model_type=args.model_type, model_name_or_path=args.model_name_or_path,
wrapper_type=args.wrapper_type, task_name=args.task_name, label_list=args.label_list,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_args():\n hpo_warning = 'Flag overwrites config value if set, used for HPO and PBT runs primarily'\n parser = argparse.ArgumentParser('train.py')\n add_arg = parser.add_argument\n add_arg('config', nargs='?', default='configs/hello.yaml')\n add_arg('-d', '--distributed', choices=['ddp-file... | [
"0.64883953",
"0.6423853",
"0.6339392",
"0.63173246",
"0.63055223",
"0.6296296",
"0.6258348",
"0.6205302",
"0.6176762",
"0.61579216",
"0.61514276",
"0.61273324",
"0.6091553",
"0.6090854",
"0.60844326",
"0.608109",
"0.6078909",
"0.607694",
"0.6071167",
"0.60487896",
"0.6036241... | 0.6690745 | 0 |
Load the model, training and evaluation configs for a regular sequence classifier from the given command line arguments. This classifier can either be used as a standalone model or as the final classifier for PET/iPET. | def load_sequence_classifier_configs(args) -> Tuple[WrapperConfig, pet.TrainConfig, pet.EvalConfig]:
model_cfg = WrapperConfig(model_type=args.model_type, model_name_or_path=args.model_name_or_path,
wrapper_type=SEQUENCE_CLASSIFIER_WRAPPER, task_name=args.task_name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(command_line_parameters=None):\n args = command_line_arguments(command_line_parameters)\n\n logger.debug(\"Loading preprocessor\")\n preprocessor = bob.bio.base.load_resource(' '.join(args.preprocessor), \"preprocessor\")\n logger.debug(\"Loading extractor\")\n extractor = bob.bio.base.load_resource(... | [
"0.6719115",
"0.64597875",
"0.64026177",
"0.6383858",
"0.6353411",
"0.6342971",
"0.6329676",
"0.62917",
"0.61846244",
"0.6178162",
"0.61706626",
"0.6156029",
"0.61509514",
"0.61228794",
"0.61039567",
"0.6080009",
"0.6074509",
"0.60659707",
"0.603283",
"0.602758",
"0.59777206"... | 0.67100024 | 1 |
Load the iPET config from the given command line arguments. | def load_ipet_config(args) -> pet.IPetConfig:
ipet_cfg = pet.IPetConfig(generations=args.ipet_generations, logits_percentage=args.ipet_logits_percentage,
scale_factor=args.ipet_scale_factor, n_most_likely=args.ipet_n_most_likely)
return ipet_cfg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(args):\n load_args={}\n with open(args.config, 'r') as f:\n for line in f:\n key, value = line.strip().split('=')\n try:\n value = int(value)\n except ValueError:\n try:\n value = float(value)\n ... | [
"0.6620625",
"0.65885556",
"0.65620697",
"0.6530543",
"0.65282035",
"0.65250957",
"0.63654464",
"0.63244563",
"0.62861556",
"0.6278691",
"0.62023723",
"0.6184847",
"0.61702293",
"0.61346585",
"0.6072536",
"0.6040853",
"0.6028272",
"0.6002226",
"0.5997254",
"0.59311545",
"0.59... | 0.6928259 | 0 |
Train or update a spaCy model. Requires data to be formatted in spaCy's JSON format. To convert data from other formats, use the `spacy convert` command. | def train(
# fmt: off
lang: ("Model language", "positional", None, str),
output_path: ("Output directory to store model in", "positional", None, Path),
train_path: ("Location of JSON-formatted training data", "positional", None, Path),
dev_path: ("Location of JSON-formatted development data", "posit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_nlu(data, config, model_dir):\n # Read the config_spacy.json as JSON \n with open(config) as f: config = json.load(f)\n\n training_data = load_data(data)\n trainer = Trainer(RasaNLUModelConfig(config))\n trainer.train(training_data)\n\n model_directory = trainer.persist(model_dir, fixed... | [
"0.6168623",
"0.60145473",
"0.59643066",
"0.59500396",
"0.59390277",
"0.5891947",
"0.58586216",
"0.58549035",
"0.5753519",
"0.569553",
"0.5639808",
"0.5621899",
"0.56205606",
"0.561257",
"0.56034636",
"0.55959255",
"0.559412",
"0.5584512",
"0.55254185",
"0.54839414",
"0.54839... | 0.7009214 | 0 |
Returns mean score between tasks in pipeline that can be used for early stopping. | def _score_for_model(meta):
mean_acc = list()
pipes = meta["pipeline"]
acc = meta["accuracy"]
if "tagger" in pipes:
mean_acc.append(acc["tags_acc"])
if "morphologizer" in pipes:
mean_acc.append((acc["morphs_acc"] + acc["pos_acc"]) / 2)
if "parser" in pipes:
mean_acc.appen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avgcpu(self):\n return (self._total_cpu['value'] / self._total_cpu['count']) if self._total_cpu['count'] else 0",
"def score(self, task):\n raise NotImplementedError(\"must subclass and implement score(task)\")",
"def getAverage(self):\n return sum(self.scores) / len(self.scores)",
"... | [
"0.6135161",
"0.60931313",
"0.60613865",
"0.5927177",
"0.5919117",
"0.59168655",
"0.58380854",
"0.58222544",
"0.5811924",
"0.57893497",
"0.5779506",
"0.57702696",
"0.5763837",
"0.5745407",
"0.57277334",
"0.5717946",
"0.571239",
"0.568665",
"0.567822",
"0.567822",
"0.567822",
... | 0.6233691 | 0 |
Load pretrained weights for the 'tokentovector' part of the component models, which is typically a CNN. See 'spacy pretrain'. Experimental. | def _load_pretrained_tok2vec(nlp, loc):
with loc.open("rb") as file_:
weights_data = file_.read()
loaded = []
for name, component in nlp.pipeline:
if hasattr(component, "model") and component.model.has_ref("tok2vec"):
component.get_ref("tok2vec").from_bytes(weights_data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(self):\n if self.ckpt_flag:\n LOG('Skip Loading Pre-trained Model......')\n else:\n if self.params.pre_trained_from is not None and os.path.exists(self.params.pre_trained_from):\n try:\n LOG('Loading Pre-trained Model at %s' % sel... | [
"0.6386861",
"0.63678175",
"0.6225031",
"0.62216717",
"0.61162937",
"0.6101295",
"0.6054075",
"0.6042603",
"0.6018365",
"0.59910965",
"0.59458715",
"0.5943918",
"0.59387076",
"0.5920058",
"0.5915071",
"0.59099936",
"0.59086907",
"0.5901546",
"0.59015244",
"0.58882916",
"0.588... | 0.6853876 | 0 |
Check that t is a tree, with the correct interla structure. (Helper function not a unit test.) | def isTree(self, t):
if type(t) != tree:
return False;
if not hasattr(t, "label"):
return False;
if type(t.label) != str:
return False;
if not hasattr(t, "children"):
return False;
if type(t.children) != list:
return Fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_tree(t):\n if type(t) != list or len(t) < 1:\n return False\n elif is_leaf(t):\n return True\n else:\n return all([is_tree(b) for b in t[1:]])",
"def test01(self):\n\n t = tree(\"a\", [tree(\"b\"), tree(\"c\")]);\n self.assertTrue(self.isTree(t))",
"def test_t... | [
"0.7773105",
"0.7650496",
"0.7045109",
"0.7035572",
"0.6966886",
"0.6953431",
"0.69326895",
"0.68154866",
"0.680478",
"0.6793031",
"0.66768706",
"0.6661258",
"0.6602542",
"0.6554972",
"0.6527791",
"0.6508529",
"0.65084046",
"0.65048134",
"0.64875036",
"0.6486214",
"0.64814633... | 0.7827654 | 0 |
Test that a tree has the correct internal structure | def test01(self):
t = tree("a", [tree("b"), tree("c")]);
self.assertTrue(self.isTree(t)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Tree():",
"def test_tree_with_one_node_has_correct_value(one_t):\n assert one_t.root.value == 10",
"def test_small_tree_has_root_value(small_tree):\n assert small_tree.root.right.value == 11",
"def test_children_tree(depth_one_tree):\n assert str(depth_one_tree.root.children) == str([1, 2, ... | [
"0.8074132",
"0.75645053",
"0.75372213",
"0.75328934",
"0.7508595",
"0.74147695",
"0.7401527",
"0.73936456",
"0.7295448",
"0.7258387",
"0.72362375",
"0.7197044",
"0.7170132",
"0.71507156",
"0.7150426",
"0.71499306",
"0.71315193",
"0.70960915",
"0.708435",
"0.7022881",
"0.7012... | 0.80878603 | 0 |
Test parse_newick on a singlenode tree representation. | def test04(self):
s = "a;"
t = parse_newick(s);
self.assertTrue(self.isTree(t) and t.label == "a" and t.isLeaf()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tree_support(self):\r\n master_tree = parse_newick('((a:2,b:3)ab:2,(c:1,d:2)cd:7)rt;')\r\n \"\"\"\r\n /-------.5 /-a\r\n ---1| \\-b\r\n \\------.5 /-c\r\n \\-d\r\n \"\"\"\r\n t2 = parse_newick('((a:2,b:3,c:33)ho:2,d... | [
"0.67046046",
"0.66692567",
"0.6668407",
"0.6530691",
"0.64476365",
"0.64186615",
"0.6259178",
"0.6180899",
"0.6084381",
"0.60290694",
"0.6021466",
"0.600306",
"0.5996744",
"0.5918722",
"0.5868246",
"0.58530134",
"0.57235086",
"0.56478876",
"0.5604132",
"0.55337864",
"0.55275... | 0.76883775 | 0 |
Test that parse_newick throws the right kind of exception when the ; is missing. | def test05(self):
s = "a"
with self.assertRaises(ParserException):
t = parse_newick(s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_start_open_parens(self):\n self.assertRaises(ValueError, NewickTokenizer, newick='hi')",
"def test_extra_closed(self):\n nt = NewickTokenizer(newick='(a,(b,c)));')\n self.assertRaises(ValueError, nt.tokens)",
"def test_unclosed_comment(self):\n nt = NewickTokenizer(newic... | [
"0.71277916",
"0.6992496",
"0.6932686",
"0.69308096",
"0.67307556",
"0.6727998",
"0.6665779",
"0.65718716",
"0.6517503",
"0.63459533",
"0.6345652",
"0.62765884",
"0.6201289",
"0.6190885",
"0.61274683",
"0.6123086",
"0.6117942",
"0.61088365",
"0.6092642",
"0.6080887",
"0.60476... | 0.75182545 | 0 |
This function parses arguments like argv and returns a dictionary with keys action tags | def parse_arguments(args): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_args(argv):\n result = {}\n for arg in argv:\n k, v = arg.split(\"=\")\n result[k] = v\n return result",
"def retrieve_args_dict():\n process_args = sys.argv[1:]\n dictionary = dict()\n for process_arg in process_args:\n splitted = process_arg.split(\":\")\n if len(spli... | [
"0.656502",
"0.64459336",
"0.64356583",
"0.6318063",
"0.6279127",
"0.62615263",
"0.6145342",
"0.6143788",
"0.6119476",
"0.60930604",
"0.60857743",
"0.6077435",
"0.60595834",
"0.60482275",
"0.60474616",
"0.6030172",
"0.6011784",
"0.59997857",
"0.598045",
"0.5979317",
"0.597013... | 0.65210056 | 1 |
returns the budget for the defined tag | def budget(config, tag):
if tag in config["budget"].keys():
print(tag)
else:
print(config["budget"].keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def budget(self):\n return self._budget",
"def getBudget(movieInfo):\n if \"budget\" in movieInfo:\n return int(movieInfo[\"budget\"])\n else:\n raise AttributeError(\"%s instance has no attribute budget\" % movieInfo)",
"def get_budget(self, category: BudgetCategory) -> Budget:\n ... | [
"0.7083501",
"0.65791714",
"0.6482024",
"0.63894933",
"0.6077988",
"0.58800274",
"0.5838075",
"0.58222085",
"0.5746922",
"0.5691997",
"0.5674798",
"0.56654537",
"0.5650313",
"0.56176656",
"0.55753535",
"0.55744225",
"0.5489822",
"0.53618115",
"0.53394234",
"0.5320373",
"0.531... | 0.719083 | 0 |
Initialize data generators. This function assumes the wrapped model to have `._data` field. | def initialize_data_iterator(self, model_idx=None):
if model_idx and not isinstance(model_idx, (list, tuple)):
raise TypeError("`model_idx` must be list-like structure")
model_indices = (
# if model_idx is None
# model_idx = [all_models_indices]
model_idx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_model(self):\n pass",
"def initialize_model(self):\n pass",
"def initialize(self, model):\n pass",
"def init_from_data(self, data):\n self.data = data\n self.norm_data()",
"def __init__(self, model: Any, data: Iterable[Any]):\n super().__init__(model, data... | [
"0.6300777",
"0.62807715",
"0.6212327",
"0.61153483",
"0.61078835",
"0.6094563",
"0.60931665",
"0.6075413",
"0.59868747",
"0.59868747",
"0.59868747",
"0.59868747",
"0.5954239",
"0.5919463",
"0.5886439",
"0.58657",
"0.58602965",
"0.5820341",
"0.58048314",
"0.5776811",
"0.57676... | 0.660022 | 0 |
Run python version inside of a docker image and get its semantic version number. | def get_python_version(self, dock_image: str) -> str:
# version string typically looks like: "Python 3.9.2"
# But other variations exist such as: "Python 3.6.9 :: Anaconda, Inc."
# and for whatever reason, the conda version prints to stderr instead...
python_version_string: str = check_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_python_version(user_image, python_binary) -> packaging.version.Version:\n\n proc = await asyncio.create_subprocess_exec(\n \"docker\",\n \"run\",\n \"--rm\",\n user_image,\n python_binary,\n \"--version\",\n stdout=subprocess.PIPE,\n stderr=... | [
"0.7416897",
"0.6631516",
"0.6582976",
"0.65689105",
"0.65503365",
"0.6505324",
"0.6406864",
"0.6402115",
"0.6245161",
"0.62432474",
"0.62357765",
"0.6217067",
"0.6191909",
"0.613984",
"0.6055866",
"0.6053228",
"0.5995903",
"0.5990503",
"0.5981206",
"0.59631395",
"0.59099054"... | 0.67462885 | 1 |
Attempt to find the resource directory for the python package of the ChRIS plugin. It usually looks like /usr/local/lib/python3.9/sitepackages/something If unsuccessful, return empty string. | def find_resource_dir(self, dock_image: str, meta: dict) -> str:
try:
return self.interrogate_python_package_location(dock_image, meta)
except CalledProcessError:
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource(self, rsc_path):\n\n\t\ttry:\n\t\t\tfrom pkg_resources import resource_filename\n\t\t\treturn resource_filename(__name__, rsc_path)\n\t\texcept ImportError:\n\t\t\treturn os.path.join(os.path.dirname(__file__), rsc_path)",
"def get_package_dir():\n return Path(__file__).parent",
"def _get_d... | [
"0.6721056",
"0.6668326",
"0.6601748",
"0.6568538",
"0.6526997",
"0.64291966",
"0.63636035",
"0.63410276",
"0.62239856",
"0.6217715",
"0.6213123",
"0.6172258",
"0.6157969",
"0.61543185",
"0.613424",
"0.61182326",
"0.60999566",
"0.6063436",
"0.6055837",
"0.60502505",
"0.604980... | 0.70710635 | 0 |
Script to clean a given case. | def main():
args = read_inputs()
Case(args.path)
print 'case path: %s' % Case.path
print '[info]: cleaning mesh and force coefficients'
os.system('rm -f '+Case.path+'/*.dat')
print '[info]: cleaning solution folders'
for i in xrange(10):
os.system('rm -rf '+Case.path+'/'+str(i)+'*')
print '[info]: cleanin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(c):",
"def RemoveCase(dirc):\n if os.path.exists(dirc):\n shutil.rmtree(dirc)\n #subprocess.call(['rm', '-r', dirc])",
"def clean(_context):",
"def hxlclean():\n run_script(hxlclean_main)",
"async def clearcases(self, ctx, problem_name):\n if not await problem_exists(ctx, p... | [
"0.6394602",
"0.6388809",
"0.5800998",
"0.56710964",
"0.56026864",
"0.5589458",
"0.5588989",
"0.55696267",
"0.55633765",
"0.55631894",
"0.55501896",
"0.5522124",
"0.5501598",
"0.54972",
"0.543099",
"0.53682435",
"0.530929",
"0.53045577",
"0.52781314",
"0.52335",
"0.5228231",
... | 0.669353 | 0 |
Create a new API class for your application. 'root' shoudl be your base route, and routes is a mapping of routeshortname > path suffix for your API. | def API(root, **routes):
# this creats a dict of properties that create Senders for
# all the friendly name --> suffix combidantions passed in
props = {'root': Route(root)}
for (short, path) in routes.iteritems():
props[short] = lambda self, content: self.sender.send_path(path, content)
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app():\r\n app = Flask(__name__, instance_relative_config=False)\r\n app.config.from_object('config.Config') \r\n \r\n api = Api(app) \r\n \r\n with app.app_context():\r\n from .flights import TicketRoute, FlightRoute\r\n api.add_resource(TicketRoute,\"/api/ticket... | [
"0.73801404",
"0.7200694",
"0.71829164",
"0.6970352",
"0.671085",
"0.67097706",
"0.67093503",
"0.6705557",
"0.6694073",
"0.66517067",
"0.6583034",
"0.6547196",
"0.64564484",
"0.64072907",
"0.6406355",
"0.6401527",
"0.63456136",
"0.63084906",
"0.62602186",
"0.6221953",
"0.6214... | 0.75148106 | 0 |
function to patch over exit_json; package return data into an exception | def exit_json(*args, **kwargs):
if 'changed' not in kwargs:
kwargs['changed'] = False
raise AnsibleExitJson(kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cli_format_error_handler_broken_json():\n resp = MagicMock()\n resp.json.side_effect = ValueError(\"\")\n resp.text = \"Not JSON\"\n output = format_utils.cli_format_error_handler(resp)\n assert 'Error: Unable to decode response. Value: Not JSON' in output",
"def test_cli_format_error_han... | [
"0.6422005",
"0.6011262",
"0.58930314",
"0.5873814",
"0.5736965",
"0.5635676",
"0.55465096",
"0.5507798",
"0.55060387",
"0.5482061",
"0.54793316",
"0.547902",
"0.54240453",
"0.5421341",
"0.5397868",
"0.539718",
"0.53748244",
"0.53737676",
"0.5362257",
"0.53568584",
"0.5345366... | 0.70887923 | 0 |
function to patch over fail_json; package return data into an exception | def fail_json(*args, **kwargs):
kwargs['failed'] = True
raise AnsibleFailJson(kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cli_format_error_handler_broken_json():\n resp = MagicMock()\n resp.json.side_effect = ValueError(\"\")\n resp.text = \"Not JSON\"\n output = format_utils.cli_format_error_handler(resp)\n assert 'Error: Unable to decode response. Value: Not JSON' in output",
"def process_json(self, data):... | [
"0.7065039",
"0.6566227",
"0.655377",
"0.6433542",
"0.6402148",
"0.6363974",
"0.63553065",
"0.63401806",
"0.62943906",
"0.6246136",
"0.6231559",
"0.62160605",
"0.6212979",
"0.61676127",
"0.6163638",
"0.6131823",
"0.60966325",
"0.6095224",
"0.60862505",
"0.60569715",
"0.604183... | 0.71612245 | 0 |
Return a new yard. | def create(request: YardRequestCreate) -> Yard:
logger.debug(f'Executing Yard create with request:{request}')
return Yard(request.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rythm(self, dev):\n new_rythm = rythm.Rythm()\n new_rythm.rythm_from_distr(duration, self.density)\n\n return new_rythm",
"def __init__(self, name: str, yard_id: Optional[int] = None) -> None:\n self._name = name\n if yard_id:\n self._yard_id = yard_id",
... | [
"0.5590437",
"0.54014885",
"0.5362551",
"0.53325903",
"0.5188523",
"0.5162973",
"0.50443614",
"0.50316876",
"0.50179154",
"0.50179154",
"0.49858508",
"0.49775422",
"0.49506262",
"0.4945812",
"0.48390582",
"0.48362887",
"0.48228404",
"0.482089",
"0.48181245",
"0.47931927",
"0.... | 0.7020021 | 0 |
Return a new garden. | def create(request: GardenRequestCreate) -> Garden:
if request.yard_id:
garden = Garden(request.name, request.yard_id)
else:
garden = Garden(request.name)
return garden | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(request: BedRequestCreate) -> Bed:\n if request.garden_id:\n bed = Bed(request.name, request.yard_id, request.garden_id)\n else:\n bed = Bed(request.name, request.yard_id)\n return bed",
"def new(cls):\n return cls()",
"def new_room(self):\r\n ... | [
"0.5969182",
"0.55627793",
"0.53683287",
"0.53473854",
"0.53283143",
"0.5322329",
"0.52581275",
"0.5212227",
"0.5196043",
"0.51944935",
"0.51816285",
"0.5158744",
"0.5142977",
"0.5117961",
"0.5069754",
"0.50693375",
"0.50672984",
"0.5046749",
"0.5021479",
"0.5010107",
"0.4999... | 0.7625244 | 0 |
Return a new bed. | def create(request: BedRequestCreate) -> Bed:
if request.garden_id:
bed = Bed(request.name, request.yard_id, request.garden_id)
else:
bed = Bed(request.name, request.yard_id)
return bed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify_bed(fbed, has_header):\n line_gen = reader(fbed, header=False)\n header = line_gen.next() if has_header else None\n fh = open(BedTool._tmp(), \"w\")\n for toks in line_gen:\n new_toks = toks[:3] + [\"Z_Z\".join(toks), \".\",\n toks[5] if len(toks) > 5 ... | [
"0.58296984",
"0.5644907",
"0.5551764",
"0.5321915",
"0.53026086",
"0.52609533",
"0.5244851",
"0.52361184",
"0.51136595",
"0.5104737",
"0.5095381",
"0.50601125",
"0.50565517",
"0.50565517",
"0.50280887",
"0.502569",
"0.49909022",
"0.49824548",
"0.4973729",
"0.49398288",
"0.49... | 0.65561134 | 0 |
Return a new Plant. | def create(request: PlantRequestCreate) -> Plant:
logger.debug(f'Executing Plant create with request:{request}')
return Plant(request.name, request.bed_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_plant(plant_type): # noqa: E501\n global seededPlants\n global tasks\n\n if not seededPlants.get(plant_type):\n seededPlants[plant_type] = 0\n \n pid = db.addPlant(plant_type)\n plant = Plant(plant_id=pid, plant_type=plant_type)\n seededPlants[plant_type] += 1\n\n #clean up ... | [
"0.62443143",
"0.60929143",
"0.6055948",
"0.5976038",
"0.5604454",
"0.558746",
"0.55310094",
"0.54382646",
"0.54322815",
"0.53988934",
"0.53903615",
"0.5373456",
"0.537302",
"0.5348257",
"0.5344622",
"0.5341449",
"0.53242874",
"0.5299267",
"0.52762425",
"0.52678794",
"0.52597... | 0.7463095 | 0 |
Private method that return the right index element from a given level and node. | def _index_list(self, level, node):
if level >= self._max_level:
raise ValueError("Invalid level: greater than `max_level`")
if node >= 2**level:
raise ValueError("Invalid node")
return 2**level + node - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level_to_index(level: int) -> int:\n\n level_data = {\n 15: 1,\n 25: 2,\n 30: 3,\n 35: 4,\n 40: 5,\n 45: 6,\n 50: 7,\n }\n return level_data[level]",
"def right_child_idx(idx):\n return (idx + 1) << 1",
"def tree_idx(tree,j1,J1,J2):\n j = j1\n... | [
"0.6774914",
"0.65624154",
"0.6238155",
"0.62297726",
"0.61812085",
"0.61276853",
"0.61116254",
"0.6070355",
"0.6063867",
"0.60625076",
"0.6038421",
"0.59762305",
"0.5957084",
"0.5940464",
"0.592238",
"0.59021884",
"0.58770186",
"0.5868177",
"0.58489066",
"0.5830463",
"0.5815... | 0.77435327 | 0 |
Find which bins are embedded (partially or totally) in a given time window. | def time_window_bins(self, t0, tend):
indexes = []
for level in range(self._max_level):
for i in range(2**level):
local_times = self.partial_time_interval(level, i)
if t0 >= local_times['t0'] and t0 < local_times['tend']:
indexes.append(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findBins(): \n\n df = pd.read_csv('significantData.csv')\n df = df.sort_values('RecordingTimestamp')\n df.to_csv('significantData.csv', index=False)\n read_in = pd.read_csv('significantData.csv')\n count = 0\n this = []\n return_bins = {}\n word = (read_in['AOI[Neutral_Left]Hit_0']).tol... | [
"0.6001422",
"0.5979062",
"0.594558",
"0.594434",
"0.5746636",
"0.5718944",
"0.57073534",
"0.5705244",
"0.56227374",
"0.56131464",
"0.5604326",
"0.5554541",
"0.54681987",
"0.5468194",
"0.54643685",
"0.5439552",
"0.5434822",
"0.54274553",
"0.54239434",
"0.54058325",
"0.5384072... | 0.66132635 | 0 |
Get the eigenvalues relative to the modes of the bins embedded (partially or totally) in a given time window. | def time_window_eigs(self, t0, tend):
indexes = self.time_window_bins(t0, tend)
return np.concatenate([self.operator.eigenvalues[idx]
for idx in indexes]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigenvalues(self) -> ndarray:\n return self._vals",
"def energies_kev(self):\n\n if not self.is_calibrated:\n raise UncalibratedError('Spectrum is not calibrated')\n else:\n return bin_centers_from_edges(self.bin_edges_kev)",
"def get_energy_per_eigenmode(self, A,... | [
"0.58370894",
"0.55990386",
"0.5529404",
"0.55293566",
"0.54781204",
"0.5472124",
"0.54494846",
"0.5428456",
"0.5418676",
"0.5387911",
"0.536809",
"0.5356477",
"0.5334652",
"0.5331583",
"0.53295034",
"0.53018385",
"0.5245877",
"0.52443105",
"0.5238841",
"0.5225844",
"0.521438... | 0.65667236 | 0 |
Get the growth rate values relative to the modes of the bins embedded (partially or totally) in a given time window. | def time_window_growth_rate(self, t0, tend):
return self.time_window_eigs(t0, tend).real/self.original_time['dt'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agg_angular_difference_timebins(\n data: np.ndarray, fps: int, time_windows: np.ndarray\n ):\n\n data = np.deg2rad(data)\n results = np.full((data.shape[0], time_windows.shape[0]), 0.0)\n for time_window_cnt in prange(time_windows.shape[0]):\n window_size = int(time_wi... | [
"0.5529094",
"0.5523554",
"0.5503484",
"0.54993916",
"0.5434323",
"0.53816473",
"0.5339452",
"0.53023434",
"0.52874565",
"0.52680075",
"0.52517766",
"0.52330875",
"0.5208008",
"0.51964575",
"0.5183654",
"0.5037942",
"0.5031358",
"0.5001336",
"0.49898788",
"0.49898517",
"0.498... | 0.597104 | 0 |
Get the reconstructed data. | def reconstructed_data(self):
try:
data = np.sum(
np.array([
self.partial_reconstructed_data(i)
for i in range(self._max_level)
]),
axis=0)
except MemoryError:
data = np.array(self.partial_rec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(self):\r\n return self.data.copy()",
"def get_data(self):\n return self.parsed_data",
"def get_data(self): # TODO: add smooth possibility\n return self.data",
"def get_data(self):\n return self.data",
"def get_data(self):\n return self.data",
"def get_data... | [
"0.7384807",
"0.71945983",
"0.71018094",
"0.70430684",
"0.70430684",
"0.70430684",
"0.69570875",
"0.69570875",
"0.6895617",
"0.68922836",
"0.68922836",
"0.68922836",
"0.68922836",
"0.68888223",
"0.6882917",
"0.6882917",
"0.6856862",
"0.6804822",
"0.67907304",
"0.67694813",
"0... | 0.72060883 | 1 |
Get the matrix containing the DMD modes, stored by column. | def modes(self):
return np.hstack(tuple(self.operator.modes)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Dmat(self):\n return self._Dmat_cache",
"def matrix(self):\n return np.matrix(list(self._columns.values()))",
"def all_modes(self):\n\n # Find \"post-proj all modes\"\n # Jump to first value, ignoring text.\n # Move through data, adding it to a list\n # continue o... | [
"0.5767924",
"0.5739843",
"0.56482184",
"0.5603151",
"0.5537699",
"0.55024064",
"0.5490287",
"0.5476487",
"0.546271",
"0.5382778",
"0.5382778",
"0.5339894",
"0.53048295",
"0.5280998",
"0.526192",
"0.5253967",
"0.5238287",
"0.5233126",
"0.52254516",
"0.521381",
"0.52133495",
... | 0.5954592 | 0 |
Return the modes at the specific `level` and at the specific `node`; if `node` is not specified, the method returns all the modes of the given `level` (all the nodes). | def partial_modes(self, level, node=None):
if node:
return self.operator.modes[self._index_list(level, node)]
indeces = [self._index_list(level, i) for i in range(2**level)]
return np.hstack(tuple([self.operator.modes[idx] for idx in indeces])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getnodelevels(self, node_p=None):\n node_p = self.getnodenamed(node_p) # Verify pointer.\n\n node_type = self.getnodetype(node_p)\n nstates = self.getnodenumberstates(node_p)\n if node_type == 1:\n # CONTINUOUS_TYPE\n nlevels = nstates + 1\n else:\n ... | [
"0.5354951",
"0.5319307",
"0.5265018",
"0.5101411",
"0.49746078",
"0.49388418",
"0.48589152",
"0.4831829",
"0.4802974",
"0.47775087",
"0.47509822",
"0.46844825",
"0.4642154",
"0.4642027",
"0.4636629",
"0.46062893",
"0.4591814",
"0.45781466",
"0.45590946",
"0.4550383",
"0.4544... | 0.70844233 | 0 |
Return the eigenvalues of the specific `level` and of the specific `node`; if `node` is not specified, the method returns the eigenvalues of the given `level` (all the nodes). | def partial_eigs(self, level, node=None):
if level >= self._max_level:
raise ValueError(
'The level input parameter ({}) has to be less than the'
'max_level ({}). Remember that the starting index is 0'.format(
level, self._max_level))
if no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigenvalues(self, expand=False, factor=False, simplify=False):\n raise NotImplementedError",
"def eigen_decomp(matrix):\n w = None\n v = None\n ### YOUR CODE HERE\n w,v=np.linalg.eig(matrix)\n ### END YOUR CODE\n return w, v",
"def eigensystem(mat):\n e, v = numpy.linalg.eig(mat... | [
"0.5242461",
"0.5114825",
"0.50866956",
"0.5004184",
"0.49853173",
"0.49390775",
"0.4933429",
"0.4927228",
"0.48673382",
"0.48499873",
"0.48347157",
"0.47743538",
"0.4752944",
"0.47522292",
"0.4748588",
"0.46996492",
"0.46762186",
"0.46594122",
"0.46453482",
"0.4602194",
"0.4... | 0.7101437 | 0 |
Return the reconstructed data computed using the modes and the time evolution at the specific `level` and at the specific `node`; if `node` is not specified, the method returns the reconstructed data of the given `level` (all the nodes). | def partial_reconstructed_data(self, level, node=None):
if level >= self._max_level:
raise ValueError(
'The level input parameter ({}) has to be less than the '
'max_level ({}). Remember that the starting index is 0'.format(
level, self._max_level)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(node):\n shapes = list()\n\n # -- If we have a transform, add any nurbs curves\n # -- from it\n for shape in node.getShapes():\n if isinstance(shape, pm.nt.NurbsCurve):\n shapes.append(shape)\n\n if not shapes:\n return None\n\n # -- Define out output data. Right... | [
"0.48708206",
"0.48325694",
"0.4717103",
"0.46905452",
"0.46058008",
"0.45872766",
"0.45579225",
"0.4549462",
"0.45096028",
"0.45037228",
"0.4485179",
"0.4482341",
"0.44601327",
"0.44452712",
"0.4380473",
"0.43233997",
"0.42929927",
"0.42859843",
"0.42788714",
"0.42265484",
"... | 0.6255533 | 0 |
Embeds an mp4 file in the notebook. | def embed_mp4(filename):
video = open(filename,'rb').read()
b64 = base64.b64encode(video)
tag = '''
<video width="640" height="480" controls>
<source src="data:video/mp4;base64,{0}" type="video/mp4">
Your browser does not support the video tag.
</video>'''.format(b64.decode())
return IPython.display.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_show_video(name, vext='.mp4', ext='.png', loop=True, autoplay=True, controls=True, embed=False, figpath=figpath, **kwargs):\n import os\n from IPython.core.display import display, Image, HTML\n from base64 import b64encode\n\n opts = 'playsinline '\n if loop: opts += 'loop '\n if autoplay:... | [
"0.6405056",
"0.6389918",
"0.624613",
"0.58332616",
"0.5745402",
"0.5608184",
"0.5495171",
"0.547484",
"0.54442585",
"0.53840584",
"0.5354212",
"0.53239614",
"0.5266749",
"0.5199485",
"0.5187718",
"0.51537603",
"0.5122003",
"0.5109699",
"0.5109699",
"0.5109699",
"0.5081165",
... | 0.7854064 | 1 |
Returns a single string summary of the address, separating fields using commas. | def summary(self):
return u", ".join(self.active_address_fields()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_address_string(self):\n output = ''\n if self.address_line_1:\n output += '{}'.format(self.address_line_1)\n if self.address_line_2:\n output += ', {}'.format(self.address_line_2)\n if self.city:\n output += ', {}'.format(self.city)\n if s... | [
"0.78189707",
"0.75865847",
"0.72340244",
"0.7221318",
"0.70897835",
"0.7086217",
"0.7069089",
"0.6952058",
"0.69167846",
"0.6916324",
"0.66950196",
"0.6601282",
"0.6566898",
"0.655473",
"0.65395886",
"0.65120167",
"0.640262",
"0.6396874",
"0.6348964",
"0.6314561",
"0.6234863... | 0.8051104 | 0 |
Join a sequence of fields using the specified separator | def join_fields(self, fields, separator=u", "):
field_values = []
for field in fields:
# Title is special case
if field == 'title':
value = self.get_title_display()
else:
value = getattr(self, field)
field_values.append(valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join(sep, xs):\n return str(sep).join(xs)",
"def join(sep, seq):\n return _to_bytes_or_str_array(\n _vec_string(sep, object_, 'join', (seq,)), seq)",
"def join(items, sep=' ', prefix=None, suffix=None, target=None):\n if target is None:\n target = SQLQuery()\n\n target... | [
"0.69708467",
"0.674667",
"0.65593576",
"0.64647615",
"0.6429916",
"0.6410351",
"0.6325085",
"0.62385356",
"0.6212414",
"0.6085514",
"0.59461766",
"0.59388465",
"0.59145224",
"0.58975995",
"0.5858211",
"0.5847662",
"0.5796375",
"0.5794207",
"0.57875186",
"0.5756469",
"0.57317... | 0.7043287 | 0 |
Save a hash of the address fields | def save(self, *args, **kwargs):
# Save a hash of the address fields so we can check whether two
# addresses are the same to avoid saving duplicates
# self.hash = self.generate_hash()
# Ensure that each user only has one default shipping address
# and billing address
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_object(self, data):\n return Address(**data)",
"def store_address(intent, session):\n sess_data = session.setdefault('attributes', {})\n if not sess_data.get('add_address') and \\\n not sess_data['next_step'] == 'store_address':\n raise RuntimeError('Something went wrong.')\... | [
"0.6370817",
"0.6088569",
"0.60453266",
"0.60335714",
"0.598078",
"0.5959527",
"0.5934991",
"0.5910224",
"0.5907966",
"0.5855384",
"0.58534986",
"0.5826116",
"0.5799289",
"0.5788313",
"0.5712779",
"0.5688992",
"0.5621706",
"0.56182045",
"0.5589447",
"0.5579695",
"0.5579695",
... | 0.69221675 | 0 |
'''Print the first paragraph of the docstring of the decorated function. The paragraph will be printed as a oneliner. May be invoked as a simple, argumentless decorator (i.e. ````) or with named arguments ``color``, ``bold``, ``prefix`` of ``tail`` (eg. ``(color=utils.red, bold=True, prefix=' ')``). | def print_doc1(*args, **kwargs):
# output settings from kwargs or take defaults
color = kwargs.get('color', blue)
bold = kwargs.get('bold', False)
prefix = kwargs.get('prefix', '')
tail = kwargs.get('tail', '\n')
def real_decorator(func):
'''real decorator function'''
@wraps(fun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printHelpFunc(self, func, leadingstrings=None):\n if leadingstrings is None:\n leadingstrings = ['- ', ' ']\n a, idx = 0, None\n for line in func.__doc__.split('\\n'):\n if len(line) == 0:\n continue\n if idx is None:\n idx = ... | [
"0.6182041",
"0.56835043",
"0.5528549",
"0.54951614",
"0.5478067",
"0.54739696",
"0.54724956",
"0.5464363",
"0.5463609",
"0.54350126",
"0.5416408",
"0.5416105",
"0.54136",
"0.53923166",
"0.53778976",
"0.5367521",
"0.5367521",
"0.5367521",
"0.5337481",
"0.5322726",
"0.53079075... | 0.7592692 | 1 |
try to determine if a test suite should run or not given a set files in a diff | def check_should_run_suite(suite, diff_files):
if suite in always_run_jobs:
# you gotta do what you gotta do
return True
all_ignore = True
any_docs = False
all_docs = True
any_console = False
all_console = True
any_java = False
any_testable_script = False
all_testab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_test(args):\n return (args.test_set or args.test_source or args.test_dataset or\n args.test_stdin or args.test_datasets)",
"def test_check():\n for f in cfg.required_files:\n assert os.path.isfile(f)",
"def run_test(standart_app, testing_app, *scenario_files):\n passed = True... | [
"0.60675377",
"0.6027447",
"0.59727937",
"0.58538693",
"0.58520204",
"0.58372957",
"0.58365786",
"0.5804472",
"0.58039814",
"0.5785943",
"0.5781354",
"0.57812536",
"0.57245654",
"0.5717809",
"0.57147026",
"0.56915843",
"0.56442523",
"0.5639239",
"0.5628038",
"0.5621098",
"0.5... | 0.7907135 | 0 |
Takes in a motion, and sends the bound key signal | def pressBoundKey(motion):
if bindings[motion]:
autopy.key.tap(bindings[motion], []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _on_key_press(self, event):",
"def _on_key_release(self, event):",
"def press_bound_key(self, event):\n if event.key in self.key_bindings:\n self.press()\n elif (event.key, pg.key.get_mods()) in self.key_bindings:\n self.press()",
"def ev_KEYUP(self, event):",
"def k... | [
"0.68667006",
"0.67747253",
"0.6757369",
"0.6677286",
"0.6660343",
"0.6565812",
"0.65357596",
"0.6482535",
"0.6442972",
"0.638499",
"0.6371723",
"0.6342939",
"0.63109654",
"0.62828064",
"0.6278564",
"0.6200766",
"0.6191682",
"0.61816347",
"0.6171723",
"0.6170504",
"0.6152393"... | 0.7920645 | 0 |
Binds a character key to a motion in the bindings table | def bind(motion, character):
bindings[motion] = character | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_key(self, key, command):\n self.key_bindings[key] = command",
"def pressBoundKey(motion):\n if bindings[motion]:\n autopy.key.tap(bindings[motion], [])",
"def bind_key(self, key):\n self.key_bindings.append(key)",
"def bindKeyboardKeysToFunctions(self):\n self.keyboard... | [
"0.73948914",
"0.717898",
"0.6787276",
"0.6590862",
"0.65523916",
"0.6453969",
"0.63455117",
"0.6275753",
"0.6270246",
"0.6268342",
"0.6202153",
"0.62004995",
"0.6192932",
"0.6180448",
"0.6134238",
"0.61339384",
"0.60985154",
"0.60825276",
"0.6080745",
"0.60624856",
"0.606173... | 0.80695057 | 0 |
creates an exgaussian CDF lookup table that will be used to interpolate values | def create_exgauss_lookup_table(self):
return self.exgauss_cdf_nparray(range(self.xmin,self.xmax, self.dx)).tolist(), range(self.xmin,self.xmax, self.dx) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_smarter_lookup_table(self, y=0.95):\n # First determine an approximate starting point for the lookup taqble by halving the max value till the point \n # where the cdf value is less than the cdf value we are looking for\n xold = self.xmax\n xnew = self.xmax\n y_calc = self.exgauss_cdf(xnew)\n ... | [
"0.68857044",
"0.5776785",
"0.5618758",
"0.55740803",
"0.55609",
"0.5537735",
"0.5410309",
"0.5400205",
"0.53806585",
"0.53747016",
"0.53696406",
"0.5324577",
"0.5312523",
"0.52905965",
"0.52819836",
"0.5277198",
"0.5264599",
"0.52586555",
"0.5256953",
"0.5254281",
"0.5247637... | 0.75694865 | 0 |
creates an exgaussian CDF lookup table but in a smarter way in that it creates a leaner lookup table with more values stacked closer to where the cdf value we are searching for is | def create_smarter_lookup_table(self, y=0.95):
# First determine an approximate starting point for the lookup taqble by halving the max value till the point
# where the cdf value is less than the cdf value we are looking for
xold = self.xmax
xnew = self.xmax
y_calc = self.exgauss_cdf(xnew)
while y_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_exgauss_lookup_table(self):\n return self.exgauss_cdf_nparray(range(self.xmin,self.xmax, self.dx)).tolist(), range(self.xmin,self.xmax, self.dx)",
"def _calc_ecdf(self):\n for numerator, vals in self.lift.items():\n for denominator, lift in vals.items():\n raw_data ... | [
"0.66475147",
"0.5811636",
"0.5665929",
"0.5633998",
"0.55846995",
"0.5386738",
"0.5367499",
"0.53664035",
"0.5290156",
"0.52471405",
"0.5237261",
"0.5190163",
"0.51828945",
"0.5166558",
"0.51589215",
"0.51433057",
"0.5126065",
"0.5123258",
"0.5092755",
"0.50826335",
"0.50671... | 0.72736365 | 0 |
1. Create and display a Frame for the widgets 2. Create and display a password prompt Label 3. Create and display an input Frame 4. Create and display a password Entry 5. Create and display an enter Button 6. Bind key to enter Button 7. Create a message Label | def create_widgets(self, root):
self.widgets['Main Frame'] = Frame(self.widgets['Login Window'], borderwidth=20)
self.widgets['Main Frame'].pack(expand=YES, fill=BOTH)
Label(self.widgets['Main Frame'], text='Enter password:').pack(side=TOP, expand=YES)
self.widgets['Input Frame'] = Fr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_widgets(self):\n self.instruction = Label(self, text=\"Enter the password \")\n self.instruction.grid(row=0, column=0, columnspan=2, sticky=W)\n\n self.password_entry = Entry(self)\n self.password_entry.grid(row=0, column=1, sticky=W)\n\n self.submit_button = Button(se... | [
"0.8136624",
"0.7529008",
"0.74277",
"0.7223204",
"0.7031169",
"0.6925377",
"0.6852082",
"0.6676885",
"0.6617138",
"0.6586638",
"0.65417933",
"0.6515163",
"0.64958483",
"0.64647",
"0.6382624",
"0.6367032",
"0.634605",
"0.63396925",
"0.6337783",
"0.63201666",
"0.6295827",
"0... | 0.7642204 | 1 |
Simulate the main task. Do something (compute a result), and send a message to the saver | def main_task_handler():
context = zmq.Context()
# socket to sending messages to save
save_sender = context.socket(zmq.PUSH)
save_sender.connect(SAVE_PUSH_QUEUE_ADDR)
c = 0
while (True):
# simulate some very complex computation
(x, y) = (random.gauss(0, 1), random.gauss(0, 1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n\n # Set up environment and agent\n e = Environment() # create environment (also adds some dummy traffic)\n a = e.create_agent(LearningAgent) # create agent\n e.set_primary_agent(a, enforce_deadline=False) # set agent to track\n\n # Now simulate it\n sim = Simulator(e, update_delay... | [
"0.6379486",
"0.6375426",
"0.6371881",
"0.63712204",
"0.629279",
"0.6278951",
"0.6243851",
"0.6223295",
"0.6182957",
"0.6136574",
"0.60471547",
"0.60366166",
"0.60341793",
"0.60041267",
"0.6000432",
"0.5988411",
"0.5983482",
"0.59803426",
"0.59710443",
"0.5966627",
"0.5954777... | 0.6512541 | 0 |
Try to find nfo file in movie directory and search in nfo IMDB idetifier | def IMDB_idenifier_search(self):
dir_list = os.listdir(self.MovieDir)
dir_count = 0
for x in dir_list:
if x.split(".")[-1].lower()=="nfo":
print "find NFO in %i list" % dir_count
break
dir_count=dir_count+1
try:
nfo_file = open(self.MovieDir+"/"+dir_list[dir_count],"r")
buffor = nfo_file.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MovieScan():\r\n for root, dirnames, filenames in os.walk(dlPath):\r\n for extend in movtypes:\r\n for filename in fnmatch.filter(filenames, extend):\r\n matches.append(os.path.join(root, filename))\r\n print(os.path.join(root, filename))\r\n sh... | [
"0.5898576",
"0.58694935",
"0.5622307",
"0.5614593",
"0.55535376",
"0.5487656",
"0.5487184",
"0.5405422",
"0.5401638",
"0.51820374",
"0.511373",
"0.5113248",
"0.510091",
"0.5017189",
"0.5016573",
"0.5016369",
"0.5010073",
"0.5002005",
"0.50001943",
"0.49860036",
"0.49847925",... | 0.77056664 | 0 |
Function returns subtitle dictionary which is computed from correct xml string. | def return_xml_dict(self):
try:
self.Correct_MultiRoot_XML()
self.subtitle_dict = sorted(self.xmltodict(self.XML_String)['subtitle'],key=itemgetter('imdb','cd'))
#self.subtitle_dict = self.xmltodict(self.XML_String)['subtitle']
print "XML subtitle list downloaded and converted to dict"
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from_origin_to_dict(self):\n try:\n for elem in self._xml_tree.getchildren():\n if elem.tag == \"info\":\n for subelem in elem.xpath(\"//Metadata/General/Metas/Titulo\"):\n self._translated_dict[\"root\"][\"title\"] = subelem.text\n ... | [
"0.5741043",
"0.56276953",
"0.55804926",
"0.54216254",
"0.5318582",
"0.5317567",
"0.53144175",
"0.53124976",
"0.53016436",
"0.5292441",
"0.52581465",
"0.5189917",
"0.51402706",
"0.5140158",
"0.51315385",
"0.5113792",
"0.51061213",
"0.5029709",
"0.50141513",
"0.5013694",
"0.50... | 0.67018545 | 0 |
From subtitle dictionary function returns value. | def return_xml_dict_entry_value(self,dict_entry, dict_entry_position):
value = self.subtitle_dict[dict_entry][dict_entry_position]
return value[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edx_get_subtitle(url, headers):\n \"\"\" or None if no subtitles are available \"\"\"\n try:\n jsonString = get_page_contents(url, headers)\n jsonObject = json.loads(jsonString)\n return edx_json2srt(jsonObject)\n except URLError as e:\n print('[warning] edX subtitles (erro... | [
"0.6290816",
"0.61481214",
"0.60934126",
"0.59526104",
"0.5819839",
"0.5644419",
"0.5638596",
"0.5580923",
"0.5557902",
"0.53163785",
"0.5266296",
"0.5250043",
"0.51997524",
"0.51850265",
"0.51807094",
"0.5156665",
"0.51562893",
"0.5116406",
"0.50712675",
"0.503532",
"0.49858... | 0.6423573 | 0 |
Function saves downloaded zip string on given path anf destroy self.zip_string if saveing is succesfull. | def save_downloaded_zip(self, dict_entry_to_download):
if self.download_subtitle_zip(dict_entry_to_download) == True:
try:
zip_file = open(self.ZipFilePath,"wb")
zip_file.write(self.zip_string)
zip_file.close
print "Zipfile: %s saved on hdd." % self.ZipFilePath
del self.zip_string
return True
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zipsave(self):\n\n filename = filedialog.asksaveasfilename(initialdir=self.root.cache_dir,\n title='Save As',\n filetypes=[('Zip', '.zip')],\n defaultextension='')... | [
"0.69184697",
"0.6477389",
"0.6425179",
"0.63842976",
"0.6137987",
"0.6123069",
"0.5896687",
"0.5882788",
"0.5697541",
"0.5678088",
"0.5674914",
"0.5637382",
"0.56089973",
"0.5559134",
"0.5541039",
"0.5518614",
"0.55055565",
"0.54959124",
"0.5464814",
"0.54589176",
"0.5444477... | 0.7418616 | 0 |
Napisy 24 GET request for subtitle zip downloading. Data is stored in self.zip_string. | def download_subtitle_zip(self, dict_entry_to_download):
request_subtitle_list = "http://napisy24.pl/download/%s/" % str(self.return_xml_dict_entry_value(dict_entry_to_download,'id'))
repeat = 3
while repeat > 0:
repeat = repeat - 1
#request_subtitle_list = "/libs/webapi.php?title=%s" % self.Movie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(self):\n if not os.path.isdir(self.save_path):\n try:\n os.mkdir(self.save_path)\n except IOError:\n print(\"Can't create subfolder. \"\n \"Check that you have write access for \"\n \"{}\".format(self.... | [
"0.62294996",
"0.573122",
"0.5613491",
"0.56069106",
"0.54558396",
"0.53945196",
"0.5256225",
"0.5209892",
"0.5174074",
"0.5155498",
"0.51524377",
"0.5145467",
"0.5109938",
"0.51030266",
"0.51014733",
"0.50734365",
"0.50671315",
"0.50465274",
"0.50144225",
"0.5005846",
"0.498... | 0.6889805 | 0 |
Funstion takes movie file path and based on EXTENSIONS from myListy.pl returns list of movies in movie file directory | def __return_movie_file_list(self, movie_path):
movie_dir = movie_path.rsplit("/",1)[0]
movie_file_list =[]
movie_extentionds = self.__movie_file_extensions(self.__file_extentions)
for x in os.listdir(movie_dir):
if x.rsplit(".",1)[-1]in movie_extentionds:
mov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_movies(path):\n movies_list = []\n \n \n for f in os.listdir(path):\n \n full_file_path = join(path,f)\n if isdir(full_file_path):\n \n movies_list.extend( get_movies(full_file_path) )\n \n elif isfile(full_file_path) and full_file_pa... | [
"0.77624446",
"0.69705206",
"0.6920418",
"0.65718144",
"0.65128",
"0.64938384",
"0.6462537",
"0.6437294",
"0.6373601",
"0.63549864",
"0.6350856",
"0.6319466",
"0.629446",
"0.6210759",
"0.6183799",
"0.61389726",
"0.6127222",
"0.61024976",
"0.6081276",
"0.60760933",
"0.607265",... | 0.7945257 | 0 |
Returns best matching movie subtitle table. | def give_movie_subtitle_consistent_data(self, movie_file_data, subtitle_file_data):
m_s_temp_data = []
preliminary_movie_subtitle_list = self.compare_movie_and_subtitle_FileData(movie_file_data, subtitle_file_data)
for x in preliminary_movie_subtitle_list:
""" Delete 0 'propability' ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _best_matching_movie(movie):\n return (Levenshtein.distance(movie_name, movie.get('title').lower()),\n (0 - movie.get('votes', 0)),\n )",
"def download_subtitle(search, results, filename, min_match=0,\n force=0, debug=0):\n s = Subseek()\n subti... | [
"0.618252",
"0.5965921",
"0.57754785",
"0.5734618",
"0.57143825",
"0.5659548",
"0.5541539",
"0.5518001",
"0.5478379",
"0.5466522",
"0.543087",
"0.53836876",
"0.5375327",
"0.52907383",
"0.52813095",
"0.5275028",
"0.52749276",
"0.52622724",
"0.5237285",
"0.5202462",
"0.5175123"... | 0.65964955 | 0 |
Takes a DNA sequence that is assumed to begin with a start codon and returns the sequence up to but not including the first in frame stop codon. If there is no in frame stop codon, returns the whole string. | def rest_of_ORF(dna):
# [???] 'assumed to begin with a start codon': doesn't need to check input?
# if len(dna) < 3:
# return ""
# if dna[0:3] != start_codon:
# return ""
l = len(dna)
for i in range(3, l, 3):
if dna[i: i + 3] in stop_codons:
return dna[0: i]
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stop_from_end(codonseq, codon_table):\n if str(codonseq[-3:]) in codon_table.stop_codons:\n #print(\"chopped\", len(CodonSeq().from_seq(codonseq[:-3])))\n return CodonSeq().from_seq(codonseq[:-3])\n elif str(codonseq[-3:]) == '---':\n #print(\"chopped\", len(CodonSeq().from_se... | [
"0.71757495",
"0.65072894",
"0.64979345",
"0.6329644",
"0.6183206",
"0.61209697",
"0.61035204",
"0.6082251",
"0.6023832",
"0.6007573",
"0.59589094",
"0.59459716",
"0.591217",
"0.5907929",
"0.57332164",
"0.57254994",
"0.5674605",
"0.563355",
"0.5596707",
"0.55794567",
"0.55748... | 0.67012167 | 1 |
Unit tests for the find_all_ORFs_oneframe function | def find_all_ORFs_oneframe_unit_tests():
data_list = [
["ATGCATGAATGTAGATAGATGTGCCC", ["ATGCATGAATGTAGA", "ATGTGCCC"]],
["ATGTAGATGTAG", ["ATG", "ATG"]],
["ATGATGATG", ["ATGATGATG"]],
["ATGGGGGATTAGATGATG", ["ATGGGGGAT", "ATGATG"]],
["ATGTGAATGTAA", ["ATG", "ATG"]],
[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_ORFs_oneframe_unit_tests():\n\n # YOUR IMPLEMENTATION HERE",
"def find_all_ORFs_oneframe_unit_tests():\n input_a='ATGATTATTTGATGAATGGATTGA'\n expected_output='[ATGATTATT,ATGGAT]'\n actual_output=find_all_ORFs_oneframe(input_a)\n print 'Expected Output is ' + expected_output\n print... | [
"0.8545172",
"0.7348566",
"0.73415834",
"0.7203369",
"0.7158465",
"0.6796761",
"0.6632994",
"0.6604659",
"0.6478488",
"0.6478216",
"0.62701315",
"0.62148196",
"0.6200575",
"0.61729914",
"0.61653095",
"0.61079854",
"0.607584",
"0.60689676",
"0.6063073",
"0.59820056",
"0.594094... | 0.76647025 | 1 |
Finds the longest ORF on both strands of the specified DNA and returns it as a string | def longest_ORF(dna):
l = find_all_ORFs_both_strands(dna)
max_len = 0
r = ""
# [???] what if there are ORFs with same length?
# this function just get the first one.
if len(l) == 0:
return ""
for o in l:
if len(o) > max_len:
r = o
max_len = len(o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_ORF(dna):\n l = find_all_ORFs_both_strands(dna)\n longest=''\n if len(l)>=1:\n\t longest =max(l,key=len)\n return longest",
"def longest_ORF(dna):\n both_strings=find_all_ORFs_both_strands(dna)\n L=max(both_strings,key=len)\n Q=len(L)\n return Q\n\n #save out put of ... | [
"0.87619084",
"0.8655862",
"0.86459744",
"0.86390924",
"0.86111736",
"0.8554702",
"0.8422834",
"0.8375487",
"0.83478934",
"0.80594677",
"0.8031292",
"0.7990923",
"0.7948157",
"0.7885518",
"0.76717263",
"0.76625794",
"0.7617656",
"0.75137126",
"0.75038695",
"0.7478359",
"0.742... | 0.8745673 | 1 |
Returns the amino acid sequences coded by all genes that have an ORF larger than the specified threshold. | def gene_finder(dna, threshold):
l = find_all_ORFs_both_strands(dna)
r = []
if len(l) > 0:
for item in l:
if len(item) > threshold:
r.append(item)
for i in range(len(r)):
r[i] = coding_strand_to_AA(r[i])
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gene_finder(dna, threshold):\n orfs = find_all_ORFs_both_strands(dna)\n orfs = [i for i in orfs if len(i)>threshold]\n orfs = [coding_strand_to_AA(i) for i in orfs]\n return orfs",
"def gene_finder(dna):\n orfs = find_all_ORFs_both_strands(dna)\n print(orfs)\n threshold = longest_ORF_non... | [
"0.74298954",
"0.71481067",
"0.6994018",
"0.68657947",
"0.6788955",
"0.67642456",
"0.59709907",
"0.58188194",
"0.5695765",
"0.557573",
"0.55652696",
"0.55194056",
"0.5454421",
"0.5452923",
"0.54236233",
"0.5409136",
"0.53492814",
"0.5158032",
"0.5150435",
"0.51174647",
"0.506... | 0.71809494 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.