query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Returns the preferred runway for the given airport. Right now we're only selecting runways based on whether or not they have ILS, but we could also choose based on wind conditions, or which direction flight plans should follow. | def get_preferred_runway(self, airport: Airport) -> RunwayData:
runways = list(RunwayData.for_pydcs_airport(airport))
for runway in runways:
# Prefer any runway with ILS.
if runway.ils is not None:
return runway
# Otherwise we lack the mission information ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_runway(self, airport: Union[str, \"Airport\"]) -> Optional[\"Flight\"]:\n msg = \"Use .aligned_on_runway(airport).max() instead.\"\n warnings.warn(msg, DeprecationWarning)\n\n return max(\n self.aligned_on_runway(airport),\n key=attrgetter(\"duration\"),\n ... | [
"0.6588333",
"0.5721019",
"0.5678698",
"0.54820865",
"0.5445117",
"0.5388726",
"0.5355984",
"0.51527876",
"0.50692517",
"0.49168152",
"0.49161312",
"0.48849434",
"0.4864975",
"0.48553964",
"0.47927576",
"0.47726896",
"0.475217",
"0.47335708",
"0.47126895",
"0.4672348",
"0.458... | 0.8533307 | 0 |
prune out entries with lowest weight. | def _prunelowestweight(self):
# note: must be called with acquired self._lock!
numentries = len(self._dict)
if numentries >= self.maxentries:
# evict according to entry's weight
items = [(entry.weight, key) for key, entry in self._dict.iteritems()]
items... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_heavier_than(self, w):\n G = nx.DiGraph()\n for u, v in self.edges:\n if self.graph[u][v][\"weight\"] <= w:\n G.add_edge(u, v, weight=self.graph[u][v][\"weight\"], alignment=self.graph[u][v][\"alignment\"])\n self.graph = G",
"def filter_by_weight(self, w... | [
"0.6713875",
"0.668257",
"0.66254586",
"0.6615816",
"0.6482034",
"0.64277047",
"0.6270732",
"0.6145243",
"0.6112046",
"0.6069026",
"0.6012259",
"0.6003529",
"0.59894925",
"0.59878355",
"0.5927412",
"0.5920374",
"0.5901654",
"0.58522505",
"0.58449197",
"0.5830802",
"0.5825418"... | 0.8380892 | 0 |
Prints all of the contacts in a specified path. | def print_all(self):
with open(self.file, 'r', encoding='utf-8') as self.contacts_file:
for i in self.contacts_file.readlines():
print(i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_contact(self):\n contacts = \"\".join(str(contact) for contact in self.contact_list)\n print(contacts)",
"def view_contacts(self):\n with open(self.filename, \"r\") as contactsFile:\n contacts = self.display_contact(contactsFile.readlines())\n\n if not contacts:... | [
"0.67285544",
"0.6681615",
"0.6376812",
"0.60674775",
"0.58926827",
"0.58382577",
"0.5805111",
"0.5754822",
"0.57326335",
"0.56835014",
"0.5655461",
"0.56480414",
"0.5593876",
"0.55586046",
"0.5556061",
"0.5505184",
"0.5464751",
"0.54598343",
"0.54571724",
"0.5447254",
"0.541... | 0.6947206 | 0 |
Takes full name as input and returns the one contact | def pull_one_contact(self, name):
contact = []
for x in self.contacts:
if x[0] == name:
contact_name = x[0]
number = x[1]
email = x[2]
zipcode = x[3]
contact = [contact_name, number, email, zipcode]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_contact_first_name(app):\n name = app.get(CONTACT_NAME_KEY)\n if name:\n return ' {}'.format(name.split(' ')[0])",
"def contact_full_name(self):\n first = self.contact_first_name\n last = self.contact_last_name\n if first and last:\n return f'{first} {last}'\... | [
"0.70435905",
"0.6775905",
"0.6767916",
"0.64946306",
"0.6442939",
"0.6439752",
"0.64186746",
"0.6342796",
"0.6310614",
"0.6242107",
"0.6131929",
"0.611",
"0.60856724",
"0.6079963",
"0.6060275",
"0.6046511",
"0.6039928",
"0.6009768",
"0.60023797",
"0.59919226",
"0.59919226",
... | 0.6841914 | 1 |
Sorts the contact book by the name or zipcode of the contacts and displays the contact book in ascending or descending order | def sort_contacts(self, method, order):
method_l = method.lower()
order_l = order.lower()
if method_l == 'name' and order_l == 'asc':
name_sort = sorted(self.contacts, key=lambda x: x[0])
for x in name_sort:
print(x)
return na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_contacts(contacts):\n \n key_list = list(contacts.keys()) #get keys\n key_list.sort() #sort key_list\n sorted_list = [] #initialize sorted list\n for key in key_list:\n contact = (key, contacts[key][0], contacts[key][1]) #create tuple\n sorted_list += [contact] #add tuple ... | [
"0.6573599",
"0.6458184",
"0.6305928",
"0.597216",
"0.5893325",
"0.57316965",
"0.5590592",
"0.5550864",
"0.5550434",
"0.5493951",
"0.54850143",
"0.54358536",
"0.5435454",
"0.5424167",
"0.5414283",
"0.5410285",
"0.54061854",
"0.53835547",
"0.52583706",
"0.5231712",
"0.5225571"... | 0.69229335 | 0 |
uses images2gif.py to turn all png images in a folder into an animated GIF | def animated_gif(folder_with_images, gif_filename, loop_duration, size):
os.chdir(folder_with_images) # changes directory to the folder with the images
png_files = []
# get list of png files in folder
for fn in os.listdir(folder_with_images):
if fn.endswith('.png'):
png_files.append(fn)
sort_ni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_gif(base_folder):\n img_list = []\n search_path = glob.glob(os.path.join(base_folder, '*.png'))\n search_path.sort()\n for f in search_path:\n im = Image.open(f)\n img_list.append(im)\n save_file = os.path.join(base_folder, 'animated_gif.gif')\n img_list[0].save(save_file... | [
"0.8201988",
"0.784977",
"0.78173923",
"0.77489877",
"0.7678784",
"0.7650474",
"0.7548243",
"0.7523239",
"0.7439131",
"0.7356226",
"0.72612065",
"0.72492033",
"0.72406083",
"0.7114576",
"0.70953244",
"0.7068107",
"0.70551455",
"0.6906683",
"0.69029206",
"0.67948526",
"0.67902... | 0.8292782 | 0 |
Display the Tweet form | def get(self, request, *args, **kwargs):
return render(request, 'tweets/index.html', {'form': self.form_class(user=request.user)}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_form():\n\n prompts = story.prompts\n\n return render_template(\"base.html\", prompts = prompts )",
"def user_timeline(username=None): # pylint: disable=unused-argument\n form = PostTweetForm()\n if form.validate_on_submit():\n try:\n current_user.post_tweet(form.tweet.dat... | [
"0.65626603",
"0.62451655",
"0.61054873",
"0.60839933",
"0.6069921",
"0.58719504",
"0.58517045",
"0.5813749",
"0.5784378",
"0.5781207",
"0.56855977",
"0.5594863",
"0.5562113",
"0.5535937",
"0.5510648",
"0.5489431",
"0.54881275",
"0.5482093",
"0.54636025",
"0.5461098",
"0.5456... | 0.6484199 | 1 |
{{{ Docstrings Reads GO and TPM files into dictionary. }}} | def read_GO_TPM_file(self, *GO_TPM_file):
dictionary = {}
for i in GO_TPM_file:
with open(i, 'r') as f:
f = f.readlines()[1:]
f = map(lambda x: x.strip(), f)
if '_GO.txt' in i:
dictionary['GO'] = f
else:
dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_to_dictionary():\n\n return;",
"def build_GO_TPM_dict(self, GO_TPM_file_list, Is_GO):\n\n f = map(lambda x: x.split('\\t'), GO_TPM_file_list)\n if Is_GO:\n go_dict = dict((i[0], i[1].split('`')) for i in f)\n return go_dict\n else:\n tpm_dict = di... | [
"0.62764466",
"0.6119582",
"0.61059195",
"0.60157615",
"0.60089105",
"0.59994686",
"0.59959334",
"0.5899969",
"0.5897268",
"0.5874877",
"0.5860927",
"0.58559364",
"0.5806741",
"0.5797594",
"0.576075",
"0.5753465",
"0.57491076",
"0.5746906",
"0.5733645",
"0.5697019",
"0.568469... | 0.68165624 | 0 |
{{{ Docstrings Writes the cumulative GO/TPM data to file. }}} | def write_cum_file(self, cum_data):
with open(self.IDs[3], 'w') as cum:
cum.write('GO_id\tCumulative_TPM\n')
for k, v in cum_data.iteritems():
cum.write(k + '\t' + str(v) + '\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_data():",
"def write_data(self):\n\n data_string = \"%s, %d, %d, %s\\n\" % (\n self.name, self.repos, self.members, self.created)\n\n file_path = os.path.join(os.path.dirname(__file__), self.data_file)\n\n with open(os.path.abspath(file_path), 'a') as f:\n f.w... | [
"0.62049794",
"0.59950626",
"0.5845376",
"0.58307445",
"0.5820113",
"0.5765106",
"0.573643",
"0.57359177",
"0.5724767",
"0.56903416",
"0.56730187",
"0.5641693",
"0.56183136",
"0.5617403",
"0.5613926",
"0.56085664",
"0.5590051",
"0.55600286",
"0.5557936",
"0.5546166",
"0.55342... | 0.8004967 | 0 |
{{{ Docstrings Filters GO data based on the primary GO category. }}} | def filter_GO_dict(self, GO_dict, *GO_category):
dictionary = {}
for i in GO_category:
tmp_dict = {}
for k, v in GO_dict.iteritems():
tmp_value = filter(lambda x: i in x, v)
if tmp_value:
tmp_dict[k] = tmp_value
dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n parser = ArgumentParser(\n description='Category Filter: Filter a List of Categories from a JSON')\n parser.add_argument('json_file_path', help='JSON file path')\n parser.add_argument('out_file', help='Output filename')\n args = parser.parse_args()\n\n ann_file = open(args.json_... | [
"0.5861926",
"0.5739233",
"0.57207024",
"0.56685543",
"0.54676676",
"0.5457863",
"0.53953564",
"0.53262365",
"0.52879685",
"0.52697474",
"0.5253551",
"0.52304476",
"0.5225333",
"0.5170825",
"0.5147459",
"0.51252097",
"0.51222163",
"0.5112287",
"0.5112287",
"0.5100528",
"0.509... | 0.68821824 | 0 |
Converts bytes to 4 x 4 array | def byte2array(bytes):
array = []
for i, byte in enumerate(bytes):
if i % 4 == 0:
array.append([byte])
else:
array[i // 4].append(byte)
return array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes2matrix(text):\n return [list(text[i:i+4]) for i in range(0, len(text), 4)]",
"def to_nibble_array(arr: ndarray) -> ndarray:\n arr = arr.ravel()\n return (arr[::2] + (arr[1::2] << 4)).astype(\"uint8\")",
"def getByteArray2D(self) -> typing.List[typing.List[int]]:\n ...",
"def image_d... | [
"0.69049335",
"0.6487146",
"0.6353773",
"0.63418293",
"0.6140696",
"0.61321247",
"0.61064464",
"0.6101885",
"0.6076199",
"0.6047178",
"0.60198945",
"0.59871984",
"0.59552336",
"0.59167445",
"0.5873622",
"0.5866856",
"0.58424544",
"0.57909036",
"0.5773045",
"0.57477385",
"0.57... | 0.7883482 | 0 |
Converts 4 x 4 array to hex string | def array2hex(array):
hexstr = ""
for i in range(4):
hexstr += ''.join('{:02x}'.format(x) for x in array[i])
return hexstr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_arr_to_hex_str(bytes_arr: List[int]) -> str:\n return \", \".join(\"0x%02x\" % b for b in bytes_arr)",
"def to_hex_str(dec_array):\r\n\r\n as_hex = [f'{i:02x}' for i in dec_array]\r\n\r\n return ''.join(as_hex)",
"def bit_array_to_string(array: Iterable) -> str:\n\n res = ''.join(\n ... | [
"0.7119604",
"0.65960336",
"0.64228106",
"0.6327956",
"0.6200571",
"0.61711365",
"0.61589646",
"0.614864",
"0.6056005",
"0.59375083",
"0.5930569",
"0.5924319",
"0.59048486",
"0.5874973",
"0.5842972",
"0.58335584",
"0.5831089",
"0.5827387",
"0.57935375",
"0.57718426",
"0.57711... | 0.77297497 | 0 |
Returns key schedule of 44 words | def getKeySchedule(key):
temp_keys = 44 * [None]
key_schedule = byte2array(key)
for i in range(len(key_schedule)):
if i%4==0:
temp = key_schedule[i]
for j in range(0,len(temp_keys),4):
temp_keys[j] = temp
temp = [temp[-1]] + te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(plaintext, key_schedule):\n state_array = byte2array(plaintext)\n round_0 = []\n round_0.extend([key_schedule[0],key_schedule[1],key_schedule[2],key_schedule[3]])\n ADD_ROUND_KEY(state_array,round_0)\n count = 0\n temp = []\n temp_key_sched = []\n\n for i in range(4,44): \n ... | [
"0.6306153",
"0.5801089",
"0.5770608",
"0.5475522",
"0.54427946",
"0.538228",
"0.5380662",
"0.53749466",
"0.5294702",
"0.52684486",
"0.5235163",
"0.51727843",
"0.5154344",
"0.51498634",
"0.5124376",
"0.5113235",
"0.51083964",
"0.5106627",
"0.50985396",
"0.5095365",
"0.5079382... | 0.7305503 | 0 |
Encrypts plaintext using key schedule | def encrypt(plaintext, key_schedule):
state_array = byte2array(plaintext)
round_0 = []
round_0.extend([key_schedule[0],key_schedule[1],key_schedule[2],key_schedule[3]])
ADD_ROUND_KEY(state_array,round_0)
count = 0
temp = []
temp_key_sched = []
for i in range(4,44):
temp.appe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(key, plaintext):\n data = fk(keyGen(key)[0], ip(plaintext))\n return fp(fk(keyGen(key)[1], swapNibbles(data)))",
"def encrypt(self, key, plaintext):\n output = []\n padded_key = padd_key(key, plaintext)\n for i in range(len(plaintext)):\n enc_ascii = (ord(plainte... | [
"0.7056993",
"0.6997083",
"0.6910249",
"0.6826273",
"0.6785555",
"0.6736617",
"0.67288643",
"0.6718968",
"0.6695133",
"0.66698223",
"0.6668952",
"0.6629753",
"0.6595874",
"0.6590091",
"0.6589204",
"0.65545017",
"0.65491396",
"0.6546425",
"0.6530666",
"0.65245265",
"0.6524502"... | 0.7380667 | 0 |
Create nullity matrix and save the plot to ``matrix_nan.png`` in the "OUT_DATA" directory. | def create_matrix_nan():
index_missing = gate_plot.isna().sum().sort_values().index
sorted_by_missing = msno.nullity_sort(gate_plot[index_missing])
matrix_nan = msno.matrix(sorted_by_missing)
matrix_nan.set_ylabel("INDEX OF OBSERVATIONS", labelpad=0, fontsize=18)
matrix_nan.get_xticklabels()[19].set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null_plot(self, dataset):\n sns_heatmap_plot = sns.heatmap(\n dataset.isnull(), cmap=\"Blues\", yticklabels=False\n )\n sns_heatmap_plot.figure.savefig(config.NULL_CHECK_HEATMAP)",
"def create_heatmap_nan():\n index_category = pd.Index(new_labels)\n sorted_by_category = ... | [
"0.63708234",
"0.6074387",
"0.57683337",
"0.56718147",
"0.56265396",
"0.54766446",
"0.5422341",
"0.53246593",
"0.5289961",
"0.5241998",
"0.5187888",
"0.5112321",
"0.51097625",
"0.510898",
"0.5086293",
"0.50471574",
"0.5039643",
"0.5014016",
"0.50119525",
"0.5000857",
"0.49794... | 0.80562246 | 0 |
Run Imagemagick's identify command. If command outputs to stderr special "extraneous bytes" error message, then capture size of extra bytes and marker code. Return None if extraneous bytes are not found, otherwise values extracted from error message. | def find_extraneous_bytes_before_marker(filepath):
code, out, err = run_command(['identify', filepath])
err_str = err.decode('utf8')
ending = "extraneous bytes before marker"
if err_str.find(ending) < 0:
return None, None, None
m = re.search(r'Corrupt JPEG data: ([\d]+) extraneous bytes befo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imageSizeNoCache(filename):\n\n if opts.no_magick:\n return (0, 0)\n\n fn = filename\n if opts.pil:\n\n try:\n im = PilImage.open(fn)\n s = im.size\n except IOError, e:\n raise SystemExit(\"Error: identifying file '%s'\" % fn + str(e))\n\n r... | [
"0.61020416",
"0.544879",
"0.5286424",
"0.51605546",
"0.51338214",
"0.5132784",
"0.5103628",
"0.509698",
"0.50425714",
"0.50197345",
"0.4971101",
"0.49556476",
"0.4923544",
"0.49070853",
"0.48903632",
"0.4869814",
"0.48540086",
"0.4850367",
"0.48499233",
"0.48085493",
"0.4745... | 0.6984234 | 0 |
Last element from scopeStack is removed and currScope is updated | def deleteScope():
global currScope
scopeStack.pop()
currScope = scopeStack[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope_pop(self) -> None:\n self.scope_stack.popleft()",
"def endScope():",
"def leaveScope(self, name):",
"def pop_instantiate_scope(self):\n self.instantiate_scope = self.instantiate_scope.get_parent()",
"def pop(self):\n self._variables = self._variable_stack.pop()",
"def scope... | [
"0.7608958",
"0.68642795",
"0.6764787",
"0.6377721",
"0.63775796",
"0.62262475",
"0.6219208",
"0.60805106",
"0.6016696",
"0.60080355",
"0.5974704",
"0.5926928",
"0.5896437",
"0.58770096",
"0.5875703",
"0.5872738",
"0.5854077",
"0.5823992",
"0.58158916",
"0.581577",
"0.5786769... | 0.80145603 | 0 |
generates new temporary variable | def newTemp():
global varSeq
toRet = 'var'+str(varSeq)
varSeq += 1
scopeDict[currScope].insert(toRet,"temporary")
return toRet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_temp_variable_name():\n counter = 0\n while True:\n counter += 1\n yield f\"t_{counter}\"",
"def get_temp_var() -> str:\n if len(DEALLOCATED_TEMP_VARS) > 1:\n var = DEALLOCATED_TEMP_VARS.pop()\n ALLOCATED_TEMP_VARS.append(var)\n\n return var\n\n # Creat... | [
"0.665959",
"0.6396607",
"0.61197865",
"0.6099496",
"0.60078543",
"0.60078543",
"0.59730935",
"0.5972153",
"0.5922348",
"0.5857888",
"0.58486015",
"0.57957274",
"0.57602435",
"0.5705927",
"0.5658735",
"0.5635153",
"0.5590427",
"0.5547302",
"0.5530237",
"0.5522898",
"0.5507687... | 0.7708905 | 0 |
Logs ban events not made through the bot. | async def on_member_ban(self, guild, target):
entry = await fetch_recent_audit_log_entry(
self.bot, guild, target=target, action=discord.AuditLogAction.ban, retry=3
)
if entry.user == self.bot.user:
return
action = Ban(
target=target,
use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def logger_bans(self, ctx, *, channel: ChannelSetting):\n await queries.update_setting(\n ctx,\n \"logging_settings\",\n \"ban_log_channel_id\",\n channel.id if channel is not None else None,\n )\n if channel is None:\n await util.se... | [
"0.66274333",
"0.6289445",
"0.6211584",
"0.6128353",
"0.5976262",
"0.5881616",
"0.5765396",
"0.5755743",
"0.5754436",
"0.57243574",
"0.56665677",
"0.5616894",
"0.55863464",
"0.5518944",
"0.54894495",
"0.548391",
"0.54765815",
"0.5444986",
"0.5386784",
"0.53838974",
"0.5364926... | 0.6299255 | 1 |
Sets up the Muted role's permissions. You must have the Administrator permission to use this. | async def setup(self, ctx):
role = discord.utils.get(ctx.guild.roles, name="Muted")
if role is None:
return await ctx.send("Please create a role named Muted first.")
for channel in ctx.guild.channels:
if isinstance(channel, CategoryChannel) or not channel.permissions_sy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init() -> None:\n appbuilder.add_permissions(update_perms=True)\n security_manager.sync_role_definitions()",
"def setup(bot):\n bot.add_cog(RoleManager(bot))",
"async def _set_roles(self, ctx: Context):\n\n guild: discord.Guild = ctx.guild\n\n host = await guild.create_role(\n ... | [
"0.70091057",
"0.6839477",
"0.66361266",
"0.6617161",
"0.6447892",
"0.6341974",
"0.62621003",
"0.6230001",
"0.6170113",
"0.61161715",
"0.61063576",
"0.60315776",
"0.602137",
"0.59753394",
"0.59370977",
"0.59244543",
"0.5920234",
"0.5868772",
"0.58590287",
"0.58578885",
"0.585... | 0.78424436 | 0 |
Unmutes a member in trading channels. You must have the Kick Members permission to use this. | async def tradingunmute(self, ctx, target: discord.Member, *, reason=None):
action = TradingUnmute(
target=target,
user=ctx.author,
reason=reason,
guild_id=ctx.guild.id,
)
await action.execute(ctx)
await action.notify()
await ctx.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unmute(self, ctx, user: Redeemed):\n if member == None or member == ctx.message.author:\n await ctx.send(\"You cannot unmute yourself!\")\n return \n await user.remove_roles(discord.utils.get(ctx.guild.roles, name=\"Muted\"))\n await ctx.send(f\"{user.mention}... | [
"0.69515646",
"0.69347554",
"0.69219375",
"0.68286806",
"0.67809457",
"0.6697323",
"0.66659373",
"0.65882045",
"0.6502169",
"0.6473313",
"0.6384512",
"0.6376163",
"0.6283388",
"0.60818565",
"0.6047106",
"0.60347235",
"0.59701824",
"0.5945254",
"0.5924875",
"0.59149057",
"0.59... | 0.7148507 | 0 |
Views a member's punishment history. You must have the Kick Members permission to use this. | async def history(self, ctx, *, target: Union[discord.Member, FetchUserConverter]):
query = {"target_id": target.id, "guild_id": ctx.guild.id}
count = await self.bot.mongo.db.action.count_documents(query)
async def get_actions():
async for x in self.bot.mongo.db.action.find(query).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def punish(\n self, ctx: commands.Context, member: discord.Member, punishment: Punishment\n ) -> None:",
"def entry_member(request,member_id):\n return EntryView.__index(request,member_id)",
"async def on_member_remove(self, member: Member):\n\n if not self._is_tracked(member.guil... | [
"0.5961462",
"0.53335446",
"0.5297916",
"0.5279688",
"0.5277867",
"0.5154507",
"0.5105471",
"0.5094938",
"0.50347066",
"0.49980646",
"0.4994079",
"0.49669912",
"0.4960998",
"0.4959691",
"0.49547735",
"0.48937735",
"0.4889033",
"0.48623428",
"0.484538",
"0.48425722",
"0.481379... | 0.5907632 | 1 |
Denormalize to uint8 [0...255] tensor from a float32 [0...1] tensor. | def denormalize(float32_frame):
if (not isinstance(float32_frame, tf.Tensor) or
float32_frame.dtype != tf.float32):
raise ValueError(f"Invalid input: {float32_frame}")
return tf.image.convert_image_dtype(float32_frame, tf.uint8, saturate=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float32_to_uint8(inputs):\n return np.uint8(np.clip(np.round(inputs * 255), 0, 255))",
"def uint8_to_float(im: np.array):\n if im.dtype == np.float32:\n warnings.warn(\"Image is already np.float32\")\n return im\n im = im.astype(np.float32) / 255\n return im",
"def uint8_to_float(... | [
"0.72965324",
"0.67540747",
"0.67540747",
"0.6749495",
"0.6719711",
"0.66579753",
"0.6494371",
"0.64181966",
"0.6409996",
"0.63891613",
"0.6387406",
"0.6382331",
"0.6354447",
"0.63429034",
"0.6335926",
"0.6300085",
"0.6289246",
"0.6245077",
"0.6231531",
"0.6220535",
"0.618546... | 0.72193897 | 1 |
Obtain a new Frame batch by applying `fn` on each element. | def apply(self, fn):
return Frame(fn(self.rgb)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batchify(fn, chunk):\n if chunk is None:\n return fn\n\n def ret(inputs, styles, alpha, feature):\n results = []\n for i in range(0, inputs.shape[0], chunk):\n input_chunk = inputs[i:i + chunk]\n style_chunk = styles[i:i + chunk]\n alpha_chunk = alpha... | [
"0.61101085",
"0.61065644",
"0.59294605",
"0.5812814",
"0.57043624",
"0.57043624",
"0.5694395",
"0.56770957",
"0.56308436",
"0.5596898",
"0.5539138",
"0.5528681",
"0.53403354",
"0.5315339",
"0.5265743",
"0.52645123",
"0.5256261",
"0.5194063",
"0.51897436",
"0.51605433",
"0.51... | 0.7081017 | 0 |
Obtain a new Frame batch by applying `reduce_fn` on each element. | def reduce(cls, frames,
reduce_fn):
rgb = reduce_fn([f.rgb for f in frames])
return Frame(rgb) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply(self, fn):\n return Frame(fn(self.rgb))",
"def reduce(self, function):\n return reduce(function, self.data)",
"def batchify(fn, chunk, world_fn = lambda x:x, gather_func = None):\n if chunk is None:\n return fn\n def ret(inputs, training = False, world_fn=world_fn):\n em... | [
"0.5898605",
"0.5626834",
"0.5527074",
"0.54001063",
"0.5352686",
"0.52958137",
"0.5288031",
"0.52771777",
"0.5268288",
"0.524487",
"0.52035064",
"0.51752454",
"0.51169777",
"0.50755507",
"0.5073291",
"0.5058255",
"0.5054055",
"0.50492036",
"0.5028246",
"0.49981123",
"0.49937... | 0.71606076 | 0 |
Create an instance from a uint8 rgb. | def make(cls, rgb_uint8):
if rgb_uint8.dtype != tf.uint8:
raise ValueError("Need uint8!")
rgb = normalize_for_rgb(rgb_uint8)
instance = cls(rgb)
instance.validate_shape()
return instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, rgb):\n \n ## The following are this class's attributes\n self.r = rgb[0]\n self.g = rgb[1]\n self.b = rgb[2]",
"def __init__(self, rgb):\n \n ## The following are this class's attributes\n self.r = rgb[0]\n self.g = rgb[1]\n ... | [
"0.66057116",
"0.66057116",
"0.61717176",
"0.59638083",
"0.5919522",
"0.5902202",
"0.58918345",
"0.58142704",
"0.57922655",
"0.576885",
"0.57604164",
"0.5719106",
"0.57088804",
"0.56110096",
"0.56023633",
"0.55925435",
"0.55275285",
"0.55231756",
"0.5508837",
"0.5498434",
"0.... | 0.81517035 | 0 |
Raise ValueError if we have invalid shapes. | def validate_shape(self):
if len(self._first_rgb.shape) != 5:
raise ValueError(f"Invalid shape: {self._first_rgb.shape}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _shape_check(self, X, y):\n if not len(y.shape) > 1:\n raise RuntimeError(\"The shape of y is incorrect.\")\n if y.shape != X.shape[:-1]:\n raise RuntimeError(\"X and y must have the same number of \" +\n \"samples and microstructure shape.\")\n... | [
"0.6995105",
"0.6986119",
"0.6962179",
"0.695349",
"0.6889278",
"0.68580693",
"0.6736823",
"0.6689245",
"0.6615782",
"0.65720016",
"0.6547961",
"0.65478575",
"0.6534164",
"0.6530391",
"0.6463948",
"0.6453337",
"0.6426276",
"0.6411735",
"0.64014214",
"0.639231",
"0.6366248",
... | 0.7520749 | 0 |
Returns frames, validates shape of first frame. | def get_frames(self):
if not self.video:
return []
# We cannot validate shape on construction as that happens inside graph
# mode as we construct from a tf.data.Dataset, so we validate here.
self.video[0].validate_shape_and_dtype()
return self.video | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_frame_batch(frames: list, *, format):\n frame_count = len(frames)\n assert frame_count > 0\n\n f1_idx = 0\n f1 = None\n while f1_idx < frame_count and f1 is None:\n try:\n f1 = _read_frame(frames[f1_idx], format=format)\n except SkipFrameException:\n f1 ... | [
"0.6609018",
"0.6322371",
"0.63184637",
"0.62587166",
"0.6191532",
"0.61825275",
"0.6118202",
"0.602572",
"0.5990667",
"0.5902788",
"0.5898221",
"0.5883571",
"0.58467305",
"0.58325005",
"0.58138317",
"0.580956",
"0.57896084",
"0.5769102",
"0.56955373",
"0.5684224",
"0.5657231... | 0.67747474 | 0 |
Return the number of frames in the video. | def num_frames(self):
return len(self.video) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frames(self):\n frame_count = 0\n if self.is_video() or self.is_audio():\n if self.__dict__['nb_frames']:\n try:\n frame_count = int(self.__dict__['nb_frames'])\n except ValueError:\n raise FFProbeError('None integer f... | [
"0.8149587",
"0.8000634",
"0.79408365",
"0.77318466",
"0.7711401",
"0.76985836",
"0.7361139",
"0.73375314",
"0.7288898",
"0.7199668",
"0.71541166",
"0.7113876",
"0.7107059",
"0.707449",
"0.7064645",
"0.703789",
"0.69904053",
"0.697358",
"0.68650484",
"0.6846845",
"0.68324274"... | 0.87998253 | 0 |
determine_category Return a category depending on a weight given. | def determine_category(weight):
if weight < 52:
return Category.FLY
elif 52 <= weight < 57:
return Category.FEATHER
elif 57 <= weight < 63:
return Category.LIGHT
elif 63 <= weight < 69:
return Category.WELTER
elif 69 <= weight < 75:
return Category.MEDIUM
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weight_category(self) -> WeightCategory:\n return WeightCategory.light if self.weight < 100 else WeightCategory.heavy",
"def get_weight(val):\n if val < 2000:\n category = 1\n elif val < 2500:\n category = 2\n elif val < 3000:\n category = 3\n elif val < 3500:\n ... | [
"0.745884",
"0.6875626",
"0.60673094",
"0.57147753",
"0.5712677",
"0.56384104",
"0.56335866",
"0.5583973",
"0.5543692",
"0.54811215",
"0.5376456",
"0.5367497",
"0.53546196",
"0.5319133",
"0.5300997",
"0.52614963",
"0.5251178",
"0.5231584",
"0.5230955",
"0.519492",
"0.51848376... | 0.81798506 | 0 |
initializes the particle filter with a normal distribution | def __init__(self, init_pos, init_stdev, num_particles, sense_noise):
self.particles = np.random.multivariate_normal(
init_pos, [[init_stdev**2, 0], [0, init_stdev**2]], num_particles)
self.weights = np.array(
[1. / num_particles for _ in range(num_particles)])
self.n = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_particles(self):\n \n # Each particle is a dimension-K vector. We generate each particle \n # uniformly at random from the space [0,1]^K. \n self.Particles = np.random.uniform(0, 1, (self.Npar, self.K))\n #print(\"Particles: \", self.Particles) \n return None",
... | [
"0.64824027",
"0.6470281",
"0.63342357",
"0.632274",
"0.632274",
"0.632274",
"0.632274",
"0.632274",
"0.62671024",
"0.6255693",
"0.6255693",
"0.6152836",
"0.6148171",
"0.61125165",
"0.61011827",
"0.6100128",
"0.6099897",
"0.6076007",
"0.60639673",
"0.60597944",
"0.6055383",
... | 0.75238234 | 0 |
returns particle with the highest weight | def get_best_particle(self):
index = self.weights.argmax()
return self.particles[index, :] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_greatest_probability(self):\n greatest = -1\n for i in range(self.dim):\n for j in range(self.dim):\n if self.kb[i][j] > greatest:\n greatest = self.kb[i][j]\n\n return greatest",
"def get_best_value(self):\n # Todo: implement\n ... | [
"0.6973724",
"0.6712545",
"0.66970956",
"0.65469986",
"0.62083495",
"0.6188585",
"0.6188585",
"0.6188585",
"0.6188585",
"0.6188585",
"0.6188585",
"0.6130807",
"0.6107099",
"0.6070922",
"0.6058072",
"0.6015375",
"0.59714365",
"0.59499085",
"0.5919791",
"0.5918699",
"0.58809555... | 0.7869971 | 0 |
move particle with a random gaussian | def __move(particle, motion):
particle[0] += random.gauss(0.0, motion)
particle[1] += random.gauss(0.0, motion)
return particle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate(self):\n #mutation_size = max(1,int(round(random.gauss(15,4))))/100\n\n\n\n mutation_size = max(1,int(round(random.gauss(15,4))))/100\n \"\"\"\n Changed the mutation by using random.randint rather than the gaussian one \n after observing that the gaussian random never ... | [
"0.6503776",
"0.63839597",
"0.63701814",
"0.63592017",
"0.62733364",
"0.6221267",
"0.6208915",
"0.62070596",
"0.61650854",
"0.6142163",
"0.6131444",
"0.6105582",
"0.60798484",
"0.607984",
"0.6073047",
"0.60154426",
"0.60147464",
"0.60069877",
"0.5957154",
"0.59550226",
"0.594... | 0.7620571 | 0 |
measures the angle between the particle and the robot | def __measurement(particle_pos, robot_pos):
return np.rad2deg(
math.atan2(particle_pos[1] - robot_pos[1],
particle_pos[0] - robot_pos[0])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle(self) -> float:\n ...",
"def _joint_angle_control(self):\n\n error = self.target_pos - self.robot_arm_pos\n return self._pd_control(error) + self.torque",
"def angle(self) -> int:",
"def angle(self):\n return angle(self.force, self.forceXYZ, self.excited_axis,\n ... | [
"0.728576",
"0.7053665",
"0.6753263",
"0.673359",
"0.66854227",
"0.66108036",
"0.6571537",
"0.64781874",
"0.64476633",
"0.6414931",
"0.6412715",
"0.6409492",
"0.6391302",
"0.63797784",
"0.6360373",
"0.6325254",
"0.6285672",
"0.6285672",
"0.6236196",
"0.6235026",
"0.62317914",... | 0.78197676 | 0 |
Calculate the yearly load factor for every fueltype by dividing the yearly average load by the peak hourly load in a year. Arguments | def calc_lf_y(fuel_yh, average_fuel_yd):
# Calculate average yearly fuel per fueltype
average_load_y = np.average(average_fuel_yd, axis=1)
# Calculate maximum hour in every day of a year
max_load_h_days = np.max(fuel_yh, axis=2)
max_load_h = np.max(max_load_h_days, axis=1)
# Caclualte yearly l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_average_load (self):\n #~ self.generation = self.forecast.generation_by_type['generation diesel']\\\n #~ [self.start_year]\n self.average_load = \\\n self.forecast.yearly_average_diesel_load.ix[self.start_year]",
"de... | [
"0.6781552",
"0.65222615",
"0.64230746",
"0.62575626",
"0.6094622",
"0.5996252",
"0.5939554",
"0.580923",
"0.57862556",
"0.57364595",
"0.57141274",
"0.5677293",
"0.56053805",
"0.553133",
"0.5470846",
"0.54136276",
"0.53950626",
"0.53443474",
"0.53425664",
"0.5330679",
"0.5271... | 0.6630462 | 1 |
tempfilt, coeffs, temp_sed, pz = readEazyBinary(MAIN_OUTPUT_FILE='photz', \ OUTPUT_DIRECTORY='./OUTPUT', \ CACHE_FILE = 'Same') Read Eazy BINARY_OUTPUTS files into structure data. If the BINARY_OUTPUTS files are not in './OUTPUT', provide either a relative or absolute path in the OUTPUT_DIRECTORY keyword. By default as... | def readEazyBinary(MAIN_OUTPUT_FILE='photz', OUTPUT_DIRECTORY='./OUTPUT', CACHE_FILE='Same'):
#root='COSMOS/OUTPUT/cat3.4_default_lines_zp33sspNoU'
root = OUTPUT_DIRECTORY+'/'+MAIN_OUTPUT_FILE
###### .tempfilt
if CACHE_FILE == 'Same':
CACHE_FILE = root+'.tempfilt'
if os.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readtempfilt(MAIN_OUTPUT_FILE='photz', OUTPUT_DIRECTORY='./OUTPUT'):\n\n root = os.path.join(OUTPUT_DIRECTORY, MAIN_OUTPUT_FILE)\n \n ###### .tempfilt\n file_path = root+'.tempfilt'\n \n if os.path.exists(file_path) is False:\n raise ValueError('File, %s, not found.' %(file_path))\n\n ... | [
"0.6047751",
"0.5246178",
"0.51966566",
"0.5086983",
"0.5083798",
"0.5073814",
"0.505774",
"0.5057473",
"0.5057473",
"0.50435996",
"0.4937564",
"0.49273506",
"0.4898537",
"0.48841074",
"0.48752788",
"0.48730662",
"0.4870236",
"0.4848012",
"0.48013437",
"0.47919822",
"0.479102... | 0.8627245 | 0 |
Callback function that is called when the Save Parameters btn is clicked. | def on_save_parameters(self):
obj_points = self.get_object_points()
cam_pos = self.get_camera_position()
distortion = self.get_distortion_coeeficients()
d = {
'object positions': obj_points,
'camera positions': cam_pos,
'distortion coefficients': d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveParam(self):\n qApp.emit(QtCore.SIGNAL(\"saveMe\"), self._param)",
"def saveParam(self):\n qApp.emit(QtCore.SIGNAL(\"saveMe\"), self._param)",
"def save(self, *args):\n # need to do!!\n pass",
"def init_save_curve_params_button(self):\n def save_params():\n ... | [
"0.70925754",
"0.70925754",
"0.67913026",
"0.6768073",
"0.6621593",
"0.66042584",
"0.6581914",
"0.6530856",
"0.6530856",
"0.6530856",
"0.6524365",
"0.64923036",
"0.6481401",
"0.64349306",
"0.64142895",
"0.6389021",
"0.63860184",
"0.6382369",
"0.6373126",
"0.6373126",
"0.63344... | 0.7093935 | 0 |
Callback function that is called when the "Load Parameters" button is called. | def on_load_parameters(self, filename=None):
if filename is None:
path, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Choose a parameter file.", "", "JSON Files (*.json)")
else:
path = filename
if path == '' or path is None:
return
self.param_file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_parameter(self):",
"def init_load_params_button(self):\n def load_params():\n \"\"\"\n load parameters from the Curve class to the fastfractal\n \"\"\"\n file_name = filedialog.askopenfilename(\n filetypes=[(\"JSON\", \"*.json\")])\n ... | [
"0.7636233",
"0.66088814",
"0.6579747",
"0.6318373",
"0.62812096",
"0.62741035",
"0.6250368",
"0.6236836",
"0.62086946",
"0.618174",
"0.6136972",
"0.611286",
"0.60765636",
"0.6062588",
"0.59959674",
"0.5963001",
"0.5931317",
"0.59206915",
"0.58839107",
"0.5883892",
"0.5875783... | 0.6689701 | 1 |
This function draws points onto the visible image. All of the drawing happens on a copy of the image so the original is maintained. | def draw_known_points(self):
if self.tracking:
if self.current_tracked_point == None:
return
p = self.current_tracked_point
x, y = (int(u) for u in p)
cv2.circle(self.altered_image, (x, y), 10, (0, 0, 255), 1, cv2.LINE_AA)
cv2.putText(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_points(self, imsize):\n mask = np.zeros(imsize)\n for t in self.points:\n mask[t] = 1\n toimage(mask).show()",
"def drawPointSet (self, points, colour):\r\n\r\n w = self.bih_vals [bih_Width]\r\n\r\n for pt in points:\r\n self.image [pt [1]][pt [0]... | [
"0.6897224",
"0.66766715",
"0.6621769",
"0.65924174",
"0.65777516",
"0.6547684",
"0.6543244",
"0.6404244",
"0.63991845",
"0.6369983",
"0.635793",
"0.6353487",
"0.6333849",
"0.6314204",
"0.62561333",
"0.6206732",
"0.61894614",
"0.6156099",
"0.6151059",
"0.6147598",
"0.6144985"... | 0.7168063 | 0 |
This function is called when we need to update the scene in tracking mode. If we don't have any points to track we just return, because there is nothing to do. If the tracker isn't initialized then we initialize it If the tracker is initialized we update it and then draw the box on the. scene. | def update_frame_tracking(self):
if not self.current_tracked_point:
return
if not self.tracker.initialized:
x, y = self.current_tracked_point
roi = (x, y, 50, 50)
self.tracker.initialize(self.original_image, roi)
return
self.roi = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tracking(self) -> None:\n dist, delta_angle, timestamp = self.vision.get_vision_data()\n # collect data only once per loop\n if timestamp is None:\n # self.next_state(\"searching\")\n # print(f\"tracking -> searching {self.vision.get_vision_data()}\")\n sel... | [
"0.5731918",
"0.57305074",
"0.56346434",
"0.5629391",
"0.55517864",
"0.5453429",
"0.5344364",
"0.5320971",
"0.529912",
"0.5293814",
"0.52543193",
"0.5253417",
"0.52365303",
"0.5204984",
"0.51992756",
"0.51680225",
"0.51443803",
"0.5124607",
"0.51197994",
"0.50978005",
"0.5097... | 0.6090624 | 0 |
Save the current image to a FITS file. This should prompt the user to create a JSON file containing a FITS header if one isn't already in use. This FITS header will be reused during the current session. | def save_fits(self):
hdu = fits.PrimaryHDU()
hdu.data = self.original_image.astype('float32')
hdr = hdu.header
if not self.metadata_filename:
# Let the user choose a JSON file containing fits header.
self.metadata_filename = self.get_fits_metadata()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fitswrite(img, imgname, **kwargs):\n try:\n if kwargs.has_key('header'):\n hdu = pyfits.PrimaryHDU(img, header = kwargs['header'])\n else:\n hdu = pyfits.PrimaryHDU(img)\n hdu.writeto(imgname)\n except IOError:\n print \"FITSWRITE: Unable to write FITS im... | [
"0.7054182",
"0.6930849",
"0.63592213",
"0.6270393",
"0.61625844",
"0.6130224",
"0.6086769",
"0.59388566",
"0.5841737",
"0.58076614",
"0.5787606",
"0.5749618",
"0.5720291",
"0.57192296",
"0.5700703",
"0.56808454",
"0.5671213",
"0.5667887",
"0.565113",
"0.56492496",
"0.5648957... | 0.77152437 | 0 |
Removes all results records such as wins, lossses and match id's from the database. | def deleteMatches():
db = connect()
c = db.cursor()
query = ("DELETE FROM results;")
c.execute(query)
db.commit()
db.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteMatches():\n conn = connect()\n cursor = conn.cursor()\n cursor.execute(\"DELETE FROM results\")\n conn.commit()\n conn.close()",
"def deleteMatches():\n # gets connection to tournament database in conn object\n conn = connect()\n # gets the cursor to execute queries\n c = co... | [
"0.7346613",
"0.69081885",
"0.68491256",
"0.6731901",
"0.6683167",
"0.6651814",
"0.66495967",
"0.6608778",
"0.6582605",
"0.6582482",
"0.6555129",
"0.6554785",
"0.6542801",
"0.65361875",
"0.6525654",
"0.6517774",
"0.6511976",
"0.6508967",
"0.6475777",
"0.64202684",
"0.63511294... | 0.7342317 | 1 |
Return the address of config file | def config_file_address() -> str:
config_files = json_files_from_folder("config")
config_file = choose_config(config_files) # Choice a config file if there is more then 1 in config folder
return config_file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_file_location():\n\n return './' + CONFIG_FILE_NAME",
"def config_file(self):\n return self[CONFIG_FILE_KEY]",
"def config_file(self):\n return join_path(self.prefix.etc.bohrium, \"config.ini\")",
"def config_path(self):\n if os.path.exists(self._config_path):\n ... | [
"0.7951816",
"0.7826119",
"0.76803935",
"0.74781823",
"0.738902",
"0.733537",
"0.72772247",
"0.72337604",
"0.71990085",
"0.7156913",
"0.7138757",
"0.70974725",
"0.70779324",
"0.7067025",
"0.7065846",
"0.70410687",
"0.70331275",
"0.7028916",
"0.7022305",
"0.6978829",
"0.697801... | 0.821069 | 0 |
GradCAM method for visualizing input saliency. | def grad_cam(input_model, image, cls, layer_name):
y_c = input_model.output[0, cls]
conv_output = input_model.get_layer(layer_name).output
grads = K.gradients(y_c, conv_output)[0]
# Normalize if necessary
# grads = normalize(grads)
gradient_function = K.function([input_model.input], [conv_output... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_cam(input_model, image, clss, layer_name, H=180, W=180):\r\n y_c = input_model.output[0, clss]\r\n conv_output = input_model.get_layer(layer_name).output\r\n grads = K.gradients(y_c, conv_output)[0]\r\n\r\n gradient_function = K.function([input_model.input], [conv_output, grads])\r\n\r\n ou... | [
"0.65379626",
"0.6204276",
"0.5884279",
"0.5698037",
"0.5402223",
"0.53441495",
"0.5318425",
"0.5276183",
"0.52716607",
"0.5201549",
"0.51886076",
"0.51762164",
"0.51748544",
"0.51095164",
"0.5086669",
"0.50808096",
"0.5079905",
"0.507406",
"0.5071252",
"0.50696766",
"0.50589... | 0.66255313 | 0 |
Takes list of codes in form 'ASD)GGH' and turns them into dictionary. key is first three digits. value is list of last three (mult. occurances)Returns dictionary. | def make_orbit_dict(orbit_codes):
orbit_dict = {}
for code in orbit_codes:
if code[0:3] in orbit_dict.keys():
orbit_dict[code[0:3]].append(code[4:])
else:
orbit_dict[code[0:3]] = [code[4:]]
return orbit_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dict(lst, rcs=None, pos=None):\n digits = lst[0].union(*lst)\n no_digits = dict()\n for dig in digits:\n where = []\n for s in enumerate(lst):\n if dig in s[1]:\n if rcs == \"S\":\n where.append(pos[s[0]])\n... | [
"0.6259482",
"0.6007973",
"0.59951216",
"0.58947045",
"0.5803456",
"0.5800195",
"0.56818557",
"0.5679202",
"0.5667462",
"0.56436056",
"0.5632375",
"0.5613897",
"0.5601778",
"0.5584296",
"0.55789876",
"0.5572728",
"0.5555314",
"0.5550332",
"0.55159205",
"0.5491724",
"0.5440315... | 0.63621217 | 0 |
Accepts dictionary of orbit codes, and initial key (center). Returns dictionary of individual distances. | def make_distance_dict(orbit_dict, key1):
orbits = 0
distances = {key1:orbits}
key_set = set(orbit_dict.keys())
value_set = set()
for value in orbit_dict.values():
value_set = value_set.union(set(value))
orbit_set = key_set.union(value_set)
orbit_set.remove(key1)
current_vertice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to_objects(orbit_tree: Dict[str, str], satellite_name) -> Dict[str, int]:\n object_distances: Dict[str, int] = {}\n satellite = orbit_tree[satellite_name]\n distance = 0\n while satellite != 'COM':\n # Get distance\n object_distances[satellite] = distance # Start with distan... | [
"0.6284505",
"0.54571176",
"0.5348561",
"0.53009427",
"0.52899563",
"0.5278169",
"0.5262005",
"0.51802576",
"0.5165019",
"0.51243347",
"0.5092222",
"0.5043042",
"0.5035513",
"0.5016536",
"0.5010947",
"0.4997802",
"0.49625573",
"0.49500382",
"0.4944014",
"0.49378332",
"0.49371... | 0.674759 | 0 |
Accepts dictionary of orbit paths and a target vertex. Returns list of path to target vertex. | def path_maker(orbit_dict, vertex):
path_list = [vertex]
while path_list[-1] != 'COM':
# print(path_list)
target = path_list[-1]
for key in orbit_dict.keys():
if target in orbit_dict[key]:
path_list.append(key)
return path_list[::-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self, source, target):\n if source == target:\n return [source]\n elif self.parent[target] is None:\n raise ValueError(\"no path to target\")\n else:\n return self.path(source, self.parent[target]) + [target]",
"def path(self, source, target):\n ... | [
"0.608171",
"0.608171",
"0.59479785",
"0.5850192",
"0.58495563",
"0.5833161",
"0.58198595",
"0.581729",
"0.581729",
"0.5787146",
"0.5774269",
"0.5771911",
"0.57635856",
"0.56759375",
"0.5617779",
"0.56149507",
"0.5577503",
"0.5557496",
"0.55098677",
"0.5485138",
"0.5476848",
... | 0.78466034 | 0 |
return all organism listed in Kegg database | def get_org_list():
resp = requests.get(''.join([Kegg.BASE_URL, 'list/organism']))
return resp.text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organisms_genes(self):\n path = os.path.join(self.parent_path, \"organisms_genes.txt\")\n with open(path, \"w\") as freqs:\n freqs.write(\"Organism,Genes\\n\")\n for org, data in self.organisms.items():\n genes = \"\"\n for gene in data.get(... | [
"0.65354395",
"0.63119715",
"0.6283204",
"0.6249244",
"0.62227803",
"0.62135947",
"0.6140487",
"0.6117435",
"0.6089482",
"0.6086453",
"0.6074738",
"0.5990961",
"0.5985105",
"0.59681773",
"0.59571993",
"0.5947314",
"0.59222317",
"0.58978045",
"0.5895238",
"0.58123374",
"0.5807... | 0.7604763 | 0 |
return all pathway for an organism listed in Kegg database | def get_pathways_list(org='hsa'):
resp = requests.get(''.join([Kegg.BASE_URL, 'list/pathway/', org]))
if resp.status_code == 200:
d = csv.DictReader(resp.text.split('\n'),
delimiter='\t',
fieldnames=('id', 'name'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pathway(identifier, organism):\n pass",
"def get_routes():\n\n return Db().get_line_ids()",
"def railway_all(osm_path): \n return (retrieve(osm_path,'lines',['railway'])).rename(columns={'railway': 'asset'})",
"def kegg_pathway_enrichment(degs, negs, dbpaths=dbpaths, show_all=True, pthresh=0... | [
"0.6855408",
"0.57694185",
"0.5750554",
"0.5700486",
"0.56512004",
"0.5650302",
"0.56490093",
"0.5596257",
"0.5583864",
"0.5557596",
"0.54984653",
"0.5467053",
"0.5422147",
"0.5395577",
"0.5370559",
"0.53676075",
"0.5362063",
"0.53475356",
"0.53179806",
"0.5292152",
"0.529098... | 0.7151952 | 0 |
return Kegg KGML_pathway object | def get_kgml_obj(pathway_id):
if pathway_id.startswith('path:'):
pathway_id = pathway_id.replace('path:', '')
resp = requests.get(''.join([Kegg.BASE_URL,
'get/',
pathway_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kegg_pathway_enrichment(degs, negs, dbpaths=dbpaths, show_all=True, pthresh=0.01):\n\n deg_num_ko, deg_keggs = cbir_to_kegg(degs)\n neg_num_ko, neg_keggs = cbir_to_kegg(negs)\n\n print \"%-4d kegg pathways from %d DEGs\" % (len(deg_keggs), len(degs) )\n print \"%-4d kegg pathways from %d nonDEGs\" ... | [
"0.57640004",
"0.56418306",
"0.55628306",
"0.55624956",
"0.55441225",
"0.55076295",
"0.54885745",
"0.5414888",
"0.52626216",
"0.5243093",
"0.52299154",
"0.51183206",
"0.50963235",
"0.5062012",
"0.5043354",
"0.5041966",
"0.5028515",
"0.5019303",
"0.5013263",
"0.5009062",
"0.49... | 0.6912723 | 0 |
Generate the config file for a server. | async def generate_default_config_file(self, server_id, owner_id):
parser = configparser.ConfigParser()
# Create each section that we need by default; future cogs
# may need to handle writing code to modify the config to add sections
parser.add_section('ServerSettings')
parser.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_server_config(filename=\"server_config.json\") -> None:\n with open(filename, \"w\") as f:\n data = {\"name\": \"Serveur de test local\", \"ip\": \"0.0.0.0\", \"port\": 25566}\n f.write(json.dumps(data, indent=4))",
"def _dump_server_config(self, _server_config):\n\n ... | [
"0.6640288",
"0.65607977",
"0.6517467",
"0.638775",
"0.6378636",
"0.6340267",
"0.63106245",
"0.62837476",
"0.626191",
"0.6231101",
"0.62090766",
"0.6187176",
"0.6173179",
"0.614317",
"0.6139799",
"0.6139589",
"0.6129176",
"0.60518533",
"0.6040522",
"0.5917994",
"0.59154946",
... | 0.68829614 | 0 |
Resamples image to given spacing and size. | def imgResample(img, spacing, size=[], useNearest=False, origin=[], outsideValue=0):
if len(spacing) != img.GetDimension(): raise Exception("len(spacing) != " + str(img.GetDimension()))
# Set Size
if size == []:
inSpacing = img.GetSpacing()
inSize = img.GetSize()
size = [int(math.ce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resample_img(img, img_type, size, spacing):\n resampler = sitk.ResampleImageFilter()\n resampler.SetOutputDirection(img.GetDirection())\n resampler.SetOutputOrigin(img.GetOrigin())\n resampler.SetOutputSpacing(spacing)\n resampler.SetSize(size)\n if img_type is \"Label\":\n resampler.S... | [
"0.7943881",
"0.7643791",
"0.75856775",
"0.74093217",
"0.7148586",
"0.6985898",
"0.69473743",
"0.67742175",
"0.6648978",
"0.66368556",
"0.6539819",
"0.6505706",
"0.6414896",
"0.6389543",
"0.6281422",
"0.6270175",
"0.618115",
"0.6171765",
"0.61706066",
"0.6149616",
"0.6079704"... | 0.78588027 | 1 |
Normalize image to unity sum | def imgNormalize(img):
constant = np.sum(sitk.GetArrayFromImage(img))*np.prod(img.GetSpacing())
return img/constant | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalise(image):",
"def normalize(img):\r\n return ((img / 255.0) - 0.5) / 0.5",
"def normalize(image):\r\n return image / 127.5 - 1.",
"def normalize(image):\n return image / 127.5 - 1.",
"def normalize(image):\n min = np.min(image)\n max = np.max(image)\n normalImg = 255*(image... | [
"0.80221593",
"0.77209437",
"0.7649952",
"0.7572828",
"0.7504156",
"0.74678594",
"0.7401729",
"0.7398767",
"0.7394718",
"0.7377331",
"0.73535275",
"0.7282052",
"0.72608453",
"0.7258828",
"0.72510463",
"0.72449976",
"0.72304803",
"0.72275317",
"0.7222405",
"0.7201099",
"0.7178... | 0.7762996 | 1 |
Sets up the global logger as configured in the `config` object. config The userdefined logging configuration | def setup_logging_with_config(config: DynaBox):
global logger
logger = setup_logging_threatbus(config, logger_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logger(config):\n filename = config[\"LOGGER_FILE\"]\n log_dir = '/'.join(filename.split('/')[0:-1]) + \"/\"\n\n check_and_create_directory(log_dir)\n\n level = config[\"LOGGER_LOGLEVEL\"].upper()\n filemode = 'a'\n _format = '%(asctime)s %(name)8s %(module)15s %(funcName)12s %(' \\\n ... | [
"0.81296",
"0.7842135",
"0.7503782",
"0.7463685",
"0.7462076",
"0.74387175",
"0.7358102",
"0.7341398",
"0.7239315",
"0.72150725",
"0.70655876",
"0.70594084",
"0.70494735",
"0.7005609",
"0.6990049",
"0.69833773",
"0.698039",
"0.6976895",
"0.6956055",
"0.6928867",
"0.69224036",... | 0.84035206 | 0 |
Cancels all async tasks. | async def cancel_async_tasks():
global async_tasks
for task in async_tasks:
if task is not asyncio.current_task():
task.cancel()
del task
async_tasks = []
return await asyncio.gather(*async_tasks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_async_tasks():\n tornado.ioloop.IOLoop.instance().stop()",
"async def cancel_tasks(self) -> None:\n if self._qos_task:\n self._qos_task.cancel()\n try:\n await self._qos_task\n except asyncio.CancelledError:\n pass\n s... | [
"0.7555089",
"0.7543023",
"0.7509475",
"0.7426591",
"0.73742604",
"0.7083023",
"0.7019093",
"0.6982878",
"0.68172",
"0.6789454",
"0.6785657",
"0.67286825",
"0.67189366",
"0.6642451",
"0.6610406",
"0.6495576",
"0.64625335",
"0.637788",
"0.6308285",
"0.63072467",
"0.6290157",
... | 0.80176604 | 0 |
Periodically writes metrics to a file. every The interval to write metrics, in seconds to the filepath to write to | async def write_metrics(every: int, to: str):
while True:
line = f"pyvast-threatbus,host={socket.gethostname()} "
start_length = len(line)
for m in metrics:
if not m.is_set:
continue
if type(m) is Gauge or type(m) is InfiniteGauge:
if l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writefile():\n\n print(\"Writing to file...\")\n\n # Open the heartbeat file in append mode and save the current time.\n with open(settings.ROOT_DIR + \"/heartbeat\", \"a\") as f:\n f.write(str(time()))",
"def setup_metrics_file(self):\n\n with open(self.metrics_path, \"w+\") as f_metr... | [
"0.6465442",
"0.63257843",
"0.61773896",
"0.6038639",
"0.5976731",
"0.593824",
"0.592454",
"0.59220535",
"0.58738124",
"0.5758625",
"0.56762564",
"0.5554106",
"0.55432475",
"0.5534424",
"0.5518398",
"0.5488493",
"0.54417235",
"0.54338413",
"0.5410348",
"0.5400014",
"0.535765"... | 0.75694364 | 0 |
Starts a zmq subscriber on the given endpoint and listens for new messages that are published on the given topic (zmq prefix matching). Depending on the topic suffix, Indicators are enqueued to the indicator_queue. | async def receive(pub_endpoint: str, topic: str, indicator_queue: asyncio.Queue):
global logger
socket = zmq.Context().socket(zmq.SUB)
socket.connect(f"tcp://{pub_endpoint}")
socket.setsockopt(zmq.SUBSCRIBE, topic.encode())
poller = zmq.Poller()
poller.register(socket, zmq.POLLIN)
logger.inf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe_to_ticks_publisher(topic):\n ConfigFile = \"../config/kuber.conf\"\n config = configparser.ConfigParser()\n config.read(ConfigFile)\n\n zmq_conf = config['ZMQ CONFIGURATION']\n publish_port = zmq_conf['publish_port']\n\n print(\"Subscribing to topic %s at %s\" % (topic, publish_port... | [
"0.61110973",
"0.5609849",
"0.55908597",
"0.55545825",
"0.5521547",
"0.5483101",
"0.5444674",
"0.54024506",
"0.5349773",
"0.5335479",
"0.52988833",
"0.5185165",
"0.5182671",
"0.51694936",
"0.5152659",
"0.51308894",
"0.512426",
"0.5122229",
"0.50869435",
"0.5054334",
"0.504626... | 0.682294 | 0 |
Turns the given STIX2 Indicator into a valid VAST query and forwards all query results (sightings) to the sightings_queue. vast_binary The vast binary command to use with PyVAST | async def retro_match_vast(
vast_binary: str,
vast_endpoint: str,
retro_match_max_events: int,
retro_match_timeout: float,
indicator: Indicator,
sightings_queue: asyncio.Queue,
):
start = time.time()
query = indicator_to_vast_query(indicator)
if not query:
g_retro_match_backl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def match_intel(\n vast_binary: str,\n vast_endpoint: str,\n indicator_queue: asyncio.Queue,\n sightings_queue: asyncio.Queue,\n live_match: bool,\n retro_match: bool,\n retro_match_max_events: int,\n retro_match_timeout: float,\n):\n global logger, open_tasks\n while True:\n ... | [
"0.6584765",
"0.6489582",
"0.63159645",
"0.5070378",
"0.49106118",
"0.48129866",
"0.48059142",
"0.46778646",
"0.46212944",
"0.44722167",
"0.44278392",
"0.43826163",
"0.43719858",
"0.4344309",
"0.43253714",
"0.43091223",
"0.4265866",
"0.42530748",
"0.4211338",
"0.41965106",
"0... | 0.68324536 | 0 |
Converts the given STIX2 Indicator to a VASTcompatible IoC and ingests it via a VAST matcher. vast_binary The vast binary command to use with PyVAST | async def ingest_vast_ioc(vast_binary: str, vast_endpoint: str, indicator: Indicator):
global logger
vast_ioc = indicator_to_vast_matcher_ioc(indicator)
if not vast_ioc:
logger.error(
f"Unable to convert STIX-2 Indicator to VAST compatible IoC. Is it a point IoC? {indicator}"
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def match_intel(\n vast_binary: str,\n vast_endpoint: str,\n indicator_queue: asyncio.Queue,\n sightings_queue: asyncio.Queue,\n live_match: bool,\n retro_match: bool,\n retro_match_max_events: int,\n retro_match_timeout: float,\n):\n global logger, open_tasks\n while True:\n ... | [
"0.6255441",
"0.6119161",
"0.5682917",
"0.5192349",
"0.5060265",
"0.493398",
"0.48183864",
"0.4803378",
"0.47764373",
"0.46372145",
"0.46292838",
"0.46243283",
"0.45121062",
"0.4508024",
"0.45072028",
"0.45029947",
"0.44965547",
"0.4473348",
"0.44625607",
"0.4462195",
"0.4459... | 0.81019396 | 0 |
Converts the given STIX2 Indicator to a VASTcompatible IoC and removes it from the VAST matcher. vast_binary The vast binary command to use with PyVAST | async def remove_vast_ioc(vast_binary: str, vast_endpoint: str, indicator: Indicator):
global logger, matcher_name
type_and_value = get_vast_type_and_value(indicator.pattern)
if not type_and_value:
logger.debug(f"Cannot remove IoC from VAST. Is it a point IoC? {indicator}")
return None
(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def ingest_vast_ioc(vast_binary: str, vast_endpoint: str, indicator: Indicator):\n global logger\n vast_ioc = indicator_to_vast_matcher_ioc(indicator)\n if not vast_ioc:\n logger.error(\n f\"Unable to convert STIX-2 Indicator to VAST compatible IoC. Is it a point IoC? {indicator}\"... | [
"0.6753386",
"0.56779706",
"0.5470638",
"0.48409158",
"0.44988817",
"0.44799104",
"0.44298604",
"0.43801382",
"0.4329384",
"0.43279293",
"0.4323277",
"0.42903358",
"0.42787653",
"0.42719406",
"0.42589614",
"0.42512602",
"0.4224931",
"0.42167395",
"0.41993895",
"0.41924408",
"... | 0.7576261 | 0 |
Reads from the indicator_queue and matches all IoCs, either via VAST's livematching or retromatching. vast_binary The vast binary command to use with PyVAST | async def match_intel(
vast_binary: str,
vast_endpoint: str,
indicator_queue: asyncio.Queue,
sightings_queue: asyncio.Queue,
live_match: bool,
retro_match: bool,
retro_match_max_events: int,
retro_match_timeout: float,
):
global logger, open_tasks
while True:
msg = await ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def retro_match_vast(\n vast_binary: str,\n vast_endpoint: str,\n retro_match_max_events: int,\n retro_match_timeout: float,\n indicator: Indicator,\n sightings_queue: asyncio.Queue,\n):\n start = time.time()\n query = indicator_to_vast_query(indicator)\n if not query:\n g_r... | [
"0.6922588",
"0.6637018",
"0.6202399",
"0.5444081",
"0.51181835",
"0.4728371",
"0.453623",
"0.45278928",
"0.4521745",
"0.45122913",
"0.45079392",
"0.44740847",
"0.446948",
"0.44226426",
"0.44106132",
"0.43992066",
"0.43902928",
"0.43865323",
"0.436398",
"0.43589398",
"0.43124... | 0.7095307 | 0 |
Starts a VAST matcher. Enqueues all matches from VAST to the sightings_queue. vast_binary The VAST binary command to use with PyVAST vast_endpoint The endpoint of a running VAST node sightings_queue The queue to put new sightings into retro_match Boolean flag to use retromatching over livematching | async def live_match_vast(
vast_binary: str, vast_endpoint: str, sightings_queue: asyncio.Queue
):
global logger, matcher_name
vast = VAST(binary=vast_binary, endpoint=vast_endpoint, logger=logger)
matcher_name = "threatbus-" + "".join(random.choice(letters) for i in range(10))
proc = await vast.mat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def retro_match_vast(\n vast_binary: str,\n vast_endpoint: str,\n retro_match_max_events: int,\n retro_match_timeout: float,\n indicator: Indicator,\n sightings_queue: asyncio.Queue,\n):\n start = time.time()\n query = indicator_to_vast_query(indicator)\n if not query:\n g_r... | [
"0.72215056",
"0.63250434",
"0.60648054",
"0.4627217",
"0.4626055",
"0.4610181",
"0.45514858",
"0.45476955",
"0.45376977",
"0.45119616",
"0.4479351",
"0.44458568",
"0.4383127",
"0.4380449",
"0.4356244",
"0.43545336",
"0.43387768",
"0.43217507",
"0.42751554",
"0.42354617",
"0.... | 0.8319855 | 0 |
Invoke a command as subprocess for the given context. The command string is treated as template string and occurences of "%ioc" are replaced with the actually matched IoC. Returns stdout from the invoked command. cmd The command, including flags, to invoke as subprocess. cmd is treated as template string and occurrence... | async def invoke_cmd_for_context(cmd: str, context: dict, ioc: str = "%ioc"):
if not ioc:
ioc = "%ioc"
cmd = cmd.replace("%ioc", ioc)
proc = await asyncio.create_subprocess_exec(
*lexical_split(cmd),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
stdi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(cmd):\n\tif \"|\" in cmd:\n\t\tcmd_parts = cmd.split('|')\n\telse:\n\t\tcmd_parts = []\n\t\tcmd_parts.append(cmd)\n\ti = 0\n\tp = {}\n\tfor cmd_part in cmd_parts:\n\t\t#print(cmd_part)\n\t\tcmd_part = cmd_part.strip()\n\t\tif i == 0:\n\t\t p[i]=Popen(shlex.split(cmd_part),stdin=None, stdout=PIPE, stderr=... | [
"0.58215666",
"0.5792031",
"0.574026",
"0.5625099",
"0.556116",
"0.5544668",
"0.5538419",
"0.55206203",
"0.55202276",
"0.5509302",
"0.5505767",
"0.5440929",
"0.5433163",
"0.5378438",
"0.537392",
"0.5325623",
"0.5315594",
"0.52947664",
"0.5293445",
"0.5287935",
"0.52774465",
... | 0.8529022 | 0 |
Transforms the context of a sighting using the command configured in `transform_context` sighting the sighting as it was reported by VAST transform_cmd The command to use to pipe sightings to. Treated | async def transform_context(sighting: Sighting, transform_cmd: str) -> Sighting:
context = (
sighting.x_threatbus_sighting_context
if ThreatBusSTIX2Constants.X_THREATBUS_SIGHTING_CONTEXT.value
in sighting.object_properties()
else None
)
if not context:
logger.error(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform():\n pass",
"def transform():",
"def transform(config, data, transfo, *args, **kwargs):\n \n# stderr.write(str((config, data, transfo) + args) + \"\\n\")\n pipe = ktpipes.KtPipe.from_json(config[transfo])\n\n return pipe.fit_transform(get_raw(data))",
"async def invoke_cmd_fo... | [
"0.62180775",
"0.6137687",
"0.5702457",
"0.5616719",
"0.5601462",
"0.5513075",
"0.5509026",
"0.5358405",
"0.53441906",
"0.53441906",
"0.53441906",
"0.53441906",
"0.53441906",
"0.53441906",
"0.53441906",
"0.53037167",
"0.5293181",
"0.5258532",
"0.5219467",
"0.516099",
"0.51377... | 0.75897956 | 0 |
Predicate to check if `reply` is a dict and contains the keyvalue pair "status" = "success" reply A python dict True if the dict contains "status" = "success" | def reply_is_success(reply: dict):
return (
reply
and type(reply) is dict
and reply.get("status", None)
and reply["status"] == "success"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_success_response(resp: Response) -> bool:\n return \\\n resp and \\\n is_dict(resp) and \\\n resp.get(\"success\", False) is True",
"def validate_reply(request, reply):\n assert isinstance(reply, dict) and 'id' in reply\n assert ('result' in reply) != ('error' in repl... | [
"0.7250996",
"0.6504684",
"0.6264166",
"0.6229269",
"0.61349565",
"0.60097516",
"0.5948076",
"0.5893526",
"0.58669925",
"0.581646",
"0.5764716",
"0.56838953",
"0.5681368",
"0.566706",
"0.5639373",
"0.56248266",
"0.55777353",
"0.55689406",
"0.55523485",
"0.5548644",
"0.5541796... | 0.8270404 | 0 |
Unsubscribes this app from Threat Bus for the given topic. endpoint The ZMQ management endpoint of Threat Bus topic The topic to unsubscribe from timeout The period after which the connection attempt is aborted | def unsubscribe(endpoint: str, topic: str, timeout: int = 5):
global logger
logger.info(f"Unsubscribing from topic '{topic}' ...")
action = {"action": "unsubscribe", "topic": topic}
reply = send_manage_message(endpoint, action, timeout)
if not reply_is_success(reply):
logger.warning("Unsubsc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unsubscribe(self, topic: str, subscription_id: int = None) -> None:\n ...",
"def unsubscribe(self, topic):\n request = protos.RequestUnsubscribe(topic=topic)\n return self.stub.unsubscribe(request)",
"def unsubscribe(self, user_token, topic):\n response = _request('DELETE'... | [
"0.72822154",
"0.6926093",
"0.64411914",
"0.63961035",
"0.63747597",
"0.6357573",
"0.6245065",
"0.61568964",
"0.6072447",
"0.60447603",
"0.60447603",
"0.60447603",
"0.60447603",
"0.60447603",
"0.6013516",
"0.60046285",
"0.59764683",
"0.59599453",
"0.59538406",
"0.59074706",
"... | 0.79936963 | 0 |
Sends heartbeats to Threat Bus periodically to check if the given p2p_topic is still valid at the Threat Bus host. Cancels all async tasks of this app when the heartbeat fails and stops the heartbeat. endpoint The ZMQ management endpoint of Threat Bus p2p_topic The topic string to include in the heartbeat timeout The p... | async def heartbeat(endpoint: str, p2p_topic: str, interval: int = 5):
global logger
action = {"action": "heartbeat", "topic": p2p_topic}
while True:
reply = send_manage_message(endpoint, action, interval)
if not reply_is_success(reply):
logger.error("Subscription with Threat Bus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_hb_off(self):\n await self.async_setup()\n off = TopicItem(\n self._off_topic,\n {\n \"cmd1\": 0x13,\n \"cmd2\": 0x00,\n \"target\": Address(\"000004\"),\n \"user_data\": None,\n \"hops_lef... | [
"0.5968126",
"0.5751398",
"0.5532078",
"0.53880507",
"0.5279109",
"0.52726096",
"0.5246624",
"0.5200716",
"0.519192",
"0.5134135",
"0.51318514",
"0.5131482",
"0.51096624",
"0.49996907",
"0.4969726",
"0.49536985",
"0.49502018",
"0.49493974",
"0.4914249",
"0.48973852",
"0.48654... | 0.7803305 | 0 |
round_hours(datetime, resolutionInHours) => datetime rounded to lower interval Works for hour resolution up to a day (e.g. cannot round to nearest week). | def round_hours(dt, resolutionInHours):
from datetime import datetime, timedelta
# First zero out minutes, seconds and micros
dtTrunc = dt.replace(minute=0,second=0, microsecond=0)
# Figure out how many minutes we are past the last interval
excessHours = (dtTrunc.hour) % resoluti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _round_time(dt=None, round_to=60):\n if hasattr(dt, 'tzinfo'):\n dt.replace(tzinfo=None)\n diff = dt - dt.replace(hour=0, minute=0, second=0, microsecond=0)\n seconds = diff.seconds\n rounding = (seconds + round_to / 2) // round_to * round_to\n return dt + datetime.timedelta(0, rounding-s... | [
"0.62496",
"0.62407213",
"0.61740667",
"0.6116412",
"0.60953623",
"0.59740126",
"0.5945597",
"0.5945597",
"0.58779293",
"0.58567286",
"0.57889855",
"0.5739316",
"0.56454057",
"0.5618119",
"0.5568635",
"0.5413379",
"0.53959805",
"0.5384869",
"0.5372498",
"0.53567505",
"0.52811... | 0.86196357 | 0 |
Calculates the significance for an A/B test. | def significance(size_a, successes_a, size_b, successes_b):
# Raising an error if the condition of size_sample > successes is not met.
if size_a < successes_a or size_b < successes_b:
raise ValueError('The size numbers must be greater than the number of successes for an '
'exper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fmeasure(B, hits, misses, falses) :\r\n x = ((1 + B**2) * hits) / ((1 + B**2) * hits + B**2 * misses + falses)\r\n return x",
"def simulate_significance(self):\n observed_difference = self.p_treatment - self.p_control\n\n try: # check to see if there's an array in self.binom_null\n ... | [
"0.5942177",
"0.5914534",
"0.5898058",
"0.5746552",
"0.5729359",
"0.56870574",
"0.5655487",
"0.5625582",
"0.5611372",
"0.5603035",
"0.55927914",
"0.5591462",
"0.5541222",
"0.54759663",
"0.547294",
"0.54472035",
"0.54131156",
"0.54129475",
"0.54105234",
"0.54044",
"0.5398178",... | 0.6507291 | 0 |
Learn using random samples, if enough samples are available in memory | def train(self):
if len(self.memory) > self.batch_size:
selecting_time_start = time.time()
experiences = self.memory.sample()
self.selecting_time += time.time() - selecting_time_start
self.learn(experiences) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_samples(self, n_samples):",
"def generate_samples(self, n_samples):",
"def learn(self):\n pass",
"def learn(self):\n pass",
"def learn(self):\n if self.step_count < self.learn_start_step or self.step_count % self.learn_interval != 0:\n return\n\n s, a, r,... | [
"0.6690334",
"0.6690334",
"0.66179794",
"0.66179794",
"0.6616561",
"0.6584631",
"0.6550663",
"0.6443997",
"0.64131385",
"0.6295754",
"0.6280296",
"0.6257376",
"0.62425834",
"0.62313735",
"0.62262535",
"0.6190727",
"0.6181846",
"0.6123597",
"0.60776126",
"0.6068146",
"0.605417... | 0.7019188 | 0 |
Returns an op to update a list of target variables from source variables. | def update_target_variables(self, target_variables,
source_variables,
tau=1.0,
use_locking=False,
name="update_target_variables"):
if not isinstance(tau, float):
raise Type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_update(target, source):\n for target_param, param in zip(target.parameters(), source.parameters()):\n target_param.data.copy_(param.data)",
"def hard_update(self,target, source):\n\t\tfor target_param, param in zip(target.parameters(), source.parameters()):\n\t\t\t\ttarget_param.data.copy_(par... | [
"0.66675526",
"0.6624005",
"0.6580059",
"0.65401715",
"0.63515884",
"0.5924977",
"0.5856354",
"0.5849391",
"0.58274955",
"0.58029515",
"0.5788468",
"0.57738566",
"0.57068956",
"0.5692191",
"0.5691666",
"0.5661541",
"0.55585796",
"0.55347294",
"0.5515069",
"0.5511939",
"0.5471... | 0.6650258 | 1 |
run a function and return the run time and the result of the function if the function requires arguments, those can be passed in too | def calculateRunTime(function, *args):
startTime = time.time()
result = function(*args)
return time.time() - startTime, result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_timer(*args, **kwargs):\n start = time.time()\n value = func(*args, **kwargs)\n end = time.time()\n runtime = end - start\n msg = f\"The runtime for {func.__name__} took {runtime} seconds to complete\"\n #print(msg.format(func=func.__name__, time=runtime))\n ... | [
"0.7586328",
"0.7548404",
"0.74903107",
"0.7458017",
"0.73813474",
"0.7225557",
"0.7115549",
"0.70576197",
"0.705625",
"0.7045507",
"0.70275384",
"0.702331",
"0.6991577",
"0.6989044",
"0.694265",
"0.69015586",
"0.69004416",
"0.6764218",
"0.67446786",
"0.67346257",
"0.67155105... | 0.8080999 | 0 |
Testing if padding works correctly for common scenarios of 2D data (batch_size x sequences). Specifically testing whether it produces proper padded sequences, and their masks. Also, testing if when symbol_to_mask is provided if it correctly masks those symbols. | def test_2D_padding(self):
field_names = ["text"]
mask_field_names = ['text_mask']
data_path = "mldp/tests/data/news.csv"
pad_symbol = "<PAD>"
mask_field_name_suffix = "mask"
padding_modes = ['left', 'right', 'both']
symbols_to_mask = ["The", "a", "to", "as"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_3D_padding(self):\n field_name = \"dummy\"\n mask_field_name = 'dummy_mask'\n pad_symbol = -99\n mask_fn_suffix = \"mask\"\n padding_mode = \"both\"\n axis = 2\n\n data_chunk = DataChunk(**{field_name: np.array([\n [[0, 1, 2], [3, 4, 5], [], [6]]... | [
"0.66571194",
"0.6441682",
"0.632566",
"0.6228574",
"0.6153739",
"0.61087537",
"0.6105533",
"0.60827976",
"0.6003496",
"0.5982256",
"0.5972349",
"0.5965401",
"0.59637886",
"0.59558815",
"0.5952085",
"0.591786",
"0.5871366",
"0.5843445",
"0.5820535",
"0.5779922",
"0.5775166",
... | 0.75791377 | 0 |
Light version test to check if the padder works for 3D data. | def test_3D_padding(self):
field_name = "dummy"
mask_field_name = 'dummy_mask'
pad_symbol = -99
mask_fn_suffix = "mask"
padding_mode = "both"
axis = 2
data_chunk = DataChunk(**{field_name: np.array([
[[0, 1, 2], [3, 4, 5], [], [6]],
[[1], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Pad3D3():\n input_shape = (1, 1, 2, 3, 2)\n pad = [1, 0, 1, 2, 1, 0]\n mode = \"constant\"\n res = [\n [\n [\n [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],\n [[0, 0, 0], [0, 1, 2], [0, 3, 4], [0, 5, 6], [0, 0, 0], [0, 0, 0]... | [
"0.6824534",
"0.66838425",
"0.6630269",
"0.66077274",
"0.65853065",
"0.6516807",
"0.65082043",
"0.65043795",
"0.64946616",
"0.648253",
"0.6417899",
"0.63924766",
"0.6375224",
"0.6359866",
"0.6327758",
"0.6305439",
"0.62622947",
"0.6182932",
"0.617922",
"0.61383235",
"0.611106... | 0.6957212 | 0 |
Add a default share ID to C{store}, pointing to C{shareID} with a priority C{priority}. The highestpriority share ID identifies the share that will be retrieved when a user does not explicitly provide a share ID in their URL (e.g. /host/users/username/). | def addDefaultShareID(store, shareID, priority):
_DefaultShareID(store=store, shareID=shareID, priority=priority) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDefaultShareID(store):\n defaultShareID = store.findFirst(\n _DefaultShareID, sort=_DefaultShareID.priority.desc)\n if defaultShareID is None:\n return u''\n return defaultShareID.shareID",
"def get_share(self, activity_user_id, activity_id, share_id):\n return None",
"def shar... | [
"0.68312156",
"0.5360172",
"0.5310793",
"0.52944005",
"0.52378845",
"0.5170581",
"0.51500475",
"0.497758",
"0.49575073",
"0.4938343",
"0.49230355",
"0.48810166",
"0.48424843",
"0.48328438",
"0.48196656",
"0.47416145",
"0.4726872",
"0.4690981",
"0.46693465",
"0.4620207",
"0.45... | 0.91040206 | 0 |
Get the highestpriority default share ID for C{store}. | def getDefaultShareID(store):
defaultShareID = store.findFirst(
_DefaultShareID, sort=_DefaultShareID.priority.desc)
if defaultShareID is None:
return u''
return defaultShareID.shareID | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDefaultShareID(store, shareID, priority):\n _DefaultShareID(store=store, shareID=shareID, priority=priority)",
"def get_highest_id(self):\n\n return self.mint.get_highest_id()",
"def genShareID(store):\n return unicode(os.urandom(16).encode('hex'), 'ascii')",
"def max_share_count(self) ->... | [
"0.7206265",
"0.60183716",
"0.5947432",
"0.5896664",
"0.57326794",
"0.5730939",
"0.56178427",
"0.5572699",
"0.5549776",
"0.55466425",
"0.5538893",
"0.55001765",
"0.54829454",
"0.5482721",
"0.54605675",
"0.54046506",
"0.53794336",
"0.5372752",
"0.5364573",
"0.53643966",
"0.535... | 0.8637612 | 0 |
Retrieve a L{SharingIndex} for a particular user, or rend.NotFound. | def locateChild(self, ctx, segments):
store = _storeFromUsername(
self.loginSystem.store, segments[0].decode('utf-8'))
if store is None:
return rend.NotFound
return (SharingIndex(store, self.webViewer), segments[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_share(self, activity_user_id, activity_id, share_id):\n return None",
"def get_user(request, user_id):\n\n try:\n get_user = User.objects.get(id=user_id)\n except:\n return JsonResponse(\n \"Not Found - User does not exist.\", status=404, safe=False\n )\n\n # C... | [
"0.5690004",
"0.5583716",
"0.5333351",
"0.5305234",
"0.52540773",
"0.52362347",
"0.52299106",
"0.51833224",
"0.5173709",
"0.5127668",
"0.5119951",
"0.50898397",
"0.5076749",
"0.5047834",
"0.5047834",
"0.50185806",
"0.49993867",
"0.49953124",
"0.4970683",
"0.49701992",
"0.4963... | 0.5849322 | 0 |
Look up a shared item for the role viewing this SharingIndex and return a L{PublicAthenaLivePage} containing that shared item's fragment to the user. These semantics are UNSTABLE. This method is adequate for simple uses, but it should be expanded in the future to be more consistent with other resource lookups. In parti... | def locateChild(self, ctx, segments):
shareID = segments[0].decode('utf-8')
role = self.webViewer.roleIn(self.userStore)
# if there is an empty segment
if shareID == u'':
# then we want to return the default share. if we find one, then
# let's use that
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromSharedItem(cls, sharedItem):\n localpart = None\n for (localpart, domain) in userbase.getAccountNames(sharedItem.store):\n break\n if localpart is None:\n raise NoSuchShare()\n for share in sharedItem.store.query(Share,\n ... | [
"0.5827662",
"0.57348615",
"0.5662804",
"0.56601375",
"0.56514573",
"0.5651063",
"0.5639989",
"0.55624044",
"0.54973114",
"0.53261805",
"0.5240352",
"0.5229794",
"0.5137831",
"0.50752205",
"0.49703422",
"0.48656753",
"0.48469245",
"0.48203176",
"0.4800584",
"0.4796039",
"0.47... | 0.59761953 | 0 |
Test to check if getting the ID of a petition works. | def testGetPetitionIDEndpoint():
api = c.Api()
petition_url = 'https://www.change.org/p/the-supreme-court-of-missouri-take-the-case-of-michael-brown-popularly-dubbed-the-ferguson-case-to-the-missouri-supreme-court-with-ferguson-officer-darren-wilson-as-the-accused'
petition_id = api.getPetitionId(petition_url)
asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_poets_id_get(self):\n pass",
"def test_solareclipses_id_get(self):\n pass",
"def test_variablepresentations_id_get(self):\n pass",
"def test_get_pet_by_id(self):\n response = self.client.open(\n '/pet/{petId}'.format(pet_id=789),\n method='GET')\n ... | [
"0.79498094",
"0.7612395",
"0.73243934",
"0.7122424",
"0.7080414",
"0.699587",
"0.69513243",
"0.69329464",
"0.6911171",
"0.67992973",
"0.67653096",
"0.6737983",
"0.67323214",
"0.67052066",
"0.6660955",
"0.66367024",
"0.66249657",
"0.661344",
"0.65653884",
"0.6541388",
"0.6514... | 0.79774404 | 0 |
Test to check if getting petition details for multiple petitions by ID works correctly. | def testGetMultiplePetitionsById():
api = c.Api()
output = api.getMultiplePetitionsById([2297756, 1756395])
if type(output) is list:
assert True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_poets_id_get(self):\n pass",
"def test_solareclipses_id_get(self):\n pass",
"def testGetPetitionIDEndpoint():\n\tapi = c.Api()\n\tpetition_url = 'https://www.change.org/p/the-supreme-court-of-missouri-take-the-case-of-michael-brown-popularly-dubbed-the-ferguson-case-to-the-missouri-supre... | [
"0.7277272",
"0.6892533",
"0.662501",
"0.6578746",
"0.6576278",
"0.6478511",
"0.64663815",
"0.6407937",
"0.6342147",
"0.62757206",
"0.6240228",
"0.62282765",
"0.6172308",
"0.6147652",
"0.61143816",
"0.6091003",
"0.60813",
"0.6016178",
"0.6005982",
"0.5984068",
"0.5963086",
... | 0.79930466 | 0 |
Test to check if getting the number of signatures on a petition works correctly | def testGetSignatureCountOnPetition():
api = c.Api()
output = api.getSignatureCountOnPetition(2297566)
if type(output) is int:
assert True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signature_length(self):",
"def test__len__(self):\n assert len(FSignature([forge.arg('a')])) == 1",
"def test_count_publications(self):\n pass",
"def test_signature_verification(self):\n curdir = os.path.dirname(os.path.abspath(__file__))\n keydir = os.path.join(curdir, \"data... | [
"0.6730864",
"0.67134356",
"0.6490915",
"0.62044877",
"0.6133203",
"0.60348886",
"0.6005115",
"0.58424556",
"0.57883483",
"0.5781113",
"0.5746445",
"0.57400393",
"0.5731183",
"0.5726611",
"0.57222307",
"0.5709273",
"0.5702754",
"0.5699209",
"0.56738657",
"0.5665725",
"0.56650... | 0.7905226 | 0 |
infinite loop to advertise the routing table to all the neighbors. trigger neighbor swtich to update routing information instantly. | def broadcast_thread(self):
while True:
try:
logger.info('broadcast routing table (dpid=%s)', dpid_to_str(self.dp.id))
for port_no, port in self.ports.items():
if port.neighbor_switch_dpid:
self.switches[port.neighbor_switch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _announce(self):\n \n \"Create dictionary to hold key: router, value: all the distances to it\"\n shortestDises = dict()\n\n \"Fill in shortestDises by going through all the values in routing table\" \n for disToDests in self.routingTable.values():\n for des... | [
"0.68915033",
"0.66389716",
"0.6598268",
"0.6571927",
"0.64771855",
"0.6414562",
"0.5976607",
"0.5940105",
"0.5861183",
"0.5837956",
"0.57994616",
"0.57953876",
"0.5771204",
"0.5767448",
"0.57330596",
"0.5663159",
"0.56330067",
"0.56264037",
"0.56159544",
"0.56072795",
"0.554... | 0.71332824 | 0 |
try to process all the queued routing information. | def process_queued_msg(self):
try:
while not self.queue.empty():
port, tbl = self.queue.get()
reveived_port = self.switches[port.neighbor_switch_dpid].ports[port.neighbor_port_no]
self.tbl.update_by_neighbor(reveived_port, port, tbl)
self.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __process_requests(self):\n\t\tfor received_message in self.receiver:\n\t\t\tif self.registry.ip_known(received_message.sender):\n\t\t\t\tlogger.info(\"Message received from registered client.\")\n\t\t\t\tif received_message.body.startswith(COMMAND_FLAG_CHAR):\n\t\t\t\t\tlogger.debug(\"Message was a command.\"... | [
"0.61211884",
"0.6118696",
"0.5979198",
"0.5806326",
"0.5766877",
"0.5762818",
"0.5662577",
"0.56588477",
"0.5649565",
"0.5638053",
"0.55420285",
"0.5537676",
"0.55065197",
"0.5502671",
"0.54951775",
"0.54863334",
"0.54849994",
"0.5483143",
"0.5479529",
"0.5476768",
"0.546869... | 0.7076636 | 0 |
return ARP table as a list of dictionary. | def get_arp_list(self):
arp_list = []
for ip, value in self.ip_to_mac.items():
arp_list.append({'ip': str(ip),
'hw_addr': str(value[0]),
'last_update': datetime.datetime.fromtimestamp(value[1]).strftime('%Y-%m-%d %H:%M:%S')})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_arp_table(self, vrf=\"\"):\n\n arp_table = []\n output = self._send_command('/ip arp print terse')\n\n arps = parse_terse_output(output)\n\n for arp in arps:\n if arp.get('mac-address'):\n arp_table.append({\n 'interface': arp.get('in... | [
"0.7437058",
"0.6826946",
"0.67796856",
"0.6630043",
"0.6517875",
"0.63336134",
"0.63289434",
"0.60332114",
"0.5915936",
"0.58368886",
"0.58107936",
"0.55169",
"0.55130374",
"0.5497963",
"0.5460182",
"0.54279923",
"0.5393707",
"0.5380129",
"0.535425",
"0.5350383",
"0.5320536"... | 0.7094078 | 1 |
return routing table as a list of dictionary. | def get_routing_table(self):
routing_tbl = []
for subnet, entry in self.tbl.items():
d = entry.to_dict()
d['subnet'] = str(subnet)
routing_tbl.append(d)
return routing_tbl | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dict(self) -> dict:\n return self._route_table",
"def all_routing(G, switch_nodes, table_file_name):\n\n table = OrderedDict({})\n for s in switch_nodes:\n for d in switch_nodes:\n if s != d:\n routing(G, s, d, table)\n\n with open(table_file_name, 'w') as ... | [
"0.77210844",
"0.6709546",
"0.64302474",
"0.63715637",
"0.623701",
"0.61796683",
"0.6155058",
"0.6075935",
"0.6040823",
"0.603392",
"0.6024642",
"0.59989035",
"0.59968525",
"0.5968736",
"0.5956476",
"0.5927441",
"0.5900913",
"0.5837161",
"0.5820069",
"0.58077735",
"0.5790471"... | 0.8206283 | 0 |
deploy all the routing entry in the routing table. | def deploy_routing_table(self):
for subnet, entry in self.tbl.items():
if entry.neighbor_port:
self.deploy_flow_entry(subnet=subnet, outport=entry.receive_port, dstport=entry.neighbor_port) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deploy():\n update_treesheets()\n restart_treesheets()",
"def post_route_table_create(self, resource_dict):\n pass",
"def __init__(self):\n self.routingTable = dict()",
"def deploy(self):\n self._switch.odlclient._request_json(self._table_path, method=\"post\", json={\n ... | [
"0.5980628",
"0.5798021",
"0.56709176",
"0.5667072",
"0.5665464",
"0.5662688",
"0.5594924",
"0.55850637",
"0.55674374",
"0.5528769",
"0.5450715",
"0.54399043",
"0.54344666",
"0.542846",
"0.54066753",
"0.5389441",
"0.53138244",
"0.53026205",
"0.53018546",
"0.5285111",
"0.52762... | 0.8103183 | 0 |
return port_no by match the destination IP address with the subnets. | def find_outport_by_ip(self, dst_ip):
for port_no, port in self.ports.items():
if port.gateway and dst_ip in port.gateway.ipv4_subnet:
return port_no
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_outport_by_subnet(self, subnet):\n for port_no, port in self.ports.items():\n if port.gateway and port.gateway.ipv4_subnet == subnet:\n return port_no\n return None",
"def get_port(self, dst_ip, access_table):\r\n if access_table:\r\n if isinstan... | [
"0.6941393",
"0.65439576",
"0.6128386",
"0.61070126",
"0.60062206",
"0.59506077",
"0.5934577",
"0.5844289",
"0.58083206",
"0.58003646",
"0.5789853",
"0.5707216",
"0.56426615",
"0.564023",
"0.55956894",
"0.5579187",
"0.5557291",
"0.5545042",
"0.55236137",
"0.5491499",
"0.54737... | 0.6856934 | 1 |
Delete fn file if it exists | def delete_file(input_fn):
if os.path.isfile(input_fn):
os.remove(input_fn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _delete_file(path):\n if os.path.isfile(path):\n os.remove(path)",
"def _delete_file(path):\n if os.path.isfile(path):\n os.remove(path)",
"def _delete_file(path):\n if os.path.isfile(path):\n os.remove(path)",
"def rm_file_if_exists(f):\n with contextlib.suppress(FileNotFo... | [
"0.77830786",
"0.7718093",
"0.7718093",
"0.7579628",
"0.75730056",
"0.75378186",
"0.7521336",
"0.74646246",
"0.73274463",
"0.7292511",
"0.7247649",
"0.72340125",
"0.7233349",
"0.71774656",
"0.7140424",
"0.71367246",
"0.713443",
"0.7099989",
"0.7091202",
"0.70755124",
"0.70725... | 0.81810206 | 0 |
Initializes this loss scale optimizer. | def __init__(self, optimizer, loss_scale):
if not isinstance(optimizer, optimizer_v2.OptimizerV2):
raise ValueError('"optimizer" must be an instance of OptimizerV2, but '
'got: %s' % optimizer)
if optimizer.clipnorm is not None:
raise ValueError('LossScaleOptimizer does not su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_loss_and_optimizer(self):\n self.criterion = CrossEntropyLoss()\n self.optimizer = Adam(self.model.parameters(), lr=self.hyper_parameters['lr'])",
"def __init__(self, **kwargs):\n\n super().__init__(**kwargs)\n self.criterion = self._initLoss()",
"def __init__(self, **kwarg... | [
"0.7157795",
"0.6916654",
"0.6916654",
"0.68659997",
"0.6758468",
"0.67563814",
"0.6621184",
"0.66053504",
"0.660172",
"0.6601449",
"0.6474571",
"0.6467551",
"0.64525384",
"0.6447518",
"0.64248365",
"0.641149",
"0.63619477",
"0.6337405",
"0.6334744",
"0.632274",
"0.63118184",... | 0.71536416 | 1 |
The `LossScale` instance associated with this optimizer. | def loss_scale(self):
return self._loss_scale | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_loss_scale(self):\n return self._loss_scale",
"def get_scaled_loss(self, loss):\n loss_scale = self._loss_scale()\n if callable(loss):\n def new_loss():\n loss_val = loss()\n return loss_val * math_ops.cast(loss_scale, loss_val.dtype)\n return new_loss\n else:\n ... | [
"0.793493",
"0.73162746",
"0.68573815",
"0.6839494",
"0.67812747",
"0.67812747",
"0.67776465",
"0.6770828",
"0.67481637",
"0.6745338",
"0.6738262",
"0.67050755",
"0.6683727",
"0.6681704",
"0.667356",
"0.66186064",
"0.65862453",
"0.6572908",
"0.6491323",
"0.64412814",
"0.63570... | 0.8009351 | 0 |
Scales the loss by the loss scale. This method is only needed if you compute gradients manually, e.g. with `tf.GradientTape`. In that case, call this method to scale the loss before passing the loss to `tf.GradientTape`. If you use `LossScaleOptimizer.minimize` or `LossScaleOptimizer.get_gradients`, loss scaling is aut... | def get_scaled_loss(self, loss):
loss_scale = self._loss_scale()
if callable(loss):
def new_loss():
loss_val = loss()
return loss_val * math_ops.cast(loss_scale, loss_val.dtype)
return new_loss
else:
return loss * math_ops.cast(loss_scale, loss.dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_scale(self):\n return self._loss_scale",
"def get_loss_scale(self):\n return self._loss_scale",
"def supervised_cost_scale(\n scale, loss_supervised, output_noise_labelled, labelled_target\n):\n cost_supervised = loss_supervised.forward(output_noise_labelled, labelled_target)\n\n co... | [
"0.6739694",
"0.6595755",
"0.65169394",
"0.6198273",
"0.61731267",
"0.59716827",
"0.5964872",
"0.58355457",
"0.58057356",
"0.5729986",
"0.57219154",
"0.57206905",
"0.5635103",
"0.5605027",
"0.55879354",
"0.55739707",
"0.55709136",
"0.552222",
"0.55163234",
"0.5515871",
"0.550... | 0.7564824 | 0 |
Multiply a (possibly sparse) gradient by the given scale factor. | def _multiply_gradient(gradient, scale):
scale = math_ops.cast(scale, gradient.dtype)
if isinstance(gradient, ops.IndexedSlices):
return ops.IndexedSlices(
gradient.values * scale,
gradient.indices,
dense_shape=gradient.dense_shape)
else:
return gradient * scale | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_scale(x, multiplier):\n return GradScale(multiplier)(x)",
"def scaling(mat, factor):\n\treturn mat / (mat + factor)",
"def scale(self, scale_factor: float) -> None:\n self.tensor[:, :3] *= scale_factor",
"def scale(self, factor):\n self.b = factor * self.b",
"def supervised_cost_s... | [
"0.6945256",
"0.6364424",
"0.6349341",
"0.63197815",
"0.62594366",
"0.6207935",
"0.6151295",
"0.60449195",
"0.602039",
"0.5922737",
"0.5878117",
"0.5822671",
"0.580783",
"0.5759809",
"0.5734907",
"0.5721659",
"0.57112604",
"0.5709619",
"0.5707256",
"0.56965876",
"0.56932414",... | 0.80634993 | 0 |
Copy energy model file. | def copy_model_file(src_dir, dst_dir, file_name, file_ext=None):
file_ext = 'osm' if file_ext is None else file_ext
src_file = src_dir.joinpath('in.{}'.format(file_ext))
dst_file = dst_dir.joinpath('{}.{}'.format(file_name, file_ext))
try:
shutil.copyfile(src_file, dst_file)
except FileNotF... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeModel(self):\n\n # Get the script\n modelScript = os.path.join(self.datapath, 'make3FGLxml.py')\n if not os.path.isfile(modelScript):\n # download it\n print(\"\\t=== Downloading make3FGLxml.py ===\")\n os.system('wget https://fermi.gsfc.nasa.gov/ssc/da... | [
"0.5939559",
"0.5896609",
"0.57205296",
"0.5705327",
"0.5664915",
"0.5664915",
"0.5664915",
"0.5561054",
"0.5485006",
"0.5483633",
"0.5475485",
"0.54704446",
"0.5431423",
"0.5431291",
"0.5385497",
"0.53754187",
"0.53675175",
"0.5362274",
"0.53395766",
"0.53362334",
"0.5321802... | 0.6624411 | 0 |
Creates an output file for in the form of topicsummary with the results | def write_to_out(result_list, topic):
# Use formatted string to make the topic-specific output file name
out_filename = f"{topic}summary.txt"
# Using the with...as construct to open an output file in write mode
with open(out_filename, "w", encoding="utf-8") as out_file:
# For every list in the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(self, outdir, topic_docs = None):\n parsed_topics_fn = outdir+'/parsed_topics_'+self.name+'.csv'\n parsed_topics = self.parse_topics()\n with open(parsed_topics_fn, 'wb') as outfile:\n writer = csv.writer(outfile)\n writer.writerow(['topic index', 'top words'])... | [
"0.7065068",
"0.67121065",
"0.667491",
"0.66702765",
"0.6493708",
"0.64164627",
"0.63807386",
"0.6348919",
"0.62307876",
"0.62293154",
"0.61001325",
"0.6076558",
"0.607312",
"0.60509425",
"0.60321623",
"0.6012794",
"0.59988433",
"0.595068",
"0.59492254",
"0.59465146",
"0.5946... | 0.750176 | 0 |
Analyzes the urls in the file with urls to find matches | def analyze_urls(filename, topic):
# Initialize an empty list. Note that I store my urls and references
# in a sort of strange way. Each element in result_list is a list of two
# elements, the first element being the url, and the second element
# being a list of all the references to the url
result_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_from_file():\r\n global default_input_path\r\n print \"JoomFind v 1.0\"\r\n print \"\\n\\nTrying to read URL(s) form \" + default_input_path + \" file...\\n\"\r\n try:\r\n if not default_input_path:\r\n f = open(\"urls.txt\")\r\n else:\r\n f=open(default_... | [
"0.7247138",
"0.7022",
"0.66191137",
"0.65766627",
"0.6553886",
"0.6445074",
"0.63741",
"0.63335973",
"0.63231295",
"0.6276514",
"0.6263442",
"0.6192583",
"0.61920995",
"0.6159629",
"0.61356217",
"0.61198586",
"0.6062683",
"0.6062513",
"0.60128546",
"0.5975132",
"0.5968954",
... | 0.7395171 | 0 |
Function adds two numbers and converts to binary. | def add_binary(a, b):
return bin(a + b)[2:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_binary(a,b):\n max_len = max(len(a),len(b))\n a = a + (max_len-len(a))*'0'\n b = b + (max_len-len(b))*'0'\n result = \"\" \n elde = 0 \n for i in range(max_len):\n a_i,b_i = int(a[i]),int(b[i])\n if (a_i + b_i+elde) == 2:\n elde = 1\n t = 0\n else:\n ... | [
"0.80124867",
"0.7827019",
"0.76427984",
"0.7577933",
"0.7251505",
"0.70949155",
"0.70785266",
"0.69601315",
"0.6959739",
"0.69178003",
"0.6867724",
"0.6841246",
"0.6840538",
"0.68314004",
"0.67125916",
"0.67007583",
"0.6699635",
"0.669284",
"0.66489726",
"0.6640531",
"0.6630... | 0.8312693 | 0 |
Initializes Hydra only if it is not already initialized. | def _ensure_hydra_initialized(
config_module: str, job_name: str = "fseval_hydra_utils"
) -> None:
gh = GlobalHydra()
if not gh.is_initialized():
initialize_config_module(
config_module=config_module, job_name=job_name, version_base="1.1"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize():\n manager.initialize()\n logs.exit_great_success()",
"def do_init(self):\n\n pass",
"def __init__(self):\n self._initialized = False\n self.init()",
"def __init__(self):\n self._initialized = False\n self.init()",
"def _manually_initialize(self) ->... | [
"0.6209268",
"0.61949795",
"0.6180044",
"0.6180044",
"0.61731255",
"0.6147392",
"0.61265355",
"0.6097938",
"0.6017801",
"0.6017801",
"0.6017801",
"0.59966564",
"0.5966444",
"0.59586257",
"0.5950315",
"0.5950315",
"0.5927798",
"0.5924597",
"0.5913495",
"0.58983785",
"0.5885621... | 0.71574265 | 0 |
Grabs the Hydra `ConfigLoader`. | def _get_config_loader(config_module: str) -> ConfigLoader:
_ensure_hydra_initialized(config_module)
gh = GlobalHydra()
cl = gh.config_loader()
return cl | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loader() -> ConfigLoader:\n return ConfigLoader.from_configuration_type(PackageType.AGENT)",
"def loader() -> ConfigLoader:\n return ConfigLoader.from_configuration_type(PackageType.AGENT)",
"def loadConfigs(self):\n self.onLoadConfig(urlopen(self.inipath))",
"def load_config(self):\n ... | [
"0.67302746",
"0.67302746",
"0.63855314",
"0.6287435",
"0.61643356",
"0.5959769",
"0.59583026",
"0.5888783",
"0.58228844",
"0.5808321",
"0.57732725",
"0.5772872",
"0.5714202",
"0.56751454",
"0.56719464",
"0.56634206",
"0.5655696",
"0.5647409",
"0.56410396",
"0.56160206",
"0.5... | 0.8083242 | 0 |
This function takes the routing vector and the neighbours routing vector and updates the current vector. If there is no update the second value is returned as false, else second value is True vec1 = vector to update vec2 = vector which is received dist = distance between them | def update_table(vec1, vec2, dist):
flag = False
for router_to in range(len(vec1)):
if vec1[router_to] > vec2[router_to] + dist:
vec1[router_to] = vec2[router_to] + dist
flag = True
return vec1, flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_update(self, neighbor, dv_list):\n neighbor.is_killed = False\n neighbor.kill_timer = time.time()\n neighbor.dv_update(dv_list)\n # Iterate to see if new node is included in the graph.\n for name in neighbor.distance_vector:\n if name not in self.distance_vec... | [
"0.63939047",
"0.6258217",
"0.6063154",
"0.56720173",
"0.5632161",
"0.5608573",
"0.5462357",
"0.5388178",
"0.5371082",
"0.53031",
"0.52890694",
"0.5269303",
"0.5231124",
"0.5221327",
"0.52091473",
"0.52045894",
"0.5196824",
"0.51870656",
"0.5162876",
"0.5161015",
"0.5159955",... | 0.7336643 | 0 |
Build chat window, set widgets positioning and event bindings | def build_window(self):
# Size config
self.root.geometry('{}x{}'.format(800, 450))
self.root.minsize(600, 400)
# create all of the main containers
self.left_frame = Frame(self.root, bg='red', width=150, height=450, pady=3)
self.right_frame = Frame(self.root, bg='blue', w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chat_window(window, chat_lines, write_box):\n for i in xrange(25):\n chat_lines[i] = Entry(Point(130,245-(i*9)),80)\n chat_lines[i].draw(window)\n chat_lines[i].setFill(\"white\")\n write_box.draw(window) # draw it to the window\n help(chat_lines)",
"def new_window_messages(self... | [
"0.6898628",
"0.6870365",
"0.68484443",
"0.6702743",
"0.6519873",
"0.6475004",
"0.6413773",
"0.6409881",
"0.6383972",
"0.63573664",
"0.6306729",
"0.6292875",
"0.6283318",
"0.6264044",
"0.62494653",
"0.6241723",
"0.62238955",
"0.6218888",
"0.62177086",
"0.6195311",
"0.61767215... | 0.7285587 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.