query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Represent an intersection using the Cantor pairing function.
def intersection(st, ave): return (st+ave)*(st+ave+1)//2 + ave
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_union_intersection():\n X = np.random.randn(d, 100)\n assert np.array_equal(lincon.indicator_intersection(X), 1-lincon.indicator_union(X))", "def intersection(x, y, f, p):", "def intersection(self, other):\n return self._geomgen(capi.geom_intersection, other)", "def intersect(self, *arg...
[ "0.6529781", "0.64454335", "0.643646", "0.6377812", "0.6290983", "0.6158032", "0.61379325", "0.6099429", "0.60879844", "0.60427094", "0.6039375", "0.6011817", "0.5966033", "0.5949825", "0.5942497", "0.5928957", "0.59143835", "0.59129083", "0.5910618", "0.5907354", "0.5888551"...
0.0
-1
Return the taxicab distance between two intersections. >>> times_square = intersection(46, 7) >>> ess_a_bagel = intersection(51, 3) >>> taxicab(times_square, ess_a_bagel) 9 >>> taxicab(ess_a_bagel, times_square) 9
def taxicab(a, b): "*** YOUR CODE HERE ***" return abs(street(a) - street(b)) + abs(avenue(a) - avenue(b))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def taxicab(a, b):\n street_1, street_2 = street(a), street(b)\n avenue_1, avenue_2 = avenue(a), avenue(b)\n return abs(street_1 - street_2) + abs(avenue_1 - avenue_2)", "def taxicab(a, b):\n\t\"*** YOUR CODE HERE ***\"\n\treturn abs(street(a)-street(b)) + abs(avenue(a)-avenue(b))", "def taxicab(a, b)...
[ "0.7120027", "0.6839901", "0.65796494", "0.65705454", "0.5223681", "0.50767803", "0.5042108", "0.49975678", "0.48670506", "0.48530948", "0.4835566", "0.4795915", "0.47938675", "0.47879708", "0.47753534", "0.47272784", "0.46994123", "0.46631414", "0.465091", "0.46485525", "0.4...
0.67126614
3
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
Print instructions to move a disk.
def print_move(origin, destination): print("Move the top disk from rod", origin, "to rod", destination)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self, num_tower, position):\n #Keep track of the location of the disk\n self.peg = num_tower\n self.position_on_peg = position\n \n #Change coordenates in graphical representation of the disk\n #Calling base clase move method\n super().move( Disk.get_center...
[ "0.6039234", "0.6002185", "0.5936001", "0.58213556", "0.57730645", "0.5628979", "0.56272626", "0.5441529", "0.54332095", "0.5373397", "0.5345443", "0.53429705", "0.53327715", "0.5329446", "0.5281114", "0.52739465", "0.5241653", "0.5238077", "0.5231009", "0.5230801", "0.523073...
0.7575055
3
Print the moves required to move n disks on the start pole to the end pole without violating the rules of Towers of Hanoi. n number of disks start a pole position, either 1, 2, or 3 end a pole position, either 1, 2, or 3 There are exactly three poles, and start and end must be different. Assume that the start pole has ...
def move_stack(n, start, end): assert 1 <= start <= 3 and 1 <= end <= 3 and start != end, "Bad start/end" "*** YOUR CODE HERE ***"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_stack(n, start, end):\n assert 1 <= start <= 3 and 1 <= end <= 3 and start != end, \"Bad start/end\"\n \n if n == 1:\n print_move(start, end) \n else:\n extra_pole = 6 - start - end\n move_stack(n-1, start, extra_pole)\n move_stack(1, start, end)\n move_sta...
[ "0.7980914", "0.7740771", "0.6126784", "0.59013176", "0.5819141", "0.55706495", "0.5505688", "0.5504053", "0.5500867", "0.54933286", "0.5467977", "0.5244985", "0.5197591", "0.5105983", "0.50870454", "0.50858366", "0.508075", "0.49935585", "0.49684587", "0.49679634", "0.496256...
0.71134025
3
Return the value of an expression that computes factorial. >>> make_anonymous_factorial()(5) 120 >>> from construct_check import check >>> check(HW_SOURCE_FILE, 'make_anonymous_factorial', ['Assign', 'AugAssign', 'FunctionDef', 'Recursion']) True
def make_anonymous_factorial(): return 'YOUR_EXPRESSION_HERE'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_anonymous_factorial():\n return lambda n: 1 if n == 1 else mul(n, make_anonymous_factorial()(sub(n, 1)))", "def make_anonymous_factorial():\n\t# u need to use a helper function if your lambda statement does\n\t# not have a name\n\t# fact = lambda n: 1 if n == 1 else mul(n, fact(sub(n, 1)))\n\tdef rec...
[ "0.795322", "0.76479423", "0.7496367", "0.6421492", "0.6419824", "0.64167154", "0.63810945", "0.63466245", "0.6338506", "0.63343805", "0.62276936", "0.61999434", "0.6188147", "0.61714816", "0.6145468", "0.61416566", "0.6131425", "0.6131287", "0.6107738", "0.60987043", "0.6065...
0.8405621
3
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
Create room/webhook and post message room then send customer SMS
def customer_new_signup(spark_api, customer_id, team_id, message_from_customer, webhook_url): # Send message via tropo message = "Thanks for signing up! To get in touch, reply to this message or call this number during business hours." tropo.send_sms(customer_id[-10:], message) # Fetch all rooms and l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def POST(self):\n\t\t\n\t\tjson_data = web.data()\t\t# Get the POST data sent from Webex Teams\n\t\t#print(\"\\nWEBHOOK POST RECEIVED:\")\n\t\t#print(json_data, \"\\n\")\n\n\t\twebhook_obj = Webhook(json_data)\t\t\t\t\t# Create a Webhook object from the JSON data\n\t\troom = api.rooms.get(webhook_obj.data.roomId)\...
[ "0.7098938", "0.6646875", "0.6630591", "0.6442523", "0.64140123", "0.63342357", "0.63222736", "0.6215194", "0.6198079", "0.6152976", "0.6151927", "0.61304444", "0.60952866", "0.60899824", "0.6030755", "0.60275304", "0.60214525", "0.601809", "0.60107744", "0.6006407", "0.59974...
0.6217545
7
Send any room messages to customer by SMS, making sure not to echo customer's SMS or messages.
def webhook_process(request): # Basic sanity checking if not request.json or not ('event' in request.json and 'data' in request.json): logging.log(logging.ERROR, 'No json or data in json') abort(400) if request.json['event'] != 'created': logging.log(logging.ERROR, 'Event is not cr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_sms(self, sms):\n pass", "def send_sms(self,msg,to=None,long=True):\n if long:\n return self.send_msg(msg,to,\"SendCatSMS\")\n else:\n return self.send_msg(msg,to,\"SendSMS\")", "def send_sms(self, body):\n message = self.twilio_client.sms.messages.cre...
[ "0.72153", "0.69181114", "0.6639897", "0.66254675", "0.6553501", "0.65526444", "0.6525755", "0.64059794", "0.63927513", "0.635507", "0.63540757", "0.627183", "0.62477255", "0.62430453", "0.6224343", "0.62242794", "0.618873", "0.6184785", "0.61725867", "0.614549", "0.612009", ...
0.0
-1
It should take nothing And return json array of all user's and their information
def list_users(): 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) users = db.session.query(User).all() resdata = [] for user in users: resdata.append({"i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_user():\n user = UserModel.objects()\n return jsonify(user), 200", "def users_no_id_get():\n all_users = []\n for user in storage.all(\"User\").values():\n all_users.append(user.to_dict())\n return jsonify(all_users)", "def get_users():\n selection = []\n try:\n s...
[ "0.7767868", "0.75064695", "0.7486039", "0.74693805", "0.7443739", "0.741982", "0.74109954", "0.7366981", "0.7364997", "0.73534054", "0.73403007", "0.73249465", "0.72949857", "0.7291494", "0.72630936", "0.726186", "0.7206385", "0.7199901", "0.7198208", "0.7172977", "0.7171010...
0.648453
85
It should be used for user creation so it takes all data from user model described earlier except id and relationships And return user's temporary jwt token ?
def create_user(): if not check_content_type(): return jsonify(status=CONTENT_TYPE_ERROR) data = request.json #TODO check if request body contain required keys #if ["login", "password", "user", "email", "first_name", "second_name", "phone"].sort() != (data.keys()).sort(): # return jsonif...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UserToken(self) -> object:", "def for_user(cls, user):\n\n token = super().for_user(user)\n\n TokenMeta.objects.get_or_create(\n jti=token['jti'],\n token=str(token),\n )\n\n return token", "def create(self, data):\n token, cr...
[ "0.7068197", "0.6890675", "0.68891424", "0.68891424", "0.68891424", "0.68891424", "0.68891424", "0.68891424", "0.6834859", "0.67731804", "0.6667489", "0.6624938", "0.6584035", "0.6555688", "0.6482245", "0.64695615", "0.64479065", "0.6439664", "0.64168483", "0.6408788", "0.640...
0.0
-1
It should take user token and update database section And return well.... nothing
def update_user(): #TODO user update pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user():", "def _update_token(token):\n session.token = token", "def temp_getToken():\n # First check if query is okay or not\n data = json.loads(request.data)\n username = data.get(\"username\",None)\n password = data.get(\"password\",None)\n \n if request.headers.get('X-VITASK-...
[ "0.6980469", "0.6788381", "0.66331285", "0.6625706", "0.6619976", "0.6572579", "0.6507547", "0.6471451", "0.6423794", "0.64029384", "0.63858753", "0.6384523", "0.63422924", "0.6332013", "0.6330532", "0.6312202", "0.62036765", "0.6197012", "0.6196945", "0.6188228", "0.6155419"...
0.66499823
2
It should take user token and password And return nothing. just delete this user from database
def delete_user(): #TODO user delete pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user():", "def delete(cls):\n user = user_schema.load(request.get_json(), partial=(\"email\",))\n\n current_identity = get_jwt_identity()\n db_user = UserModel.find_by_id(current_identity)\n logging.info(\n f\"Delete called by {db_user.id}: {db_user.username} wit...
[ "0.8245988", "0.8094278", "0.79578537", "0.77676976", "0.75711685", "0.748723", "0.74508", "0.74470454", "0.73795223", "0.72883624", "0.7269549", "0.71676147", "0.71491003", "0.70365703", "0.7034477", "0.70184124", "0.70036274", "0.6996407", "0.699598", "0.69952154", "0.69941...
0.7995271
2
It should take limiter (for example 10 random path's) And return array of paths with all data provided except coordinates (but when dev build it's okay)
def list_paths(): paths = db.session.query(Path).all() data = [] for path in paths: data.append({"id" : path.id, "title":path.title,"rating":path.rating, "description":path.description,"date":path.date, "start_coordinate":path.start_coordinate, "end_co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimized_path(coords, startid, mask):\n coords = np.column_stack((coords, mask))\n pass_by = np.asarray(coords)\n path = [coords[startid]]\n pass_by = np.delete(pass_by, startid, axis=0)\n while pass_by.any():\n nearest_id, nearest = min(\n enumerate(pass_by), key=lambda x: di...
[ "0.62314683", "0.6198397", "0.58058447", "0.5761351", "0.57430595", "0.57112736", "0.5702389", "0.56382763", "0.5606894", "0.55856305", "0.55711824", "0.55240107", "0.54835707", "0.54586005", "0.54335684", "0.5425482", "0.54141396", "0.54081756", "0.5407028", "0.53954357", "0...
0.0
-1
It should take all data needed for creation of path And no return
def create_path(): if not check_content_type(): return jsonify(status=CONTENT_TYPE_ERROR) data = request.json if not check_token(data["token"]): return jsonify(status=TOKEN_ERROR) #TODO check that we have required keys in request body to Path creation title = data["title"] rating...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(self):\n ...", "def prepare_path(self,path):\n debug.info(4,\"Set path: \" + str(path))\n\n # This is marked for debug\n path.set_path()\n\n # For debugging... if the path failed to route.\n if False or path==None:\n self.write_debug_gds()\n\n ...
[ "0.6511428", "0.64666474", "0.6107135", "0.61054385", "0.6089046", "0.6060304", "0.6022867", "0.599679", "0.59728765", "0.59154546", "0.58834463", "0.58768857", "0.58740234", "0.58728284", "0.5834883", "0.5831352", "0.5823931", "0.58224046", "0.58064187", "0.58030295", "0.579...
0.5744296
27
It should update all user information and we need to check user token
def update_path(): #TODO update path information pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user():", "def update_user():\n #TODO user update \n pass", "async def update(self):\n self.data = await self.api.user.get()", "def test_update_user(self):\n token = self.authenticate_user(self.auth_user_data).data[\"token\"]\n response = self.client.put(self.user_url,\n...
[ "0.8475117", "0.80762476", "0.7211855", "0.71284574", "0.70691365", "0.7039774", "0.700582", "0.69647455", "0.68810004", "0.682694", "0.6816446", "0.6799031", "0.670049", "0.6663624", "0.6663624", "0.6656589", "0.66043735", "0.6600797", "0.65735185", "0.6551525", "0.65486246"...
0.0
-1
it should take user token (it should be user with role admin or so) and password and no return. but delete this path from database
def delete_path(): #TODO delete path from database pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user():", "def delete_user():\n #TODO user delete\n pass", "def delete_user():\n token = request.args.get('token')\n data = jwt.decode(token, app.config['SECRET_KEY'])\n\n permit = functions.delete_user(data)\n if permit:\n return make_response(jsonify({'Delete': 'User Delet...
[ "0.6882728", "0.6600979", "0.6442104", "0.6431626", "0.6199002", "0.6198386", "0.6184373", "0.6175392", "0.61739355", "0.6154988", "0.6083398", "0.6067171", "0.6040718", "0.6025336", "0.5950242", "0.59005874", "0.58870757", "0.58870757", "0.58725816", "0.5852299", "0.58464605...
0.55862695
57
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 all users registered at excursion
def assoc_list(): 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) users_paths = db.session.query(UserPathAssociation).all() resdata = [] for e in users_paths: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_users():", "def get_users(self):\r\n\t\tlogger.debug(\"Fetch users\")\r\n\t\t\r\n\t\treturn login.get_users()", "def get_users():\n return db.fetch_users()", "def getInterestedUsers():", "def get_users(self):\n users = []\n page = 1\n while not len(users) % 100:\n ...
[ "0.8572794", "0.7658152", "0.7489579", "0.7470524", "0.7346282", "0.73064995", "0.73031485", "0.7269989", "0.72584635", "0.72584635", "0.72584635", "0.72584635", "0.7252011", "0.72429305", "0.7241409", "0.7196677", "0.71711403", "0.71708596", "0.71601003", "0.7156562", "0.715...
0.0
-1
development demo for frontend work check
def test_route(): coordinates = "54.971288,82.875554|54.988211,82.906425|55.038288,82.937137|55.060150,82.984610" return jsonify(data=coordinates, status=OK_STATUS)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def demo():\n ...", "def development_function(self): \n return None", "def test_Demo(self):\n self._run(self._example_scenarios, \"Demo\")", "def should_show():", "def test_quick_build(self):\n pass", "def test(self):\n pass", "def testing(self):\n print('test s...
[ "0.63391596", "0.6087888", "0.60736024", "0.60091513", "0.59981024", "0.5935011", "0.5920325", "0.58774805", "0.58619386", "0.5839741", "0.5838705", "0.58170086", "0.57993233", "0.57925045", "0.5769986", "0.57453775", "0.57439023", "0.57287276", "0.57160985", "0.5709616", "0....
0.0
-1
takes path_id and returns all waypoints
def generate_coordinate(): #TODO debug dat fucking code if not check_content_type(): return jsonify(status=CONTENT_TYPE_ERROR) reqdata = request.json try: if not check_token(reqdata["token"]): return jsonify(status=TOKEN_ERROR) except: return jsonify(status=REQ_ER...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_path(self, starting_waypoint, destination_id):\n # Run dijkstra's algorithm\n dijkstra_output = dijkstra.DijkstraSPF(self.graph, starting_waypoint)\n \n # Get waypoint_id of destination\n cur = armaps.model.get_db()\n cur.execute(\n \"SELECT waypoint_id ...
[ "0.64917606", "0.62769824", "0.62649757", "0.6230449", "0.621781", "0.6089363", "0.60655874", "0.601833", "0.6014707", "0.5981585", "0.5973532", "0.59211046", "0.587732", "0.5869312", "0.58577955", "0.58385986", "0.5831729", "0.5825229", "0.5812677", "0.57631683", "0.57394826...
0.0
-1
actually that's just pass hashing lol
def raw_password_to_string(raw_string): return hashlib.sha256(str(raw_string).encode('utf-8')).hexdigest()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def HashAlgorithm(self) -> _n_7_t_0:", "def hash(self) -> str:\r\n ...", "def hash(self) -> bytes:", "def hash_key(self):", "def hashing(word) :\r\n ans = hashlib.sha256(word.encode())\r\n return ans.hexdigest()", "def current_hash(self):", "def hashcode(o):", "def __hash__(self):\n ...
[ "0.78062844", "0.769477", "0.75788176", "0.7432525", "0.7197758", "0.7175085", "0.71015054", "0.7054006", "0.7051356", "0.70512056", "0.7031017", "0.70059437", "0.6994937", "0.6960184", "0.6944826", "0.6941813", "0.6928904", "0.6898604", "0.68907386", "0.6880028", "0.6879239"...
0.0
-1
magic generation! very top secret
def generate_token(login, password): time = datetime.datetime.now().timestamp() raw_string = str(login) + str(password) + str(time) return hashlib.sha256(str(raw_string).encode('utf-8')).hexdigest()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate():", "def generate(self):", "def passwordGen() :\n\treturn __randomString(12)", "def gensalt():\n return hexlify(os.urandom(24)).decode()", "def generate_secret_number(self):\n self.secret_number = randint(0, self.difficulty)\n # print(f\"secret_number = {self.secret_number}\"...
[ "0.77251697", "0.6991", "0.6777404", "0.6668828", "0.6621261", "0.6607946", "0.65829366", "0.6549961", "0.6549961", "0.6549961", "0.65182585", "0.64814043", "0.6452127", "0.64483225", "0.6382743", "0.6376844", "0.6344381", "0.6260516", "0.62596536", "0.6241607", "0.62277144",...
0.0
-1
return true in case if token valid
def check_token(token): token = db.session.query(Token).filter(Token.token==token).first() if token == None: return False #TODO token lifetime #if (datetime.datetime.now() - token.date >= datetime.timedelta(day=2)): # return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def validate_token(self, token):", "def check_for_token(token):\n try:\n decode_token(token)\n return True\n except:\n return False", "def verify_token(self, token):\n return False", "def test_unused_token_is_valid(self):\n assert self.token.is_valid()", "def ...
[ "0.82097185", "0.8140379", "0.81355923", "0.7914643", "0.78615093", "0.78422207", "0.7573815", "0.74966556", "0.7471199", "0.7436773", "0.7294061", "0.72937906", "0.7229699", "0.71921486", "0.7146299", "0.70567137", "0.69968945", "0.69913256", "0.68749946", "0.68700546", "0.6...
0.6887068
18
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
Ensure we can create a new building.
def test_post_building(self): url = '/building/' data = {"address": "дом 50 улица Ленина", "total_bricks_required": 300} today = date.today() date_output = today.strftime("%Y-%m-%d") data_output = { "id": 1, "address": "дом 50 улица...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creates_valid_building(self, cell):\n def wont_cut_off_other_commercial_buildings(pos):\n \"\"\"Helper function that ensures other commercial buildings won't be cutoff if a commercial building is\n placed at pos\"\"\"\n for adj_cell in self.environment.grid.get_neighborh...
[ "0.6149066", "0.60781157", "0.5911046", "0.5865075", "0.5821171", "0.5813078", "0.5784675", "0.5746099", "0.57275873", "0.57275873", "0.569468", "0.5693626", "0.5692525", "0.566429", "0.56606543", "0.56389713", "0.56243294", "0.558071", "0.55754536", "0.5574062", "0.55678195"...
0.0
-1
Ensure that without a building we can not create a new brick_task.
def test_post_brick_task(self): task_url = '/building/id/3/add-bricks' task_data = { "bricks": 200, "date_load": "2030-03-10" } response = self.client.post(task_url, task_data, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_R...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumb_task():\n return True", "def _check_can_submit(self):\n if not self.parallel and self.last_submitted_i != self.highest_continuous_done_i:\n raise CannotSubmitNewTask(\n f\"Attempt to get task for {self} \"\n f\"out of order: last submitted {self.last_su...
[ "0.58794796", "0.58149904", "0.57713705", "0.57603836", "0.56704164", "0.5647729", "0.55785745", "0.5520681", "0.546715", "0.5453792", "0.5427059", "0.54269284", "0.5421115", "0.540672", "0.53743273", "0.5352993", "0.53447807", "0.5338095", "0.53360236", "0.53190583", "0.5313...
0.51699674
38
Dispatch some bricks and check the stats
def test_post_brick_task(self): task_url = '/building/id/1/add-bricks' task_data = { "bricks": 100, "date_load": "2030-03-10" } self.client.post(task_url, task_data, format='json') task_url = '/building/id/1/add-bricks' task_data = { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _monitor(self):\n # while CONF.weight == 'bw':\n while True:\n self._send_echo_request()\n self.create_link_delay()\n # self.get_loss()\n self.stats['flow'] = {}\n self.stats['port'] = {}\n for dp in self.datapaths.values():\n ...
[ "0.57859915", "0.55887634", "0.5506207", "0.5475481", "0.5435428", "0.537355", "0.5356436", "0.53383297", "0.5325674", "0.53071356", "0.5215758", "0.52093613", "0.5204521", "0.51719254", "0.5168573", "0.51683146", "0.51554996", "0.5150338", "0.51472735", "0.51448953", "0.5141...
0.5560453
2
Query of minmum Tier and CGPA on job id
def University_calculation(jobid): min_cgpa=90 """~~~~~~~~~""" dbconnect= connect_to_db() Candidate_qualifications=pd.read_sql("select candidate_id,university_name,institute_name,aggregate from candidate_qualification where candidate_id in(select candidate_id from master_id where job_id="+str(jobid)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_job_query(self):\n context = aq_inner(self.context)\n catalog = getToolByName(context, 'portal_catalog')\n mt = getToolByName(self, 'portal_membership') \n currentUser = mt.getAuthenticatedMember() \n \n if \"Site Administrators\" not in currentUser.getGroups():\n\treturn catalog.searchRe...
[ "0.5880039", "0.5506129", "0.5467628", "0.5228536", "0.5168022", "0.5120933", "0.51059866", "0.50934154", "0.5050494", "0.5010462", "0.49944985", "0.49767104", "0.49651697", "0.494382", "0.48621768", "0.48598516", "0.48432046", "0.4807202", "0.48071113", "0.47951928", "0.4794...
0.4691528
34
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
Return dict of file types and its extensions.
def TYPES(): if config.types_cache: return config.types_cache types = { 'actionscript': '.as .mxml', 'asm': '.asm .s', 'batch': '.bat .cmd', #'binary': 'Binary files, as defined by Perl's -B op (default: off)', 'cc': '.c .h .xs', 'cfmx': '.cfc .cfm .cfml...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_extension_to_type_map(file_types):\n extension_to_type = dict()\n for file_type in file_types:\n for file_ext in file_type['extensions']:\n if file_ext not in extension_to_type:\n extension_to_type[file_ext] = file_type\n return extension_to_type", "def ComputeF...
[ "0.763715", "0.7182069", "0.6990045", "0.68455327", "0.67907184", "0.6781619", "0.6718573", "0.65699273", "0.65577275", "0.6477392", "0.638216", "0.6374214", "0.6350945", "0.62902635", "0.62902635", "0.624474", "0.61979735", "0.61897975", "0.6184642", "0.6162244", "0.61284614...
0.63220716
13
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 pattern in each line of file.
def search(path, f): started = False for count, line in enumerate(f): number = count + 1 if search_line(line): if not started: print config.term.highlight(relpath(path), 'GREEN') if config.filenames: break started ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grep(pattern, filename):\n rx = re.compile(pattern)\n with open(filename, 'r') as file:\n for line in file:\n if rx.search(line):\n yield line", "def grep_me(pattern, fname):\n for line in stream_reader(fname):\n if re.search(pattern, line, re.I):\n ...
[ "0.7754115", "0.772458", "0.7566962", "0.7401021", "0.73548084", "0.70622396", "0.7045306", "0.6969334", "0.69634515", "0.69435984", "0.6909578", "0.68896705", "0.68886346", "0.6710138", "0.66423684", "0.6598283", "0.65414864", "0.65358496", "0.64989007", "0.6468703", "0.6442...
0.65670025
16
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
Iterator over files which names satisfies the search parameters.
def walk_files(): # TODO: not check twice the same dir or file for path in config.targets: abs_path = os.path.join(cwd, path) if not os.path.islink(abs_path) and os.path.isfile(abs_path): walked.append(abs_path) yield abs_path #process_file(abs_path) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files(pathname: str) -> Iterator[dict]:\n for filename in glob.iglob(f'{pathname}/*'):\n r = match_filename(filename=filename)\n if r:\n yield r", "def filenames(self, glob='*', limit=0, recurse=False):\n for a in self.ls_names(glob, limit=limit, recurse=recurse):\n ...
[ "0.7143449", "0.6806924", "0.6717614", "0.66894305", "0.66321737", "0.65333736", "0.6480589", "0.6405443", "0.64030373", "0.6400605", "0.6353649", "0.6306214", "0.630192", "0.62971354", "0.62838227", "0.62457496", "0.62377614", "0.62249476", "0.6202404", "0.61908376", "0.6190...
0.0
-1
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 fist 24 bytes (6 words) of a TFM file contain twelve 16bit integers that give the
def _read_lengths(self): stream = self.stream stream.seek(0) ########### # Read and set table lengths self.table_lengths = [None]*len(tables) (self.entire_file_length, header_length, self.smallest_character_code, self.largest_character_code) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def m16i():\n\n global offset\n\n x = 0L\n for i in range(2):\n try:\n byte = midifile[offset]\n offset += 1\n except:\n error(\"Invalid MIDI file include (i16->int, offset=%s)\" % offset)\n x = (x << 8) + ord(byte)\n\n return int(x)", "def read_i...
[ "0.6806584", "0.63461256", "0.62110627", "0.6183381", "0.6170893", "0.6077263", "0.6055383", "0.59995687", "0.59053993", "0.5870395", "0.5807494", "0.5766607", "0.57580394", "0.5752466", "0.5727707", "0.5727707", "0.57185113", "0.57169336", "0.5705531", "0.5690018", "0.566762...
0.0
-1
The first data array is a block of header information, which contains general facts about the font. The header must contain at least two words, and for TFM files to be used with Xerox printing software it must contain at least 18 words, allocated as described below. ``header[0]`` is a 32bit check sum that TEX will copy...
def _read_header(self): stream = self.stream self._seek_to_table(tables.header) # Read header[0 ... 1] checksum = stream.read_unsigned_byte4() design_font_size = stream.read_fix_word() # Read header[2 ... 11] if there character_info_table_position = self.table...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_font_parameters(self):\n\n stream = self.stream\n\n self._seek_to_table(tables.font_parameter)\n\n if self.tfm.character_coding_scheme == 'TeX math italic':\n # undocumented in tftopl web\n pass\n else:\n # Read the seven fix word parameters\n ...
[ "0.5547137", "0.5544906", "0.5527031", "0.54338384", "0.54278547", "0.5304448", "0.5289456", "0.52327514", "0.5182959", "0.51704085", "0.5146259", "0.51352066", "0.5132421", "0.51025385", "0.5036685", "0.50115645", "0.5003028", "0.5002731", "0.49602506", "0.49543583", "0.4951...
0.5401551
5
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
Next comes the char info array, which contains one char info word per character. Each char info word contains six fields packed into four bytes as follows.
def _read_characters(self): # Read the character information table for c in range(self.smallest_character_code, self.largest_character_code + 1): self._process_char(c)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_char_info(self, c):\n\n index = c - self.smallest_character_code\n bytes = self._read_four_byte_numbers_in_table(\n tables.character_info, index)\n\n width_index = bytes[0]\n height_index = bytes[1] >> 4\n depth_index = bytes[1] & 0xF\n italic_index = ...
[ "0.66203916", "0.5909764", "0.5874805", "0.5723141", "0.5625157", "0.5544843", "0.55069035", "0.5447513", "0.5435269", "0.537435", "0.52129316", "0.5208179", "0.5158724", "0.51543826", "0.5144566", "0.5135801", "0.5110744", "0.5065201", "0.5037014", "0.5036735", "0.5024731", ...
0.5025694
20
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
Tests moving a file
def test_move_file_new_workspace(self, mock_message, mock_delete, mock_upload, mock_download, mock_paths): volume_path = os.path.join('the', 'volume', 'path') file_path_1 = os.path.join('my_dir', 'my_file.txt') file_path_2 = os.path.join('my_dir', 'my_file.json') full_path_file_1 = os.p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moveFile(source, dest):\n try:\n shutil.move(source, dest) \n except IOError as e:\n print (\"Unable to move file. %s\" %(e))", "def move_file(path):\n new_path = os.path.join(TEST_DIR, TEST_FILE)\n command = ['mv', TEST_FILE, new_path]\n file_operation(path, command)", "def mo...
[ "0.7711519", "0.7582299", "0.7474023", "0.73866624", "0.7370703", "0.73142", "0.7272098", "0.7219259", "0.7162279", "0.7143103", "0.712096", "0.7079723", "0.69801605", "0.6915869", "0.6910514", "0.6820217", "0.6798866", "0.66927844", "0.6688219", "0.6658179", "0.66407305", ...
0.6973797
13
Tests moving a file
def test_move_file_new_workspace_without_download(self, mock_message, mock_delete, mock_upload, mock_download, mock_paths): volume_path = os.path.join('the', 'volume', 'path') file_path_1 = os.path.join('my_dir', 'my_file.txt') file_path_2 = os.path.join('my_dir', 'my_file.json') full_p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moveFile(source, dest):\n try:\n shutil.move(source, dest) \n except IOError as e:\n print (\"Unable to move file. %s\" %(e))", "def move_file(path):\n new_path = os.path.join(TEST_DIR, TEST_FILE)\n command = ['mv', TEST_FILE, new_path]\n file_operation(path, command)", "def mo...
[ "0.7711519", "0.7582299", "0.7474023", "0.73866624", "0.7370703", "0.73142", "0.7272098", "0.7219259", "0.7162279", "0.7143103", "0.712096", "0.7079723", "0.69801605", "0.6973797", "0.6915869", "0.6910514", "0.6820217", "0.6798866", "0.66927844", "0.6658179", "0.66407305", ...
0.6688219
19
Tests moving a file
def test_move_file_new_path(self, mock_message, mock_move): volume_path = os.path.join('the', 'volume', 'path') file_path_1 = os.path.join('my_dir', 'my_file.txt') file_path_2 = os.path.join('my_dir', 'my_file.json') full_path_file_1 = os.path.join(volume_path, file_path_1) full...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moveFile(source, dest):\n try:\n shutil.move(source, dest) \n except IOError as e:\n print (\"Unable to move file. %s\" %(e))", "def move_file(path):\n new_path = os.path.join(TEST_DIR, TEST_FILE)\n command = ['mv', TEST_FILE, new_path]\n file_operation(path, command)", "def mo...
[ "0.7711519", "0.7582299", "0.7474023", "0.73866624", "0.7370703", "0.73142", "0.7219259", "0.7162279", "0.7143103", "0.712096", "0.7079723", "0.69801605", "0.6973797", "0.6915869", "0.6910514", "0.6820217", "0.6798866", "0.66927844", "0.6688219", "0.6658179", "0.66407305", ...
0.7272098
6
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
This program takes in a file with strings, and produces delimiterseparated combinations of these strings.
def console_start( file_path: str, delimiter: str, prefix: str, postfix: str, min_parts: int, max_parts: int, ) -> None: import sys error_message = None try: main( file_path, delimiter=delimiter, prefix=prefix, postfix=postfix,...
{ "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.6874418", "0.54696983", "0.5427321", "0.5409542", "0.5376775", "0.5370502", "0.5347375", "0.5314152", "0.53054637", "0.5301588", "0.5301126", "0.5252907", "0.5232522", "0.52278763", "0.5190499", "0.5180537", "0.5164951", "0.51628846", "0.51388574", "0.51068133", "0.5078360...
0.0
-1
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
Checks that the script checker works
def test_otter_check_script(self): # run for each individual test for file in glob(TEST_FILES_PATH + "tests/*.py"): # capture stdout output = StringIO() with contextlib.redirect_stdout(output): # mock block_print otherwise it interferes with capture o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scriptChecker(filename):\n if not os.path.exists(filename):\n print 'ERROR: %s does not exist' % filename\n import errno\n return errno.ENOENT\n\n # The script-checker program is called directly. If we call the code\n # from this python interpreter, any changes to an observing scr...
[ "0.70963734", "0.7057622", "0.682522", "0.6817014", "0.66594744", "0.64477414", "0.642847", "0.63979995", "0.63742423", "0.63742423", "0.63742423", "0.63742423", "0.63665223", "0.6331992", "0.62861043", "0.6219874", "0.6213596", "0.6207089", "0.6204746", "0.62004364", "0.6199...
0.0
-1
Checks that the script checker works
def test_otter_check_notebook(self): # run for each individual test for file in glob(TEST_FILES_PATH + "tests/*.py"): # capture stdout output = StringIO() with contextlib.redirect_stdout(output): # mock block_print otherwise it interferes with capture...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scriptChecker(filename):\n if not os.path.exists(filename):\n print 'ERROR: %s does not exist' % filename\n import errno\n return errno.ENOENT\n\n # The script-checker program is called directly. If we call the code\n # from this python interpreter, any changes to an observing scr...
[ "0.70963734", "0.7057622", "0.682522", "0.6817014", "0.66594744", "0.64477414", "0.642847", "0.63979995", "0.63742423", "0.63742423", "0.63742423", "0.63742423", "0.63665223", "0.6331992", "0.62861043", "0.6219874", "0.6213596", "0.6207089", "0.6204746", "0.62004364", "0.6199...
0.0
-1
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
Mock copy file to.
def mock_copy_file_to(iterator, metadata): chunks = [chunk.data for chunk in iterator] self.assertEqual(3, len(chunks)) self.assertEqual([('path-bin', b'/file')], metadata) data = b''.join(chunks) self.assertEqual(data, contents) return untrusted_runner_pb2.CopyFileToResponse(resu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_15_copyto(self):\n with mock.patch(BUILTINS + '.open', mock.mock_open()):\n status = udocker.FileUtil(\"source\").copyto(\"dest\")\n self.assertTrue(status)\n status = udocker.FileUtil(\"source\").copyto(\"dest\", \"w\")\n self.assertTrue(status)\n ...
[ "0.8122548", "0.74830496", "0.7332181", "0.72871107", "0.72668934", "0.6915809", "0.6846528", "0.67997044", "0.67707396", "0.67559165", "0.67559165", "0.67559165", "0.67180955", "0.66859967", "0.6684247", "0.6660035", "0.66151756", "0.6505115", "0.6496338", "0.6477941", "0.64...
0.72541636
5
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
Test get host path.
def test_get_cf_host_path(self): os.environ['ROOT_DIR'] = '/host' os.environ['WORKER_ROOT_DIR'] = '/worker' worker_path = os.path.join(os.environ['WORKER_ROOT_DIR'], 'a', 'b', 'c') self.assertEqual(file_host.rebase_to_host_root(worker_path), '/host/a/b/c') worker_path = os.environ['WORKER_ROOT_DIR...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_host(self):\n pass", "def test_get_host_access(self):\n pass", "def test_host_path(self):\n url = create_url(\n host=\"www.example.com\", path=\"path/to/resource\", scheme_no_ssl=\"http\"\n )\n self.assertEqual(url, \"http://www.example.com/path/to/res...
[ "0.8315634", "0.77355766", "0.7611911", "0.72548294", "0.72548294", "0.70257354", "0.6795541", "0.6527053", "0.65192544", "0.6490157", "0.6485603", "0.64630127", "0.64582074", "0.64465535", "0.6401503", "0.63968176", "0.63678986", "0.63454664", "0.6296492", "0.624655", "0.624...
0.67514616
7
Remove html tags from a string
def remove_html_tags(text: str) -> str: clean = re.compile('<.*?>') return re.sub(clean, '', str(text))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_html_tags(text):\n print('VOU REMOVER AS TAGS DA STRING')\n clean = re.compile('<.*?>')\n print('',re.sub(clean, '', text))\n return re.sub(clean, '', text)", "def remove_html_tags(self,text):\n #https://medium.com/@jorlugaqui/how-to-strip-html-tags-from-a-string-in-python-7cb81a2bb...
[ "0.8635796", "0.8504325", "0.8412075", "0.8405605", "0.83518916", "0.83518916", "0.83284837", "0.83064634", "0.8298507", "0.8230413", "0.8216462", "0.8161706", "0.8151882", "0.81427675", "0.8129797", "0.80991477", "0.8070709", "0.80528504", "0.80186284", "0.80122066", "0.7980...
0.8376141
4
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
Return a tuple of 'footnotes' and collection of footnotes. Footnotes are "collected" from the node and its children.
def apply_layer(self, text_index): footnotes = [] for label in self.layer.keys(): if is_contained_in(label, text_index): footnotes += [x['footnote_data'] for x in self.layer[label] if 'footnote_data' in x] re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeFootnotesDiv(self, root):\n\n if not list(self.footnotes.keys()):\n return None\n\n div = etree.Element(\"div\")\n div.set('class', 'footnote')\n etree.SubElement(div, \"hr\")\n ol = etree.SubElement(div, \"ol\")\n\n for id in self.footnotes.keys():\n ...
[ "0.6317781", "0.61900926", "0.6149558", "0.6146513", "0.5762061", "0.56409013", "0.5610856", "0.54278535", "0.5426516", "0.53579605", "0.52695143", "0.51903385", "0.51892966", "0.51519656", "0.5131307", "0.5113108", "0.5091132", "0.5089666", "0.5081637", "0.50717264", "0.5071...
0.5484363
7
Print status each time.
def on_status(self, status): if self._counter < self._limit: if re.match(r'^en(-gb)?$', status.lang): # english tweets only with open(self._file, "a+") as f: f.write( json.dumps(self._map_status_fields(status)) + ',\n') pri...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _print_status(self):", "def status(s):\n print('\\033[1m{0}\\033[0m'.format(s))\n time.sleep(2)", "def _PrintStatus(self):\n comment = 'iter %i' % (self.n_iter)\n self.gfile.write(fileio.GetPrintCoordsXyzString(\n self.mol.atoms, comment, 14, 8))\n self.PrintEnergy(self.n_iter)\n s...
[ "0.8277072", "0.75176513", "0.7487483", "0.7366643", "0.7340062", "0.7316466", "0.73164415", "0.73164415", "0.73164415", "0.73164415", "0.7304564", "0.7295404", "0.7295404", "0.7295404", "0.7295404", "0.7240836", "0.72358745", "0.72280544", "0.7167335", "0.71368235", "0.71220...
0.0
-1
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
Cleanup the test byproducts.
def classCleanup(cls): cls.RemoveTempFile(SettingsCommandTestCase.output_file_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.tmp.cleanup()", "def teardown(self):\n\n del self.testC, self.insts, self.testInst, self.dname, self.test_vals\n\n return", "def cleanup(self):\n super(Test200SmartSanityDownload004, self).cleanup()", "def teardown(self):\n del self.testInst, self...
[ "0.7640776", "0.74029046", "0.7368922", "0.7343883", "0.7318036", "0.7304285", "0.7304285", "0.7304285", "0.7271605", "0.7271605", "0.7271605", "0.7263641", "0.7263641", "0.7263641", "0.7233525", "0.72201914", "0.72102296", "0.72102296", "0.7205624", "0.7205624", "0.71853197"...
0.0
-1
Test argument parsing. Run the program with args_in. The program dumps its arguments to stdout. Compare the stdout with args_out.
def expect_args(self, args_in, args_out): filename = SettingsCommandTestCase.output_file_name outfile = self.getBuildArtifact(filename) if lldb.remote_platform: outfile_arg = os.path.join( lldb.remote_platform.GetWorkingDirectory(), filename ) el...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_parse_args(args):\n # Must return so that check command return value is passed back to calling routine\n # otherwise py.test will fail\n return main(parse_args(args))", "def main_parse_args(args):\n # Must return so that check command return value is passed back to calling routine\n # oth...
[ "0.70857084", "0.70857084", "0.6719469", "0.6544911", "0.64907324", "0.6395866", "0.6362561", "0.632354", "0.63156325", "0.62827814", "0.6258688", "0.6254855", "0.6252494", "0.62392056", "0.6207981", "0.61993474", "0.61984104", "0.61981714", "0.6184711", "0.61758745", "0.6159...
0.7031648
2
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
Responsible for generating the links that are located on the left side of individual technique domain pages
def get_technique_side_menu_data(domain, technique_list, tactic_list): # Get tactics techniques side menu data to fill out with jinja tactics_techniques_menu_data = [] for tactic in tactic_list: tactic_row = {} tactic_row['name'] = tactic['name'] tactic_row['id'] = util.ge...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getExpandedLinks():", "def make_navbar_for_homepage(self):\n links = [\n \"home\", [\"Result Pages\", self._result_page_links()], \"Version\"\n ]\n if len(self.samples) > 1:\n links[1][1] += [\"Comparison\"]\n if self.publication:\n links.insert(2,...
[ "0.603881", "0.59611195", "0.5923129", "0.5906821", "0.5832609", "0.58210886", "0.5725273", "0.5673449", "0.56281406", "0.558823", "0.55820566", "0.5566538", "0.5542917", "0.55155784", "0.5482084", "0.547729", "0.5472593", "0.54505503", "0.5410811", "0.5399908", "0.5361225", ...
0.0
-1
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
Create transform from (lon, lat) to (column, row) coordinates
def lonlat2cr_for_geotif(path): old_cs, new_cs, gta, local_vars = _create_xform(path) transform = osr.CoordinateTransformation(new_cs, old_cs) def composite(lon, lat): """xform from (lon, lat) to (c, r)""" if not -90 <= lat <= 90: raise ValueError('illegal lat value, did you swi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform_from_latlon(lat, lon):\n from affine import Affine\n lat = np.asarray(lat)\n lon = np.asarray(lon)\n trans = Affine.translation(lon[0], lat[0])\n scale = Affine.scale(lon[1] - lon[0], lat[1] - lat[0])\n return trans * scale", "def gen_gps_to_coords(lat,lon,rows,cols,min_lat,max_la...
[ "0.68157905", "0.66313314", "0.661171", "0.6593962", "0.6544747", "0.6531103", "0.6518472", "0.6451298", "0.6443582", "0.6433205", "0.63895917", "0.6381785", "0.63414675", "0.63401574", "0.6333194", "0.63325125", "0.6327625", "0.6324136", "0.6297547", "0.6277964", "0.6277665"...
0.0
-1
xform from (lon, lat) to (c, r)
def composite(lon, lat): if not -90 <= lat <= 90: raise ValueError('illegal lat value, did you switch coordinates') return (~gta * transform.TransformPoint(lat, lon)[:2])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def composite(c, r):\n x, y = gta * (c, r)\n lat, lon = transform.TransformPoint(x, y)[:2]\n if not -90 <= lat <= 90:\n raise ValueError('illegal lat value, did you switch coordinates')\n return lon, lat", "def merc(lat, lon):\n\tr_major = 6378137.000\n\tx = r_major * math....
[ "0.76137656", "0.69122946", "0.6881515", "0.68766624", "0.6610878", "0.65857524", "0.6521325", "0.64422315", "0.6299409", "0.62912303", "0.62782985", "0.62745625", "0.62368286", "0.6209349", "0.6204365", "0.6120023", "0.607636", "0.60706896", "0.6065761", "0.6049449", "0.6039...
0.5487496
85
Create transform from (column, row) to (lon, lat) coordinates
def cr2lonlat_for_geotif(path): old_cs, new_cs, gta, local_vars = _create_xform(path) transform = osr.CoordinateTransformation(old_cs, new_cs) def composite(c, r): """xform from (c, r) to (lon, lat)""" x, y = gta * (c, r) lat, lon = transform.TransformPoint(x, y)[:2] if not ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform_from_latlon(lat, lon):\n from affine import Affine\n lat = np.asarray(lat)\n lon = np.asarray(lon)\n trans = Affine.translation(lon[0], lat[0])\n scale = Affine.scale(lon[1] - lon[0], lat[1] - lat[0])\n return trans * scale", "def _build_geotransform(self, i, j):\n assert i...
[ "0.66467303", "0.6624821", "0.66023815", "0.65764207", "0.6559197", "0.6513407", "0.6504504", "0.6468915", "0.6444075", "0.63868356", "0.63452953", "0.63281846", "0.6316108", "0.6261537", "0.62128407", "0.61810315", "0.61589795", "0.6146225", "0.61366695", "0.61320674", "0.61...
0.5831346
56
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
Straighten an image that has been rotated and has blank (alpha == 0) corners
def straighten_image(img, scale=1): img = img[::scale, ::scale] blank = (img[:, :, 3] == 0) degrees = _find_angle(blank) if degrees > 45: degrees = degrees - 90 nr, nc = img.shape[:2] radians = np.radians(degrees) # Rotate image img = img.astype(float) / img.max() new_img = t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def straighten(image):\n gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n gray = cv2.bitwise_not(gray)\n thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]\n coords = np.column_stack(np.where(thresh > 0))\n angle = cv2.minAreaRect(coords)[-1]\n if angle < -45:\n a...
[ "0.7247929", "0.7087627", "0.6532112", "0.63538", "0.62858284", "0.6238983", "0.6210797", "0.62102747", "0.61778975", "0.61557895", "0.6126098", "0.61174065", "0.60648906", "0.6063642", "0.60582924", "0.6030168", "0.60160047", "0.60000926", "0.5985503", "0.59584457", "0.59356...
0.6804736
2
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