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 |
|---|---|---|---|---|---|---|
Convert the labelme annotations to coco format and validate the annotations with randomly picked 5 images. If the annotation is incorrect, the program terminates. | def convert_labelme_to_coco(path_to_data):
# convert labelme annotations to coco
labelme2coco.convert(path_to_data, path_to_data + r'\coco_annotation.json')
# Open the coco format data
with open(path_to_data + r'\coco_annotation.json') as f:
coco_d = json.load(f)
# Get the category... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_annotation(target, images, bbox_path):\n good_image_paths = []\n bad_image_paths = []\n bb = read_annotation_yolov5(bbox_path)\n for path in images:\n basename = os.path.basename(path) # extract file name only (e.g., bear_013.jpg)\n basename_no_ext = os.path.splitext(basenam... | [
"0.6922452",
"0.6743097",
"0.67311317",
"0.6724994",
"0.64523804",
"0.6366201",
"0.6221984",
"0.6215864",
"0.6204359",
"0.6179897",
"0.61457837",
"0.613554",
"0.6132579",
"0.60457397",
"0.602493",
"0.5998027",
"0.5937625",
"0.5865713",
"0.5820261",
"0.5809766",
"0.5806412",
... | 0.6996364 | 0 |
Convert an array of export statements (what we get from envextra in the config) into a dict | def env_lines_to_dict(self, env_lines):
env_dict = {}
for env_line in env_lines:
split_env_line = shlex.split(env_line)
if split_env_line[0] == "export":
split_env_line = split_env_line[1:]
for item in split_env_line:
if "=" in item:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_configurations():\n pass",
"def export(self) -> Dict[str, Any]:\n return {\n \"name\": self.name,\n \"channels\": [channel for channel in self.channels],\n \"packages\": self.packages.export(),\n \"logs\": [log for log in self.logs],\n \... | [
"0.59988654",
"0.59330225",
"0.5903955",
"0.56446517",
"0.5643221",
"0.56416047",
"0.54888237",
"0.5403373",
"0.53202504",
"0.52638626",
"0.5262855",
"0.5257865",
"0.5199736",
"0.5194403",
"0.5183345",
"0.5182272",
"0.51688004",
"0.5123766",
"0.5117179",
"0.5108427",
"0.51010... | 0.6357385 | 0 |
Quote a string or list of strings using the Condor submit file "new" argument quoting rules. Returns str The arguments in a quoted form. Warnings You will need to surround the result in doublequotes before using it in the Arguments attribute. Examples >>> quote_arguments(["3", "simple", "arguments"]) '3 simple argument... | def quote_arguments(args):
if isinstance(args, str):
args_list = [args]
else:
args_list = args
quoted_args = []
for a in args_list:
qa = _double_up_quotes(a)
if " " in qa or "'" in qa:
qa = "'" + qa + "'"
quoted_args.append(qa)
return " ".join(quo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argument_list_quote(arguments):\n args = []\n for arg in arguments:\n args.append(argument_quote(arg))\n return '\"%s\"' % ' '.join(args)",
"def _quote_arguments(args):\n return map(lambda x: '\"{}\"'.format(x) if ' ' in x else '{}'.format(x), args)",
"def argument_quote(argument):\n... | [
"0.7215548",
"0.6580144",
"0.6086504",
"0.5937315",
"0.5752094",
"0.56268567",
"0.55315644",
"0.544126",
"0.54088515",
"0.533452",
"0.5203533",
"0.5165263",
"0.51386887",
"0.51292366",
"0.5123674",
"0.50810844",
"0.5078379",
"0.5072677",
"0.50487226",
"0.50456464",
"0.5013752... | 0.74514025 | 0 |
Quote a dict of strings using the Condor submit file "new" environment quoting rules. Returns str The environment in quoted form. Warnings You will need to surround the result in doublequotes before using it in the Environment attribute. Examples >>> from collections import OrderedDict >>> quote_environment(OrderedDict... | def quote_environment(env):
if not isinstance(env, dict):
raise TypeError("env must be a dict")
entries = []
for k, v in env.items():
qv = _double_up_quotes(str(v))
if " " in qv or "'" in qv:
qv = "'" + qv + "'"
entries.append("%s=%s" % (k, qv))
return " ".j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_environment(envdict):\n lines = []\n for k, v in envdict.iteritems():\n if \" \" in v: # NOTE: per the spec, one might want to handle all 'whitespace' chars.\n v = v.replace(\"'\", \"''\")\n v = \"'%s'\" % v\n v = v.replace('\"', '\"\"')\n lines.append('%... | [
"0.75373447",
"0.6221324",
"0.6093788",
"0.5934985",
"0.5808252",
"0.57019943",
"0.5597145",
"0.5515628",
"0.5512391",
"0.547237",
"0.5445413",
"0.5308214",
"0.5276308",
"0.52133214",
"0.51868063",
"0.5152444",
"0.50912315",
"0.5079086",
"0.50783825",
"0.5009073",
"0.50075024... | 0.8446683 | 0 |
Returns a new list containing square roots of the elements of the original list that are perfect squares. >>> seq = [8, 49, 8, 9, 2, 1, 100, 102] >>> squares(seq) [7, 3, 1, 10] >>> seq = [500, 30] >>> squares(seq) [] | def squares(s):
"*** YOUR CODE HERE ***"
result = []
for num in s:
sr = round(math.sqrt(num))
if sr * sr == num:
result.append(sr)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_squares(self):\n\t\tself.squares = [x for x in range(self.low, self.high + 1) if sqrt(x) == int(sqrt(x))]",
"def squares(s):\n\n \"*** YOUR CODE HERE ***\"\n return [int(x**(1/2)) for x in s if x**(1/2) == round(x**(1/2))]",
"def list_squared(start, stop):\n result = []\n\n for num in rang... | [
"0.7532929",
"0.70103526",
"0.69574976",
"0.68897986",
"0.6871598",
"0.68224853",
"0.6734844",
"0.6657192",
"0.6642378",
"0.66411835",
"0.6640479",
"0.66332394",
"0.66236895",
"0.6610896",
"0.6526553",
"0.65028816",
"0.6489638",
"0.648101",
"0.64674306",
"0.631349",
"0.630965... | 0.7138826 | 1 |
Return the value of G(n), computed recursively. >>> g(1) 1 >>> g(2) 2 >>> g(3) 3 >>> g(4) 10 >>> g(5) 22 >>> from construct_check import check >>> check(HW_SOURCE_FILE, 'g', ['While', 'For']) True | def g(n):
"*** YOUR CODE HERE ***"
if n < 4:
return n
else:
return g(n-1) + 2*g(n-2) + 3*g(n-3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def g(n):\n\t\"*** YOUR CODE HERE ***\"\n\tif n <= 3:\n\t\treturn n\n\telse:\n\t\treturn g(n-1) + 2*g(n-2) + 3*g(n-3)",
"def g(n):\n \"*** YOUR CODE HERE ***\"\n if n <=3:\n return n\n else:\n return g(n-1)+2*g(n-2)+3*g(n-3)",
"def g(n):\n \"*** YOUR CODE HERE ***\"\n if n <= 3:\n ... | [
"0.65347075",
"0.64384305",
"0.6329685",
"0.6329685",
"0.61571145",
"0.60239685",
"0.5937985",
"0.55639344",
"0.55369043",
"0.5523096",
"0.5420632",
"0.5410982",
"0.5398192",
"0.53921515",
"0.5342789",
"0.5293935",
"0.52893794",
"0.5279808",
"0.52543837",
"0.5252531",
"0.5185... | 0.6510758 | 1 |
Return the value of G(n), computed iteratively. >>> g_iter(1) 1 >>> g_iter(2) 2 >>> g_iter(3) 3 >>> g_iter(4) 10 >>> g_iter(5) 22 >>> from construct_check import check >>> check(HW_SOURCE_FILE, 'g_iter', ['Recursion']) True | def g_iter(n):
"*** YOUR CODE HERE ***"
if n < 4:
return n
else:
g1 = 1
g2 = 2
g3 = 3
i = 3
while(i < n):
i += 1
t = g3 + 2*g2 + 3*g1
g1 = g2
g2 = g3
g3 = t
return g3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def g_iter(n):\n\tif n <= 3:\n\t\treturn n\n\telse:\n\t\tg_n_1, g_n_2, g_n_3 = 3, 2, 1\n\t\t# always update the g_i until reach the final n\n\t\tfor i in range(4,n+1):\n\t\t\tg_i = g_n_1 + 2*g_n_2 + 3*g_n_3\n# \t\t\tupdate the g(n-1), g(n-2), g(n-3)\n\t\t\tg_n_1, g_n_2, g_n_3 = g_i, g_n_1, g_n_2\n\t\treturn g_i\n\... | [
"0.73015696",
"0.68882436",
"0.62829113",
"0.6223856",
"0.6131208",
"0.60937464",
"0.6027959",
"0.597907",
"0.5950993",
"0.59052163",
"0.58999294",
"0.58999294",
"0.584625",
"0.5844759",
"0.58446234",
"0.5835706",
"0.5794958",
"0.5790122",
"0.57023543",
"0.5638049",
"0.563491... | 0.7122139 | 1 |
Return the number of ways to make change for amount. >>> count_change(7) 6 >>> count_change(10) 14 >>> count_change(20) 60 >>> count_change(100) 9828 >>> from construct_check import check >>> check(HW_SOURCE_FILE, 'count_change', ['While', 'For']) True | def count_change(amount):
"*** YOUR CODE HERE ***"
if amount < 1:
return 0
elif amount == 1:
return 1
elif amount == 2:
return 2
else:
return count_change(amount - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_change(amount):\n\toptions = [2**i for i in range(amount+1) if 2**i <= amount]\n\toptions = sorted(options, reverse = True)\n\tlength = len(options)\n\n\t# print(length)\n\tdef helper(remains, i, options, length):\n\t\t# loop until reaching the smallest coin\n\t\tif i >= length :\n\t\t\treturn 0\n\t\t# c... | [
"0.750737",
"0.7155193",
"0.6912649",
"0.69010884",
"0.67702913",
"0.6648249",
"0.65593016",
"0.65591896",
"0.6208104",
"0.5816895",
"0.56851083",
"0.5558492",
"0.5312004",
"0.52741164",
"0.52447283",
"0.52056",
"0.518745",
"0.5175362",
"0.5113141",
"0.5073923",
"0.5057803",
... | 0.72280043 | 1 |
Create the webhook if it doesn't already exist. The Webhook is triggered when new messages are posted to the room. | def create_new_message_webhook(room, webhook_url):
# when a message
resource = "messages"
# is created
event = "created"
filter_ = ""
# insecure example secret used to generate the payload signature
secret = config.SPARK_WEBHOOK_SECRET
# Connect to SparkAPI with SPARK_TOKEN
spark_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_webhooks():\n client = RequestManager()\n client.set_method(\"POST\")\n client.set_endpoint(\"/projects/{0}/webhooks\".format(STORED_ID['project_id']))\n name = \"\".join(choices(string.ascii_letters, k=6))\n body = {\"webhook_url\": 'https://' + name, \"webhook_versio... | [
"0.7510101",
"0.71174085",
"0.6854709",
"0.66574806",
"0.6462748",
"0.6379622",
"0.6142991",
"0.61359745",
"0.6063905",
"0.604515",
"0.60279125",
"0.60028166",
"0.59783626",
"0.5958843",
"0.58807003",
"0.58486533",
"0.57544047",
"0.57061857",
"0.5696835",
"0.56884986",
"0.566... | 0.7444837 | 1 |
Find an active agent on the team and assign them to the room | def assign_team_member_to_customer_room(room, **room_args):
logging.log(logging.INFO, 'assign_team_member_to_customer_room')
# setup Spark API connection using SPARK_TOKEN
spark_api = ciscosparkapi.CiscoSparkAPI(access_token=config.SPARK_TOKEN)
person_ids_in_room = []
logging.log(logging.INFO, ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_team(self, agents_on_team):\n self.agents_on_team = agents_on_team",
"def registerTeam(self, agentsOnTeam):\n\n self.agentsOnTeam = agentsOnTeam",
"def assign_agents(particle,self):\n\n self.models[particle].state2agents(self.states[particle])\n\n return self.models[particle]",... | [
"0.5883716",
"0.582684",
"0.57222563",
"0.5710909",
"0.56679535",
"0.5631196",
"0.55353266",
"0.54998595",
"0.5459364",
"0.54566145",
"0.54290885",
"0.5423177",
"0.53831804",
"0.53805006",
"0.5376918",
"0.5325809",
"0.5302468",
"0.5296057",
"0.5238835",
"0.5231388",
"0.521540... | 0.64783984 | 0 |
Posts message to customer's Spark Room for customer_id using room_args. Room/Webhook will be created if necessary. | def customer_room_message_send(customer_id, **room_args):
# Basic sanity checking
if 'text' not in room_args and 'markup' not in room_args and 'files' not in room_args:
raise PassedParametersError("Must specify at least one of text/markup/files")
# setup Spark API connection using SPARK_TOKEN
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_new_signup(spark_api, customer_id, team_id, message_from_customer, webhook_url):\n\n # Send message via tropo\n message = \"Thanks for signing up! To get in touch, reply to this message or call this number during business hours.\"\n tropo.send_sms(customer_id[-10:], message)\n\n # Fetch al... | [
"0.59380233",
"0.56253624",
"0.5252518",
"0.5224164",
"0.51958823",
"0.5193579",
"0.50124633",
"0.50122374",
"0.49953628",
"0.49653572",
"0.49550867",
"0.49480957",
"0.4946862",
"0.49219984",
"0.48729196",
"0.48683706",
"0.48597386",
"0.48506933",
"0.48418263",
"0.48284423",
... | 0.7371444 | 0 |
Check if given room belongs to customer_id. Looks at last 10 characters of each | def is_customers_room(room, customer_id):
room_last_10 = room.title[-10:]
customer_id_last10 = customer_id[-10:]
if room_last_10 == customer_id_last10:
return True
logging.log(logging.INFO, "NO MATCH for %s %s " % (room_last_10, customer_id_last10))
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_room(r_l, out, char_bud):\n if r_l == \"R\":\n if len(out) + len(sentence[\"tokens\"][counter_r][0]) < char_bud:\n return True\n else:\n return False\n if r_l == \"L\":\n if len(out) + len(sentence[\"tokens\"][counter_l][0]) < cha... | [
"0.5715806",
"0.56134945",
"0.5574621",
"0.5250753",
"0.5223137",
"0.5128236",
"0.5072222",
"0.506887",
"0.505743",
"0.4931521",
"0.4929062",
"0.4925988",
"0.4905181",
"0.48851773",
"0.47877455",
"0.47873718",
"0.4782352",
"0.47482577",
"0.47185382",
"0.4704556",
"0.46382764"... | 0.8444396 | 0 |
we should take user token and path id and create assoc betweeb user and his password | def create_user_path_assoc():
if not check_content_type():
return jsonify(status=CONTENT_TYPE_ERROR)
reqdata = request.json
if not check_token(reqdata["token"]):
return jsonify(status=TOKEN_ERROR)
#TODO check that request body contain needed data
#if ["user_id", "path_id", "ready", "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate():\n try:\n body = request.get_json()\n\n activate_token = body[\"activate_token\"]\n password = body[\"password\"]\n\n if len(password) < 3 or len(password) > 50:\n return bad_request()\n\n if not models.token_exists(activate_token):\n\n ret... | [
"0.62621117",
"0.62346333",
"0.61671156",
"0.61413085",
"0.61245376",
"0.6083655",
"0.6033242",
"0.6020575",
"0.59848195",
"0.5967562",
"0.59649783",
"0.59640026",
"0.59355044",
"0.5934715",
"0.5880868",
"0.5853217",
"0.58479744",
"0.584258",
"0.5823585",
"0.58147603",
"0.581... | 0.6367729 | 0 |
here we should take user token and return all his paths | def return_array_of_user_paths():
if not check_content_type():
return jsonify(status=CONTENT_TYPE_ERROR)
reqdata = request.json
if not check_token(reqdata["token"]):
return jsonify(status=TOKEN_ERROR)
user = db.session.query(User).get_or_404(reqdata["id"])
print(user.paths[0].path.ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UserToken(self) -> object:",
"def getAllSocialPaths(self, userID):\n visited = {} # Note that this is a dictionary, not a set\n # !!!! IMPLEMENT ME\n pass",
"def get_all_access():\n\t# Get the email from the user making the request\n\temail = get_jwt_identity()\n\treturn get_all_acces... | [
"0.58251524",
"0.5674125",
"0.5542355",
"0.5537274",
"0.54388803",
"0.54378325",
"0.5408396",
"0.54047626",
"0.5392191",
"0.5388384",
"0.533989",
"0.5315466",
"0.53092307",
"0.5298692",
"0.52615076",
"0.5257217",
"0.52303827",
"0.52263474",
"0.5226098",
"0.522373",
"0.5207918... | 0.60975367 | 0 |
here we should take user token and delete his path | def delete_user_path_assoc():
#TODO delete user path assoc
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user():",
"def delete_user():\n #TODO user delete\n pass",
"def delete_user():\n del globalopts.appdata[request.user]\n del globalopts.users[request.user]\n return \"\", 200",
"def deauth(request):\n\n if(request.token):\n request.token.delete()\n return JsonResponse({'messag... | [
"0.6992621",
"0.66495234",
"0.6613394",
"0.65799147",
"0.6460222",
"0.64533365",
"0.6449197",
"0.64322025",
"0.64186275",
"0.6408798",
"0.64074534",
"0.6357774",
"0.63450295",
"0.63366646",
"0.63124985",
"0.629666",
"0.6272013",
"0.622002",
"0.6215148",
"0.61695504",
"0.61331... | 0.69666207 | 1 |
return true in case if http contenttype header application/json | def check_content_type():
return request.content_type == "application/json" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_json(self):\n mt = self.mimetype or self.headers.get('Accept')\n if not mt:\n return False\n if 'application/json' in mt:\n return True\n if mt.startswith('application/') and mt.endswith('+json'):\n return True\n return False",
"def is_json(request: HttpRequest):\n c... | [
"0.8645014",
"0.82041943",
"0.779997",
"0.7696868",
"0.76209074",
"0.6923115",
"0.6919368",
"0.6727148",
"0.6703706",
"0.6674128",
"0.66583306",
"0.6607934",
"0.65860164",
"0.6428396",
"0.6419199",
"0.6374357",
"0.632561",
"0.63124114",
"0.6275513",
"0.6273118",
"0.6266922",
... | 0.8678554 | 0 |
insert a new reservation into the reservation table | def insert_reservation(house, id, check_in_date, check_in_time, check_out_date, guest_name,
guest_cell, guest_telegram, num_guest, comment, confirm):
sql = """INSERT INTO %s VALUES(%s, '%s', '%s', '%s', '%s', '%s', '%s', %s, '%s', %s) RETURNING reservation_id;"""
conn = None
reservati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SaveToPeopleSQL(self, reservationid, humanid):\n cursor = self.cursor\n\n selector = '''\n insert into dbo.[people] ([reservationid], [humanid])\n values (?,?)\n '''\n\n values = (reservationid, humanid)\n cursor.execute(selector, values)",
"def create_n... | [
"0.6577621",
"0.6466516",
"0.6437117",
"0.638199",
"0.63248324",
"0.6276918",
"0.62141246",
"0.6211627",
"0.61856735",
"0.604802",
"0.6041068",
"0.60130626",
"0.59944504",
"0.59232014",
"0.5874383",
"0.58662474",
"0.5826088",
"0.5755627",
"0.5755627",
"0.5755627",
"0.5724426"... | 0.6811607 | 0 |
Build options for parsing language types. | def build_lang_options(parser):
langs = OptionGroup(parser, "File type options",
("Use this options to select file types you'd like to process.\n"
"Use --help-types option to output all available file types."))
for ftype in TYPES():
langs.add_option('--%s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_options(self, options):\n pass",
"def ParseOptions(cls, options, config_object):",
"def options(self, parser, env):\n pass",
"def add_parse_options(cls, parser):\n # Decoder params\n parser.add_argument(\"-beam_size\", default=1, type=int, help=\"Beam size\")\n pa... | [
"0.56313854",
"0.55033135",
"0.549861",
"0.5472193",
"0.5451628",
"0.544645",
"0.543898",
"0.543763",
"0.54214746",
"0.5410095",
"0.5380468",
"0.5370253",
"0.5363826",
"0.5360438",
"0.53587586",
"0.5352318",
"0.5351205",
"0.5351205",
"0.5342864",
"0.5329086",
"0.53279406",
... | 0.75984526 | 0 |
Search and replace patterns in file. If backup setting is on then for each modified file create unique backup file with .FILENAME.XXX~ there XXX is numeral suffix | def search_replace(path, f):
base, name = os.path.split(path)
while True:
tmp_path = '%s.%s.sr~' % (path, str(time.time()).replace('.', ''))
if not os.path.exists(tmp_path):
break
data = f.read()
if search_line(data):
print path
if config.explain:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file_replace(path, args):\n try:\n fisier = open(path, 'r')\n except IOError:\n print(\"Nu am putut deschide fisierul :\", path)\n return\n full_data = fisier.read()\n fisier.close()\n\n try:\n fisier = open(path, \"w+\")\n except IOError:\n print(\"Nu... | [
"0.6075093",
"0.58167344",
"0.57572097",
"0.57559025",
"0.57524633",
"0.5682571",
"0.56750935",
"0.5581424",
"0.5558917",
"0.54431474",
"0.5407974",
"0.53983253",
"0.5390096",
"0.53896135",
"0.53821135",
"0.53563595",
"0.5337024",
"0.53308517",
"0.5323081",
"0.53059065",
"0.5... | 0.614383 | 0 |
Determine if fname is backup file name. | def isbackup(fname):
return bool(BACKUP_RE.search(fname)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_backuped_file(file_name):\n return str(file_name).endswith(BACKUPED_FILES)",
"def check_base_filename(self, record):\n time_tuple = time.localtime()\n\n if self.file_name_format:\n pass\n\n if self.suffix_time != time.strftime(self.suffix, time_tuple) or not os.path.exis... | [
"0.7815696",
"0.6688547",
"0.64778984",
"0.6264358",
"0.62476087",
"0.61512923",
"0.60459733",
"0.5963137",
"0.59307975",
"0.5864477",
"0.57959646",
"0.5760985",
"0.57010245",
"0.5660149",
"0.5625667",
"0.5619978",
"0.56119597",
"0.5611512",
"0.55985445",
"0.55823183",
"0.558... | 0.83070534 | 0 |
Create a `TerminalController` and initialize its attributes with appropriate values for the current terminal. `term_stream` is the stream that will be used for terminal output; if this stream is not a tty, then the terminal is assumed to be a dumb terminal (i.e., have no capabilities). | def __init__(self, term_stream=sys.stdout):
try:
import curses
curses.setupterm()
except:
return
if not term_stream.isatty():
return
# Look up string capabilities.
for capability in self._STRING_CAPABILITIES:
(attrib,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def terminal_init(self):\n pass",
"def __init__(self, stream):\n if stream.isatty():\n pass\n else:\n raise TypeError(\"Stream must be TTY (sys.stdout, sys.stderr)\")\n \n self._BS = \"\\x08\"\n self._SP = \" \"\n self._last_width = 0\n ... | [
"0.59652",
"0.5615144",
"0.54912895",
"0.52887625",
"0.52851677",
"0.5223518",
"0.5165743",
"0.5147226",
"0.5071659",
"0.505962",
"0.5025898",
"0.48908564",
"0.48805162",
"0.48645216",
"0.48614362",
"0.4857036",
"0.48461643",
"0.4845205",
"0.48380554",
"0.48092356",
"0.480592... | 0.64451367 | 0 |
Display available file types | def display_file_types():
print 'Available file types. Each line contains the file type and the list of extensions by those the file type is determined. To include FOOBAR file type to search use --FOOBAR, to exlude use --noFOOBAR. You can include and exclude a number of file types.'
for ftype, extensions in TY... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_type_options():\n curr_type = global_settings.settings[menu_option]\n msg = \"\"\n for i in range(len(file_types)):\n if curr_type == file_types[i]:\n msg += str(i) + \" \" + file_types[i] + \" SELECTED\\n\"\n else:\n msg += str(i) + \" \" + file_types[i] +... | [
"0.7317718",
"0.71191174",
"0.70702636",
"0.70702636",
"0.67736834",
"0.6644009",
"0.6632094",
"0.6614344",
"0.65085596",
"0.64952815",
"0.6491149",
"0.6471447",
"0.6457224",
"0.63667023",
"0.6285033",
"0.6212446",
"0.6169332",
"0.61309534",
"0.61190706",
"0.6087771",
"0.6035... | 0.88249856 | 0 |
Compute the pointer to the word element index index from the base base. A word element has a size of 32bit. ``prt = base + 4index`` | def word_ptr(base, index):
return base + 4*index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def idx2off(i):\n return i * 32 - (24 * (i//4))",
"def bytes_to_index(lead, tail):\n lead_offset = 0x81 if lead < 0xA0 else 0xC1\n tail_offset = 0x40 if tail < 0x7F else 0x41\n return (lead - lead_offset) * 188 + tail - tail_offset",
"def get_base_index(self, base):\n num_bases = len(self.to... | [
"0.62375116",
"0.60986",
"0.6095896",
"0.5959151",
"0.58488744",
"0.5837316",
"0.57247674",
"0.57137364",
"0.5572218",
"0.5571219",
"0.55461186",
"0.55414087",
"0.55056304",
"0.5488403",
"0.5464307",
"0.54163104",
"0.54005605",
"0.53965604",
"0.5387477",
"0.5376323",
"0.53682... | 0.8458481 | 0 |
Seek to the table table. | def _seek_to_table(self, table):
self.stream.seek(self.table_pointers[table]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self):\n self.curr_table += 1\n\n if self.curr_table == self.numtables:\n raise StopIteration()\n else:\n return self.getTableByIndex(self.curr_table)",
"def _get_table(self, cursor):\n raise NotImplementedError",
"def getTableByIndex(self, index):\n ... | [
"0.6716625",
"0.6608818",
"0.6537215",
"0.6471446",
"0.6471446",
"0.61668456",
"0.6163812",
"0.6123178",
"0.60995656",
"0.6055506",
"0.5928246",
"0.59138536",
"0.5907426",
"0.58347434",
"0.5818251",
"0.58148175",
"0.57715636",
"0.5771209",
"0.57641464",
"0.5751659",
"0.573318... | 0.8310612 | 0 |
Return a pointer to the word element at index in the table table. | def _position_in_table(self, table, index):
return self.word_ptr(self.table_pointers[table], index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_ptr(base, index):\n\n return base + 4*index",
"def get_word_with_index(index):\n return reverse_word_index[index-3]",
"def word_from_id(self, idx: int) -> str:\n try:\n word = self.id2word[idx]\n except:\n raise KeyError(\"invalid index to get correspondin... | [
"0.71713465",
"0.6710033",
"0.647052",
"0.64275444",
"0.64000016",
"0.627637",
"0.6230234",
"0.620498",
"0.5997333",
"0.5994419",
"0.5897665",
"0.5840249",
"0.58399916",
"0.5783078",
"0.575517",
"0.5751453",
"0.5734819",
"0.5734819",
"0.5702223",
"0.5684829",
"0.5657467",
"... | 0.75631076 | 0 |
Return the fix word in table table at index index. | def _read_fix_word_in_table(self, table, index):
return self.stream.read_fix_word(self._position_in_table(table, index)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_word_with_index(index):\n return reverse_word_index[index-3]",
"def word_at(self, index, signed = False):\n return 0",
"def _position_in_table(self, table, index):\n\n return self.word_ptr(self.table_pointers[table], index)",
"def get_next_word(self, index, orignal=False):\n try:\... | [
"0.7023475",
"0.6607199",
"0.63332784",
"0.62407106",
"0.61667347",
"0.5965174",
"0.59546214",
"0.5891202",
"0.58116204",
"0.56669796",
"0.5634454",
"0.5632258",
"0.5579958",
"0.5555492",
"0.55403674",
"0.5468816",
"0.5456604",
"0.5415371",
"0.5396345",
"0.5366563",
"0.536528... | 0.8199197 | 0 |
Return the four numbers in table table at index index. | def _read_four_byte_numbers_in_table(self, table, index):
return self.stream.read_four_byte_numbers(self._position_in_table(table, index)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info(index, n):\n return index/n, index%n",
"def __get_row(self, index: int) -> int:\n return index // self.columns",
"def __get_column(self, index: int) -> int:\n return index % self.columns",
"def index(self) -> int:",
"def index2qindexb(self, index):\n r = index // 0x10\n... | [
"0.6256296",
"0.61769336",
"0.5994595",
"0.5719449",
"0.56975514",
"0.56891197",
"0.563756",
"0.5593905",
"0.558259",
"0.55777436",
"0.55777436",
"0.5575794",
"0.55332804",
"0.55188483",
"0.54888606",
"0.5472156",
"0.54072744",
"0.5406689",
"0.53736943",
"0.53688806",
"0.5360... | 0.75347275 | 0 |
Return the extensible recipe, four numbers, at index index. Extensible characters are specified by an extensible recipe, which consists of four bytes called top, mid, bot, and rep (in this order). These bytes are the character codes of individual pieces used to build up a large symbol. If top, mid, or bot are zero, the... | def _read_extensible_recipe(self, index):
return self._read_four_byte_numbers_in_table(tables.extensible_character, index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_extension_info(self, data, counter):\n try:\n if data[counter+47] == 11 or data[counter+50:counter+53] == b\"\\x0e\\xac\\x0b\" or data[82:85] == b\"\\x0f\\xf0\\x0b\":\n return \"|||\"\n\n count = 49 + counter\n length = int.from_bytes(data[counter... | [
"0.5214011",
"0.49292856",
"0.47483248",
"0.46619806",
"0.4635413",
"0.44699928",
"0.44410896",
"0.4437927",
"0.44217527",
"0.43964815",
"0.43601838",
"0.43417162",
"0.4337935",
"0.43295974",
"0.43120626",
"0.43041757",
"0.4291322",
"0.42824116",
"0.42597744",
"0.42349783",
"... | 0.76511264 | 0 |
The final portion of a TFM fie is the param array, which is another sequence of fix word values. param[1] = ``slant`` is the amount of italic slant, which is used to help position accents. For example, slant = .25 means that when you go up one unit, you also go .25 units to the right. The slant is a pure number; it's t... | def _read_font_parameters(self):
stream = self.stream
self._seek_to_table(tables.font_parameter)
if self.tfm.character_coding_scheme == 'TeX math italic':
# undocumented in tftopl web
pass
else:
# Read the seven fix word parameters
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doParametersOfInterest(self):\r\n if self.fg4fixed:\r\n self.modelBuilder.doVar(\"CMS_zz4l_fg4[0]\")\r\n self.modelBuilder.doVar(\"r[1,0,4]\")\r\n print \"Fixing CMS_zz4l_fg4\"\r\n poi = \"r\"\r\n else:\r\n if self.modelBuilder.out.var(\"CMS_... | [
"0.5400104",
"0.5254214",
"0.5206212",
"0.520376",
"0.5155425",
"0.5094093",
"0.5069205",
"0.5046871",
"0.50354075",
"0.5022196",
"0.49847862",
"0.49655205",
"0.49636424",
"0.4954346",
"0.4911089",
"0.48956797",
"0.48862684",
"0.48778197",
"0.48648793",
"0.4850119",
"0.484206... | 0.5571183 | 0 |
The lig kern array contains instructions in a simple programming language that explains what to do for special letter pairs. Each word is a lig kern command of four bytes. | def _read_lig_kern_programs(self):
# print 'Lig/Kern Table'
# Fixme: complete special cases
# Read very first instruction of the table
(first_skip_byte,
next_char,
op_byte,
remainder) = self._read_four_byte_numbers_in_table(tables.lig_kern, 0)
if fir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singleglyph(x):\n return [glyph(x)]",
"def init_kern(num_pitches, lengthscale, energy, frequency):\n\n kern_act = init_kern_act(num_pitches)\n kern_com = init_kern_com(num_pitches, lengthscale, energy, frequency)\n kern = [kern_act, kern_com]\n return kern",
"def on_hot_lower(self,splitted_w... | [
"0.52664185",
"0.52324265",
"0.5190644",
"0.49902183",
"0.49524304",
"0.48243922",
"0.4799325",
"0.4796385",
"0.4771531",
"0.47566155",
"0.47562125",
"0.47500035",
"0.47483367",
"0.47292683",
"0.47266775",
"0.47224197",
"0.4721936",
"0.4693159",
"0.46886936",
"0.46700308",
"0... | 0.6828259 | 0 |
Process the character code c in the character information table. | def _process_char(self, c):
width_index, height_index, depth_index, italic_index, tag, remainder = self._read_char_info(
c)
# Get the parameters in the corresponding tables
if width_index != 0:
width = self._read_fix_word_in_table(tables.width, width_index)
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_char(self, char):\n for key, pattern in self.char_map.items():\n if char in pattern:\n return key\n return 'U'",
"def _charToIndex(self,ch): \n return self.char_dict[ch]",
"def getChar(self,code):\r\n return chr(code)",
"def process_chara... | [
"0.60199857",
"0.5995649",
"0.5895552",
"0.5874629",
"0.5780173",
"0.57260835",
"0.57081205",
"0.5705879",
"0.5598203",
"0.5580874",
"0.554651",
"0.5473547",
"0.54209983",
"0.5418408",
"0.5327699",
"0.5319574",
"0.53130203",
"0.53003746",
"0.5280291",
"0.5277612",
"0.5248423"... | 0.7244657 | 0 |
Read the character code c data in the character information table. | def _read_char_info(self, c):
index = c - self.smallest_character_code
bytes = self._read_four_byte_numbers_in_table(
tables.character_info, index)
width_index = bytes[0]
height_index = bytes[1] >> 4
depth_index = bytes[1] & 0xF
italic_index = bytes[2] >> 6
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_characters(self):\n\n # Read the character information table\n for c in range(self.smallest_character_code, self.largest_character_code + 1):\n self._process_char(c)",
"def test_read_c(self):\n self._test_read(self.encoding_c, self.hashing_algorithm_c,\n ... | [
"0.6755259",
"0.63797873",
"0.6293932",
"0.62920505",
"0.6089438",
"0.6071494",
"0.602174",
"0.6018201",
"0.59013844",
"0.5839739",
"0.5755356",
"0.57003623",
"0.549275",
"0.54288435",
"0.54024756",
"0.5398537",
"0.53903955",
"0.537822",
"0.5324148",
"0.5303587",
"0.5300114",... | 0.7199772 | 0 |
Returns a generator for delimiterseparated combinations of the strings from `strings`. The combination sizes range from `min_parts` to the smaller of `max_parts` (if it is not `None`) and the number of items in `strings`. | def combine_strings(
strings: Iterable[str],
delimiter: str = " ",
min_parts: int = 0,
max_parts: int = None,
) -> Generator[str, None, None]:
min_parts = 0 if min_parts is None else min_parts
if min_parts < 0:
raise ValueError("min_parts cannot be negative.")
if max_parts is not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bruteforce(strip, min_length, max_length):\n return (''.join(char) for char in chain.from_iterable(product(strip, repeat=x)\n for x in range(min_length, max_length+1)))",
"def _tokens_partitions(tokens, min_number_of_tokens, number_of_partitions):\n... | [
"0.5976369",
"0.5884152",
"0.561761",
"0.5489877",
"0.5373369",
"0.5336096",
"0.5319506",
"0.53185827",
"0.5291077",
"0.52784747",
"0.523727",
"0.5198446",
"0.5193889",
"0.5150338",
"0.514983",
"0.5130469",
"0.51253945",
"0.509443",
"0.50677395",
"0.50625944",
"0.50609386",
... | 0.8301148 | 0 |
Returns a generator for the lines in a file. All trailing spaces and newlines are removed from each read line. The parameter `file_path` is the path to a text file for which the lines are to be fetched from. | def read_lines(file_path: str) -> Generator[str, None, None]:
with open(file_path) as f:
for line in f:
yield line.rstrip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_text_file(file_path):\n with open(file_path, 'r') as f:\n for line in f:\n line = line.rstrip()\n if not line:\n continue\n yield line",
"def readfile(path: str):\n with open(path) as file:\n for line in file.readlines():\n ... | [
"0.7864164",
"0.7831481",
"0.7813181",
"0.7415857",
"0.73461574",
"0.73056495",
"0.70490074",
"0.70286083",
"0.70038885",
"0.6995738",
"0.69923013",
"0.6933258",
"0.68956476",
"0.6863389",
"0.6857514",
"0.6850605",
"0.67782885",
"0.6752518",
"0.67178637",
"0.6717156",
"0.6702... | 0.8636409 | 0 |
Prints the `combination` string on its own line. This string is delimited by `delimiter`, preceded by the `prefix` string, and followed by the `postfix` string. | def print_combination(
combination: str, delimiter: str = " ", prefix: str = None, postfix: str = None
) -> None:
if prefix is not None:
print(prefix, end=delimiter)
print(combination, end="")
if postfix is not None:
print(delimiter if len(combination) > 0 else "", end=postfix)
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(\n file_path: str,\n delimiter: str = \" \",\n prefix: str = None,\n postfix: str = None,\n min_parts: int = 0,\n max_parts: int = None,\n) -> None:\n lines = read_lines(file_path)\n lines_with_text = (line for line in lines if len(line) > 0)\n line_combinations = combine_string... | [
"0.6388247",
"0.5657468",
"0.48115373",
"0.46865362",
"0.46651104",
"0.46057737",
"0.46045065",
"0.45726445",
"0.4551462",
"0.451783",
"0.45060995",
"0.44773766",
"0.44678497",
"0.4443884",
"0.44389498",
"0.44321448",
"0.44154876",
"0.44086614",
"0.44011688",
"0.43997845",
"0... | 0.84563273 | 0 |
Runs the program. The parameter `file_path` is the path to the file which is to be read. The `delimiter` argument specifies which delimiter to use to separate the output strings. The parameters `prefix` and `postfix` are optional strings appended and prepended to the output lines. The `min_parts` parameter specifies th... | def main(
file_path: str,
delimiter: str = " ",
prefix: str = None,
postfix: str = None,
min_parts: int = 0,
max_parts: int = None,
) -> None:
lines = read_lines(file_path)
lines_with_text = (line for line in lines if len(line) > 0)
line_combinations = combine_strings(
lines_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def console_start(\n file_path: str,\n delimiter: str,\n prefix: str,\n postfix: str,\n min_parts: int,\n max_parts: int,\n) -> None:\n import sys\n\n error_message = None\n try:\n main(\n file_path,\n delimiter=delimiter,\n prefix=prefix,\n ... | [
"0.66171956",
"0.5419413",
"0.50911546",
"0.5056001",
"0.48763207",
"0.48553953",
"0.46703777",
"0.46060747",
"0.45071557",
"0.44918415",
"0.44612107",
"0.4441966",
"0.44117573",
"0.44062215",
"0.43964303",
"0.43940163",
"0.43858075",
"0.4366964",
"0.43627298",
"0.43624535",
... | 0.7501073 | 0 |
check if exchange rates exist for all Price List currencies (to company's currency) | def validate_exchange_rates_exist(self):
company_currency = frappe.db.get_value("Company", self.company, "default_currency")
if not company_currency:
msgprint(_("Please specify currency in Company") + ": " + self.company,
raise_exception=ShoppingCartSetupError)
price_list_currency_map = frappe.db.get_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getActiveCurrencies():",
"def getCurrencies():",
"def update_all_currencies():\n rates_to_update = []\n rates_to_create = []\n for currency in settings.ALLOWED_CURRENCIES:\n try:\n rate = update_currency_data_from_rss(currency, commit=False)\n if rate.id is None:\n ... | [
"0.71018636",
"0.66748184",
"0.6629021",
"0.6588203",
"0.6566872",
"0.6488751",
"0.6484487",
"0.64375925",
"0.6365472",
"0.63330144",
"0.62951094",
"0.629225",
"0.6266622",
"0.6142166",
"0.6140089",
"0.6060332",
"0.60507655",
"0.60332155",
"0.6025823",
"0.6020183",
"0.5985447... | 0.84533095 | 0 |
Function to model the price of a European Option, under the BlackScholes pricing model heuristic, using an antithetic variates method variancereduced MonteCarlo simulation. This function simulates two perfectly negatively correlated simple Geometric Brownian Motion (GBM) processes of the underlying asset price, before ... | def blackScholes(current: float, volatility: float, ttm: float, strike: float,
rf: float, dividend: float, sim_count: int, eval_count: int,
opt_type: str='C', **kwargs) -> dict:
# Verify option choice
if opt_type not in ['C', 'P']:
raise ValueError('Incorrect option ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare(numberOfSimulations, initialValue, sigma, T, strike, r = 0):\n \n numberOfTests = 100\n \n \n #the two lists that will contain our average errors for the different tests\n errorsStandardMonteCarlo = []\n errorsMonteCarloWithAV = []\n \n #our benchmark: the analytic price ... | [
"0.66519797",
"0.60911804",
"0.60525775",
"0.5962542",
"0.58621377",
"0.58234996",
"0.5763114",
"0.5741226",
"0.567553",
"0.56474507",
"0.5644827",
"0.5632423",
"0.5624563",
"0.5607738",
"0.55745095",
"0.5509977",
"0.55045414",
"0.5465388",
"0.5444405",
"0.54173887",
"0.53988... | 0.6501072 | 1 |
Test get worker path. | def test_get_cf_worker_path(self):
os.environ['WORKER_ROOT_DIR'] = '/worker'
local_path = os.path.join(os.environ['ROOT_DIR'], 'a', 'b', 'c')
self.assertEqual(
file_host.rebase_to_worker_root(local_path), '/worker/a/b/c')
local_path = os.environ['ROOT_DIR']
self.assertEqual(file_host.rebas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_worker(self):\n worker_helper = WorkerHelper()\n worker_d = worker_helper.get_worker(ToyWorker, {'foo': 'bar'})\n worker = success_result_of(worker_d)\n self.assertIsInstance(worker, ToyWorker)\n self.assertIsInstance(worker._amqp_client, FakeAMQClient)\n self... | [
"0.65934354",
"0.6360944",
"0.62332517",
"0.59729254",
"0.5945865",
"0.5931231",
"0.58893883",
"0.58634233",
"0.58264047",
"0.5816103",
"0.57897335",
"0.57879317",
"0.5751385",
"0.57352287",
"0.56841",
"0.56825376",
"0.56722623",
"0.56704295",
"0.5656956",
"0.5656956",
"0.565... | 0.6835389 | 0 |
Scrape links of WBUR articles for a specified year | def scrape_article_links(year: int) -> List[str]:
# Take into considerations leap years and days when no articles are published
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_year_with_links():\n response = get_response(MAIN_PAGE)\n if response.ok:\n soup = BeautifulSoup(response.text, 'html.parser')\n years_li = soup.find_all(\n 'md-card-footer'\n )\n years_dict = {}\n # Not including the last <a> tag because that is not rele... | [
"0.71862036",
"0.71593505",
"0.7155051",
"0.6790815",
"0.6759994",
"0.67148083",
"0.66857797",
"0.65773827",
"0.65297294",
"0.65275764",
"0.650633",
"0.6365005",
"0.63623565",
"0.63112026",
"0.62049234",
"0.61433667",
"0.6139933",
"0.6039888",
"0.599428",
"0.59832263",
"0.598... | 0.8203429 | 0 |
Scrape contents of articles given the URLs | def scrape_articles(urls: List[str]) -> List[str]:
base_url = "https://www.wbur.org"
articles = []
for url in urls:
url = f"{base_url}{url}"
req = Request(url)
html_page = urlopen(req)
soup = BeautifulSoup(html_page, 'lxml')
paragraphs = soup.find_all('p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_content(soup: bs4.BeautifulSoup, keyword: str=\"\") -> dict:\n articles = {}\n urls = _filter_duplicate_urls(_get_urls(soup, keyword))\n for url in urls:\n try:\n response = requests.get(url)\n if response.status_code == 200:\n # Comment/Uncomment below... | [
"0.7043554",
"0.7042964",
"0.70412135",
"0.7004407",
"0.69894034",
"0.6858116",
"0.68372273",
"0.68079615",
"0.67389524",
"0.67154986",
"0.6683458",
"0.6680562",
"0.6663507",
"0.66628796",
"0.66282916",
"0.6562888",
"0.6555466",
"0.65241516",
"0.6505032",
"0.65037906",
"0.642... | 0.7597384 | 0 |
Creates and saves a csv file containing a single column for the scraped articles | def create_csv(articles: List[str], year: int) -> None:
df = pd.DataFrame({
'text': articles
})
df.to_csv(f"wbur{year}.csv") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_csv(companies):\n print(\"Saving companies.csv...\")\n\n Path(\"output\").mkdir(parents=True, exist_ok=True)\n file_name = 'output/companies.csv'\n\n with open(file_name, 'w', newline='') as csvfile:\n writer = csv.writer(csvfile, delimiter=',')\n i = 0\n while i < 500:\n ... | [
"0.6890485",
"0.6742668",
"0.65642285",
"0.65591663",
"0.6520742",
"0.6491834",
"0.6458035",
"0.64558274",
"0.64135855",
"0.6413078",
"0.6404125",
"0.63978297",
"0.6386491",
"0.6349512",
"0.63473815",
"0.63460076",
"0.633349",
"0.6327605",
"0.6324338",
"0.6314723",
"0.626726"... | 0.74493724 | 0 |
Extract fields from status to save to json. | def _map_status_fields(self, tweet):
data = {
# status
"date": tweet.created_at.strftime('%Y-%m-%d %H:%M:%S'),
"id": tweet.id_str,
"text": tweet.text,
"truncated": tweet.truncated,
"lang": tweet.lang,
# user
"user_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_status(self, status) -> None:\r\n if \"VehicleInfo\" in status:\r\n if \"RemoteHvacInfo\" in status[\"VehicleInfo\"]:\r\n self.hvac = status[\"VehicleInfo\"][\"RemoteHvacInfo\"]\r\n\r\n if \"ChargeInfo\" in status[\"VehicleInfo\"]:\r\n self.bat... | [
"0.6647689",
"0.6349667",
"0.60837454",
"0.6059531",
"0.6050074",
"0.5994271",
"0.59692353",
"0.59652483",
"0.59057873",
"0.59021086",
"0.58989656",
"0.5840351",
"0.5840351",
"0.5793476",
"0.57565075",
"0.567152",
"0.5638876",
"0.5635663",
"0.55974156",
"0.556527",
"0.5554442... | 0.6915547 | 0 |
Responsible for verifying techniques directory and generating techniques index markdown | def generate():
# Verify if directory exists
if not os.path.isdir(config.techniques_markdown_path):
os.mkdir(config.techniques_markdown_path)
#Write the technique index.html page
with open(os.path.join(config.techniques_markdown_path, "overview.md"), "w", encoding='utf8') as md_file:
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walkthrough(software_map):\n\n for i in software_map:\n\n if not i[\"is_file\"]:\n\n # for each directory: make a index.md\n dname = \"./docs/\" + i[\"name\"]\n index = \"./docs/\" + i[\"name\"] + \"/index.md\"\n print(index)\n os.mkdir(dname)\n\... | [
"0.58886623",
"0.58457476",
"0.57502025",
"0.5703051",
"0.56759125",
"0.56134313",
"0.5500864",
"0.5470556",
"0.5454886",
"0.5448571",
"0.5448571",
"0.54260826",
"0.54148185",
"0.54075974",
"0.53453696",
"0.53054494",
"0.5277186",
"0.52735656",
"0.5244364",
"0.5243433",
"0.52... | 0.7166579 | 0 |
Generate technique index markdown for each domain and generates shared data for techniques | def generate_domain_markdown(domain):
#Reads the STIX and creates a list of the ATT&CK Techniques
full_techniques = stixhelpers.get_techniques(config.ms[domain])
tactic_list = stixhelpers.get_tactic_list(config.ms[domain])
data = {}
technique_list = get_techniques_list(full_techniques)
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate():\n\n # Verify if directory exists\n if not os.path.isdir(config.techniques_markdown_path):\n os.mkdir(config.techniques_markdown_path)\n\n #Write the technique index.html page\n with open(os.path.join(config.techniques_markdown_path, \"overview.md\"), \"w\", encoding='utf8') as md... | [
"0.7529587",
"0.6753163",
"0.5811377",
"0.5526393",
"0.5446928",
"0.5422765",
"0.5422765",
"0.5392124",
"0.5317624",
"0.52876973",
"0.5264621",
"0.5209",
"0.52000964",
"0.5198834",
"0.5198507",
"0.5195234",
"0.51844853",
"0.5183828",
"0.51717633",
"0.5149823",
"0.5149334",
... | 0.69349456 | 1 |
Generetes markdown data for given technique | def generate_technique_md(technique, domain, side_menu_data, tactic_list):
attack_id = util.get_attack_id(technique)
# Only add technique if the attack id was found
if attack_id:
technique_dict = {}
technique_dict['attack_id'] = attack_id
technique_dict['domain'] = domain.split("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate():\n\n # Verify if directory exists\n if not os.path.isdir(config.techniques_markdown_path):\n os.mkdir(config.techniques_markdown_path)\n\n #Write the technique index.html page\n with open(os.path.join(config.techniques_markdown_path, \"overview.md\"), \"w\", encoding='utf8') as md... | [
"0.73341054",
"0.7133402",
"0.6663783",
"0.659057",
"0.6576931",
"0.63710845",
"0.62863004",
"0.6106517",
"0.60687923",
"0.60239404",
"0.5961844",
"0.5960654",
"0.5940064",
"0.5900538",
"0.5900436",
"0.5838119",
"0.5826031",
"0.58112127",
"0.57876456",
"0.5779548",
"0.5773856... | 0.73468506 | 0 |
Given a technique and a tactic list, return data of related techniques. Data includes technique id/name and tactic name/id for each related technique | def get_related_techniques_data(technique, tactic_list):
technique_data = []
if config.related_techniques.get(technique['id']):
for rel_tech in config.related_techniques[technique['id']]:
attack_id = util.get_attack_id(rel_tech['object'])
if attack_id:
row... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_examples_table_data(technique, reference_list, next_reference_number):\n\n # Creating map to avoid repeating the code 3 times\n examples_map = [\n { 'example_type': config.tools_using_technique }, \n { 'example_type': config.malware_using_technique },\n { 'example_type': config.g... | [
"0.6661438",
"0.6644859",
"0.66175026",
"0.6393515",
"0.6246491",
"0.61199707",
"0.60754085",
"0.5725204",
"0.5500558",
"0.5417878",
"0.533964",
"0.52860373",
"0.5199164",
"0.516859",
"0.51545167",
"0.49810523",
"0.4943632",
"0.48681778",
"0.48513177",
"0.48226207",
"0.478531... | 0.85353535 | 0 |
Given a technique a reference list, find mitigations that mitigate technique and return list with mitigation data. Also modifies the reference list if it finds a reference that is not on the list | def get_mitigations_table_data(technique, reference_list, next_reference_number):
mitigation_data = []
# Check if technique has mitigations
if config.technique_mitigated.get(technique['id']):
# Iterate through technique mitigations
for mitigation in config.technique_mitigated[technique['id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_techniques_used_by_malware():\n global techniques_used_by_malware\n \n if not techniques_used_by_malware:\n techniques_used_by_malware = rsh.techniques_used_by_malware(get_srcs())\n \n return techniques_used_by_malware",
"def get_mitigation_mitigates_techniques():\n global mitiga... | [
"0.6026351",
"0.59703493",
"0.58191",
"0.5710842",
"0.56594396",
"0.55248374",
"0.5523887",
"0.54103875",
"0.5382938",
"0.5350205",
"0.52979887",
"0.52793556",
"0.51606363",
"0.5085763",
"0.49043208",
"0.47701126",
"0.47418934",
"0.47043297",
"0.47007185",
"0.46617642",
"0.46... | 0.60934097 | 0 |
Given a technique object, find examples in malware using technique, tools using technique and groups using technique. Return list with example data | def get_examples_table_data(technique, reference_list, next_reference_number):
# Creating map to avoid repeating the code 3 times
examples_map = [
{ 'example_type': config.tools_using_technique },
{ 'example_type': config.malware_using_technique },
{ 'example_type': config.groups_using... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_techniques(db):\n\n techniques = []\n for element in db:\n for technique in element['techniques_used']:\n if technique not in techniques:\n techniques.append(technique)\n \n return sorted(techniques)",
"def get_techniques_used_by_groups():\n global techniqu... | [
"0.628506",
"0.62599236",
"0.6136026",
"0.60789555",
"0.5992689",
"0.5951035",
"0.5889614",
"0.5713279",
"0.563185",
"0.5599353",
"0.5587775",
"0.55412316",
"0.5538815",
"0.5419111",
"0.5401357",
"0.5392721",
"0.53859246",
"0.5369623",
"0.5243388",
"0.52172226",
"0.521398",
... | 0.659891 | 0 |
This method is used to generate a list of techniques | def get_techniques_list(techniques):
technique_list = {}
for technique in techniques:
if 'revoked' not in technique or technique['revoked'] == False:
attack_id = util.get_attack_id(technique)
if attack_id:
technique_dict = {}
technique_dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_techniques(db):\n\n techniques = []\n for element in db:\n for technique in element['techniques_used']:\n if technique not in techniques:\n techniques.append(technique)\n \n return sorted(techniques)",
"def techniques(self):\n return self._get_child_pag... | [
"0.6610979",
"0.6524354",
"0.62929714",
"0.61466",
"0.61216724",
"0.61157763",
"0.59929365",
"0.5992363",
"0.5967745",
"0.59375405",
"0.59261817",
"0.5862121",
"0.5525391",
"0.5521534",
"0.5519102",
"0.5513661",
"0.5487172",
"0.5474245",
"0.54732275",
"0.54732275",
"0.5459485... | 0.6863604 | 0 |
Given the technique's detection string, replace the citations and add them to the reference_list is they are not found. Return modified detection string | def get_detection_string(detection, reference_list, next_reference_number):
citations_from_descr = util.get_citations_from_descr(detection)
filtered_detection = util.replace_html_chars(markdown.markdown(detection))
filtered_detection = util.filter_urls(filtered_detection)
filtered_detection = util.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ref_tag_preprocess(inp_tag_text):\n\n # some words in references\n inp_tag_text = inp_tag_text.replace(\"до римлян\", \"Римл\")\n inp_tag_text = inp_tag_text.replace(\" и \", \"; \")\n inp_tag_text = inp_tag_text.replace(\" і \", \"; \")\n inp_tag_text = inp_tag_text.replace(\"–\", \"-\")\n #... | [
"0.5983218",
"0.5867871",
"0.5652614",
"0.558464",
"0.55107594",
"0.5485288",
"0.5324073",
"0.5307263",
"0.5304254",
"0.5300193",
"0.52907175",
"0.52869886",
"0.5280883",
"0.52644163",
"0.52494705",
"0.52478",
"0.5241941",
"0.5224906",
"0.5224906",
"0.52240586",
"0.52064675",... | 0.6253816 | 0 |
Patch django.request logger to ignore warnings. | def no_request_warning():
return patch_logger('django.request', 'warning', log_kwargs=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_logger(log, request):\n request.cls.log = log",
"def unpatch():\n _u(sanic.Sanic, \"handle_request\")\n if not SANIC_PRE_21:\n _u(sanic.Sanic, \"_run_request_middleware\")\n _u(sanic.request.Request, \"respond\")\n if not getattr(sanic, \"__datadog_patch\", False):\n retu... | [
"0.6512308",
"0.6345203",
"0.6293786",
"0.628367",
"0.6275584",
"0.62672555",
"0.623322",
"0.6210527",
"0.61037356",
"0.6073067",
"0.6044601",
"0.60088855",
"0.5969443",
"0.59051746",
"0.5904183",
"0.5851811",
"0.58263904",
"0.58186126",
"0.5768054",
"0.5733492",
"0.5733492",... | 0.85700905 | 0 |
xform from (c, r) to (lon, lat) | def composite(c, r):
x, y = gta * (c, r)
lat, lon = transform.TransformPoint(x, y)[:2]
if not -90 <= lat <= 90:
raise ValueError('illegal lat value, did you switch coordinates')
return lon, lat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cr2lonlat_for_geotif(path):\n old_cs, new_cs, gta, local_vars = _create_xform(path)\n transform = osr.CoordinateTransformation(old_cs, new_cs)\n\n def composite(c, r):\n \"\"\"xform from (c, r) to (lon, lat)\"\"\"\n x, y = gta * (c, r)\n lat, lon = transform.TransformPoint(x, y)[:... | [
"0.6946017",
"0.6875609",
"0.6777287",
"0.67524993",
"0.6716408",
"0.66537076",
"0.6602633",
"0.64604294",
"0.6418981",
"0.6406474",
"0.6382838",
"0.6360858",
"0.63093865",
"0.6304608",
"0.6299599",
"0.6263775",
"0.6230886",
"0.6198476",
"0.6191175",
"0.61556995",
"0.6152255"... | 0.7614783 | 0 |
Save straightened version of geotiff at `src_path` to `tgt_path`. | def create_straightened(src_path, tgt_path):
img = skio.imread(src_path)
straight_img, xform, angle = straighten_image(img)
save_geotiff(tgt_path, (straight_img * 255).astype('uint8'), xform) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveAsGeotiff(self, geotiff_fname, overwrite=True, verbose=False):\n if not overwrite and os.path.exists(geotiff_fname):\n raise ValueError('output geotiff already exists:\\n {}'.format(\n geotiff_fname))\n\n if overwrite and os.path.exists(geotiff_fname):\n ... | [
"0.6665498",
"0.6444286",
"0.59382063",
"0.5935782",
"0.5847079",
"0.5664643",
"0.56095916",
"0.54957837",
"0.5420205",
"0.5419931",
"0.53277814",
"0.5223335",
"0.51851106",
"0.5165319",
"0.5149921",
"0.51454896",
"0.51343054",
"0.5089744",
"0.50778294",
"0.50766367",
"0.5061... | 0.7338728 | 0 |
Save a raster image as a geotiff with associated transform | def save_geotiff(path, raster, xform):
# Import rasterio here, so that we don't need it in the cloud.
import rasterio
import affine
n_lats, n_lons, depth = raster.shape
assert raster.max() <= 255
assert raster.min() >= 0
profile = {
'crs': 'EPSG:4326',
'nodata': 0,
'dtype':... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_image(nom, image, _geo_trans):\n cols = image.shape[2]\n rows = image.shape[1]\n bands = image.shape[0]\n print(bands, cols, rows)\n driver = gdal.GetDriverByName(\"GTiff\")\n out_raster = driver.Create(nom, cols, rows, bands, gdal.GDT_Byte)\n # if (geo_trans):\n # outRaster.Se... | [
"0.748401",
"0.70260197",
"0.69436365",
"0.69406134",
"0.69158727",
"0.6690425",
"0.66588354",
"0.6629013",
"0.6620407",
"0.6539317",
"0.65314543",
"0.6381361",
"0.63328516",
"0.63243276",
"0.62995696",
"0.628616",
"0.6275659",
"0.61972815",
"0.6176187",
"0.61506325",
"0.6034... | 0.7922152 | 0 |
Fill in blank areas on the edges of images Applies a Gaussian kernel with width `sigma` to fill in the the first `sigma` width of unfilled points. Then apply a `2 sigma` width Gaussian to fill the next `2 sigma` width of unfilled points. Etc. | def fill(img, sigma=1, erosion=2):
img = img.copy()
img = skimage.img_as_float(img)
h, w, d = img.shape
assert d == 4, "image must be RGBA"
raw_mask = (img[:, :, 3] != 0)
if raw_mask.sum() == 0:
return img
mask = morphology.binary_erosion(raw_mask, selem=morphology.disk(erosion))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_kernel(size, sigma): \n \n kernel = np.zeros((size, size))\n\n #####################################\n # START YOUR CODE HERE #\n #####################################\n k = (size - 1) / 2\n sigma_sq = sigma ** 2\n pi_sigma = 1/(2 * np.pi * sigma_sq)\n for i in... | [
"0.61494803",
"0.60855705",
"0.5982485",
"0.5890864",
"0.58883697",
"0.5880866",
"0.586728",
"0.5848967",
"0.5832641",
"0.58226866",
"0.5791329",
"0.5754669",
"0.5750084",
"0.57419986",
"0.5730211",
"0.5723482",
"0.57178754",
"0.5703451",
"0.57008785",
"0.569052",
"0.56896883... | 0.71587646 | 0 |
Faster version of `fill` (usually) Try applying `fill` to only a `max_fill` area on the border of the image. If that is not enought to fully fill the border, fall back to default fill. In the latter case this will be slower than the base fill. | def fast_fill(img, sigma=1, erosion=2, max_fill=256):
h, w, d = img.shape
if (img[:, :, 3] != 0).sum() == 0:
return img
if min(h, w) <= 2 * max_fill:
return fill(img, sigma, erosion)
new = img.copy()
new[:max_fill] = fill(img[:max_fill], sigma, erosion)
new[-max_fill:] = fill(img... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_corners(input_image, fill_value=0, thresh=1, tol=None, fill_below_thresh=True):\n\n s = input_image.shape\n\n if (input_image[0, 0] < thresh) == fill_below_thresh:\n input_image = flood_fill(input_image, (0, 0), fill_value, tolerance=tol)\n if (input_image[-1, 0] < thresh) == fill_below_th... | [
"0.63137245",
"0.6278365",
"0.6200204",
"0.61978185",
"0.61965805",
"0.60700846",
"0.6059652",
"0.59688854",
"0.59662366",
"0.59070265",
"0.5903179",
"0.589714",
"0.588309",
"0.5854719",
"0.5853577",
"0.58095926",
"0.58064723",
"0.57960904",
"0.5779643",
"0.56925577",
"0.5673... | 0.7674791 | 0 |
Check if the Instana Agent is listening on and . | def is_agent_listening(self, host, port):
try:
rv = False
url = "http://%s:%s/" % (host, port)
response = self.client.get(url, timeout=0.8)
server_header = response.headers["Server"]
if server_header == AGENT_HEADER:
logger.debug("Host... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isListening(self):\n if not self.proxy:\n self.proxy = self.session.service(\"ALExpressiveListening\")\n return self.proxy.isListening()",
"def available(self):\n from pyhs3 import STATE_LISTENING\n return self._connection.api.state == STATE_LISTENING",
"def is_listen... | [
"0.69082576",
"0.6781381",
"0.67236483",
"0.66583073",
"0.6597917",
"0.65964216",
"0.6443436",
"0.64348936",
"0.63661027",
"0.62650263",
"0.61452365",
"0.6133517",
"0.607216",
"0.6067738",
"0.60436565",
"0.60321605",
"0.6028546",
"0.5990147",
"0.5979438",
"0.59621173",
"0.592... | 0.70526135 | 0 |
With the passed in Discovery class, attempt to announce to the host agent. | def announce(self, discovery):
try:
url = self.__discovery_url()
logger.debug("making announce request to %s", url)
response = None
response = self.client.put(url,
data=to_json(discovery),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def announce(self):\n self.notify(self.newAgent)\n if not self.agent.is_someone_subscribed():\n self.fail(cause=\"Noone Interested\")",
"def discovery(self, discovery):\n self._discovery = discovery",
"def discover(self):\n self.ola_thread.run_discovery(self.universe.get(), s... | [
"0.5947719",
"0.58452016",
"0.5585052",
"0.5345744",
"0.5330744",
"0.53060704",
"0.51516455",
"0.51401395",
"0.5137399",
"0.5128347",
"0.50388765",
"0.4961324",
"0.4937676",
"0.49360597",
"0.4907737",
"0.48760882",
"0.48737139",
"0.48590297",
"0.485389",
"0.48241162",
"0.4814... | 0.6446654 | 0 |
Used to report entity data (metrics & snapshot) to the host agent. | def report_data(self, entity_data):
try:
response = None
response = self.client.post(self.__data_url(),
data=to_json(entity_data),
headers={"Content-Type": "application/json"},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_agent_statistics(ctx):\n data = ctx.obj.get_agent_statistics()\n output_json_data(data)",
"def get_report(self):\n raise NotImplementedError('Agent is an abstract base class')",
"def send_metrics(self):\n metrics = self.get_metrics()\n if not metrics:\n return\n... | [
"0.61093044",
"0.6000067",
"0.5698678",
"0.565605",
"0.5642961",
"0.55764127",
"0.556718",
"0.55512047",
"0.5549297",
"0.55395067",
"0.55278474",
"0.5513736",
"0.54888225",
"0.5475359",
"0.54621094",
"0.5440199",
"0.5429361",
"0.54253405",
"0.5418064",
"0.5406231",
"0.5398051... | 0.6607751 | 0 |
URL for announcing to the host agent | def __discovery_url(self):
port = self.sensor.options.agent_port
if port == 0:
port = AGENT_DEFAULT_PORT
return "http://%s:%s/%s" % (self.host, port, AGENT_DISCOVERY_PATH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def href(self, request) -> str:\n raise NotImplementedError()",
"def arp_announce(self):\n pass",
"def url(vmanage_host,vmanage_port,api):\r\n \"\"\" function to get the url provide api endpoint \"\"\"\r\n \r\n return f\"https://{vmanage_host}:{vmanage_port}{api}\"",
"def href(self, re... | [
"0.58208126",
"0.56645566",
"0.55948234",
"0.55914885",
"0.5587822",
"0.5564786",
"0.55532277",
"0.551836",
"0.5515046",
"0.54996955",
"0.5453796",
"0.5452599",
"0.5382161",
"0.53463817",
"0.529863",
"0.5288116",
"0.5274814",
"0.52424526",
"0.5193244",
"0.51733655",
"0.515489... | 0.5997673 | 0 |
URL for posting traces to the host agent. Only valid when announced. | def __traces_url(self):
path = AGENT_TRACES_PATH % self.from_.pid
return "http://%s:%s/%s" % (self.host, self.port, path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _submit_url(self, request: Request) -> str:\n variables = [v.replace('/', '%2F') for v in request.variables]\n vars = ','.join(variables)\n return (\n f'https://{self.config.harmony_hostname}/{request.collection.id}'\n f'/ogc-api-coverages/1.0.0/collections/{vars}/cov... | [
"0.55625236",
"0.53895074",
"0.5079583",
"0.5004161",
"0.5003211",
"0.499963",
"0.4992628",
"0.49587142",
"0.49417904",
"0.49353853",
"0.49221927",
"0.49051777",
"0.48803085",
"0.48568583",
"0.48393092",
"0.48316365",
"0.48142818",
"0.47955108",
"0.4783378",
"0.4761256",
"0.4... | 0.75070876 | 0 |
Convert signed twotailed pvalues in tidy dataframe to two columns of onetailed pvalues. | def convert_to_one_tailed(longpvals):
higher_in_dis = longpvals[longpvals['p'] > 0].index
longpvals.loc[higher_in_dis, 'p-dis'] = longpvals.loc[higher_in_dis, 'p']/2
higher_in_h = longpvals[longpvals['p'] <= 0].index
longpvals.loc[higher_in_h, 'p-h'] = abs(longpvals.loc[higher_in_h, 'p']/2)
def p_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, dataframe: DataFrame) -> DataFrame:",
"def transform(self, df):\n temp = df.where(df >= self.df_med, -1)\n temp = temp.where(df <= self.df_med, 1).where(df != self.df_med, 0)\n return temp",
"def normalize_price_values(df):\r\n\r\n\tdf_normalize_dict = dict()\r\n\r\n\tf... | [
"0.5283908",
"0.5201904",
"0.50020725",
"0.5000971",
"0.4988177",
"0.49546647",
"0.49204186",
"0.49189258",
"0.48975918",
"0.48936588",
"0.48907062",
"0.48809013",
"0.48784265",
"0.48647115",
"0.4834164",
"0.48318642",
"0.4798001",
"0.47972462",
"0.4755715",
"0.47548717",
"0.... | 0.54419976 | 0 |
Update the lists that will produce the reproducibility dataframe | def update_reproducibility_df_lists(values, variables, metric_labels,
diseaselabels, newvalues, newvariables,
newmetric_label, newdisease_label):
values += newvalues
variables += newvariables
metric_labels += [newmetric_label]*len(newva... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_data(self):\n # take care of samples\n patients = self.samples.iloc[:,1].tolist()\n samples = self.samples.iloc[:,0].tolist()\n self.samples = pd.DataFrame(patients,index = samples,columns = ['patient']) # indexed by sample\n #\n # take care of expression data\n cols = self.expression... | [
"0.59460425",
"0.57309216",
"0.55985343",
"0.557751",
"0.5576779",
"0.5559483",
"0.55061835",
"0.550185",
"0.54883957",
"0.5453005",
"0.53934854",
"0.53604716",
"0.53446424",
"0.5336182",
"0.5329649",
"0.5324857",
"0.53203195",
"0.5312671",
"0.5301265",
"0.5289845",
"0.528326... | 0.7305929 | 0 |
Calculate "dysbiosis" metrics in various ways. Metrics can be diseasewise (i.e. one number per disease) or datasetwise (i.e. one number per dataset). There's also one genuswise metric. | def get_dysbiosis_metrics(diseases, datasets, df, pthresh, samplesizes,
overall=None):
# Keep only OTUs which were signficant in at least one study
# if x is zero, this returns zero (i.e. if there is no effect, it
# doesn't count as significant so don't worry)
sigmap = lambda ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dysbiosis_df(dfpvals, qthresh, samplesizes, overall, dfauc):\n ## Get the tidy dataframe with the \"dysbiosis\" metrics\n datasets = dfpvals.columns.tolist()\n diseases = list(set([i.split('_')[0] for i in datasets]))\n dysbiosis = get_dysbiosis_metrics(diseases, datasets, dfpvals, qthresh, sam... | [
"0.6015697",
"0.5291068",
"0.52776206",
"0.5251048",
"0.5233152",
"0.52106285",
"0.5177707",
"0.5171312",
"0.5145322",
"0.5121666",
"0.5097878",
"0.50963205",
"0.5074108",
"0.50674963",
"0.5050814",
"0.50436914",
"0.5038707",
"0.5038141",
"0.500424",
"0.4983577",
"0.4978",
... | 0.7558074 | 0 |
Calculates the dysbiosis dataframe from dfpvals, qthresh, samplesizes, and overall. Also appends results from classifiers (in dfauc) and returns tidy dataframe with all the metrics. | def get_dysbiosis_df(dfpvals, qthresh, samplesizes, overall, dfauc):
## Get the tidy dataframe with the "dysbiosis" metrics
datasets = dfpvals.columns.tolist()
diseases = list(set([i.split('_')[0] for i in datasets]))
dysbiosis = get_dysbiosis_metrics(diseases, datasets, dfpvals, qthresh, samplesizes, o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dysbiosis_metrics(diseases, datasets, df, pthresh, samplesizes,\n overall=None):\n\n # Keep only OTUs which were signficant in at least one study\n # if x is zero, this returns zero (i.e. if there is no effect, it\n # doesn't count as significant so don't worry)\n sigma... | [
"0.6998664",
"0.5498175",
"0.5398973",
"0.5380001",
"0.5380001",
"0.5376634",
"0.5368823",
"0.53660005",
"0.5334311",
"0.5332189",
"0.53077316",
"0.5301847",
"0.528861",
"0.52462155",
"0.5234512",
"0.5225775",
"0.5214241",
"0.52137834",
"0.51803124",
"0.51625824",
"0.5158908"... | 0.8481515 | 0 |
Get part of list past i position included. Return [] is list is shorter | def past_indice(l, i):
return l[i:] if i <= len(l) else [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice_(self, start, stop):\n \n sl = UnorderedList()\n \n current = self.head\n \n for i in range(min(stop, self.length())):\n if i >= start:\n sl.append(current.get_data())\n current = current.get_next()\n \n return s... | [
"0.6184768",
"0.601741",
"0.6012456",
"0.5956669",
"0.5904169",
"0.580093",
"0.57858896",
"0.56827193",
"0.5681486",
"0.5651482",
"0.5649691",
"0.5639707",
"0.56303376",
"0.56295496",
"0.5620146",
"0.561906",
"0.56130284",
"0.5602169",
"0.557603",
"0.55745345",
"0.5565249",
... | 0.7636868 | 0 |
Test that the "reset" command exits sandbox process. | def test_reset(u_boot_console):
u_boot_console.run_command('reset', wait_for_prompt=False)
assert(u_boot_console.validate_exited()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_destroy_exit_code(destroy_result: Result) -> None:\n assert destroy_result.exit_code == 0",
"def test_reset_confirmation_failure(self):\n self._create_program_and_course_enrollment(self.program_uuid, self.user)\n\n with pytest.raises(CommandError):\n with self._replace_stdin(... | [
"0.6778436",
"0.6716901",
"0.66181916",
"0.65129143",
"0.63427615",
"0.63267905",
"0.6321782",
"0.6269297",
"0.6232972",
"0.62284225",
"0.6225554",
"0.61808336",
"0.61801964",
"0.61580604",
"0.61489266",
"0.60723764",
"0.6021471",
"0.6014386",
"0.5961628",
"0.5912922",
"0.591... | 0.8134297 | 0 |
Modifies the osd df tree stats dictionary to include additional keys for better traversal | def update_stats_dict(stats_dict: dict) -> dict:
dict_copy = {}
for node in stats_dict["nodes"]:
if node["type"] == "osd":
dict_copy.update({node["id"]: node})
elif node["type"] == "host":
dict_copy.update({node["name"]: node})
dict_copy.update({"stray": stats_dict[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def improve_tree(tree, freq_dict):\n # todo",
"def get_stats(self):\n\t\n\tceph_cluster = \"%s-%s\" % (self.prefix, self.cluster)\n\n\tdata = { ceph_cluster: { } }\n\tadmin_folder=\"/var/run/ceph/\"\n\tif(os.path.isdir(admin_folder)):\n\t\tfiles=os.walk(admin_folder).next()[2]\n else:\n\t\tprint \"No f... | [
"0.61935604",
"0.6069216",
"0.6001222",
"0.576004",
"0.57425445",
"0.56485784",
"0.5601644",
"0.5563706",
"0.555342",
"0.5531584",
"0.539289",
"0.53479964",
"0.5272574",
"0.5258337",
"0.52559775",
"0.5252622",
"0.5247009",
"0.52317107",
"0.51732695",
"0.5172705",
"0.51663923"... | 0.6601258 | 0 |
Get user_hw_action list ordered by hw_action id desc. | async def get_user_hw_action_list(
request: Request,
user_id: object = None,
name=None,
limit: int = 0,
offset: int = 0) -> list:
ret_val = []
query_str = get_user_hw_action_list_query
try:
if limit > 0:
query_str += ' ORDER BY uhwa.id DESC LIMIT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_user_hw_action_dropdown_list(\n request: Request,\n user_id: object = None,\n name=None,\n limit: int = 0,\n offset: int = 0) -> list:\n ret_val = []\n\n query_str = get_user_hw_action_list_query\n\n try:\n if limit > 0:\n query_str += ' O... | [
"0.67384195",
"0.6622735",
"0.6605048",
"0.59234667",
"0.59082854",
"0.5831477",
"0.55603856",
"0.5509714",
"0.53983074",
"0.5274773",
"0.52493",
"0.52375597",
"0.52054816",
"0.5151684",
"0.5059717",
"0.501881",
"0.5018441",
"0.50154513",
"0.4879599",
"0.4847937",
"0.4837456"... | 0.7527538 | 0 |
Get user_hw_action list count. | async def get_user_hw_action_list_count(
request: Request,
user_id: object = None,
name=None) -> int:
ret_val = 0
query_str = get_user_hw_action_list_count_query
try:
async with request.app.pg.acquire() as connection:
row = await connection.fetchval(query_str, u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_actions():\n return 6",
"def get_number_of_actions(self):\n return self.__environment.action_space.n",
"def action_count(self):\n raise NotImplementedError",
"async def get_user_hw_action_list(\n request: Request,\n user_id: object = None,\n name=None,\n l... | [
"0.6756155",
"0.66021574",
"0.6536091",
"0.60807174",
"0.6020988",
"0.59411806",
"0.589664",
"0.58373946",
"0.5837161",
"0.5816002",
"0.5805106",
"0.5792135",
"0.5719951",
"0.57095796",
"0.5677916",
"0.56623185",
"0.56425726",
"0.5635936",
"0.55697066",
"0.55688494",
"0.55645... | 0.8094028 | 0 |
Get user_hw_action dropdown list. | async def get_user_hw_action_dropdown_list(
request: Request,
user_id: object = None,
name=None,
limit: int = 0,
offset: int = 0) -> list:
ret_val = []
query_str = get_user_hw_action_list_query
try:
if limit > 0:
query_str += ' ORDER BY uha.id DE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_user_hw_action_list(\n request: Request,\n user_id: object = None,\n name=None,\n limit: int = 0,\n offset: int = 0) -> list:\n ret_val = []\n\n query_str = get_user_hw_action_list_query\n\n try:\n if limit > 0:\n query_str += ' ORDER BY u... | [
"0.59505457",
"0.5507002",
"0.5401321",
"0.53395784",
"0.53354234",
"0.53100324",
"0.52825046",
"0.52602917",
"0.52471375",
"0.5244501",
"0.52289706",
"0.51792496",
"0.5178827",
"0.51756155",
"0.5133339",
"0.5132621",
"0.51210713",
"0.5054093",
"0.50498927",
"0.5021374",
"0.5... | 0.72873855 | 0 |
Get user_hw_action element by hw_action id. | async def get_user_hw_action_element(
request: Request,
user_id: object = None,
user_hw_action_id: int = 0) -> dict:
ret_val = {}
query_str = get_user_hw_action_element_query
try:
async with request.app.pg.acquire() as connection:
row = await connection.fetchrow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def update_user_hw_action_element(\n request: Request,\n user_hw_action_id: int = 0,\n user_id: object = None,\n hw_action_id: object = None,\n value: str = '',\n date_from: object = None,\n date_to: object = None,\n active: bool = True) -> dict:\n\n ... | [
"0.602205",
"0.59792584",
"0.59128565",
"0.58285356",
"0.57795525",
"0.57200396",
"0.5680287",
"0.5650404",
"0.5606802",
"0.55979854",
"0.55730385",
"0.55720365",
"0.54777026",
"0.5474907",
"0.5447135",
"0.5384388",
"0.5359117",
"0.5357769",
"0.5350716",
"0.5302518",
"0.52932... | 0.770337 | 0 |
Updated user hw action element. | async def update_user_hw_action_element(
request: Request,
user_hw_action_id: int = 0,
user_id: object = None,
hw_action_id: object = None,
value: str = '',
date_from: object = None,
date_to: object = None,
active: bool = True) -> dict:
ret_val = {}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Update(self, action, context):\n # type: (QtWidgets.QAction, MenuContext) -> None\n pass",
"def command_update_hw(self, cmd):\n # TODO\n pass",
"def user_update(user, action, change, data={}):\n return user, action, change()",
"def update_user():\n #TODO user update \n ... | [
"0.6150106",
"0.59626174",
"0.5933568",
"0.58857137",
"0.58615917",
"0.5740417",
"0.5662136",
"0.56096417",
"0.5524114",
"0.55016327",
"0.5501093",
"0.54874814",
"0.5487117",
"0.5476334",
"0.5474875",
"0.54568803",
"0.5452883",
"0.54350376",
"0.5420841",
"0.5420841",
"0.53956... | 0.663944 | 0 |
Delete user hw action location element | async def delete_user_hw_action_location_association(
request: Request,
user_hw_action_id: int = 0,
location_id: int = 0) -> dict:
ret_val = {}
query_str = delete_user_hw_action_location_element_query
try:
async with request.app.pg.acquire() as connection:
row =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_location(self, location_id):",
"def delete_testing_loc():\n\n user_id = session.get('user_id', None)\n test_id = request.form.get('test_id')\n del_testing_saved_locations(user_id, test_id)\n\n flash(\"Location removed!\")\n\n return jsonify(\"Success!\")",
"def destroy_unoccupied(requ... | [
"0.7080843",
"0.63735086",
"0.6227535",
"0.6211661",
"0.61750007",
"0.59836805",
"0.59447455",
"0.5835343",
"0.5828464",
"0.5793558",
"0.5763661",
"0.5722859",
"0.5694722",
"0.5685501",
"0.568324",
"0.56825525",
"0.56595117",
"0.56583446",
"0.56460756",
"0.56391454",
"0.56366... | 0.665624 | 1 |
Create user hw action location element | async def create_user_hw_action_location_element(
request: Request,
user_hw_action_id: int = 0,
location_id: int = 0) -> dict:
ret_val = {}
query_str = create_user_hw_action_location_element_query
try:
async with request.app.pg.acquire() as connection:
row = awa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_location(self, location):\n \"Does nothing\"",
"async def update_user_hw_action_location_element(\n request: Request,\n user_hw_action_id: int = 0,\n location_id: int = 0) -> dict:\n\n ret_val = {}\n\n try:\n\n user_hw_action_location = await get_user_hw_action... | [
"0.6501098",
"0.6049239",
"0.5852175",
"0.55307126",
"0.5457156",
"0.5445937",
"0.5387072",
"0.53646594",
"0.526601",
"0.5258049",
"0.524216",
"0.5242155",
"0.5239184",
"0.52304375",
"0.52004963",
"0.5198689",
"0.51953",
"0.519014",
"0.51771957",
"0.5176893",
"0.5176216",
"... | 0.6528975 | 0 |
Update user hw action location association. | async def update_user_hw_action_location_element(
request: Request,
user_hw_action_id: int = 0,
location_id: int = 0) -> dict:
ret_val = {}
try:
user_hw_action_location = await get_user_hw_action_location_element(
request, user_hw_action_id=user_hw_action_id, locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def delete_user_hw_action_location_association(\n request: Request,\n user_hw_action_id: int = 0,\n location_id: int = 0) -> dict:\n\n ret_val = {}\n query_str = delete_user_hw_action_location_element_query\n try:\n\n async with request.app.pg.acquire() as connection:\n ... | [
"0.5593399",
"0.54550964",
"0.54339",
"0.53970563",
"0.53875065",
"0.5344133",
"0.53124726",
"0.5286892",
"0.52606964",
"0.5176878",
"0.51755166",
"0.5131439",
"0.5119593",
"0.5117834",
"0.50947464",
"0.5019211",
"0.5009067",
"0.50087947",
"0.49611032",
"0.49488407",
"0.49445... | 0.67727256 | 0 |
Get list of all user hw action ids attached on location. TU SAM | async def get_attached_user_hw_action_id_list(
request: Request,
location_id: int = 0) -> []:
ret_val = []
query_str = get_attached_hw_action_id_list_for_location_query
try:
async with request.app.pg.acquire() as connection:
rows = await connection.fetch(query_str, loca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_user_hw_action_list_by_location_id(\n request: Request,\n user_id: object = None,\n location_id: int = 0) -> []:\n\n ret_val = []\n query_str = get_attached_user_hw_action_list_for_location_query\n try:\n\n async with request.app.pg.acquire() as connection:\n ... | [
"0.76256377",
"0.70122194",
"0.60559696",
"0.5912093",
"0.5893191",
"0.5842051",
"0.5704554",
"0.5671783",
"0.564515",
"0.56439936",
"0.5610305",
"0.5608252",
"0.5578609",
"0.55730045",
"0.54980344",
"0.54745597",
"0.5443029",
"0.54367554",
"0.54084855",
"0.53930837",
"0.5378... | 0.7853884 | 0 |
Delete user hw action list attached to location id. | async def delete_user_hw_action_list_by_location_id(
request: Request,
user_id: object = None,
location_id: int = 0) -> []:
ret_val = []
query_str = delete_attached_user_hw_action_list_for_location_query
try:
# print('THIS IS LOCATION ID: {}'.format(location_id))
att... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def delete_user_hw_action_location_association(\n request: Request,\n user_hw_action_id: int = 0,\n location_id: int = 0) -> dict:\n\n ret_val = {}\n query_str = delete_user_hw_action_location_element_query\n try:\n\n async with request.app.pg.acquire() as connection:\n ... | [
"0.67462575",
"0.66135746",
"0.63126004",
"0.6176471",
"0.6121506",
"0.60958934",
"0.591431",
"0.58870196",
"0.58680236",
"0.5824778",
"0.58092797",
"0.57698774",
"0.57125425",
"0.56117177",
"0.5607668",
"0.55849206",
"0.55827045",
"0.55230117",
"0.55137694",
"0.55057746",
"0... | 0.7934018 | 0 |
Random velocity as an integer Between 1050 pixels per second | def _randomVelocity(self):
return random.choice([-1, 1]) * random.randint(10, 50) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_velocity():\n vel_dir = np.random.random(2) * 2 - 1\n vel = vel_dir * np.random.randint(2, 6)\n vel = np.where(np.abs(vel) > 1, vel, (vel / vel) * 1).astype(np.float16)\n return vel",
"def getRandSpeed(self) -> int:\n num = int(random.uniform(-4,4))\n while(-1<=num and num<=1... | [
"0.7667083",
"0.7054428",
"0.67863053",
"0.66575736",
"0.66035014",
"0.6495527",
"0.6449711",
"0.6372023",
"0.63706774",
"0.6259101",
"0.6254404",
"0.6229643",
"0.61981577",
"0.6197165",
"0.6170514",
"0.61581373",
"0.61581373",
"0.6146865",
"0.61138713",
"0.60814106",
"0.6081... | 0.8211917 | 0 |
Define custom axis of the stats_kstest2 Ferret PyEF | def ferret_custom_axes(id):
axis_defs = [ None ] * pyferret.MAX_FERRET_NDIM
axis_defs[0] = ( 1, 2, 1, "KS,P", False )
return axis_defs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_axes(self):\n raise NotImplementedError()",
"def __init__(self, axis=-1):\n self.axis = axis",
"def getAxisValuesEvent(self): \n varID = self.myParent.getVar().id\n axisVar = MV2.array(self.axis)\n axisVar.setAxis(0, self.axis)\n axisVar.id = varID +... | [
"0.5768559",
"0.5655012",
"0.54957694",
"0.5450697",
"0.54254967",
"0.54239786",
"0.534711",
"0.53141004",
"0.53086776",
"0.5305469",
"0.5283433",
"0.5283112",
"0.52304465",
"0.5202986",
"0.5171157",
"0.5163523",
"0.5158583",
"0.5118967",
"0.5083052",
"0.508089",
"0.50685585"... | 0.6452346 | 0 |
Returns the nth term of the numbers that can be arranged as symmetric cube shapes [1, 8, 27, 64] | def cube(n):
result = [num*num*num for num in range(n)]
return result[1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube(n):\n return n**3",
"def six_cubed():\n print(math.pow(6,3))",
"def six_cubed():\n print(math.pow(6, 3))",
"def cube(num):\n return num ** 3",
"def collatz(n):\n if n%2==0: return n/2\n else: return 3*n+1",
"def cube(x):\n return x ** 3",
"def cube(x):\n return x ** 3",... | [
"0.71186316",
"0.6480103",
"0.64490527",
"0.643903",
"0.6316823",
"0.6301688",
"0.6301688",
"0.61822426",
"0.61690825",
"0.6110071",
"0.6092846",
"0.6074926",
"0.60742134",
"0.6055168",
"0.603976",
"0.6007538",
"0.5919181",
"0.5917835",
"0.5869493",
"0.5855652",
"0.58506876",... | 0.66809696 | 1 |
Add the the self.scn_line_list variable the command for the utilization of the INIT testbench command. | def DATA_CHECKER_INIT(self, alias, index, file_path):
line_to_print = "DATA_CHECKER[{0}] INIT({1}, {2})".format(alias, index, file_path)
self.scn_line_list.append(line_to_print) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, scn_line_list):\n self.scn_line_list = scn_line_list",
"def at_cmdset_creation(self):\n self.add(Command())",
"def __init__(self, command_line: List[str]) -> None:\n self.command_line = list(command_line)",
"def __init__(self, command_list, ):\n self.command_lis... | [
"0.6523301",
"0.5951089",
"0.5943871",
"0.5942963",
"0.58159584",
"0.5575033",
"0.5569893",
"0.5569893",
"0.5542223",
"0.5503401",
"0.5458512",
"0.5442024",
"0.5420204",
"0.5397194",
"0.5389913",
"0.53692174",
"0.5357473",
"0.5353473",
"0.5312238",
"0.53019863",
"0.52967995",... | 0.614542 | 1 |
Add the the self.scn_line_list variable the command for the utilization of the CLOSE testbench command. | def DATA_CHECKER_CLOSE(self, alias, index):
line_to_print = "DATA_CHECKER[{0}] CLOSE({1})".format(alias, index)
self.scn_line_list.append(line_to_print) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_command( self, more_command_list ):\n print( f\"adding {more_command_list}\")\n if more_command_list is None: # perhaps was here to reinit to zero length ?? for now a do nothing\n pass\n #self.command_list = more_command_list # [ r\"D:\\apps\\Notepad++\\no... | [
"0.56938934",
"0.52051395",
"0.52051395",
"0.52051395",
"0.51754934",
"0.51447105",
"0.5140671",
"0.5131802",
"0.511744",
"0.5089544",
"0.50882906",
"0.50165707",
"0.50131583",
"0.4998877",
"0.4987812",
"0.4976306",
"0.49725762",
"0.4971059",
"0.49568474",
"0.4925168",
"0.492... | 0.57682115 | 0 |
whether or not str is quoted | def is_quoted(str):
return ((len(str) > 2)
and ((str[0] == "'" and str[-1] == "'")
or (str[0] == '"' and str[-1] == '"'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_quote(cls, char):\n return char in (\"'\", '\"')",
"def isquoted(token):\n\n # Token is quoted\n return token.startswith((\"'\", '\"')) and token.endswith((\"'\", '\"'))",
"def check_if_quotations(string):\n quote_found_double = False\n quote_found_single = False\n for i ... | [
"0.7705723",
"0.75687397",
"0.7266267",
"0.6991756",
"0.66225153",
"0.66030955",
"0.6500596",
"0.64395237",
"0.63842493",
"0.6379116",
"0.6355492",
"0.6355275",
"0.63462305",
"0.6330335",
"0.62957424",
"0.62409854",
"0.6199656",
"0.6188422",
"0.615714",
"0.61365765",
"0.61364... | 0.8505823 | 0 |
whether or not str is a URL argument | def is_url_arg(str):
return (True if URL_REGEX.match(str[1:-1] if is_quoted(str) else str)
else False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_url(string):\n return \"http\" in string",
"def __isUrl(self, url):\n if type(url)==str:\n return url.startswith('http://') or url.startswith('https://')\n return False",
"def is_url(string):\n try:\n urlparse(string)\n return True\n except:\n retu... | [
"0.7797083",
"0.75735813",
"0.73908395",
"0.7226459",
"0.68933237",
"0.6872319",
"0.6832194",
"0.68077755",
"0.6775221",
"0.67085016",
"0.67078424",
"0.6691067",
"0.6662707",
"0.6633087",
"0.65910274",
"0.65551054",
"0.6544095",
"0.6522813",
"0.649989",
"0.6471646",
"0.646380... | 0.8336535 | 0 |
Parses the Dockerfile which is referenced in f, invoking the appropriate methods in delegate | def parse_dockerfile_with_delegate(fp, delegate):
mline = False
line = ''
for line0 in fp.read().splitlines():
# Skip next instruction
if AWS_SKIP_REGEX.match(line0):
delegate.run_skip()
continue
# Skip empty lines and comments
elif COMMENT_REGEX.mat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_dockerfile_for_args(target):\n import colorama\n build_args = {}\n missing_args = {}\n empty_string = \"\"\n\n # read dockerfile for args that have no value\n try:\n with open(target + '/Dockerfile') as dockerfile:\n for line in dockerfile:\n if line.star... | [
"0.59220093",
"0.55810225",
"0.5559459",
"0.543682",
"0.53771085",
"0.5376819",
"0.5280178",
"0.5260183",
"0.5223538",
"0.52198106",
"0.519638",
"0.51916337",
"0.51782244",
"0.51778024",
"0.5171943",
"0.5130877",
"0.5123142",
"0.509146",
"0.5081681",
"0.5074057",
"0.5073434",... | 0.73493445 | 0 |
Invoked when the ENV variable key is assigned value | def run_env(self, key, value):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, key, item):\n super(EnvironmentVariables, self).__setitem__(key, item)\n os.environ[key] = item",
"def setenv(self, key, value):\n self._env[key] = value",
"def overwrite_environment_variable(self, key, value):\n if value is not None:\n self._printer... | [
"0.71190184",
"0.6520684",
"0.6477925",
"0.6293351",
"0.6282099",
"0.62065995",
"0.6192421",
"0.6161247",
"0.6156353",
"0.6107239",
"0.6044714",
"0.60414433",
"0.5981913",
"0.59789765",
"0.59789765",
"0.59789765",
"0.59789765",
"0.59789765",
"0.59789765",
"0.59680593",
"0.596... | 0.73775166 | 0 |
Invoked when cmds should be run | def run_run(self, cmds):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_cmd(self):\r\n self.run = True",
"def commands():",
"def commands():\n pass",
"def commands():\n pass",
"def commands():\n pass",
"def commands():\n pass",
"def cmd(self):",
"def run(self):\n self.cmdloop()",
"def ConsoleRun(self, command, sender):\n pass",
... | [
"0.70180553",
"0.6991362",
"0.6942904",
"0.6942904",
"0.6942904",
"0.6942904",
"0.6696623",
"0.6568137",
"0.65501654",
"0.6502923",
"0.6490506",
"0.6482494",
"0.64726007",
"0.64669955",
"0.64531946",
"0.6392404",
"0.6375683",
"0.6352139",
"0.63419855",
"0.6321749",
"0.6284225... | 0.8265414 | 0 |
Invoked when src should be copied to dst | def run_copy(self, src, dst):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self, src_path: str, tgt_path: str) -> None:",
"def move(self, dst, src): # pragma: no cover\n raise NotImplementedError(\"Implement this\")",
"def copy_contents(self, dst, src, size, condition=None, **kwargs):\n raise NotImplementedError()",
"def copy_tree_checker(src, dst):\n ... | [
"0.684205",
"0.66136926",
"0.6580783",
"0.6557567",
"0.6547169",
"0.65216875",
"0.64992964",
"0.6454224",
"0.6365512",
"0.62888414",
"0.62716484",
"0.62557656",
"0.62125784",
"0.62059265",
"0.6173281",
"0.6138458",
"0.6135269",
"0.6107685",
"0.6085962",
"0.6078006",
"0.606501... | 0.80904776 | 0 |
Invoked when src should be added to dst | def run_add(self, src, dst):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_copy(self, src, dst):\n pass",
"def add_link (self, src, dst):\n raise NotImplementedError",
"def add_req (self, src, dst):\n raise NotImplementedError",
"def assign(self, dst, req, src):\n if req == 'null':\n return\n if req in ('write', 'inplace'):\n dst[:] = src\n ... | [
"0.7102323",
"0.6734214",
"0.662322",
"0.65017915",
"0.6429906",
"0.64043015",
"0.63439864",
"0.60419446",
"0.5963952",
"0.5921709",
"0.5847843",
"0.583667",
"0.58271646",
"0.58191067",
"0.5758026",
"0.5722273",
"0.572211",
"0.57052636",
"0.56613034",
"0.5647836",
"0.56400925... | 0.7857617 | 0 |
Find an object given its ID from a list of items | def find_by_id(object_id, items):
for item in items:
if object_id == item["id"]:
return item
raise Exception(f"Item with {object_id} not found") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object_by_id(self, object_list, object_id):\n obj = None\n for i in object_list:\n if i.get_id() == object_id:\n obj = i\n break\n return obj",
"def find_item_by_id(self, item_id: str) -> ClientWorklistItem:\n # print(f'Finding item wit... | [
"0.7937062",
"0.7304144",
"0.7251918",
"0.7070019",
"0.705509",
"0.7005335",
"0.69254357",
"0.69254357",
"0.6823798",
"0.68061745",
"0.678606",
"0.66440827",
"0.6587592",
"0.6525803",
"0.65205777",
"0.6463741",
"0.64635897",
"0.6457988",
"0.64533836",
"0.6448341",
"0.64291537... | 0.84317213 | 0 |
Test Multiple pages of response coming back | def test_execute_get_success_with_multiple_pages():
response_queue = queue.Queue()
message = FakeMessage()
message.raw_payload = json.dumps(TestData.JOB_TEMPLATE_PAYLOAD_ALL_PAGES)
headers = {"Content-Type": "application/json"}
with aioresponses() as mocked:
mocked.get(
TestData... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_response_is_paginated(self):\r\n user = ViewAfishaTests.mentor\r\n EventFactory.create_batch(50, city=user.profile.city)\r\n client = self.return_authorized_user_client(user)\r\n\r\n response_data = client.get(path=EVENTS_URL).data\r\n\r\n self.assertTrue(\"next\" in res... | [
"0.70876974",
"0.6742121",
"0.65078133",
"0.650118",
"0.648242",
"0.64380234",
"0.6427036",
"0.6399775",
"0.63872343",
"0.6385378",
"0.6381569",
"0.6349449",
"0.6338915",
"0.63041335",
"0.628687",
"0.62860924",
"0.6275239",
"0.6251562",
"0.62098557",
"0.6196413",
"0.6176467",... | 0.6826234 | 1 |
HTTP POST Test with Filtered Response GZIPPed | def test_execute_post_filtered_zip_success():
response_queue = run_post(
json.dumps(TestData.JOB_TEMPLATE_POST_FILTERED_PAYLOAD_GZIPPED),
TestData.JOB_TEMPLATE_POST_RESPONSE,
)
result = response_queue.get()
response = ast.literal_eval(gzip.decompress(result).decode("utf-8"))
validate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compress_response(self):\n r = GZipMiddleware(self.get_response)(self.req)\n self.assertEqual(self.decompress(r.content), self.compressible_string)\n self.assertEqual(r.get(\"Content-Encoding\"), \"gzip\")\n self.assertEqual(r.get(\"Content-Length\"), str(len(r.content)))",
"... | [
"0.64330626",
"0.6299873",
"0.6263577",
"0.61930263",
"0.6186077",
"0.61293703",
"0.6115723",
"0.6036706",
"0.59558666",
"0.59094465",
"0.5854884",
"0.58485293",
"0.5842008",
"0.5673604",
"0.5652594",
"0.5637316",
"0.56218165",
"0.55327237",
"0.5516337",
"0.55045617",
"0.5497... | 0.7019999 | 0 |
Test to Monitor completion of job with huge artifacts | def test_execute_monitor_job_huge_artifact():
response_queue = queue.Queue()
message = FakeMessage()
message.raw_payload = json.dumps(TestData.JOB_MONITOR_GZIP_PAYLOAD)
headers = {"Content-Type": "application/json"}
with aioresponses() as mocked:
mocked.get(
TestData.JOB_MONITOR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_get_huge_artifact():\n writer = SimpleWriter()\n work_queue = asyncio.Queue()\n await work_queue.put(TestData.JOB_GET_PAYLOAD)\n worker = tower_api_worker.TowerApiWorker(TestData.config, writer, work_queue)\n headers = {\"Content-Type\": \"application/json\"}\n with aioresponses() ... | [
"0.7460174",
"0.648365",
"0.6319169",
"0.62829",
"0.61046445",
"0.60778874",
"0.6062635",
"0.6027667",
"0.59981215",
"0.59329385",
"0.59142697",
"0.58336353",
"0.578648",
"0.57611513",
"0.57514536",
"0.57494694",
"0.57489073",
"0.5745268",
"0.57376176",
"0.5732172",
"0.570298... | 0.74507254 | 1 |
Emulate the Unix socketpair() function on Windows. | def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
# We create a connected TCP socket. Note the trick with setblocking(0)
# that prevents us from having to create a thread.
lsock = socket.socket(family, type, proto)
lsock.bind(('localhost', 0))
lsock.listen(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def socket_pair():\n # Connect a pair of sockets\n port = socket_any_family()\n port.bind((\"\", 0))\n port.listen(1)\n client = socket(port.family)\n client.setblocking(False)\n client.connect_ex((loopback_address(port), port.getsockname()[1]))\n client.setblocking(True)\n server = port... | [
"0.67273897",
"0.6674087",
"0.5924282",
"0.57430905",
"0.5705649",
"0.5667401",
"0.5635149",
"0.55424136",
"0.5499504",
"0.5472787",
"0.54423577",
"0.54059166",
"0.54048026",
"0.5359836",
"0.53251463",
"0.5322048",
"0.53046817",
"0.525587",
"0.5185227",
"0.5182713",
"0.515538... | 0.68180084 | 0 |
Required property for paging indexing. | def paging_index(self):
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_index(self):\r\n return (self.per_page * (self.page_number - 1)) + 1",
"def paginated(self) -> global___Snippet.Paginated:",
"def end_index(self):\r\n if self.page_number == self.num_pages:\r\n return self.total_count\r\n return self.page_number * self.per_page",
"de... | [
"0.6568693",
"0.6449987",
"0.6436679",
"0.6420659",
"0.63921016",
"0.6387182",
"0.6372103",
"0.63244283",
"0.6296986",
"0.6293287",
"0.6256105",
"0.6246576",
"0.62288445",
"0.6218717",
"0.62127787",
"0.6130625",
"0.61163986",
"0.6111341",
"0.60654837",
"0.60475534",
"0.602246... | 0.789019 | 0 |
Required property for paging results. | def paging_results(self):
return 30 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pagination(self):\n return self.__pagination",
"def pagination(self):\n return self._pagination",
"def paging_index(self):\n\n return 0",
"def paginated(self) -> global___Snippet.Paginated:",
"def get_paginate_data(self, *args, **kwargs):\n pass",
"def rows_per_page(self):... | [
"0.7393641",
"0.7259711",
"0.7052853",
"0.7042176",
"0.703677",
"0.6972491",
"0.66814995",
"0.65357864",
"0.65357864",
"0.65313524",
"0.6496097",
"0.6488124",
"0.6482209",
"0.64763427",
"0.6459869",
"0.64330477",
"0.6398995",
"0.6299724",
"0.6278607",
"0.62765026",
"0.6229067... | 0.7375352 | 1 |
Parse elasticsearch results. Parse a search result returned from elasticsearch client to return an array of dicts containing only the interesting parts. | def parse_results(self, result):
interesting = []
for item in result["hits"]["hits"]:
source = item["_source"]
meta = source.get("meta")
title = "No title found"
descr = None
os_path = None
highlight = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_search_results(fields, results):\n my_results = []\n for result in results:\n my_results.append(SearchAnimeResult(fields, result))\n return my_results",
"def parse_query_results(self):\n # TODO: nicely parsed needs defining; may depend on query\n return self.json_result",
... | [
"0.6793492",
"0.67013067",
"0.6465043",
"0.6334906",
"0.62835765",
"0.61902833",
"0.6171834",
"0.61566615",
"0.6094304",
"0.6094304",
"0.6094278",
"0.60831743",
"0.6029349",
"0.598892",
"0.598892",
"0.5942892",
"0.5933647",
"0.59039205",
"0.58767045",
"0.58719695",
"0.5844716... | 0.7748185 | 0 |
Test reconnect after restarting the remote impalad without using connect; | def test_auto_reconnect_after_impalad_died(self):
# Use pexpect instead of ImpalaShell() since after using get_result() in ImpalaShell()
# to check Disconnect, send_cmd() will no longer have any effect so we can not check
# reconnect.
impalad = ImpaladService(socket.getfqdn())
# Iterate over test v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reconnecting(self) -> bool:",
"def reconnect(self):\n\t\t# TODO: Make sure the remote devices are actually found?\n\t\tself.setup()\n\t\tself.patch()",
"def reconnect(self):\n self.test_cmd()\n if not self.check_network: \n self.reset()\n attempt=0\n while not self.ch... | [
"0.74889195",
"0.7229402",
"0.71620506",
"0.6919871",
"0.69196284",
"0.68877256",
"0.6729152",
"0.6725588",
"0.66447777",
"0.66320306",
"0.6627751",
"0.65981334",
"0.6590967",
"0.65798396",
"0.6573456",
"0.6514554",
"0.65071476",
"0.64965737",
"0.64816004",
"0.6480941",
"0.64... | 0.7763525 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.