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 |
|---|---|---|---|---|---|---|
Validate a template instantiation. This function ensures that the bindings on the instantiation refer to declared identifiers on the instantiation. | def _validate_template_inst(self, node, lexer):
names = set()
if node.identifiers:
names.update(node.identifiers.names)
for binding in node.body:
if binding.name not in names:
msg = "'%s' is not a valid template id reference"
syntax_error(m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_template(self, node, lexer):\n param_names = set()\n const_names = set()\n ident_names = set()\n\n def check_const(name, node):\n msg = None\n if name in param_names:\n msg = \"declaration of 'const %s' shadows a parameter\"\n ... | [
"0.6679387",
"0.6478176",
"0.6001375",
"0.590897",
"0.5644582",
"0.55499667",
"0.5294157",
"0.52924526",
"0.52882624",
"0.5256766",
"0.5223132",
"0.52088165",
"0.5206995",
"0.5105446",
"0.50752544",
"0.5072722",
"0.5042741",
"0.5035759",
"0.5009744",
"0.4994651",
"0.4994651",... | 0.8240367 | 0 |
Validate arguments and keywords arguments. Assume that the second token is a STAR. | def _validate_arglist_and_kwlist(self, p, items, keywords):
kwnames = set()
args = []
kws = []
self._validate_arglist_list(items, p.lexer.lexer)
for arg in items:
if isinstance(arg, ast.keyword):
kws.append(arg)
kwnames.add(arg.arg)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_star_args_with_keywords():\n assert arguments.fun_star_params(visited_color='orange',\n link_color='yellow',\n back_color='red',\n fore_color='blue') == ('orange',\n ... | [
"0.6387502",
"0.62051344",
"0.6136954",
"0.61239696",
"0.60451764",
"0.58679515",
"0.5834235",
"0.5833137",
"0.58054125",
"0.58051646",
"0.57713306",
"0.57533115",
"0.5741011",
"0.5736715",
"0.5722483",
"0.56204885",
"0.5607345",
"0.56033695",
"0.56025857",
"0.55663013",
"0.5... | 0.6569695 | 0 |
Return a tuple containing the number of arrived and departed TCP connections at the given host and port, along with the last update timestamp. | def connection_stats(self, host="localhost", port=9090):
mgr = NetworkConnectionsManager(self.db_uri_)
return mgr.connection_stats(host, port) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def net_get_connections ():\n\tdata = commands.getoutput(\"netstat -n | grep -c tcp\")\n\t\n\treturn data",
"def num_connections_by_status(self, host=\"localhost\", port=9090, status=NetworkConnectionsManager.wait_connection_status):\n\t\tmgr = NetworkConnectionsManager(self.db_uri_)\n\t\treturn mgr.num_connecti... | [
"0.6543587",
"0.63084567",
"0.6216155",
"0.617168",
"0.6024085",
"0.5964516",
"0.58905166",
"0.58480567",
"0.58389306",
"0.56446403",
"0.5604468",
"0.5566305",
"0.5535176",
"0.55129045",
"0.54838455",
"0.5445254",
"0.543818",
"0.5434288",
"0.5421533",
"0.5417215",
"0.54123724... | 0.66777825 | 0 |
Return the number of pending and served TCP connections at the given host and port. | def num_pending_connections(self, host="localhost", port=9090):
mgr = NetworkConnectionsManager(self.db_uri_)
return mgr.num_pending_connections(host, port) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_connections_by_status(self, host=\"localhost\", port=9090, status=NetworkConnectionsManager.wait_connection_status):\n\t\tmgr = NetworkConnectionsManager(self.db_uri_)\n\t\treturn mgr.num_connections_by_status(host, port, status)",
"def net_get_connections ():\n\tdata = commands.getoutput(\"netstat -n | ... | [
"0.72206396",
"0.67307204",
"0.6660507",
"0.66078466",
"0.63690484",
"0.6061792",
"0.6001934",
"0.59449774",
"0.59302354",
"0.58279747",
"0.5748955",
"0.5747473",
"0.5725744",
"0.5718424",
"0.5672113",
"0.562684",
"0.56213427",
"0.5606561",
"0.55943865",
"0.5546111",
"0.55100... | 0.7675019 | 0 |
Return the number of TCP connections to the given host and port and for the given status. | def num_connections_by_status(self, host="localhost", port=9090, status=NetworkConnectionsManager.wait_connection_status):
mgr = NetworkConnectionsManager(self.db_uri_)
return mgr.num_connections_by_status(host, port, status) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_port_counts(ssh):\r\n cmd02='netstat -na'\r\n retry_number=3\r\n try:\r\n while True:\r\n if retry_number == 0:\r\n logger.writeLog(\"get port counts fail\",level='error')\r\n break\r\n stdin,stdout,stderr=ssh.exec_command(cmd02)\r\n ... | [
"0.68410623",
"0.64477056",
"0.6383886",
"0.6108565",
"0.60123247",
"0.5894078",
"0.584534",
"0.57750434",
"0.5764128",
"0.5686742",
"0.5621689",
"0.5611162",
"0.56012166",
"0.55899924",
"0.5586538",
"0.5584097",
"0.55648154",
"0.553535",
"0.55054396",
"0.5504922",
"0.5476246... | 0.8449921 | 0 |
r"""|coro| Requests previously offline members from the guild to be filled up | async def request_offline_members(self, *guilds):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def scan_members(self, ctx):\n if not ctx.guild.id:\n return\n\n if not await self.bot.guildservice.check_guild(ctx.guild.id):\n await self.bot.guildservice.add_guild(ctx.guild)\n\n async for member in ctx.guild.fetch_members():\n await self.register_memb... | [
"0.60097337",
"0.5959812",
"0.59061867",
"0.5699752",
"0.5587353",
"0.5515036",
"0.5505876",
"0.54902285",
"0.54902285",
"0.5444672",
"0.5443009",
"0.5439936",
"0.5438627",
"0.5351881",
"0.53483593",
"0.5319313",
"0.5299255",
"0.52944815",
"0.5280214",
"0.52680117",
"0.524691... | 0.8564125 | 0 |
Generate colormap for N lines/points from the given colormap Later used in loop for each line/point by colorVal = scalarMap.to_rgba(i) i from 0 | def LineColorCoding(N,cmap='jet'):
colormap_name = cmap
cm = plt.get_cmap(colormap_name)
cNorm = colors.Normalize(vmin=0, vmax=N-1)
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
return scalarMap | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color_map(n):\n jet = plt.get_cmap('jet')\n cNorm = colors.Normalize(vmin=0, vmax=n-1)\n scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)\n outmap = []\n for i in range(n):\n outmap.append( scalarMap.to_rgba(i) )\n return outmap",
"def display_cmap_color_range(cmap_style='ra... | [
"0.75112605",
"0.6632478",
"0.6578862",
"0.6532801",
"0.64647084",
"0.64263225",
"0.64244705",
"0.63608927",
"0.635885",
"0.63546515",
"0.63398165",
"0.6310235",
"0.6309026",
"0.63089347",
"0.62898755",
"0.6284386",
"0.62525696",
"0.623394",
"0.62333196",
"0.6223972",
"0.6186... | 0.7548113 | 0 |
Secure the uploaded file is an image | def secure_filetype(file):
ext_list = ['png', 'jpg', 'jpeg']
ext_valid = file.filename.split('.')[-1] in ext_list
mimetype_list = ["image/jpeg", "image/jpg", "image/png"]
mimetype_valid = file.mimetype in mimetype_list
return ext_valid and mimetype_valid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_and_save_img(file, path):\n img_bytes = file.read()\n if not secure_filetype(file):\n return \"Not an image. \"\n input_image = Image.open(io.BytesIO(img_bytes))\n input_image.save(path)\n if not secure_filesize(path):\n return \"Too large given file. \"\n return ''",
"d... | [
"0.6554967",
"0.6406549",
"0.62095004",
"0.6166299",
"0.61382854",
"0.6104518",
"0.60615754",
"0.6045073",
"0.6040482",
"0.5996438",
"0.59558356",
"0.59558094",
"0.5948003",
"0.59385616",
"0.59111744",
"0.5893656",
"0.58829314",
"0.5842686",
"0.58411264",
"0.58405143",
"0.582... | 0.6721071 | 0 |
Secure the size of the uploaded file is smaller than MAX_FILESIZE | def secure_filesize(filepath):
return os.path.getsize(filepath) <= MAX_FILESIZE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_max_file_size(self, file_size):\n # NOTE: this method does not check the file size before upload,\n # but checks after the file is uploaded to the server\n if file_size > constants.MAX_UPLOAD_FILE_SIZE_BYTES:\n raise ArtifactMaxSizeError(\n f'Artifact size ... | [
"0.727252",
"0.7133552",
"0.70251024",
"0.69188094",
"0.6799686",
"0.6660166",
"0.6615638",
"0.6607412",
"0.6486542",
"0.644599",
"0.64264923",
"0.6355493",
"0.6347269",
"0.62421507",
"0.6239919",
"0.6224063",
"0.6214218",
"0.61739886",
"0.61398435",
"0.61218286",
"0.609277",... | 0.7341425 | 0 |
create pillow image with barcode inside | def save_barcode_to_pillow(self, scale_x=1, scale_y=1):
# creating a black and while 1-BIT image
# note: if you have problems with 1-BIT images
# select image type "L" and set color=255 for a greyscale image
im = Image.new('1',
(int(self.barcode_array['num_cols']... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_barcode(preds, labels):\n # the bar\n x = sorted([a for a in zip(preds, labels)], key=lambda x: x[0])\n x = np.array([[49, 163, 84] if a[1] == 1 else [173, 221, 142] for a in x])\n # x = np.array([a[1] for a in x]) # for bw image\n\n axprops = dict(xticks=[], yticks=[])\n barprops = dict... | [
"0.65775234",
"0.64884293",
"0.6355653",
"0.63141257",
"0.62750673",
"0.6226933",
"0.61234",
"0.6032769",
"0.6032769",
"0.6007017",
"0.6006699",
"0.60021627",
"0.60001177",
"0.5989265",
"0.5988984",
"0.59123755",
"0.59093726",
"0.58969015",
"0.58897674",
"0.58893675",
"0.5866... | 0.665032 | 0 |
str > Boolean Given a str 'myint', return 'True' if each digit is greater than or equal to the previous digit going from lefttoright. Return 'False' otw >>> isTidy('129') True >>> isTidy('7') True >>> isTidy('100') False | def isTidy(mystr):
for char_index in range(len(mystr) - 1):
if mystr[char_index] > mystr[char_index + 1]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str2bool(str):\n return int(str) != 0",
"def intable(int_str, base=10):\n try:\n int(int_str, base)\n return True\n except:\n return False",
"def is_int(string:str) -> bool:\n try:\n int(string)\n return True\n except:\n return False",
"def str_to_... | [
"0.61370903",
"0.5932983",
"0.5866292",
"0.5809784",
"0.57843447",
"0.5782664",
"0.5780815",
"0.5774021",
"0.5742161",
"0.57349616",
"0.5718255",
"0.5651227",
"0.56299496",
"0.5603001",
"0.5547087",
"0.55391425",
"0.5538978",
"0.5536504",
"0.5530544",
"0.55238724",
"0.5491961... | 0.69380695 | 0 |
str > str Given an integer string 'mystr', return a tidy integer string that is as close as possible to 'mystr'. The algorithm to use | def maxTidy(mystr):
tidyFlag = isTidy(mystr)
while not tidyFlag:
numarray = [int(char) for char in mystr]
for i in range(1, len(numarray)):
if numarray[i] < numarray[i - 1]:
numarray[i - 1] -= 1
for j in range(i, len(numarray)):
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(s):\n # check the input string is a valid length\n min_length = 1\n max_length = 101\n\n if len(s) < min_length or len(s) > max_length:\n return ''\n\n # need to handle integers between 1 and 10^100, so up to 101 decimal places of precision\n # The Python default is 28 signifi... | [
"0.6588028",
"0.6263586",
"0.61148185",
"0.61035854",
"0.6044126",
"0.6029237",
"0.60153794",
"0.5980579",
"0.5965579",
"0.59469116",
"0.59435564",
"0.5909614",
"0.58972603",
"0.5891423",
"0.5871647",
"0.5849175",
"0.5840574",
"0.5836244",
"0.5833249",
"0.5821985",
"0.578772"... | 0.70200473 | 0 |
(string, tuple) > Note Initialize a note with memo and optional list of tags. Automatically set the note's creation date and a unique id. | def __init__(self, memo, tags=()):
self.memo = memo
self.tags = tags
self.creation_date = datetime.date.today()
global last_id
last_id += 1
self.id = last_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_note(self, memo, tags=()):\n self.notes.append(Note(memo, tags))",
"def __init__(self, memo, tags=''):\n self.date = datetime.date.today()\n self.memo = memo\n self.tags = tags\n global last_id\n last_id += 1\n self.id = last_id",
"def create_note(self, ... | [
"0.7476427",
"0.642017",
"0.63055474",
"0.6291261",
"0.62780344",
"0.6176142",
"0.61630386",
"0.6147655",
"0.61455023",
"0.6102256",
"0.6031282",
"0.5960521",
"0.5901579",
"0.58963525",
"0.5890661",
"0.5865349",
"0.58641875",
"0.5848796",
"0.57985455",
"0.57985455",
"0.579854... | 0.657177 | 1 |
(Notebook) > string Returns a nicely formatted string of all the notes in the Notebook | def __str__(self):
result = "\nNotebook:\n"
for note in self.notes:
result += f"\nNote created on {note.creation_date}.\nTags: " \
f"{', '.join(note.tags)}\nMemo: {note.memo}"
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getnotes():",
"def __repr__(self):\n return str(self.notes)",
"def getNotesString(self, *args):\n return _libsbml.SBase_getNotesString(self, *args)",
"def render_note(note: str) -> str:\n note = emojize(note)\n note = markdown(note, extensions=['nl2br'])\n return note",
"def _dis... | [
"0.6887666",
"0.68716663",
"0.66750056",
"0.66500753",
"0.6610822",
"0.6573041",
"0.62988573",
"0.62435395",
"0.62395066",
"0.6229095",
"0.62264144",
"0.62264144",
"0.62264144",
"0.61905676",
"0.6149423",
"0.6142191",
"0.61234397",
"0.6062278",
"0.6028662",
"0.5973743",
"0.59... | 0.83395696 | 0 |
(int) > Note Locate the note with the given id. | def _find_note(self, note_id):
for note in self.notes:
if str(note.id) == str(note_id):
return note
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_note(self, id):\n for note in self.notes:\n if note.id == id:\n return note\n return None",
"def get_note(self, id):\n try:\n note = self.session.query(models.Note).filter(\n (models.Note.id == id)\n & (models.Note.... | [
"0.8259186",
"0.7229158",
"0.7178397",
"0.6776571",
"0.6716936",
"0.66794765",
"0.63966894",
"0.6372906",
"0.6358717",
"0.63075805",
"0.620736",
"0.6088811",
"0.6069665",
"0.59924036",
"0.59857935",
"0.5915616",
"0.58951306",
"0.5851504",
"0.5827585",
"0.57314634",
"0.5716913... | 0.78751373 | 1 |
(int, string) > None Find the note with the given id and change its memo to the given value. | def modify_memo(self, note_id, memo):
try:
self._find_note(note_id).memo = memo
except AttributeError:
print(f"Note with id {note_id} not found") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_memo(self, id, new_memo):\n self._find_note(id).memo = new_memo",
"def modify_tags(self, id, new_tag):\n for note in self.notes:\n if note.id == id:\n note.memo = new_tag",
"def modificar_nota(self, nota_id, memo):\n nota = self._encontrar_nota(nota_id)... | [
"0.74434525",
"0.65758264",
"0.62447673",
"0.6069608",
"0.59258395",
"0.58562964",
"0.57100075",
"0.5600991",
"0.55390906",
"0.5436309",
"0.54126716",
"0.5410817",
"0.54078734",
"0.5362416",
"0.53388757",
"0.5330866",
"0.53235054",
"0.5299905",
"0.52753437",
"0.52501434",
"0.... | 0.8077349 | 0 |
(int, list) > None Find the note with the given id and change its tags to the given value. | def modify_tags(self, note_id, tags):
try:
self._find_note(note_id).tags = tags
except AttributeError:
print(f"Note with id {note_id} not found") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_tags(self, id, new_tag):\n for note in self.notes:\n if note.id == id:\n note.memo = new_tag",
"async def update_note(note,tags=None):\n\n assert isinstance(note, dict), note\n\n id = note.pop('id')\n title = note.pop('title')\n body = note.pop('body')\n ... | [
"0.7731811",
"0.654463",
"0.5642622",
"0.5369626",
"0.53666764",
"0.53280866",
"0.5324178",
"0.53074807",
"0.5303219",
"0.5296171",
"0.5237457",
"0.52036124",
"0.5185239",
"0.5176934",
"0.51702344",
"0.5160224",
"0.5140717",
"0.51326704",
"0.5106468",
"0.5084178",
"0.506289",... | 0.7637606 | 1 |
Find all notes that match the given filter string. | def search(self, filtr):
return [note for note in self.notes if note.match(filtr)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(self, filter):\n return [note for note in self.notes if note.match(filter)]",
"def filter_notes_regex(self, search_string=None):\n sspat = utils.build_regex_search(search_string)\n\n filtered_notes = []\n active_notes = 0 # total number of notes, including deleted ones\n\n ... | [
"0.85091656",
"0.7274182",
"0.6959757",
"0.68630975",
"0.65128666",
"0.6480791",
"0.63805544",
"0.6175719",
"0.60054994",
"0.5987531",
"0.5975926",
"0.5935716",
"0.5894421",
"0.5870363",
"0.56967676",
"0.5631697",
"0.5579731",
"0.5575306",
"0.5552158",
"0.54501283",
"0.543539... | 0.7533182 | 1 |
This method is used in order to start the server | def start_server(self):
app.run(host=str(self.__constants.host),
port=int(self.__constants.port),
debug=bool(self.__constants.runindebug)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start():\n\n start_server()",
"def start(self):\n self.serve_forever()",
"def start(self):\n self.serve_forever()",
"def start_server(self):\n if not self._server:",
"def startServer(self):\n processor = ThinService.Processor(self.serverLogic)\n serverSocke... | [
"0.8638101",
"0.8093041",
"0.8093041",
"0.8046356",
"0.791814",
"0.78468686",
"0.78003395",
"0.7795933",
"0.7674649",
"0.7673057",
"0.7635485",
"0.7590675",
"0.756053",
"0.7555532",
"0.75478023",
"0.7535096",
"0.7514343",
"0.7497415",
"0.7497415",
"0.7491235",
"0.74865043",
... | 0.82562554 | 1 |
This method returns a list of duplicate files | def find_duplicates():
return AppServer.service.find_duplicated_files() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duplicates(files):\n checksums = {}\n # Create a dictionary of files, keyed by their checksum\n for f in files:\n checksum = get_checksum(f)\n checksums.setdefault(checksum,[]).append(f)\n # Create a list of lists of duplicate files. Only file lists\n # with more than one item ... | [
"0.77437985",
"0.7641333",
"0.72605205",
"0.7254903",
"0.72257817",
"0.72212934",
"0.71446794",
"0.70961773",
"0.69767016",
"0.6832686",
"0.6818336",
"0.6816415",
"0.6791807",
"0.67066544",
"0.66865283",
"0.6606116",
"0.65231436",
"0.6517979",
"0.650318",
"0.64915305",
"0.647... | 0.83544374 | 0 |
Get the operation times in minutes as a dictionary. | def get_operation_times(self):
self.write("TIMERS?")
timers = {}
timers['psu'] = int(re.search(r"\d+", self.read()).group())
timers['laser'] = int(re.search(r"\d+", self.read()).group())
timers['laser_above_1A'] = int(re.search(r"\d+", self.read()).group())
self.read() #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op_time(self):\r\n # timing is stored by node, we compute timing by Op on demand\r\n rval = {}\r\n for node, t in self.apply_time.items():\r\n rval.setdefault(node.op, 0)\r\n rval[node.op] += t\r\n return rval",
"def op_time(self):\n # timing is stored... | [
"0.67250717",
"0.6579046",
"0.65780365",
"0.65361685",
"0.6487194",
"0.6280842",
"0.62122524",
"0.6178536",
"0.616214",
"0.6161048",
"0.61545867",
"0.61476314",
"0.6055943",
"0.60438454",
"0.5990956",
"0.5990956",
"0.5990956",
"0.59448224",
"0.5926422",
"0.5924522",
"0.591217... | 0.72543854 | 0 |
Disable emission and unlock the button afterwards. You have to press the physical button to enable emission again. | def disable_emission(self):
self.ask("LASER=OFF")
self.ask("LASER=ON") # unlocks emission button, does NOT start emission! | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _disable(self):\n self.enabled = False",
"def on_disable(self) -> None:\n self._cancel_automation()",
"def disable(self):\r\n self.update(enabled=False)",
"def disable(self):\n self.enabled = False",
"def _led_disable():\n # type: () -> None\n GPIO.output(LED_nOE, GPIO... | [
"0.72219205",
"0.70091116",
"0.6999903",
"0.6953848",
"0.6864924",
"0.6856653",
"0.67950094",
"0.67918247",
"0.67732984",
"0.6770535",
"0.6750257",
"0.67029285",
"0.66727287",
"0.6663905",
"0.6636811",
"0.66305315",
"0.66301656",
"0.6621983",
"0.6614975",
"0.6601305",
"0.6574... | 0.8407728 | 0 |
gets the dimensions of `filename` | def GetDimensions(filename):
with Image(filename=filename) as img:
dimensions = (img.width, img.height)
return(dimensions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetSize(filename):\n return os.path.getsize(filename)",
"def image_size_from_file(filename):\n with PIL.Image.open(filename) as img:\n width, height = img.size\n return height, width",
"def getimagesize(filename):\n img = Image.open(filename)\n (w,h) = img.size\n t = \"IMAGETYPE_%S\" % i... | [
"0.75778204",
"0.7542941",
"0.74166805",
"0.73599815",
"0.73038477",
"0.70471734",
"0.7028066",
"0.70055157",
"0.6966619",
"0.6961465",
"0.69326055",
"0.6929278",
"0.6860623",
"0.6854549",
"0.6788435",
"0.67519546",
"0.67309034",
"0.6723016",
"0.66477436",
"0.65888184",
"0.65... | 0.8412316 | 0 |
generate random offsets for frames | def GenerateOffsets(frames, cut_pixels):
def GenRandom(max_rand):
return random.randint(-max_rand, max_rand)
max_rand = int(cut_pixels / 2)
if frames == 2:
return([(0, 0), (max_rand, max_rand), (0, 0)])
finished = False
while not finished:
coords = [(0, 0)]
for i in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_random_offsets(self, block_locations):\n\n min_x, max_x, min_y, _ = self._find_min_and_max_coords(block_locations)\n x_offset = randrange(10 - (max_x - min_x)) - min_x\n y_offset = 0 - min_y\n return [x_offset, y_offset]",
"def _random_start_position(self):\r\n self... | [
"0.668289",
"0.6422517",
"0.6390465",
"0.6374342",
"0.6183227",
"0.6038416",
"0.5885281",
"0.5827252",
"0.58197993",
"0.5788587",
"0.5786397",
"0.57753265",
"0.57548165",
"0.57329357",
"0.5716339",
"0.5708877",
"0.57035154",
"0.56725943",
"0.56613964",
"0.5644079",
"0.5640078... | 0.70308375 | 0 |
Rounds x to the 1st significant figure of y | def round_to(x, y):
return round(x, -int(floor(log10(abs(y))))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round(x):\n return int(x + copysign(0.5, x))",
"def custom_round(x):\n if x >= 1:\n x = 1\n else:\n x = 0\n return x",
"def divide_and_round_up(x, y):\n return ((x - 1) // y) + 1",
"def iround(x):\n return ipart(x + 0.5)",
"def sround(x, precision=0):\n sr = Stochasti... | [
"0.6559765",
"0.6453437",
"0.62575746",
"0.6186344",
"0.6103765",
"0.6059738",
"0.6017485",
"0.6012494",
"0.5949063",
"0.58420855",
"0.5826586",
"0.5816684",
"0.5806346",
"0.5804545",
"0.5800569",
"0.5770115",
"0.57675886",
"0.57675886",
"0.5765154",
"0.57598203",
"0.5752724"... | 0.6586625 | 0 |
Depending on the attack type parameter, spread the worm or perform a SYNFLOOD attack on specified address. | def attack_command(s, atck_type=None, victim_ip=None):
global BOT_STATES
global PORT
valid_attack = {
'0' : 'spread worm',
'1' : 'syn flood'
}
# Validate user input options
if not atck_type or not victim_ip:
print("Invalid input. Enter 'help for options.")
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack(self, robot):\n pass",
"def attack(self, attack_name, pokemon_to_hit):\n attack = next(attack for attack in self.attacks if attack.name == attack_name)\n if pokemon_to_hit.weakness == self.type:\n pokemon_to_hit.hp -= attack.damage * 2\n else:\n pokemo... | [
"0.5654576",
"0.5513364",
"0.546923",
"0.54036206",
"0.53306586",
"0.5316201",
"0.52848244",
"0.52418107",
"0.52152485",
"0.51987654",
"0.51302165",
"0.5105089",
"0.5102558",
"0.5088103",
"0.50788254",
"0.5053148",
"0.5051697",
"0.5021784",
"0.5019423",
"0.49805796",
"0.49555... | 0.61657387 | 0 |
Send a 'STOP' message to all enrolled bots and reset states to ready. | def stop_command(s):
global BOT_STATES
logger.info("Sending STOP")
print("Sending STOP to all BUSY bots.")
for addr in BOT_STATES.keys():
if BOT_STATES[addr] == 2:
s.sendto('STOP', (addr, PORT))
logger.info("Sent STOP to {}".format(addr))
print("Sent STOP to {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopall(self):\n\n for i in self.bots:\n try:\n i.stop()\n except:\n pass",
"def _stop_bot(_event):\n pass",
"def stop_all():\r\n motors.stop_all_motors()\r\n led.set_colour_solid(0)\r\n display.clear()",
"def turn_off(self, **kwa... | [
"0.773631",
"0.71759677",
"0.67646635",
"0.6679473",
"0.6659878",
"0.6640594",
"0.6635307",
"0.6563835",
"0.6562362",
"0.6562166",
"0.652363",
"0.6501538",
"0.64877415",
"0.6483175",
"0.6481263",
"0.6479091",
"0.64660865",
"0.6451119",
"0.6449899",
"0.6442603",
"0.6433154",
... | 0.77169406 | 1 |
Check in on status of bots. Sends the bots a ROLL message where they respond with their states. | def roll_command(s):
for addr in BOT_STATES.keys():
s.sendto('ROLL', (addr, PORT))
print('ROLL sent to {}'.format(addr))
logger.info('All bot statuses updated.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bot_listener():\n global BOT_STATES\n global PORT\n\n sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n sock.bind(('', PORT))\n\n while True:\n bot_resp, client_addr = sock.recvfrom(1024)\n\n if bot_resp == 'HELO':\n logger.info(\"Received 'HELO' from: {}\".forma... | [
"0.6071128",
"0.5908716",
"0.5874661",
"0.58539534",
"0.58171713",
"0.5779238",
"0.57592994",
"0.56777537",
"0.56663173",
"0.5612952",
"0.5612143",
"0.5593972",
"0.5589959",
"0.5574685",
"0.5558764",
"0.55285126",
"0.5521233",
"0.5516782",
"0.5507092",
"0.5494661",
"0.5480551... | 0.71331793 | 0 |
List bots characterized by their current state. | def list_bots():
bot_count = len(BOT_STATES)
idle = []
ready = []
busy = []
for addr in BOT_STATES.keys():
if BOT_STATES[addr] == 0:
idle.append(addr)
elif BOT_STATES[addr] == 1:
ready.append(addr)
elif BOT_STATES[addr] == 2:
busy.appe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def bot_list(self) -> list:\n return await self._do_request(\"get\", botlist_address, self._user_auth)",
"def list(self):\n\n result = []\n for i in self.bots:\n result.append(i.name)\n return result",
"def bots():\n return get_bots(\"botsunlimited.settings\")",
... | [
"0.7389889",
"0.72231615",
"0.67013156",
"0.65763295",
"0.6545056",
"0.6470417",
"0.6468487",
"0.6372104",
"0.6121923",
"0.6121494",
"0.5993512",
"0.5980015",
"0.59018785",
"0.5874151",
"0.5860195",
"0.5812102",
"0.5806294",
"0.578931",
"0.577182",
"0.5754218",
"0.5714406",
... | 0.7488443 | 0 |
Listens on specified port for bot responses, adds bots if not enrolled, and updates their states. | def bot_listener():
global BOT_STATES
global PORT
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', PORT))
while True:
bot_resp, client_addr = sock.recvfrom(1024)
if bot_resp == 'HELO':
logger.info("Received 'HELO' from: {}".format(client_addr))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bot():\n log(log.DEBUG, 'Starting bot')\n bot = BotSad()\n bot.listen()",
"def listen(self, port, address=\"\"):\n sockets = self.bind_udp_sockets(port, address=address)\n self.add_sockets(sockets)",
"def listen(address, port, community, mibs):\n snmp.listen(address, port, communi... | [
"0.58395386",
"0.5819374",
"0.5421392",
"0.5341439",
"0.5316938",
"0.52805775",
"0.52795386",
"0.525829",
"0.52362156",
"0.52343875",
"0.52270055",
"0.5226375",
"0.5179167",
"0.51745737",
"0.516524",
"0.51304287",
"0.51015294",
"0.5080643",
"0.50738096",
"0.5069052",
"0.50664... | 0.6808215 | 0 |
Gray out all buttons | def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deactivate_all(self):\n\t\t\n\t\tfor button in self.buttons:\n\t\t\tif button not in [\"apply\", \"clear\"]:\n\t\t\t\tself.buttons[button].set_sensitive(False)",
"def hide_main_buttons(self):\n pass",
"def _disable_buttons(self) -> None:\n self.email_button.config(text=\"Email(s) sent!\")\n ... | [
"0.70111954",
"0.6574382",
"0.6562065",
"0.65458655",
"0.6515202",
"0.6334071",
"0.61079484",
"0.6022451",
"0.6011258",
"0.5993602",
"0.5964074",
"0.593698",
"0.5926155",
"0.5854068",
"0.58134246",
"0.58111674",
"0.5783603",
"0.5761176",
"0.57354677",
"0.57351977",
"0.5729003... | 0.6771006 | 1 |
Loads bunch of AUCS stored in files files should be tagged as tag_cellline_ligand. and contain a single column with all AUCs. This is convenientn if you ran many simulation that stores AUC in different files | def loaddata(self, directory=None, tag="AUC"):
self.data = {}
for c in self.cellLines:
self.data[c] = {}
for l in self.ligands:
self.data[c][l] = []
for l in self.ligands:
for c in self.cellLines:
if self.verbose:print("Combini... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_ineraction_files(file_prefix):\n\tbinintfile=file_prefix+'.binint.log'\n\tcollfile=file_prefix+'.collision.log'\n\tmergefile=file_prefix+'.semergedisrupt.log'\n\tunitsfile=file_prefix+'.conv.sh'\n\n\twith open(binintfile, 'r') as f:\n\t\tnum_int = sum([1 for line in f if '****' in line])\n\t\tf.seek(0) #n... | [
"0.62888294",
"0.6198705",
"0.59711814",
"0.58968544",
"0.57964903",
"0.5739937",
"0.56960034",
"0.56644475",
"0.5627246",
"0.56152415",
"0.55847937",
"0.5551147",
"0.55015457",
"0.54909337",
"0.54869473",
"0.54789245",
"0.5473256",
"0.54239464",
"0.54134405",
"0.5386903",
"0... | 0.6529171 | 0 |
returns all mean AUCS in a matrix structure | def get_mean(self):
mean = np.array(np.zeros((4,8)))
for i,c in enumerate(self.cellLines):
for j,l in enumerate(self.ligands):
mean[i][j] = self.aucs[c][l]['mean']
return mean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_mean(matrix):\n return sum(map(mean,matrix))",
"def mean(data_matrix):\n return np.asmatrix(np.mean(data_matrix, axis=0))",
"def glcm_stat_mean(glcm_matrix):\n return np.mean(glcm_matrix)",
"def get_mean(self):\r\n for i in range(1,len(self.data[0])):\r\n self.pr... | [
"0.7341551",
"0.7203482",
"0.70830446",
"0.68304986",
"0.6820221",
"0.6678811",
"0.66404146",
"0.6583939",
"0.6457701",
"0.64234823",
"0.6372766",
"0.6364545",
"0.631668",
"0.62946856",
"0.6280955",
"0.62771595",
"0.62653273",
"0.6249245",
"0.6248259",
"0.62303585",
"0.620828... | 0.73292905 | 1 |
returns all mean AUCS in a dictionary structure | def get_mean_dict(self):
mean = {}
for c in self.cellLines:
mean[c] = {}
for l in self.ligands:
mean[c][l] = self.aucs[c][l]['mean']
return mean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(self) -> Dict:\n raise NotImplementedError",
"def summaries(e_dict, m_dict):\n for key, value in m_dict.items():\n e_dict[key].append(np.mean(value))\n return e_dict",
"def fmean(configuration):\n fmean_dict_all = {\n \"HL\" : {'H1' : 100., 'L1' : 100.},\n \"HLV\" : {'H1' : 100.... | [
"0.6692809",
"0.6616",
"0.65772694",
"0.65650886",
"0.6478568",
"0.63648903",
"0.633546",
"0.61431646",
"0.61224526",
"0.60316265",
"0.6016715",
"0.5965792",
"0.5897379",
"0.58560675",
"0.58334625",
"0.5830484",
"0.5802997",
"0.57899207",
"0.5771529",
"0.5765115",
"0.57646143... | 0.69496346 | 0 |
Decrypt a message with a given private key. Takes in a private_key generated by Crypto.PublicKey.RSA, which must be of size exactly 4096 If the ciphertext is invalid, return None | def decrypt(private_key, ciphertext):
if len(ciphertext) < 512 + 16:
return None
msg_header = ciphertext[:512]
msg_iv = ciphertext[512:512+16]
msg_body = ciphertext[512+16:]
try:
symmetric_key = PKCS1_OAEP.new(private_key).decrypt(msg_header)
except ValueError:
return None
if len(symmetric_key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(data, private_key):\r\n\r\n # Retrieve session key, tag, ciphertext and nonce from file\r\n enc_session_key, nonce, tag, ciphertext = \\\r\n [ file_in.read(x) for x in (private_key.size_in_bytes(), 16, 16, -1) ]\r\n\r\n\r\n # Decrypt the session key\r\n session_key = cipher_rsa.decrypt(e... | [
"0.72634965",
"0.71843773",
"0.7027609",
"0.6922721",
"0.68982226",
"0.6890842",
"0.68421274",
"0.6769495",
"0.6729046",
"0.6672852",
"0.66695887",
"0.6598913",
"0.6557704",
"0.6508217",
"0.64087945",
"0.6316787",
"0.6260778",
"0.6222339",
"0.618807",
"0.6171613",
"0.61268145... | 0.7740842 | 0 |
starts from an entity and executes the path by doing depth first search. If there are multiple edges with the same label, we consider max_branch number. | def execute_one_program(self, e: str, path: List[str], depth: int, max_branch: int):
if depth == len(path):
# reached end, return node
return [e]
next_rel = path[depth]
next_entities = self.train_map[(e, path[depth])]
# next_entities = list(set(self.train_map[(e, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _step(self):\n if self.best_unexplored_lower_bound < self.best_upper_bound:\n\n # Select a Node\n self._active_node = self._pop_node_with_best_lower_bound()\n\n # Reporting\n if self._reporting:\n print(self.report)\n\n # Select a Ver... | [
"0.547687",
"0.5423474",
"0.5100088",
"0.50876856",
"0.50838363",
"0.5082886",
"0.50793916",
"0.503926",
"0.50349957",
"0.5019097",
"0.50185573",
"0.501204",
"0.50001",
"0.4995637",
"0.4993701",
"0.49823725",
"0.49755004",
"0.49488726",
"0.49433365",
"0.49382582",
"0.4938176"... | 0.6204094 | 0 |
Calculates precision of each path wrt a query relation, i.e. ratio of how many times, a path was successful when executed to how many times the path was executed. | def calc_precision_map(self, output_filenm=""):
logger.info("Calculating precision map")
success_map, total_map = {}, {} # map from query r to a dict of path and ratio of success
# not sure why I am getting RuntimeError: dictionary changed size during iteration.
train_map = [((e1, r), e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryPrecision(self, query_doc_IDs_ordered, query_id, true_doc_IDs, k):\n\n\t\tprecision = -1\n\n\t\t#Fill in code here\n\t\trel_ret = 0 # no. of relevant docs retrieved\n\n\t\tfor docID in query_doc_IDs_ordered[:k]:\n\t\t\tif docID in true_doc_IDs:\n\t\t\t\trel_ret += 1\n\n\t\tprecision = rel_ret/k\n\n\t\tre... | [
"0.61812943",
"0.57956576",
"0.5756396",
"0.5742558",
"0.5645471",
"0.5587133",
"0.55666864",
"0.55505645",
"0.55011934",
"0.55001915",
"0.54952246",
"0.5491445",
"0.54837245",
"0.54835707",
"0.5461931",
"0.5452443",
"0.5450329",
"0.54490876",
"0.54057485",
"0.53849137",
"0.5... | 0.6258763 | 0 |
Computes a pixel neighbor map for given pixel distances within an TM and between pixels at adjecent TMs. | def compute_pixneighbor_map(
config, pixdist: float = 1.8, intertmdist: float = 2.5
) -> list:
m = config.GetMapping()
xpix = np.array(m.GetXPixVector())
ypix = np.array(m.GetYPixVector())
size = m.GetSize()
dist = pixdist * size
intdist = intertmdist * size
neighbors = [] # [[]]*2048
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transport_map(img):\n row, col = img.shape[:2]\n I = [None] * col # To store column number of images\n T = np.zeros((row,col), dtype=float) #Transport map\n C = np.zeros((row,col), dtype=int) #Map with path chosen\n for i in range(row):\n print \"row number Transport map:\",i\n fo... | [
"0.6320377",
"0.60415965",
"0.58535016",
"0.5827735",
"0.5815497",
"0.5553943",
"0.5543738",
"0.55415577",
"0.55342793",
"0.55337656",
"0.54653984",
"0.544497",
"0.5438962",
"0.54340076",
"0.54031384",
"0.53901225",
"0.5368199",
"0.5361898",
"0.53458023",
"0.5340604",
"0.5333... | 0.73221 | 0 |
Fetch the blogroll from a YAML file Return a dictionary generator | def loadblogs(filename):
stream = file(filename, 'r')
data = yaml.load_all(stream)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_datas(self) -> tp.Dict[str, dict]:\n with open(self._file, \"r\") as stream:\n try:\n load: tp.Dict[str, dict] = yaml.safe_load(stream)\n logger.info(\"YAML imported\")\n return load\n except yaml.YAMLError as exc:\n ... | [
"0.63969445",
"0.62679315",
"0.6134144",
"0.61296606",
"0.60277283",
"0.60232943",
"0.5987963",
"0.59842217",
"0.59732056",
"0.59686875",
"0.5899873",
"0.58834726",
"0.58754736",
"0.58664304",
"0.5852948",
"0.58378595",
"0.5827406",
"0.5817819",
"0.5815559",
"0.5795058",
"0.5... | 0.69280285 | 0 |
Update the Firebase store from blogroll.yaml Add any blogs in the YAML file that aren't already in the Firebase store, along with its owner and the latest ETag or LastModified data from the feed. | def update_firebase():
# Firebase instance and auth param
fb = firebase.FirebaseApplication(FIREBASE_URL, None)
auth = {'auth': FIREBASE_SECRET}
# Current blogroll.yaml and FB store
yamlpath = path.join(path.dirname(__file__), '..', 'blogroll.yaml')
blogroll = loadblogs(yamlpath)
fb_store ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_posts(accounts):\n # print(account.columns)\n for index, post in accounts.iterrows():\n\n # If a post with this URL already exists in database, then continue with next one\n if collection.count_documents({'Posts.URL': post['URL']}, limit=1) != 0:\n print('Post with url ', ... | [
"0.61540896",
"0.6004785",
"0.5631109",
"0.5549566",
"0.52210116",
"0.521589",
"0.5172908",
"0.5161415",
"0.51544964",
"0.51225495",
"0.51189125",
"0.5110958",
"0.5107982",
"0.50858223",
"0.50394106",
"0.5031426",
"0.5018237",
"0.50133663",
"0.50114733",
"0.4977893",
"0.49431... | 0.7752235 | 0 |
Calculate the marginals P(y_s|X) and P(y_s, y_s+1|X) using forward and backward messages returns (mx26, m1x26x26) marginal distributions for each letter in the word | def get_marginals(word, model):
# forward and backward message at once
char_count, _ = word.shape
alpha = np.zeros((char_count, model.dimY)) # alphas
lbeta = np.zeros((char_count, model.dimY)) # log version of betas
first_term = np.dot(word, model.getW(model.labels))
second_term_a = model._T
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marginalize(counts):\n\t# Sum columns\n\tx_counts = np.sum(counts, axis=0)\n\t# Sum rows\n\ty_counts = np.sum(counts, axis=1)\n\n\tmarginalized = {'theta_1': x_counts, 'theta_2': y_counts}\n\n\treturn marginalized",
"def marginal(self):\n m = np.zeros(len(self.domain))\n for fnode in self.neigh... | [
"0.60359585",
"0.59205",
"0.5920008",
"0.5853057",
"0.5761325",
"0.56386566",
"0.56210643",
"0.56109506",
"0.55320245",
"0.5515198",
"0.5510336",
"0.5491179",
"0.54811347",
"0.5466245",
"0.5403813",
"0.5399361",
"0.5398806",
"0.53894496",
"0.5383771",
"0.535307",
"0.5342185",... | 0.8056387 | 0 |
Indicator func [label == k] | def get_ind(labels, k):
return (np.array(labels) == k).astype('float64') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_labels (points, labels, fun):\n your_labels = fun (points)\n return (labels == your_labels)",
"def presence(label):\r\n\r\n return lambda x, y: 1.0 * ((label in x) == (label in y))",
"def recall(gt, pred, k):\n k = min(len(pred), k)\n return sum([int(pred[i] in gt) for i in ran... | [
"0.64414",
"0.6142404",
"0.5890926",
"0.58058643",
"0.5768107",
"0.57386917",
"0.5721323",
"0.56426954",
"0.5619493",
"0.55276185",
"0.54309857",
"0.5427038",
"0.54159737",
"0.54125726",
"0.53974235",
"0.53671473",
"0.53431934",
"0.5338066",
"0.5328939",
"0.52978337",
"0.5248... | 0.6958311 | 0 |
calculate the gradient for given word with m chars and corresponding true labels W and T are initial weights TODO matrix implementation | def calculate_gradient_crf(train, model):
word = train[0]
label = train[1]
char_count, _ = word.shape
# get the marginals
marY, marY1 = get_marginals(word, model)
# calculate w_k for all 26 Ws. To do matrix approach
grad_W = []
for k in range(1,model.dimY+1):
ind_k = get_ind(labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient(w, x, t):\n return 2 * np.dot(x.T, (nn(x, w) - t))",
"def calculate_gradient(y, tx, w):\n return tx.T.dot(sigmoid(tx.dot(w))-np.reshape(y,(len(y),1)))",
"def compute_gradient(X, t, w): # TODO: try to change to square loss since it's hessian is easier to obtain\n # TODO : print to console... | [
"0.6380519",
"0.63348216",
"0.61813146",
"0.6144904",
"0.6125579",
"0.60797465",
"0.60776895",
"0.60069954",
"0.597834",
"0.59709597",
"0.5948029",
"0.59349626",
"0.5929249",
"0.5880993",
"0.58753586",
"0.5865767",
"0.5848433",
"0.5845222",
"0.58187354",
"0.58018273",
"0.5793... | 0.7180974 | 0 |
Draw the button to the screen depending on soundon flag. | def draw_sound_button(self):
if self.settings.sound_on:
self.screen.blit(self.image_sound_on, self.rect)
else:
self.screen.blit(self.image_sound_off, self.rect) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def button_sound(self):\n sound = pygame.mixer.Sound('assests/sounds/Button_Sound.wav')\n sound.play()",
"def draw_button(self):\n self.screen.fill(self.button_color, self.rect)\n self.screen.blit(self.msg_img, self.msg_img_rect)",
"def draw_button(self):\r\n self.surface.fil... | [
"0.7117985",
"0.71075696",
"0.7089486",
"0.69307727",
"0.6909666",
"0.6822665",
"0.68051106",
"0.67750704",
"0.6587988",
"0.6553631",
"0.65220034",
"0.6433722",
"0.64230895",
"0.6407568",
"0.64034826",
"0.6374402",
"0.6287281",
"0.62751865",
"0.62718153",
"0.6177018",
"0.6166... | 0.8733873 | 0 |
checks if balance is positive | def balance(balance):
if float(balance) >= 0.0:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positive_balance_check(user):\n return has_positive_balance(user)",
"def __bool__(self):\n return self.balance > 0",
"def check_funds(self, amount):\n if abs(amount)>self.get_balance(): return False\n else: return True",
"def check_funds(self, amount):\n if amount > self.ge... | [
"0.81463295",
"0.73042417",
"0.72899854",
"0.7057274",
"0.6986943",
"0.6916065",
"0.6853253",
"0.68147284",
"0.67388105",
"0.6703565",
"0.670249",
"0.6673638",
"0.66495174",
"0.6628537",
"0.6573587",
"0.6564371",
"0.6545044",
"0.6513351",
"0.65111935",
"0.65109164",
"0.647895... | 0.82587105 | 0 |
checks if notifyer includes the char '@' | def notifyer(notifyer):
if '@' in notifyer:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _at_notification(username, _sub=re.compile(r\"[^\\w'.-]*\").sub):\n return \"@\" + _sub(\"\", username)",
"def mention(result):\n return result.text.find('@') != -1",
"def CheckReviewer(reviewer):\r\n if \"@\" not in reviewer:\r\n return # Assume nickname\r\n parts = reviewer.split(\"@\")\r\n ... | [
"0.67085975",
"0.66555923",
"0.6324322",
"0.6296109",
"0.62701887",
"0.5984388",
"0.5950377",
"0.5931341",
"0.58767325",
"0.57619786",
"0.5757168",
"0.565749",
"0.5540098",
"0.5534619",
"0.54895955",
"0.5443971",
"0.53327",
"0.5264029",
"0.52463037",
"0.52455944",
"0.5233661"... | 0.8534201 | 0 |
Returns heuristic cost estimate for path between two nodes. | def heuristic_cost_estimate(self, first_node_object, second_node_object):
(first_column, first_row) = first_node_object
(second_column, second_row) = second_node_object
return numpy.sqrt((first_row - second_row) ** 2 +
(first_column - second_column) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_heuristic(node1, node2):\n return abs(node1.x - node2.x) + abs(node1.y - node2.y)",
"def heuristic(p1, p2):\n x1, y1 = p1\n x2, y2 = p2\n heuristic = abs(x1 - x2) + abs(y1 - y2)\n return heuristic",
"def computeShortestPathCoherence(node1, node2, w):\n\n\tif node1.strip()==node2.st... | [
"0.74732375",
"0.7098494",
"0.7052666",
"0.6961692",
"0.6868195",
"0.6866785",
"0.68314254",
"0.68120164",
"0.67767656",
"0.6737849",
"0.6715671",
"0.66442704",
"0.6643553",
"0.661536",
"0.661536",
"0.661536",
"0.65896356",
"0.6546054",
"0.6536738",
"0.6534267",
"0.6516135",
... | 0.758592 | 0 |
Executes the distutils code to build and install the pyccsm wrappers. | def run_distutils():
from distutils.core import setup, Extension
source_dir = os.getcwd()
build_dir = Params.cmake_binary_dir
gsched_module = Extension('_gsched',
sources=[build_dir+'/gsched_wrap.c',
build_dir+'/gsched.c'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n for key in UNSAFE_FLAGS:\n if key in os.environ:\n del os.environ[key]\n\n parser = argparse.ArgumentParser()\n parser.add_argument('--fcompiler', choices=['pgi', 'intel', 'gfortran'],\n help='Fortran compiler to use')\n parser.add_argument('--usec... | [
"0.6593337",
"0.6535293",
"0.65105677",
"0.64276314",
"0.63603014",
"0.62254214",
"0.6216925",
"0.6176343",
"0.61657244",
"0.61179215",
"0.6059067",
"0.60562205",
"0.5964491",
"0.59303516",
"0.590866",
"0.5890979",
"0.58811283",
"0.58780426",
"0.5854955",
"0.5819179",
"0.5783... | 0.6563516 | 1 |
generate a sales example with tables for customers, sales, products | def main():
s = content.DataFiles()
date_list = generate.get_list_dates(2016, 2016, 500)
prod_list = list(s.get_collist_by_name(os.path.join(content.data_fldr,'food','garden_produce.csv'), 'name')[0])
tbl_cust = generate.TableGenerator(8, ['STRING','PEOPLE', 'PEOPLE', 'PLACE'], ['Customer ID',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_summary_of_records(self):\n ids = self.get_saleman_ids()\n table = [\n [\"Seller name\",\"Number of sales\",\"Total Value ($)\"]\n ]\n for id in ids:\n table_id = [self.get_seller_name(id),self.get_number_of_sales(id),\n s... | [
"0.59732586",
"0.5785441",
"0.5771715",
"0.570645",
"0.5650823",
"0.5644279",
"0.55376863",
"0.54924285",
"0.54814047",
"0.54727465",
"0.5444592",
"0.5433245",
"0.5430196",
"0.541598",
"0.5367277",
"0.5366972",
"0.53534484",
"0.5351333",
"0.53489405",
"0.5344632",
"0.53371185... | 0.69267106 | 0 |
Parse the ADP page HTML and iterate out serializable rows. | def _parse_doc(self, html_doc):
c = itertools.count(start=1)
# load adp page and parse out stats table
doc = html.fromstring(html_doc)
rows = doc.xpath(
'//table[@id="adp_table"]/tr[contains(@class, "contentrow")]')
for row in rows:
text = [v.strip() fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_view_page(self):\n for row in self.driver.find_elements_by_css_selector(\"table\"):\n cells = row.find_elements_by_tag_name(\"td\")\n for cell in cells:\n yield cell.text",
"def _parse_result_page(self, page):\n items = []\n table = list(page.fi... | [
"0.65425724",
"0.6302129",
"0.622085",
"0.6209609",
"0.6088788",
"0.60779214",
"0.60050493",
"0.58280545",
"0.5810578",
"0.57971364",
"0.578679",
"0.5778047",
"0.57356834",
"0.56832653",
"0.5631428",
"0.55914",
"0.5577234",
"0.5569017",
"0.55506384",
"0.5539603",
"0.55137676"... | 0.68281966 | 0 |
Creates a dictionary where the keys are the employee ID and the values associate with it are the employees name, salary, and email address | def make_employee_dict(names, ID_numbers, salaries, email_addresses):
d = dict()
for i in range(len(names)):
d[ID_numbers[i]] = Employee(names[i], ID_numbers[i], salaries[i], email_addresses[i])
return d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def employee_id(self):\n for i in self.emp_dict:\n self.emp_id[i] = self.emp_dict[i][0]\n #print(self.emp_id)\n return self.emp_id",
"def create_employee_structure(employees):\n employees_dict = {}\n for employee in position_sort(employees):\n if not employee.is_secre... | [
"0.6583202",
"0.64773506",
"0.63519627",
"0.6321661",
"0.63113487",
"0.6213478",
"0.6001616",
"0.59993625",
"0.5955378",
"0.59340984",
"0.5930626",
"0.59140646",
"0.58262366",
"0.5825099",
"0.5823625",
"0.57922107",
"0.57843775",
"0.5739199",
"0.5734489",
"0.57167673",
"0.565... | 0.85496974 | 0 |
Return true if subject is serialized | def isDone(self, subject):
return subject in self._serialized | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_stringified(self) -> bool:\n return self._stringify",
"def is_text_serializer(serializer):\n return isinstance(serializer.dumps({}), text_type)",
"def can_be_pickled(x):\n try:\n s = BytesIO() \n pickle.dump(x, s) \n return True\n except:\n return False",
... | [
"0.6352182",
"0.60579926",
"0.59776586",
"0.59443784",
"0.5859056",
"0.5855416",
"0.58180535",
"0.5810346",
"0.58011305",
"0.57682997",
"0.5754378",
"0.5727073",
"0.56994593",
"0.5691962",
"0.5673316",
"0.56449115",
"0.55767673",
"0.55507547",
"0.55482227",
"0.5546081",
"0.55... | 0.6803579 | 0 |
Return the number of times this node has been referenced in the object position | def refCount(self, node):
return self._references.get(node, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referencecount(self) :\n\t\ttry :\n\t\t\treturn self._referencecount\n\t\texcept Exception as e:\n\t\t\traise e",
"def n_refs(self):\n return self._n_refs",
"def node_count(self):\n return self._node_count",
"def circular_reference_count(obj: typing.Any) -> int:\r\n if np is not None:\r\... | [
"0.73285043",
"0.7065692",
"0.69931144",
"0.6977847",
"0.6945317",
"0.6934825",
"0.6894152",
"0.68024766",
"0.67220914",
"0.6693765",
"0.66885644",
"0.661544",
"0.6597283",
"0.65527266",
"0.65287834",
"0.6519777",
"0.6518639",
"0.6515954",
"0.6502533",
"0.64782953",
"0.645483... | 0.769454 | 0 |
Build a hash key by predicate to a list of objects for the given subject | def buildPredicateHash(self, subject):
properties = {}
for s,p,o in self.store.triples((subject, None, None)):
oList = properties.get(p, [])
oList.append(o)
properties[p] = oList
return properties | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hits_to_identifiers( hits, predicate ):\n result = { }\n for hit in hits:\n for ref in hit_to_references( hit, predicate ):\n if ref in result:\n result[ ref ].add( hit )\n else:\n result[ ref ] = set( [ hit ] )\n return result",
"def predic... | [
"0.5736396",
"0.5721624",
"0.5721624",
"0.56184936",
"0.56184936",
"0.55222666",
"0.5480491",
"0.5430563",
"0.5408601",
"0.5408601",
"0.5403026",
"0.5370942",
"0.53698176",
"0.5361436",
"0.5361436",
"0.5263427",
"0.523759",
"0.5141724",
"0.5141724",
"0.5074739",
"0.49995753",... | 0.78420794 | 0 |
Take a hash from predicate uris to lists of values. Sort the lists of values. Return a sorted list of properties. | def sortProperties(self, properties):
# Sort object lists
for prop, objects in properties.items():
objects.sort()
# Make sorted list of properties
propList = []
seen = {}
for prop in self.predicateOrder:
if (prop in properties) and (prop not in se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __sort_properties(properties):\n return sorted(properties.items(), key=lambda x: (x[1] is None, x[1]))",
"def test_key_order_property_sorter(\n properties: list[str], expected: list[str]\n ) -> None:\n result = sorted(properties, key=functools.cmp_to_key(task_property_sorter))\n ... | [
"0.64929235",
"0.5990212",
"0.5946619",
"0.59434307",
"0.5912999",
"0.590627",
"0.5839437",
"0.57552755",
"0.57384574",
"0.5731395",
"0.5666403",
"0.565087",
"0.56253415",
"0.5591786",
"0.55706227",
"0.5554157",
"0.5480971",
"0.5406701",
"0.54028654",
"0.54009783",
"0.5399241... | 0.6845455 | 0 |
Mark a subject as done. | def subjectDone(self, subject):
self._serialized[subject] = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_done(self):\n self.status = \"DONE\"",
"def isDone(self, subject):\n return subject in self._serialized",
"def mark_as_done(self, task):\n raise NotImplementedError('')",
"def tellDone(self, success, originatorId):\n self.jobSender.send(self.jobSender.createJobDoneEven... | [
"0.704864",
"0.6673957",
"0.6525201",
"0.6275602",
"0.6173174",
"0.6173174",
"0.6173174",
"0.6036304",
"0.60341066",
"0.6020315",
"0.5999019",
"0.5998865",
"0.5915908",
"0.59151214",
"0.58811367",
"0.58715284",
"0.5813549",
"0.5813549",
"0.5813549",
"0.5760726",
"0.57472414",... | 0.8353019 | 0 |
Returns indent string multiplied by the depth | def indent(self, modifier=0):
return (self.depth+modifier)*self.indentString | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_with_depth(self, string, depth):\n print(\"{0}{1}\".format(\" \" * depth, string))",
"def depth_from_indentation(function):\n def wrap(start, values):\n #print 'Depth %d | %d %s' %(self._depth, start, values)\n #self._depth = start\n se... | [
"0.7097198",
"0.70590717",
"0.67140275",
"0.67130893",
"0.6709319",
"0.6664868",
"0.6606697",
"0.6559184",
"0.6539386",
"0.64193255",
"0.6396829",
"0.6362152",
"0.63595223",
"0.63404703",
"0.62998295",
"0.62909067",
"0.6274676",
"0.62546766",
"0.62416536",
"0.6239278",
"0.623... | 0.7225648 | 0 |
Write text in given encoding. | def write(self, text):
self.stream.write(text.encode(self.encoding, 'replace')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(text, filename, encoding='utf-8', mode='wb'):\r\n text, encoding = encode(text, encoding)\r\n with open(filename, mode) as textfile:\r\n textfile.write(text)\r\n return encoding",
"def write_text(self, text):\n self.write(self.render_text(text))",
"def write_text(self, data, en... | [
"0.74717695",
"0.7019952",
"0.69565916",
"0.6928853",
"0.68908024",
"0.6887152",
"0.679194",
"0.66439027",
"0.6633984",
"0.6590899",
"0.6485758",
"0.6421125",
"0.6376359",
"0.63053346",
"0.6278782",
"0.62766683",
"0.62641996",
"0.6243525",
"0.6221964",
"0.62199134",
"0.621321... | 0.71010154 | 1 |
This function will delete the article | def delete(self, request, slug=None, **kwargs):
article_delete = self.get_object()
article_delete.delete()
return Response({"message": {"Article was deleted successful"}},
status.HTTP_200_OK) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(article_id):\r\n response = table.get_item(\r\n Key={'article_id': article_id}\r\n )\r\n data = response.get('Item')\r\n if data is None:\r\n flash('Unable to get Article')\r\n return redirect(url_for('article.list')) \r\n\r\n # Delete article for a particular ... | [
"0.77090985",
"0.74669415",
"0.73265046",
"0.7262695",
"0.72596824",
"0.7233334",
"0.7102965",
"0.69857645",
"0.68926746",
"0.68667036",
"0.67924905",
"0.67499053",
"0.6718008",
"0.6718008",
"0.6716182",
"0.6710186",
"0.6664958",
"0.66613835",
"0.66613835",
"0.66613835",
"0.6... | 0.774713 | 0 |
THis function will update no of reads on an article by user | def update_read(self, article):
read_statistics = ReadingStatistics.objects.filter(
user=self.request.user, article=article)
if read_statistics:
read_time = read_statistics[0].article.read_time
read_time_int = int(read_time.split(' ')[0]) * 60
no_sec = rea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_author_views(cls, article=None, author=None, action='views'):\n query_field = article.author if article else author\n\n owner = ReadStats.objects.get(user=query_field)\n\n if action == 'views':\n owner.views += 1\n else:\n owner.reads += 1\n owner... | [
"0.7124792",
"0.70553327",
"0.6112314",
"0.6071061",
"0.5997906",
"0.5914071",
"0.5792758",
"0.5734675",
"0.56934166",
"0.56541574",
"0.5651333",
"0.5643238",
"0.55879575",
"0.55871814",
"0.55841875",
"0.5581353",
"0.5559804",
"0.5511293",
"0.5486273",
"0.54840887",
"0.546837... | 0.71937746 | 0 |
Overriding queryset to get only the article ratings | def get_queryset(self):
return ArticleRating.objects.filter(article=self.get_object()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ratings(self):\n return Vote.objects.filter(content_type=self.get_content_type(), object_id=self.instance.pk, key=self.field.key)",
"def get_average_rating(self):\n queryset = ArticleRating.objects.filter(article_id=self.get_object())\n return queryset.aggregate(Avg('rate')).get(\"ra... | [
"0.7271844",
"0.7071089",
"0.6878233",
"0.6859942",
"0.6859942",
"0.6474285",
"0.64735067",
"0.63896847",
"0.6379566",
"0.6251398",
"0.6225194",
"0.6225194",
"0.62195325",
"0.611549",
"0.60846317",
"0.6002514",
"0.5999148",
"0.59632",
"0.59182006",
"0.591358",
"0.58642286",
... | 0.87318647 | 0 |
Parse json settings from file. | def parse_json_settings(file: str):
with open(file) as f:
return json.load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_JSON_settings(settings_name):\n with open(settings_name, 'r') as fp:\n setting_params = json.load(fp)\n return setting_params",
"def load_json():\n\n global REMOVE_WORDS, NEGATIVE_WORDS # pylint: disable=W0603\n this_dir, _ = os.path.split(__file__)\n settings_path = o... | [
"0.78234035",
"0.7454186",
"0.738491",
"0.7332821",
"0.72581226",
"0.72537506",
"0.7247257",
"0.72134763",
"0.7206956",
"0.72042084",
"0.71891797",
"0.7181957",
"0.70747685",
"0.7022381",
"0.6965703",
"0.68439865",
"0.68427104",
"0.6822185",
"0.6803582",
"0.6751785",
"0.67412... | 0.8716982 | 0 |
Parse websites settings from file. | def parse_websites_settings(file: str):
with open(file) as f:
data = json.load(f)
return mapping_to_website(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_settings(site_name):\n siteid = _get_site_id(site_name)\n if siteid is None:\n raise FileNotFoundError('no_site')\n # cur = conn.cursor(cursor_factory=pgx.RealDictCursor)\n # querystring = 'select count(*) from sites where sitename = %s', (site_name,))\n # if cur.fetchone()['count'] ... | [
"0.65807444",
"0.61060965",
"0.60990846",
"0.59811866",
"0.5958516",
"0.59537965",
"0.5902357",
"0.5889026",
"0.58186096",
"0.5792139",
"0.57509905",
"0.5722189",
"0.5722189",
"0.57016504",
"0.5693384",
"0.5669682",
"0.5665954",
"0.56584835",
"0.563955",
"0.5604042",
"0.55809... | 0.7911105 | 0 |
Mapping map data to Website structs. | def mapping_to_website(data: list) -> [Website]:
return [
Website(
url=site['url'],
check_interval=site['check_interval'],
regexp_pattern=site['regexp_pattern'],
) for site in data
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_site_map(url):\n site_map = {}\n links_visited = []\n base_domain = find_base_domain(url)\n\n # Setup a RobotFileParser object for checking if links can be crawled\n rp = robotparser.RobotFileParser()\n rp.set_url('http://' + base_domain + '/robots.txt')\n rp.read()\n\n # Get an ... | [
"0.6044969",
"0.597719",
"0.5800148",
"0.56795913",
"0.5547703",
"0.5524982",
"0.55220145",
"0.55100423",
"0.5463102",
"0.5437905",
"0.5426898",
"0.5400445",
"0.53647476",
"0.53603876",
"0.534807",
"0.530098",
"0.52835846",
"0.52315533",
"0.5227864",
"0.5193354",
"0.5191985",... | 0.7272798 | 0 |
Ingest an edgelist from a Pandas DataFrame. | def ingest_from_edgelist_dataframe(
self, edgelist: pd.DataFrame, source_column: str, target_column: str
) -> None:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_pandas_edgelist(\n self,\n pdf,\n source=\"source\",\n destination=\"destination\",\n edge_attr=None,\n weight=None,\n edge_id=None,\n edge_type=None,\n renumber=True,\n ):\n if not isinstance(pdf, pd.core.frame.DataFrame):\n ... | [
"0.6260767",
"0.5854634",
"0.5813079",
"0.5792581",
"0.5786084",
"0.57832754",
"0.5701461",
"0.56941575",
"0.56775814",
"0.5646918",
"0.56055623",
"0.55786383",
"0.5561005",
"0.5557618",
"0.5529307",
"0.5464919",
"0.5403515",
"0.5362619",
"0.5352921",
"0.53206956",
"0.5293345... | 0.81996965 | 0 |
Get a generator of all of the nodes in this graph. | def all_nodes_as_iterable(self, include_metadata: bool = False) -> Generator:
if include_metadata:
return [
(self._names.get_name(i), self._meta.get_node(self._names.get_name(i)))
for i in self._nk_graph.iterNodes()
]
return [self._names.get_name(i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes_iter(self) -> Generator:\n for n in self.graph.nodes(data=True):\n yield n",
"def nodes(self):\n for node_set in self.itervalues():\n for node in node_set:\n yield node",
"def node_gen(self):\n for n in self.child_list:\n yield from... | [
"0.81258786",
"0.76152724",
"0.7595835",
"0.7333707",
"0.71609825",
"0.7120504",
"0.7104925",
"0.70782614",
"0.70782614",
"0.707579",
"0.70283145",
"0.702749",
"0.70215607",
"0.70172447",
"0.69621",
"0.69600874",
"0.69326246",
"0.69045335",
"0.6896022",
"0.68157387",
"0.68079... | 0.7627982 | 1 |
Tests the initialization and running of a workflow with a configuration yaml file | def test_workflow_config(mock_env_home, set_workflow_config, input_path, output_path):
# Write workflow.yaml file
workflow_name = "test-workflow-config"
workflow_config = set_workflow_config[0]
workflow_config["destination"]["output_path"] = output_path
workflow_config["destination"]["index"] = Fals... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_configurator(self):\n runner = Runner(YamlManifest(manifest))\n run1 = runner.run(JobOptions(resource=\"test1\"))\n assert not run1.unexpectedAbort, run1.unexpectedAbort.getStackTrace()\n assert len(run1.workDone) == 1, run1.workDone\n result = list(run1.workDone.values(... | [
"0.68822724",
"0.67206216",
"0.66400737",
"0.6616477",
"0.64584905",
"0.64548177",
"0.63643444",
"0.63445413",
"0.63292676",
"0.63263446",
"0.62706995",
"0.62419355",
"0.62386894",
"0.62195754",
"0.61875206",
"0.6161727",
"0.61542577",
"0.6145375",
"0.61266404",
"0.6126245",
... | 0.6951811 | 0 |
Test confirms that if workflow produces no enriched data that no output file is created | def test_workflow_no_enriched_data(mock_env_home, set_workflow_config, input_path, output_path):
# Create source and destination configurations
source = set_workflow_config[1]
destination = set_workflow_config[2]
source["input_path"] = input_path
destination["output_path"] = output_path
# Create... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_workflow_no_data(mock_env_home, set_workflow_config, input_path, output_path):\n # Create source and destination configurations\n source = set_workflow_config[1]\n destination = set_workflow_config[2]\n source[\"input_path\"] = input_path\n destination[\"output_path\"] = output_path\n\n #... | [
"0.7107578",
"0.70797193",
"0.69251007",
"0.67894983",
"0.6663592",
"0.6645255",
"0.6616969",
"0.65280044",
"0.64092195",
"0.6382751",
"0.6379438",
"0.63791543",
"0.63355976",
"0.62302613",
"0.6210383",
"0.6183999",
"0.6167952",
"0.61557144",
"0.614564",
"0.61419594",
"0.6114... | 0.7350689 | 0 |
Helper function to write workflow.yaml configuration file | def write_config_file(workflow_config, workflow_name):
workflow_dir = "{0}/.config/clx/{1}".format(dirname, workflow_name)
if not os.path.exists(workflow_dir):
os.makedirs(workflow_dir)
with open(workflow_dir + "/workflow.yaml", "w") as f:
yaml.dump(workflow_config, f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self):\n cfgpath = os.path.join(self.config_dir, CONFIG_FILENAME)\n ofile = open(cfgpath, 'w')\n if ofile:\n log.debug( \"Write config: %s\" % cfgpath )\n cfg = yaml.dump(self.yaml, default_flow_style=False)\n log.debug( \"Config:\\n%s\" % cfg)\n ... | [
"0.7270503",
"0.7038618",
"0.70204663",
"0.67338604",
"0.6706485",
"0.6684431",
"0.66827565",
"0.663946",
"0.66339976",
"0.65713143",
"0.6563332",
"0.65350217",
"0.6507845",
"0.64915544",
"0.64478093",
"0.6445943",
"0.64154655",
"0.63305336",
"0.63142926",
"0.6297442",
"0.629... | 0.77259755 | 0 |
The dplace shift of a term t above cutoff c | def typeShiftAbove(d, c, tyT):
tymap = TypeMap(
onvar=lambda c, x, n: TyVar(x+d, n+d) if x >= c else TyVar(x, n+d),
cutoff=c)
return tymap.visit(tyT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dspmt(t):\n t = np.asarray(t)\n return spmt(t) - spmt(t - 1)",
"def _squash_correction(t):\n # TODO: Refer to OpenAI implementation for more numerically stable correction\n # https://github.com/openai/spinningup/blob/master/spinup/algos/pytorch/sac/core.py\n return torch.sum(torch.... | [
"0.5693871",
"0.55972594",
"0.55784374",
"0.5518223",
"0.5509465",
"0.5506729",
"0.54885364",
"0.5475864",
"0.5453303",
"0.54527485",
"0.5408065",
"0.5370242",
"0.53084266",
"0.528154",
"0.5248789",
"0.52028376",
"0.51881176",
"0.5181443",
"0.5175417",
"0.5173579",
"0.5173435... | 0.64094704 | 0 |
This function provides all coordinate atoms in a PDB file, and outputs to a file. | def coord_atoms():
import os
choice = input('Enter the name of the file: ')
filepath = os.path.join('/home/njesh/python-mini-project-JaneNjeri/Data', choice)
a_list = []
with open(filepath, 'r') as pdb:
for line in pdb:
if line[:4] == 'ATOM':
line_split = lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writepdb3(list_of_coords, name):\n list_of_coords2 = []\n for elem in range(len(list_of_coords)):\n if (list_of_coords[elem] not in list_of_coords2):\n list_of_coords2.append(list_of_coords[elem])\n os.chdir(os.getcwd())\n if ((\".pdb\" not in name) and (\".PDB\" not in name)):\n ... | [
"0.7513441",
"0.6889955",
"0.67729276",
"0.677234",
"0.6483865",
"0.64682543",
"0.6431568",
"0.6252634",
"0.619412",
"0.6123344",
"0.6122452",
"0.6096775",
"0.5998792",
"0.5947251",
"0.5931171",
"0.58651996",
"0.5813067",
"0.580622",
"0.58020884",
"0.57915753",
"0.57875085",
... | 0.7229828 | 1 |
This function write out coordinates for all alphacarbon atoms (CA), in a PDB file. | def write_CA_atoms():
import os
choice = input('Enter the name of the file: ')
filepath = os.path.join('/home/njesh/python-mini-project-JaneNjeri/Data', choice)
ca_list = []
with open(filepath, 'r') as pdb:
for line in pdb:
if line[:4] == 'ATOM' and line[12:16] == " CA ":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writepdb(self,fname):\n pdbfile = open(fname + \".pdb\", \"w\")\n for a in self.atoms:\n pdbfile.write(str(a.type) + \"\\t\" + str(a.x) + \"\\t\" + str(a.y) + \"\\t\" + str(a.z) + \"\\n\")\n pdbfile.close()",
"def writepdb3(list_of_coords, name):\n list_of... | [
"0.67991954",
"0.6747536",
"0.61739635",
"0.6170322",
"0.6072794",
"0.60442764",
"0.59800243",
"0.59703165",
"0.58119977",
"0.5752962",
"0.5681545",
"0.5615418",
"0.5575187",
"0.5481844",
"0.5480295",
"0.54744005",
"0.546253",
"0.54363734",
"0.541528",
"0.54086083",
"0.540388... | 0.70517373 | 0 |
This function write out the sequence of the PDB file in a fasta format, based on the coordinates section. | def write_coord_seq():
import os
choice = input('Enter the name of the file: ')
filepath = os.path.join('/home/njesh/python-mini-project-JaneNjeri/Data', choice)
lis = []
with open(filepath, 'r') as file:
for line in file:
if line[:4] == 'ATOM':
line_split = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _writeOneFASTA(sequence, filehandle):\n filehandle.write(\">\" + sequence.getName()+\"\\n\")\n data = sequence.getSequence()\n lines = ( sequence.getLen() - 1) / 60 + 1\n for i in range(lines):\n #note: python lets us get the last line (var length) free\n #lineofseq = data[i*60 : (i+1... | [
"0.6639975",
"0.6584337",
"0.65418094",
"0.6407959",
"0.6387728",
"0.6378226",
"0.6373042",
"0.63087463",
"0.6307065",
"0.6303731",
"0.6280986",
"0.6277212",
"0.6201288",
"0.6190486",
"0.6186309",
"0.61752695",
"0.6118587",
"0.61012286",
"0.61004883",
"0.6085029",
"0.5995717"... | 0.71958053 | 0 |
This function calls out the submenu for writing out sequences in a PDB file, in fasta format. | def submenu2():
j = ''
while j == '':
print('\nS U B M E N U 2')
print('1. SEQRES sequence')
print('2. Coordinate sequence')
print('3. Alignment sequence')
print('b. Back')
print('q. Quit')
option = input('Select an option: ')
if option.lower... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Write_file():\n \n import os\n import sys\n pdbfile_list()\n\n file_list = pdbfile_list()\n \n items = os.listdir('/home/njesh/python-mini-project-JaneNjeri/Data/')\n \n file_list = [name for name in items if name.endswith('.pdb')]\n\n for count, fileName in enumerate(file_list, 0... | [
"0.6118511",
"0.5976945",
"0.59647244",
"0.5870363",
"0.5832415",
"0.5814681",
"0.5804334",
"0.5679246",
"0.5658946",
"0.56446624",
"0.56267023",
"0.55722386",
"0.5569507",
"0.5538576",
"0.5530787",
"0.5504774",
"0.5498563",
"0.5483159",
"0.5482121",
"0.54813945",
"0.5478593"... | 0.63389236 | 0 |
Main function which runs the population initialisation, then chooses which model to run, either the Python/R model or the OpenCL model | def main(parameters_file, no_parameters_file, initialise, iterations, scenario, data_dir, output, output_every_iteration,
debug, repetitions, lockdown_file, use_cache, opencl, opencl_gui, opencl_gpu):
# If we are running with opencl_gui then set opencl to True, so you only need to pass one flag
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n # set up output directory and file\n output_file_folder = \"output/{}\".format(args.experiment_name)\n Path(output_file_folder).mkdir(parents=True, exist_ok=True)\n args.output_file_name = \"{}/{}.csv\".format(output_file_folder, args.model_name)\n args.checkpoint_name = \"{}/{}.pt\"... | [
"0.70694065",
"0.69462544",
"0.6943128",
"0.688267",
"0.68664354",
"0.68212295",
"0.68166226",
"0.68027884",
"0.67726964",
"0.67445964",
"0.66979295",
"0.6659263",
"0.66318476",
"0.65856487",
"0.6579081",
"0.6579081",
"0.65680456",
"0.654768",
"0.65400743",
"0.65373385",
"0.6... | 0.72051686 | 0 |
If user's input is a greeting, return a greeting response | def greeting(sentence):
for word in sentence.split():
if word.lower() in GREETING_INPUTS:
return random.choice(GREETING_RESPONSES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greeting(sentence):\r\n for word in sentence.split():\r\n if word.lower() in GREETING_INPUTS:\r\n return random.choice(GREETING_RESPONSES)",
"def greeting(sentence):\n for word in sentence.split():\n if word.lower() in INPUTS:\n return random.choice(RESPONSES)",
"d... | [
"0.69484407",
"0.68645644",
"0.6784528",
"0.65542436",
"0.653157",
"0.6500704",
"0.6446522",
"0.6437424",
"0.6412287",
"0.6376714",
"0.6370838",
"0.6367144",
"0.6359417",
"0.6346757",
"0.6306879",
"0.6270127",
"0.6267739",
"0.62539667",
"0.6237718",
"0.62252486",
"0.6221855",... | 0.69631165 | 0 |
Tests the secret key sent in the post request with the one stored for this user. Also checks that the user has been set up and is not deleted Return true if they are the same, false otherwise. | def authenticateUser(self, postedSecretKey):
return (not self.deleted) and self.setup_confirmed and self.secret_key == postedSecretKey | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_api(submitted_key, users_key):\r\n if users_key != submitted_key:\r\n return False\r\n else:\r\n return True",
"def has_user(self):\n\t\treturn len( self.a_token ) > 0 and len( self.a_secret ) > 0",
"def know_secret(self):\r\n return(self.secret != \"\") and... | [
"0.655295",
"0.65017235",
"0.63398755",
"0.6263844",
"0.6098665",
"0.6011897",
"0.6011745",
"0.6005103",
"0.5877704",
"0.58532053",
"0.5838412",
"0.58329546",
"0.5803486",
"0.57846344",
"0.5783287",
"0.5775227",
"0.5721551",
"0.5710709",
"0.57016295",
"0.5690968",
"0.5689238"... | 0.76938874 | 0 |
Generates a random string of length 20 with letters and numbers to be stored as a user's secret key. | def _generateSecretKey():
return ''.join(SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(20)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_key():\n key = []\n chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'\n for i in xrange(20):\n key.append(random.choice(chars))\n return ''.join(key)",
"def get_random_secret_key():\n chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'\n... | [
"0.84760064",
"0.83303833",
"0.80883294",
"0.7991474",
"0.79716235",
"0.78556705",
"0.7825114",
"0.7793576",
"0.7765287",
"0.7759033",
"0.76967126",
"0.7645301",
"0.76375616",
"0.758583",
"0.757601",
"0.75389576",
"0.7536386",
"0.7506599",
"0.7499383",
"0.7496711",
"0.7472499... | 0.86365056 | 0 |
Adds a new user to Cloudant if a user with the specified ID does not already exist. | def add_user(self, user_id):
user_doc = {
'type': 'user',
'name': user_id
}
return self.add_doc_if_not_exists(user_doc, 'name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addUser(self, id : int) -> bbUser.bbUser:\n id = self.validateID(id)\n # Ensure no user exists with the specified ID in the database\n if self.userIDExists(id):\n raise KeyError(\"Attempted to add a user that is already in this bbUserDB\")\n # Create and return a new user... | [
"0.7403662",
"0.71318257",
"0.7117046",
"0.6804548",
"0.67237693",
"0.6702986",
"0.66610867",
"0.6650537",
"0.66451794",
"0.6637581",
"0.6633221",
"0.66149116",
"0.6567166",
"0.6557209",
"0.6552168",
"0.6505712",
"0.6476322",
"0.64711523",
"0.64595485",
"0.64449644",
"0.64233... | 0.73941034 | 1 |
Finds the ingredient based on the specified ingredientsStr in Cloudant. | def find_ingredient(self, ingredient_str):
return self.find_doc('ingredient', 'name', self.get_unique_ingredients_name(ingredient_str)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_recipe(ingredients):\n\n params = '+'.join(ingredients.split())\n url_search = SEARCH_URL.format(params)\n response = req.get(url_search)\n\n return response.content",
"def add_ingredient(self, ingredient_str, matching_recipes, user_doc):\n ingredient_doc = {\n 'type': 'i... | [
"0.64196384",
"0.63723385",
"0.59787077",
"0.5608707",
"0.55318654",
"0.55147403",
"0.5431092",
"0.5366164",
"0.53442395",
"0.52913475",
"0.5260261",
"0.5250978",
"0.5240064",
"0.52321863",
"0.521597",
"0.5212754",
"0.51980674",
"0.5117159",
"0.5084609",
"0.50597316",
"0.5013... | 0.8024213 | 0 |
Adds a new ingredient to Cloudant if an ingredient based on the specified ingredientsStr does not already exist. | def add_ingredient(self, ingredient_str, matching_recipes, user_doc):
ingredient_doc = {
'type': 'ingredient',
'name': self.get_unique_ingredients_name(ingredient_str),
'recipes': matching_recipes
}
ingredient_doc = self.add_doc_if_not_exists(ingredient_doc, '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_ingredient_to_recipe(cls, new_count, ingredients_dict, recipe_id):\n\n for i in range(1, (new_count+1)):\n item = ingredients_dict[i][0]\n measure = ingredients_dict[i][1]\n prepnotes = ingredients_dict[i][2]\n qty = ingredients_dict[i][3]\n\n n... | [
"0.6402136",
"0.62395746",
"0.60926694",
"0.6089224",
"0.5745252",
"0.56482553",
"0.5522077",
"0.55129164",
"0.55002844",
"0.54999214",
"0.5491616",
"0.5421674",
"0.5418088",
"0.54120946",
"0.53756034",
"0.5323461",
"0.53057015",
"0.5282823",
"0.5272447",
"0.5263433",
"0.5257... | 0.7257475 | 0 |
Records the request by the user for the specified ingredient. Stores the ingredient and the number of times it has been accessed in the user doc. | def record_ingredient_request_for_user(self, ingredient_doc, user_doc):
try:
self.client.connect()
# get latest user
latest_user_doc = self.client[self.db_name][user_doc['_id']]
# see if user has an array of ingredients, if not create it
if 'ingredient... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_recipe_request_for_user(self, recipe_doc, ingredient_cuisine_doc, user_doc):\n try:\n self.client.connect()\n # get latest user\n latest_user_doc = self.client[self.db_name][user_doc['_id']]\n # see if user has an array of recipes, if not create it\n ... | [
"0.7254027",
"0.60655373",
"0.5620976",
"0.5385148",
"0.53316146",
"0.5264869",
"0.5236615",
"0.5212068",
"0.5203554",
"0.5180342",
"0.51694304",
"0.5160639",
"0.516041",
"0.51377136",
"0.5124968",
"0.5120941",
"0.5117456",
"0.511593",
"0.5113912",
"0.510576",
"0.50938547",
... | 0.81100976 | 0 |
Gets the unique name for the cuisine to be stored in Cloudant. | def get_unique_cuisine_name(cuisine):
return cuisine.strip().lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cloud_name(self):\n return self._cloud_name",
"def name(self):\n return self._unique_id",
"def uniqueName(self):\n return \"{0}::{1}\".format(self.name(), str(self.uid))",
"def name(self):\n _LOGGER.debug(self._shelly_cloud_device_name + ' >>> ' +\n self._... | [
"0.69707954",
"0.67968565",
"0.67321056",
"0.67232347",
"0.6681907",
"0.6660067",
"0.66364676",
"0.6603239",
"0.6563786",
"0.6559235",
"0.64756316",
"0.64637494",
"0.6455279",
"0.6455279",
"0.6431675",
"0.64266485",
"0.6399031",
"0.63853705",
"0.63853705",
"0.63853705",
"0.63... | 0.772097 | 0 |
Finds the cuisine with the specified name in Cloudant. | def find_cuisine(self, cuisine):
return self.find_doc('cuisine', 'name', self.get_unique_cuisine_name(cuisine)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_cinema_by_name(name):\n return Cinema.objects.filter(name=name).first()",
"def search_for_customer(self, name):\n customers_list = self.get_customers()\n return next((customer for customer in customers_list if customer.get('name') == name), {'name': None, 'parent':None, 'active': None, ... | [
"0.6604075",
"0.6361762",
"0.62392396",
"0.5784303",
"0.57595485",
"0.5674132",
"0.5655677",
"0.56188124",
"0.5610572",
"0.55919045",
"0.5574991",
"0.5536591",
"0.5526236",
"0.5455855",
"0.5455855",
"0.54347557",
"0.5412566",
"0.53999233",
"0.5348956",
"0.533814",
"0.526589",... | 0.7685861 | 0 |
Adds a new cuisine to Cloudant if a cuisine with the specified name does not already exist. | def add_cuisine(self, cuisine_str, matching_recipes, user_doc):
cuisine_doc = {
'type': 'cuisine',
'name': self.get_unique_cuisine_name(cuisine_str),
'recipes': matching_recipes
}
cuisine_doc = self.add_doc_if_not_exists(cuisine_doc, 'name')
self.recor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_cuisine(self, cuisine):\n return self.find_doc('cuisine', 'name', self.get_unique_cuisine_name(cuisine))",
"def __init__(self, name, cuisine):\n self.name = name\n self.cuisine = cuisine",
"def __init__(self, name, cuisine):\n self.name = name\n self.cuisine = cuisin... | [
"0.62463516",
"0.6038917",
"0.6038917",
"0.56726915",
"0.56451964",
"0.560645",
"0.53489584",
"0.5211575",
"0.52104944",
"0.5167857",
"0.5094013",
"0.5081382",
"0.50701505",
"0.50697273",
"0.502182",
"0.5007587",
"0.4996839",
"0.4984489",
"0.496807",
"0.4967935",
"0.48786673"... | 0.64994293 | 0 |
Records the request by the user for the specified cuisine. Stores the cuisine and the number of times it has been accessed in the user doc. | def record_cuisine_request_for_user(self, cuisine_doc, user_doc):
try:
self.client.connect()
# get latest user
latest_user_doc = self.client[self.db_name][user_doc['_id']]
# see if user has an array of cuisines, if not create it
if 'cuisines' not in la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_recipe_request_for_user(self, recipe_doc, ingredient_cuisine_doc, user_doc):\n try:\n self.client.connect()\n # get latest user\n latest_user_doc = self.client[self.db_name][user_doc['_id']]\n # see if user has an array of recipes, if not create it\n ... | [
"0.61743486",
"0.5742047",
"0.55771655",
"0.54980665",
"0.5390325",
"0.53030026",
"0.51814884",
"0.5118397",
"0.50666904",
"0.50595593",
"0.505652",
"0.5050669",
"0.49807584",
"0.49764434",
"0.49220353",
"0.49047112",
"0.49016166",
"0.48853627",
"0.4874656",
"0.48486537",
"0.... | 0.78111994 | 0 |
Gets the unique name for the recipe to be stored in Cloudant. | def get_unique_recipe_name(recipe_id):
return str(recipe_id).strip().lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self.recipe_name",
"def get_recipe_identifier(self, recipe):\n identifier = recipe[\"Input\"].get(\"IDENTIFIER\")\n if not identifier:\n print \"ID NOT FOUND\"\n # build a pseudo-identifier based on the recipe pathname\n recipe_path =... | [
"0.78749037",
"0.6840971",
"0.68258405",
"0.672091",
"0.66088504",
"0.6607504",
"0.66001374",
"0.6542941",
"0.65062714",
"0.6503789",
"0.64103025",
"0.6373508",
"0.63614017",
"0.63614017",
"0.63614017",
"0.63614017",
"0.63614017",
"0.63614017",
"0.63614017",
"0.63614017",
"0.... | 0.7637187 | 1 |
Finds the recipe with the specified ID in Cloudant. | def find_recipe(self, recipe_id):
return self.find_doc('recipe', 'name', self.get_unique_recipe_name(recipe_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_recipe(self, _id):\n raise NotImplementedError()",
"def get_recipe(cls, recipeid):\n\n recipe = Recipe.query.filter_by(recipe_id=recipeid).one()\n\n return recipe",
"def fetch_recipe(*, recipe_id: int) -> Any:\n\n result = [recipe for recipe in RECIPES if recipe[\"id\"] == recip... | [
"0.7594997",
"0.7383382",
"0.6990766",
"0.6829485",
"0.67923516",
"0.66948515",
"0.6684738",
"0.6621708",
"0.65666085",
"0.6446299",
"0.6335227",
"0.6195868",
"0.6164148",
"0.6157345",
"0.6126464",
"0.60658747",
"0.6046439",
"0.6020594",
"0.60177875",
"0.60129344",
"0.5988627... | 0.8302437 | 0 |
Finds the user's favorite recipes in Cloudant. | def find_favorite_recipes_for_user(self, user_doc, count):
try:
self.client.connect()
db = self.client[self.db_name]
latest_user_doc = db[user_doc['_id']]
if 'recipes' in latest_user_doc.keys():
user_recipes = latest_user_doc['recipes']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_fav_recipes():\n if not g.user:\n flash(\"Please login to view.\",\"warning\")\n return redirect('/login')\n \n data = search_recipes(request) \n favorite_list = [l.id for l in g.user.recipes]\n favorites = [f['id'] for f in data['results'] if f['id'] in favorite_list]\n \n... | [
"0.7678972",
"0.65551317",
"0.63764644",
"0.63032466",
"0.62328964",
"0.6138599",
"0.61219084",
"0.60753155",
"0.60740477",
"0.6066479",
"0.59104925",
"0.5895202",
"0.58920485",
"0.5865666",
"0.5790188",
"0.5708167",
"0.5705508",
"0.5702603",
"0.5681511",
"0.56741816",
"0.565... | 0.7039102 | 1 |
Records the request by the user for the specified recipe. Stores the recipe and the number of times it has been accessed in the user doc. | def record_recipe_request_for_user(self, recipe_doc, ingredient_cuisine_doc, user_doc):
try:
self.client.connect()
# get latest user
latest_user_doc = self.client[self.db_name][user_doc['_id']]
# see if user has an array of recipes, if not create it
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_ingredient_request_for_user(self, ingredient_doc, user_doc):\n try:\n self.client.connect()\n # get latest user\n latest_user_doc = self.client[self.db_name][user_doc['_id']]\n # see if user has an array of ingredients, if not create it\n if ... | [
"0.6817663",
"0.60684633",
"0.59699374",
"0.5941115",
"0.5925918",
"0.57739407",
"0.5753103",
"0.5695883",
"0.554835",
"0.54054683",
"0.5368459",
"0.5334589",
"0.53227234",
"0.53188944",
"0.53163266",
"0.52971375",
"0.5287158",
"0.52846503",
"0.52569",
"0.5243322",
"0.5201493... | 0.7902559 | 0 |
Finds a doc based on the specified doc_type, property_name, and property_value. | def find_doc(self, doc_type, property_name, property_value):
try:
self.client.connect()
db = self.client[self.db_name]
selector = {
'_id': {'$gt': 0},
'type': doc_type,
property_name: property_value
}
que... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_document(self, metadata_field, field_val):\n\n if metadata_field not in self.metadata_fields:\n raise MissingMetadataError([metadata_field])\n\n if metadata_field == \"date\":\n field_val = int(field_val)\n\n for document in self.documents:\n if getattr... | [
"0.6637194",
"0.6182206",
"0.5832996",
"0.5768869",
"0.5684342",
"0.5682957",
"0.5614469",
"0.5592694",
"0.5527936",
"0.5522087",
"0.55121976",
"0.549408",
"0.5464405",
"0.5431053",
"0.5376275",
"0.5330821",
"0.53095627",
"0.5278214",
"0.5265642",
"0.5260498",
"0.52393246",
... | 0.86970437 | 0 |
Adds a new doc to Cloudant if a doc with the same value for unique_property_name does not exist. | def add_doc_if_not_exists(self, doc, unique_property_name):
doc_type = doc['type']
property_value = doc[unique_property_name]
existing_doc = self.find_doc(doc_type, unique_property_name, property_value)
if existing_doc is not None:
print('Returning {} doc where {}={}'.format(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_document(obj):\n index = obj.get_index_name()\n doc_type = obj.get_document_type()\n body = obj.get_document_body()\n exists = ES.exists(index=index, doc_type=doc_type, id=obj.pk)\n\n if not exists:\n ES.create(index=index, doc_type=doc_type, body=body, id=obj.pk)\n return N... | [
"0.611054",
"0.5632766",
"0.5597991",
"0.55933577",
"0.54912066",
"0.5417457",
"0.53981847",
"0.53293335",
"0.5327089",
"0.5323742",
"0.526858",
"0.52545476",
"0.5241042",
"0.5233962",
"0.522708",
"0.5196779",
"0.51897454",
"0.51704806",
"0.51538277",
"0.5063545",
"0.50605637... | 0.8177068 | 0 |
Create a tcl file that describes a qsys system based off a base qsys file. | def create_tcl_system_file(target, custom_components, sys_clock_rate_hz, template, working_dir):
tcl_file = target.system_name + ".tcl"
logger.info("Making tcl file for qsys")
copyfile(RES_DIR + target.base_qsys_file,
working_dir + target.base_qsys_file)
quartus_version = re.search(r'.int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_qsys_file(target, custom_components, sys_clock_rate_hz, template, working_dir):\n create_tcl_system_file(target, custom_components,\n sys_clock_rate_hz, template, working_dir)\n gen_qsys_file_from_tcl(target.system_name + \".tcl\", working_dir)",
"def gen_qsys_file_from_tc... | [
"0.77672344",
"0.7557116",
"0.69605935",
"0.61645275",
"0.59258425",
"0.5872246",
"0.57592255",
"0.54449874",
"0.541045",
"0.5238685",
"0.5231931",
"0.5229755",
"0.5225811",
"0.51890856",
"0.5182244",
"0.511283",
"0.50993204",
"0.5098818",
"0.50579906",
"0.50564843",
"0.50538... | 0.7829646 | 0 |
Run a command as a subprocess and log the cmd. Logs a message and the command to standard out and logs the output of the command to a logfile | def run_cmd_and_log(cmd, log_msg, log_file_path, err_on_fail=True):
logger.info(log_msg)
logger.info(f"log file can be found at {log_file_path}")
logger.info(cmd.replace("\\", "\\\\"))
with open(log_file_path, "w") as log_file:
process = subprocess.Popen(cmd,
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_command(command, directory='/'):\n command = command.replace('\\\\', '/')\n directory = directory.replace('\\\\', '/')\n print command\n with open(os.path.join(tempfile.gettempdir(), 'test.log'), 'w') as f:\n process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.P... | [
"0.7479172",
"0.7462216",
"0.740506",
"0.735991",
"0.7343922",
"0.7215375",
"0.72044075",
"0.71654505",
"0.70875394",
"0.7078146",
"0.701274",
"0.69459",
"0.69299924",
"0.68735695",
"0.6866887",
"0.68640286",
"0.68082714",
"0.6720168",
"0.67115325",
"0.67037344",
"0.6676487",... | 0.8055413 | 0 |
Generate qsys file that represents a system in Platform Designer. | def gen_qsys_file(target, custom_components, sys_clock_rate_hz, template, working_dir):
create_tcl_system_file(target, custom_components,
sys_clock_rate_hz, template, working_dir)
gen_qsys_file_from_tcl(target.system_name + ".tcl", working_dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_qsys_system(target, custom_components, sys_clock_rate_hz, template, working_dir):\n system_exists = os.path.isfile(working_dir + target.system_name + \".qsys\")\n if not(system_exists):\n gen_qsys_file(target, custom_components,\n sys_clock_rate_hz, template, working_dir)\... | [
"0.7203819",
"0.6325511",
"0.62818646",
"0.58965987",
"0.5863322",
"0.5863322",
"0.5661688",
"0.55886024",
"0.5568931",
"0.5491222",
"0.54823476",
"0.5419112",
"0.5394712",
"0.538607",
"0.53592867",
"0.535594",
"0.5332553",
"0.5322564",
"0.5302037",
"0.5239812",
"0.5229278",
... | 0.68581283 | 1 |
Generate the qsys file from the tcl file using qsysscript. | def gen_qsys_file_from_tcl(tcl_file, working_dir):
# TODO: Updates search path from being a hardcoded (relative) path
ipx_file = "components.ipx"
copyfile(RES_DIR + ipx_file, working_dir + ipx_file)
cmd = f'cd {working_dir} && ' + QSYS_BIN_DIR + 'qsys-script ' + \
f'--script={tcl_file} ' + \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_qsys_file(target, custom_components, sys_clock_rate_hz, template, working_dir):\n create_tcl_system_file(target, custom_components,\n sys_clock_rate_hz, template, working_dir)\n gen_qsys_file_from_tcl(target.system_name + \".tcl\", working_dir)",
"def create_tcl_system_fil... | [
"0.7248534",
"0.72212696",
"0.6248071",
"0.57488835",
"0.5679034",
"0.5220639",
"0.5185655",
"0.5095496",
"0.5053244",
"0.5036436",
"0.4979814",
"0.49347183",
"0.49125186",
"0.4863376",
"0.48574942",
"0.47973153",
"0.47827646",
"0.47740585",
"0.47551546",
"0.47435743",
"0.470... | 0.788633 | 0 |
Generate the make_project.tcl file and copy over needed files. | def gen_project_tcl(project_name, project_revision, target, template, working_dir):
base_project_file = target.base_proj_tcl_file
top_level_vhdl_file = target.top_level_vhdl_file
original_system = target.original_system
logger.info("Generating make_project.tcl")
with open(working_dir + "make_proje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_project(project_name, project_revision, target, template, working_dir):\n gen_project_tcl(project_name, project_revision,\n target, template, working_dir)\n qsys_files = filter(lambda file: file.endswith(\".qsys\"), target.files_list)\n for file in qsys_files:\n gen_qsys_... | [
"0.72692394",
"0.6701755",
"0.66655624",
"0.6571978",
"0.644585",
"0.64106894",
"0.62053",
"0.61334175",
"0.61192715",
"0.61088634",
"0.6080405",
"0.5999778",
"0.59710586",
"0.5945298",
"0.5906773",
"0.58853406",
"0.5879609",
"0.5863016",
"0.58625835",
"0.5862108",
"0.5841605... | 0.7958386 | 0 |
Check if a Quartus project with the given name and revision exists. | def project_with_revision_exists(project_name, project_revision, working_dir):
try:
with open(working_dir + project_name + ".qpf", "r") as project_file:
for line in project_file:
if f"PROJECT_REVISION = \"{project_revision}\"" in line:
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_project_exists(self, project):\n session = self.session_factory()\n exists = session.query(PipelineRun).filter_by(project=project).first()\n session.close()\n if exists:\n return True\n return False",
"def check_existing_project(\n self, description:... | [
"0.68579394",
"0.65762264",
"0.6364895",
"0.6341049",
"0.6183336",
"0.61532426",
"0.5999038",
"0.5985066",
"0.58920544",
"0.5828919",
"0.58182925",
"0.5780027",
"0.57312506",
"0.5724363",
"0.5703073",
"0.5685464",
"0.56812745",
"0.562562",
"0.55993485",
"0.55755734",
"0.55464... | 0.8249584 | 0 |
Generate and compiles the project defined in make_project.tcl. | def gen_project(project_name, project_revision, target, template, working_dir):
gen_project_tcl(project_name, project_revision,
target, template, working_dir)
qsys_files = filter(lambda file: file.endswith(".qsys"), target.files_list)
for file in qsys_files:
gen_qsys_system_from_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_project_tcl(project_name, project_revision, target, template, working_dir):\n base_project_file = target.base_proj_tcl_file\n top_level_vhdl_file = target.top_level_vhdl_file\n original_system = target.original_system\n\n logger.info(\"Generating make_project.tcl\")\n\n with open(working_dir... | [
"0.77112544",
"0.7570964",
"0.6840524",
"0.6802186",
"0.66383195",
"0.66341853",
"0.6615946",
"0.652523",
"0.64695925",
"0.64488447",
"0.6374409",
"0.6285248",
"0.62651664",
"0.62651664",
"0.62651664",
"0.62603164",
"0.62486166",
"0.6221456",
"0.61719203",
"0.61060834",
"0.60... | 0.76754475 | 1 |
Compile an existing Quartus project. Creates a tcl file to execute the compilitation with. | def compile_project(project_name, project_revision, template, working_dir):
tcl_file = "compile_project.tcl"
with open(working_dir + tcl_file, "w") as compile_file:
compile_file.write(template.add_quartus_compile_project(
project_name, project_revision))
log_msg = "Compiling project"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_project_tcl(project_name, project_revision, target, template, working_dir):\n base_project_file = target.base_proj_tcl_file\n top_level_vhdl_file = target.top_level_vhdl_file\n original_system = target.original_system\n\n logger.info(\"Generating make_project.tcl\")\n\n with open(working_dir... | [
"0.688694",
"0.6687275",
"0.6620322",
"0.611469",
"0.5821403",
"0.5693169",
"0.5689069",
"0.56630486",
"0.5566953",
"0.555773",
"0.54483753",
"0.5440808",
"0.54384756",
"0.5409276",
"0.53976715",
"0.5381501",
"0.5353479",
"0.5336392",
"0.5323197",
"0.5309403",
"0.52999014",
... | 0.77143633 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.