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
Determine if a player has won on the given board_state.
def has_winner(board_state, winning_length): board_width = len(board_state) board_height = len(board_state[0]) # check rows for x in range(board_width): winner = _has_winning_line(board_state[x], winning_length) if winner != 0: return winner # check columns for y in ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_won(board, player):\r\n return False", "def has_won(board, player):\n return False", "def is_game_won(board, player):\n\n\tis_won = False\n\n\tif (\n\t\tboard[0] == board[1] == board[2] == player or\n\t\tboard[3] == board[4] == board[5] == player or\n\t\tboard[6] == board[7] == board[8] == player...
[ "0.79794073", "0.7962099", "0.77557176", "0.7624931", "0.7350112", "0.72522813", "0.70972157", "0.7095919", "0.7083247", "0.7078027", "0.70777637", "0.7077196", "0.7007858", "0.6986884", "0.6973706", "0.69680285", "0.69646233", "0.69161004", "0.68918866", "0.687477", "0.68736...
0.6907228
18
Run a single game of tictactoe until the end, using the provided function args to determine the moves for each player.
def play_game(plus_player_func, minus_player_func, board_size=5, winning_length=4, log=False): board_state = _new_board(board_size) player_turn = 1 while True: _available_moves = list(available_moves(board_state)) if len(_available_moves) == 0: # draw if log: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_game(mc_move_function, ntrials, reverse = False):\n # Setup game\n board = TTTBoard(3, reverse)\n curplayer = PLAYERX\n winner = None\n\n # Run game\n while winner == None:\n # Move\n row, col = mc_move_function(board, curplayer, ntrials)\n board.move(row, col, curpl...
[ "0.61312234", "0.60480046", "0.60451484", "0.60361534", "0.60033566", "0.5980271", "0.5970943", "0.59649867", "0.5925829", "0.5925095", "0.5891507", "0.5877892", "0.5868325", "0.5866884", "0.58609414", "0.5852589", "0.5732131", "0.5701758", "0.5693335", "0.5681218", "0.567969...
0.0
-1
A player func that can be used in the play_game method. Given a board state it chooses a move randomly from the valid moves in the current state.
def random_player(board_state, _): moves = list(available_moves(board_state)) return random.choice(moves)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_strategy(player, board):\n return random.choice(Othello.legal_moves(player, board))", "def move_random(self, board):\n self.get_moves(board.board)\n return random.choice(self.available_moves)", "def randomMove(board):\r\n go = True\r\n while go:\r\n y = random.randint(0...
[ "0.7818172", "0.7593907", "0.73932165", "0.7253854", "0.72194034", "0.7201982", "0.7074549", "0.7062782", "0.70347655", "0.70231247", "0.6997784", "0.69781554", "0.6972281", "0.69547147", "0.6952076", "0.69505334", "0.6949678", "0.6943139", "0.69346225", "0.6917967", "0.68817...
0.87458694
0
shape of the whole domain with the halo points.
def shape_halo(self): return [c.size for c in self.coords_halo]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shape_with_halo(self):\n # TODO: Drop me after the domain-allocation switch, as this method\n # will be provided by the superclass\n return tuple(j + i + k for i, (j, k) in zip(self.shape_domain, self._halo))", "def shape(self):", "def shape(self):", "def shape(self) -> Shape:", "d...
[ "0.7041785", "0.6348338", "0.6348338", "0.6217209", "0.60234183", "0.59201473", "0.5863797", "0.57955235", "0.5774673", "0.5743306", "0.57097733", "0.5701146", "0.5701146", "0.56974775", "0.5685528", "0.56634617", "0.56310666", "0.56310666", "0.5606582", "0.55863523", "0.5581...
0.6829687
1
shape of the interior domain.
def shape_in(self): return [c.size for c in self.coords]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shape(self):", "def shape(self):", "def shape(self):\n # TODO: perhaps this should be a list? That's what the shape\n # normally is.\n return np.array([len(self._R_boundaries)-1, len(self._P_boundaries)-1])", "def shape(self):\n return self._shape", "def shape(self) -> Shape:", ...
[ "0.7221017", "0.7221017", "0.71000314", "0.6791237", "0.6745107", "0.67078817", "0.6703702", "0.6703702", "0.67030513", "0.6636736", "0.6634805", "0.6632598", "0.65988344", "0.6592197", "0.6526844", "0.6517238", "0.6517238", "0.6507547", "0.64677215", "0.64558387", "0.6435168...
0.615935
37
x component of the coordinates in the interior domain.
def x(self): return self.coords[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x_coord(self):\n\n return self.x0 + np.arange(self.nx) * self.dx", "def x(self):\n return self._coords[0]", "def x(self):\n if self._x is None:\n self.compute_coordinates()\n return self._x", "def get_x(self):\n return self.coords[0]", "def Getxcoord(self):...
[ "0.8358697", "0.8154594", "0.8109607", "0.8066341", "0.8036693", "0.7739915", "0.7691257", "0.7688244", "0.7548885", "0.7508032", "0.74587315", "0.74127597", "0.7358614", "0.73565143", "0.7294545", "0.7292517", "0.7270111", "0.72684973", "0.72265565", "0.72084564", "0.7204393...
0.8181522
1
y component of the coordinates in the interior domain.
def y(self): return self.coords[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y_coord(self):\n\n return self.y0 + np.arange(self.ny) * self.dy", "def y(self):\n return self._coords[1]", "def y(self) -> int:\n return self.data.y_centre >> 4", "def get_y(self):\n return self.coords[1]", "def y(self):\n if self._y is None:\n self.comput...
[ "0.84114426", "0.81654555", "0.80646", "0.79960674", "0.78949875", "0.7806516", "0.77400583", "0.77166253", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.7681602", "0.76600176", "0.76600176", "0.7660017...
0.82379454
1
z component of the coordinates in the interior domain.
def z(self): return self.coords[2]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_z(self):\n return self.coords[2]", "def z(self):\n return self._coords[2]", "def getZ(self):\n\t\treturn self.coords.z", "def getZCoord(self, x, y):\n n = self.normal()\n z = (-n.x * (x - self.p0.x) - n.y * (y - self.p0.y) + n.z * self.p0.z) / n.z\n return z", "de...
[ "0.8204318", "0.81756115", "0.79953474", "0.7745512", "0.7492492", "0.74836826", "0.73827064", "0.73827064", "0.73827064", "0.7358403", "0.734638", "0.7295331", "0.7255795", "0.7253108", "0.7170729", "0.71611345", "0.7105172", "0.7076959", "0.6902277", "0.6868089", "0.6856292...
0.8187841
1
x component of the coordinates of the whole domain (halo points included).
def x_halo(self): return self.coords_halo[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x_coord(self):\n\n return self.x0 + np.arange(self.nx) * self.dx", "def x(self):\n if self._x is None:\n self.compute_coordinates()\n return self._x", "def x(self):\n return self.coords[0]", "def x(self):\n return self._coords[0]", "def get_x(self):\n ...
[ "0.7628023", "0.7627613", "0.7605079", "0.7560858", "0.75197285", "0.73364943", "0.7319262", "0.7208585", "0.7040728", "0.70402396", "0.700919", "0.6968909", "0.69673264", "0.6955738", "0.69547075", "0.69454676", "0.69199395", "0.682559", "0.681483", "0.6806043", "0.6782578",...
0.77378696
0
y component of the coordinates of the whole domain (halo points included).
def y_halo(self): return self.coords_halo[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y_coord(self):\n\n return self.y0 + np.arange(self.ny) * self.dy", "def y(self):\n return self.coords[1]", "def get_y(self):\n return self.__y", "def y(self):\n return self._coords[1]", "def y(self):\n if self._y is None:\n self.compute_coordinates()\n ...
[ "0.7791334", "0.7649934", "0.7597563", "0.75450903", "0.75338155", "0.75070745", "0.74508405", "0.7420105", "0.74109304", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.7409863", "0.73475975", "0.7347597...
0.80401057
0
z component of the coordinates of the whole domain (halo points included).
def z_halo(self): return self.coords_halo[2]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_z(self):\n return self.coords[2]", "def z(self):\n return self.coords[2]", "def z(self):\n return self._coords[2]", "def getZ(self):\n\t\treturn self.coords.z", "def getZCoord(self, x, y):\n n = self.normal()\n z = (-n.x * (x - self.p0.x) - n.y * (y - self.p0.y) +...
[ "0.76964957", "0.7511645", "0.74793464", "0.7448726", "0.7278982", "0.7142226", "0.70404834", "0.69665307", "0.69276017", "0.6924901", "0.68958646", "0.68958646", "0.68958646", "0.68489766", "0.68006426", "0.6787681", "0.6751956", "0.6748075", "0.6724205", "0.66953576", "0.66...
0.7551448
1
Check the validity of the dictionnary which define the domain. Parameter
def check_dictionary(self, dico): if dico is not None: self.log.info('Check the dictionary') test, aff = validate(dico, proto_domain, test_comp = False) if test: self.log.info(aff) else: self.log.error(aff) sys.exit(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_domain_additional(cls, domain: D) -> bool:\n action_space = domain.get_action_space().unwrapped()\n observation_space = domain.get_observation_space().unwrapped()\n\n if not isinstance(action_space, Iterable) and not isinstance(action_space, gym.spaces.Tuple):\n action_sp...
[ "0.65451413", "0.6538749", "0.6353704", "0.6342437", "0.6328692", "0.63006294", "0.6273927", "0.61062527", "0.60574967", "0.6056676", "0.60533655", "0.59491223", "0.5946937", "0.59356123", "0.5934907", "0.5897498", "0.5869605", "0.5868954", "0.58672255", "0.586326", "0.584886...
0.7223405
0
Create the mpi topology
def construct_mpi_topology(self, dico): period = [True]*self.dim if dico is None: comm = mpi.COMM_WORLD else: comm = dico.get('comm', mpi.COMM_WORLD) self.mpi_topo = MPI_topology(self.dim, period, comm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createTopology(self):\n\n # find DAG root\n dagRoot = None\n for mote in self.motes:\n if mote.id == 0:\n mote.role_setDagRoot()\n dagRoot = mote\n assert dagRoot\n\n if self.settings.mobilityModel == 'RPGM':\n # put DAG roo...
[ "0.69177186", "0.6628953", "0.6226658", "0.61995256", "0.61995256", "0.60618436", "0.60247886", "0.6013558", "0.5998706", "0.59884655", "0.5967811", "0.5916848", "0.58346283", "0.5791707", "0.57730216", "0.5722135", "0.57025063", "0.5692879", "0.56564605", "0.5617648", "0.556...
0.7762457
0
Create the coordinates of the interior domain and the whole domain with halo points.
def create_coords(self): phys_box = self.geom.bounds # the physical box where the domain lies # validation of the space step with the physical box size for k in range(self.dim): self.global_size.append((phys_box[k][1] - phys_box[k][0])/self.dx) if not self.global_size[-1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shape_with_halo(self):\n # TODO: Drop me after the domain-allocation switch, as this method\n # will be provided by the superclass\n return tuple(j + i + k for i, (j, k) in zip(self.shape_domain, self._halo))", "def get_bounds_halo(self):\n bottom_right = np.asarray([self.coords_h...
[ "0.629629", "0.6192578", "0.6049337", "0.58665466", "0.58665466", "0.5679478", "0.5666392", "0.55614126", "0.5559982", "0.55101025", "0.5502505", "0.5448007", "0.5385942", "0.53807485", "0.5354319", "0.53424925", "0.53216344", "0.52725726", "0.5272524", "0.52718675", "0.52423...
0.68091905
0
Return the coordinates of the bottom right and upper left corner of the whole domain with halo points.
def get_bounds_halo(self): bottom_right = np.asarray([self.coords_halo[k][0] for k in range(self.dim)]) upper_left = np.asarray([self.coords_halo[k][-1] for k in range(self.dim)]) return bottom_right, upper_left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bounds(self):\n bottom_right = np.asarray([self.coords[k][0] for k in range(self.dim)])\n upper_left = np.asarray([self.coords[k][-1] for k in range(self.dim)])\n return bottom_right, upper_left", "def bottomLeftCorner(self):\n self._updateExtents()\n return (self._mMin...
[ "0.67394066", "0.67303276", "0.66209525", "0.65128374", "0.64220613", "0.64210343", "0.6401192", "0.63610166", "0.6264927", "0.62276", "0.6118288", "0.59756935", "0.59198815", "0.5914908", "0.5878579", "0.58711284", "0.58591115", "0.580208", "0.5798796", "0.578806", "0.577766...
0.8023142
0
Return the coordinates of the bottom right and upper left corner of the interior domain.
def get_bounds(self): bottom_right = np.asarray([self.coords[k][0] for k in range(self.dim)]) upper_left = np.asarray([self.coords[k][-1] for k in range(self.dim)]) return bottom_right, upper_left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bounds_halo(self):\n bottom_right = np.asarray([self.coords_halo[k][0] for k in range(self.dim)])\n upper_left = np.asarray([self.coords_halo[k][-1] for k in range(self.dim)])\n return bottom_right, upper_left", "def bottomLeftCorner(self):\n self._updateExtents()\n ret...
[ "0.76211905", "0.7292665", "0.69914323", "0.67774415", "0.6669149", "0.6615716", "0.6581587", "0.6549148", "0.6523538", "0.65019536", "0.64836305", "0.64644194", "0.64228207", "0.6417498", "0.6398502", "0.63445574", "0.63234276", "0.6316152", "0.6315162", "0.6314326", "0.6278...
0.77522284
0
Add an element if elem.isfluid = False as a solid part. (bw=0) if elem.isfluid = True as a fluid part. (bw=1)
def __add_elem(self, elem): # compute the box around the element adding vmax safety points vmax = self.stencil.vmax elem_bl, elem_ur = elem.get_bounds() phys_bl, phys_ur = self.get_bounds_halo() tmp = np.array((elem_bl - phys_bl)/self.dx, np.int) - vmax nmin = np.maximum...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sketch_und_part(self):\n if (self.dimension == '3D'):\n #Sketch Wuerfel zeichnen\n self.sketch_Wuerfel = self.model.ConstrainedSketch(\n name='Seitenansicht_Wuerfel',\n sheetSize=200.0)\n self.sketch_Wuerfel.rectangle(\n point...
[ "0.5353897", "0.52898836", "0.52194977", "0.5092196", "0.49273452", "0.48061937", "0.47618276", "0.47300842", "0.47194925", "0.4717585", "0.46338245", "0.46224457", "0.46221817", "0.46195388", "0.46033767", "0.4593283", "0.45669478", "0.45467424", "0.45268017", "0.45268017", ...
0.61179656
0
Get the list of all the labels used in the geometry.
def list_of_labels(self): L = np.unique(self.box_label) return np.union1d(L, self.geom.list_of_elements_labels())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_labels(self):\n return []", "def get_labels(self) -> List[str]:\n raise NotImplementedError()", "def get_labels(self) -> Set[str]:", "def get_labels(self) -> List[str]:\n return self.labels", "def labels(self):\n return self._labels", "def labels_all(self):\n return sel...
[ "0.78688353", "0.77143806", "0.7649815", "0.76258653", "0.7622505", "0.7539628", "0.7502521", "0.74491197", "0.74491197", "0.74491197", "0.74491197", "0.74491197", "0.74491197", "0.7397355", "0.7367742", "0.7357493", "0.73287654", "0.73217773", "0.7304837", "0.7304837", "0.73...
0.7938898
0
Visualize the domain by creating a plot.
def visualize(self, viewer_app=viewer.matplotlibViewer, view_distance=False, view_in=True, view_out=True, view_bound=False, label=None): fig = viewer_app.Fig(dim = self.dim) view = fig[0] if isinstance(view_distance, bool): view_seg = view_distance view_distance = list(r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_plot(self):\r\n\t\tx, y = zip(*[p.p for p in self.universe])\r\n\t\tself.ax.cla()\r\n\t\tself.ax.plot(x, y, '.')\r\n\t\tself.ax.set_title('Universe at time: %d' % self.universe.time)\r\n\t\tself.ax.set_xlim([P_MU-4*P_STD, P_MU+4*P_STD])\r\n\t\tself.ax.set_ylim([P_MU-4*P_STD, P_MU+4*P_STD])", "def vi...
[ "0.7162099", "0.7078026", "0.70367897", "0.6830851", "0.68271685", "0.6822806", "0.6790577", "0.67280227", "0.6702536", "0.6591383", "0.65613216", "0.6556937", "0.6517892", "0.6462875", "0.64443344", "0.6443013", "0.6442326", "0.6401814", "0.63987905", "0.63952917", "0.638571...
0.0
-1
Function that writes all the informations of a domain
def verification(dom, with_color=False): # some terminal colors if with_color: blue = '\033[01;05;44m' black = '\033[0m' green = '\033[92m' white = '\033[01;37;44m' else: blue = '' black = '' green = '' white = '' print('Nombre de points :...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self):\n self.__domainlist.sort()\n\n try:\n fileobject = open(filename, mode=\"w\")\n for domain in self.__domainlist:\n fileobject.write(domain + \"\\n\")\n fileobject.close()\n except:\n print(\"Error when writing file\")"...
[ "0.7394263", "0.6997635", "0.6566115", "0.6418956", "0.63475776", "0.6291576", "0.60947907", "0.6093731", "0.6071532", "0.60149324", "0.5960534", "0.5881924", "0.58262575", "0.5778478", "0.5778478", "0.56793374", "0.5558486", "0.5536063", "0.55333006", "0.55250967", "0.552432...
0.0
-1
Create snapshot with unexpected device count for previous versions.
def test_create_with_too_many_devices(test_microvm_with_api): test_microvm = test_microvm_with_api # Create and start a microVM with `FC_V0_23_MAX_DEVICES_ATTACHED` # network devices. devices_no = FC_V0_23_MAX_DEVICES_ATTACHED _create_and_start_microvm_with_net_devices(test_microvm, devices_no) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_snapshot_compatibility(microvm_factory, guest_kernel, rootfs):\n vm = microvm_factory.build(guest_kernel, rootfs)\n vm.spawn()\n vm.basic_config(\n vcpu_count=2,\n mem_size_mib=256,\n )\n\n # Add a memory balloon with stats enabled.\n vm.api.balloon.put(amount_mib=0, deflat...
[ "0.5707831", "0.5573247", "0.5530108", "0.55096114", "0.5387642", "0.525641", "0.52525467", "0.52115786", "0.5178012", "0.51598006", "0.5086971", "0.5044647", "0.5015125", "0.49779987", "0.49674007", "0.4938787", "0.49172089", "0.49106458", "0.48969096", "0.48893365", "0.4873...
0.607721
0
Tests taking a snapshot at the version specified in Cargo.toml Check that it is possible to take a snapshot at the version of the upcoming release (during the release process this ensures that if we release version x.y, then taking a snapshot at version x.y works something we'd otherwise only be able to test once the x...
def test_snapshot_current_version(uvm_nano): vm = uvm_nano vm.start() version = get_firecracker_version_from_toml() # normalize to a snapshot version target_version = f"{version.major}.{version.minor}.0" snapshot = vm.snapshot_full(target_version=target_version) # Fetch Firecracker binary ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_pre_release(scraper, version_parts):\n\n new_version_parts = list(version_parts)\n if len(new_version_parts) > 4:\n new_version_parts[4] = int(new_version_parts[4]) + 1\n elif len(new_version_parts) > 3:\n new_version_parts.append(1)\n else:\n new_version_parts.extend(['a'...
[ "0.6502068", "0.6310254", "0.6265", "0.6260519", "0.6240066", "0.62363416", "0.6196736", "0.61603254", "0.6096417", "0.6088469", "0.60742664", "0.6066883", "0.6045832", "0.6043664", "0.603125", "0.5988045", "0.5978905", "0.5974485", "0.5948521", "0.59446055", "0.5923739", "...
0.70966417
0
Attempt to create a snapshot with newer virtio features.
def test_create_with_newer_virtio_features(uvm_nano): test_microvm = uvm_nano test_microvm.add_net_iface() test_microvm.start() # Init a ssh connection in order to wait for the VM to boot. This way # we can be sure that the block device was activated. test_microvm.ssh.run("true") # Pause m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_snapshot_compatibility(microvm_factory, guest_kernel, rootfs):\n vm = microvm_factory.build(guest_kernel, rootfs)\n vm.spawn()\n vm.basic_config(\n vcpu_count=2,\n mem_size_mib=256,\n )\n\n # Add a memory balloon with stats enabled.\n vm.api.balloon.put(amount_mib=0, deflat...
[ "0.67031753", "0.5935706", "0.5914112", "0.5762848", "0.5759202", "0.5687569", "0.5678241", "0.56615245", "0.56577706", "0.556173", "0.5539944", "0.5531928", "0.552826", "0.54974014", "0.54896766", "0.5480551", "0.54506993", "0.5432392", "0.54126745", "0.54020923", "0.5380297...
0.7215181
0
Verifies that we can't create a snapshot with target version less than 1.5 if cpu template with additional vcpu features or kvm capabilities is in use.
def test_create_with_1_5_cpu_template(uvm_plain): # We remove KVM_CAP_IOEVENTFD from kvm checks just for testing purpose. custom_cpu_template = json.loads('{"kvm_capabilities": ["!36"]}') test_microvm = uvm_plain test_microvm.spawn() test_microvm.basic_config(vcpu_count=2, mem_size_mib=256) te...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_with_newer_virtio_features(uvm_nano):\n test_microvm = uvm_nano\n test_microvm.add_net_iface()\n test_microvm.start()\n\n # Init a ssh connection in order to wait for the VM to boot. This way\n # we can be sure that the block device was activated.\n test_microvm.ssh.run(\"true\")\...
[ "0.65462935", "0.6420692", "0.6118976", "0.60601354", "0.60190666", "0.5678747", "0.5554583", "0.55517364", "0.5539511", "0.55231994", "0.54974645", "0.5484495", "0.5428318", "0.54254496", "0.54118603", "0.5407401", "0.540111", "0.5394907", "0.5390333", "0.53765833", "0.53608...
0.7106182
0
Compare power function with builtin exponentiation
def pass_test(power_func, num, pow): true_pow = num**pow # Print accordingly if true_pow == power_func(num, pow): print("Test Passed") else: print("Error: Test not passed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def power(num, exponent):\n return num ** exponent", "def power(a, b):\n \n return a**b", "def power(a, b):\n pass", "def power(num, exponent):\n power = num ** exponent\n return power", "def exponent(num,power=2):\n return num ** power", "def power(num1, num2):\n exponent = num1 *...
[ "0.7698817", "0.76238865", "0.7567662", "0.75390667", "0.74961966", "0.7377043", "0.7375325", "0.73349035", "0.7298315", "0.71073616", "0.70669913", "0.70454425", "0.70377856", "0.7021158", "0.6987446", "0.69689125", "0.6905377", "0.6866605", "0.67770195", "0.67557365", "0.66...
0.7073906
10
Test for correctness and run time.
def full_test(power_func, test_num, test_pow, test_dict): # Get sort_func name func_name = power_func.__name__ # Measure time function takes start = timer() power_func(test_num, test_pow) end = timer() # Store time in test dictionary test_dict[func_name] = end-start # Test for correc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self, runtime):", "def check():", "def test_check_cost():", "def runTest(self):\n return True", "def test_comprehensive_system(self):\n\n with ROV_Validity_Table() as db:\n\n # Run MRT_Parser to fill mrt_announcements table which will\n # be used as the input t...
[ "0.76117027", "0.73374003", "0.7305376", "0.7104261", "0.70961267", "0.7000361", "0.69930726", "0.69748384", "0.688779", "0.688779", "0.68223035", "0.6801772", "0.6791196", "0.67599744", "0.67599744", "0.67599744", "0.6759878", "0.67136264", "0.67136264", "0.67119783", "0.671...
0.0
-1
Read the special config blocks and store in a dictionary
def parse_special(special): special_name = "" specials = {} for line in special: if check_template_start(line): special_name = line.split(":")[1] specials[special_name] = [] elif check_template_end(line): special_name = "" elif special_name != "": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_block_config():\n ret = {}\n ret[keyword.function] = []\n ret[keyword.inputs] = []\n ret[keyword.expect] = []\n return ret", "def parse_config(fpath):\n\n with open(fpath, \"r\") as f:\n # Ignore lines consisting only of whitespace or commented lines.\n lines = [\n ...
[ "0.7062198", "0.65265226", "0.6522121", "0.63530326", "0.63237303", "0.6279691", "0.6254327", "0.62248856", "0.62101585", "0.62071514", "0.6206471", "0.6194919", "0.6155586", "0.61548185", "0.608414", "0.6081995", "0.6007709", "0.5962564", "0.59612393", "0.59369946", "0.59031...
0.5562557
75
Replace all special lines with their blocks in the special config
def replace_base(base, specials): new_config = [] for line in base: new_config.append(line) if check_template_start(line): # Found template line, try to add special special = line.split(":")[1] if special in specials: new_config.extend(specials...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace(lines):\n for index, line in enumerate(lines):\n if not line == '\\n':\n token_line = tokenizer.tokenize_line(line)\n for ind, tok in enumerate(token_line):\n if token_line[ind][1] in replacement_dic.keys() and token_line[ind][1] not in ignore_variable:\n ...
[ "0.60071075", "0.59372526", "0.5920741", "0.57225025", "0.5639018", "0.56047815", "0.5575346", "0.5567408", "0.5562298", "0.55614144", "0.55471146", "0.55306953", "0.5528332", "0.5473518", "0.5411829", "0.54098475", "0.5369975", "0.53312016", "0.5301475", "0.5291877", "0.5289...
0.70681936
0
Clip a polygon with another polygon.
def polygon_clip(subjectPolygon, clipPolygon): def inside(p): return (cp2[0] - cp1[0]) * (p[1] - cp1[1]) > (cp2[1] - cp1[1]) * (p[0] - cp1[0]) def computeIntersection(): dc = [cp1[0] - cp2[0], cp1[1] - cp2[1]] dp = [s[0] - e[0], s[1] - e[1]] n1 = cp1[0] * cp2[1] - cp1[1] * cp2[0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clip_polygon(subject, clipper, operation = 'difference'):\n Subject = Polygon()\n Clipper = Polygon()\n\n for s in subject:\n Subject.add(Vertex(s))\n\n for c in clipper:\n Clipper.add(Vertex(c))\n\n clipped = Clipper.difference(Subject)\\\n if operation == 'reversed-diff'\\\n ...
[ "0.73871416", "0.71527326", "0.67622846", "0.6655635", "0.66529", "0.6612446", "0.65643936", "0.6487739", "0.6454339", "0.6290975", "0.6247579", "0.6042842", "0.6040423", "0.60388094", "0.60388094", "0.60195905", "0.59496385", "0.5936355", "0.5933871", "0.5932276", "0.5883224...
0.6551858
7
Compute area of two convex hull's intersection area. p1,p2 are a list of (x,y) tuples of hull vertices. return a list of (x,y) for the intersection and its volume
def convex_hull_intersection(p1, p2): inter_p = polygon_clip(p1,p2) if inter_p is not None: hull_inter = ConvexHull(inter_p) return inter_p, hull_inter.volume else: return None, 0.0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convex_hull_intersection(p1, p2):\n inter_p = polygon_clip(p1, p2)\n if inter_p is not None:\n hull_inter = ConvexHull(inter_p)\n return inter_p, hull_inter.volume\n else:\n return None, 0.0", "def convex_hull_intersection(self, p1, p2):\n inter_p = self.polygon_clip(p1,p...
[ "0.8143819", "0.8140708", "0.70325965", "0.6644891", "0.65631235", "0.63782674", "0.6323484", "0.629715", "0.61973083", "0.6167351", "0.61586636", "0.6157963", "0.6141326", "0.6125375", "0.61231095", "0.6099263", "0.60979515", "0.60971546", "0.6084221", "0.6077353", "0.607299...
0.81397164
3
All possible tiers Each tier is a tuple in alphabetical order
def build_tiers(self): self.tiers = [] for size in range(1,len(self.sigma)+1): for combo in itertools.combinations(self.sigma, size): self.tiers.append(tuple(sorted(list(combo))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def part_1():\n return itertools.permutations(range(5))", "def flip(tier: int) -> list:\n pool = load_minion_pool()\n n_to_show = tier // 2 + 3\n available_minions = []\n\n for t in range(1, tier + 1):\n for _ in range(settings.TIER_COUNTS[t]):\n available_minions += pool[str(t)]...
[ "0.5811346", "0.57635534", "0.56175697", "0.55959123", "0.5509604", "0.5472255", "0.54375213", "0.5435182", "0.5416104", "0.54044276", "0.5403584", "0.5363441", "0.5363441", "0.53515655", "0.5348641", "0.534456", "0.5333362", "0.5300959", "0.5291334", "0.5283928", "0.5224548"...
0.6834271
0
Patch an object with a needed attribute.
def patch_object(mocker): def _object(obj_to_patch, attribute, return_value): mock_func = mocker.patch.object(obj_to_patch, attribute) if return_value is not None: mock_func.return_value = return_value return _object
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch(self, obj, field, value):\n return Patch(obj, field, value)", "def Patch(self, obj):\n # TODO (jason.stredwick): Change to\n # auto_update_attr = class_attr.GetPODAttrs(Bug)\n # once the special cases have been resolved.\n special_props = ['target_element', 'has_target_element',\n ...
[ "0.76002645", "0.72562224", "0.69803596", "0.6769369", "0.65772796", "0.65772796", "0.65426695", "0.65337133", "0.65073776", "0.64899504", "0.6477458", "0.6455356", "0.6347116", "0.63402766", "0.6297255", "0.62557065", "0.62532693", "0.6205195", "0.6205195", "0.6205195", "0.6...
0.60075223
33
Mock clip.Path to get a different path than the default.
def mock_path(mocker): def _path(module, side_effect): mock_func = mocker.patch(f'{module}.Path.mkdir') mock_func.side_effect = side_effect return _path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_set_path_4(self, verify_path2_mock):\n test_file = Path(\"/dir1/dir2/../file.txt\")\n verify_path2_mock.return_value = (True, None)\n output = basic.set_path(test_file, kind=\"file\", expect=True)\n exp = Path(\"/dir1/file.txt\")\n self.assertEqual(output, exp)", "def ...
[ "0.62415814", "0.6212893", "0.6178796", "0.6098295", "0.6094493", "0.59861505", "0.5955945", "0.5938097", "0.584768", "0.5844672", "0.57498765", "0.5744569", "0.5736058", "0.57053375", "0.57032806", "0.5697243", "0.5694985", "0.5653811", "0.56268764", "0.5626876", "0.56013525...
0.5195472
49
Mock clip.Path to get a different path than the default.
def mock_path_mkdir(mocker): def _path(obj_to_patch, attribute, side_effect): mock_func = mocker.patch.object(obj_to_patch, attribute) mock_func.side_effect = side_effect return _path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_set_path_4(self, verify_path2_mock):\n test_file = Path(\"/dir1/dir2/../file.txt\")\n verify_path2_mock.return_value = (True, None)\n output = basic.set_path(test_file, kind=\"file\", expect=True)\n exp = Path(\"/dir1/file.txt\")\n self.assertEqual(output, exp)", "def ...
[ "0.6240082", "0.6211727", "0.6177706", "0.6096658", "0.6093146", "0.5984969", "0.59549236", "0.5936637", "0.584658", "0.5843622", "0.5748406", "0.57428294", "0.5735809", "0.5704555", "0.5702183", "0.5695934", "0.5695079", "0.56529605", "0.562511", "0.56249416", "0.5601013", ...
0.0
-1
Mock the requests.get return value. If we try to set attributes on requests.get directly, we'll
def mock_requests_get(mocker, mocked_requests_get): def _requests_get(module, content, status): mock_func = mocker.patch(f'{module}.requests.get') mock_func.return_value = mocked_requests_get(content, status) return _requests_get
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mock_requests_get(self, mocker):\n mock = mocker.patch(\"requests.get\")\n mock.return_value.__enter__.return_value.json.return_value = {\n \"item\": {\n \"icon\": \"\",\n \"icon_large\": \"\",\n \"id\": 21787,\n \"type\": \"M...
[ "0.72807246", "0.72359955", "0.7179954", "0.70539004", "0.7024782", "0.69704086", "0.69374245", "0.68708456", "0.6863891", "0.68198556", "0.67906505", "0.6764723", "0.67489815", "0.6732757", "0.6729054", "0.6710932", "0.66979325", "0.6666944", "0.6651065", "0.66106665", "0.65...
0.719874
2
Simulate requests raising an exception.
def mock_requests_exception(mocker): def _requests_exception(module, exception): mock_func = mocker.patch(f'{module}.requests.get') mock_func.side_effect = exception return _requests_exception
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _raise_performing_request_error(self, *args, **kwargs):", "def test_exception():\n class Handler(RequestHandler):\n def get(self):\n self.set_status(400)\n self.write('Fail')\n\n app = Application([url('/hello', Handler)])\n\n with Tester(app) as tester:\n for i i...
[ "0.7364481", "0.72800875", "0.69547635", "0.6914229", "0.67766964", "0.67396665", "0.6722903", "0.6688388", "0.6677752", "0.6655239", "0.66538423", "0.6649622", "0.66298413", "0.6622028", "0.66155547", "0.66072726", "0.65861887", "0.65859425", "0.65722626", "0.6570693", "0.65...
0.6127084
63
Create a fake requests.Response object.
def mocked_requests_get(): class MockResponse: def __init__(self, _content, _status): self.content = _content self.status_code = _status def content(self): return self.content return MockResponse
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response():\n def inner(ret_code, ret_value):\n \"\"\"Set up response with the given parameters.\n\n :param ret_code: Return code for the response\n :param ret_value: Return value for the response\n :return: Mocked Responce object with the given parameters\n \"\"...
[ "0.736011", "0.71040297", "0.7098835", "0.6869094", "0.6854902", "0.6733961", "0.6733961", "0.6719025", "0.6631267", "0.6599584", "0.6549238", "0.65430015", "0.6531704", "0.6485677", "0.64722425", "0.643935", "0.64389443", "0.6423061", "0.642237", "0.6392279", "0.63886", "0...
0.73249215
1
Delete all schedules from storage
def wipe(self):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_all():\n storage = FileStorage()\n objects = storage.all()\n objects = list(objects.values())\n\n for element in objects:\n storage.delete(element)\n objects = storage.all()", "def remove_all():\n \"\"\" Removes all from the database \"\"\"\n ...
[ "0.67903996", "0.6692977", "0.65550745", "0.6550395", "0.6493148", "0.64656925", "0.64595354", "0.6438414", "0.6422963", "0.63632655", "0.6361692", "0.63402975", "0.63228196", "0.6302844", "0.6288532", "0.62680525", "0.62613064", "0.624178", "0.62197363", "0.6144944", "0.6121...
0.0
-1
Return all JobStates present in storage
def all_stored_job_state(self, repository_origin_id=None, job_type=None):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_states():\n states = []\n for state in storage.all(\"State\").values():\n states.append(state.to_dict())\n return jsonify(states)", "def get_states():\n all_states = []\n states = storage.all(State).values()\n for state in states:\n all_states.append(state.to_dict())\n ...
[ "0.70959705", "0.70369786", "0.70325696", "0.6953881", "0.6952176", "0.6944491", "0.6943182", "0.68910843", "0.6842506", "0.6766063", "0.6744036", "0.6644306", "0.649214", "0.64365315", "0.6280112", "0.6280112", "0.62451684", "0.62207997", "0.62207997", "0.621835", "0.6201651...
0.732007
0
Return the unique job with the given id
def get_job_state(self, job_origin_id):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_job_by_id(self, job_id):\n return self.get_resource(category=SYSTEM, resource_level=JOB,\n resource_level_id=job_id)", "def get_job(self, _id):\n data = {\n 'class': 'Job',\n 'id': _id,\n 'attrs': {},\n }\n job =...
[ "0.7371126", "0.7347247", "0.7267338", "0.725329", "0.71483725", "0.71149886", "0.7078288", "0.7053403", "0.70340437", "0.7011335", "0.6989745", "0.698619", "0.69853693", "0.6967988", "0.69580775", "0.69107187", "0.6877992", "0.68590534", "0.68409127", "0.67786914", "0.673982...
0.0
-1
Add a job to storage.
def add_job_state(self, job):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, job):\r\n self.jobs.put(job)", "def add_job(self, job):\n self.job_list.append(job)\n return", "def add_job(self, job):\n with self._mutex:\n self._jobs.append(job)", "def add_job(self, job):\n self.job_list.append(job)\n self.num_jobs += 1",...
[ "0.8303181", "0.7816713", "0.769324", "0.76033986", "0.72202975", "0.71949184", "0.7073336", "0.7073336", "0.7062141", "0.68707186", "0.68078905", "0.6772507", "0.6732047", "0.6640165", "0.6637045", "0.66317594", "0.65742826", "0.6526206", "0.6507963", "0.63838726", "0.638387...
0.61567235
29
Update a job in storage.
def update_job_state(self, job):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self):\n self._log.debug(\"About to update job {0}\".format(self.id))\n resp = self._api.get_job(self.id)\n\n if resp.success:\n self.submission = self._format_submission(resp.result)\n return True\n\n else:\n raise resp.result", "def update...
[ "0.68505573", "0.67774576", "0.6659658", "0.6659658", "0.6659658", "0.6659658", "0.6564279", "0.6517204", "0.6458511", "0.6458511", "0.64496225", "0.6410681", "0.6359297", "0.6357958", "0.6333834", "0.63191736", "0.63028765", "0.62683195", "0.61782503", "0.6171958", "0.616505...
0.66005653
6
Delete a job in storage.
def delete_job_state(self, job_origin_id):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _delete_job(self, job):", "def _delete_job(self, job):\n with self.db_lock:\n return self.rcon.zrem(job)", "def job_delete(job):\n\n if os.path.exists(job.output_abspath):\n os.remove(job.output_abspath)\n db.session.delete(job)\n db.session.commit()", "def delete_job(se...
[ "0.812532", "0.7588499", "0.7546053", "0.7532317", "0.7443797", "0.7427653", "0.7349561", "0.73434865", "0.72797036", "0.7231576", "0.6949614", "0.6915326", "0.68772835", "0.687612", "0.6850112", "0.6781744", "0.67704695", "0.67349565", "0.6731967", "0.66634506", "0.66589355"...
0.611005
54
Get the ticks for a given job.
def get_job_ticks(self, job_origin_id):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_job_tick_stats(self, job_origin_id):", "def get_ticks(self):\n return pg.time.get_ticks()", "def get_latest_job_tick(self, job_origin_id):", "def get_ticks(self, market, period):\n return self.__call__('market', 'GetTicks',\n {'marketName': market,\n ...
[ "0.6805147", "0.65050817", "0.63807094", "0.6250666", "0.5612657", "0.5576679", "0.55496687", "0.5537462", "0.5457608", "0.54030746", "0.5366965", "0.53657764", "0.5344443", "0.5304836", "0.53023386", "0.529134", "0.528076", "0.5270107", "0.52592474", "0.5257897", "0.52511895...
0.79622924
0
Get the most recent tick for a given job.
def get_latest_job_tick(self, job_origin_id):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_job(self): # TOFIX model the job and return an object instead of dictionary\n return self._data.get('summary_fields', {}).get('last_job')", "def latest_job(self):\n return self.jobmanagers[self.current_network].latest_job", "def get_last_job_id():\n\n return JobDetail.query.with_enti...
[ "0.6885023", "0.68426526", "0.63668716", "0.625937", "0.61686134", "0.61422634", "0.6088384", "0.60683393", "0.60473347", "0.604174", "0.5943635", "0.5943489", "0.58863485", "0.58651054", "0.5843796", "0.58378553", "0.5831277", "0.57627594", "0.57353145", "0.5645166", "0.5631...
0.79333454
0
Add a job tick to storage.
def create_job_tick(self, job_tick_data):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, job):\r\n self.jobs.put(job)", "def update_job_tick(self, tick):", "def add_job(self, job):\n self.job_list.append(job)\n self.num_jobs += 1", "def add_job(self, job):\n self.job_list.append(job)\n return", "def add_job(self, job):\n with self._mutex:...
[ "0.68822646", "0.644974", "0.6336911", "0.60865444", "0.6081882", "0.5925319", "0.58823025", "0.5867289", "0.58074796", "0.5784127", "0.5779706", "0.5779706", "0.576042", "0.5738642", "0.5720947", "0.56882465", "0.56653124", "0.56326026", "0.561558", "0.56124854", "0.5605226"...
0.6734833
1
Update a job tick already in storage.
def update_job_tick(self, tick):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_tick(self, tick: InstigatorTick):", "def update_job_state(self, job):", "def update(self, ticks):\n self.quantity_cursor.update(ticks)", "def on_job_update(_job):\n nonlocal job\n job = _job", "def on_job_update(_job):\n nonlocal job\n job = _job", "def on_jo...
[ "0.65579045", "0.6554705", "0.6091657", "0.6049211", "0.6049211", "0.6049211", "0.6049211", "0.5960409", "0.5899886", "0.5852035", "0.5800887", "0.5797093", "0.5778178", "0.5775377", "0.5766446", "0.57579905", "0.57497984", "0.5748029", "0.5748029", "0.5748029", "0.5717909", ...
0.78228307
0
Wipe ticks for a job for a certain status and timestamp.
def purge_job_ticks(self, job_origin_id, tick_status, before):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def purge_ticks(self, origin_id: str, tick_status: TickStatus, before: float):", "def __delete_job_status(self, job: Job):\n\n keys = self._get_keys(f'jobstatus:{job.id}:*')\n for key in keys:\n self.redis_client.delete(key)", "def _cleanupDownCounts(self):\n now = datetime.now(...
[ "0.6632468", "0.5895949", "0.5505163", "0.5471308", "0.5446002", "0.5350745", "0.5347354", "0.53052574", "0.5266057", "0.5187827", "0.51671374", "0.516343", "0.51591295", "0.51247317", "0.5116081", "0.5100693", "0.5090704", "0.50796276", "0.5065009", "0.50444114", "0.5044082"...
0.7620381
0
Get tick stats for a given job.
def get_job_tick_stats(self, job_origin_id):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_job_stats(self, job_name):\n return self.manager.get_job_stats(job_name)", "def get_job_ticks(self, job_origin_id):", "def stats(self):\n resp = self.server.request(\"get\", \"/jobs/%s/%s/stats\" %\n (self.sessionid, self.name))\n return self.server.json_body(resp)",...
[ "0.686602", "0.6589052", "0.61278665", "0.59427047", "0.58626354", "0.57995313", "0.5791054", "0.57735854", "0.56960267", "0.5658474", "0.56300795", "0.5602183", "0.55705327", "0.55694175", "0.5538241", "0.5442942", "0.54197836", "0.5391828", "0.53831077", "0.53716314", "0.53...
0.7929325
0
Perform any needed migrations
def upgrade(self):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migration():", "def post_migrations(self):", "def migrate(self):\n\tpass", "def run_migration_checks():\n check_model_state()\n check_migration_state()", "def perform_migration():\n with cd(env.code_dir):\n with _virtualenv():\n sudo('python manage.py migrate --settings=prod_...
[ "0.77959275", "0.77799666", "0.7711844", "0.73845613", "0.73517853", "0.73338085", "0.7192316", "0.7185039", "0.715605", "0.71404064", "0.7015841", "0.6983788", "0.6967566", "0.68327975", "0.68189925", "0.680037", "0.6735632", "0.66867834", "0.66476285", "0.66215956", "0.6595...
0.0
-1
Allows for optimizing database connection / use in the context of a long lived dagit process
def optimize_for_dagit(self, statement_timeout):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db():\n raise TimeoutError", "def _db_connection(self):\n pass", "def main():\n config = Config.init_from_env()\n\n while True:\n logger.info('running query...')\n\n conn = connect_to_db(config)\n with conn.cursor() as cur:\n cur.execute(\"\"\"SELECT datname ...
[ "0.6886876", "0.6700232", "0.6482189", "0.6420081", "0.633664", "0.6292243", "0.6285649", "0.6235156", "0.61463004", "0.6138491", "0.6135904", "0.6121325", "0.61131597", "0.6103187", "0.6099227", "0.6063172", "0.60518104", "0.60201025", "0.60201025", "0.60201025", "0.60201025...
0.0
-1
Initialize the source object
def __init__(self, RA, DEC, AST, I_data, Q_data, U_data, V_data): self.RA = RA self.DEC = DEC self.AST = AST self.I_data = I_data self.Q_data = Q_data self.U_data = U_data self.V_data = V_data self.fit_p = None self.e_fit_p = None self.good...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, source):\n self._source = source", "def __init__(self, source):\n self.source = source", "def __init__(self, source):\n self.source = source", "def __init__(self, source):\r\n self.source = source", "def __init__(self, source, *args, **kwargs):\n super(...
[ "0.84137446", "0.81543994", "0.81543994", "0.81408143", "0.8004293", "0.7625181", "0.71825546", "0.71825546", "0.71825546", "0.71825546", "0.71825546", "0.71825546", "0.71825546", "0.71825546", "0.71547294", "0.71457464", "0.7138613", "0.7136901", "0.7135622", "0.7135622", "0...
0.0
-1
Fit cluster I vs RAcos(Dec) and Dec
def fit(self, filename, **options): amp_guess = np.max(self.I_data) center_x_guess = self.RA[self.I_data.argmax()] center_y_guess = self.DEC[self.I_data.argmax()] # cos dec correction center_x_guess = center_x_guess*np.cos(np.deg2rad(center_y_guess)) sigma_x_guess = optio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit(self):\n self.cluseter_agglomerative(n_clusters=20, linkage='average', iterate=5)\n self.sub_clustering(n_clusters=3, index_cluster=[79], linkage='complete')\n self.merge_clusters([[0,9,53],[1,83],[46,35,67],[88,23],[6,68]])\n self.merge_clusters([[6,33,52],[17,14]])\n se...
[ "0.6232339", "0.5684823", "0.5617525", "0.553194", "0.547829", "0.541152", "0.54086167", "0.53931034", "0.53846407", "0.537234", "0.5349465", "0.53037167", "0.5292465", "0.5263835", "0.5233318", "0.5226791", "0.5207712", "0.520619", "0.52058524", "0.51855236", "0.5173525", ...
0.0
-1
Converts a series of consumption data into a lagged, scaled sample.
def prepare_training_data(consumption_series, lag): # scale training data scaler = MinMaxScaler(feature_range=(-1, 1)) consumption_vals = scaler.fit_transform(consumption_series.values.reshape(-1, 1)) # convert consumption series to lagged features consumption_lagged = create_lagged_featu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def downsample(time_series,res = '0.2S'):\n\n Nvalues = len(time_series.index)\n samplerate = 1/ ((time_series.timestamp[Nvalues-1] - time_series.timestamp[0]) / Nvalues)\n timestart = dt.datetime(1970, 1, 1, 0, 0, 0, 0) #dt.datetime.now()\n start = pd.Timestamp(timestart)\n end = pd.Timestamp(times...
[ "0.58058953", "0.5682728", "0.5602917", "0.558418", "0.55332106", "0.5464574", "0.54036844", "0.53578377", "0.5353402", "0.52929103", "0.5281908", "0.524232", "0.52113897", "0.5205267", "0.51940095", "0.5193135", "0.51782006", "0.5166779", "0.51162773", "0.5104673", "0.508758...
0.6613549
0
Uses last hour's prediction to generate next for num_pred_hours, initialized by most recent cold start prediction. Inverts scale of predictions before return.
def generate_hourly_forecast(num_pred_hours, consumption, model, scaler, lag): # allocate prediction frame preds_scaled = np.zeros(num_pred_hours) # initial X is last lag values from the cold start X = scaler.transform(consumption.values.reshape(-1, 1))[-lag:] # forecast for i ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self):\n # format data\n df = self.normalize(self.daily)\n x = df.index.astype(np.int64).values.reshape(-1, 1)\n y = self.normalize(df[['Adj Close']]).values\n\n # format time\n one_day_time = 86400000000000\n x_tomorrow = x[-1] + one_day_time\n x...
[ "0.6147885", "0.60168874", "0.5948102", "0.59448326", "0.5736109", "0.5730648", "0.5723199", "0.5713034", "0.57063735", "0.56251585", "0.56192535", "0.5606722", "0.5595283", "0.5580066", "0.55339456", "0.5530532", "0.5509373", "0.550588", "0.54749984", "0.5469587", "0.5446055...
0.7551356
0
Recursively parse requirements from nested pip files.
def parse_reqs(req_path='./requirements.txt'): req = [] with codecs.open(req_path, 'r') as handle: # remove comments and empty lines lines = (line.strip() for line in handle if line.strip() and not line.startswith('#')) for line in lines: # check for nested ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_req_file(req_file, verbatim=False):\n req_list = []\n requirements = req_file.readlines()\n for requirement in requirements:\n requirement_no_comments = requirement.split(\"#\")[0].strip()\n\n # if matching requirement line (Thing==1.2.3), update dict, continue\n req_match =...
[ "0.6786804", "0.6664783", "0.6641698", "0.66211325", "0.66119075", "0.65428483", "0.6501512", "0.6493474", "0.63900733", "0.63147587", "0.6300729", "0.62659717", "0.61893356", "0.6095277", "0.60434747", "0.60229355", "0.6022184", "0.59152234", "0.5904207", "0.58895177", "0.58...
0.69987404
0
Parse contents of the README.
def parse_readme(): # Get the long description from the relevant file readme_path = path.join(here, 'README.md') with codecs.open(readme_path, encoding='utf-8') as handle: desc = handle.read() return desc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_readme():\n readme = Path(README_PATH).read_text()\n Actions.read_from_md(readme)", "def readme():\n with open('README.md') as readme_file:\n return readme_file.read()", "def readme():\n with open('README.md') as _file:\n return _file.read()", "def readme():\n with open(...
[ "0.6963818", "0.68499607", "0.6843953", "0.68420315", "0.67245597", "0.6724281", "0.66542006", "0.663165", "0.65984565", "0.6555213", "0.65377915", "0.6471558", "0.6464941", "0.6371735", "0.6349831", "0.63303596", "0.6280362", "0.6276107", "0.6224707", "0.62189406", "0.621518...
0.8034528
0
Get the string representation of the model
def __str__(self): return json.dumps(self.to_dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self) -> str:\n # noinspection PyUnresolvedReferences\n opts = self._meta\n if self.name_field:\n result = str(opts.get_field(self.name_field).value_from_object(self))\n else:\n ...
[ "0.8463654", "0.7898162", "0.77145106", "0.77145106", "0.76879215", "0.7655091", "0.7650248", "0.757232", "0.75623566", "0.7551965", "0.7551965", "0.7551292", "0.7549884", "0.7536579", "0.7519798", "0.7517772", "0.75146", "0.745953", "0.74590117", "0.74517524", "0.7426484", ...
0.0
-1
Given the pixels which are mapped to the closed field line region, return the pixel with the largest radial coordinate for each poloidal coordinate.
def surface_line(sep_pixels, mode='max'): # Index all pixels radially lin_array = np.repeat(np.arange(64), 64).reshape(64, 64).T # Apply the mask la_masked = ma.array(lin_array, mask=sep_pixels) # Return the maximum radial indices for each poloidal position if (mode == 'max'): return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_max_point(image):\r\n max_value= 0\r\n better_point= None\r\n for line in range(len(image)):\r\n for column in range(len(image[0])):\r\n if image[line][column]>max_value:\r\n max_value= image[line][column]\r\n better_point = [line,column]\r\n retu...
[ "0.63896453", "0.6343119", "0.6170493", "0.61105126", "0.6010083", "0.58846235", "0.5847404", "0.5814799", "0.57171196", "0.5709415", "0.5709284", "0.56938785", "0.5640586", "0.56322056", "0.5615116", "0.5602537", "0.56014585", "0.557604", "0.55760396", "0.55375856", "0.55284...
0.5977568
5
Computes cross entropy between targets (encoded as onehot vectors) and predictions.
def cross_entropy_loss(predictions, targets, epsilon=1e-12): predictions = np.clip(predictions, epsilon, 1. - epsilon) N = predictions.shape[0] ce = -np.sum(targets*np.log(predictions+1e-9))/N return ce
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(predictions, targets):\n likelihood = targets * np.log(predictions)\n return -np.sum(likelihood) / predictions.shape[0]", "def cross_entropy(predicted, target):\n batch_size, num_classes = predicted.shape\n\n e_x = predicted.exp()\n log_e_x = e_x.log()\n a = log_sum_x_trick(pr...
[ "0.7892568", "0.75793386", "0.75247025", "0.751529", "0.7430935", "0.73616475", "0.73616475", "0.7344533", "0.7198154", "0.7078395", "0.7066774", "0.7011896", "0.69843245", "0.6977101", "0.69487417", "0.69227016", "0.6911786", "0.68707484", "0.685989", "0.68182206", "0.679910...
0.7006511
12
get a mapping of dn and domain name, sid
def domainnames(l): mapping = {} # locate all the samba domains in the ldap r = l.search_s('dc=elex', ldap.SCOPE_SUBTREE, '(objectClass=sambaDomain)', ['sambaDomainName','sambaSID']) for dn, entry in r: mapping[dn] = (entry['sambaDomainName'][0], entry['sambaSID'][0]) return mapping
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_domain_mappings(domain_to_intents: Dict) -> Dict:\n domain2id = {}\n domains = list(domain_to_intents)\n for index, domain in enumerate(domains):\n domain2id[domain] = index\n return domain2id", "def get_ingkey_ndbno_map(session):\n alias_ndbno = {}\n\n for a...
[ "0.6582829", "0.56286347", "0.5624903", "0.5525862", "0.55090404", "0.55004203", "0.5462208", "0.5441851", "0.53912187", "0.53654265", "0.535627", "0.5353621", "0.53343844", "0.5332277", "0.5325799", "0.52989244", "0.52860177", "0.5236246", "0.51990306", "0.5192915", "0.51833...
0.7258395
0
get the domain ldap root for the given dn >>> dn = "sambaDomainName=IEPERTEST,dc=Ieper,dc=elex" >>> domainroot(dn) 'dc=Ieper,dc=elex'
def domainroot(d): dn = str2dn(d) dn.pop(0) return dn2str(dn)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_root_domain(url):\n if url is None:\n return ''\n\n http = text.find_between(url, 'http://', '/')\n https = text.find_between(url, 'https://', '/')\n if http != '':\n if http.startswith('www.'):\n return http[4:]\n else:\n return http\n else:\n ...
[ "0.59731376", "0.58926845", "0.58213747", "0.57498807", "0.5353788", "0.53386265", "0.5327255", "0.53180313", "0.52835435", "0.5229424", "0.51967984", "0.51759446", "0.5168741", "0.512568", "0.51203126", "0.5037568", "0.5010395", "0.49844295", "0.49844295", "0.49776703", "0.4...
0.78520805
0
get a list of dn's of all the sambaaccounts for a given domainroot
def sambaaccountsindomainroot(domainroot, l): dns = {} r = l.search_s(domainroot, ldap.SCOPE_SUBTREE, '(objectClass=sambaSamAccount)', ['uidNumber']) for dn, entry in r: try: dns[dn] = entry['uidNumber'][0] except KeyError: sys.stderr.write("dn %s has no uidNumber!\n" % dn) return dns
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def domainnames(l):\n mapping = {}\n # locate all the samba domains in the ldap\n r = l.search_s('dc=elex', ldap.SCOPE_SUBTREE, '(objectClass=sambaDomain)', ['sambaDomainName','sambaSID'])\n for dn, entry in r:\n mapping[dn] = (entry['sambaDomainName'][0], entry['sambaSID'][0])\n return mapping", "def ge...
[ "0.66664594", "0.6225633", "0.6047989", "0.5977809", "0.5909574", "0.58053553", "0.5803501", "0.57814616", "0.57603765", "0.57531065", "0.5686316", "0.5632562", "0.56190073", "0.5612749", "0.5571444", "0.5562495", "0.55482376", "0.55228823", "0.5510787", "0.55037886", "0.5493...
0.790107
0
update an account with a new sid number
def updatesid(dn, sid, l): mod_attrs = [(ldap.MOD_REPLACE, 'sambaSID', sid )] l.modify_s(dn, mod_attrs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, account):\n model = models.load('Account', account)\n return self.client.update_account(model=model)", "def updateAccount(accountNumber: int, payload: str ):\n statement = \"update account set \" + payload+ f\" where account_number = {accountNumber}\"\n cursor = connection.cu...
[ "0.68811387", "0.65051657", "0.6367951", "0.6271997", "0.62145466", "0.61361814", "0.6134124", "0.6107987", "0.60869086", "0.59739476", "0.5946718", "0.5814789", "0.5802594", "0.5763696", "0.5756033", "0.5756033", "0.5756033", "0.5756033", "0.5756033", "0.5756033", "0.5725383...
0.6992691
0
returns the squareneighborhoodenvironment second to last column is the action last column is the outcome
def get_all_patterns(self, game_state: Union[GridGameState, np.ndarray], action=None, next_game_state: Union[GridGameState, np.ndarray, None] = None, differential=False): if isinstance(game_state, GridGameState): game_state_grid = game_state.get_tile...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_transition(self, row, col, action, tot_row, tot_col):\n\n '''\n Expand the grid of the environment to handle when the \n agent decides to move in the direction of a wall \n '''\n state_probabilities = np.zeros((int(np.sqrt(self.env.observation_space.n)) + 2, int(np.sqrt(s...
[ "0.62888545", "0.62888545", "0.61843216", "0.6090792", "0.60547835", "0.5863124", "0.58260244", "0.5782786", "0.5765824", "0.57480395", "0.5636127", "0.5619147", "0.55536985", "0.55308455", "0.548652", "0.5456624", "0.5455377", "0.5453422", "0.5447977", "0.5441266", "0.542942...
0.0
-1
r"""Create input tensors given the list of prompt tokens.
def _create_input(inputs: List[Tensor], initial: bool = False) \ -> Dict[str, Tensor]: word_embed = torch.stack(inputs, dim=0) seq_len, batch_size, embed_dim = word_embed.size() if not initial: # Add a dummy token at the end that stands for the token # to pred...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_inputs(title, list_labels):\n print(f\"{title}\")\n # list which holds the input answers from user\n user_inputs = []\n for item in list_labels:\n user_inputs.append(input(f\"{item}: \"))\n return user_inputs", "def get_inputs(list_labels, title):\n inputs = []\n\n print(f\"\\...
[ "0.5943801", "0.5874354", "0.5750032", "0.5678299", "0.55471927", "0.55375314", "0.55304873", "0.55301905", "0.5503433", "0.55009323", "0.54978406", "0.5443688", "0.54417616", "0.5436629", "0.54334015", "0.537875", "0.53765416", "0.5369801", "0.53374743", "0.5288369", "0.5286...
0.59976834
0
r"""Perform autoregressive decoding using XLNet. The algorithm is
def forward(self, # type: ignore start_tokens: torch.LongTensor, memory: Optional[State] = None, cache_len: int = 512, max_decoding_length: Optional[int] = 500, recompute_memory: bool = True, print_steps: bool = False, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x):\n # Encoder1 --block1\n encode_block1 = self.conv_encoder1(x)\n if self.residus[0] == 1:\n encode_block1 += self.residual_shortcut1(x)\n encode_pool1 = self.max_pool_encoder1(encode_block1)\n\n # Encoder2 --block2\n encode_block2 ...
[ "0.5537087", "0.55339885", "0.54327846", "0.54184777", "0.5396983", "0.5360435", "0.53085345", "0.52792335", "0.5273877", "0.52571446", "0.5235639", "0.5223918", "0.5216948", "0.5197833", "0.51948017", "0.5164546", "0.5149774", "0.5149628", "0.51201344", "0.5116834", "0.51032...
0.0
-1
Get the symbol definition and random weight of a network
def get_network(name, batch_size, dtype='float32', ir='relay'): if ir == 'relay': from tvm.relay import testing else: raise Exception("ir must be `relay`, but you used `{}`".format(ir)) input_shape = (batch_size, 3, 224, 224) if name == 'mobilenet': net, params = testing.mobilen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_weights(self):", "def get_weights(net):\n return [p.data for p in net.parameters()]", "def wsngraph():\n G = nx.Graph()\n G.add_node(1)\n G.add_node(2)\n G.add_node(3)\n G.add_node(4)\n G.add_node(5)\n G.add_node(6)\n G.add_node(7)\n G.add_node(8)\n G.add_node(9)\n G...
[ "0.6108389", "0.5802951", "0.5793653", "0.5750533", "0.57088494", "0.56437266", "0.5613346", "0.5592894", "0.554547", "0.55027777", "0.5497525", "0.5497525", "0.54788816", "0.54666185", "0.54370296", "0.5430508", "0.5430508", "0.54239696", "0.5417186", "0.54112595", "0.540771...
0.0
-1
given a list of system dicts and fact namespace, return a dict of comparisons, along with a dict of system data
def build_comparisons(inventory_service_systems, fact_namespace): fact_comparison = _select_applicable_info(inventory_service_systems, fact_namespace) system_mappings = [_system_mapping(system) for system in inventory_service_systems] return {'facts': fact_comparison, 'systems': system_mappings}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _select_applicable_info(systems, fact_namespace):\n # create dicts of id + info\n ids_and_info = [_system_facts_and_id(system, fact_namespace) for system in systems]\n\n # union the keys into one big set\n available_info_names = set()\n for fact_ids in ids_and_info:\n available_info_names...
[ "0.6751611", "0.64506835", "0.59273654", "0.54507446", "0.5415962", "0.53574604", "0.52777123", "0.5273807", "0.52517354", "0.5235233", "0.5234047", "0.52329373", "0.5217976", "0.5211301", "0.51864505", "0.5144741", "0.5138967", "0.51296264", "0.5087264", "0.50721955", "0.502...
0.7789255
0
Take a list of systems with fact namespace, and output a "pivoted" list of facts, where each fact key has a dict of systems and their values. This is useful when comparing facts across systems.
def _select_applicable_info(systems, fact_namespace): # create dicts of id + info ids_and_info = [_system_facts_and_id(system, fact_namespace) for system in systems] # union the keys into one big set available_info_names = set() for fact_ids in ids_and_info: available_info_names |= fact_ids...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _find_facts_for_namespace(system, fact_namespace):\n # TODO: we are assuming we just need to handle one namespace\n for facts in system['facts']:\n if facts['namespace'] == fact_namespace:\n dataframe = json_normalize(_flatten_list_facts(facts['facts']), sep='.')\n # TODO: we...
[ "0.599296", "0.57565916", "0.5621143", "0.5443486", "0.5262978", "0.5095327", "0.50548106", "0.50017583", "0.48622108", "0.48508248", "0.4813298", "0.47710633", "0.4763719", "0.46962604", "0.46861643", "0.4658715", "0.4652692", "0.46504876", "0.46204603", "0.46028978", "0.459...
0.4845707
10
return the facts for the given namespace
def _find_facts_for_namespace(system, fact_namespace): # TODO: we are assuming we just need to handle one namespace for facts in system['facts']: if facts['namespace'] == fact_namespace: dataframe = json_normalize(_flatten_list_facts(facts['facts']), sep='.') # TODO: we should tr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _facts(facts):\n return {'swift_facts': facts}", "def get_all_by_namespace(context, namespace_name, session):\n\n # namespace get raises an exception if not visible\n namespace = namespace_api.get(\n context, namespace_name, session)\n\n db_recs = (\n session.query(models.Metade...
[ "0.6179005", "0.60052156", "0.5814096", "0.57992786", "0.5792006", "0.57476157", "0.5712751", "0.56517786", "0.562293", "0.5562041", "0.55495805", "0.55207497", "0.55160123", "0.5473524", "0.5363391", "0.5360087", "0.5358159", "0.53243786", "0.53009593", "0.5258396", "0.52021...
0.71858376
0
Pull the system facts dict out from a system record and add the ID to the dict
def _system_facts_and_id(system, fact_namespace): facts_and_id = _find_facts_for_namespace(system, fact_namespace) facts_and_id[SYSTEM_ID_KEY] = system[SYSTEM_ID_KEY] return facts_and_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _system_mapping(system):\n return {'id': system['id'], 'fqdn': system['fqdn'], 'last_updated': system['updated']}", "def create_system_data():\n system_data = dict()\n system_data['system'] = dict()\n system_data['system']['primary'] = dict()\n system_data['system']['primary']['controllers'] =...
[ "0.6592336", "0.5519249", "0.52790916", "0.52427906", "0.511191", "0.51064813", "0.5094681", "0.50490534", "0.5019681", "0.50044346", "0.49629274", "0.49606988", "0.49120373", "0.49032432", "0.48786232", "0.4853964", "0.4850545", "0.48393828", "0.483793", "0.48377714", "0.481...
0.6877349
0
Take an individual fact, search for it across all systems, and create a dict of each system's ID and fact value. Additionally, add a "state" field that says if all systems have the same values or different values. Note that when passing in "systems" to this method, the ID needs to be listed as a fact key.
def _create_comparison(systems, info_name): info_comparison = COMPARISON_DIFFERENT system_id_values = [{'id': x['id'], 'value': x.get(info_name, "FACT_NOT_SET")} for x in systems] system_values = {system['value'] for system in system_id_values} if "FACT_NOT_SET" in system_values: info_compari...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _system_facts_and_id(system, fact_namespace):\n facts_and_id = _find_facts_for_namespace(system, fact_namespace)\n facts_and_id[SYSTEM_ID_KEY] = system[SYSTEM_ID_KEY]\n return facts_and_id", "def _select_applicable_info(systems, fact_namespace):\n # create dicts of id + info\n ids_and_info = [...
[ "0.61924046", "0.5710258", "0.5444056", "0.5426606", "0.5076391", "0.50066507", "0.5004025", "0.49934798", "0.49750796", "0.49106765", "0.46943542", "0.4599882", "0.4599882", "0.4599882", "0.45977145", "0.45152375", "0.45084983", "0.4507461", "0.44489235", "0.4419014", "0.441...
0.5402677
4
create a header mapping for one system
def _system_mapping(system): return {'id': system['id'], 'fqdn': system['fqdn'], 'last_updated': system['updated']}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setSoapHdr(self):\n mapHdrData = {}\n\n for task, taskMap in self.mapHdrRaw.items():\n if len(taskMap) == 0:\n # skip this task if there are no elements in it\n continue\n \n taskStruct = structType(data = taskMap)\n\n m...
[ "0.6216434", "0.620413", "0.6202114", "0.60866916", "0.6065891", "0.6005825", "0.6005363", "0.5992969", "0.59732544", "0.59199125", "0.5913567", "0.5901967", "0.5893599", "0.5864299", "0.5859369", "0.5817306", "0.5784841", "0.5782217", "0.57806534", "0.5770666", "0.5756628", ...
0.54142433
49
Takes a parameter of a database table, database column and input value. Open a connection to the database. Inserts the given input to the given database column in the given database table. Saves and closes the connection.
def insertData(table, column, input): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("INSERT INTO '" + table + "' (" + column + ") VALUES ('" + input + "')") con.commit() con.close() except: print('Could not run function insertData from DbController')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit_to_database(self, table, output):\n try:\n # TODO: Is this the correct method for this?\n with SESSION.begin_nested():\n i = insert(getattr(db, table))\n vals = i.values(output)\n SESSION.execute(vals) # TODO: What is this?\n ...
[ "0.6499374", "0.6467502", "0.6432609", "0.642731", "0.6394885", "0.6324648", "0.6303387", "0.6270057", "0.6249122", "0.6245554", "0.61839783", "0.61709726", "0.61705667", "0.61124736", "0.60817313", "0.6029818", "0.6000239", "0.5996185", "0.59731865", "0.5967328", "0.5955773"...
0.8079351
0
Takes a parameter of a database table. Open a connection to the database. Asks for the latest added row in database. Saves and closes the connection. Returns the id of the row.
def getLatestId(table): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT max( measurementId ) FROM Measurement") id = cur.fetchone() con.commit() con.close() return id[0] except: print('Could not run function getLatestId from DbController')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(q, *params):\n db = Database()\n db.cur.execute(q, *params)\n ret_id = db.cur.lastrowid\n db.con.close()\n return ret_id", "def getLastId(self,table):\n\tif self.dbType==\"sqlite\":\n\t query = \"SELECT LAST_INSERT_ROWID() FROM %s LIMIT 1\"%table\n\telse:\n\t query = \"SELECT LAST_I...
[ "0.66030145", "0.6529629", "0.649401", "0.640542", "0.6362824", "0.6284276", "0.62791777", "0.6267712", "0.62239826", "0.62156045", "0.6184368", "0.6179019", "0.6103859", "0.6077099", "0.60505813", "0.598806", "0.5979676", "0.59573686", "0.5955495", "0.5923925", "0.5921158", ...
0.6293333
5
Takes a parameter of a database table and a name. Open a connection to the database. Selects all rows from given table where the name matches the given name. Checks if there is no rows and save the given name if not. Returns an object of the organizations data. Saves and closes the connection.
def checkIfOrganisationExists(table, name): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name='" + name + "'") ob = cur.fetchall() if not ob: cur.execute("INSERT INTO '" + table + "' (name) VALUES ('" + name + "')") con.commit() cur.execu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAllWhereNameIs2(table, name, orgName):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name like'\" + name + \"%' and organisationId like (SELECT organisationId FROM Organisation WHERE name like '\" + orgName + \"' )\")\n\t\tob =...
[ "0.6584832", "0.56436473", "0.56424224", "0.5445914", "0.53992385", "0.5322616", "0.5317675", "0.5276783", "0.52582735", "0.5035784", "0.49893025", "0.49835908", "0.49494904", "0.4946467", "0.4929817", "0.49230644", "0.49134114", "0.490836", "0.48627073", "0.48460436", "0.482...
0.6698518
0
Takes a parameter of a database table, a name and a foreign key. Open a connection to the database. Selects all rows from given table where the name matches the given name. Checks if there is no rows with matching name and save the given name if not the return a object of the measurement object. Otherwise loops through...
def checkIfMeasuringObjectExists(table, name, fk): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name='" + name + "'") ob = cur.fetchall() bo = False if not ob: cur.execute("INSERT INTO '" + table + "' (name, organisationId) VALUES ('" + name +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkIfAntennaExists(table, name, fk):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name='\" + name + \"'\")\n\t\tob = cur.fetchall()\n\t\tbo = False\n\t\tif not ob:\n\t\t\tcur.execute(\"INSERT INTO '\" + table + \"' (name, measu...
[ "0.5825028", "0.54133224", "0.52821904", "0.5057512", "0.4970804", "0.4853761", "0.483541", "0.48263484", "0.47983626", "0.47972316", "0.47867805", "0.47804394", "0.47424772", "0.473968", "0.473309", "0.4724627", "0.47091377", "0.4699343", "0.46908638", "0.46786463", "0.46757...
0.6349163
0
Takes a parameter of a database table, a name and a foreign key. Open a connection to the database. Selects all rows from given table where the name matches the given name. Checks if there is no rows with matching name and save the given name if not the return a object of the antenna. Otherwise loops through the list o...
def checkIfAntennaExists(table, name, fk): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name='" + name + "'") ob = cur.fetchall() bo = False if not ob: cur.execute("INSERT INTO '" + table + "' (name, measuringObjectId) VALUES ('" + name + "', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkIfMeasuringObjectExists(table, name, fk):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name='\" + name + \"'\")\n\t\tob = cur.fetchall()\n\t\tbo = False\n\t\tif not ob:\n\t\t\tcur.execute(\"INSERT INTO '\" + table + \"' (nam...
[ "0.5775556", "0.55818015", "0.52031857", "0.5173361", "0.51214767", "0.50995225", "0.49776843", "0.49723682", "0.49298635", "0.49137506", "0.49100566", "0.4876978", "0.48237494", "0.48185825", "0.47975516", "0.47720587", "0.47643965", "0.476333", "0.47346067", "0.47134042", "...
0.6691352
0
Takes a parameter of a database table. Open a connection to the database. Collects all rows from that table and return as a list. Saves and closes the connection.
def getAllName(table): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table) names = cur.fetchall() con.commit() con.close() return names except: print('Could not run function getAllName from DbController')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_rows(table, db_file):\n \n try:\n conn, c = connect_to_db(db_file) \n c.execute('SELECT * FROM {t}'.format(t=safe(table)))\n allrows = c.fetchall()\n conn.close()\n return allrows\n except Exception as e:\n print(\"Error when trying to fetch all row...
[ "0.71056473", "0.6945642", "0.69364375", "0.69354993", "0.6890469", "0.6853193", "0.68162286", "0.6810731", "0.68048996", "0.67670256", "0.6726298", "0.6682274", "0.6635236", "0.6629247", "0.66119444", "0.6593554", "0.6505351", "0.64627415", "0.6428178", "0.6420916", "0.63942...
0.0
-1
Takes a parameter of a database table and a name. Open a connection to the database. Select the rowa from given table where name matches the given name. If no match returns an empty string otherwise returns an object of the matching organization. Saves and closes the connection.
def getAllWhereNameIs(table, name): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name like'" + name + "%'") ob = cur.fetchall() if not ob: return "" else: obje = ob[0] return obje con.commit() con.close() except: print('Could not ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAllWhereNameIs2(table, name, orgName):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name like'\" + name + \"%' and organisationId like (SELECT organisationId FROM Organisation WHERE name like '\" + orgName + \"' )\")\n\t\tob =...
[ "0.7150075", "0.644911", "0.62818587", "0.6092429", "0.6091963", "0.5959734", "0.59330434", "0.5920153", "0.58863497", "0.5806769", "0.5781294", "0.5738642", "0.5728878", "0.57224065", "0.5719498", "0.5671159", "0.56409097", "0.5638782", "0.5627955", "0.55980676", "0.5566317"...
0.6432116
2
Takes a parameter of a database table, a name and a organization name. Open a connection to the database. Select the row from given table where name matches the given name and the foreign key matches the organisationsId from the organization with the given name. If no match returns an empty string otherwise returns an ...
def getAllWhereNameIs2(table, name, orgName): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name like'" + name + "%' and organisationId like (SELECT organisationId FROM Organisation WHERE name like '" + orgName + "' )") ob = cur.fetchall() if not ob...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkIfOrganisationExists(table, name):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name='\" + name + \"'\")\n\t\tob = cur.fetchall()\n\n\t\tif not ob:\n\t\t\tcur.execute(\"INSERT INTO '\" + table + \"' (name) VALUES ('\" + name...
[ "0.649052", "0.58591986", "0.5553993", "0.541119", "0.53702897", "0.53158283", "0.5298932", "0.52573925", "0.5228335", "0.51941264", "0.5193201", "0.51424927", "0.5105643", "0.5103786", "0.50759363", "0.50589263", "0.50571203", "0.50493544", "0.50341445", "0.50220186", "0.502...
0.6875108
0
Takes a parameter of a database table, a name, a measuring object name and a organization name. Open a connection to the database. Select the row from given table where name matches the given name and the foreign key matches the measuringObjectId from the measuring object with the given name, which foreign key should m...
def getAllWhereNameIs3(table, name, objectName, orgName): try: con = sqlite3.connect('PampDb.db') cur = con.cursor() cur.execute("SELECT * FROM " + table + " WHERE name like'" + name + "%' and measuringObjectId like (SELECT measureingObjectId FROM MeasuringObject WHERE name like'" + objectName + "' and organisat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkIfMeasuringObjectExists(table, name, fk):\n\ttry:\n\t\tcon = sqlite3.connect('PampDb.db')\n\t\tcur = con.cursor()\n\t\tcur.execute(\"SELECT * FROM \" + table + \" WHERE name='\" + name + \"'\")\n\t\tob = cur.fetchall()\n\t\tbo = False\n\t\tif not ob:\n\t\t\tcur.execute(\"INSERT INTO '\" + table + \"' (nam...
[ "0.647255", "0.59009075", "0.5862029", "0.5327575", "0.5271932", "0.51865", "0.51475155", "0.5062982", "0.50051904", "0.4929531", "0.48816788", "0.4817058", "0.47862557", "0.47796994", "0.47717777", "0.4741117", "0.47383088", "0.47381008", "0.47295547", "0.46936247", "0.46817...
0.6301946
1
Checks that the default parameters of a CoolantChannelRingStraight are correct.
def test_default_parameters(self): # assert self.test_shape.rotation_angle == 360 assert self.test_shape.start_angle == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_raw_parameters(self):\n # exclude some irrelevant or mandatory parameters\n excluded_keys = (\"cmd\", \"client\", \"resource_group_name\", \"name\")\n # check whether the remaining parameters are set\n # the default value None or False (and other empty values, like empty strin...
[ "0.57292235", "0.5649407", "0.5493077", "0.54790646", "0.5410326", "0.54050815", "0.539264", "0.53915656", "0.5389374", "0.53777575", "0.53308314", "0.5328452", "0.52771133", "0.5256819", "0.5243553", "0.52401507", "0.5219868", "0.5205472", "0.5191979", "0.5157206", "0.515077...
0.5559056
2
Creates a coolant channel ring using the CoolantChannelRingStraight parameteric shape and checks that a cadquery solid is created.
def test_creation(self): assert self.test_shape.solid is not None assert self.test_shape.volume() > 1000
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_cable_ring(self, env, info={}, cable_idx=0):\n def rad_to_deg(rad):\n return (rad * 180.0) / np.pi\n\n def get_discretized_rotations(num_rotations):\n # counter-clockwise\n theta = i * (2 * np.pi) / num_rotations\n return (theta, rad_to_deg(theta))\...
[ "0.6032365", "0.5329425", "0.5172214", "0.5099691", "0.50813854", "0.5008946", "0.5005978", "0.49561918", "0.4910132", "0.4908677", "0.48693416", "0.48510155", "0.48496482", "0.4801606", "0.48015696", "0.4749347", "0.47295332", "0.47240025", "0.4691071", "0.4684929", "0.46806...
0.42844978
99
Creates a CoolantChannelRingStraight shape and checks that the areas of its faces are correct.
def test_faces(self): self.test_shape.workplane = "XY" self.test_shape.rotation_axis = "Z" assert self.test_shape.area == pytest.approx((((math.pi * (10**2)) * 2) + (math.pi * (10 * 2) * 100)) * 8) assert len(self.test_shape.areas) == 24 assert self.test_shape.areas.count(pytes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_cable_ring(self, env, info={}, cable_idx=0):\n def rad_to_deg(rad):\n return (rad * 180.0) / np.pi\n\n def get_discretized_rotations(num_rotations):\n # counter-clockwise\n theta = i * (2 * np.pi) / num_rotations\n return (theta, rad_to_deg(theta))\...
[ "0.54048467", "0.537262", "0.5357499", "0.5338746", "0.5328752", "0.529666", "0.51922953", "0.51870656", "0.51857233", "0.5181824", "0.5127006", "0.512343", "0.5072488", "0.507105", "0.5065166", "0.50545657", "0.5044749", "0.501881", "0.5014258", "0.49945888", "0.49945888", ...
0.0
-1
Creates CoolantChannelRingStraight shapes and checks that the volumes are correct.
def test_volume(self): self.test_shape.workplane = "XY" self.test_shape.rotation_axis = "Z" assert self.test_shape.volume() == pytest.approx(math.pi * (10**2) * 100 * 8)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_creation(self):\n\n assert self.test_shape.solid is not None\n assert self.test_shape.volume() > 1000", "def test_creation(self):\n\n assert self.test_shape.solid is not None\n assert self.test_shape.volume() > 1000", "def add_cable_ring(self, env, info={}, cable_idx=0):\n ...
[ "0.5674478", "0.5674478", "0.5592306", "0.55478907", "0.54318386", "0.541907", "0.5385598", "0.53693736", "0.53376484", "0.5288099", "0.5281223", "0.52626747", "0.5222897", "0.51526165", "0.51446766", "0.5129756", "0.5091278", "0.50819427", "0.5051377", "0.504616", "0.5023189...
0.0
-1
Checks that the coolant channels are placed at the correct azimuthal placement angles for a given start angle.
def test_start_angle(self): assert self.test_shape.azimuth_placement_angle == [ 0, 45, 90, 135, 180, 225, 270, 315, ] self.test_shape.start_angle = 10 assert self.test_shape.azimuth_placement...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_angle_of_arcs(self):\n\n if self.thin_arc_start_angle >= 3600:\n self.thin_arc_start_angle %= 360\n self.thin_arc_start_angle += 360\n\n elif self.thin_arc_start_angle <= -3600:\n self.thin_arc_start_angle %= 360\n self.thin_arc_start_angle -= 360...
[ "0.64040065", "0.55662644", "0.5453842", "0.54343426", "0.542246", "0.5321511", "0.52047867", "0.5199475", "0.51695144", "0.5155091", "0.5144264", "0.5114534", "0.50843585", "0.505066", "0.50357336", "0.50191617", "0.5004695", "0.49946713", "0.4977154", "0.49758136", "0.49680...
0.610046
1
Test import dataset wine.
def test_import_wine(): X, y = wine_data() assert(X.shape[1] == 12) assert(len(y.unique().tolist()) == 3) assert(X.shape[0] == y.shape[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import_data():\n\n file_path = os.path.join(CONST_ADVANTICSYS_DIR, CONST_ADVANTICSYS_TEST_1)\n\n # Bring df\n success, log, test_ingress_df = advanticsys_import(file_path)\n assert success, log\n assert isinstance(test_ingress_df, pd.DataFrame)\n\n # Test import function\n success, lo...
[ "0.6878423", "0.6717447", "0.66107994", "0.6513562", "0.64724684", "0.6419172", "0.635929", "0.63393587", "0.6322275", "0.6305654", "0.6271661", "0.6262919", "0.6250121", "0.62494475", "0.6245525", "0.6239293", "0.62058556", "0.61902046", "0.61705625", "0.615137", "0.6088381"...
0.74175483
0
Constructor. Sets the parent, sets up the UI and fills the tree.
def __init__(self, iface=None): parent = None if iface is None else iface.mainWindow() super(DockWidget, self).__init__(parent) # Set up the user interface from Designer. # After setupUI you can access any designer object by doing # self.<objectname>, and you can use autoconnect ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self, parent):\n self.widget = QtGui.QTreeView(parent)", "def __init__(self, parent=None):\n super(Representative, self).__init__(parent)\n self.setupUi(self)", "def __init__(self,parent, id = wx.ID_ANY, pos = (10,10), size=(-1,-1)):\n\n wx.TreeCtrl.__init__(self, parent,...
[ "0.76014423", "0.7525523", "0.7442736", "0.7348248", "0.7325853", "0.7277504", "0.72760564", "0.7221381", "0.7190728", "0.7139197", "0.71225977", "0.709324", "0.7070534", "0.7013553", "0.691987", "0.6911241", "0.69035274", "0.6893549", "0.6848428", "0.68216026", "0.6812221", ...
0.0
-1
Returns ranked accuracy given true classes and predicted probabilities.
def top_k_accuracy(y_true : np.ndarray, probs: np.ndarray, k: int) -> float: # Top k sorted preds sorted_probs = probs.argsort()[:,-k:] # Does the truth intersect with any of the top k predictions? matches = np.max(sorted_probs == y_true.reshape(-1, 1), axis=1) return matches.mean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_accuracy(true, predicted):\n return sum([t==p for t,p in zip(true, predicted)]) / float(len(true))", "def accuracy(preds, labels):\n correct = preds == labels\n return correct.sum().float() / correct.shape[0]", "def accuracy(predicted, ground_truth):\n predicted_labels_decoded = np...
[ "0.7954947", "0.78648776", "0.7796339", "0.7776252", "0.77718586", "0.7771421", "0.7771421", "0.775524", "0.7739714", "0.7696608", "0.7682014", "0.76794153", "0.7577913", "0.7562003", "0.7551231", "0.75275767", "0.75275767", "0.75218564", "0.7516644", "0.75076306", "0.7505706...
0.0
-1
Builds a tree, starting at root, of matching subsequences between sorted_nodes1 and sorted_nodes2. The subsequences match if the order of the nodes is preserved and they satisfy are_equal_nodes.
def fill_tree(root, sorted_nodes1, sorted_nodes2): for id1 in range(root.id1+1, len(sorted_nodes1)): for id2 in range(root.id2+1, len(sorted_nodes2)): if are_equal_nodes(sorted_nodes1[id1], sorted_nodes2[id2]): child_node = TreeNode(id1, id2) fill_tree(child_node,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_longest_matches(sorted_nodes1, sorted_nodes2):\n root = TreeNode(-1,-1)\n fill_tree(root, sorted_nodes1, sorted_nodes2)\n match = find_treepaths(root, [])\n\n # Remove (-1, -1) superroot.\n if isinstance(match[0], list): # More than one match of the same length.\n res = []\n f...
[ "0.6480154", "0.6017104", "0.5900179", "0.58926785", "0.57914406", "0.5785781", "0.56803095", "0.5670274", "0.5616493", "0.5585591", "0.548172", "0.5441299", "0.5415218", "0.54117894", "0.5322896", "0.53055215", "0.53055215", "0.52935976", "0.5283271", "0.5247669", "0.5240782...
0.7211512
0
Returns the longest paths through the tree starting at root.
def find_treepaths(root, treepaths): treepaths.append(root)# possible that more than one match of the same length if root.children: path_children = max(root.children, key = lambda node: node.depth) # pick the deepest child tree(s) if isinstance(path_children, TreeNode): find_treepath...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_path(game, player, cur_length=0, max_length=10):\n moves = game.get_legal_moves(player)\n\n # Break recursion if we reach a dead end or we're at the limit.\n if not moves or cur_length >= max_length:\n return cur_length\n # Otherwise search recursively.\n else:\n best_depth...
[ "0.70472926", "0.66193223", "0.64925385", "0.6379252", "0.6372987", "0.6354955", "0.6342008", "0.63089573", "0.62788874", "0.62379885", "0.6157672", "0.61548233", "0.6142876", "0.60721266", "0.6016198", "0.59961236", "0.5966782", "0.59641474", "0.5886199", "0.58638775", "0.58...
0.5438467
73
Returns the longest common subsequences between sorted_nodes1 and sorted_nodes2.
def find_longest_matches(sorted_nodes1, sorted_nodes2): root = TreeNode(-1,-1) fill_tree(root, sorted_nodes1, sorted_nodes2) match = find_treepaths(root, []) # Remove (-1, -1) superroot. if isinstance(match[0], list): # More than one match of the same length. res = [] for m in match...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_common_subsequence(seq1, seq2):\n mat = DPMatrix(seq1, seq2, match=1, mismatch=0, gap=0)\n mat.fill()\n\n lcs = []\n augSeq1, augSeq2 = mat.augmented_sequences()\n for c1, c2 in zip(augSeq1, augSeq2):\n if c1 == c2:\n lcs.append(c1)\n\n return ''.join(lcs)", "def l...
[ "0.7247269", "0.71503085", "0.69920135", "0.6895138", "0.68178797", "0.6648128", "0.64169645", "0.63929033", "0.6190487", "0.6148989", "0.6120559", "0.6112058", "0.6086676", "0.6060063", "0.6056009", "0.5992014", "0.5970511", "0.59483576", "0.5925975", "0.5925972", "0.5920781...
0.75042135
0
Converts matched pairs of indices in sorted_small_nodes and sorted_large_nodes into matched pairs of nodeids.
def get_matched_nodeids_from_orderids(sorted_small_nodes, sorted_large_nodes, matched_orderids): orderid2nodeid_func = lambda order_pair: (sorted_small_nodes[order_pair[0]].nodeid, sorted_large_nodes[order_pair[1]].nodeid) return list(map(orderid2nodeid_func, matched_orderids))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matching_nodeids(small_dmrs, large_dmrs, all_surface=False):\n sorted_small_nodes = sort_nodes(small_dmrs.nodes)\n sorted_large_nodes = sort_nodes(large_dmrs.nodes)\n\n longest_matches = find_longest_matches(sorted_small_nodes, sorted_large_nodes) # list (of lists) of tuples (id_from_sub, id)\n\n ...
[ "0.6820625", "0.5716441", "0.5706402", "0.56754607", "0.55908996", "0.5546528", "0.5427354", "0.5134633", "0.5119809", "0.5119312", "0.50765777", "0.50579196", "0.5057068", "0.5023635", "0.50086886", "0.4989392", "0.49750262", "0.49497184", "0.49187142", "0.48737258", "0.4856...
0.7717208
0
Finds nodeids present in the aligned matched region of the large DMRS, but which have no equivalents in the small DMRS.
def find_extra_surface_nodeids(orderids, sorted_large_nodes): extra_nodeids = [] first_overlap_orderid = orderids[0] min_cfrom = sorted_nodes[first_overlap_orderid].cfrom # Check if any earlier nodes also in the region. while True: prev_cfrom = sorted_nodes[first_overlap_orderid-1].cfrom ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matching_nodeids(small_dmrs, large_dmrs, all_surface=False):\n sorted_small_nodes = sort_nodes(small_dmrs.nodes)\n sorted_large_nodes = sort_nodes(large_dmrs.nodes)\n\n longest_matches = find_longest_matches(sorted_small_nodes, sorted_large_nodes) # list (of lists) of tuples (id_from_sub, id)\n\n ...
[ "0.7025583", "0.58557904", "0.5646902", "0.56260955", "0.55979025", "0.5596457", "0.5506559", "0.54735655", "0.54688025", "0.5428346", "0.54266435", "0.5401781", "0.5376381", "0.53503776", "0.53159696", "0.53106", "0.5259019", "0.52510506", "0.52362823", "0.52313286", "0.5221...
0.56096166
4
Returns a subgraph of dmrs containing only nodes with subgraph_nodeids and all the links between them.
def get_subgraph(dmrs, subgraph_nodeids): links = [] for nodeid in subgraph_nodeids: node_links = dmrs.get_out(nodeid) for link in node_links: if link.end in subgraph_nodeids: links.append(link) nodes = [dmrs[nodeid] for nodeid in subgraph_nodeids] return Dict...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_subgraphs(graph):\n nodes_powerset = get_nodes_combinations(graph)\n #print(\"Doing\")\n #draw_graph(graph)\n subgraphs = []\n for nodes in nodes_powerset:\n subg = graph.subgraph(nodes)\n nodes = subg.nodes(data=True)\n if nx.is_weakly_connected(subg):\n subg...
[ "0.7035432", "0.6588273", "0.651714", "0.6372824", "0.6290915", "0.6162915", "0.5933553", "0.59246063", "0.59132445", "0.5816567", "0.57999897", "0.57736963", "0.57541233", "0.5741261", "0.566491", "0.5662782", "0.5647418", "0.5560412", "0.5558986", "0.5549748", "0.55334896",...
0.819001
0
Finds matching pairs of nodeids between small_dmrs and large_dmrs.
def get_matching_nodeids(small_dmrs, large_dmrs, all_surface=False): sorted_small_nodes = sort_nodes(small_dmrs.nodes) sorted_large_nodes = sort_nodes(large_dmrs.nodes) longest_matches = find_longest_matches(sorted_small_nodes, sorted_large_nodes) # list (of lists) of tuples (id_from_sub, id) all_matc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matched_nodeids_from_orderids(sorted_small_nodes, sorted_large_nodes, matched_orderids):\n orderid2nodeid_func = lambda order_pair: (sorted_small_nodes[order_pair[0]].nodeid, sorted_large_nodes[order_pair[1]].nodeid)\n return list(map(orderid2nodeid_func, matched_orderids))", "def get_matches(self,...
[ "0.7055238", "0.5894939", "0.55227906", "0.5489085", "0.54599357", "0.5449781", "0.5447405", "0.5445119", "0.5440812", "0.53929174", "0.53769183", "0.537584", "0.5372282", "0.5365889", "0.53626955", "0.5340169", "0.53266394", "0.5322242", "0.531484", "0.53060037", "0.5296792"...
0.82478267
0
Check for equality, in everything but the last provenance.
def verify_slim_restart_equality(self, in_ts, out_ts): assert in_ts.num_provenances + 1 == out_ts.num_provenances in_tables = in_ts.dump_tables() in_tables.sort() out_tables = out_ts.dump_tables() out_tables.sort() self.assertTableCollectionsEqual(in_tables, out_tables, s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testEquality(self):\n pass", "def test_equality(self):\n self.assertTrue(Record(1, 2) == Record(1, 2))\n self.assertFalse(Record(1, 2) == Record(1, 3))\n self.assertFalse(Record(1, 2) == Record(2, 2))\n self.assertFalse(Record(1, 2) == Record(3, 4))", "def test_equal_on_e...
[ "0.7151801", "0.67575616", "0.6750969", "0.6594036", "0.65184104", "0.64447683", "0.64215165", "0.6413873", "0.63874745", "0.6368648", "0.636855", "0.6347611", "0.63152367", "0.63029677", "0.6300809", "0.6295113", "0.6253116", "0.62390214", "0.6235458", "0.62001276", "0.61816...
0.0
-1
Number of tree encounters when slope is (3,1)
def solve_part1(input): def is_tree(cell): return 1 if cell == "#" else 0 def get_cell(row, pos): return row[pos % len(row)] pos = 0 trees = 0 for row in input: trees += is_tree(get_cell(row, pos)) pos += 3 return trees
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leaf_count(t: Tree) -> int:\n if t.children == []:\n return 1\n else:\n return sum([leaf_count(child) for child in t.children])", "def leaf_count(self) -> int:\n if self.children == []:\n return 1\n else:\n return sum([x.leaf_count() for x in self.child...
[ "0.6907491", "0.68810225", "0.6854434", "0.6781808", "0.6753598", "0.66757894", "0.66155106", "0.6588846", "0.6567529", "0.6486102", "0.64605945", "0.64430356", "0.6425145", "0.6416989", "0.63806796", "0.63761276", "0.6331753", "0.6319245", "0.63084203", "0.6269724", "0.62279...
0.0
-1