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
Iterate through self.extra_dominoes, start at random position. a generator of (domino, is_flipped) pairs. Each domino is returned twice, with True or False in random order.
def choose_and_flip_extra_dominoes(self, random): for domino in self.choose_extra_dominoes(random): if domino.head.pips == domino.tail.pips: yield domino, False else: flip_first = random.randint(0, 1) for j in range(2): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_extra_dominoes(self, random):\n dominoes = self.extra_dominoes[:]\n count = len(dominoes)\n start = random.randrange(count)\n for i in range(count):\n yield dominoes[(i + start) % count]", "def pickup_dominoes(self, num_dominoes, player):\n\n for domino in...
[ "0.7208414", "0.5903002", "0.5236969", "0.47793296", "0.4773952", "0.47145683", "0.46093652", "0.4590172", "0.45812768", "0.45804274", "0.45732227", "0.45460996", "0.4520758", "0.4515188", "0.44946986", "0.4483429", "0.44739068", "0.446823", "0.4457632", "0.44459644", "0.4417...
0.8199502
0
Fill any remaining holes in a board with random dominoes.
def fill(self, random, matches_allowed=True, reset_cycles=True): if reset_cycles: self.cycles_remaining = 10000 for y in range(self.height): for x in range(self.width): if self[x][y] is None: return self.fill_space(x, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generatePiece(self):\n\n empty_tiles = []\n for y in range(BOARD_SIZE):\n for x in range(BOARD_SIZE):\n if self.grid[x][y].isEmpty():\n empty_tiles.append(self.grid[x][y])\n\n two_or_four = random.choice([2, 4])\n random.choice(empty_tile...
[ "0.66953135", "0.66307515", "0.6221004", "0.61889106", "0.61411875", "0.6111304", "0.6097655", "0.60493696", "0.6027702", "0.60260206", "0.5993181", "0.5961893", "0.5957831", "0.59363246", "0.5921322", "0.5914031", "0.5912128", "0.5899322", "0.586239", "0.5824843", "0.5819278...
0.6348215
2
Try all possible dominoes and positions starting at x, y.
def fill_space(self, x, y, random, matches_allowed): rotation = random.randint(0, 3) * 90 for _ in range(4): try: choices = self.choose_and_flip_extra_dominoes( random) for domino, is_flipped in choices: if self.cycles_r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_neighbors(x: int, y: int) -> t.Generator[COORDINATE, None, None]:\n yield x - 1, y\n yield x + 1, y\n yield x, y - 1\n yield x, y + 1", "def get_valid_neighbors(self, x, y):\n\t\tx_1, x_2 = max(x-1, 0), min(x+1, self.width-1)\n\t\ty_1, y_2 = max(y-1, 0), min(y+1, self.height-1)\n\t\treturn [...
[ "0.6415961", "0.6168593", "0.6105088", "0.599384", "0.59264785", "0.57454664", "0.5723433", "0.56902546", "0.5687131", "0.5655497", "0.55992746", "0.55781144", "0.5574971", "0.5547561", "0.5546644", "0.55269146", "0.5513151", "0.5504241", "0.5485868", "0.547279", "0.5455407",...
0.5182411
75
Get a direction by name.
def get_direction(self, name): index = Domino.direction_names.find(name) return Domino.directions[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_direction(self, string):\r\n return Direction.query(\r\n or_(Direction.name == string, Direction.short_name == string)\r\n ).first()", "def getDirection(self, direction: str):\n return direction", "def get_direction(self, start_direction, **kwargs):\n return sel...
[ "0.65444416", "0.644363", "0.6317267", "0.58342814", "0.5821944", "0.5821525", "0.57715315", "0.57485586", "0.56602365", "0.56146896", "0.56140655", "0.5608703", "0.5557051", "0.5557051", "0.55225646", "0.54623437", "0.54026246", "0.5378701", "0.5376569", "0.5370104", "0.5360...
0.81401694
0
True if either cell matches one of its neighbours. Slightly different type of matching from isMatch().
def hasMatch(self): for cell in (self.head, self.tail): for neighbour in cell.find_neighbours(): if neighbour.pips == cell.pips: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_neighbours(self):\n for p in self.targetCell.possibilities:\n if p != 0:\n if p not in self.targetCell.row_neighbour_possibilities:\n self.targetCell.solve(p)\n return True\n elif p not in self.targetCell.column_neighbo...
[ "0.6724939", "0.65565187", "0.651675", "0.6491993", "0.64436924", "0.64371634", "0.64162314", "0.64157915", "0.64040434", "0.64029574", "0.6330807", "0.6311212", "0.62970114", "0.625364", "0.6251876", "0.62480813", "0.6242117", "0.62384665", "0.6207678", "0.6207055", "0.61696...
0.7738691
0
Create a smaller copy of this object to pass to worker process.
def clone(self) -> 'BoardGraph': return self.__class__(self.board_class)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __copy__(self):\n return self.__constructor__(\n self._data,\n length=self._length_cache,\n width=self._width_cache,\n ip=self._ip_cache,\n call_queue=self.call_queue,\n )", "def copy (self):\n return self.__class__(self.name, self[:...
[ "0.6662542", "0.64063597", "0.63941157", "0.6390088", "0.63717836", "0.63605547", "0.63560516", "0.6349903", "0.6349903", "0.6298009", "0.6234194", "0.6204179", "0.6184515", "0.61842054", "0.61738104", "0.61686826", "0.6168217", "0.6144363", "0.6136073", "0.61004347", "0.6097...
0.0
-1
Generate all moves from the board's current state.
def generate_moves(self, board: Board) -> typing.Iterator[MoveDescription]: dominoes = set(board.dominoes) for domino in dominoes: dx, dy = domino.direction yield from self.try_move(domino, dx, dy) yield from self.try_move(domino, -dx, -dy)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_replay(self) -> Generator[List[List[str]], None, None]:\n current_moves = OrderedDict()\n for move in self.moves:\n current_moves[move] = self.moves[move]\n yield self.compile_board(current_moves)", "def get_next_moves1(self):\n moves = []\n for ...
[ "0.7687294", "0.75485986", "0.7526451", "0.73771197", "0.7353344", "0.7320948", "0.7244764", "0.72096926", "0.71489346", "0.7104699", "0.7087352", "0.70759535", "0.7061898", "0.7032542", "0.7012025", "0.69028956", "0.6886255", "0.68502146", "0.6826952", "0.6810871", "0.678000...
0.6947321
15
Check how close a board state is to a solution.
def check_progress(self, board: Board) -> int: dominoes = set(board.dominoes) domino_count = len(dominoes) return domino_count
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def goal_test(self, state):\n return state.board==range(self.N*self.N)", "def game_value(self, state):\n # check horizontal wins\n for row in state:\n for i in range(2):\n if row[i] != ' ' and row[i] == row[i+1] == row[i+2] == row[i+3]:\n return 1...
[ "0.6641022", "0.6587507", "0.65672845", "0.6506069", "0.6476153", "0.64679784", "0.6447769", "0.64371794", "0.6434607", "0.6403322", "0.6369696", "0.633765", "0.6321402", "0.6298924", "0.6291309", "0.6289576", "0.6285071", "0.6282994", "0.6243411", "0.6233561", "0.6229891", ...
0.0
-1
Move a domino and calculate the new board state. Afterward, put the board back in its original state.
def move(self, domino, dx, dy) -> typing.Tuple[str, int]: domino.move(dx, dy) try: board = domino.head.board if not board.is_connected(): raise BadPositionError('Board is not connected.') if board.has_loner(): raise BadPositionError('Bo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self, domino, dx, dy, offset=None):\n matching_dominoes = set()\n complement_found = False\n domino.move(dx, dy)\n board = domino.head.board\n try:\n if not board.is_connected():\n raise BadPositionError('Board is not connected after move.')\n ...
[ "0.7599279", "0.6890704", "0.6870524", "0.6765509", "0.6765455", "0.67173713", "0.6701276", "0.66965497", "0.66819054", "0.6667514", "0.6663559", "0.66578156", "0.66204715", "0.657253", "0.65490776", "0.6526394", "0.6526335", "0.6520004", "0.6495556", "0.6494918", "0.6452767"...
0.7041228
1
Find a solution from the graph of moves.
def get_solution(self, return_partial=False, solution_nodes=None): solution = [] if solution_nodes is None: solution_nodes = self.get_solution_nodes(return_partial) for i in range(len(solution_nodes)-1): source, target = solution_nodes[i:i+2] solution.append(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_solution(self):\n start_time = time.clock()\n frontier = [Node(self, None, 0, None)]\n explored = []\n visited = 0\n\n while True:\n visited += 1\n # pop the lowest value from the frontier (sorted using bisect, so pop(0) is the lowest)\n n...
[ "0.6948969", "0.6945463", "0.6844808", "0.6760467", "0.67420334", "0.669188", "0.6654858", "0.66528285", "0.6647661", "0.65487176", "0.65396374", "0.6538588", "0.6532799", "0.6524817", "0.6484505", "0.64668554", "0.64626557", "0.6455783", "0.6454573", "0.64381254", "0.6419061...
0.6077739
74
Move a domino and calculate the new board state. Afterward, put the board back in its original state.
def move(self, domino, dx, dy, offset=None): matching_dominoes = set() complement_found = False domino.move(dx, dy) board = domino.head.board try: if not board.is_connected(): raise BadPositionError('Board is not connected after move.') for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self, domino, dx, dy) -> typing.Tuple[str, int]:\n domino.move(dx, dy)\n try:\n board = domino.head.board\n if not board.is_connected():\n raise BadPositionError('Board is not connected.')\n if board.has_loner():\n raise BadPosit...
[ "0.7041228", "0.6890704", "0.6870524", "0.6765509", "0.6765455", "0.67173713", "0.6701276", "0.66965497", "0.66819054", "0.6667514", "0.6663559", "0.66578156", "0.66204715", "0.657253", "0.65490776", "0.6526394", "0.6526335", "0.6520004", "0.6495556", "0.6494918", "0.6452767"...
0.7599279
0
Decorator for issuing multiple http requests
def _return_response(cls, func): argspec = inspect.getfullargspec(func) @wraps(func) def wrapper(self, *args, **kwargs): func_name = func(self, *args, **kwargs) params = {'apikey':self.apikey, 'function':func_name} base_url = AlphaVantageDecorator._ENDPOINT for arg_name in argspec.args[1:]: # request...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def run_requests(self):\n loop = asyncio.get_event_loop()\n tasks = []\n async with aiohttp.ClientSession(connector=self.connector) as session:\n\n for index, id in enumerate(self.ids):\n if id not in self.processed_ids:\n url = self.base_url ...
[ "0.61410576", "0.6138692", "0.59472036", "0.59395415", "0.5802204", "0.5770221", "0.5767999", "0.57490396", "0.5704602", "0.5683102", "0.5680795", "0.56755716", "0.5667314", "0.5650187", "0.5645092", "0.56253076", "0.56051934", "0.55997926", "0.55630124", "0.5544833", "0.5524...
0.51747566
71
Logger for info and debugging
def _logger(cls, func): @wraps(func) def wrapper(self, *args, **kwargs): logging.info('func - {}, args - {}, kwargs - {}'.format(func.__name__, args, kwargs)) return func(*args, **kwargs) return wrapper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def demo_log(self):\n self.logger.debug('This is a debug')\n self.logger.debug(self.name)\n self.logger.debug(self.doc)", "def log_info():\n # Get an instance of a logger\n logging.basicConfig(level=logging.DEBUG)\n return logging.getLogger('general')", "def debug(self, tag, messa...
[ "0.7785035", "0.7727039", "0.7579996", "0.7466447", "0.7413452", "0.73579514", "0.7337026", "0.7331997", "0.7299061", "0.7261084", "0.72499794", "0.7196792", "0.7175254", "0.7174347", "0.7151619", "0.7131409", "0.7117388", "0.71168184", "0.7082517", "0.7082029", "0.70723045",...
0.0
-1
Attempts to exploit a ColdFusion file disclosure vulnerability to retrieve a hashed admin password. If found, this script will produce a hash to be used to bypass admin login by computing the value of the admin hash and a ColdFusion salt input parameter.
def retrieve_hash(host, salt): password_pattern = re.compile(r'\npassword=(.+)\r') url = 'http://%s/CFIDE/administrator/enter.cfm?locale=../../../../../../../../../../ColdFusion8/lib/password.properties%%00en' % host try: response = requests.post(url) password_hash = re.search(pass...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_hash(masterpw, password, args):\n salt_hasher = hmac.new(masterpw, digestmod=DIGEST)\n\n if args.salt_url is not None:\n print(\"[INFO] Using resource at URL as salt ...\")\n with urlopen(args.salt_url) as f:\n while True:\n data = f.read(128)\n ...
[ "0.56448627", "0.55366296", "0.54568374", "0.54494023", "0.53573483", "0.533294", "0.5329196", "0.5288839", "0.52837366", "0.5233808", "0.52312523", "0.5218411", "0.51976466", "0.5186236", "0.5183251", "0.51653415", "0.5149853", "0.51409924", "0.5114079", "0.51067483", "0.509...
0.6947036
0
This routine is for generation of UDP flows using pktgen. Only UDP packets are generated using this routine.
def start_traffic_pktgen( vm_fix, src_min_ip='', src_max_ip='', dest_ip='', dest_min_port='', dest_max_port=''): vm_fix.logger.info("Sending traffic...") try: cmd = '~/pktgen_new.sh %s %s %s %s %s' % (src_min_ip, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_udp_pkt(src=None, dst=None, payload_len=-1):\n getipaddr = lambda addr: rand_ipaddr() if addr is None else addr\n sip = getipaddr(src)\n dip = getipaddr(dst)\n payload = get_payload(payload_len)\n pkt = fuzz(IP(src=sip, dst=dip)/UDP())/payload\n # pkt.show2()\n # os.write(2, str(pkt))\...
[ "0.69952375", "0.6753392", "0.62750065", "0.61651886", "0.6104409", "0.6053558", "0.6030146", "0.5923889", "0.57885873", "0.57851034", "0.5730775", "0.5703929", "0.5686091", "0.5664387", "0.56469774", "0.5626165", "0.5607047", "0.5603519", "0.55522037", "0.54991364", "0.54808...
0.56683207
13
This method starts traffic between VMs using pktgen
def start_traffic_pktgen_between_vm( sr_vm_fix, dst_vm_fix, dest_min_port=10000, dest_max_port=10000): start_traffic_pktgen( sr_vm_fix, src_min_ip=sr_vm_fix.vm_ip, src_max_ip=sr_vm_fix.vm_ip, dest_ip=dst_vm_fix.vm_ip, dest_min_port=dest_min_po...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_traffic_pktgen(\n vm_fix,\n src_min_ip='',\n src_max_ip='',\n dest_ip='',\n dest_min_port='',\n dest_max_port=''):\n vm_fix.logger.info(\"Sending traffic...\")\n try:\n cmd = '~/pktgen_new.sh %s %s %s %s %s' % (src_min_ip,\n ...
[ "0.7372693", "0.59777474", "0.58827966", "0.5760567", "0.5757512", "0.5692496", "0.5627953", "0.5596239", "0.5572661", "0.5571036", "0.55461", "0.55419725", "0.55401415", "0.5530725", "0.552947", "0.55276793", "0.5517556", "0.5503944", "0.54876393", "0.5487193", "0.5486951", ...
0.664063
1
Accesses a topic viewer page.
def get(self, topic_name: str) -> None: topic = topic_fetchers.get_topic_by_name(topic_name) canonical_story_ids = topic.get_canonical_story_ids( include_only_published=True) additional_story_ids = topic.get_additional_story_ids( include_only_published=True) cano...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topic(request, topic_id):\n posts = Post.objects.filter(topic=topic_id).order_by(\"created\")\n posts = mk_paginator(request, posts, DJANGO_SIMPLE_FORUM_REPLIES_PER_PAGE)\n topic = Topic.objects.get(pk=topic_id)\n return render_to_response(\"forum/topic.html\", add_csrf(request, posts=posts, pk=top...
[ "0.6657337", "0.6631817", "0.6620546", "0.66133547", "0.6364716", "0.61645633", "0.60999537", "0.5886278", "0.5870889", "0.57333785", "0.5714898", "0.570398", "0.5697183", "0.5550665", "0.5549936", "0.55430144", "0.5496878", "0.549279", "0.5485409", "0.547195", "0.54691803", ...
0.0
-1
Parse the Journal head
def ParsePageHead(read): page_head = {} result = struct.unpack_from(PageHeadFormat, read, 0) for i in xrange(len(PageHeadProperties)): page_head[PageHeadProperties[i]] = result[i] return page_head
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_header(self):\n bodystart=re.compile(r\"<body>\", re.IGNORECASE).search(self.lines).span()[1]\n oldheader=self.lines[0:bodystart]\n start=re.compile(\"<title>\", re.IGNORECASE).search(oldheader).span()[1]\n finish=re.compile(\"</title>\", re.IGNORECASE).search(oldheader).span(...
[ "0.6171695", "0.61086303", "0.60351753", "0.60184866", "0.58766985", "0.58121574", "0.57135296", "0.5654955", "0.5542627", "0.5479059", "0.5463076", "0.54042464", "0.53687775", "0.5368292", "0.5324605", "0.5276549", "0.5274114", "0.52684", "0.51968133", "0.5187109", "0.518307...
0.51219124
25
get output file's raw name, without .txt or .csv
def get_output_raw_name(journal_file_name, output_type='txt'): dot_pos = journal_file_name.rfind('.') if dot_pos != -1: output_file_name = journal_file_name[0: dot_pos] else: output_file_name = journal_file_name num_of_output = 1 if output_type == 'txt': while True: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getOutputFilename(self, filename):\n return filename[:-4] + \".txt\"", "def get_file_name(self):\n return str(self.get_file())", "def _get_output_filename(dataset_dir, split_name):\n return '%s/%s*.tfrecord' % (dataset_dir, split_name)", "def _get_raw_output_fp(self, output_dir, params):...
[ "0.74351394", "0.7248863", "0.72257614", "0.7196246", "0.70979714", "0.7075223", "0.7033236", "0.7024702", "0.7010298", "0.698268", "0.6951329", "0.6924173", "0.69214404", "0.691918", "0.6910793", "0.69105744", "0.6872355", "0.6843693", "0.6799241", "0.6777324", "0.67486", ...
0.7691399
0
Apply base theme to the application.
def _apply_base_theme(self, app): app.setStyle("Fusion") with open(self._STYLESHEET) as stylesheet: app.setStyleSheet(stylesheet.read())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_theme(self, ax):\n pass", "def apply_style(self, app):\n\n darkPalette = QPalette()\n\n # base\n darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180))\n darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))\n darkPalette.setColor(QPalette.Light, ...
[ "0.71454114", "0.7026285", "0.7016173", "0.6658857", "0.66372305", "0.6465947", "0.6465947", "0.6419377", "0.63436294", "0.6121915", "0.60901904", "0.607666", "0.6037439", "0.5978628", "0.5909347", "0.5894715", "0.5894359", "0.5853654", "0.5733367", "0.5661598", "0.56274146",...
0.83967525
0
Apply Dark Theme to the Qt application instance.
def apply_style(self, app): darkPalette = QPalette() # base darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180)) darkPalette.setColor(QPalette.Button, QColor(53, 53, 53)) darkPalette.setColor(QPalette.Light, QColor(180, 180, 180)) darkPalette.setColor(QPalet...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dark_theme(self):\n if self.actionDark_Theme.isChecked():\n QApplication.setStyle(QStyleFactory.create(\"Fusion\"))\n palette = QPalette()\n palette.setColor(QPalette.Window, QColor(53, 53, 53))\n palette.setColor(QPalette.WindowText, Qt.white)\n pa...
[ "0.8299862", "0.77994823", "0.7793831", "0.7326548", "0.710293", "0.62984896", "0.627744", "0.61767536", "0.6167514", "0.615951", "0.6017849", "0.5933398", "0.5875817", "0.58577627", "0.5841447", "0.5615513", "0.56107634", "0.55707407", "0.5564432", "0.5564432", "0.55601716",...
0.76089656
3
Apply Light Theme to the Qt application instance.
def apply_style(self, app): lightPalette = QPalette() # base lightPalette.setColor(QPalette.WindowText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.Button, QColor(240, 240, 240)) lightPalette.setColor(QPalette.Light, QColor(180, 180, 180)) lightPalette.setColor(QPal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_theme(self):\n # get the QApplication instance, or crash if not set\n app = QtWidgets.QApplication.instance()\n if app is None:\n raise RuntimeError(\"No Qt Application found.\")\n\n if self.darkCheckBox.isChecked():\n app.setStyleSheet(qdarkstyle.load_...
[ "0.73362345", "0.7268235", "0.6951579", "0.6824019", "0.67134887", "0.61943114", "0.61578697", "0.61033326", "0.6091632", "0.6071398", "0.60527337", "0.5875625", "0.5875625", "0.58475655", "0.57241774", "0.57137465", "0.5653085", "0.5578202", "0.54841846", "0.54613185", "0.54...
0.743344
0
Create new entity returning uuid of created record
def create_entity(data: dict) -> str: new_uuid = str(uuid4()) Entity.create(uuid=new_uuid, data=data["data"]) return new_uuid
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_instance(**kwargs):\n ctxt = context.get_admin_context()\n return db.instance_create(ctxt, _create_instance_dict(**kwargs))['id']", "def new(self):\n uuid = uuid4().hex\n cur = self.conn.cursor()\n cur.execute(\n \"\"\"\n INSERT INTO experiments (uuid)\n ...
[ "0.6654303", "0.6614401", "0.6504342", "0.64369875", "0.6267132", "0.6234407", "0.62021786", "0.62021786", "0.61904436", "0.6179102", "0.613219", "0.61154836", "0.60848325", "0.6072805", "0.60569495", "0.6037746", "0.6018132", "0.6005871", "0.6001378", "0.59915316", "0.599153...
0.7855162
0
determine langage used base on the extension
def identifyLangage(script): langage = "undefined" scriptNameInArray = script.split(".") extension = scriptNameInArray[-1] if(extension == "pl"): langage = "perl" elif(extension == "py"): langage = "python" elif(extension == "sh"): langage = "bash" else: langage == "not recognised" return langage
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lang(self):\n return self.langs.lang", "def get_language(self, article):\r\n # we don't want to force the target laguage\r\n # so we use the article.meta_lang\r\n if self.config.use_meta_language == True:\r\n if article.meta_lang:\r\n return article.m...
[ "0.717291", "0.71475804", "0.70080835", "0.70027035", "0.69902664", "0.698173", "0.6898868", "0.6871327", "0.6855876", "0.68457574", "0.6826537", "0.6808138", "0.6802423", "0.6731631", "0.6702847", "0.668899", "0.664422", "0.6610783", "0.6597736", "0.6578168", "0.65664876", ...
0.75546545
0
Get the stderr of script
def getErrors(script): p = subprocess.Popen(['./'+script], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() return err
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_stderr(self):\n return self._get_log('stderr')", "def stderr(self) -> str:\n _args: list[Arg] = []\n _ctx = self._select(\"stderr\", _args)\n return _ctx.execute_sync(str)", "def result_stderr(result):\n return result[1][1]", "def stderr(self):\n return self.__stderr...
[ "0.80331707", "0.77476525", "0.77177006", "0.7631188", "0.73205614", "0.72101223", "0.7183124", "0.7134146", "0.7087779", "0.70248073", "0.6913695", "0.6896512", "0.6791896", "0.66601497", "0.66361713", "0.65947324", "0.64891607", "0.64813185", "0.63999623", "0.6331216", "0.6...
0.79301566
1
scan script for simple errors
def scanForSimpleError(script): langage = identifyLangage(script) line_number = 0 logFile_name = "scan.log" # Scanning File logFile = open(logFile_name, 'w') scriptFile = open(script, 'r') for line in scriptFile: line_number +=1 lineWithoutBackN = line.replace("\n", "") lineInArray = lineWithoutBackN.spli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan_error(self, line: int, message: str):\n self.report(line, \"\", message)", "def error_check(command):\r\n\r\n # TODO\r", "def check_errors(self) -> None:", "def check_errors():\n\n for error in errors:\n ERROR('%s' % str(error))\n\n if len(errors) != 0:\n sys.exit(1)", ...
[ "0.6841208", "0.68405724", "0.66131353", "0.6445967", "0.6399118", "0.6177685", "0.61256075", "0.6095763", "0.6076316", "0.6045332", "0.60325944", "0.5948576", "0.5919206", "0.5869653", "0.58674383", "0.58112127", "0.5804113", "0.5793846", "0.57393223", "0.57348496", "0.57310...
0.754085
0
fixe script using log of the scan function Is working but need several pass for multiple errors on same line
def fixSimpleError(scan_log, script): # save original script # create model file scriptInArray = script.split(".") dst = scriptInArray[0]+"_save."+scriptInArray[1] model = scriptInArray[0]+"_model."+scriptInArray[1] copyfile(script, dst) copyfile(script, model) # open log file fileLog = open(scan_log, "r") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scanForSimpleError(script):\n\tlangage = identifyLangage(script)\n\tline_number = 0\n\tlogFile_name = \"scan.log\"\n\n\t# Scanning File\n\tlogFile = open(logFile_name, 'w')\n\tscriptFile = open(script, 'r')\n\tfor line in scriptFile:\n\t\tline_number +=1\n\t\tlineWithoutBackN = line.replace(\"\\n\", \"\")\n\t\...
[ "0.67336774", "0.64371395", "0.6261081", "0.6214104", "0.5969992", "0.58345926", "0.5819728", "0.5748759", "0.57192427", "0.5687304", "0.56308526", "0.56277806", "0.5606772", "0.559432", "0.55892843", "0.55892843", "0.5573461", "0.5558475", "0.5552363", "0.55447894", "0.55432...
0.6165698
4
Identify simple errors [UNFINISHED]
def IdentifySimpleError(langage, errorLog): if(langage == "perl"): errorLogInArray = errorLog.split(" ") if(errorLogInArray[0] == "syntax" and errorLogInArray[1] == "error"): if (errorLogInArray[4] == "line"): errorLineInArray = errorLogInArray[5].split(",") errorLine = int(errorLineInArray[0])-1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_errors(self) -> None:", "def has_errors(self) -> bool:", "def identify_result_error(self, record):\n return [\"error\"]", "def error(self):\n ...", "def errors(self):\n raise NotImplementedError", "def get_short_errors(self):\n if not self.was_successful():\n ...
[ "0.70311564", "0.68223935", "0.6774739", "0.65763986", "0.657623", "0.65213794", "0.65057683", "0.6467196", "0.64508605", "0.6433878", "0.6424665", "0.6399238", "0.6345873", "0.6332129", "0.6325519", "0.6299628", "0.6247677", "0.6227118", "0.621859", "0.6214397", "0.621159", ...
0.61665934
25
Returns a representation given a batch of raw observations.
def compute_full_representation(self, x, training=None): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batchify(batch):\n\n\tquestion_len = list()\n\tlabel_list = list()\n\tfor ex in batch:\n\t\tquestion_len.append(len(ex[0]))\n\t\tlabel_list.append(ex[1])\n\n\t'''\n\tPadding the labels - unequal length sequences for sequenial data like we have. \n\tSince actual labels are 0/1 - we pad with -1, and will use thi...
[ "0.5871176", "0.5809071", "0.5725259", "0.5611394", "0.553202", "0.5515099", "0.5494135", "0.5455625", "0.5416254", "0.5381305", "0.5371014", "0.53222305", "0.5319968", "0.53115827", "0.52698505", "0.5269598", "0.5249466", "0.5247259", "0.52394205", "0.52348226", "0.52166593"...
0.0
-1
Returns the loss function that will be used to train the encoder.
def get_loss_fn(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_loss_fn():\n return reconstruction", "def get_loss(self):\n raise NotImplementedError", "def loss(self):\n return 'mse'", "def loss_op(self):\n return self.loss", "def get_loss_function(loss):\n try:\n\n loss_func_map = {\"sparse_softmax_cross_entropy\": tf.losses....
[ "0.7495766", "0.7134641", "0.70509577", "0.7038898", "0.6990812", "0.6928303", "0.6885967", "0.68388313", "0.6784255", "0.6783532", "0.67699516", "0.6748856", "0.672302", "0.66822994", "0.66506594", "0.6647998", "0.6568442", "0.6567009", "0.65539795", "0.65407044", "0.6529401...
0.77475625
0
Returns the size of the representation.
def get_representation_size(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size(self):\r\n return self.info().size", "def size (self):\n\t\timport struct\n\t\treturn struct.calcsize (self.struct)", "def size(self):\r\n return self._size", "def size(self):\n # type: () -> string_types\n return self._size", "def size(self):\n return self.__size", ...
[ "0.83479226", "0.83057487", "0.82931733", "0.8279536", "0.8264634", "0.8264634", "0.8264634", "0.8264634", "0.8264634", "0.8264576", "0.82553595", "0.8245518", "0.8245518", "0.8245518", "0.82341105", "0.82209253", "0.8216626", "0.8215871", "0.8215871", "0.8215871", "0.8215871...
0.818457
40
Return the state if the dataset requires one. Datasets which e.g. read files from disks require open file handlers, and this sort of stateful information should be handled by the data stream. Returns
def open(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_dataset(self):\n return self._dataset is not None", "def isOpened(self) -> bool:\n return True if self.data_file else False", "def __getstate__(self):\n return [self.dataset, self.parser]", "def read_data(self):\r\n read_status = True\r\n lines = self.__read_lines__()\r\...
[ "0.6283819", "0.6104138", "0.59465337", "0.5871984", "0.58360755", "0.58360755", "0.5735881", "0.5735", "0.5720222", "0.5720222", "0.5703286", "0.5658094", "0.565653", "0.5642201", "0.5624983", "0.5605287", "0.5590852", "0.5588724", "0.5578193", "0.5546453", "0.5546068", "0...
0.0
-1
Resets the state. Returns
def reset(self, state): self.close(state) return self.open()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.set_state(self._initial_state)", "def reset(self):\n self.state.fill(EMPTY)", "def reset(self):\n self.state = copy.copy(self.mu)", "def reset(self):\n self.state = copy.copy(self.mu)", "def reset(self):\n self.state = copy.copy(self.mu)", "def r...
[ "0.86699235", "0.8570231", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.82631886", "0.8260696", "0.82180303", "0.81856394", "0.81699526", "0.81641394", "0.81495494", "0.80976254", ...
0.7932665
78
Switches the dataset state to the next epoch. The default implementation for this method is to reset the state. Returns
def next_epoch(self, state): return self.reset(state)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_epoch(self):\n self._curr_batch = 0\n if self.shuffle_order:\n self.shuffle()", "def _reset(self):\n np.random.shuffle(self.id)\n self.episode_step = 0 # Reset episode step counter at the end of every episode\n self._state = self.X_train[self.id[self.episode...
[ "0.73462296", "0.69393736", "0.6755204", "0.6629461", "0.6506496", "0.646609", "0.6465896", "0.6438578", "0.6374113", "0.6371389", "0.6335564", "0.63048464", "0.628498", "0.6273848", "0.62642074", "0.6264049", "0.6257736", "0.6157545", "0.6111303", "0.60934657", "0.6084503", ...
0.7705791
0
Cleanly close the dataset e.g. close file handles.
def close(self, state): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\n self.data.close()", "def close_raster_file(self):\n try:\n if self.dataset:\n del self.dataset\n self.dataset = None\n except AttributeError:\n pass", "def close(self):\n self._ds = None\n self._schema = N...
[ "0.7750784", "0.77349025", "0.76858103", "0.76858103", "0.76599306", "0.73445404", "0.7042353", "0.7028149", "0.70259005", "0.699551", "0.6992215", "0.699024", "0.69872534", "0.69787323", "0.69787323", "0.69787323", "0.69787323", "0.69787323", "0.69787323", "0.69787323", "0.6...
0.0
-1
Request data from the dataset.
def get_data(self, state=None, request=None): raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_data(self):\n pass", "def _fetch_data(self, samples):\n pass", "def _fetch_data(self):\n pass", "def fetch_data(self):", "def get_data():\n pass", "def get(id: str) -> DataSet:\n pass", "def download_dataset(self):\n raise NotImplementedError", "d...
[ "0.70144516", "0.6764992", "0.67043954", "0.668935", "0.6603808", "0.6480153", "0.6456423", "0.642233", "0.6313345", "0.6313345", "0.63009125", "0.6277616", "0.6271615", "0.6270388", "0.6261579", "0.6259656", "0.6259656", "0.6259656", "0.6247137", "0.622092", "0.6189023", "...
0.66428065
4
Use the default iteration scheme to construct a data stream.
def get_default_stream(self): if not hasattr(self, 'default_scheme'): raise ValueError("Dataset does not provide a default iterator") return DataStream(self, iteration_scheme=self.default_scheme)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_data_iterator(input):\n assert isinstance(input, DataLoader)\n data_iterator = iter(input)\n return data_iterator", "def __iter__(self):\n\n # Open the data reader\n self.data.open()\n\n starts = np.arange(self.start, self.stop, self.chunksize)\n for a, b in zip_long...
[ "0.6576385", "0.6544374", "0.63232946", "0.6247353", "0.6233099", "0.62073475", "0.618729", "0.61413085", "0.61413085", "0.61413085", "0.61316687", "0.60305387", "0.6023972", "0.6003705", "0.5974357", "0.5966117", "0.5944801", "0.594095", "0.5936904", "0.59299433", "0.5929826...
0.6743139
0
Filter the requested sources from those provided by the dataset. A dataset can be asked to provide only a subset of the sources it can provide (e.g. asking MNIST only for the features, not for the labels). A dataset can choose to use this information to e.g. only load the requested sources into memory. However, in case...
def filter_sources(self, data): return tuple([d for d, s in zip(data, self.provides_sources) if s in self.sources])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_new_sourcedatasets(self):\n previous_study_version = self.get_previous_version()\n SourceDataset = apps.get_model('trait_browser', 'SourceDataset')\n if previous_study_version is not None:\n qs = SourceDataset.objects.filter(source_study_version=self)\n # We can p...
[ "0.6109405", "0.6090112", "0.59479564", "0.58847076", "0.5806422", "0.56509817", "0.5643852", "0.5635574", "0.5618711", "0.5561764", "0.55469316", "0.5468559", "0.5457959", "0.54406905", "0.5426888", "0.53734815", "0.53640324", "0.5352967", "0.5352967", "0.5352967", "0.532246...
0.69611335
0
Load data from e.g. the file system. Any interaction with the outside world e.g. the file system, database connections, servers, etc. should be done in this method. This allows datasets to be pickled and unpickled, even in environments where the original data is unavailable or has changed position.
def load(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_data(self):\n\n # This allows a simulated dataset to use the same constructor.\n if self.input_file is None:\n return\n\n logging.info(f\"Loading data from file {self.input_file}\")\n\n # Load the dataset.\n if os.path.isdir(self.input_file):\n sel...
[ "0.7141625", "0.70812446", "0.6996258", "0.6739241", "0.671555", "0.66502666", "0.66256225", "0.66122127", "0.660477", "0.6554516", "0.65081316", "0.6492618", "0.6394391", "0.63342303", "0.6333271", "0.63321525", "0.63236", "0.63203585", "0.63146406", "0.63104624", "0.6305116...
0.0
-1
r"""Decorator to assign lazy properties.
def lazy_properties(*lazy_properties): def lazy_property_factory(lazy_property): """Create properties that perform lazy loading of attributes.""" def lazy_property_getter(self): if not hasattr(self, '_' + lazy_property): self.load() if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lazyprop(fn):\n\n @property\n def _lazyprop(self):\n if not hasattr(self, _LAZY_PROP_VALUES):\n setattr(self, _LAZY_PROP_VALUES, {})\n lazy_props_dict = self.__dict__[_LAZY_PROP_VALUES]\n if fn.__name__ not in lazy_props_dict:\n lazy_props_dict[fn.__name__] = fn...
[ "0.8049432", "0.7841857", "0.7502832", "0.7430036", "0.70390606", "0.6653071", "0.6615944", "0.6382133", "0.6360276", "0.6321418", "0.6294221", "0.6286034", "0.62268466", "0.6226058", "0.6203311", "0.61819655", "0.6177798", "0.6024198", "0.60222995", "0.6020153", "0.60117716"...
0.70495415
4
Create properties that perform lazy loading of attributes.
def lazy_property_factory(lazy_property): def lazy_property_getter(self): if not hasattr(self, '_' + lazy_property): self.load() if not hasattr(self, '_' + lazy_property): raise ValueError("{} wasn't loaded".format(lazy_property)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lazy_properties(*lazy_properties):\n def lazy_property_factory(lazy_property):\n \"\"\"Create properties that perform lazy loading of attributes.\"\"\"\n def lazy_property_getter(self):\n if not hasattr(self, '_' + lazy_property):\n self.load()\n ...
[ "0.70922816", "0.6685102", "0.6428715", "0.6299822", "0.6247607", "0.5921087", "0.5776609", "0.5761453", "0.57289666", "0.56989306", "0.5629627", "0.56074035", "0.5563408", "0.55521804", "0.55443585", "0.55443585", "0.55443585", "0.5507907", "0.547553", "0.5448069", "0.543360...
0.7106498
0
Write dummy data to a pickle file to test data_loader
def setUpClass(cls): cls.test_file_1 = "/tmp/test_data_loader_dummy_1.pkl" cls.test_file_2 = "/tmp/test_data_loader_dummy_2.pkl" cls.in_cols = ["file", "id", "len", "seq", "phyche", "pssm", "logits", "ss", "h_0", "h_1", "h_2", "lm_logits"] cls.out_cols = ["dataset"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_pickle_save(self):\n l = [1, 2, 3, 4, 5]\n self.plugin.save_data(l)", "def generate_test_data(obj, name):\n with open('tests/{}'.format(name), 'wb') as f:\n pickle.dump(obj, f)", "def write_data():\n\n data_location = os.path.realpath(os.path.join(os.path.dirname(__file__), ...
[ "0.70575863", "0.698519", "0.6909019", "0.6814289", "0.6714272", "0.6623098", "0.6600464", "0.65858126", "0.65789527", "0.6576893", "0.65427506", "0.6518593", "0.64903533", "0.6473973", "0.6354887", "0.63534415", "0.63029104", "0.62939644", "0.6272786", "0.62551713", "0.61984...
0.57441884
70
Construct a TensorFlow data iterator.
def load_array(data_arrays, batch_size, is_train=True): #@save dataset = tf.data.Dataset.from_tensor_slices(data_arrays) if is_train: dataset = dataset.shuffle(buffer_size=1000) dataset = dataset.batch(batch_size) return dataset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_data_iterator(train_size, n, shuffle, prec=tf.float32):\n\n ph_batch_size = tf.placeholder(tf.int64)\n data_x = tf.placeholder(dtype=prec, shape = [None, n,n], name='data_x');\n data_label = tf.placeholder(dtype=prec, shape = [None, 1], name='data_label') \n\n if shuffle:\n train_...
[ "0.7453825", "0.7260238", "0.7010937", "0.6886433", "0.6867274", "0.68346286", "0.67860144", "0.6771582", "0.674272", "0.66766465", "0.6672481", "0.6618134", "0.6587647", "0.65850115", "0.6532677", "0.6509443", "0.648623", "0.6439111", "0.6400993", "0.63446546", "0.63277245",...
0.0
-1
Download the FashionMNIST dataset and then load it into memory.
def load_data_fashion_mnist(batch_size, resize=None): #@save (x_train, y_train), (x_test,y_test) = tf.keras.datasets.fashion_mnist.load_data() x_train,x_test = x_train/255, x_test/255 print(y_train.shape) # Divide all numbers by 255 so that all pixel values are between # 0 and 1, add a batch dimen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_mnist(dataset_name='mnist', **kwargs):\n dataset_name = dataset_name.strip().lower().replace('minist', 'mnist')\n\n if dataset_name.lower() not in ['mnist', 'fashion-mnist']:\n raise ValueError('Only mnist or fashion-mnist are valid dataset_name.')\n\n base = 'http://yann.lecun.com/exdb/m...
[ "0.71234226", "0.7064415", "0.7033558", "0.6991901", "0.6874012", "0.686237", "0.6845285", "0.67524415", "0.6718236", "0.67100763", "0.66571885", "0.66491216", "0.65999293", "0.6589558", "0.6569006", "0.64759755", "0.64609265", "0.6445239", "0.63856936", "0.6363303", "0.63010...
0.6300633
21
Render a Django response and finish up this request. You'll need to call this if the view function/method is a coroutine.
def render(self, response): logger.debug("TornadoRequest::render") response = self._handler.finish_response(self, response) logger.debug("response: Finished")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finish_response(self, request, response):\n logger.debug(\"TornadoHandler::finish_response\")\n\n try:\n response = self._render_template(request, response)\n except Exception as e:\n return self._handle_response_exception(request, response, e)\n\n try:\n ...
[ "0.734545", "0.7148183", "0.6868576", "0.6828342", "0.66384035", "0.6576349", "0.6576349", "0.6488101", "0.64071804", "0.63726956", "0.63658375", "0.6342019", "0.63327676", "0.6281047", "0.62706876", "0.62440646", "0.6232727", "0.61879945", "0.6183402", "0.6164196", "0.616272...
0.7349427
0
Convenience wrapper for the Tornado request's write() method.
def write(self, chunk): return self.tornado_request.write(chunk)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, *args, **kwargs):\n\n self.response.out.write(*args, **kwargs)", "def write(self, *a, **kw):\n self.response.out.write(*a, **kw)", "def write(self, *a, **kw):\n self.response.out.write(*a, **kw)", "def write(self, *a, **kw):\n self.response.out.write(*a, **kw)", ...
[ "0.7011142", "0.6603937", "0.6603937", "0.6603937", "0.6603937", "0.6603937", "0.6459584", "0.6459584", "0.6424561", "0.6364683", "0.57424295", "0.5591314", "0.5554613", "0.5515465", "0.5395379", "0.5374757", "0.5356486", "0.5350801", "0.5335824", "0.53176373", "0.52599496", ...
0.7030209
0
Convenience wrapper for the Tornado request's finish() method.
def finish(self): return self.tornado_request.finish()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def RequestHandler_finish(self):\n if self.request._oboe_finish_ev and self.request._oboe_ctx and self.request._oboe_ctx.is_valid():\n ev = self.request._oboe_finish_ev\n ctx = self.request._oboe_ctx\n if hasattr(self, 'get_status'): # recent Tornado\n ev.add_info(\"Status\", sel...
[ "0.6845464", "0.65772814", "0.6546038", "0.6546038", "0.64914596", "0.643756", "0.64001775", "0.6219688", "0.6184029", "0.6064755", "0.6025992", "0.5989794", "0.5957331", "0.5918375", "0.579136", "0.57792234", "0.5768139", "0.57536525", "0.57431555", "0.5708127", "0.569587", ...
0.7975853
0
Finish processing Django Request/Response instances
def finish_response(self, request, response): logger.debug("TornadoHandler::finish_response") try: response = self._render_template(request, response) except Exception as e: return self._handle_response_exception(request, response, e) try: self._appl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finish_successful_request(self):\n self.session_manager.finish_successful_request()", "def RequestHandler_finish(self):\n if self.request._oboe_finish_ev and self.request._oboe_ctx and self.request._oboe_ctx.is_valid():\n ev = self.request._oboe_finish_ev\n ctx = self.request._oboe_ct...
[ "0.71462715", "0.7140125", "0.7105688", "0.7105688", "0.692803", "0.69160885", "0.68923664", "0.67768365", "0.6755757", "0.66574407", "0.6555433", "0.653736", "0.65251666", "0.6524693", "0.6523928", "0.650245", "0.64916134", "0.64916134", "0.64319104", "0.6427797", "0.6422", ...
0.6531124
12
Returns the equivalent of the HTTP request's SCRIPT_NAME header variable. If Apache mod_rewrite has been used, returns what would have been the script name prior to any rewriting (so it's the script name as seen from the client's perspective), unless the FORCE_SCRIPT_NAME setting is set (to anything).
def get_script_name(t_req): if settings.FORCE_SCRIPT_NAME is not None: return force_text(settings.FORCE_SCRIPT_NAME) # If Apache's mod_rewrite had a whack at the URL, Apache set either # SCRIPT_URL or REDIRECT_URL to the full resource URL before applying any # rewrites. Unfortunately not every ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getScriptname():\n return os.environ.get('SCRIPT_NAME', '')", "def get_current_request_hostname():\r\n hostname = None\r\n request = get_current_request()\r\n if request:\r\n hostname = request.META.get('HTTP_HOST')\r\n\r\n return hostname", "def get_wsgi_file_name(self):\n ret...
[ "0.74698013", "0.64156264", "0.6333524", "0.5728996", "0.5704559", "0.551568", "0.5501407", "0.54212606", "0.5419497", "0.54038095", "0.5375227", "0.52965987", "0.5247907", "0.5221188", "0.5179678", "0.5173248", "0.5162168", "0.514716", "0.5140043", "0.5136708", "0.51301867",...
0.82943535
0
Write a usage statment and exit.
def usage(exit_code): sys.stderr.write(""" List the processes that are listening to a port. Defaults to ZeroMQ port of 5570. Use by: listeningPort [--help] [--short | --pid | --proc] [--kill] \ <port0> [<port1> ...] e.g.: listeningPort 5570 # The ZeroMQ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def usage(self, msg):\r\n self.stderr.write(\"Error: %s\\n\" % str(msg))\r\n self.stderr.write(\"For help, use %s -h\\n\" % self.progname)\r\n self.exit(2)", "def usage():", "def usage():", "def usage():\n pass", "def _usage_exit(self, argv):\n progname = os.path.basename(arg...
[ "0.70077986", "0.69412273", "0.69412273", "0.6855964", "0.6791845", "0.6775393", "0.6760198", "0.67529994", "0.6715877", "0.6689969", "0.66717726", "0.6668972", "0.6617772", "0.6592716", "0.6528043", "0.6500915", "0.64013433", "0.63891304", "0.63354975", "0.63192517", "0.6314...
0.0
-1
More proper boolean operator for easier reading. return 1 Indicate a found listener return 0 Indicates nobody listening
def is_listening(port): return not listening(port)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isListening(self):\n if not self.proxy:\n self.proxy = self.session.service(\"ALExpressiveListening\")\n return self.proxy.isListening()", "def listening(self):\n return self._server is not None", "def available(self):\n from pyhs3 import STATE_LISTENING\n retu...
[ "0.66875106", "0.65970385", "0.6574591", "0.65360075", "0.6319728", "0.6317834", "0.6192521", "0.61528975", "0.6120801", "0.6109273", "0.60723865", "0.6063828", "0.60545415", "0.6010599", "0.5838284", "0.58022517", "0.5795148", "0.5793659", "0.57519114", "0.57032394", "0.5682...
0.66736966
1
The return code may seem to be reversed, but
def listening(port, shortened=False, pid_only=False, proc_only=False, kill=False): if platform.system() not in ['Darwin', 'Linux']: sys.stderr.write('listeningPort available only under Linux and Darwin!\n') sys.exit(-1) fuser = find_execut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_return_codes(self):\n return self.__return_codes", "def __reversed__(self): # real signature unknown; restored from __doc__\n pass", "def get_code():\n return inspect.getsource(is_palindrome)", "def revise():", "def exercise_b2_113():\r\n pass", "def z(self) -> int:", "def exer...
[ "0.65284365", "0.61215353", "0.6061751", "0.6042293", "0.602448", "0.59620416", "0.58978015", "0.58908737", "0.5880695", "0.5880609", "0.58135647", "0.58110553", "0.58046925", "0.57999724", "0.57377833", "0.5699936", "0.5687256", "0.56819195", "0.56633073", "0.5634027", "0.56...
0.0
-1
Process runtime args. Based on the args, run the program. Return the number of listeners for all provided ports. 100 == error for port
def main(): import getopt try: options, remainder = getopt.getopt( sys.argv[1:], '', ['help', # Print usage msg, exit 'short', # Output is shortened 'pid', # Output only pid of listenig process 'proc', # Output only process ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def portcheck_main(args=sys.argv[1:]):\n ports = portcheck(*args)\n for i in ports:\n print '%s: %s' % (i, ports[i])\n return 0", "def run_app():\n target = None\n negative_results = False\n\n description = 'Simple TCP port scanner'\n epilog = 'The author of this code take no responsi...
[ "0.6942394", "0.66215736", "0.63740706", "0.62902844", "0.60026693", "0.5923105", "0.58010936", "0.57660186", "0.5717203", "0.56580085", "0.5623557", "0.55659944", "0.55659944", "0.55630726", "0.5499098", "0.5495286", "0.54854834", "0.5462336", "0.54213244", "0.5405209", "0.5...
0.7322132
0
A varible scope with custom variable getter to convert fp16 trainable variables with fp32 storage followed by fp16 cast.
def fp32_trainable_vars(name='fp32_vars', *args, **kwargs): return tf.variable_scope( name, custom_getter=_fp32_trainvar_getter, *args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def float32_variable_storage_getter(getter, name, shape=None, dtype=None,\n initializer=None, regularizer=None,\n trainable=True,\n *args, **kwargs):\n storage_dtype = tf.float32 if trainable else dtype\n ...
[ "0.57333016", "0.5732924", "0.54829913", "0.54007953", "0.53704756", "0.5277184", "0.52319235", "0.5210958", "0.5210958", "0.52065945", "0.5204911", "0.5188432", "0.5175494", "0.515704", "0.51456213", "0.5122729", "0.5103204", "0.5067088", "0.50535905", "0.50203663", "0.50168...
0.5123304
15
Testing opssysd correctly stores switch_version column. Test if the opssysd correctly parse the osrelease file and stores the information in the OVSDB.
def check_switch_version(dut, file_name): copy_os_release_file(dut, file_name) # Restart the ovsdb-server and sysd start(dut) version_id = read_os_release_file(dut, file_name, 'VERSION_ID') build_id = read_os_release_file(dut, file_name, 'BUILD_ID') expected = "{0} (Build: {1})".format(version_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_hyperflex_server_firmware_version(self):\n pass", "def init_linuxVersion(self):\n releaseDic = collections.OrderedDict() # 排序的字典\n releaseDic['/etc/oracle-release'] = self.__getOracleVersion\n releaseDic['/etc/redhat-release'] = self.__getRedhatVersion\n re...
[ "0.59922117", "0.58298945", "0.5813068", "0.5752418", "0.57282406", "0.5699847", "0.56906575", "0.56672615", "0.56032926", "0.5582374", "0.55770415", "0.5560227", "0.5493755", "0.5482867", "0.5482622", "0.54738504", "0.5470605", "0.5469388", "0.5446355", "0.54303396", "0.5381...
0.6845919
0
Read the local osrelease file and return the data.
def read_os_release_file(dut, fname=default_os_release_file, key=None): cur_dir, f = os.path.split(__file__) path = os.path.join(cur_dir, os_release_files_dir, fname) d = {} with open(path) as f: for line in f: k, v = line.rstrip().split("=") d[k] = v if key: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_release_version():\n with open(\"RELEASE-VERSION\", \"r\") as f:\n return f.readline().strip()", "def versionRead():\n xuvtop = os.environ['XUVTOP']\n vFileName = os.path.join(xuvtop, 'VERSION')\n vFile = open(vFileName)\n versionStr = vFile.readline()\n vFil...
[ "0.6877728", "0.6081906", "0.6046769", "0.6038422", "0.60357785", "0.6028265", "0.6022373", "0.6018158", "0.60076445", "0.59902287", "0.593641", "0.589239", "0.5883661", "0.587215", "0.5849723", "0.5803643", "0.5778237", "0.57766265", "0.5729708", "0.5707521", "0.5704802", ...
0.68287444
1
Copy a given osrelease file to /etc/osrelease.
def copy_os_release_file(dut, fname=default_os_release_file): # src = os.path.join(os.path.sep, 'shared', os_release_files_dir, fname) dst = os.path.join(os.path.sep, 'etc', 'os-release') dut("/bin/cp /tmp/files/os_releases/" + fname + " " + dst, shell="bash")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_os_release_file(**kwargs):\n\n LOGGER.info(\"Doing pre-flight checks\")\n\n releases_repo_url = OPENSTACK_REPOS + '/releases.git'\n releases_folder = kwargs['workdir'] + '/releases'\n\n oa_folder = kwargs['workdir'] + '/openstack-ansible'\n click.confirm((\"Are your sure your {} folder is...
[ "0.5891819", "0.5617878", "0.5600983", "0.54453236", "0.5412584", "0.5301226", "0.5192675", "0.5176676", "0.5082615", "0.50576097", "0.50236535", "0.5004781", "0.50029683", "0.49893183", "0.4973388", "0.49352297", "0.49307936", "0.4925656", "0.49127647", "0.49001563", "0.4860...
0.7919572
0
Create an empty DB file and load it into ovsdbserver.
def start_ovsdb(dut): dut(ovsdb_tool + "create /var/run/openvswitch/ovsdb.db " "/usr/share/openvswitch/vswitch.ovsschema", shell="bash") # Load the newly created DB into ovsdb-server dut(ovs_appctl + "-t ovsdb-server ovsdb-server/add-db " "/var/run/openvswitch/ovsdb.db", shell="bash")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_db():\n data = json.dumps({}, indent=4)\n with open(db_file, 'w') as f:\n f.write(data)", "def create_db():\n # check for DB existance\n db_file = vmcheckerpaths.db_file()\n if not os.path.isfile(db_file):\n create_db_tables(db_file)\n else:\n _logger.info('Skippin...
[ "0.7182743", "0.6928271", "0.69146526", "0.6876974", "0.66469234", "0.66009253", "0.65507185", "0.6547437", "0.64534765", "0.64410937", "0.64226925", "0.63940984", "0.6385802", "0.63851756", "0.6366313", "0.6365291", "0.6363898", "0.6357812", "0.6350014", "0.6342471", "0.6318...
0.64550304
8
Remove the OpenSwitch DB from ovsdbserver. It also removes the DB file from the file system.
def stop_ovsdb(dut): # Remove the database from the ovsdb-server. dut(ovs_appctl + "-t ovsdb-server ovsdb-server/remove-db OpenSwitch", shell="bash") # Remove the DB file from the file system. dut("/bin/rm -f /var/run/openvswitch/ovsdb.db", shell="bash")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_remove():\n\n db.session.close()\n db.drop_all()\n\n path = current_app.config['SNER_VAR']\n for file_object in os.listdir(path):\n file_object_path = os.path.join(path, file_object)\n if os.path.isdir(file_object_path):\n shutil.rmtree(file_object_path)\n else:\n...
[ "0.7118374", "0.70850265", "0.6969073", "0.6936522", "0.6843543", "0.6600032", "0.6549064", "0.6437333", "0.6426025", "0.6383878", "0.636996", "0.63381946", "0.6297148", "0.62754035", "0.62196547", "0.6199373", "0.6198524", "0.6159389", "0.6147187", "0.61467093", "0.61348754"...
0.76180816
0
Wait until System table is visible in the ovsdbserver.
def wait_until_ovsdb_is_up(dut): cmd = ovs_vsctl + "list System | grep uuid" wait_count = 20 while wait_count > 0: out = dut(cmd, shell="bash") if "_uuid" in out: break wait_count -= 1 sleep(1) assert wait_count != 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_for_update(self):\n while \"updating_db\" in self.status():\n time.sleep(1)", "def _wait(self):\n conn = None\n try:\n conn = libvirt.open(\"qemu:///system\")\n while True:\n time.sleep(10)\n try:\n st...
[ "0.6886629", "0.6821255", "0.6755564", "0.6671902", "0.64411813", "0.6287124", "0.61255527", "0.6053661", "0.60326856", "0.5992341", "0.5992341", "0.5960418", "0.58658767", "0.5795993", "0.578191", "0.5767885", "0.57642967", "0.5763632", "0.5742546", "0.57251287", "0.57207835...
0.6530201
4
Draws tower on screen.
def draw(self, win): img = self.tower_imgs win.blit(img, (self.x - img.get_width() // 2, self.y - img.get_height() // 2)) if self.selected: self.menu.draw(win)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_t(self):\r\n pen.forward(20)\r\n pen.left(90)\r\n pen.down()\r\n pen.forward(40)\r\n pen.right(90)\r\n pen.up()\r\n pen.forward(20)\r\n pen.down()\r\n pen.back(40)\r\n pen.up()\r\n pen.right(90)\r\n pen.forward(40)\r\n ...
[ "0.71633965", "0.7044889", "0.69550157", "0.6934212", "0.6876668", "0.67765385", "0.6776053", "0.6760245", "0.6739821", "0.66813356", "0.664586", "0.65988165", "0.6582451", "0.65794027", "0.657053", "0.6556787", "0.65509653", "0.6514951", "0.65098363", "0.6500126", "0.6488497...
0.66734296
10
Returns if tower if clicked on
def clicked(self, x_pos, y_pos): img = self.tower_imgs if self.x - img.get_width() // 2 + self.width >= x_pos >= self.x - img.get_width() // 2: if self.y + self.height - img.get_height() // 2 >= y_pos >= self.y - img.get_height() // 2: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def click(self, X, Y):\n tower_image = self.tower_images[self.level - 1]\n\n if X <= self.x + tower_image.get_width() // 2 - 2 * self.extra_padding and X >= self.x - tower_image.get_width() // 2 + self.extra_padding // 2:\n if self.name in TowerConstants.MAGIC_TOWER_NAMES or self.name in ...
[ "0.6965782", "0.6657078", "0.6631379", "0.6516536", "0.6370106", "0.63419133", "0.6220411", "0.618749", "0.61458325", "0.6143745", "0.60729307", "0.60694027", "0.6068607", "0.6031927", "0.60096204", "0.5948788", "0.5947022", "0.59364295", "0.5909544", "0.58931243", "0.5892988...
0.6254577
6
Draws range of tower if clicked on.
def draw_range(self, win): if self.selected: surface = pygame.Surface((self.range * 4, self.range * 4), pygame.SRCALPHA, 32) pygame.draw.circle(surface, (128, 128, 128, 100), (self.range, self.range), self.range, 0) win.blit(surface, (self.x - self.range, self.y - self.range...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_bounds():\n\n pass", "def draw(self):\n if context.click():\n self.place()", "def draw(self):\n #for (x, y) in self.coords:\n # pyxel.rect(\n # (x + self.x) * 4,\n # (y + self.y) * 4,\n # (x + self.x) * 4 + 3,\n # ...
[ "0.6205973", "0.61523294", "0.6008315", "0.5989245", "0.5944279", "0.5893319", "0.5844363", "0.5831077", "0.5826656", "0.58184046", "0.58160055", "0.5798459", "0.5755259", "0.57308894", "0.5701369", "0.5675944", "0.5657623", "0.56501853", "0.56467706", "0.5638101", "0.5619085...
0.7217638
0
Returns if tower has been clicked on.
def click(self, X, Y): img = self.tower_imgs if self.x - img.get_width() // 2 + self.width >= X >= self.x - img.get_width() // 2: if self.y + self.height - img.get_height() // 2 >= Y >= self.y - img.get_height() // 2: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_pressed(self) -> bool:", "def isPieceClicked(self):\r\n if self.clickedPiece is None:\r\n return False\r\n return True", "def isClicked(self, row, col):\n return self.clicked[row, col] == 1", "def getclickable(self):\n try:\n return self.isclickable\n ...
[ "0.6949313", "0.6936848", "0.6916155", "0.6890082", "0.685717", "0.6793036", "0.67926514", "0.67634255", "0.66977507", "0.6636105", "0.66307724", "0.6606198", "0.646153", "0.6410857", "0.64082205", "0.63949907", "0.63554156", "0.63232154", "0.63199455", "0.63180447", "0.63055...
0.5907925
68
Returns price of tower.
def buy_and_pay(self): return self.price
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_price(self):\n if self.price is None:\n price = self.data['pizza'][self.item_type][self.size]\n for topping in self.toppings:\n price += self.data['topping'][topping]\n return price\n return self.price", "def get_price(self):\r\n return...
[ "0.75573534", "0.7442761", "0.7405577", "0.7405577", "0.7405577", "0.71886677", "0.7154768", "0.7145633", "0.69703823", "0.69652617", "0.69652617", "0.6936439", "0.6890059", "0.68765694", "0.6692105", "0.6666204", "0.6639355", "0.6592077", "0.65790415", "0.65737045", "0.65166...
0.647741
23
Enables ability to move tower if desired.
def move_tower(self, x, y): self.x = x self.y = y self.menu.x = x self.menu.y = y self.menu.update()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable_moves(self):\r\n if self.board is not None:\r\n self.board.enable_moves()", "def disable_moves(self):\r\n self.board.disable_moves()", "def player_moves_player(self, x, y):\n activePlayer = self.get_active_player()\n if activePlayer.humanControlled:\n ...
[ "0.6857337", "0.61109406", "0.6083374", "0.59833616", "0.59682626", "0.58562505", "0.58186543", "0.58016217", "0.5784899", "0.5756816", "0.5755793", "0.57396764", "0.5693231", "0.56827146", "0.56718737", "0.56635517", "0.5659995", "0.565577", "0.5654262", "0.5650572", "0.5646...
0.6065812
3
Returns if tower has collided with other towers.
def collide_other_tower(self, other_tower): x2 = other_tower.x y2 = other_tower.y dis = math.sqrt((x2 - self.x) ** 2 + (y2 - self.y) ** 2) if dis >= 100: return False else: return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_collision(self):\n to_del_tie_fighters = []\n to_del_bullets = []\n for i in range(len(self.tie_fighters)):\n for j in range(len(self.bullets)):\n distance = math.sqrt(math.pow(self.tie_fighters[i].position_x -\n sel...
[ "0.66479945", "0.6531968", "0.63689274", "0.62439644", "0.62210834", "0.6191183", "0.61626065", "0.6146874", "0.6141496", "0.6111181", "0.60250914", "0.60068333", "0.59923124", "0.59918606", "0.59909797", "0.5972956", "0.59619415", "0.5958758", "0.5958758", "0.5938597", "0.59...
0.64796
2
Returns the scan resolution in mm of the ship.
def scanResolution(self): return self._getAttribute(Attribute.scanResolution)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getResolution(self):\n return self.resolution", "def getResolution(self):\n return self._lowLevelGetDeviceResolution()", "def get_current_resolution(self):\n return self.display_info[\"width\"], self.display_info[\"height\"]", "def resolution(self) -> int:\n return self._resol...
[ "0.7246049", "0.69126594", "0.685117", "0.6794998", "0.67246604", "0.6541934", "0.6535295", "0.6369", "0.6277552", "0.6272509", "0.6237596", "0.62197703", "0.61901945", "0.6151652", "0.61414826", "0.61146194", "0.6110332", "0.6093271", "0.6090543", "0.6054958", "0.60548455", ...
0.73278564
0
Returns the max target range in metres of the ship.
def targetRange(self): return self._getAttribute(Attribute.targetRange)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_range(self):\n return self._max_range", "def __find_max_distance(self):\n return utils.find_max_distance(self.__game)", "def max(self):\n return self._max_coords", "def speed_max(self):\n return self._speed_max", "def maximum(self) -> Union[int, float]:\n return s...
[ "0.73674613", "0.7078885", "0.7044618", "0.6981582", "0.6943583", "0.69382846", "0.692371", "0.6908214", "0.6892179", "0.6888499", "0.68463236", "0.67757446", "0.6704904", "0.66685164", "0.6667965", "0.6664101", "0.6652931", "0.664733", "0.66399574", "0.66399574", "0.6636634"...
0.6399989
43
Returns the max number of locked targets.
def maxTargets(self): return self._getAttribute(Attribute.maxTargets)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxTasksAchievable(self):\n maxTasks = 0\n for w in self._workers:\n maxTasks = maxTasks + w.multitask\n return maxTasks", "def max_node_count(self) -> int:\n return pulumi.get(self, \"max_node_count\")", "def node_count_max(self) -> int:\n return int(self.graph_tuple_stats.node_cou...
[ "0.7053719", "0.6945075", "0.67787427", "0.6716458", "0.66914487", "0.65706974", "0.6546918", "0.6542584", "0.65309083", "0.65046275", "0.6473251", "0.6438238", "0.6386052", "0.6385337", "0.6385203", "0.63613576", "0.6358105", "0.63530767", "0.63487595", "0.6279512", "0.62710...
0.6987084
1
Returns the sensor strength of the ship.
def sensorStrength(self): # TODO: also return type of sensor radar = self._getAttribute(Attribute.scanRadarStrength) ladar = self._getAttribute(Attribute.scanLadarStrength) magnetometric = self._getAttribute(Attribute.scanMagnetometricStrength) gravimetric = self._getAttribute(Attribute.scanGravimet...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getStrength(self):\n return self.st", "def strength(self) -> int:\n return self._strength", "def wireless_signal_strength(self) -> int:\n return self.data[Attribute.WIRELESS_SIGNAL_STRENGTH]", "def getPersonStrength(self):\n strength = self.myDesign.myShipHull.mass/200\n ...
[ "0.72526914", "0.67626673", "0.6689082", "0.6676303", "0.6576709", "0.6460022", "0.6326511", "0.6292669", "0.62278104", "0.6079792", "0.60773563", "0.602665", "0.6026219", "0.5985158", "0.5903484", "0.5875291", "0.58557934", "0.582385", "0.5819542", "0.58171266", "0.58148235"...
0.79078126
0
Returns details about the ship's capacitor.
def capacitor(self): capacity = self._getAttribute(Attribute.capacitorCapacity) recharge = self._getAttribute(Attribute.capacitorRecharge) recharge /= 1000 # milliseconds return { "capacity": capacity, "recharge": recharge, }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getShip(self):\r\n return self._ship", "def my_ship_info(self, ship_id):\n r = requests.get(self.base_url + f'/users/{self.username}/ships/{ship_id}', headers=self.auth_header)\n return r.text", "def get_card(self):\n return self.card", "def card(self):\n return self.cd...
[ "0.6025865", "0.5962599", "0.5775231", "0.5688934", "0.5532411", "0.53715676", "0.53670514", "0.5319011", "0.52973115", "0.52933747", "0.5288867", "0.5282726", "0.5235691", "0.5224877", "0.52141637", "0.52120286", "0.5172074", "0.5133092", "0.51199114", "0.50787777", "0.50685...
0.63753223
0
Returns details about the ship's shield. Resists are integers from 0 to 100.
def shield(self): capacity = self._getAttribute(Attribute.shieldCapacity) recharge = self._getAttribute(Attribute.shieldRecharge) em = self._getAttribute(Attribute.shieldEM) explosive = self._getAttribute(Attribute.shieldExplosive) kinetic = self._getAttribute(Attribute.shieldKinetic) thermal = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shield(self) -> Union[int, float]:\n return self.proto.shield", "def shield(self) -> Union[int, float]:\n return self.proto.shield", "def shield_percentage(self) -> Union[int, float]:\n if not self.proto.shield_max:\n return 0\n return self.proto.shield / self.proto.s...
[ "0.71837157", "0.71837157", "0.63567024", "0.63567024", "0.620633", "0.61392653", "0.59401715", "0.55441207", "0.55341315", "0.5515987", "0.5445214", "0.5393898", "0.5393898", "0.53693086", "0.53582525", "0.5346322", "0.534188", "0.53272325", "0.5286073", "0.5232572", "0.5096...
0.71346664
2
Returns details about the ship's armor. Resists are integers from 0 to 100.
def armor(self): capacity = self._getAttribute(Attribute.armorCapacity) em = self._getAttribute(Attribute.armorEM) explosive = self._getAttribute(Attribute.armorExplosive) kinetic = self._getAttribute(Attribute.armorKinetic) thermal = self._getAttribute(Attribute.armorThermal) em = 1.0 - em ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getArmor(self):\n return self.av", "def armor(self) -> Union[int, float]:\n return self.type_data.proto.armor", "def armor(self) -> Union[int, float]:\n return self.type_data.proto.armor", "def get_armor_equipped(self):\n\t\treturn self.equippedArmor", "def armor_mapping(self, armo...
[ "0.672655", "0.6709763", "0.6709763", "0.6694133", "0.5853349", "0.5786742", "0.5659746", "0.56013674", "0.5586368", "0.55516726", "0.54307085", "0.54023623", "0.52987903", "0.5295258", "0.52864414", "0.524963", "0.52466756", "0.5236324", "0.52125114", "0.5185202", "0.5182413...
0.70991963
0
Returns details about the ship's hull. Resists are integers from 0 to 100.
def hull(self): capacity = self._getAttribute(Attribute.hullCapacity) em = self._getAttribute(Attribute.hullEM) explosive = self._getAttribute(Attribute.hullExplosive) kinetic = self._getAttribute(Attribute.hullKinetic) thermal = self._getAttribute(Attribute.hullThermal) em = 1.0 - em explo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hull_points(self, show_progress):\n if self.points and not self.hull_points:\n self.graham_scan(show_progress)\n print(\"Input: {} points\").format(len(self.points))\n print(\"Convex hull: {} points\").format(len(self.hull_points))\n return self.hull_points", ...
[ "0.6672058", "0.6176164", "0.59618896", "0.58829105", "0.58734185", "0.56309587", "0.5607765", "0.5572041", "0.55508894", "0.55086654", "0.55001277", "0.54714054", "0.54605114", "0.54518104", "0.54211336", "0.5401091", "0.53931373", "0.53588456", "0.5355742", "0.53469115", "0...
0.7092801
0
Returns the mass of the ship in kg.
def mass(self): return self._getAttribute(Attribute.mass)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mass(self):\n return self.m", "def mass(self):\n return self._mass", "def mass(self):\n return self._mass", "def get_mass(self):\n _pal.lib.geometry_get_mass.restype = c.c_float\n return _pal.lib.geometry_get_mass(self._geometry)", "def getMass(self):\n return ...
[ "0.7700583", "0.7442594", "0.7442594", "0.7403629", "0.7257066", "0.7243392", "0.71628", "0.69766843", "0.69766843", "0.69614315", "0.6877484", "0.6763508", "0.6741722", "0.6729715", "0.66413784", "0.6555275", "0.6544383", "0.65086937", "0.64038354", "0.63498867", "0.63444513...
0.7356114
4
Returns the agility of the ship.
def agility(self): return self._getAttribute(Attribute.agility)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_agility(self):\n return self.__agility", "def getAgility(self):\n return self.ag", "def ship_status(self):\n try:\n if self.warp_drive.is_at_warp:\n return STATUS_AT_WARP\n except AttributeError:\n pass\n if self.hull < self.ship_c...
[ "0.71741396", "0.6533135", "0.62021345", "0.58686894", "0.5845468", "0.5738765", "0.57350934", "0.57290393", "0.5692616", "0.56269544", "0.5558341", "0.5537012", "0.5521611", "0.5497823", "0.5494352", "0.5493872", "0.5486315", "0.5460528", "0.5449845", "0.5426114", "0.541868"...
0.72832453
0
Returns the max speed of the ship in m/s.
def speed(self): return self._getAttribute(Attribute.maxVelocity)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_max(self):\n return self._speed_max", "def max_speed(self) -> int:\n return self._max_speed", "def get_max_speed(self):\n if self.mot_type == 'ims':\n return self.get_par(\"max_speed\")\n elif self.mot_type == 'xps8p':\n return self.get_par(\"max_speed_xps\")\n else:\...
[ "0.80530673", "0.7898047", "0.7832208", "0.7482002", "0.7284336", "0.6997841", "0.69419146", "0.678503", "0.6669273", "0.6586474", "0.65635264", "0.6530637", "0.65293014", "0.6467135", "0.6413761", "0.6413761", "0.638455", "0.638455", "0.6373889", "0.63461125", "0.63413966", ...
0.76320755
3
Returns the signature radius of the ship.
def signatureRadius(self): return self._getAttribute(Attribute.signatureRadius)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_radius(self):\n return self.radius", "def get_radius(self):\n return self.radius", "def get_radius(self):\n return self.__radius", "def get_radius(self):\r\n return self._handler.get_radius()", "def get_radius(self):\n return self.r", "def get_radius(self):\n ...
[ "0.6727663", "0.6727663", "0.6722686", "0.6706938", "0.6699158", "0.6697993", "0.65364933", "0.65341675", "0.6533542", "0.6533542", "0.6533542", "0.6533542", "0.6533542", "0.6469756", "0.6409528", "0.64033717", "0.63899565", "0.63726634", "0.627117", "0.6267666", "0.62168795"...
0.8012885
0
Returns the warp speed of the ship in AU/s.
def warpSpeed(self): multiplier = self._getAttribute(Attribute.warpSpeedMultiplier) return multiplier * self.baseWarpSpeed
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wind_speed(self):\n return self.flow_field.wind_speed", "def speed(self):\n return sqrt(self.velocity_x ** 2 + self.velocity_y ** 2)", "def get_speed(self):\n return self._speed", "def speed(self) -> float:\n return self._speed", "def speed(self) -> float:\n return se...
[ "0.6979192", "0.6968374", "0.69073606", "0.68811303", "0.68811303", "0.684289", "0.6759257", "0.66982025", "0.6667661", "0.6667661", "0.66550624", "0.66299623", "0.66035396", "0.65631795", "0.6509234", "0.64987284", "0.64891005", "0.64751405", "0.64751405", "0.64723843", "0.6...
0.82695305
0
Returns the time needed for the ship to enter warp.
def alignTime(self): agility = self.agility mass = self.mass alignTime = -math.log(0.25) * agility * mass / 1000000 return alignTime
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_time_walking(self):\n return self.time_step_to_enqueue - self.time_entered", "def get_time(self) -> float:\n self.rocket.update()\n return self.rocket.time", "def time_for_travel(self):\n return great_circle(self.pickupcoords, self.dropoffcoords).miles * 3600 / 25", "def g...
[ "0.719643", "0.7167309", "0.69177204", "0.6831743", "0.6800295", "0.67585397", "0.66823614", "0.6676479", "0.6651766", "0.6617591", "0.6617591", "0.66170424", "0.65979695", "0.65413624", "0.6538821", "0.6525674", "0.6506417", "0.64824873", "0.6465137", "0.6451975", "0.6431837...
0.0
-1
Get the number of slots for a given ship.
def slots(self): highSlots = self._getAttribute(Attribute.highSlots) medSlots = self._getAttribute(Attribute.medSlots) lowSlots = self._getAttribute(Attribute.lowSlots) if None in [highSlots, medSlots, lowSlots]: # This is a T3 ship. highSlots = medSlots = lowSlots = 0 # Get rigs and s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ship_size(coordinates, field):\r\n return len(ship_coordinates(coordinates, field))\\\r\n if has_ship(coordinates, field) else 0", "def ship_count(self):\r\n return sum(f.ship_count for f in self)", "def get_number_rows(si_settings, ship_height, alien_height):\r\n available_space_y = (s...
[ "0.678716", "0.6708723", "0.6604067", "0.64804345", "0.647676", "0.6446091", "0.64105386", "0.63767254", "0.6366114", "0.6364903", "0.6181303", "0.6169852", "0.6051106", "0.5926516", "0.5916196", "0.5863569", "0.58317244", "0.5710366", "0.5655945", "0.5553721", "0.55536443", ...
0.6098219
12
Get effective hitpoints of ship based on given damage profile.
def get_ehp(self, damageProfile = None): if damageProfile is None: damageProfile = [1, 1, 1, 1] totalDamage = sum(damageProfile) emMultiplier = damageProfile[0] / totalDamage explosiveMultiplier = damageProfile[1] / totalDamage kineticMultiplier = damageProfile[2] / totalDamage thermalMul...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getDamagePoints(self, weapon, hitloc):\n try:\n points = self.damage[weapon][int(hitloc) - 1]\n self.debug(\"_getDamagePoints(%s, %s) -> %d\" % (weapon, hitloc, points))\n return points\n except (KeyError, IndexError), err:\n self.warning(\"_getDamageP...
[ "0.58444387", "0.54253817", "0.5018482", "0.49989057", "0.4984102", "0.49799725", "0.49535167", "0.4933344", "0.49060372", "0.4848012", "0.48381183", "0.48204282", "0.48185968", "0.48093298", "0.47938338", "0.4789829", "0.47700018", "0.4751191", "0.47470975", "0.4715458", "0....
0.5185065
2
Here we drop the first column, which is useless and rename the columns with uppercase.
def cleaning_data(): data.drop(["Unnamed: 0"], axis = 1, inplace = True) data.columns = map(str.upper, data.columns) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uppercase_all_column_names(df:DataFrame)->DataFrame:\n for col in df.columns:\n df = df.withColumnRenamed(col, col.upper())\n return df", "def _clean_up_table_column_names(loop_dict):\n \n # Make the column names all lowercase\n # and remove any underscores from the beginning\n for k...
[ "0.670421", "0.6379539", "0.6352936", "0.6272925", "0.62530506", "0.62204903", "0.6190862", "0.6184449", "0.61701965", "0.6132059", "0.6099708", "0.60867906", "0.6080659", "0.60554224", "0.6015632", "0.599467", "0.59028536", "0.58984935", "0.5895571", "0.5886753", "0.5850004"...
0.75469196
0
In this function, we call the API of NBA Stats thanks to the inspecting console to update our original dataset from Kaggle. The cool point here is that we are gonna update this dataset with info from the current season. Although is not ended yet, it's fine in order to enrich our data.
def calling_api(): url_bio = "https://stats.nba.com/stats/leaguedashplayerbiostats?College=&Conference=&Country=&DateFrom=&DateTo=&Division=&DraftPick=&DraftYear=&GameScope=&GameSegment=&Height=&LastNGames=0&LeagueID=00&Location=&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PerMode=PerGame&Period=0&PlayerExperience...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player_team_data(self, start_date, end_date = None, \n get_player_data_ind = True, get_team_data_ind = True, \n pre_player_data_dir = None, pre_team_data_dir = None):\n #Converts start and end date from string to datetime\n start_date = ...
[ "0.5904324", "0.5902132", "0.57382816", "0.57373065", "0.5718162", "0.56430864", "0.5641176", "0.56379896", "0.55986893", "0.55755377", "0.5567273", "0.55645984", "0.55612344", "0.55196846", "0.5490538", "0.5481568", "0.5469396", "0.54392934", "0.54362196", "0.54210824", "0.5...
0.70550686
0
We just set the columns and the rows from our call and do some modifications in the resulting columns of our DataFrame.
def updating_api(response_bio): frame_bio = pd.DataFrame(response_bio['resultSets'][0]['rowSet']) frame_bio.columns = response_bio['resultSets'][0]['headers'] frame_bio.drop(["PLAYER_ID", "TEAM_ID", "PLAYER_HEIGHT_INCHES"], axis=1, inplace=True) frame_bio["SEASON"] = "2020-21" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def augment_dataframe(self, df: pd.DataFrame) -> pd.DataFrame:", "def transform(self, dataframe: DataFrame) -> DataFrame:", "def set_data(self):\n # take care of samples\n patients = self.samples.iloc[:,1].tolist()\n samples = self.samples.iloc[:,0].tolist()\n self.samples = pd.DataFrame(patients,...
[ "0.7080994", "0.65243924", "0.6344557", "0.629279", "0.6263308", "0.6195808", "0.6125308", "0.6117135", "0.60997665", "0.604475", "0.6003345", "0.59953165", "0.5968952", "0.596216", "0.59263223", "0.58961135", "0.5883221", "0.5880314", "0.5861472", "0.58429843", "0.58344173",...
0.0
-1
A room with an unknown room version should not break sync (and should be excluded).
def test_unknown_room_version(self) -> None: inviter = self.register_user("creator", "pass", admin=True) inviter_tok = self.login("@creator:test", "pass") user = self.register_user("user", "pass") tok = self.login("user", "pass") # Do an initial sync on a different device. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def room_of(self, guest_name):\n pass", "def get_room_or_error(room_id) -> PublicChatRoom:\n try:\n return PublicChatRoom.objects.get(pk=room_id)\n except PublicChatRoom.DoesNotExist:\n raise ClientError(\"ROOM_INVALID\", \"Room not created\")", "def test_new_room(new_room):\n try...
[ "0.5479755", "0.5352999", "0.53118664", "0.5281718", "0.51888007", "0.5170421", "0.5131571", "0.5111089", "0.5103384", "0.5095766", "0.50885797", "0.50845325", "0.5068195", "0.49836266", "0.49664915", "0.495951", "0.4904172", "0.4896691", "0.48871648", "0.48798552", "0.486519...
0.6844382
0
Rooms shouldn't appear under "joined" if a join loses a race to a ban.
def test_ban_wins_race_with_join(self) -> None: # A local user Alice creates a room. owner = self.register_user("alice", "password") owner_tok = self.login(owner, "password") room_id = self.helper.create_room_as(owner, is_public=True, tok=owner_tok) # Do a sync as Alice to get t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_rooms(self, exclude=[]):\n stmt = Session.query(Lesson.room, Lesson.day, Lesson.order,\n Lesson.schedule_id)\n stmt = stmt.group_by(Lesson.room, Lesson.order, Lesson.day, Lesson.schedule_id)\n stmt = stmt.having(func.count(Lesson.room)>1)\n stmt = stmt.filter(not_(L...
[ "0.60549825", "0.5959514", "0.5958933", "0.59361064", "0.58495605", "0.5714841", "0.5688591", "0.5605994", "0.5584611", "0.55729496", "0.556611", "0.553233", "0.54888505", "0.5464354", "0.5461276", "0.5449192", "0.54279804", "0.5424823", "0.5380059", "0.5365503", "0.5365503",...
0.6758452
0
Generate a sync config (with a unique request key).
def generate_sync_config( user_id: str, device_id: Optional[str] = "device_id" ) -> SyncConfig: global _request_key _request_key += 1 return SyncConfig( user=UserID.from_string(user_id), filter_collection=Filtering(Mock()).DEFAULT_FILTER_COLLECTION, is_guest=False, reques...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_generated_config(self, auth_provider: KeyProvider, secret_key):\n\n generated_config = {\n 'jupyterhub': {\n 'proxy': {\n 'https': {\n 'hosts': [self.spec['domain']]\n }\n },\n 'ingre...
[ "0.596656", "0.5661122", "0.55148077", "0.5476729", "0.5386889", "0.52841794", "0.52840906", "0.5246648", "0.5237421", "0.52204037", "0.51961136", "0.51553464", "0.5150974", "0.51448613", "0.5127649", "0.5121277", "0.5121277", "0.5118716", "0.5100069", "0.5089299", "0.5077849...
0.7949307
0
divide a character string into individual tokens, which need not be separated by spaces (but can be!) also, the results are returned in a manner similar to iterator instead of a new data structure
def new_split_iter(expr): expr = expr + ";" # append new symbol to mark end of data, for simplicity pos = 0; #begin at first character position in the list while expr[pos] != ";": #repeat until the end of the input is found. if expr[pos].isdigit(): e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(str):\n return str.split()", "def tokenize(s):\n return s.split()", "def tokenize(self, input_string: str) -> List[str]:", "def tokenize(text,split_str='\\s',chars=False):\n if not chars:\n text=re.split(split_str,text)\n return [token for token in text if token not in [\"\"]]...
[ "0.7698143", "0.7487164", "0.7296585", "0.7190682", "0.71789664", "0.7095132", "0.7080676", "0.6931621", "0.6822178", "0.679578", "0.6759211", "0.67582", "0.6750599", "0.67415357", "0.67150646", "0.6640322", "0.6636809", "0.66356945", "0.663491", "0.6625722", "0.6624194", "...
0.0
-1
Save the beam parameter type with the specified name, description and units.
def _savebeamparamproptype(self, cursor, bpptname, bpptunit=None, bpptdesc=None): sql = """ INSERT INTO beam_param_prop_type ( beam_param_prop_type_name, beam_param_prop_type_desc, beam_param_prop_type_unit ) VALUES ( '%s', %s, %s ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_parms(self, name):\n self._save_parms(name.encode())", "def save(\n cls,\n save_location: typing.Union[str, BytesIO, Path],\n project_info,\n parameters: dict,\n range_changed=None,\n step_changed=None,\n ):", "def write_parameter(self, parameter_nam...
[ "0.6326744", "0.5966426", "0.596266", "0.5775812", "0.57679296", "0.5691061", "0.5647583", "0.5620973", "0.56005216", "0.5581241", "0.55669177", "0.5535288", "0.5534114", "0.5506977", "0.5506977", "0.5477506", "0.54759413", "0.5464111", "0.54561913", "0.5452761", "0.5451538",...
0.6978819
0
Query the DB for the beam parameter property type with the given name and units.
def retrievebeamparamproptype(self, cursor, bpptname, bpptunit=None): sql = """ SELECT beam_param_prop_type_id, beam_param_prop_type_name, beam_param_prop_type_desc, beam_param_prop_type_unit FROM beam_param_prop_type WHERE ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_parameter_type(self, name):\n phil_scope = phil.parse(\n \"\"\"include scope dials.command_line.scale.phil_scope\"\"\",\n process_includes=True,\n )\n obj = phil.find_scope(phil_scope, name)\n if not obj:\n raise ValueError(\n \"\"...
[ "0.55514073", "0.5370979", "0.53658986", "0.5357402", "0.52250284", "0.5210971", "0.51845634", "0.5178483", "0.51416516", "0.51144356", "0.50588375", "0.5011084", "0.49770406", "0.49436116", "0.49431488", "0.49372455", "0.48987404", "0.4895201", "0.4863563", "0.4856202", "0.4...
0.6423724
0
Do the main thing here
def main(self): self.jamf_url = self.env.get("JSS_URL") self.jamf_user = self.env.get("API_USERNAME") self.jamf_password = self.env.get("API_PASSWORD") self.script_path = self.env.get("script_path") self.script_name = self.env.get("script_name") self.script_category = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(self):\r\n pass", "def main():\n pass", "def main(self):", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def m...
[ "0.8507596", "0.8429522", "0.8422422", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "0.8378591", "...
0.0
-1
Attempts to create connection to the DB
def db_connect(): rds_host = os.environ['RDS_HOST'] name = os.environ['DB_USERNAME'] password = os.environ['DB_PASS'] db_name = os.environ['DB_NAME'] # try to connect to mysql db try: conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, cursorclass=pymysql.cursors.D...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_connection():\r\n try:\r\n conn = sq.connect(DBClass.db_name)\r\n except sq.Error as e:\r\n raise e\r\n \r\n return conn", "def create_connection(self):\n try:\n self.conn = psycopg2.connect(host=self.host, port=self.port, databas...
[ "0.82925993", "0.79282445", "0.7819027", "0.7701475", "0.76424354", "0.7637635", "0.7615196", "0.7610654", "0.7608734", "0.76047164", "0.7593595", "0.75872505", "0.75690114", "0.7548496", "0.7517285", "0.75060135", "0.75018847", "0.7476792", "0.7470816", "0.7465462", "0.74652...
0.0
-1
Checks validity of post request
def check_post(*params, conn, event): # check that connection to db valid if conn is None: return (False, connection_error()) # check that post request body is not empty if event.get('body') is None: return (False, format_response(404, {"error":"post request is empty"})) request = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_post_data ( ):\n # check every field is present\n try:\n request.json[ 'source_lang' ]\n request.json[ 'target_lang' ]\n request.json[ 'text' ]\n\n TranslatorApp.verify_rpc_value ( request.json )\n\n except KeyError: # All the values are ...
[ "0.68396235", "0.68267936", "0.67970574", "0.67464995", "0.6743694", "0.6737659", "0.67249835", "0.6723429", "0.6690368", "0.6686085", "0.6655791", "0.6647895", "0.6620084", "0.65968996", "0.6478333", "0.643864", "0.6372505", "0.6351049", "0.63355416", "0.63355416", "0.632054...
0.7285991
0
Connects to and executes post requests to the DB
def post(create_query, insert_query, conn): try: with conn.cursor() as cur: cur.execute(create_query) cur.execute(insert_query) conn.commit() except pymysql.IntegrityError as e: print(e) return format_response(400, {'error': repr(e)}) except (pymy...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(self):\n blob_key = self.request.get(\"blobkey\")\n\n database_creation.run(blob_key)", "def post():\n pass", "def post(self, request):\n return self.execute_query()", "def do_POST(self,):\n self.http_method = 'POST'\n self.response()", "def post(self):\n ...
[ "0.69178957", "0.6808864", "0.6625101", "0.6473524", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.6472932", "0.64701337", "0.64470035", "0.6426787", ...
0.61923754
29
Connects to and executes get requests in the DB
def get(get_query, conn, multiple=None): try: if multiple is not None: result = { multiple: [] } with conn.cursor() as curr: curr.execute(get_query) for row in curr: result[multiple].append(row) else: with conn...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n\n \n\n try:\n db = getDatabase()\n connection = db.connect()\n\n connection.get(self)\n\n except Exception as e:\n raise e\n finally:\n db.dispose()", "def do_GET(self):\n print(\"do_GET: got: \" + str(self....
[ "0.7205715", "0.65766305", "0.65255743", "0.6299569", "0.6289188", "0.6287125", "0.6287125", "0.6287125", "0.6287125", "0.6277264", "0.6268164", "0.6251907", "0.6228192", "0.62165284", "0.61531556", "0.60838366", "0.6082236", "0.6055139", "0.6018284", "0.59699744", "0.5922894...
0.0
-1
Connects to and executes delete requests in the DB
def delete(table, row_id, conn): try: with conn.cursor() as cur: query = 'delete from {} where {}'.format(table, row_id) cur.execute(query) conn.commit() except pymysql.IntegrityError as e: print(e) return format_response(400, {'error': repr(e)}) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete():", "def delete(self):\n\n\n try:\n db = getDatabase()\n connection = db.connect()\n\n connection.delete(self)\n except Exception as e:\n raise e\n finally:\n db.dispose()", "def delete(self):\n ...", "def delete()...
[ "0.75152755", "0.7353083", "0.7300788", "0.7177255", "0.6917534", "0.6917534", "0.6917534", "0.6917534", "0.6821693", "0.6785322", "0.67845994", "0.6716414", "0.6716414", "0.66891634", "0.66866225", "0.66649693", "0.6660199", "0.6639476", "0.66301316", "0.6600601", "0.6591334...
0.0
-1
Uploads image to S3 Bucket and returns id
def handle_image(data, user_id): import boto3 s3_client = boto3.client('s3') bucket_name = 'grouplite-bucket' key = str(user_id)+'-'+str(datetime.now()) s3_client.put_object(Bucket=bucket_name, Body=data, Key=key) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_image():\n s3client = __initiate_s3client()\n # Generate random UUIDs as image ids\n image_id = str(uuid.uuid4())\n # Generate pre-signed POST url\n url_info = s3client.generate_presigned_post(\n Bucket=env.get('bucket'),\n Key=image_id\n )\n return Response(status_cod...
[ "0.772035", "0.73825383", "0.68447506", "0.6707085", "0.66686594", "0.665868", "0.66541964", "0.6504776", "0.6491276", "0.64902574", "0.6468291", "0.6467243", "0.644531", "0.64173573", "0.6394816", "0.6393609", "0.637998", "0.637168", "0.6370416", "0.63333064", "0.6297082", ...
0.7330185
2
Downloads base64 encoded image from S3 Bucket
def down_image(image_id): import boto3 from botocore import errorfactory s3_client = boto3.client('s3') bucket_name = 'grouplite-bucket' try: response = s3_client.get_object(Bucket=bucket_name, Key=image_id) except errorfactory.ClientError as e: print(e) return format_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image(filename):\n\n client.download_file(S3_BUCKET, filename, 'uploads/{}'.format(filename))", "def get_blob(self, download_meta):\n bucket_name, key = self._get_bucket_key(download_meta)\n response = self.s3.get_object(Bucket=bucket_name,\n Key=key)...
[ "0.71327126", "0.68351406", "0.65610856", "0.6547404", "0.65048814", "0.6462952", "0.6450995", "0.6424799", "0.6371607", "0.6265902", "0.6264738", "0.6241289", "0.62049055", "0.6135215", "0.6133612", "0.6119457", "0.61054146", "0.60637724", "0.60560626", "0.6038806", "0.60258...
0.5687627
61