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 |
|---|---|---|---|---|---|---|
It inserts single task in the notebook | def insert_single_task(note,task,i):
task_txt = '__Richiesta ' + str(i+1) + ' \[' + str(task['tot_points']) + ' punti\]__: '
task_txt += task['description1']
note['cells'] += [nb.v4.new_markdown_cell(task_txt)]
note.cells[-1].metadata = {"init_cell": True, "editable": False, "deletable": False, "tags": ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(task):\n tasks.insert_one(task.__dict__)",
"def insert_single_graph_task(note,task,i):\n task_txt = '__Richiesta ' + str(i+1) + ' \\[' + str(task['tot_points']) + ' punti\\]__: '\n task_txt += task['description1']\n note['cells'] += [nb.v4.new_markdown_cell(task_txt)]\n note.cells[-1].m... | [
"0.76232517",
"0.75070447",
"0.72566",
"0.6981216",
"0.68950176",
"0.6675669",
"0.66216433",
"0.66114956",
"0.6593036",
"0.65786946",
"0.6565165",
"0.65340275",
"0.65340275",
"0.65340275",
"0.65340275",
"0.6529487",
"0.65182",
"0.6516017",
"0.65036213",
"0.637549",
"0.6365498... | 0.7723317 | 0 |
It inserts single graph task in the notebook | def insert_single_graph_task(note,task,i):
task_txt = '__Richiesta ' + str(i+1) + ' \[' + str(task['tot_points']) + ' punti\]__: '
task_txt += task['description1']
note['cells'] += [nb.v4.new_markdown_cell(task_txt)]
note.cells[-1].metadata = {"init_cell": True, "editable": False, "deletable": False, "t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_single_task(note,task,i):\n task_txt = '__Richiesta ' + str(i+1) + ' \\[' + str(task['tot_points']) + ' punti\\]__: '\n task_txt += task['description1']\n note['cells'] += [nb.v4.new_markdown_cell(task_txt)]\n note.cells[-1].metadata = {\"init_cell\": True, \"editable\": False, \"deletable\"... | [
"0.6518716",
"0.6330897",
"0.6322476",
"0.61989594",
"0.61099726",
"0.6080319",
"0.6060175",
"0.5925725",
"0.5870776",
"0.586264",
"0.5805432",
"0.5796729",
"0.5796208",
"0.57847506",
"0.57609886",
"0.57553774",
"0.57553774",
"0.57553774",
"0.57553774",
"0.57335174",
"0.57162... | 0.81495446 | 0 |
It inserts all tasks in the notebook | def insert_tasks(note, exer_tasks):
for i in range(len(exer_tasks)):
if 'graphml' in exer_tasks[i]:
insert_single_graph_task(note,exer_tasks[i],i)
else:
insert_single_task(note,exer_tasks[i],i)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_single_task(note,task,i):\n task_txt = '__Richiesta ' + str(i+1) + ' \\[' + str(task['tot_points']) + ' punti\\]__: '\n task_txt += task['description1']\n note['cells'] += [nb.v4.new_markdown_cell(task_txt)]\n note.cells[-1].metadata = {\"init_cell\": True, \"editable\": False, \"deletable\"... | [
"0.6673035",
"0.66140544",
"0.6597456",
"0.6560367",
"0.6516223",
"0.6411854",
"0.63824534",
"0.634004",
"0.6207628",
"0.6137081",
"0.6023969",
"0.6017024",
"0.5976587",
"0.5975252",
"0.5893493",
"0.58892006",
"0.58738554",
"0.58422655",
"0.57891345",
"0.578191",
"0.57780385"... | 0.7027427 | 0 |
It inserts all supplementary folders, such as 'allegati' and 'img' if needed | def insert_suppl_folders(path_mode):
global REL_PATH_IMAGES
os.mkdir(path_mode + '/allegati')
if len(images_to_add) > 0:
path_ex_images = path_mode + 'img'
os.mkdir(path_ex_images)
for img in images_to_add:
path_img_src = os.getcwd() + '/' + REL_PATH_IMAGES + img
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_std_dirs(self):\n super().init_std_dirs()\n for a in \"nord\",\"sued\",\"\":\n for b in \"ost\",\"west\",\"\":\n for c in \"ob\",\"unt\",\"\":\n self._std_dirs.add(a+b+c+\"en\")\n self._std_dirs.remove(\"en\") # :-)",
"def _insert_direct... | [
"0.62323695",
"0.57801276",
"0.57184356",
"0.5646572",
"0.55996084",
"0.5578261",
"0.5534348",
"0.55329144",
"0.55256784",
"0.5502216",
"0.54964125",
"0.5493847",
"0.5490419",
"0.5455443",
"0.5451141",
"0.5448923",
"0.5448923",
"0.54366255",
"0.54281116",
"0.5424291",
"0.5419... | 0.71097124 | 0 |
It inserts checkpoints folder for graph exercise | def insert_graph_folder(path_mode):
os.mkdir(path_mode + 'allegati/ck_points') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkpoint_directory(checkpoint):\n if os.path.isdir(checkpoint):\n pass\n else:\n os.mkdir(checkpoint)",
"def checkpoint():",
"def save(self, checkpoint_dir, step):\n model_name = \"CNN.model\"\n model_dir = \"%s\" % (\"cnn\")\n checkpoint_dir = os.path.join(checkpoin... | [
"0.674986",
"0.64394623",
"0.6316174",
"0.63067126",
"0.62779635",
"0.61672807",
"0.6116683",
"0.6101317",
"0.61011064",
"0.6052063",
"0.60136",
"0.59544116",
"0.5916166",
"0.5887528",
"0.5883463",
"0.58677626",
"0.5864836",
"0.58615166",
"0.5861133",
"0.5855455",
"0.5854965"... | 0.65316284 | 1 |
Get offers by address | def get_offers(street_id: int, house_number: str) -> List[Dict[str, Any]]:
url = 'https://api.n1.ru/api/v1/offers/'
params = _offers_params.copy()
params['filter_or[addresses][0][street_id]'] = street_id
params['filter_or[addresses][0][house_number]'] = house_number
offset, count, offers = 0, 1, []... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def expand(self, address: str) -> List[str]: # type: ignore\n request_url = self._get_url(method=\"expand\", address=address)\n async with ClientSession() as session:\n async with session.get(request_url) as response:\n return await response.json()",
"def address(se... | [
"0.6091287",
"0.5870372",
"0.5854513",
"0.58382744",
"0.5755688",
"0.57346946",
"0.5690253",
"0.56761956",
"0.5664629",
"0.565183",
"0.562804",
"0.55766773",
"0.55675524",
"0.5536427",
"0.54976434",
"0.548347",
"0.5481196",
"0.54752403",
"0.54645747",
"0.54293114",
"0.5390426... | 0.66298217 | 0 |
Construct a dumbEmoji object from its dictionary representation. If both an ID and a unicode representation are provided, the emoji ID will be used. | def fromDict(cls, emojiDict : dict, **kwargs) -> dumbEmoji:
rejectInvalid = kwargs["rejectInvalid"] if "rejectInvalid" in kwargs else False
if type(emojiDict) == dumbEmoji:
return emojiDict
if "id" in emojiDict:
if emojiDict["id"] == 0:
return dumbEmoji.E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dumbEmojiFromStr(s : str) -> dumbEmoji:\n if type(s) == dumbEmoji:\n return s\n if type(s) == dict:\n return dumbEmojiFromDict(s)\n if isUnicodeEmoji(s):\n return dumbEmoji(unicode=s)\n elif isCustomEmoji(s):\n return dumbEmoji(id=int(s[s[s.index(\":\")+1:].index(\":\")+... | [
"0.71143246",
"0.67178386",
"0.67085356",
"0.586928",
"0.5608321",
"0.54813236",
"0.53057253",
"0.5232978",
"0.51436514",
"0.5137245",
"0.51251453",
"0.5094067",
"0.50500804",
"0.50497",
"0.5020558",
"0.5019778",
"0.5004183",
"0.49909002",
"0.49721834",
"0.49710587",
"0.49602... | 0.8126695 | 0 |
Get a string uniquely identifying this object, specifying what type of emoji it represents and the emoji itself. | def __repr__(self) -> str:
return "<dumbEmoji-" + ("id" if self.isID else "unicode") + ":" + (str(self.id) if self.isID else self.unicode) + ">" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emoji(self):\n return self._manager.get_emoji(self.name)",
"def what_means_emoji(emoji):\r\n try:\r\n return unicodedata.name(emoji)\r\n except TypeError:\r\n return \"Not found\"",
"def what_means_emoji(emoji: str) -> str:\n try:\n return unicodedata.name(emoji)\n e... | [
"0.70906323",
"0.70417243",
"0.6945318",
"0.6738189",
"0.6588527",
"0.64517045",
"0.6435972",
"0.61878496",
"0.6114433",
"0.60338575",
"0.5971636",
"0.59520096",
"0.59371823",
"0.59272593",
"0.59217024",
"0.5920829",
"0.5869472",
"0.5855183",
"0.5854191",
"0.5854024",
"0.5843... | 0.71700424 | 0 |
Decide if this dumbEmoji is equal to another. Two dumbEmojis are equal if they represent the same emoji (i.e ID/unicode) of the same type (custom/unicode) | def __eq__(self, other : dumbEmoji) -> bool:
return type(other) == dumbEmoji and self.sendable == other.sendable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_equal_same_type(self, other):\n # id\n self_id = self.id\n other_id = other.id\n if (self_id and other_id) and (self_id != other_id):\n return False\n \n # bot\n if self.bot != other.bot:\n return False\n \n # description\... | [
"0.68937147",
"0.672709",
"0.6565798",
"0.6536798",
"0.64388484",
"0.6422217",
"0.64122105",
"0.64017344",
"0.63660663",
"0.6365248",
"0.6365248",
"0.6365248",
"0.6356838",
"0.6338421",
"0.63170964",
"0.63095015",
"0.6297439",
"0.6296631",
"0.6293915",
"0.62918085",
"0.624116... | 0.85106534 | 0 |
Get the object's 'sendable' string. | def __str__(self) -> str:
return self.sendable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_notification_string(self, obj):\n return str(obj)",
"def __str__(self):\n return self.socket.__str__()",
"def sendingString(self):\n return ''",
"def get_string(self):\n return self.__str",
"def __str__(self):\n return self.message.as_string()",
"def str_(object... | [
"0.6647728",
"0.64413273",
"0.6384214",
"0.6264619",
"0.596922",
"0.5957972",
"0.5919381",
"0.5894887",
"0.5892727",
"0.5855834",
"0.5855834",
"0.58506733",
"0.5840316",
"0.58388084",
"0.5806508",
"0.5785254",
"0.57149434",
"0.57088196",
"0.5707448",
"0.57003844",
"0.56927854... | 0.834316 | 0 |
Decide whether a given string contrains a single unicode emoji. | def isUnicodeEmoji(c : str) -> bool:
return c in UNICODE_EMOJI | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isemoji(c):\n if type(c) == str:\n c = c.encode('utf-8')\n c = bytes(c)\n return c.decode() in UNICODE_EMOJI",
"def is_unicode_emoji(self):\n ...",
"def isCustomEmoji(s : str) -> bool:\n if s.startswith(\"<\") and s.endswith(\">\"):\n try:\n first = s.index(\":\"... | [
"0.729983",
"0.7260883",
"0.6767872",
"0.6643175",
"0.64480215",
"0.6371073",
"0.6363176",
"0.6225852",
"0.6214717",
"0.62065816",
"0.61978394",
"0.6130279",
"0.61087215",
"0.60887325",
"0.604412",
"0.601829",
"0.6014799",
"0.60046893",
"0.5983586",
"0.5973297",
"0.5971133",
... | 0.7760603 | 0 |
Decide whether the given string matches the formatting of a discord custom emoji, | def isCustomEmoji(s : str) -> bool:
if s.startswith("<") and s.endswith(">"):
try:
first = s.index(":")
second = first + s[first+1:].index(":") + 1
except ValueError:
return False
return stringTyping.isInt(s[second+1:-1])
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_custom_emoji(self):\n ...",
"def isUnicodeEmoji(c : str) -> bool:\n return c in UNICODE_EMOJI",
"def is_unicode_emoji(self):\n ...",
"def isemoji(c):\n if type(c) == str:\n c = c.encode('utf-8')\n c = bytes(c)\n return c.decode() in UNICODE_EMOJI",
"def test__Emoji__... | [
"0.7647528",
"0.74017656",
"0.7253228",
"0.6766918",
"0.669791",
"0.637084",
"0.6277603",
"0.60913396",
"0.6026468",
"0.6018341",
"0.60052675",
"0.586997",
"0.58484954",
"0.5836161",
"0.5784417",
"0.57647836",
"0.57608426",
"0.56535584",
"0.56405294",
"0.5618477",
"0.559613",... | 0.7713803 | 0 |
Construct a dumbEmoji object from a string containing either a unicode emoji or a discord custom emoji. s may also be a dumbEmoji (returns s), a dictionaryserialized dumbEmoji (returns dumbEmojiFromDict(s)), or only an ID of a discord custom emoji (may be either str or int) | def dumbEmojiFromStr(s : str) -> dumbEmoji:
if type(s) == dumbEmoji:
return s
if type(s) == dict:
return dumbEmojiFromDict(s)
if isUnicodeEmoji(s):
return dumbEmoji(unicode=s)
elif isCustomEmoji(s):
return dumbEmoji(id=int(s[s[s.index(":")+1:].index(":")+3:-1]))
elif ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dumbEmojiFromReaction(e : Union[Emoji, PartialEmoji, str]) -> dumbEmoji:\n if type(e) == dumbEmoji:\n return e\n if type(e) == str:\n if isUnicodeEmoji(e):\n return dumbEmoji(unicode=e)\n elif isCustomEmoji(e):\n return dumbEmojiFromStr(e)\n else:\n ... | [
"0.73704153",
"0.67345047",
"0.6712129",
"0.55812204",
"0.5573378",
"0.5344799",
"0.5204431",
"0.51069784",
"0.5083844",
"0.50199986",
"0.5003013",
"0.5000269",
"0.49893963",
"0.49843222",
"0.49783143",
"0.49485734",
"0.49419922",
"0.49398628",
"0.49135268",
"0.49050397",
"0.... | 0.86721313 | 0 |
Construct a new dumbEmoji object from a given discord.PartialEmoji. | def dumbEmojiFromPartial(e : PartialEmoji) -> dumbEmoji:
if type(e) == dumbEmoji:
return e
if e.is_unicode_emoji():
return dumbEmoji(unicode=e.name)
else:
return dumbEmoji(id=e.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dumbEmojiFromReaction(e : Union[Emoji, PartialEmoji, str]) -> dumbEmoji:\n if type(e) == dumbEmoji:\n return e\n if type(e) == str:\n if isUnicodeEmoji(e):\n return dumbEmoji(unicode=e)\n elif isCustomEmoji(e):\n return dumbEmojiFromStr(e)\n else:\n ... | [
"0.7101741",
"0.6709785",
"0.64398634",
"0.63015676",
"0.6224656",
"0.5882849",
"0.57151186",
"0.5711911",
"0.5615709",
"0.5413826",
"0.53191",
"0.5176797",
"0.5072924",
"0.500275",
"0.4990136",
"0.49339044",
"0.49198377",
"0.49154934",
"0.4903326",
"0.48609483",
"0.4844375",... | 0.8514286 | 0 |
Construct a new dumbEmoji object from a given discord.PartialEmoji, discord.Emoji, or string. | def dumbEmojiFromReaction(e : Union[Emoji, PartialEmoji, str]) -> dumbEmoji:
if type(e) == dumbEmoji:
return e
if type(e) == str:
if isUnicodeEmoji(e):
return dumbEmoji(unicode=e)
elif isCustomEmoji(e):
return dumbEmojiFromStr(e)
else:
raise Va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dumbEmojiFromPartial(e : PartialEmoji) -> dumbEmoji:\n if type(e) == dumbEmoji:\n return e\n if e.is_unicode_emoji():\n return dumbEmoji(unicode=e.name)\n else:\n return dumbEmoji(id=e.id)",
"def dumbEmojiFromStr(s : str) -> dumbEmoji:\n if type(s) == dumbEmoji:\n retu... | [
"0.8397029",
"0.72753966",
"0.6563865",
"0.637708",
"0.5984603",
"0.58272344",
"0.57156444",
"0.55220985",
"0.5387467",
"0.5310422",
"0.52765894",
"0.5270386",
"0.5209428",
"0.51802826",
"0.5163356",
"0.5144365",
"0.51281816",
"0.5125791",
"0.51228696",
"0.5094152",
"0.506551... | 0.7759242 | 1 |
Resolve name to an object hash in repo. | def object_resolve(repo, name):
candidates = list()
hashRE = re.compile(r"^[0-9A-Fa-f]{4,40}$")
# Empty string? Abort.
if not name.strip():
return None
# Head is nonambiguous
if name == "HEAD":
return [ref_resolve(repo, "HEAD")]
if hashRE.match(name):
if len(name)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_hash(cls, name, registry, hash_prefix):\n validate_package_name(name)\n return get_package_registry(registry).resolve_top_hash(name, hash_prefix)",
"def resolve_name(obj, _):\n return obj.name.decode()",
"def resolve_checksum(obj, _):\n return obj.checksum.decode()",
"def get_... | [
"0.67912203",
"0.6606747",
"0.5768186",
"0.5659127",
"0.564087",
"0.5640289",
"0.563536",
"0.5614921",
"0.5572751",
"0.55387646",
"0.54750144",
"0.5431943",
"0.5403939",
"0.54027575",
"0.53777945",
"0.53500545",
"0.53297156",
"0.5290761",
"0.5281102",
"0.5277347",
"0.52418566... | 0.7397585 | 0 |
Adds commandline arguments pertaining to training a model. These are different from the arguments dictating the model architecture. | def add_train_args(parser):
parser.register('type', 'bool', str2bool)
# Runtime environment
runtime = parser.add_argument_group('Environment')
runtime.add_argument('--no-cuda', type='bool', default=False,
help='Train on CPU, even if GPUs are available.')
runtime.add_argument... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_train_args(parser):\n\n # Runtime environment\n runtime = parser.add_argument_group('Environment')\n runtime.add_argument('--dataset', type=str, default=\"searchqa\",\n help='Dataset: searchqa, quasart or unftriviaqa')\n runtime.add_argument('--base_dir', type=str, defau... | [
"0.7584579",
"0.7450639",
"0.7416743",
"0.7408205",
"0.7381234",
"0.72820014",
"0.72462153",
"0.7141932",
"0.71342915",
"0.7133612",
"0.7102615",
"0.70485526",
"0.7035238",
"0.7016071",
"0.6951427",
"0.6938835",
"0.69271606",
"0.68915665",
"0.68802047",
"0.68490934",
"0.68385... | 0.74698377 | 1 |
Simulated annealing exponential. Simulated annealing algorithm using an exponential cooling scheme. Adjusts temperature according to the exponential cooling scheme. Tries to find cheapest neighborhood. | def sim_an_exp(neighborhood, Tmax, Tmin, iterations):
temp = Tmax
# set iteration number to 0 at start
n = 0
plot_list = []
cooling_rate = float(Tmin/Tmax)**(1/iterations)
current_costs = neighborhood.get_total_costs()
while (n < iterations):
temp = Tmax * (float(cooling_rate)*... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anneal():\n best_sol = list(range(SIZE))\n best_sum = get_sum(best_sol)\n shuffle(best_sol)\n\n temp = 10000000\n cool_rate = 0.0003\n\n counter = 0\n while temp > 1:\n new_sol = best_sol.copy()\n i, j = randint(0, SIZE - 1), randint(0, SIZE - 1)\n new_sol[i], new_sol[... | [
"0.6621392",
"0.6526154",
"0.6444988",
"0.63142693",
"0.6181417",
"0.60797936",
"0.60496944",
"0.5986877",
"0.5936431",
"0.589768",
"0.5877126",
"0.5728195",
"0.5727873",
"0.56842846",
"0.55905545",
"0.5544997",
"0.54957473",
"0.5488071",
"0.5485391",
"0.54837227",
"0.5463890... | 0.70145494 | 0 |
Output a text message remotely, in CLI caller process, whose | def remote_output(text_message, clear_terminal=False, *args, **kwargs):
try:
return current_thread().listener.process(
LicornMessage(data=text_message,
channel=kwargs.pop('_message_channel_', 1),
clear_terminal=clear_terminal, **kwargs),
options.msgproc.getProxy())
except AttributeError:
impor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output(self, msg):",
"def _say(text):\n subprocess.call(['say', text])",
"def output_raw_message(text):\n database.messages_output_queue.put(text)",
"def output(text):\n sys.stdout.write(text)",
"def print_srv(msg):\n\tprint \"Server:\", \" >> \", msg",
"def send_message(self, the_messag... | [
"0.6457053",
"0.6456575",
"0.6390399",
"0.6327086",
"0.6300392",
"0.62942404",
"0.62228566",
"0.6210915",
"0.6201261",
"0.6190994",
"0.61495626",
"0.61495626",
"0.61495626",
"0.61495626",
"0.6128676",
"0.61205196",
"0.610542",
"0.6079627",
"0.6079339",
"0.6077453",
"0.6077404... | 0.71699345 | 0 |
We will store the reference to the clientside listener as an attribute of the current thread, for any serverside output to go to him. | def set_listener(self, listener):
th = current_thread()
#print '>> SET listener on', th.name, listener
th.listener = listener | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_client(self):\n e = threading.Event()\n reg_t = threading.Thread(target=self.handle_reg_client, args=(e,))\n stream_t = threading.Thread(target=self.handle_stream_client,\n args=(e,))\n reg_t.start()\n stream_t.start()",
"def start_... | [
"0.6247886",
"0.58453846",
"0.5763011",
"0.5719741",
"0.5718329",
"0.57051593",
"0.5697255",
"0.5535844",
"0.5532213",
"0.55186445",
"0.54966384",
"0.546701",
"0.5453457",
"0.5452526",
"0.54516095",
"0.54486775",
"0.544669",
"0.5401086",
"0.5398339",
"0.5377311",
"0.53742",
... | 0.6229746 | 1 |
define a "_" attribute on the current thread, based on languages known by the current daemon instance. The "_" will be called, afterwise, by the global "_" builtin, which will look for it in every running thread. | def setup_listener_gettext(self):
th = current_thread()
#print '>> listener gettext in ', th.name
try:
th._ = th._licornd.langs[th.listener.lang].ugettext
except KeyError:
# the daemon doesn't have the client lang installed. Not a problem.
# Still, make a shortcut to the daemon's default translator ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _define_nlp(new_nlp: Language):\n global nlp\n nlp = new_nlp",
"def name_thread( cls, id, ):\n if cls.main_thread_id is None:\n y= 1/0 # cheap exception when main_thread not set up\n\n if id == cls.main_thread_id:\n ret = f\"Main\"\n else:\n ret ... | [
"0.5163722",
"0.51049274",
"0.5094344",
"0.50404215",
"0.50404215",
"0.5001869",
"0.49973524",
"0.49887657",
"0.49527636",
"0.4952586",
"0.49323928",
"0.49224895",
"0.48921528",
"0.48565826",
"0.48565826",
"0.4794708",
"0.47946295",
"0.47946295",
"0.47852412",
"0.47852412",
"... | 0.54593545 | 0 |
process a message and sends answer via callback if needed. | def process(self, message, callback):
if message.type == message_type.EMIT:
# We are in the server, the message has just been built.
# Forward it nearly "as is". Only the message type is changed,
# to make us know it has been processed one time since emission,
# and thus the next hop will be the client, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_msg(msg):\n if comm._msg_callback:\n comm._msg_callback(msg)",
"def message_callback(self, message):\n pass",
"def handle(self, message):\n for callback in self.callbacks:\n callback(message['data'])",
"def handle(self, message):\n print(\"... | [
"0.71582013",
"0.6970587",
"0.6961721",
"0.69066334",
"0.6903625",
"0.6903625",
"0.68190426",
"0.6788773",
"0.6773902",
"0.67577934",
"0.6756239",
"0.6722958",
"0.6685537",
"0.667079",
"0.6637155",
"0.6630341",
"0.6580362",
"0.65576947",
"0.6553877",
"0.6517122",
"0.65083236"... | 0.7846346 | 0 |
checks if the given programm terminates and returns accumulator dict | def check_execution(programm: List[str]):
line_counter = 0
list_of_executed_lines = [0]
accumulator_value = {'act_val': 0}
last_instruction = len(programm)
while True:
(command, value) = programm[line_counter]
if command == 'nop':
line_counter = nop(line_counter, value)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_results(self):\n if not 'EXECUTION OF GAMESS TERMINATED NORMALLY' in self.file_dic['output']:\n print self.job_name + \" didn't finish\"\n raise TypeError('Calculation didn\\'t finish')",
"def determine_exit_code(self) -> int:",
"def state_processing_exit(cfg, app, win):... | [
"0.5274038",
"0.52132493",
"0.5066323",
"0.49277002",
"0.48872745",
"0.48607138",
"0.4858303",
"0.48562905",
"0.48065233",
"0.4799421",
"0.47846892",
"0.47835",
"0.47149792",
"0.47120002",
"0.4694685",
"0.46841353",
"0.46828207",
"0.46718556",
"0.46710336",
"0.464818",
"0.464... | 0.62431157 | 0 |
Calls semantic actions for the given tree node. | def call_actions(self, node, context=None):
self.context = context = context if context else Context()
context.parser = self
def set_context(context, node):
context.start_position = node.start_position
context.end_position = node.end_position
context.node = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_node(node):\r\n if not isinstance(node, ParseResults):\r\n # Then treat it as a terminal node.\r\n if terminal_converter is None:\r\n return node\r\n else:\r\n return terminal_converter(node)\r\n\r\n ... | [
"0.65022296",
"0.64837646",
"0.6361529",
"0.5986352",
"0.58124864",
"0.577195",
"0.577195",
"0.5768551",
"0.5735777",
"0.5678265",
"0.5619564",
"0.55530465",
"0.55490094",
"0.5507411",
"0.5452447",
"0.54408294",
"0.53673846",
"0.53673846",
"0.5363453",
"0.53328955",
"0.533088... | 0.69352645 | 0 |
For the current position in the input stream and actions in the current state find next tokens. This function must return only tokens that are relevant to specified context ie it mustn't return a token if it's not expected by any action in given state. | def _next_tokens(self, context):
state = context.state
input_str = context.input_str
position = context.position
actions = state.actions
in_len = len(input_str)
tokens = []
# add special tokens (EMPTY and STOP) if they are applicable
if EMPTY in actions:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_token(self, context, token):",
"def _get_all_possible_tokens_ahead(self, context):\n tokens = []\n if context.position < len(context.input_str):\n for terminal in self.grammar.terminals.values():\n try:\n tok = terminal.recognizer(context.input_... | [
"0.66236097",
"0.6461844",
"0.6441464",
"0.6415223",
"0.6155764",
"0.6155764",
"0.6155764",
"0.6124266",
"0.60193527",
"0.5668175",
"0.5642413",
"0.56317776",
"0.5591159",
"0.5569572",
"0.5554571",
"0.55447847",
"0.55132",
"0.55073",
"0.5484807",
"0.5483292",
"0.547721",
"0... | 0.7525591 | 0 |
Calls registered shift action for the given grammar symbol. | def _call_shift_action(self, context):
debug = self.debug
token = context.token
sem_action = token.symbol.action
if self.build_tree:
# call action for building tree node if tree building is enabled
if debug:
h_print("Building terminal node",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _call_shift_action(self, context):\n debug = self.debug\n token = context.token\n sem_action = token.symbol.action\n\n if self.build_tree:\n # call action for building tree node if tree building is enabled\n if debug:\n h_print(\"Building termina... | [
"0.60593754",
"0.58083284",
"0.5472519",
"0.5405932",
"0.534024",
"0.5325374",
"0.5295643",
"0.5295643",
"0.5265304",
"0.5261245",
"0.5103639",
"0.5092218",
"0.49588338",
"0.49423075",
"0.49236375",
"0.48676485",
"0.48510936",
"0.4850286",
"0.48325142",
"0.47916",
"0.47611374... | 0.64362437 | 0 |
Calls registered reduce action for the given grammar symbol. | def _call_reduce_action(self, context, subresults):
debug = self.debug
result = None
bt_result = None
production = context.production
if self.build_tree:
# call action for building tree node if enabled.
if debug:
h_print("Building non-term... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _call_reduce_action(self, context, subresults):\n debug = self.debug\n result = None\n bt_result = None\n production = context.production\n\n if self.build_tree:\n # call action for building tree node if enabled.\n if debug:\n h_print(\"Bu... | [
"0.5647278",
"0.5551271",
"0.53377557",
"0.52707666",
"0.52382267",
"0.52345824",
"0.5143216",
"0.51314694",
"0.50739235",
"0.49302822",
"0.49294648",
"0.48488995",
"0.4841632",
"0.48236185",
"0.47548437",
"0.47397217",
"0.47113505",
"0.45758638",
"0.45712143",
"0.45620832",
... | 0.57662225 | 0 |
When the class is initialized, I start off by predefining the clusters I'll be sorting the side effects into, and collecting the side effects that I'll be sorting. | def __init__(self):
self._predefined_cluster_topics()
self._gatherSEs() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortSEs(self):\n # Starting off by printing to screen all of the information I need to know to do the sorting\n for i,cluster in enumerate(self.clusters):\n print(\"Cluster ID: {:g}\\t\\t Cluster: {:s}\".format(i, cluster))\n \n df_info = []\n for SE in np.unique(s... | [
"0.62850326",
"0.61733544",
"0.6152049",
"0.6029055",
"0.5959611",
"0.5955761",
"0.5872654",
"0.5853246",
"0.5838495",
"0.5800631",
"0.57865006",
"0.5755781",
"0.57259995",
"0.56953233",
"0.5679612",
"0.56667656",
"0.5663166",
"0.56548065",
"0.5651312",
"0.56196284",
"0.56160... | 0.63086236 | 0 |
Cluster definitions were chosen based on the top classes of side effects that were repeatedly mentioned when exploring the side effect identifications in the top 99.5% of detections. These have been typed in so that there are names that are humanreadable for the website. As a note to remind myself, I did look into doin... | def _predefined_cluster_topics(self):
self.clusters = ['Doesnt fit',
'Weight changes',
'Mood and behavioral changes',
'Vision changes',
'Headaches',
'Body aches and pain',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_defect_clusters_modifier(frame, data):\n\n if data.particles.count == 0:\n # No particles there to classify, create empty properties anyway\n data.particles_.create_property('Si_V', dtype=int, components=1)\n data.particles_.create_property('Si_I', dtype=int, components=1)\n ... | [
"0.65005785",
"0.630571",
"0.6224865",
"0.6172398",
"0.60474205",
"0.6022522",
"0.60134906",
"0.59746605",
"0.5973413",
"0.5972667",
"0.5944649",
"0.5902835",
"0.5882888",
"0.587975",
"0.58641523",
"0.58494043",
"0.5837116",
"0.58261085",
"0.58129156",
"0.5758364",
"0.5746152... | 0.6719053 | 0 |
Using the side effect information that was matched for each review using IdentifySideEffects.py, in this function I go through the results and drop any side effect that showed up in 0.05% or fewer of the reviews, and collect the names of the others to be hand clustered into different side effect bunches. | def _gatherSEs(self):
# Grab all files for every condition to sort
files = glob.glob('ReviewsMatched2SideEffects/*csv')
files = np.sort(files)
# For each dataframe, grab top 99.5% of reviews, and just consider side effect info
notSEcols = ['Full Review', 'Positive polarity', 'Ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapRev2Cluster(self):\n\n # For each condition, operating on the side effect matching file to reduce down into\n # the more general categories\n clusterMapping = pd.read_csv('ClusteredSideEffects.csv', sep='$', index_col=0)\n for condition in self.conditions:\n print(\"I'... | [
"0.5698241",
"0.5311521",
"0.5279259",
"0.5263338",
"0.5245303",
"0.5178098",
"0.51491153",
"0.5120402",
"0.50660115",
"0.50506526",
"0.5050289",
"0.50355315",
"0.49921966",
"0.4966798",
"0.4931672",
"0.49259079",
"0.49068508",
"0.49033716",
"0.48931625",
"0.4890035",
"0.4854... | 0.69928265 | 0 |
This function takes the side effect clustering info, and translates the columns of the reviews where side effects were identified into this smaller collection of categories, by just doing a boolean check of whether any of the side effects in the cluster were mentioned in the review. | def mapRev2Cluster(self):
# For each condition, operating on the side effect matching file to reduce down into
# the more general categories
clusterMapping = pd.read_csv('ClusteredSideEffects.csv', sep='$', index_col=0)
for condition in self.conditions:
print("I'm working on... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_defect_clusters_modifier(frame, data):\n\n if data.particles.count == 0:\n # No particles there to classify, create empty properties anyway\n data.particles_.create_property('Si_V', dtype=int, components=1)\n data.particles_.create_property('Si_I', dtype=int, components=1)\n ... | [
"0.6361595",
"0.5947091",
"0.5854552",
"0.58110327",
"0.56161827",
"0.5561606",
"0.5517034",
"0.5451545",
"0.54303914",
"0.53707826",
"0.53635705",
"0.5320519",
"0.53024",
"0.5277033",
"0.5269413",
"0.52648365",
"0.5259141",
"0.5234076",
"0.5209505",
"0.5199268",
"0.51855546"... | 0.6780027 | 0 |
Returns the url for raw version on a hastebinlike. | def get_raw(link: str) -> str:
link = link.strip("<>/") # Allow for no-embed links
authorized = (
"https://hastebin.com",
"https://gist.github.com",
"https://gist.githubusercontent.com",
)
if not any([link.startswith(url) for url in authorized]):
raise BadArgument(mes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_url(self) -> str:\n return self.url_as(raw=True)",
"def url_HITEMP():\n url=u\"https://hitran.org/hitemp/data/bzip2format/\"\n return url",
"def get_url(self):\r\n if self.mod.filename:\r\n return self.mod.service.get_mirror() + self.mod.filename",
"def Url(self) -> str... | [
"0.67534655",
"0.66471505",
"0.6378518",
"0.6211556",
"0.6174408",
"0.6144776",
"0.6084945",
"0.6028592",
"0.6020991",
"0.5949043",
"0.5875202",
"0.58715135",
"0.585292",
"0.585292",
"0.58210635",
"0.5820153",
"0.58103424",
"0.579868",
"0.5787926",
"0.57786345",
"0.5759821",
... | 0.671765 | 1 |
Inits CoordinateTransform. Initializes the logger "ge_search". | def __init__(self):
self._utils = utils.SearchUtils()
self._logger = self._utils.logger
self._dms_pattern = (
r"\s*(\d+)\s*°\s*(\d+)\s*(?:ʹ|′|')\s*(\d+\.?\d*)\s*(?:ʺ|\"|″)"
r"\s*([EWNS])\s*")
self._ddm_pattern = (
r"\s*(\d+)\s*°\s*(\d+\.?\d*)\s*(?:ʹ|′|')\s*([EWNS])\s*")
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, logger=logging.getLogger(\"dummy\")):\n super(ShowMap, self).__init__()\n self.logger = logger",
"def __init__(self, look_from, look_to, look_up=vec3(0, 1, 0),\n interspatial_distance=1.0,\n spatial_rows=8, spatial_cols=8):\n self.set_look(l... | [
"0.58225256",
"0.57891184",
"0.5727557",
"0.55570704",
"0.54991025",
"0.54635084",
"0.54302835",
"0.54293704",
"0.5418686",
"0.540085",
"0.53255767",
"0.53100204",
"0.5306434",
"0.5301951",
"0.5292017",
"0.5289117",
"0.5275699",
"0.5263299",
"0.5262443",
"0.52277774",
"0.5221... | 0.60678434 | 0 |
Performs a coordinate transformation from DMS format to DD. | def TransformDMSToDD(self, coordinates):
conversion_status = False
is_valid_latitude = False
is_valid_longitude = False
decimal_degrees_coordinates = []
self._logger.debug(
"Performing DMS to DD transformation on coordinates %s, %s.",
coordinates[0], coordinates[1])
for (iter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TransformDDMToDD(self, coordinates):\n\n conversion_status = False\n is_valid_latitude = False\n is_valid_longitude = False\n\n decimal_degrees_coordinates = []\n\n self._logger.debug(\n \"Performing DDM to DD transformation on coordinates %s, %s.\",\n coordinates[0], coordinates[1... | [
"0.7525573",
"0.6748616",
"0.6722527",
"0.6354118",
"0.6346019",
"0.6219656",
"0.5987066",
"0.5948604",
"0.58772933",
"0.5858982",
"0.57792664",
"0.576169",
"0.5757614",
"0.5563154",
"0.5552106",
"0.55492955",
"0.54525703",
"0.5426175",
"0.54229134",
"0.53983045",
"0.53861314... | 0.77212256 | 0 |
Performs a coordinate transformation from DDM format to DD. | def TransformDDMToDD(self, coordinates):
conversion_status = False
is_valid_latitude = False
is_valid_longitude = False
decimal_degrees_coordinates = []
self._logger.debug(
"Performing DDM to DD transformation on coordinates %s, %s.",
coordinates[0], coordinates[1])
for (iter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TransformDMSToDD(self, coordinates):\n\n conversion_status = False\n is_valid_latitude = False\n is_valid_longitude = False\n\n decimal_degrees_coordinates = []\n\n self._logger.debug(\n \"Performing DMS to DD transformation on coordinates %s, %s.\",\n coordinates[0], coordinates[1... | [
"0.7474167",
"0.6904719",
"0.6519173",
"0.600629",
"0.59713817",
"0.59111756",
"0.5886718",
"0.5722866",
"0.571665",
"0.5692827",
"0.5613098",
"0.5562689",
"0.55029976",
"0.5487671",
"0.5472231",
"0.544446",
"0.5414255",
"0.535084",
"0.53320277",
"0.52730834",
"0.52131176",
... | 0.7517128 | 0 |
Performs a coordinate transformation from MGRS format to DD. | def TransformMGRSToDD(self, coordinate):
conversion_status = False
decimal_degrees_coordinates = []
self._logger.debug(
"Performing MGRS to DD transformation on coordinates %s.", coordinate)
try:
mgrs_obj = mgrs.MGRS()
(latitude, longitude) = mgrs_obj.toLatLon(str(coordinate[0]))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TransformUTMToDD(self, coordinates):\n conversion_status = True\n decimal_degrees_coordinates = []\n\n zone_number = 0\n zone_letter = \"\"\n easting = 0.0\n northing = 0.0\n\n self._logger.debug(\n \"Performing UTM to DD transformation on coordinates %s.\", coordinates)\n\n matc... | [
"0.7061816",
"0.69003606",
"0.6772094",
"0.6195972",
"0.577376",
"0.56875616",
"0.5570641",
"0.5536427",
"0.5486212",
"0.5471577",
"0.5439173",
"0.5439173",
"0.5393237",
"0.53706396",
"0.5322971",
"0.5322351",
"0.528734",
"0.5282393",
"0.52597624",
"0.5247148",
"0.5231469",
... | 0.7295104 | 0 |
Performs a coordinate transformation from UTM format to DD. UTM stands for Universal Transverse Mercator. Each UTM coordinate transforms into a latitude and longitude values Latitude bands in A, B, I, O, X and Y are not valid Zone range should be in 1 to 60 Zone bands 32X, 34X, 36X are not used | def TransformUTMToDD(self, coordinates):
conversion_status = True
decimal_degrees_coordinates = []
zone_number = 0
zone_letter = ""
easting = 0.0
northing = 0.0
self._logger.debug(
"Performing UTM to DD transformation on coordinates %s.", coordinates)
matched = re.match(self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LLtoUTM( Lat, Long, ReferenceEllipsoid=23):\r\n a = _ellipsoid[ReferenceEllipsoid][_EquatorialRadius]\r\n eccSquared = _ellipsoid[ReferenceEllipsoid][_eccentricitySquared]\r\n k0 = 0.9996\r\n\r\n#Make sure the longitude is between -180.00 .. 179.9\r\n LongTemp = (Long+180)-int((Long+180)/360)*360-1... | [
"0.61168015",
"0.60796356",
"0.58007675",
"0.5572624",
"0.5431108",
"0.54139775",
"0.5363576",
"0.53400147",
"0.53209305",
"0.52154",
"0.5192102",
"0.51857835",
"0.51463497",
"0.5111765",
"0.51029116",
"0.5094791",
"0.50906944",
"0.4999059",
"0.4921121",
"0.4911285",
"0.49011... | 0.78469384 | 0 |
Check the coordinate type. Valid types are DD, DMS, DDM, UTM, MGRS. | def GetInputType(self, coordinates):
coordinate_type = ""
pattern_matched = []
for pattern, input_type in self._input_pattern_types:
pattern_obj = re.compile(pattern)
pattern_matched = [pattern_obj.match(z) is not None for z in coordinates]
if self.IsValidInputType(pattern_matched):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_xyz_coord_type(xyz_coord):\n\n if type(xyz_coord) is not list and type(xyz_coord) is not tuple:\n raise TypeError(\"Coordinates must be a list or tuple.\")\n\n if len(xyz_coord) != 3:\n raise ValueError(\"Coordinates must have a length of 3.\")\n\n for i in xyz_coord:\n che... | [
"0.6791422",
"0.62034756",
"0.6023375",
"0.57705986",
"0.5761784",
"0.57582533",
"0.5719532",
"0.57169145",
"0.56801",
"0.5658772",
"0.5597396",
"0.5580171",
"0.5578312",
"0.5509077",
"0.5492488",
"0.54869676",
"0.5473583",
"0.5458756",
"0.5445187",
"0.5437756",
"0.54295564",... | 0.68479925 | 0 |
Create a basic pyarrow array | def basic_array_creation():
print('From normal creation')
arr: pa.Array = pa.array([1, 2, 3, 4, 5], type=pa.int8())
print(arr)
print('From pandas series')
arr: pa.Array = pa.Array.from_pandas(pd.Series([1, 2, 3, 4, 5]))
print(arr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _numpy_to_arrow_array(array: np.ndarray) -> pa.Array:\n num_elems = array.shape[0] # Do we need a code path for one-dim numpy arrays? That lets unwanted inputs creep in. \n data_buffer = pa.py_buffer(np.ascontiguousarray(array))\n offsets = pa.py_buffer(\n np.linspace(0, data_buffer.size, num=... | [
"0.71162504",
"0.64124566",
"0.63962644",
"0.6369482",
"0.6333945",
"0.62978005",
"0.6251755",
"0.62341565",
"0.6190227",
"0.6138734",
"0.61303043",
"0.6108928",
"0.6086987",
"0.6085836",
"0.6075743",
"0.6030543",
"0.60226136",
"0.60002375",
"0.5953602",
"0.5953602",
"0.59393... | 0.77110356 | 0 |
Write to parquet file and read back into pyarrow table | def basic_table_read_write_parquet():
numbers = pa.table([
pa.array(range(1, 6), type=pa.int8()),
pa.array(range(10, 60, 10), type=pa.int8()),
pa.array(range(100, 600, 100), type=pa.int16()),
], names=['a', 'b', 'c'])
fn = 'numbers.parquet'
fp = os.path.join(DATA_OUTPUT_DIR, fn)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_file_to_parquet(input_file, output_file):\n df = pd.read_csv(input_file)\n df.to_parquet(output_file)",
"def export_to_parquet(data):\n table = pa.Table.from_pandas(data)\n pq.write_to_dataset(table\n , root_path=os.path.join(os.getcwd(),EXPORT_PATH['PARQUET_BASE_PATH']... | [
"0.69995284",
"0.6804984",
"0.6769222",
"0.66753775",
"0.6637115",
"0.65674895",
"0.6467774",
"0.63901526",
"0.6375069",
"0.63018656",
"0.6293713",
"0.60635674",
"0.6028268",
"0.60231304",
"0.5893761",
"0.58736205",
"0.5832343",
"0.5798294",
"0.57622206",
"0.57443166",
"0.571... | 0.7746117 | 0 |
Get basic details about the table | def basic_table_details():
tbl: pa.table = pa.Table.from_pylist([
{'first_name': 'Kakashi', 'last_name': 'Hatake', },
{'first_name': 'Itachi', 'last_name': 'Uchiha', },
{'first_name': 'Shisui', 'last_name': 'Uchiha', },
])
results = {
'column_names': tbl.column_names,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n return TableDetails.query.all(), 200",
"def table_info(self, table_path: str, verbose:bool = True) -> Table:\n dataset, table = table_path.split('.')\n dataset_ref = self.client.dataset(dataset)\n table_ref = dataset_ref.table(table)\n info = self.client.get_ta... | [
"0.7769854",
"0.72460604",
"0.70347965",
"0.68604356",
"0.6852934",
"0.6802214",
"0.6802214",
"0.67834836",
"0.66877687",
"0.6619868",
"0.6588988",
"0.6571055",
"0.65535975",
"0.65366066",
"0.65298",
"0.64865065",
"0.64839876",
"0.64839876",
"0.64083654",
"0.639374",
"0.63578... | 0.74669945 | 1 |
Helper method that reads and extracts color component from an image. RGB color space is implied. | def read_image_color(path: str, color: str) -> np.ndarray:
img = imread(path)
if color == 'red':
return img[:, :, 0]
elif color == 'green':
return img[:, :, 1]
elif color == 'blue':
return img[:, :, 2]
return read_image_greyscale(path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color(im_obj):\n #im = Image.open(path, 'r')\n x, y = im_obj.size\n\n r, g, b = 0, 0, 0\n for i in xrange(x):\n for j in xrange(y):\n color_px = im_obj.getpixel((i, j))\n #print color_px\n r += color_px[0]\n g += color_px[1]\n b += c... | [
"0.7307919",
"0.70542383",
"0.70472246",
"0.6942331",
"0.691418",
"0.68836814",
"0.6750066",
"0.67246366",
"0.66998976",
"0.65578544",
"0.6533599",
"0.65319836",
"0.65065336",
"0.6444968",
"0.64053226",
"0.6382954",
"0.6355968",
"0.6350754",
"0.634277",
"0.63340145",
"0.63277... | 0.7349516 | 0 |
Method that calculates percentage of similarity between the two images, based on the histogram of oriented gradients criteria. | def similarity_two_images_hog(img1: np.ndarray, img2: np.ndarray) -> np.ndarray:
hog_image1 = hog_of_image(img1)
hog_image2 = hog_of_image(img2)
max_difference = max(2 * sum_all_magnitudes(img1), 2 * sum_all_magnitudes(img2))
return 100 - 100 * np.sum(np.absolute(hog_image1 - hog_image2)) / max_differe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def similarity_two_images_color(img1: np.ndarray, img2: np.ndarray) -> np.ndarray:\n hist_image_1 = histogram_of_image_color(img1, HIST_BINS_INTENSITY, BIN_DIFFERENCE_INTENSITY_HALF)\n hist_image_2 = histogram_of_image_color(img2, HIST_BINS_INTENSITY, BIN_DIFFERENCE_INTENSITY_HALF)\n max_difference = max(... | [
"0.7540546",
"0.7163017",
"0.6756175",
"0.65709436",
"0.6542429",
"0.6531283",
"0.6515051",
"0.6010692",
"0.5963248",
"0.5929537",
"0.5915009",
"0.5903433",
"0.59020185",
"0.5895249",
"0.5883509",
"0.58757615",
"0.5861176",
"0.5844794",
"0.5823207",
"0.58217096",
"0.581695",
... | 0.7218943 | 1 |
Method that calculates percentage of similarity between the two images, based on the color intensity histogram . | def similarity_two_images_color(img1: np.ndarray, img2: np.ndarray) -> np.ndarray:
hist_image_1 = histogram_of_image_color(img1, HIST_BINS_INTENSITY, BIN_DIFFERENCE_INTENSITY_HALF)
hist_image_2 = histogram_of_image_color(img2, HIST_BINS_INTENSITY, BIN_DIFFERENCE_INTENSITY_HALF)
max_difference = max(2 * np.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def similarity_score(self, img1, img2):\n\t\t# resize into the same shape first\n\t\tif img1.shape != img2.shape:\n\t\t\tv, h = max(img1.shape[0], img2.shape[0]), max(img1.shape[1], img2.shape[1])\n\t\t\tdim = (h, v)\n\t\t\th_scale = min(img1.shape[1], img2.shape[1]) / h\n\t\t\tv_scale = min(img1.shape[0], img2.sh... | [
"0.7740349",
"0.7458357",
"0.71896726",
"0.7043453",
"0.7038354",
"0.69585323",
"0.68749",
"0.68118656",
"0.668674",
"0.6680084",
"0.66232836",
"0.66081375",
"0.6484376",
"0.64747816",
"0.6471494",
"0.6433179",
"0.64161193",
"0.63970333",
"0.63619226",
"0.6344773",
"0.6303669... | 0.8422804 | 0 |
Method that visualizes input images and returns the YES/NO answer. If the result from same_landmark_images is above the threshold, the answer will be YES. Otherwise, answer will be NO. | def visualize_results_same_landmark(img_1: str, img_2: str) -> None:
similarity_percentage = same_landmark_images(img_1, img_2)
print(similarity_percentage)
same_landmark = 'YES' if similarity_percentage > THRESHOLD else 'NO'
fig = plt.figure()
ax = fig.add_subplot(121)
ax.imshow(imread(img_1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkAnswer(img, marker, answerList, threshold=110):\n\n markerCenter = np.asarray(marker.shape)//2\n width = img.shape[1]\n height = img.shape[0]\n\n #To run template matching to find answer markers\n resultFinal = cv2.matchTemplate(imgModified, marker, 0)\n resultFinal = (1-resultFinal/np.m... | [
"0.6469036",
"0.61177295",
"0.6027925",
"0.60039324",
"0.5954979",
"0.59176314",
"0.5912567",
"0.589861",
"0.5896603",
"0.5889799",
"0.58722126",
"0.58580315",
"0.57845366",
"0.57761604",
"0.57746804",
"0.5770863",
"0.57100344",
"0.56825066",
"0.5669011",
"0.5664584",
"0.5664... | 0.7602637 | 0 |
Get current selected items from view | def get_selected_items(self):
selection_model = self.view.selectionModel()
items = [row.data(NODEROLE) for row in selection_model.selectedRows(0)]
return items | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_selected(self):\n return [sel.internalPointer().obj for sel in self.view.selectedIndexes()]",
"def get_selected(self):\n\n # if there are items in the list\n if self.currentIndex() != -1:\n modelitem = self._dictmodel.itemFromIndex(\n self._modelindexes[ sel... | [
"0.7382247",
"0.7012544",
"0.6996464",
"0.698295",
"0.6814918",
"0.67935324",
"0.67131203",
"0.66167873",
"0.6438972",
"0.64261305",
"0.6410039",
"0.6399936",
"0.6381359",
"0.634729",
"0.6282976",
"0.6257425",
"0.62275416",
"0.62242496",
"0.621204",
"0.618071",
"0.6171668",
... | 0.7239535 | 1 |
Find the nodes in the current scene per asset. | def get_nodes(self, selection=False):
raise NotImplementedError
items = self.get_selected_items()
# Collect all nodes by hash (optimization)
# if not selection:
# nodes = cmds.ls(dag=True, long=True)
# else:
# nodes = commands.get_selected_nodes()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_nodes(self):\n # Start with root nodes in the scene\n for node_id in self.gltf.scenes[0].nodes:\n node = self.load_node(self.gltf.nodes[node_id])\n self.scene.root_nodes.append(node)",
"def getNodes(self):\n return self.__allNodes",
"def get_nodes(self):\n ... | [
"0.6308501",
"0.5936618",
"0.5871418",
"0.58445436",
"0.5844401",
"0.5844401",
"0.5844401",
"0.5840474",
"0.5838292",
"0.5799338",
"0.5798442",
"0.5772615",
"0.57538897",
"0.57218283",
"0.5667744",
"0.5643801",
"0.56265265",
"0.56171966",
"0.5600463",
"0.55895185",
"0.5562948... | 0.65618366 | 0 |
Select nodes from listed asset | def select_asset_from_items(self):
# items = self.get_nodes(selection=False)
# nodes = []
# for item in items.values():
# nodes.extend(item["nodes"])
#
# commands.select(nodes)
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes(self, selection=False):\n raise NotImplementedError\n\n items = self.get_selected_items()\n\n # Collect all nodes by hash (optimization)\n # if not selection:\n # nodes = cmds.ls(dag=True, long=True)\n # else:\n # nodes = commands.get_selected... | [
"0.65650755",
"0.5738566",
"0.56588864",
"0.55985224",
"0.5577653",
"0.5551203",
"0.5516879",
"0.54899585",
"0.54613703",
"0.54594606",
"0.54342175",
"0.5373641",
"0.53372043",
"0.5332001",
"0.5222675",
"0.5220603",
"0.52109855",
"0.5209644",
"0.51903003",
"0.5189908",
"0.518... | 0.7563111 | 0 |
Accepts a line of input data and returns a list of parsed attribute data for a single track with the given source user_id. | def parse_track(line, user_id):
track_data = []
# Remove curly braces and split on commas
tokens = re.split("[\{\}]|, ", line)
for attr in ATTRIBUTES:
for tok in tokens:
tok = tok[2:] # strip (u') from attribute names
if tok.startswith(attr):
attr_data = re.split("\': ", tok)
v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_echonest_data_file(filepath, user_id):\n f = open(filepath, 'r')\n\n # printing each track's data to standard out\n for track in f:\n data = user_id + \",\"\n data += \",\".join(parse_track(track, user_id))\n print data\n f.close()",
"def get_line_data(line):\n line_parts = line.split(\... | [
"0.6634319",
"0.6308905",
"0.56285936",
"0.5532833",
"0.550925",
"0.5491459",
"0.541879",
"0.5410497",
"0.53788143",
"0.53206307",
"0.53174406",
"0.5306988",
"0.5295188",
"0.52889705",
"0.5275228",
"0.5268182",
"0.52671564",
"0.51856047",
"0.5169987",
"0.51108456",
"0.5100581... | 0.77147216 | 0 |
Return an image url for the context in that order context image field context lead image field portal logo | def image_url(self):
context = aq_inner(self.context)
obj_url = context.absolute_url()
if hasattr(context, 'getField'):
field = self.context.getField('image')
if not field:
field = context.getField(IMAGE_FIELD_NAME)
if field and field.get_size... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def or_meta_image_url(context):\n try:\n request = context['request']\n absolute_url = request.build_absolute_uri(OR_META_IMAGE_URL)\n except KeyError:\n absolute_url = BASE_URL + OR_META_IMAGE_URL\n return absolute_url",
"def get_image_url():",
"def image_url(self) -> str:\n ... | [
"0.73293394",
"0.72720546",
"0.67300415",
"0.6720588",
"0.6720588",
"0.6720588",
"0.6684334",
"0.6672172",
"0.6418265",
"0.640839",
"0.63645226",
"0.6349584",
"0.6336353",
"0.6303204",
"0.62944496",
"0.62932086",
"0.62390316",
"0.62227726",
"0.62030196",
"0.62018144",
"0.6195... | 0.7907804 | 0 |
image and analyze measurement sets created with simobserve "project" needs to be the directory of results generated by running simobserve or simalma. In particular $project/$project.skymodel will be required in order to compare output and input images. | def simanalyze(project='sim', image=True, imagename='default', skymodel='', vis='default', modelimage='', imsize=[0, 0], imdirection='', cell='', interactive=False, niter=0, threshold='0.1mJy', weighting='natural', mask=[], outertaper=[''], pbcor=True, stokes='I', featherimage='', analyze=False, showuv=True, showpsf=Tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_run(self):\n rig_analysis_dir = \"rig_analysis\"\n analysis_root = os.path.join(self.io_args.output_root, rig_analysis_dir)\n os.makedirs(analysis_root, exist_ok=True)\n\n self.io_args.output_obj = os.path.join(analysis_root, \"final.obj\")\n self.io_args.output_equirect... | [
"0.5790673",
"0.5762024",
"0.56743467",
"0.56095785",
"0.5568179",
"0.55627775",
"0.5538388",
"0.5528766",
"0.5516628",
"0.55030715",
"0.5491057",
"0.54674774",
"0.5448375",
"0.5445074",
"0.5440277",
"0.5435487",
"0.54311734",
"0.5422931",
"0.539894",
"0.539894",
"0.539894",
... | 0.6970828 | 0 |
Initialise. Create a dictionary reference of part ID's and their OBJ path. | def __init__(self):
# Load in light information.
self.lights_dictionary = utils.load_dictionary(self.LIGHTS_JSON)
# Load in nice name information.
self.nice_name_dictionary = utils.load_dictionary(self.NICE_JSON)
# Set an initial order flag.
self.part_order = 0
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self): \n self.suburbs_dict = dict()\n self.raw_proIds_dict = dict()\n self.propertyIds_dict = dict()\n self.valuations = dict()",
"def __init__(self, pg):\n self._paths = []\n for key, value in pg.items():\n if key == \"paths\":\n ... | [
"0.60454375",
"0.6014876",
"0.5839867",
"0.57908285",
"0.56131625",
"0.5604289",
"0.56011385",
"0.5597128",
"0.55666476",
"0.5491945",
"0.54889387",
"0.546553",
"0.54474974",
"0.54161716",
"0.54092383",
"0.5408581",
"0.5390852",
"0.53690827",
"0.53604496",
"0.5344424",
"0.530... | 0.6372537 | 0 |
Get all the parts from a specific category. | def get_parts_from_category(self, category, pack=None):
# Validate pack name.
pack = pack or "Parts"
parts = []
for item, value in self.part_reference.items():
# Get pack and category values.
part_category = value["category"]
part_pack = value["pack"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_by_category(self, category):\n products = self.db.query(f\"\"\"\n SELECT product.id, product.name, product.nutrition_grade,\n product.url from product\n JOIN product_category ON product_category.product_id = product.id\n JOIN category ON product_catego... | [
"0.6393756",
"0.638984",
"0.6291781",
"0.62815714",
"0.6078679",
"0.59699047",
"0.59693354",
"0.5956573",
"0.5868023",
"0.5844391",
"0.5797236",
"0.5771589",
"0.57642555",
"0.57452977",
"0.56833696",
"0.5676469",
"0.5652664",
"0.5649387",
"0.5648078",
"0.5618981",
"0.55888873... | 0.77700573 | 0 |
Clear the part cache. | def clear_cache(self):
self.part_cache.clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_clear(self):\n\t\tself.__cache = {}",
"def clear_cache(self):\n pass",
"def clear_cache():\n # TODO\n pass",
"def clear(self):\n self._cache = dict()",
"def clear(self, cacheDir):",
"def cache_clear(self):\n self.fold_term.cache_clear()",
"def _clear_cache(s... | [
"0.7598071",
"0.755676",
"0.7550637",
"0.7482251",
"0.7461557",
"0.7355643",
"0.73039967",
"0.7300015",
"0.7278507",
"0.72022617",
"0.7066547",
"0.70605874",
"0.7042397",
"0.7027958",
"0.701708",
"0.69678",
"0.69349027",
"0.6914124",
"0.6911558",
"0.69090104",
"0.69018495",
... | 0.90049267 | 0 |
Wrapper to retrieve all blender objects that are made for NMS. If capture_presets is True, we get a list of all top level parts and preset objects. If it's False, we get all top level and preset level NMS items. We also excluse all top level preset items. | def get_all_nms_objects(self, capture_presets=False, skip_object_type=None):
if capture_presets:
# Get all preset and top level parts.
presets = [part for part in bpy.data.objects if "PresetID" in part]
# Get All top level flat parts.
flat_parts = [part for part i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_part_data(self, capture_presets=False, skip_object_type=None):\n skip_object_type = skip_object_type or []\n datas = []\n nms_objects = self.get_all_nms_objects(\n capture_presets=capture_presets,\n skip_object_type=skip_object_type\n )\n for ite... | [
"0.6420746",
"0.5760284",
"0.49495584",
"0.48371053",
"0.4755552",
"0.475461",
"0.47282794",
"0.47005814",
"0.46928364",
"0.4611271",
"0.45861813",
"0.4574641",
"0.4564265",
"0.45507795",
"0.45496696",
"0.45321596",
"0.45135257",
"0.45005405",
"0.44986194",
"0.44899145",
"0.4... | 0.83333904 | 0 |
Get the path to the OBJ file from a part. | def get_obj_path(self, part):
part_dictionary = self.part_reference.get(part, {})
return part_dictionary.get("full_path", None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_path(obj):\n return PATH + obj.strftime('%d-%B-%Y-comments.txt')",
"def getPath(obj):",
"def _object_path(self, name: str) -> str:\n prefix = name[:2]\n suffix = name[2:]\n return posixpath.join(self._path, \"objects\", prefix, suffix)",
"def object_path(self) -> pulumi.I... | [
"0.62191933",
"0.58089453",
"0.5781003",
"0.5726144",
"0.5726144",
"0.56777966",
"0.56626594",
"0.5642023",
"0.5630741",
"0.56293774",
"0.5629084",
"0.5606375",
"0.557084",
"0.5562557",
"0.5525682",
"0.55157596",
"0.5510066",
"0.550353",
"0.54460704",
"0.5415796",
"0.541564",... | 0.8144223 | 0 |
Retrieve the object that represents the part. There are 3 outcomes. If the object already exists in the scene cache, we can just duplciate it. If it doesn't exist in the cache, find the obj path. If the obj path doesn't exist, just createa cube. | def retrieve_part(self, part_name):
# Duplicate.
if part_name in self.part_cache:
cached_item_name = self.part_cache[part_name]
# If it's in the cache, but deleted by user, we can import again.
if cached_item_name in bpy.data.objects:
cached_item = bpy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_obj(self, obj_name, obj_type):\n content = self.connection_obj.content\n obj_list = content.viewManager.CreateContainerView(content.rootFolder, obj_type, True).view\n for obj in obj_list:\n sys.stdout.write('Checking object \"{0}\" \\r'.format(obj.name))... | [
"0.59116536",
"0.58929765",
"0.5854496",
"0.5848827",
"0.58191043",
"0.5787029",
"0.5785431",
"0.5682149",
"0.56311023",
"0.5617351",
"0.56139",
"0.55792934",
"0.5566541",
"0.55508584",
"0.5518639",
"0.5480985",
"0.5478649",
"0.5478336",
"0.54448473",
"0.53829855",
"0.5341484... | 0.71612567 | 0 |
If the part is is found to have light information, add them. | def build_light(self, item):
# Validete NMS object.
if "ObjectID" not in item:
return
# Get object id from item.
object_id = item["ObjectID"]
# Find light data
if object_id not in self.lights_dictionary:
return
# Build Lights
lig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addLight(self, id):\r\n\t\t\r\n\t\tnewLight = Light(id)\r\n\t\tself.lights[id] = newLight",
"def getLight(self):\n return self.light",
"def add_light_point(\n self,\n *,\n light_name: str,\n light_unique_id: str,\n room_name: str,\n room_... | [
"0.6229817",
"0.6133737",
"0.59870344",
"0.5915703",
"0.59155124",
"0.58827716",
"0.5843275",
"0.58196086",
"0.5783713",
"0.5756289",
"0.57190174",
"0.5709876",
"0.5700385",
"0.5686898",
"0.5683283",
"0.5589152",
"0.5589152",
"0.55884653",
"0.5557841",
"0.55489635",
"0.554607... | 0.6141828 | 1 |
IDs of the network interfaces created in customer's account by MediaConnect. | def network_interface_ids(self) -> Optional[Sequence[str]]:
return pulumi.get(self, "network_interface_ids") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_network_interfaces(self):\n return self.mycam.devicemgmt.GetNetworkInterfaces()",
"def getConnectedInterfaces(self):\n interfaces = self.connectedInterfaces[:] #make a copy\n interfaces.extend(self.getLinkedInterfaces())\n return interfaces",
"def __get_network_interface_i... | [
"0.7463362",
"0.6915018",
"0.66636765",
"0.66263914",
"0.6592041",
"0.6583993",
"0.65461373",
"0.6390737",
"0.6381346",
"0.63586706",
"0.63470113",
"0.63105786",
"0.63002795",
"0.627223",
"0.6246476",
"0.6245056",
"0.6245056",
"0.6245056",
"0.6232177",
"0.6220933",
"0.6210221... | 0.7276994 | 1 |
Security Group IDs to be used on ENI. | def security_group_ids(self) -> Optional[Sequence[str]]:
return pulumi.get(self, "security_group_ids") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def security_group_ids(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:\n return pulumi.get(self, \"security_group_ids\")",
"def security_group_ids(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:\n return pulumi.get(self, \"security_group_ids\")",
"def security_group_ids(self) ->... | [
"0.7389509",
"0.71285164",
"0.71285164",
"0.7048376",
"0.67974186",
"0.67568666",
"0.67568666",
"0.6745237",
"0.6725674",
"0.67222977",
"0.67222977",
"0.64746714",
"0.64716935",
"0.6415293",
"0.64103705",
"0.63623637",
"0.6357916",
"0.6357916",
"0.6336307",
"0.63204765",
"0.6... | 0.7320602 | 1 |
Group objects by category and take the average of the values. | def avg_by_category(self, start_date, end_date):
data = self.by_date(start_date, end_date)
return data.values('category__name').annotate(avg_value=models.Avg('value')).order_by('category') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average(values_per_category):\n sum = 0\n num_categories = 0\n for category in values_per_category:\n num_categories += 1\n sum += values_per_category[category]\n return sum / num_categories",
"def create_feature_average_value_for_category(data, item):\n utils.save_log('{0} :... | [
"0.70602226",
"0.6710419",
"0.64120346",
"0.62712085",
"0.6120465",
"0.5990346",
"0.59093577",
"0.58876765",
"0.5752044",
"0.5730655",
"0.56454986",
"0.5562313",
"0.5547221",
"0.5533601",
"0.55290794",
"0.55239445",
"0.5521062",
"0.55177146",
"0.551102",
"0.5453478",
"0.54500... | 0.6962641 | 1 |
Group objects by record date and take the average of the values. | def avg_by_day(self, start_date, end_date, category, user):
data = self.by_date(start_date, end_date)
return data.values('record_date').annotate(avg_value=models.Avg('value')).order_by('record_date') \
.filter(category__name=category, user__name=user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_click_through_rate_by_group(df):\n Searches_PerDay_By_Group = searched_per_day_by_group(df)\n CT_PerDay_By_Group = df.groupby([pd.TimeGrouper('D'),\n 'group']).apply(lambda row: \n len(row[row['action'] == 'visitPag... | [
"0.5960267",
"0.57261544",
"0.567528",
"0.56569767",
"0.5639703",
"0.5606969",
"0.5600014",
"0.5597623",
"0.55784494",
"0.552615",
"0.5476418",
"0.5470451",
"0.5461615",
"0.5454737",
"0.5447417",
"0.54327357",
"0.54300565",
"0.5417642",
"0.54167616",
"0.54033726",
"0.53765064... | 0.67396075 | 0 |
Returns a settings namespace after parsing command args | def get_settings():
parser = argparse.ArgumentParser(
description='Pull statements for all accounts')
parser.add_argument('settings_file', nargs='?', default="settings.yaml")
args = parser.parse_args()
settings_path = Path(args.settings_file).expanduser()
try:
settings = Namespace(**... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse() -> Namespace:\n parser = ArgumentParser()\n parser.add_argument(\n \"--config\",\n \"-c\",\n default=\"qwauto.cfg\",\n help=\"Config file. Defaults to qwauto.cfg.\",\n )\n return parser.parse_args()",
"def get_settings(self, settings=None, prefix='tangled.app.... | [
"0.6477401",
"0.64727813",
"0.64185375",
"0.6275149",
"0.60986054",
"0.59726256",
"0.5962492",
"0.5910816",
"0.58961666",
"0.5861469",
"0.5834968",
"0.57949656",
"0.5779675",
"0.5768273",
"0.5741047",
"0.5720372",
"0.5705985",
"0.5683846",
"0.5682854",
"0.56375146",
"0.563485... | 0.7195516 | 0 |
Pulls statements with an AccountManager and a settings file | def pull():
am = AccountManager(get_settings())
am.pull_all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_account_settings():\n pass",
"def get_settings():\n parser = argparse.ArgumentParser(\n description='Pull statements for all accounts')\n parser.add_argument('settings_file', nargs='?', default=\"settings.yaml\")\n args = parser.parse_args()\n settings_path = Path(args.settings_file... | [
"0.6413895",
"0.5742083",
"0.5610173",
"0.54968953",
"0.54864454",
"0.5280441",
"0.5255773",
"0.51920587",
"0.50945574",
"0.5094172",
"0.5033235",
"0.49833357",
"0.49638778",
"0.48905936",
"0.48724076",
"0.48680738",
"0.4866036",
"0.4857431",
"0.48478934",
"0.48386467",
"0.48... | 0.57436806 | 1 |
Opens the SimpleChromeDriver and falls into the interpreter for playing around with things | def open_scd():
settings = get_settings()
download_dir = Path(settings.chrome_download_dir).expanduser()
profile_dir = Path(settings.chrome_profile_dir).expanduser()
with SimpleChromeDriver(download_dir, profile_dir) as scd:
scd.start()
import code
code.interact(local=dict(global... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_chrome():\n os.system(\"start {CHROME_PATH} --remote-debugging-port={CHROME_DEBUG_PORT} --user-data-dir=\\\"{CHROME_USERDATA_PATH}\\\" --lang=zh-CN\".format(\n CHROME_PATH=CHROME_PATH, CHROME_DEBUG_PORT=CHROME_DEBUG_PORT, CHROME_USERDATA_PATH=CHROME_USERDATA_PATH))\n\n chrome_options = Optio... | [
"0.70674855",
"0.7066412",
"0.6698198",
"0.6633192",
"0.6588362",
"0.6559349",
"0.65485334",
"0.65295887",
"0.65019816",
"0.65019816",
"0.6455774",
"0.6451579",
"0.6418617",
"0.6371837",
"0.6366316",
"0.63517374",
"0.63277173",
"0.6312584",
"0.6263341",
"0.625561",
"0.62232",... | 0.72392744 | 0 |
Execute an HTTP request with auth params and the specified timeout overrides | def execute_request(
self, method, url, connect_timeout=None, read_timeout=None, retries=None
) -> HTTPClientResponse:
# make a request
if not connect_timeout:
connect_timeout = int(self.auth_config["conn_timeout"])
if not read_timeout:
read_timeout = int(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait(self, timeout):\n log.info(u\"%s %s(%r)\", self.request_params['method'],\n self.request_params['url'],\n self.request_params['params'])\n req = requests.Request(**self.request_params)\n self.apply_authentication(req)\n return self.session.send(s... | [
"0.63088524",
"0.6247988",
"0.62124074",
"0.6187927",
"0.61567974",
"0.6068046",
"0.59495205",
"0.58763015",
"0.58209085",
"0.5793957",
"0.5771294",
"0.57208633",
"0.56996447",
"0.56928515",
"0.56845695",
"0.5609583",
"0.5589153",
"0.5588614",
"0.5583398",
"0.5580235",
"0.557... | 0.6362464 | 0 |
Retrieves the supported Grype DB version from the installed copy of Grype using the grype wrapper. | def _get_supported_grype_db_version() -> str:
grype_wrapper = GrypeWrapperSingleton.get_instance()
try:
version_response = grype_wrapper.get_grype_version()
except CommandException as exc:
raise GrypeVersionCommandError() from exc
try:
return str(versi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_version():\n return IMPL.db_version()",
"def get_tgis_db_version():\n global tgis_db_version\n return tgis_db_version",
"def query_version(self):\n return self.connection.cursor().execute('SELECT version()').fetchone()[0]",
"def db_version(engine):\n return IMPL.db_version(engine)",... | [
"0.6191847",
"0.6040958",
"0.58951956",
"0.5851429",
"0.57658803",
"0.5737336",
"0.57286435",
"0.5583542",
"0.5483228",
"0.54262656",
"0.5402712",
"0.53914493",
"0.53416324",
"0.53212005",
"0.5308742",
"0.5298837",
"0.52895033",
"0.52853537",
"0.51873213",
"0.51723254",
"0.51... | 0.79563135 | 0 |
Sends HTTP request to toolbox service URL in listing.json to retrieve a single grype DB. This is painfully written because of legacy compatibility constraints. Ideally, listing.json would be passed in by download machinery. We're calling _list_feed_groups() here, as changing the signature would break Liskov substitutio... | def _get_feed_group_data(self) -> Tuple[Dict, HTTPClientResponse]:
grype_db_listing = self._list_feed_groups()
grype_db_url = grype_db_listing["url"]
logger.info("Downloading grypedb %s", grype_db_url)
grype_db_download_response = self.http_client.execute_request(
requests.ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list_feed_groups(self) -> Dict[str, Union[int, str]]:\n logger.info(\"Downloading grypedb listing.json from %s\", self.feed_url)\n listing_response = self.http_client.execute_request(\n requests.get, self.feed_url, retries=self.RETRY_COUNT\n )\n if not listing_response.s... | [
"0.7464513",
"0.6158113",
"0.58096033",
"0.5529715",
"0.5419804",
"0.5396559",
"0.52540576",
"0.51877",
"0.5172096",
"0.511572",
"0.51128113",
"0.50924474",
"0.5065635",
"0.50482696",
"0.5025073",
"0.50112647",
"0.49460277",
"0.4920945",
"0.491703",
"0.4901946",
"0.48794585",... | 0.6964935 | 1 |
Launch a message server | def launch_server(message_handler, options):
logger = logging.getLogger(__name__)
# if (options.debug):
# logger.setLevel(logging.DEBUG)
# if not options.monitor_port:
# logger.warning(
# "Monitoring not enabled. No monitor-port option defined.")
# else:
# threading.Thread(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self.logger.info(\"Starting messenger.\")\n self.recv()",
"def start_server():\n server = WebsocketServer(9001, host='0.0.0.0')\n server.set_fn_message_received(message_received)\n server.set_fn_client_left(client_left)\n print(\"Started\")\n server.run_forever()",
... | [
"0.71951044",
"0.69903094",
"0.68153095",
"0.6758208",
"0.67322",
"0.6686282",
"0.6588503",
"0.6588503",
"0.65669477",
"0.6534661",
"0.64832234",
"0.6467008",
"0.64637846",
"0.6462153",
"0.6454513",
"0.6436597",
"0.64224863",
"0.6400424",
"0.637943",
"0.6367329",
"0.63482744"... | 0.7277049 | 0 |
This route gets the list of libraries and displays the list. | def display_library_info():
print "in display library info \n"
library_list = model.get_libraries_info(model.db_session, session)
return render_template('library.html', libraries=library_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_library(command):\n namespace = app.main(command)\n assert namespace.command == 'll' or namespace.command == \"listlibrary\"",
"def list():\n\n click.secho('List of libraries in SJSU-Dev2\\n', fg='white', bold=True)\n package_registry = GetListOfSJSUDev2Repos()\n library_list = [f'{x : <20}: {p... | [
"0.68228596",
"0.6596242",
"0.61904055",
"0.59197336",
"0.59178156",
"0.5836246",
"0.57642555",
"0.5733107",
"0.57213897",
"0.5708084",
"0.5685866",
"0.5666071",
"0.56392485",
"0.5633478",
"0.56210726",
"0.5610541",
"0.55725324",
"0.55701923",
"0.5546857",
"0.55211914",
"0.55... | 0.74210876 | 0 |
This route get all the "finished reading" books for a given patron and displays the list of books. | def get_books_read_by_patron():
list_of_books = model.get_finished_books(session['patron'])
return render_template('finished_book_list.html',
list_of_books=list_of_books
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books_read():\n search_criteria = request.args.get('search')\n if search_criteria == \"\":\n list_of_books = []\n\n flash(\"Please enter an author or a title.\")\n\n return render_template('finished_book_list.html',\n list_of_books=list_of_books\n ... | [
"0.64070886",
"0.55834407",
"0.547648",
"0.547648",
"0.5455169",
"0.5398032",
"0.5342192",
"0.53275925",
"0.5284721",
"0.5246715",
"0.5231898",
"0.5223435",
"0.51984453",
"0.51879793",
"0.5127413",
"0.5113941",
"0.51017475",
"0.50928843",
"0.50924",
"0.508505",
"0.50527245",
... | 0.79014367 | 0 |
This route gets the list of books in the "finished reading" data set for the given search criteria and displays it. | def get_books_read():
search_criteria = request.args.get('search')
if search_criteria == "":
list_of_books = []
flash("Please enter an author or a title.")
return render_template('finished_book_list.html',
list_of_books=list_of_books
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books_read_by_patron():\n list_of_books = model.get_finished_books(session['patron'])\n\n return render_template('finished_book_list.html',\n list_of_books=list_of_books\n )",
"def search_results():\n search = False\n if session['patron']:\n... | [
"0.67272794",
"0.6672735",
"0.6667757",
"0.64459836",
"0.63530356",
"0.6247039",
"0.61578137",
"0.61141086",
"0.6018966",
"0.5967315",
"0.59433323",
"0.58752257",
"0.58516234",
"0.5834715",
"0.5819309",
"0.581132",
"0.5809273",
"0.5784365",
"0.5779153",
"0.5716664",
"0.571274... | 0.7893955 | 0 |
This page shows the details of a given book, as well as giving an option to put the book on hold, on a wish list, or check out | def show_book():
book = request.form
return render_template("book_details.html",
book = book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_book_details(book_id):\n\n book = get_book_details(book_id, GR_KEY)\n acct = get_current_account(session[\"acct\"])\n user = get_user_by_acct(acct)\n # query to get all friends of the current user that have read any edition of\n # the currently displayed book.\n friend_matches = db.sessi... | [
"0.736281",
"0.7154339",
"0.7143676",
"0.7132039",
"0.71129745",
"0.6964758",
"0.68972486",
"0.6820274",
"0.6815041",
"0.6747962",
"0.67237973",
"0.6720687",
"0.66943884",
"0.6682821",
"0.6660547",
"0.6652523",
"0.6649352",
"0.65983063",
"0.6577794",
"0.6572502",
"0.64780146"... | 0.7607586 | 0 |
Takes a neutron energy in meV and converts it to velocity in m/s | def E2V(E):
# for energy in mev returns velocity in m/s
return sqrt(E/5.227e-6) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def V2E(V):\n# for v in m/s returns energy in meV\n return 5.227e-6*V*V",
"def get_velocity(self):\n return self.momentum/self.mass",
"def v(self):\n\n # TODO This translation formula works, but needs simplified.\n\n # PWM duration can go from 0 to 4095 with 4095 representing max rpm\n# ... | [
"0.78528506",
"0.705492",
"0.6876731",
"0.6768488",
"0.6761787",
"0.6674187",
"0.6668404",
"0.65552133",
"0.6535376",
"0.65039057",
"0.6476464",
"0.64695966",
"0.6421411",
"0.6388866",
"0.6383476",
"0.6382111",
"0.63706553",
"0.63682246",
"0.63481134",
"0.6329709",
"0.6317823... | 0.84514856 | 0 |
Takes a neutron velocity in m/s and converts it to energy in meV | def V2E(V):
# for v in m/s returns energy in meV
return 5.227e-6*V*V | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def E2V(E):\n# for energy in mev returns velocity in m/s\n return sqrt(E/5.227e-6)",
"def ev2ve(eV): \n return cv*np.sqrt( eV*(eV+2.e0*mec2))/(eV+mec2)",
"def convert_kJmol_eV(en_kJmol):\n return en_kJmol*kJmol_eV",
"def convert_eV_kJmol(en_eV):\n return en_eV/kJmol_eV",
"def get_velocity(se... | [
"0.83459365",
"0.6815675",
"0.67636794",
"0.6739672",
"0.65842444",
"0.65460247",
"0.6528744",
"0.64472735",
"0.64174247",
"0.6320826",
"0.63104355",
"0.6280522",
"0.62719524",
"0.62493163",
"0.6248619",
"0.62358755",
"0.6218848",
"0.6196734",
"0.6193975",
"0.6172972",
"0.616... | 0.8155034 | 1 |
Takes a neutron of E mev and converts it to k ^A1 | def E2K(E):
return sqrt(E/2.0723) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_eV_kcalmol(en_eV):\n return en_eV/kcalmol_eV",
"def convert_kcalmol_eV(en_kcalmol):\n return en_kcalmol*kcalmol_eV",
"def convert_kJmol_eV(en_kJmol):\n return en_kJmol*kJmol_eV",
"def convert_eV_kJmol(en_eV):\n return en_eV/kJmol_eV",
"def energyK(k):\r\n C1 = 9.7846113e-07\r\n ... | [
"0.6721857",
"0.67000496",
"0.64946455",
"0.64832133",
"0.6313385",
"0.61389035",
"0.6074069",
"0.60543835",
"0.6041998",
"0.60085064",
"0.5986969",
"0.59514695",
"0.59202105",
"0.58958745",
"0.588238",
"0.5873765",
"0.5866969",
"0.58540505",
"0.57961535",
"0.5794663",
"0.578... | 0.6714882 | 1 |
Takes a neutron velocity V in m/s and converts it to lambda in angstroms | def V2lambda(V):
return(3956/V) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nm_to_ev(lambda_):\n h = 6.2 * 10 ** -34 # (?)\n c = 299792458\n f = c / lambda_\n e = h * f * 100000000 # because of nm instead of m\n e2 = 1.0 * e / (10 ** -19)\n print(e2, \"eV\")\n return e2",
"def angstrom_aod_at_lambda(aod0, lambda0, alpha=1.14, lambda1=700.0):\n return aod0 *... | [
"0.66738105",
"0.66485393",
"0.6566697",
"0.6527834",
"0.6354463",
"0.6297796",
"0.6270176",
"0.61058545",
"0.6032348",
"0.6003408",
"0.5979153",
"0.59565634",
"0.59547573",
"0.5875637",
"0.5864775",
"0.58594537",
"0.5839281",
"0.58387655",
"0.58381325",
"0.5807664",
"0.57662... | 0.7585652 | 0 |
Helper method update TOC when a domain is created If validateOnly is true, then the acl is checked to verify that create is enabled, but doesn't update the .toc | def addTocEntry(toc_file, file_path, domain):
print("addTocEntry, filePath", file_path, "domain:", domain)
hdf5_ext = config.get('hdf5_ext')
try:
with Hdf5db(toc_file) as db:
group_uuid = db.getUUIDByPath('/')
pathNames = file_path.split('/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_document_acl(view, creating=False):\n\n def wrapper(self):\n \"\"\"Decorator wrapper method.\n \"\"\"\n cleaned_data = self.cleaned_data\n\n fields = ['read_access', 'write_access', 'prefix', 'link_id', 'scope_path']\n\n if not all((i in cleaned_data) for i in fields):\n return cl... | [
"0.5845014",
"0.5076325",
"0.49939507",
"0.48601678",
"0.48084491",
"0.48077354",
"0.48005694",
"0.47739637",
"0.46517733",
"0.45879027",
"0.45787993",
"0.45564243",
"0.45460358",
"0.45284393",
"0.45146358",
"0.44962946",
"0.44811073",
"0.44607168",
"0.44526574",
"0.4443297",
... | 0.528959 | 1 |
Convert of vtt header to srt format | def convert_header(contents):
replacement = re.sub(r"WEBVTT\n", "", contents)
replacement = re.sub(r"Kind:[ \-\w]+\n", "", replacement)
replacement = re.sub(r"Language:[ \-\w]+\n", "", replacement)
return replacement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_header(self):\n return self._format_dict(self.header)",
"def format_header(self, header):\n raise NotImplementedError()",
"def vtt_to_srt(str_name_file: str):\n file_contents: str = read_text_file(str_name_file)\n str_data: str = \"\"\n str_data = str_data + convert_content(file_... | [
"0.6088649",
"0.60409075",
"0.5982811",
"0.5934275",
"0.5832585",
"0.58294976",
"0.57966506",
"0.5780759",
"0.5774896",
"0.57538635",
"0.5746083",
"0.57375956",
"0.57328814",
"0.5719",
"0.564905",
"0.56379205",
"0.55978924",
"0.558544",
"0.55438346",
"0.5519921",
"0.5510985",... | 0.64968735 | 0 |
Add 00 to padding timestamp of to srt format | def padding_timestamp(contents):
find_srt = Template(r'$a,$b --> $a,$b(?:[ \-\w]+:[\w\%\d:,.]+)*\n')
minute = r"((?:\d\d:){1}\d\d)"
second = r"((?:\d\d:){0}\d\d)"
padding_minute = find_srt.substitute(a=minute, b=r"(\d{0,3})")
padding_second = find_srt.substitute(a=second, b=r"(\d{0,3})")
replace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapt_timestamp(data):\n return str(time.mktime(data.timetuple()))",
"def timestamp():\n tmptz = time.timezone\n sign_str = '+'\n if tmptz > 0:\n sign_str = '-'\n tmptz_hours = int(tmptz / 3600)\n\n return str(\"%s%s%02d:%02d\" % (time.strftime(\"%Y-%m-%dT%H:%M:%S\", time.localtime()... | [
"0.66472447",
"0.6457021",
"0.6393625",
"0.6393462",
"0.6350214",
"0.6336234",
"0.6263154",
"0.62455124",
"0.62337667",
"0.62255126",
"0.61724216",
"0.6121975",
"0.61116374",
"0.6053914",
"0.60491264",
"0.6024081",
"0.5988719",
"0.59877145",
"0.59877145",
"0.59829587",
"0.596... | 0.7146555 | 0 |
Convert timestamp of vtt file to srt format | def convert_timestamp(contents):
find_vtt = Template(r'$a.$b --> $a.$b(?:[ \-\w]+:[\w\%\d:,.]+)*\n')
all_timestamp = find_vtt.substitute(a=r"((?:\d\d:){0,2}\d\d)", b=r"(\d{0,3})")
return padding_timestamp(re.sub(all_timestamp, r"\1,\2 --> \3,\4\n", contents)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vtt_to_srt(str_name_file: str):\n file_contents: str = read_text_file(str_name_file)\n str_data: str = \"\"\n str_data = str_data + convert_content(file_contents)\n str_name_file: str = str_name_file.replace(\".vtt\", \".srt\")\n print(str_name_file)\n file_create(str_name_file, str_data)",
... | [
"0.6683671",
"0.6568868",
"0.6554131",
"0.6480832",
"0.6471074",
"0.6465562",
"0.64065695",
"0.63293505",
"0.62585163",
"0.62457705",
"0.62293285",
"0.619308",
"0.6189691",
"0.6135376",
"0.60712487",
"0.6066042",
"0.6032804",
"0.60269606",
"0.6025064",
"0.59907967",
"0.598300... | 0.66320807 | 1 |
Check if line is a timestamp srt format | def timestamp_line(content):
return re.match(r"((\d\d:){2}\d\d),(\d{3}) --> ((\d\d:){2}\d\d),(\d{3})", content) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_timestamp(in_timestamp):\n\n pattern = (r'^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) '\n r'(2[0-3]|[01][0-9]):[0-5][0-9]$')\n return re.match(pattern, in_timestamp)",
"def has_timestamp(self):\n return (self.data_type() & 0x100 == 0x100) and (self.raw_da... | [
"0.714841",
"0.6785563",
"0.6723808",
"0.6652499",
"0.653623",
"0.6501922",
"0.6450312",
"0.6437147",
"0.64026755",
"0.6368102",
"0.62984866",
"0.6237578",
"0.62275463",
"0.62115127",
"0.6203749",
"0.61719316",
"0.61599284",
"0.6122666",
"0.610517",
"0.60912156",
"0.6072568",... | 0.7542476 | 0 |
Adds sequence numbers to subtitle contents and returns new subtitle contents | def add_sequence_numbers(contents):
output = ''
lines = contents.split(os.linesep)
i = 1
for line in lines:
if timestamp_line(line):
output += str(i) + os.linesep
i += 1
output += line + os.linesep
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtitle(self, txt):\n num = len(txt)\n ticks = \"-\" * num\n print(txt)\n print(ticks)",
"def make_movie(processed_files_directory='files/', WITH_SUBTITLES=False, WITH_AUDIO=False):\r\n # Declare the text for sub-titles\r\n\r\n if WITH_SUBTITLES: # if the user is willing to... | [
"0.6397169",
"0.5851335",
"0.58445024",
"0.57404715",
"0.57136846",
"0.5704279",
"0.5637793",
"0.5507947",
"0.5447455",
"0.5390939",
"0.5376324",
"0.53399193",
"0.532644",
"0.53077745",
"0.5235994",
"0.5194618",
"0.51195514",
"0.51173997",
"0.5107369",
"0.51044905",
"0.509927... | 0.64458424 | 0 |
Create a file with some data | def file_create(str_name_file: str, str_data):
try:
with open(str_name_file, "w", encoding='utf-8') as file:
file.writelines(str(str_data))
except IOError:
str_name_file = str_name_file.split(os.sep)[-1]
with open(str_name_file, "w") as file:
file.writelines(str(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file(self, name: str, content: str) -> None:\n file_path = self.path + os.path.sep + name\n with open(file_path, \"w+\") as file:\n file.write(content)\n file.close()",
"def _make_data_file(cls, filename):\n cls.cluster.fs.setuser(cls.cluster.superuser)\n f = ... | [
"0.7375092",
"0.7285238",
"0.72829986",
"0.71868503",
"0.7181609",
"0.71142983",
"0.7053093",
"0.7049526",
"0.7037781",
"0.70052004",
"0.69710934",
"0.69526565",
"0.6927249",
"0.69097686",
"0.68936116",
"0.689034",
"0.6886221",
"0.68802625",
"0.686139",
"0.683874",
"0.6838413... | 0.7528697 | 0 |
Read a file text | def read_text_file(str_name_file: str):
content: str = ''
with open(str_name_file, mode="r", encoding='utf-8') as file:
print("file being read: " + str_name_file + "\n")
content = file.read()
return content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_and_read_file(file_path):\n text_data = open(file_path).read()\n # print text_data\n return text_data",
"def read_file(file_path):\n try:\n input_file = open(file_path)\n text_content = input_file.read()\n input_file.close()\n return text_content\n except IOErr... | [
"0.8044944",
"0.78825456",
"0.78413635",
"0.78128046",
"0.7774484",
"0.7762294",
"0.77582824",
"0.7742505",
"0.7731055",
"0.76884305",
"0.7666519",
"0.76493275",
"0.7603076",
"0.75604767",
"0.75604767",
"0.7550243",
"0.75406176",
"0.75353503",
"0.75306386",
"0.75245684",
"0.7... | 0.7980319 | 1 |
Convert vtt file to a srt file | def vtt_to_srt(str_name_file: str):
file_contents: str = read_text_file(str_name_file)
str_data: str = ""
str_data = str_data + convert_content(file_contents)
str_name_file: str = str_name_file.replace(".vtt", ".srt")
print(str_name_file)
file_create(str_name_file, str_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_vtt_to_str(file):\n if \".vtt\" in file:\n vtt_to_srt(file)",
"def vtts_to_srt(directory, rec = False):\n top_most_path = directory\n if rec:\n walk_tree(top_most_path, convert_vtt_to_str)\n else:\n walk_dir(top_most_path, convert_vtt_to_str)",
"def srt_to_txt(srt_f... | [
"0.7679102",
"0.6568333",
"0.6135263",
"0.6111478",
"0.60124356",
"0.59333867",
"0.58832467",
"0.58692455",
"0.5842131",
"0.57859445",
"0.5673785",
"0.5644509",
"0.5640229",
"0.563155",
"0.56288797",
"0.5557443",
"0.55483806",
"0.5546673",
"0.5535919",
"0.54678655",
"0.542262... | 0.83748895 | 0 |
Recursively descend the directory tree rooted at top_most_path, calling the callback function for each regular file | def walk_tree(top_most_path, callback):
for file in os.listdir(top_most_path):
pathname = os.path.join(top_most_path, file)
mode = os.stat(pathname)[ST_MODE]
if S_ISDIR(mode):
# It's a directory, recurse into it
walk_tree(pathname, callback)
elif S_ISREG(mode)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walk_tree(self, path, topdown=True):\n if isinstance(path, File):\n # Called with File object as an argument\n root = path\n path = root.path\n else:\n root = File(path)\n\n files, dirs = [], []\n\n try:\n for item in os.listdir... | [
"0.63659745",
"0.6272923",
"0.6254014",
"0.6186204",
"0.60597473",
"0.6031394",
"0.57061976",
"0.561369",
"0.5589204",
"0.5582814",
"0.5578533",
"0.55698955",
"0.5526784",
"0.5515174",
"0.5508904",
"0.5494105",
"0.5447828",
"0.5412961",
"0.5407788",
"0.5404839",
"0.5403189",
... | 0.8324267 | 0 |
Convert vtt file to string | def convert_vtt_to_str(file):
if ".vtt" in file:
vtt_to_srt(file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vtt_to_srt(str_name_file: str):\n file_contents: str = read_text_file(str_name_file)\n str_data: str = \"\"\n str_data = str_data + convert_content(file_contents)\n str_name_file: str = str_name_file.replace(\".vtt\", \".srt\")\n print(str_name_file)\n file_create(str_name_file, str_data)",
... | [
"0.7051123",
"0.6688065",
"0.6371707",
"0.62851584",
"0.6205126",
"0.6066471",
"0.6044508",
"0.5947304",
"0.5822214",
"0.5713148",
"0.56957585",
"0.56629586",
"0.5635694",
"0.5622869",
"0.5550305",
"0.55342364",
"0.55237234",
"0.55043954",
"0.54838353",
"0.54683805",
"0.54683... | 0.8420665 | 0 |
Wrap `query_disc` to use lon, lat, and radius in degrees. | def ang2disc(nside, lon, lat, radius, inclusive=False, fact=4, nest=False):
vec = ang2vec(lon,lat)
return hp.query_disc(nside,vec,radius,inclusive,fact,nest) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_ned_astroquery(\n ra_deg: float, dec_deg: float, searchradius_arcsec: float = 0.5\n):\n c = SkyCoord(ra_deg, dec_deg, unit=u.deg, frame=\"icrs\")\n\n r = searchradius_arcsec * u.arcsecond\n\n try:\n return Ned.query_region(c, radius=r)\n except RemoteServiceError:\n return No... | [
"0.5736847",
"0.5595939",
"0.52858996",
"0.5268093",
"0.5176837",
"0.51369256",
"0.5119396",
"0.50598395",
"0.49871904",
"0.49617773",
"0.4958676",
"0.4953333",
"0.49315655",
"0.49267972",
"0.48987582",
"0.48584494",
"0.48230812",
"0.47648123",
"0.47589496",
"0.47231853",
"0.... | 0.6305191 | 0 |
Place the data into shared variables. This allows Theano to copy the data to the GPU, if one is available. | def shared(data):
shared_x = theano.shared(
np.asarray(data[0], dtype=theano.config.floatX), borrow=True)
shared_y = theano.shared(
np.asarray(data[1], dtype=theano.config.floatX), borrow=True)
return shared_x, T.cast(shared_y, "int32") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shared_dataset(data_x, data_y, borrow=True):\n shared_x = theano.shared(np.asarray(data_x,\n dtype=theano.config.floatX),\n borrow=borrow)\n shared_y = theano.shared(np.asarray(data_y, dtype=np.int32),\n ... | [
"0.68390095",
"0.65236115",
"0.6510937",
"0.6494002",
"0.6491432",
"0.64688736",
"0.64314127",
"0.6360119",
"0.62821925",
"0.6223201",
"0.6150297",
"0.6136502",
"0.6135919",
"0.6131957",
"0.61183447",
"0.6104276",
"0.60326403",
"0.60100406",
"0.59526163",
"0.5941425",
"0.5941... | 0.65370464 | 1 |
Stage does not like crossing a fault position (340deg on CL Supra) Given a starting and endpoint for rotation, determines a list of target rotations to get the stage to final target_pos without passing fault position | def check_rotation_fault(self, current_pos, target_pos):
fault_pos = 340.
def cw_dist(A, B):
return (B-A)%360.
def ccw_dist(A,B):
return (A-B)%360.
def fast_dist(A,B):
return min(ccw_dist(A,B), cw_dist(A,B))
def fast_dir(A,B):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_position(self, time):\n \"\"\"\n start_pos = self.points[self.cur_start]\n seg_time = time - self.last_checkpoint_time\n\n #The arguement of target-velocity dosent matter\n cur_pos = self.target_velocity(time)*seg_time + start_pos\n\n \n # or time > (self... | [
"0.6193844",
"0.5831822",
"0.58242",
"0.5781318",
"0.574071",
"0.56934154",
"0.56552666",
"0.5641227",
"0.56156343",
"0.5531071",
"0.55279505",
"0.5517539",
"0.5513877",
"0.55099434",
"0.546366",
"0.5448648",
"0.54435873",
"0.5404726",
"0.539504",
"0.53871554",
"0.53834295",
... | 0.67032796 | 0 |
Read data file and return as set of integers. | def get_input(data_file: str) -> Set[int]:
with open(data_file) as f:
return {int(x.strip()) for x in f.readlines()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_numbers(fname='input.txt'):\n with open(fname) as fp:\n # we use a set: efficient for quick lookup, and we don't care about order or duplicates\n numbers = set(int(num) for num in fp.readlines())\n return numbers",
"def read(filename):\n with open(filename) as file:\n nitems, nse... | [
"0.7277781",
"0.7089037",
"0.68486595",
"0.6832651",
"0.67666775",
"0.6755465",
"0.6752125",
"0.67204857",
"0.65563333",
"0.6508978",
"0.6490099",
"0.63425106",
"0.6316921",
"0.62128764",
"0.6192018",
"0.6169",
"0.61439556",
"0.61346734",
"0.61329025",
"0.60721856",
"0.606405... | 0.87379855 | 0 |
Builds embeddings from Qatar Living corpus. The corpus is really small, so the resulting embeddings perform badly. | def QL_embeddings():
ql = QatarLivingCorpus(dev_file)
sent = []
for th in ql:
for s in ThreadParser(th).get_sentences():
sent.append(s)
# CBOW, size=100, window=5
w2v = Word2Vec(sent)
# useful after training to trim unneeded model memory = use (much) less RAM
w2v.init_si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_embeddings(self):\n\t\tprint(\"Presetting embedding weights\")\n\t\t\t\n\t\tnp.random.seed(0)\n\t\tweights = np.random.uniform(low = -0.05, high = 0.05, size = (self.FREQCAP, self.EMB_SIZE))\n\t\t\n\t\tcounter = 0\n\n\t\twords = []\n\t\tweights_tmp = []\n\n\t\twith open(self.embeddingpath) as handle:\n\t\... | [
"0.6164814",
"0.6150414",
"0.61193067",
"0.6106871",
"0.60634977",
"0.6010797",
"0.59968466",
"0.59964824",
"0.5981353",
"0.5977348",
"0.59497637",
"0.5909066",
"0.59064466",
"0.5849806",
"0.58397895",
"0.58360213",
"0.58005273",
"0.57881904",
"0.57847244",
"0.57503754",
"0.5... | 0.7027481 | 0 |
Set given formatter for major and minor xticks. | def set_xaxis_formatter(formatter, ax=None):
if ax is None:
ax = plt.gca()
ax.xaxis.set_major_formatter(formatter)
ax.xaxis.set_minor_formatter(formatter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_formatter_cb( self, ax ):\n ax.set_xlim( xmin=self.begin_num,xmax=self.end_num )\n dl = common.PrettyDateLocator()\n df = common.PrettyDateFormatter( dl )\n ax.xaxis.set_major_locator( dl )\n ax.xaxis.set_major_formatter( df )\n ax.xaxis.set_clip_on(False)\n s... | [
"0.68968135",
"0.67625785",
"0.6714589",
"0.62620986",
"0.6123192",
"0.6086848",
"0.6049142",
"0.59762126",
"0.59619135",
"0.59440976",
"0.59329605",
"0.59156513",
"0.58769333",
"0.5824798",
"0.58071625",
"0.5786213",
"0.57638794",
"0.56809086",
"0.55767065",
"0.5568881",
"0.... | 0.74608004 | 0 |
Set given formatter for major and minor yticks. | def set_yaxis_formatter(formatter, ax=None):
if ax is None:
ax = plt.gca()
ax.yaxis.set_major_formatter(formatter)
ax.yaxis.set_minor_formatter(formatter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y_formatter_cb(self, ax):\n # y_vals should be the y-location of the labels.\n labels = getattr( self, 'labels', [] )\n labels = list(labels); #labels.reverse()\n y_vals = numpy.arange(.5,len(labels)+.5,1)\n\n # Locations should be fixed.\n fl = FixedLocator( y_vals )... | [
"0.6946587",
"0.66931295",
"0.6268211",
"0.6228131",
"0.61958724",
"0.6146527",
"0.59247035",
"0.59110713",
"0.5820537",
"0.57645077",
"0.5735007",
"0.56910706",
"0.5676311",
"0.5676178",
"0.56239057",
"0.5623393",
"0.5590683",
"0.5590308",
"0.55687886",
"0.5564425",
"0.55308... | 0.77969426 | 0 |
Attempt to fuzzy match the target string to an operator name using the given scorer function. The alias for the match with the highest score is returned. If a match with a score above the cutoff is not found, None is returned | def _fuzzy_match(
self, target: str, scorer=None, score_cutoff=85, limit=1
) -> pd.Series:
scorer = scorer or self.default_scorer()
# result = pd.Series(name = target)
extracted: list = process.extractBests(
target, self.operator, scorer=scorer, limit=limit, score_cutof... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fuzzy_match(object, answer, threshold=80):\n answer_phrase = generate_ngrams(answer)\n if answer_phrase:\n best_match = [fuzz.ratio(object, phr) for phr in answer_phrase]\n if np.max(best_match)>threshold:\n return np.max(best_match), answer_phrase[np.argmax(best_match)]\n ... | [
"0.659055",
"0.64439535",
"0.59002095",
"0.5863153",
"0.5831834",
"0.5701473",
"0.5665831",
"0.5550824",
"0.54848444",
"0.5475604",
"0.5324608",
"0.53036016",
"0.52972806",
"0.5290554",
"0.5284169",
"0.52791375",
"0.5251146",
"0.52473545",
"0.5191728",
"0.51911855",
"0.518684... | 0.71132505 | 1 |
Populate the index from a sql table. | def load(cls):
df = Operator_Table.df
df.operator = df.operator.apply(sp.normalize)
df.operator_alias = df.operator_alias.apply(sp.normalize)
df = df.rename(columns={"operator_alias": "alias"})
return SQLIndex(data=df).set_index("operator") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_index():",
"def build_index():\n pass",
"def create_new_index(self, dict_pg_info):\n # ! Setting if fun can use default setting\n ruler = Rules()\n str_conn = ruler.pg_info_rules(dict_pg_info)\n conn = psycopg2.connect(str_conn)\n\n with conn:\n with ... | [
"0.6368501",
"0.6023515",
"0.59747756",
"0.59641385",
"0.5937889",
"0.592518",
"0.590878",
"0.5883567",
"0.5831351",
"0.58310884",
"0.5824989",
"0.5792725",
"0.5674515",
"0.56426316",
"0.5632395",
"0.5627473",
"0.5621183",
"0.5617214",
"0.5617214",
"0.5613995",
"0.55791384",
... | 0.61137277 | 1 |
Look for an exact match for the target string in a list of all operator names. If found, returns the alias for that name. Otherwise, returns None. | def lookup(self, target: str) -> pd.Series:
try:
# self.refresh()
result = pd.Series(name=target)
if target is not None:
result = self.loc[target].copy()
if result.ndim > 1:
result = result.max()
result[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fuzzy_match(self, other):\n magic, fuzzy = False, False\n try:\n magic = self.alias == other.magic\n except AttributeError:\n pass\n\n if '.' in self.alias:\n major = self.alias.split('.')[0]\n fuzzy = major == other.alias \n return... | [
"0.600872",
"0.5476128",
"0.5431273",
"0.53964996",
"0.5336919",
"0.53155607",
"0.5303619",
"0.5226297",
"0.52201563",
"0.51875824",
"0.5180949",
"0.51748854",
"0.5127156",
"0.51046616",
"0.50755596",
"0.5064597",
"0.5043313",
"0.5024844",
"0.5005249",
"0.49946284",
"0.499088... | 0.54977614 | 1 |
Attempt to fuzzy match the target string to an operator name using the given scorer function. The alias for the match with the highest score is returned. If a match with a score above the cutoff is not found, None is returned | def _fuzzy_match(
self, target: str, scorer=None, score_cutoff=85, limit=1
) -> pd.Series:
scorer = scorer or self.default_scorer()
# result = pd.Series(name = target)
extracted: list = process.extractBests(
target, self.operator, scorer=scorer, limit=limit, score_cutof... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fuzzy_match(object, answer, threshold=80):\n answer_phrase = generate_ngrams(answer)\n if answer_phrase:\n best_match = [fuzz.ratio(object, phr) for phr in answer_phrase]\n if np.max(best_match)>threshold:\n return np.max(best_match), answer_phrase[np.argmax(best_match)]\n ... | [
"0.6589819",
"0.64425164",
"0.58997977",
"0.58632153",
"0.58299005",
"0.56999075",
"0.5664272",
"0.5549336",
"0.5484873",
"0.5475975",
"0.53234446",
"0.53025043",
"0.52954453",
"0.52909315",
"0.5284119",
"0.5278062",
"0.5250008",
"0.5246519",
"0.51911473",
"0.51895994",
"0.51... | 0.71131057 | 0 |
Get the features from one image. Global intensity histogram per channel and local histogram on image patches. | def _get_features_from_batch_images(self, img, r, p):
tmp_feats = []
for channel in range(4):
current_img = img[channel, :, :]
tmp_feats = np.append(tmp_feats, np.histogram(current_img)[0])
# extract 8*8 patches of 64*64 px and derive 10 bins histogram
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color_hist_features(img, p):\n # Compute the histogram of the color channels separately\n channel1_hist = np.histogram(img[:, :, 0], bins=p.hist_bins)\n channel2_hist = np.histogram(img[:, :, 1], bins=p.hist_bins)\n channel3_hist = np.histogram(img[:, :, 2], bins=p.hist_bins)\n # Concatenate... | [
"0.7379405",
"0.73698366",
"0.7358129",
"0.7352107",
"0.73067987",
"0.72972965",
"0.72677433",
"0.7140472",
"0.7089154",
"0.7082067",
"0.6995413",
"0.6963337",
"0.6898634",
"0.68926054",
"0.6876243",
"0.6866601",
"0.6840813",
"0.6817776",
"0.6807787",
"0.68063486",
"0.6802365... | 0.78143317 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.