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
Is move a square on the board?
def is_valid(self, move): return move > 10 and move < 89
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_new_move(my_board, x, y):\n return my_board[x, y] == CLOSED", "def does_move_win(self, x, y):\n me = self.board[x][y]\n for (dx, dy) in [(0, +1), (+1, +1), (+1, 0), (+1, -1)]:\n p = 1\n while self.is_on_board(x+p*dx, y+p*dy) and self.board[x+p*dx][y+p*dy] == me:\n ...
[ "0.76694965", "0.76564497", "0.76129466", "0.7534907", "0.7482585", "0.7451095", "0.7349873", "0.7335955", "0.73351735", "0.73169786", "0.72943103", "0.72885555", "0.72349745", "0.7217792", "0.71833056", "0.7168608", "0.7166267", "0.71539867", "0.71370345", "0.71336055", "0.7...
0.0
-1
Get player's opponent piece.
def opponent(self, player): # player = core.BLACK (can do this for any static var) if player == core.BLACK: return core.WHITE else: return core.BLACK
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getOpponent(self):\n return self.__opponent", "def get_opponent(self):\n for cell in self.__state.board.find_workers():\n player = self.__state.board.get_player_id(cell[0], cell[1])\n if not player == self.__pid:\n return player", "def opponent(self):\n ...
[ "0.7492938", "0.7264806", "0.7049177", "0.7040058", "0.68809295", "0.6790353", "0.6682499", "0.6642669", "0.6617875", "0.6548825", "0.65392536", "0.639095", "0.63774604", "0.63774604", "0.63543737", "0.6320625", "0.6320233", "0.6275478", "0.62690526", "0.62504077", "0.6211759...
0.70919555
2
Find a square that forms a bracket with `square` for `player` in the given `direction`. Returns None if no such square exists. Returns the index of the bracketing square if found
def find_bracket(self, square, player, board, direction): curr = square+ direction opp = self.opponent(player) if(board[curr]!=opp): return None while(self.is_valid(curr) and board[curr]==opp): curr+=direction if(self.is_valid(curr) and board[curr] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_bracket(square, player, board, direction):\n bracket = square + direction\n if board[bracket] == player:\n return None\n opp = Othello.opponent(player)\n while board[bracket] == opp:\n bracket += direction\n return None if board[bracket] in (OUTER, ...
[ "0.80075675", "0.657441", "0.63864964", "0.6318657", "0.6174479", "0.5725372", "0.57224786", "0.5603353", "0.5454616", "0.54519516", "0.54519516", "0.543676", "0.5399402", "0.5393349", "0.5366055", "0.52998435", "0.52970845", "0.5295573", "0.5294598", "0.5291805", "0.5225825"...
0.80948424
0
Is this a legal move for the player?
def is_legal(self, move, player, board): if(self.is_valid(move)==False): return False if(board[move]!=core.EMPTY): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_move(self, player, move):\n return (True)", "def player(self):\n legal = self.board.legal_move(self.black)\n if(len(legal) == 0):\n self.p_no_move = 1\n print(\"No legal move for player!\")\n self.computer_turn = True\n self.player_turn =...
[ "0.8153959", "0.7920928", "0.78006524", "0.7740374", "0.7722312", "0.7576567", "0.7451655", "0.7385302", "0.7312729", "0.727711", "0.72697985", "0.71980315", "0.7145663", "0.71408117", "0.7109313", "0.7081617", "0.7077877", "0.70748216", "0.70613927", "0.7060065", "0.7006584"...
0.7460049
6
Update the board to reflect the move by the specified player.
def make_move(self, move, player, board): #nBoard = board.copy() board[move] = player for d in core.DIRECTIONS: if self.find_bracket(move, player, board, d)!=None: self.make_flips(move, player, board, d) return board
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self, row, col, player):\n self.board[row][col] = player", "def move(self, row, col, player):\n if self._board[row][col] == EMPTY:\n self._board[row][col] = player", "def move(self, row, col, player):", "def _update_player(self, player: Player, update_grid = None):\n ...
[ "0.7772014", "0.7355093", "0.7287095", "0.7274741", "0.69488734", "0.68208927", "0.68134964", "0.67698324", "0.67647517", "0.67599833", "0.6638706", "0.6591518", "0.65851456", "0.6582012", "0.6581577", "0.6557409", "0.6527905", "0.6525072", "0.65132385", "0.65091723", "0.6493...
0.0
-1
Flip pieces in the given direction as a result of the move by player.
def make_flips(self, move, player, board, direction): curr = move + direction opp = self.opponent(player) while(board[curr]==opp): board[curr] = player curr += direction #return board
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flip(self, x, y):\n self.pieces[x + (y * self.width)].flip()", "def flip(self, bev_direction: str = 'horizontal') -> None:\n pass", "def make_flips(move, player, board, direction):\n bracket = Othello.find_bracket(move, player, board, direction)\n if not bracket:\n re...
[ "0.68362707", "0.6592844", "0.65014696", "0.6500981", "0.6391202", "0.62869", "0.61508685", "0.61346436", "0.6131365", "0.6130957", "0.6108974", "0.6072877", "0.6030984", "0.59973514", "0.5908052", "0.5880105", "0.57856685", "0.5767312", "0.5751639", "0.5737677", "0.57143956"...
0.69535416
0
Get a list of all legal moves for player, as a list of integers
def legal_moves(self, player, board): #go through the whole board and check whether the piece is on the board or not #num/row size - num%col == num2/row size - num@%col #num/row size + num%col moves = list() opp = self.opponent(player) #print(board) for i i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possible_moves(self): \n return [a + 1 for a, b in enumerate(self.board) if b == 0]", "def get_valid_moves(self) -> list[int]:\n return self._valid_moves", "def get_possible_moves(board):\n\tpossible_moves = []\n\n\tfor count, player in enumerate(board):\n\t\tif player is not server_pl...
[ "0.77633595", "0.77482265", "0.768101", "0.7625057", "0.76249105", "0.75210696", "0.74038094", "0.7357803", "0.7330449", "0.72653216", "0.7263358", "0.72607195", "0.723677", "0.72177565", "0.7181947", "0.7173437", "0.71125764", "0.70690686", "0.705811", "0.7040512", "0.697783...
0.71604383
16
Can player make any moves? Returns a boolean
def any_legal_move(self, player, board): moves = self.legal_moves(player, board) #print(moves) return len(moves)!=0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_check(self):\r\n \r\n if not self.run:\r\n return False\r\n \r\n if self.get_num_legal_moves() == 0:\r\n SlTrace.lg(\"NO more legal moves!\", \"nolegalmoves\")\r\n ###return False \r\n \r\n if self.new_move:\r\n se...
[ "0.80388695", "0.7600481", "0.76002926", "0.75457877", "0.73324925", "0.7276734", "0.72636664", "0.71992004", "0.71682996", "0.7102028", "0.7098147", "0.7088383", "0.70783705", "0.70189273", "0.6986816", "0.69830495", "0.69700056", "0.69603264", "0.6956357", "0.6952261", "0.6...
0.77968675
1
Which player should move next? Returns None if no legal moves exist.
def next_player(self,board, prev_player): opp = self.opponent(prev_player) isOpp = self.any_legal_move(opp, board) isPrev = self.any_legal_move(prev_player, board) if(isOpp==False and isPrev==False): return None elif(isOpp == False and isPrev == True): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None", "def player_move():\n\tmove = None\n\twhile mo...
[ "0.7872411", "0.74398774", "0.71945137", "0.71246403", "0.70864546", "0.70783263", "0.705533", "0.7050984", "0.70068854", "0.6994962", "0.69577587", "0.6937091", "0.68736523", "0.68567985", "0.6854401", "0.6811088", "0.6777367", "0.6775967", "0.67653716", "0.67629874", "0.672...
0.74983096
1
Compute player's score (number of player's pieces minus opponent's).
def score(self,player, board): numPlayer = 0 numOpp = 0 for i in self.squares(): if board[i] == player: numPlayer+= SQUARE_WEIGHTS[i] else: numOpp+=SQUARE_WEIGHTS[i] return numPlayer-numOpp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score2(self,player, board):\r\n numPlayer = 0\r\n numOpp = 0\r\n for i in self.squares():\r\n if board[i] == player:\r\n numPlayer+= 1\r\n else:\r\n numOpp+=1\r\n return numPlayer-numOpp", "def score(player, board):\n mine...
[ "0.77100617", "0.76665014", "0.7596806", "0.755954", "0.74644375", "0.7270104", "0.72659296", "0.7192504", "0.71761346", "0.70750165", "0.70623815", "0.7020574", "0.6970311", "0.69272745", "0.69137883", "0.68977886", "0.6897169", "0.68841004", "0.68778896", "0.68595576", "0.6...
0.7846785
0
Compute player's score (number of player's pieces minus opponent's).
def score2(self,player, board): numPlayer = 0 numOpp = 0 for i in self.squares(): if board[i] == player: numPlayer+= 1 else: numOpp+=1 return numPlayer-numOpp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score(self,player, board):\r\n numPlayer = 0\r\n numOpp = 0\r\n for i in self.squares():\r\n if board[i] == player:\r\n numPlayer+= SQUARE_WEIGHTS[i]\r\n else:\r\n numOpp+=SQUARE_WEIGHTS[i]\r\n return numPlayer-numOpp", "def scor...
[ "0.7845445", "0.7665763", "0.7595392", "0.7558798", "0.74634653", "0.72690827", "0.72640866", "0.7191977", "0.7175509", "0.7073882", "0.70610803", "0.7019335", "0.696953", "0.69266623", "0.6912282", "0.6897905", "0.68971044", "0.68832207", "0.68773335", "0.68591225", "0.68503...
0.7709773
1
Determine which player won or TIED
def terminal_test(self, board): blackScore = board.count(core.BLACK) whiteScore = board.count(core.WHITE) if blackScore > whiteScore: return core.PLAYERS[core.BLACK] elif blackScore < whiteScore: return core.PLAYERS[core.WHITE] else: re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def other_player(cls, player):\n return 0 if player == 1 else 1", "def winner(self):\n if self.__current_player == 1:\n if self.__fields[0].winner():\n print(self.__players[0]._Player__name + \"is winner!\")\n Game.play = False\n elif self.__current_p...
[ "0.7408237", "0.73853755", "0.7267272", "0.72462034", "0.7160971", "0.71601397", "0.71561503", "0.7132931", "0.71317226", "0.7095893", "0.7046908", "0.70039946", "0.7000272", "0.6996662", "0.69900584", "0.6986868", "0.69611496", "0.69256836", "0.6915876", "0.6915876", "0.6915...
0.0
-1
Clip the values of x from eps to 1eps and renormalize them so that they sum to 1.
def clip_and_renorm(x, eps=1e-5): x = np.clip(x, eps, 1-eps) return x / x.sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def threshold_and_normalize_pixels(x, eps=1e-2):\n x = torch.clamp(x, min=eps)\n x = x / torch.sum(x, dim=1, keepdim=True)\n return x", "def _normalize(x):\n tol = 1e-10\n dims = x.shape\n\n x = x.flatten()\n inverse = (np.sum(x**2) + tol) ** -.5\n x = x * inverse\n ...
[ "0.716385", "0.71209276", "0.7078646", "0.6867248", "0.68503493", "0.68422705", "0.6825308", "0.6799856", "0.6776279", "0.6757192", "0.66739017", "0.66679573", "0.6650903", "0.650148", "0.6492298", "0.64902186", "0.64388424", "0.642077", "0.6390071", "0.63312405", "0.6331007"...
0.76624894
0
Run the sumproduct belief propagation for a single ray accumulating the occupancy to ray messages in log space and producing the new ray to occupancy messages. Arguments
def single_ray_belief_propagation(ray_voxel_indices, ray_to_occupancy_accumulated_pon, ray_to_occupancy_pon, s): # Create an index that when passed to a numpy array will return the voxels # that this ray passes through # TODO: Remove this c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def belief_propagation(\n S,\n ray_voxel_indices,\n ray_voxel_count,\n ray_to_occupancy_messages_pon,\n grid_shape,\n gamma=0.05,\n bp_iterations=3,\n progress_callback=lambda *args: None\n):\n # Extract the number of rays\n N, M = S.shape\n\n # Initialize the ray to occupancy mess...
[ "0.6919233", "0.5892002", "0.5517866", "0.54245466", "0.52051145", "0.51677525", "0.5152469", "0.5125298", "0.5082556", "0.50799584", "0.5073586", "0.505811", "0.5040545", "0.5011798", "0.4996324", "0.498793", "0.49791676", "0.49737632", "0.4945683", "0.49369043", "0.49077606...
0.7314743
0
Compute the depth distribution for each ray according to eq 55 in my report.
def single_ray_depth_estimate( ray_voxel_indices, ray_to_occupancy_accumulated_pon, ray_to_occupancy_pon, s ): # Create an index that when passed to a numpy array will return the voxels # that this ray passes through if ray_voxel_indices.shape[-1] == 3: indices = ( ray_vo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_depth_distribution(\n S,\n ray_voxel_indices,\n ray_voxel_count,\n ray_to_occupancy_messages_pon,\n ray_to_occupancy_accumulated_pon,\n S_new\n):\n # Extract the number of rays\n N, M = S.shape\n\n # Fill S_new with zeros\n S_new.fill(0)\n\n # Iterate over the rays\n ...
[ "0.6694844", "0.6654807", "0.6267751", "0.6171776", "0.6167753", "0.59690034", "0.59573865", "0.5930685", "0.59288687", "0.5914298", "0.57433236", "0.5730665", "0.5693678", "0.5665114", "0.5603573", "0.5586095", "0.5579907", "0.5579907", "0.5555946", "0.55493295", "0.55155706...
0.61307365
5
Compute the approximate marginal distributions of each occupancy variable
def compute_occupancy_probabilities( ray_to_occupancy_accumulated_pon, gamma=0.031 ): # The probability of the i^th voxel is given from # p(o_i) =\ # \mu_{\phi \to o_i}(o_i) \prod_{\psi_k \in L} \mu_{\psi_k \to o_i}(o_i) # # We need to compute the \prod_{\psi_k \in L} \mu_{\psi_k \to o_i}(o_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marginalDistribution(self, x, variable):\n return self._distribution.marginal(x, variable)", "def occupation_distribution(data):", "def marginal(self):\n m = np.zeros(len(self.domain))\n for fnode in self.neighbors:\n m += self.received[fnode]\n return np.exp(normalize(m)...
[ "0.69214064", "0.6871677", "0.67752934", "0.6695681", "0.6630897", "0.6572321", "0.6369079", "0.63327956", "0.6281994", "0.62414736", "0.62369066", "0.61250496", "0.61205524", "0.61062807", "0.60554814", "0.60171336", "0.5955231", "0.593358", "0.58735806", "0.5868777", "0.586...
0.0
-1
Run the belief propagation for a set of rays
def belief_propagation( S, ray_voxel_indices, ray_voxel_count, ray_to_occupancy_messages_pon, grid_shape, gamma=0.05, bp_iterations=3, progress_callback=lambda *args: None ): # Extract the number of rays N, M = S.shape # Initialize the ray to occupancy messages to uniform ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def single_ray_belief_propagation(ray_voxel_indices,\n ray_to_occupancy_accumulated_pon,\n ray_to_occupancy_pon, s):\n # Create an index that when passed to a numpy array will return the voxels\n # that this ray passes through\n # TODO: Rem...
[ "0.6051191", "0.57601404", "0.56488925", "0.5455181", "0.5427728", "0.54135686", "0.5383709", "0.53433657", "0.5283373", "0.52386534", "0.5231889", "0.52266884", "0.5205245", "0.5200786", "0.51926756", "0.5170246", "0.51418513", "0.51362956", "0.5133803", "0.51281625", "0.512...
0.64419127
0
Perform the depth estimation according to Equation 55 in my report p(D_r = d_i) = 1\Z \mu_{o_i \to \psi_r}(o_i=1) \prod_{j=1}^{i1} \mu_{o_j \to \psi_r}(o_j = 0) s_i
def compute_depth_distribution( S, ray_voxel_indices, ray_voxel_count, ray_to_occupancy_messages_pon, ray_to_occupancy_accumulated_pon, S_new ): # Extract the number of rays N, M = S.shape # Fill S_new with zeros S_new.fill(0) # Iterate over the rays for r in range(N): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_estimation(x_left, x_right, f=33.4, d=114):\n depth = abs(f * d / ((x_left - x_right) / 72 * 2.54)) / 100 # - 0.418879\n return depth", "def _estimateDepth(self, size, neighbourRadius):\n neighbourRadius *= 1.5\n for i in xrange(100):\n j = 2**i\n spacings = [...
[ "0.67218643", "0.6288294", "0.6240507", "0.594687", "0.5937492", "0.59242696", "0.586455", "0.58417153", "0.57648003", "0.57510024", "0.57486445", "0.5738527", "0.5704622", "0.5702639", "0.56910264", "0.56805176", "0.5638139", "0.5630299", "0.56262654", "0.56231076", "0.56103...
0.0
-1
View the top of the heap
def peek(self): return self.m * self.heap[0] if self.heap else None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top(heap):\n return heap[_root()]", "def top(self):", "def print_heap(self):\n print self.queue[:self.size:]", "def top(self, top):\n self.ptr.top(top)", "def vtop(self, addr):\n pass", "def main():\n heap = MinHeap()\n for i in range(10):\n heap.add(i)\n print...
[ "0.7776735", "0.73952436", "0.71884525", "0.7153927", "0.69775426", "0.69589305", "0.6931902", "0.6920529", "0.68991625", "0.6857245", "0.6803377", "0.6803377", "0.65676486", "0.648923", "0.64815575", "0.64791524", "0.6466259", "0.64315844", "0.6429634", "0.63845813", "0.6348...
0.6263346
30
Add a new item to the heap
def push(self, item): self.heap.append(self.m * item) self._sift_up()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(self, item):\n heapq.heappush(self.heap, item)", "def insert(self, item):\n self.heaplist.append(item)\n self.currentsize += 1\n self.shift_item_up(self.currentsize)", "def heappush(heap, item):\n heap.append(item)\n Heap.siftdown(heap, 0, len(heap) - 1)", "...
[ "0.86625844", "0.84260476", "0.83818865", "0.83268684", "0.83058447", "0.83046746", "0.81907606", "0.81827074", "0.8125624", "0.8119751", "0.8094255", "0.7948402", "0.78585076", "0.7813688", "0.77300596", "0.7647694", "0.7630693", "0.760874", "0.75826657", "0.75822777", "0.75...
0.8161657
8
Plot stats for allproperties specified in properties_to_plot on one plot.
def optimization_run_properties_one_plot( results: Result, properties_to_plot: Optional[List[str]] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], List[List[float]]]] = None, legends: Optional[Union[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_many(self, property_list):\n\t\tself.property_existence(property_list)\n\n\t\tsns.pairplot(self.df[property_list])\n\t\tplt.tight_layout()\n\t\tplt.show()", "def plot_properties(self, property_x=None, property_y=None):\n\n\t\tself.property_existence([property_x, property_y])\n\n\t\tfig, ax = plt.subplot...
[ "0.75361174", "0.73993117", "0.6505304", "0.6423644", "0.633898", "0.6082438", "0.5929184", "0.59047884", "0.58050925", "0.5801211", "0.5786275", "0.57455045", "0.5687699", "0.5686295", "0.5667004", "0.56063676", "0.55991805", "0.55541974", "0.5547238", "0.55392843", "0.55346...
0.6990053
2
One plot per optimization property in properties_to_plot.
def optimization_run_properties_per_multistart( results: Union[Result, Sequence[Result]], properties_to_plot: Optional[List[str]] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], List[List[float]]]] = Non...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_many(self, property_list):\n\t\tself.property_existence(property_list)\n\n\t\tsns.pairplot(self.df[property_list])\n\t\tplt.tight_layout()\n\t\tplt.show()", "def optimization_run_properties_one_plot(\n results: Result,\n properties_to_plot: Optional[List[str]] = None,\n size: Tuple[float, float...
[ "0.71136564", "0.7106824", "0.70605874", "0.61590767", "0.6127294", "0.6100989", "0.58987767", "0.5892727", "0.5865572", "0.58586276", "0.58002615", "0.5791218", "0.57700926", "0.57644415", "0.5728571", "0.57230747", "0.57168967", "0.5715274", "0.5685466", "0.5634376", "0.561...
0.61634773
3
Plot stats for an optimization run property specified by opt_run_property. It is possible to plot a histogram or a line plot. In a line plot, on the x axis are the numbers of the multistarts, where the multistarts are ordered with respect to a function value. On the y axis of the line plot the value of the correspondin...
def optimization_run_property_per_multistart( results: Union[Result, Sequence[Result]], opt_run_property: str, axes: Optional[matplotlib.axes.Axes] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], Lis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimization_run_properties_one_plot(\n results: Result,\n properties_to_plot: Optional[List[str]] = None,\n size: Tuple[float, float] = (18.5, 10.5),\n start_indices: Optional[Union[int, Iterable[int]]] = None,\n colors: Optional[Union[List[float], List[List[float]]]] = None,\n legends: Opti...
[ "0.66925603", "0.63589454", "0.6322748", "0.6245997", "0.602035", "0.59249425", "0.59024245", "0.5690448", "0.568816", "0.5664423", "0.5628853", "0.56173986", "0.56059617", "0.55577713", "0.55445033", "0.5530686", "0.55180305", "0.55145836", "0.54932714", "0.547722", "0.54603...
0.7293934
0
Plot values of the optimization run property across different multistarts.
def stats_lowlevel( result: Result, property_name: str, axis_label: str, ax: matplotlib.axes.Axes, start_indices: Optional[Union[int, Iterable[int]]] = None, color: Union[str, List[float], List[List[float]]] = 'C0', legend: Optional[str] = None, plot_type: str = 'line', ): fvals = re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def results_plot_fuel_reactor(self):\n \n import matplotlib.pyplot as plt \n\n # Total pressure profile\n P = []\n for z in self.MB_fuel.z:\n P.append(value(self.MB_fuel.P[z]))\n fig_P = plt.figure(1)\n plt.plot(self.MB_fuel.z, P)\n plt.grid()\n plt.xlabel(\"Bed height [-]\")\n...
[ "0.67386675", "0.6636919", "0.6468642", "0.63708216", "0.6351907", "0.6337131", "0.6336514", "0.62994426", "0.6257881", "0.6239519", "0.6221294", "0.61722106", "0.61707246", "0.6161194", "0.61459094", "0.61107713", "0.61022514", "0.60939723", "0.60936457", "0.60926545", "0.60...
0.0
-1
Creates a pt = [x, y]' vector and yaw scalar from two input vectors representing points in the map frame.
def _get_pt_theta(self, R, C, base_rad_m=0.2): #rospy.loginfo("Received R: %s, C: %s" % (R, C)) G = C - R #rospy.loginfo("Calculated G = %s" % G) G_mag = np.linalg.norm(G) #rospy.loginfo("Calculated G_mag = %s" % G_mag) # magnitude of distance for goal is magnitude of di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vector_to_pitchyaw(vectors):\n '''x = cos(yaw)cos(pitch) y = sin(yaw)cos(pitch) z = sin(pitch)'''\n n = vectors.shape[0]\n out = np.empty((n, 2))\n vectors = np.divide(vectors, np.linalg.norm(vectors, axis=1).reshape(n, 1))\n out[:, 0] = np.arcsin(vectors[:, 1]) # theta\n out[:, 1] = np.arct...
[ "0.7170129", "0.68854094", "0.6122778", "0.609041", "0.5802181", "0.5776113", "0.5679148", "0.5653731", "0.56464136", "0.558112", "0.5578127", "0.5555221", "0.5537814", "0.552987", "0.5524724", "0.552017", "0.55173385", "0.5503303", "0.550058", "0.5496128", "0.54903823", "0...
0.0
-1
Checks a row & peg combination to see if it refers to a real place in the triangle.
def is_valid(row, peg): return ( (row < TRI_SIZE) and (row >= 0) and (peg < TRI_SIZE) and (peg >= 0) and (peg <= row) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __check_row(self, x: int, y: int) -> bool:\n return not any([self.__maze[x, y + i] for i in (-1, 0, 1)])", "def _pre_check(self) -> bool:\n if self._fuse_row:\n rows = (\n self._tiling.cells_in_row(self._row_idx),\n self._tiling.cells_in_row(self._row_id...
[ "0.7280164", "0.68686604", "0.6789244", "0.67537653", "0.6733248", "0.6684262", "0.6682173", "0.65795547", "0.6564693", "0.65318656", "0.6483577", "0.6470317", "0.6459898", "0.6441177", "0.64353055", "0.64183944", "0.63982993", "0.63813514", "0.6358549", "0.6357853", "0.63511...
0.79514277
0
Returns a copy of the triangle (faster than deepcopy).
def copy_triangle(tri): return [[peg for peg in row] for row in tri]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triangle(self):\n [r,c] = self.D\n m = min(r,c)\n S = self\n T = zeros(r,c)\n while m > 0:\n NoLigne = 0\n while S[NoLigne, 0] == 0 and (NoLigne < m - 1):\n NoLigne += 1\n S = S.swap(NoLigne,0)\n if S[...
[ "0.6823598", "0.642301", "0.6033022", "0.6030731", "0.5999631", "0.5969139", "0.59297556", "0.58959395", "0.58513814", "0.58339965", "0.57237965", "0.5711828", "0.56681204", "0.560612", "0.55897707", "0.5587957", "0.5586594", "0.55755776", "0.5572819", "0.5558009", "0.5556987...
0.720594
0
Performs a jump between an occupied (row, peg) tuple A and an unoccupied C, passing over B. If anything is bad with the jump, returns False; otherwise returns True.
def jump(tri, A, B, C): start_row, start_peg = A mid_row, mid_peg = B end_row, end_peg = C # Check to make sure A is occupied and B is clear if tri[start_row][start_peg] == False: return False if tri[end_row][end_peg]: return False # Make sure we're jumping over an occupied space. if t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jump(self, j_orig, j_over, j_land):\n orig_x, orig_y = j_orig\n over_x, over_y = j_over\n land_x, land_y = j_land\n\n # indexes for each square\n orig_i = orig_y * self.ncols + orig_x\n over_i = over_y * self.ncols + over_x\n land_i = land_y * self.ncols + land_...
[ "0.58794034", "0.5780335", "0.56505096", "0.56226003", "0.5529821", "0.548902", "0.545118", "0.54377955", "0.5421571", "0.54183495", "0.5403734", "0.5387588", "0.53724825", "0.5344193", "0.5342577", "0.5336441", "0.52679", "0.52414954", "0.5229286", "0.52260715", "0.52221286"...
0.7989009
0
Returns a (mid_row, mid_peg) tuple between (start_row, start_peg) and (end_row, end_peg).
def mid(start_row, start_peg, end_row, end_peg): if start_row + 2 == end_row: mid_row = start_row + 1 elif start_row == end_row + 2: mid_row = start_row - 1 elif start_row == end_row: mid_row = start_row if start_peg + 2 == end_peg: mid_peg = start_peg + 1 elif start...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def startAndEnd(self):\n upperRow = 0\n upperCol = 0\n lowerRow = 0\n lowerCol = 0\n if self.selectionMode == kSelectionNone:\n upperRow = self.penRow\n upperCol = self.penCol\n lowerRow = self.penRow\n lowerCol = self.penCol\n e...
[ "0.6485405", "0.59999824", "0.599718", "0.57569534", "0.57080907", "0.5679897", "0.5622903", "0.5562309", "0.5506314", "0.5498558", "0.54762554", "0.54337853", "0.53962946", "0.5344107", "0.53079104", "0.52601105", "0.5217689", "0.5206089", "0.51990014", "0.51918226", "0.5168...
0.84714884
0
Prints out the history of states.
def print_history(hist): print_triangle(triangle) for past_triangle in hist: print_triangle(past_triangle) print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_history(self):\n self.game_started = False\n for state in self.history:\n self.__draw_board(state)", "def showState(self):\n for i in self.state[0]:\n for j in self.state[1]:\n print(self.table[i][j], end=\"\")\n print(\"\")", "def ...
[ "0.7997242", "0.7270549", "0.72583467", "0.71551496", "0.7126221", "0.70488614", "0.69170225", "0.670212", "0.6673894", "0.662962", "0.65791935", "0.6547414", "0.6543382", "0.64653563", "0.64425373", "0.64204794", "0.64140356", "0.6396624", "0.6376319", "0.63631135", "0.63414...
0.7103629
5
Searches, using recursive backtracking.
def search(tri, history = []): count = 0 children = [] for start_row in range(len(tri)): for start_peg in range(len(tri[start_row])): if tri[start_row][start_peg] == True: count += 1 for end_row, end_peg in jump_lookup[(start_row, start_peg)]: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(self):\r\n #get the initial state\r\n initialState = State()\r\n \r\n #create root node\r\n rootNode = Node(initialState)\r\n \r\n #show the search tree explored so far\r\n treeplot = TreePlot()\r\n treeplot.generateDiagram(rootNode, rootNod...
[ "0.6654038", "0.65033793", "0.6456524", "0.6307618", "0.6231046", "0.62213635", "0.6207362", "0.61557186", "0.6107835", "0.6091845", "0.6074678", "0.60684437", "0.60239583", "0.5979148", "0.59736043", "0.5972576", "0.5958814", "0.5956313", "0.5955384", "0.5945115", "0.5939703...
0.6503747
1
Create a redis connection by uri.
def connect_redis(uri): puri = urlparse.urlparse(uri) host = puri.hostname port = puri.port password = puri.password if puri.password else '' db_name = puri.path.split('/')[1] r = redis.Redis(host=host, port=port, password=password, db=db_name) assert r.ping() return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conn_redis(host, port, db=0):\r\n r = redis.Redis(host=host, port=port, db=db)\r\n return r", "def create_connection():\n # REDIS_URL is defined in .env and loaded into the environment by Honcho\n redis_url = os.getenv('REDIS_URL')\n # If it's not defined, use the Redis default\n if not red...
[ "0.7483556", "0.74211794", "0.7264241", "0.72543937", "0.68576866", "0.67962694", "0.6592169", "0.65768725", "0.6565991", "0.6559168", "0.65246797", "0.6495612", "0.6445122", "0.64029026", "0.63978356", "0.6371485", "0.6359366", "0.6345691", "0.6345691", "0.6323229", "0.62616...
0.82560194
0
Update next_waypoint based on base_waypoints and current_pose. True if a valid waypoint has been updated, False otherwise
def _update_next_waypoint(self): if not self.base_waypoints: #rospy.logwarn("Waypoints not updated: base_waypoints not available yet.") return False if not self.current_pose: #rospy.logwarn("Waypoints not updated: current_pose not available yet.") return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self):\n\n # If the agent has already reached the\n # last waypoint it doesn't need to update\n if self.finished:\n return True\n\n # Skip if the proxy don't have any [new] data\n if (self.pp.info.datatime == 0) or \\\n (self.pp.info.datatime == s...
[ "0.75298524", "0.6561931", "0.6387742", "0.6317193", "0.63150394", "0.622506", "0.60167783", "0.59918606", "0.5980918", "0.59700096", "0.5907589", "0.59038836", "0.5851159", "0.5754915", "0.5693167", "0.5637678", "0.56281024", "0.5589967", "0.5589809", "0.5587563", "0.5584952...
0.78717625
0
Update next_waypoint based on current_pose and base_waypoints Generate the list of the next LOOKAHEAD_WPS waypoints Update velocity for them Publish them to "/final_waypoints"
def update_and_publish(self): # 1. Find next_waypoint based on ego position & orientation if self._update_next_waypoint(): # 2. Generate the list of next LOOKAHEAD_WPS waypoints num_base_wp = len(self.base_waypoints) last_base_wp = num_base_wp-1 waypoint_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_next_waypoint(self):\n if not self.base_waypoints:\n #rospy.logwarn(\"Waypoints not updated: base_waypoints not available yet.\")\n return False\n\n if not self.current_pose:\n #rospy.logwarn(\"Waypoints not updated: current_pose not available yet.\")\n ...
[ "0.7230159", "0.6776315", "0.67544454", "0.6514871", "0.6341936", "0.6335558", "0.633497", "0.6204625", "0.61543787", "0.6134523", "0.6099235", "0.6051331", "0.59626335", "0.5945264", "0.5943431", "0.59124935", "0.5906773", "0.5842161", "0.5803007", "0.5779287", "0.57633066",...
0.8069657
0
Receive and store ego pose
def pose_cb(self, msg): self.current_pose = msg.pose
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pose_cb(self, msg):\n rospy.loginfo(rospy.get_name() + ': pose received')\n self.current_pose = msg.pose", "def handle_pose(msg):\n global sensor_cfg\n global no_position\n global body_frame\n global frame_cfg\n\n quat = np.array([msg.pose.orientation.x, msg.pose.orientation.y, m...
[ "0.6791787", "0.6781667", "0.64822555", "0.64822555", "0.64195806", "0.63596", "0.6339097", "0.6322449", "0.62868583", "0.62387246", "0.62365425", "0.62295204", "0.61943114", "0.6193431", "0.6192812", "0.61869586", "0.61656916", "0.61653006", "0.61484575", "0.61422306", "0.60...
0.662574
2
Receive and store the whole list of waypoints.
def waypoints_cb(self, msg): t = time.time() waypoints = msg.waypoints num_wp = len(waypoints) if self.base_waypoints and self.next_waypoint is not None: # Normally we assume that waypoint list doesn't change (or, at least, not # in the position where the car is ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def waypoints_cb(self, msg):\n rospy.loginfo(rospy.get_name() + ': waypoints received')\n self.base_waypoints = msg.waypoints", "def getWaypoints(self):\n return self.listener.waypoints", "def waypoints_cb(self, waypoints):\n # This callback should be called only once, with the list...
[ "0.6804397", "0.6662376", "0.62895554", "0.5920205", "0.59094435", "0.58577603", "0.58577603", "0.5814295", "0.5766491", "0.57356954", "0.5727133", "0.5711017", "0.5708899", "0.56178194", "0.5490954", "0.5476933", "0.5401106", "0.5401106", "0.5384114", "0.53779995", "0.533546...
0.63749915
2
Receive and store the waypoint index for the next red traffic light. If the index is <0, then there is no red traffic light ahead
def traffic_cb(self, msg): prev_red_light_waypoint = self.red_light_waypoint self.red_light_waypoint = msg.data if msg.data >= 0 else None if prev_red_light_waypoint != self.red_light_waypoint: if debugging: rospy.loginfo("TrafficLight changed: %s", str(self.red_light...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def traffic_waypoint_cb(self, msg):\n\n # Save waypoint index for detected traffic light\n self.stopline_waypoint_idx = msg.data", "def process_traffic_lights(self):\n light = None\n\n #some plausability checks before starting the processing\n if None is self.waypoints:\n ...
[ "0.68233603", "0.68028736", "0.6512141", "0.63163286", "0.62774485", "0.6242495", "0.6130179", "0.60852367", "0.6077796", "0.6001004", "0.5991535", "0.59076035", "0.58939004", "0.5641353", "0.5638717", "0.56332844", "0.55674475", "0.54337895", "0.54020077", "0.5376153", "0.53...
0.604425
9
Restore original velocities of points
def restore_velocities(self, indexes): for idx in indexes: self.set_waypoint_velocity(self.base_waypoints, idx, self.base_wp_orig_v[idx])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_velocities(self):\r\n self.wx = np.copy(Turbine.wzero)\r\n self.wy = np.copy(Turbine.wzero)", "def reset(self):\n self.t = 0.0\n self.last_t = None\n self.current_y = np.copy(self.start_y)\n self.current_yd = np.copy(self.start_yd)", "def reset(self):\n ...
[ "0.7025841", "0.6620128", "0.63186425", "0.62810314", "0.6206654", "0.61409414", "0.6138598", "0.6134401", "0.6096291", "0.60953915", "0.6012672", "0.5995094", "0.59774", "0.5973119", "0.59690225", "0.59552336", "0.59322405", "0.5886006", "0.58640605", "0.58620423", "0.585557...
0.6673411
1
Decelerate a list of wayponts so that they stop on stop_index
def decelerate(self, waypoints, stop_index, stop_distance): if stop_index <= 0: return dist = self.distance(waypoints, 0, stop_index) step = dist / stop_index # Generate waypoint velocity by traversing the waypoint list backwards: # - Everything beyond stop_index wil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plan_stop(wps, idx, min_decel, max_decel, speed_limit):\n\n if idx < 0:\n return []\n\n wps = wps[0: idx+1]\n\n # Calculate the acceleration needed to stop the car at the last waypoint in wps\n path_length = distance(wps, 0, len(wps)-1)\n a = -wps[0].twist.twist.linear.x**2/(2*path_length...
[ "0.69572246", "0.5711461", "0.56443334", "0.5461794", "0.5378483", "0.5345332", "0.5312884", "0.52976394", "0.5167818", "0.51332635", "0.51195765", "0.50715023", "0.5067811", "0.50550187", "0.50407976", "0.50374746", "0.50099397", "0.4976755", "0.49753836", "0.49560714", "0.4...
0.6354519
1
Compare two waypoints to see whether they are the same (within 0.5 m and 0.5 m/s)
def is_same_waypoint(self, wp1, wp2, max_d=0.5, max_v=0.5): dl = lambda a, b: math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2 + (a.z-b.z)**2) ddif = dl(wp1.pose.pose.position, wp2.pose.pose.position) if ddif < max_d: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __comparing_points(self, point1, point2) -> bool:\n return (abs(point1.x - point2.x) <= self.dirt_pos_tolerance and abs(\n point1.y - point2.y) <= self.dirt_pos_tolerance)", "def match(uspec1, uspec2):\n \n if uspec1.is_power_onoff() and uspec2.is_power_onoff():\n return True\n...
[ "0.66216546", "0.65738994", "0.6439483", "0.6387838", "0.6352702", "0.63003606", "0.6274246", "0.6252439", "0.6230331", "0.62167144", "0.6209074", "0.62022907", "0.61987966", "0.61629647", "0.6139927", "0.61213946", "0.6107632", "0.6103632", "0.6090313", "0.6084919", "0.60797...
0.73450947
0
Ensures that the string method behaves as expected
def test_string_method(self): # Get Bangkok bangkok = Country.objects.get(iso3="THA").capital # Assert that the string of a city is its name self.assertEqual(str(bangkok), bangkok.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_str(self):\n self.assertEqual(str(self.bs), str(self.wbs))\n self.assertEqual(str(self.be), str(self.be))\n # str(us) fails in Python 2\n self.assertEqual(str, type(str(self.wus)))\n # str(ue) fails in Python 2\n self.assertEqual(str, type(str(self.wue)))", "def...
[ "0.75274694", "0.75132626", "0.73530805", "0.7309857", "0.7270092", "0.721282", "0.71722436", "0.7136118", "0.70180273", "0.7011948", "0.6983644", "0.6929323", "0.69226277", "0.68956167", "0.68881965", "0.68660265", "0.6839274", "0.6811262", "0.68098056", "0.6734716", "0.6727...
0.0
-1
Ensures that the string method behaves as expected
def test_string_method(self): # Get Thailand thailand = Country.objects.get(iso3="THA") # Assert that the string of a city is its name self.assertEqual(str(thailand), thailand.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_str(self):\n self.assertEqual(str(self.bs), str(self.wbs))\n self.assertEqual(str(self.be), str(self.be))\n # str(us) fails in Python 2\n self.assertEqual(str, type(str(self.wus)))\n # str(ue) fails in Python 2\n self.assertEqual(str, type(str(self.wue)))", "def...
[ "0.7527163", "0.7513367", "0.73523635", "0.7309321", "0.727023", "0.72126997", "0.71719736", "0.71354777", "0.7018639", "0.7012386", "0.6982922", "0.6929377", "0.69216764", "0.68958277", "0.688879", "0.68658817", "0.6838508", "0.681058", "0.6809467", "0.6735072", "0.67267585"...
0.0
-1
Ensures that a capital can only belong to one country
def test_capital_unicity(self): # Get Bangkok bangkok = Country.objects.get(iso3="THA").capital # Get United States united_states = Country.objects.get(iso3="USA") # Initialize assertRaises block with self.assertRaises(IntegrityError): # Set the capital of...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_country_name_not_in_countries(self):\n\t\tcountry_code = get_country_code('Venezuela, RB')\n\t\tself.assertEqual(country_code, 've')", "def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is True\n assert val...
[ "0.57727647", "0.5747203", "0.5745896", "0.5662479", "0.5656905", "0.55133384", "0.54153365", "0.53913385", "0.53848505", "0.53621507", "0.5360658", "0.53440136", "0.5325288", "0.53173727", "0.528774", "0.5264815", "0.5211678", "0.5199605", "0.5149981", "0.5145287", "0.514528...
0.64122915
0
Ensures that the cleaning of UN member status behaves as expected
def test_un_member_status(self): # Get Hong Kong hong_kong = Country.objects.get(iso3="HKG") # Assert that is_un_member_at is None self.assertEqual(hong_kong.is_un_member_at, None) # Initialize assertRaises block with self.assertRaises(ValidationError): # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(self, uid, states=None):\n\n # doesn't change status", "def clean(self):\n # Perform the standard ACE cleaning\n max_status = mm_ace.clean(self)\n\n # Replace bad values with NaN and remove times with no valid data\n self.data = self.data[self.data['status'] <= max_status]\n\n ret...
[ "0.6766085", "0.60108733", "0.5959499", "0.5928209", "0.59210426", "0.5901284", "0.5901226", "0.586937", "0.5864156", "0.5860781", "0.58541995", "0.58541995", "0.58360237", "0.58315945", "0.5801635", "0.5786526", "0.57726616", "0.57681125", "0.57417685", "0.572516", "0.567833...
0.73605675
0
Two close clusters, one big and the other small,
def _generateFig1(): x0, y0 = make_blobs(n_samples=200, n_features=2, centers=[[13, 13]], cluster_std=1, random_state=45) x1, y1 = make_blobs(n_samples=1000, n_features=2, centers=[[5, 0]], cluster_std=3.7, random_state=45) y1 += 1 X = np.vstack((x0, x1)) y = np.hstack((y0, y1)) # Visualize the...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compare(self):\n len0 = len(self.cluster_lists[0])\n len1 = len(self.cluster_lists[1])\n longer_index = 0 if len0 >= len1 else 1\n shorter_index = 1 if len1 <= len0 else 0\n self.stars_length = len(self.cluster_lists[shorter_index]) \n self.starlets_length = len(self.c...
[ "0.6443352", "0.6231452", "0.6208744", "0.6200639", "0.6188412", "0.6161846", "0.6109839", "0.6088792", "0.60667986", "0.6064064", "0.6028824", "0.60123897", "0.60062116", "0.5996975", "0.59852415", "0.59730357", "0.5971053", "0.5955494", "0.58921957", "0.58790106", "0.587067...
0.0
-1
Remove all erroneous colors, replaced by the most commonly found in the direct neighborhood
def clean(data, out, npcolors): prev_err = 0 new_err = 0 old = data.copy() for r in range(data.shape[0]): for c in range(data.shape[1]): found = -1 for i, col in enumerate(npcolors): if data[r, c] == col: found = i if fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_colors(images):\n images = images[:, :, :, :, 0]\n return images", "def color_invalid(self):\n for i in self.invalid:\n self.color_cell(i, INVALID)", "def lightness_correction(self):\n points = self.color_lookup_table_points\n lightness_max_value = math.sqrt(3 *...
[ "0.6484606", "0.6377774", "0.62030065", "0.60673124", "0.6038112", "0.5998475", "0.5998475", "0.595649", "0.594523", "0.5914712", "0.5899766", "0.58824664", "0.58483124", "0.5814882", "0.580523", "0.5790582", "0.5781437", "0.57611006", "0.575656", "0.5732335", "0.5723635", ...
0.6692518
0
Run a default synthesis
def test_synth_simple(): twd = tempfile.mkdtemp(dir=os.getcwd()+"/tmp") print(twd) wmin, wmax, dwl = 6700, 6720, 0.01 ll = turbopy.TSLineList(os.path.join(data_path, "vald-6700-6720.list")) atmo = turbopy.MARCSModel.load(os.path.join(data_path, "sun.mod")) atmo.Teff = 5777 atmo.log...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_a_sound(): # document string\n print('quack')", "def main():\n\n start_program()\n yes_syn_words, no_syn_words, stop_words, record, mp3_filename, text, device_index, output_file = \\\n process_parameter_set()\n stand_alone_flag = process_check_input_argument()\n process_speak_liste...
[ "0.60132974", "0.59505826", "0.5925289", "0.5898953", "0.58482397", "0.58189064", "0.580842", "0.57480925", "0.5742441", "0.57370013", "0.5716831", "0.56612676", "0.56570905", "0.5643319", "0.5616963", "0.5609976", "0.560651", "0.5598493", "0.55957323", "0.5588792", "0.556845...
0.5430164
30
Run a default synthesis
def test_synth_linelist(): twd = tempfile.mkdtemp(dir=os.getcwd()+"/tmp") print(twd) wmin, wmax, dwl = 6700, 6720, 0.01 ll1 = turbopy.TSLineList(os.path.join(data_path, "vald-6700-6720.list")) ll2 = turbopy.TSLineList(os.path.join(data_path, "converted_BertrandPlez.002060")) atmo = tur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_a_sound(): # document string\n print('quack')", "def main():\n\n start_program()\n yes_syn_words, no_syn_words, stop_words, record, mp3_filename, text, device_index, output_file = \\\n process_parameter_set()\n stand_alone_flag = process_check_input_argument()\n process_speak_liste...
[ "0.6013574", "0.5951026", "0.5925496", "0.5898746", "0.5848472", "0.5818447", "0.58081436", "0.57470936", "0.5742656", "0.57360643", "0.5716793", "0.5661541", "0.5656903", "0.5644049", "0.5617325", "0.56107515", "0.5605524", "0.5597335", "0.55965066", "0.5587949", "0.556806",...
0.0
-1
Call metric on dataset.
def __call__(self, dataset: 'LAMLDataset', dropna: bool = False): assert hasattr(dataset, 'target'), 'Dataset should have target to calculate metric' raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, dataset):\n\t\tpass", "def calculate_dataset_metrics(self):\n pass", "def __evaluate_metric(dataset, y_act, y_pred):\n if dataset.metric == 'specific':\n if dataset.best_is_min:\n return return_specific_metrics(y_act, y_pred)\n else:\n return -re...
[ "0.69342786", "0.6845238", "0.64811146", "0.647018", "0.63276863", "0.63267714", "0.62144816", "0.6204923", "0.6203799", "0.6178699", "0.6079341", "0.6041779", "0.60119766", "0.6000055", "0.59915954", "0.5976304", "0.59285223", "0.590045", "0.5898877", "0.58946544", "0.589144...
0.63039166
6
Calculate metric value. If the metric does not include weights, then they are ignored.
def __call__(self, y_true, y_pred, sample_weight=None): if self.flg: return self.func(y_true, y_pred, sample_weight=sample_weight) return self.func(y_true, y_pred)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weighted_metrics(self):\n return None", "def evaluate(self, representativeness: float, weight: float) -> float:\n pass", "def getWeight(self) -> float:\n ...", "def calculate_weighted_results():\n pass", "def default_metric_value(self) -> float:", "def getMetricValue(self):\n ...
[ "0.701454", "0.68711394", "0.67886615", "0.6717882", "0.66692466", "0.6656426", "0.65597034", "0.65110725", "0.6412962", "0.634709", "0.6312145", "0.62502164", "0.6189488", "0.6171433", "0.6166266", "0.6166266", "0.6159111", "0.6145808", "0.6094989", "0.6055709", "0.6042169",...
0.0
-1
Name of used metric.
def name(self) -> str: if self._name is None: return 'AutoML Metric' else: return self._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric_name(self) -> str:\n return self._metric_name", "def metric_name(self) -> str:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> str:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> str:\n return self._values.get('metric_name'...
[ "0.83211684", "0.8219123", "0.8219123", "0.81296223", "0.81296223", "0.7885565", "0.78679574", "0.7769057", "0.7769057", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.7764613", "0.741644", "0.71540844", "0.69523746"...
0.76520246
18
Implement call sklearn metric on dataset.
def __call__(self, dataset: 'SklearnCompatible', dropna: bool = False) -> float: assert hasattr(dataset, 'target'), 'Dataset should have target to calculate metric' if self.one_dim: assert dataset.shape[1] == 1, 'Dataset should have single column if metric is one_dim' # TODO: maybe r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, dataset):\n\t\tpass", "def evaluate(self, data, metric, classes=None):\n func_dict = {\n 'mutual_information': sklearn.metrics.mutual_info_score,\n 'normed_mutual_information': sklearn.metrics.normalized_mutual_info_score,\n 'square_error': sklearn.metrics.mean_squa...
[ "0.69129854", "0.66921866", "0.6664506", "0.6658557", "0.65358526", "0.64022624", "0.63196886", "0.6217403", "0.62092805", "0.61501414", "0.61377925", "0.6125066", "0.6089111", "0.6083159", "0.60741395", "0.6060244", "0.6057991", "0.6048644", "0.6021093", "0.5998874", "0.5975...
0.6836997
1
Create metric for dataset. Get LAMLMetric that is called on dataset.
def get_dataset_metric(self) -> LAMLMetric: # for now - case of sklearn metric only one_dim = self.name in _one_dim_output_tasks dataset_metric = SkMetric(self.metric_func, name=self.metric_name, one_dim=one_dim, greater_is_better=self.greater_is_better) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_metric(self) -> EvalMetric:\n pass", "def create_metric(self) -> 'LossMetric':\n raise NotImplementedError()", "def __call__(self, dataset: 'LAMLDataset', dropna: bool = False):\n assert hasattr(dataset, 'target'), 'Dataset should have target to calculate metric'\n raise ...
[ "0.666398", "0.60399914", "0.5974834", "0.5590214", "0.55357915", "0.55043375", "0.55043375", "0.5482854", "0.54779565", "0.5451086", "0.5451086", "0.54114413", "0.5354682", "0.5354682", "0.51812303", "0.51812303", "0.51733845", "0.5146675", "0.5142152", "0.5129933", "0.51012...
0.7164863
0
loads the trained model
def __init__(self , model_file_name ): logging.set_verbosity(logging.ERROR) with TheTFGraph.as_default(): with TheTFSession.as_default(): self.model = keras.models.load_model( model_file_name + ".hdf5" , compile=False ) JSON = json.load( open(model_file_name + ".json"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(self):\n print(\"==> Loading model from\", self.model_dir)\n self.model = tf.keras.models.load_model(self.model_dir)", "def load_model(self):\n if self.ckpt_flag:\n LOG('Skip Loading Pre-trained Model......')\n else:\n if self.params.pre_trained_from is ...
[ "0.83975", "0.80978334", "0.803848", "0.8006234", "0.8006234", "0.7986819", "0.7961007", "0.79427683", "0.7912983", "0.7907797", "0.7878334", "0.7867409", "0.78210264", "0.7813657", "0.7778192", "0.7770571", "0.7763487", "0.7745689", "0.76948744", "0.76580065", "0.7651958", ...
0.0
-1
returns the prediction of the model for the input good/bad site errors
def __call__(self , good_sites={} , bad_sites={} , wf=None , tsk=None , sourcejson=None): if wf : if sourcejson : jj = json.load( open(sourcejson) ) jjb = jj[wf]['errors'] good_sites = jjb['good_sites'] bad_sites = jjb['bad_sites'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, X):\n fmodel = self.estimators_[np.array(self.estimator_errors_).argmin()]\n predictions = fmodel.predict(X)\n return predictions", "def predict(x_tst, model):\n\n predictions = model.predict(x_tst)\n return predictions", "def make_predictions(self):\n if is_...
[ "0.65535253", "0.6547375", "0.6497838", "0.6474936", "0.64700997", "0.6457139", "0.6452555", "0.643692", "0.6426011", "0.63976145", "0.63880944", "0.63773805", "0.634643", "0.63293964", "0.63226146", "0.63225234", "0.63196623", "0.630443", "0.6302294", "0.6301109", "0.6288922...
0.0
-1
Returns confirmation html page
def get(cls, confirmation_id: str): response_object = {"status": "fail", "message": "Invalid Payload"} confirmation = ConfirmationModel.find_by_id(_id=confirmation_id) if not confirmation: response_object["message"] = "Confirmation reference not found" return response_ob...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm(request):\n return render(request,\"confirm.html\")", "def confirm():\n if request.method == 'POST':\n user_type = session.get('type', None)\n if user_type == 'Admin':\n return redirect('/index')\n elif user_type == 'Client':\n return redirect('/client...
[ "0.74561346", "0.683766", "0.6733679", "0.6456007", "0.64410394", "0.63745975", "0.6295902", "0.6274699", "0.62547296", "0.6234513", "0.6206061", "0.62045884", "0.6164084", "0.6094845", "0.60204047", "0.60081846", "0.5981034", "0.5932147", "0.5919668", "0.5891318", "0.5888231...
0.5670258
38
Returns confirmation for specific user
def get(cls, user_id: int): response_object = {"status": "fail"} user = UserModel.find_by_id(_id=user_id) if not user: return response_object, 404 else: response_object["status"] = "success" response_object["current_time"] = int(time()) re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_confirmation_email(user_pk):\n pass", "def confirm():\n if request.method == 'POST':\n user_type = session.get('type', None)\n if user_type == 'Admin':\n return redirect('/index')\n elif user_type == 'Client':\n return redirect('/clients/' + session.get('...
[ "0.76152027", "0.7109021", "0.6789676", "0.67045313", "0.6679205", "0.6656919", "0.6578207", "0.6557551", "0.6538443", "0.65078926", "0.6493086", "0.6492265", "0.6421568", "0.6383825", "0.6377426", "0.63269174", "0.6316806", "0.6283499", "0.6260746", "0.6254596", "0.62017685"...
0.54621446
82
Collectes entries in rootdir's basedir directory which is always relateive to rootdir.
def _collect_entries(rootdir: str, basedir: str): files = [] dirs = [] for entry in os.listdir(os.path.join(rootdir, basedir)): rel_path = os.path.join(basedir, entry) full_path = os.path.join(rootdir, rel_path) isdir = os.path.isdir(full_path) if isdir and (rel_path in ('....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_final_dirs(self, root=\"\"):\n _updated = int(self.stats()[\"db_update\"])\n _hash = uhash(root)\n return self._get_final_dirs(_updated=_updated, _hash=_hash, root=root)", "def getImmediateSubdirectories(dir):", "def _load_dirs(self):\n rootdirs = self._docset.get_compounds(...
[ "0.66336405", "0.6516187", "0.63490784", "0.6312109", "0.6306998", "0.6250683", "0.61746", "0.6130482", "0.6113366", "0.6081825", "0.60749775", "0.6051456", "0.6035353", "0.602858", "0.60019743", "0.59748715", "0.59671766", "0.59671766", "0.5945204", "0.593414", "0.5931592", ...
0.76479506
0
Return MD5 hash's hexdigest bases on nongit nonpycache entries of the root_dir. The purpose is to check if two directory is identical except the modification dates. The two directories can be on different machines when the file transfer would be costly.
def python_repo_hash_md5(root_dir: str, *, verbose: bool = False): m = hashlib.md5() for e in _collect_entries(root_dir, '.'): if verbose: log_info('Processing e', e) m.update( f"path={e['path']}\tisdir={e['isdir']}\tsize={e['size']}\tmode={e['mode']:03o}\tmtime={e['mtime...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_md5_of_dir(self, verbose=0):\n directory = self.cfg['sharing_path']\n if verbose:\n start = time.time()\n md5Hash = hashlib.md5()\n if not os.path.exists(directory):\n self.stop(1, 'Error during calculate md5! Impossible to find \"{}\" in user folder'...
[ "0.6838967", "0.6250359", "0.6099796", "0.5913261", "0.5903527", "0.5851177", "0.5848145", "0.5792256", "0.5689556", "0.56635755", "0.56403613", "0.5586936", "0.5534521", "0.5526404", "0.5467155", "0.5463636", "0.54520786", "0.5427325", "0.5422579", "0.54110044", "0.5407061",...
0.7109552
0
Plot comparison for Neural Network perturbation
def plot_xents(name, col1="darkblue", col2="darkred", ylim=0.2): mean5 = np.loadtxt("mean5_{}.txt".format(name)) mean15 = np.loadtxt("mean15_{}.txt".format(name)) pos1 = np.arange(1, len(mean5)+1) pos2 = np.arange(1, len(mean15)+1) sns.set_style("darkgrid") plt.plot(pos1, mean5, col1, pos2, me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_predictions(self):\n\n plt.title(\"Targets vs. Predictions\")\n plt.plot(self.T, label=\"Targets\")\n plt.plot(self.Y, label=\"Predictions\")\n plt.xlabel(\"Sample number\")\n plt.legend()\n plt.show()", "def visualizePredictions(testData,knn_predictions):\r\n ...
[ "0.6870466", "0.6508898", "0.64197093", "0.63677764", "0.6366839", "0.63598055", "0.63373405", "0.63080764", "0.62799644", "0.6244469", "0.62381005", "0.62381005", "0.6214602", "0.6193353", "0.61867315", "0.6180719", "0.61647266", "0.61536115", "0.610797", "0.60818666", "0.60...
0.0
-1
Like handle_solvent_tests(), but for systems with a membrane
def handle_solvent_memb_tests(test_case, do_copy=False): if not 'solvent_tests' in test_case: raise ValueError("Missing 'solvent_tests'") solvent_tests = test_case['solvent_tests'] # find the step containing SOLVENT_TEST_PLACEHOLDER placeholder = 'SOLVENT_TEST_PLACEHOLDER' found = False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gameHandleEvents(self):\n # this kinda gonna be reiterating the other tests??\n # the tests of all the individual methods below make this test work\n pass", "def unitary_test():", "def test_launch_failures_hw(self):\n self.test_launch_failures()", "def test_emirp_check():...
[ "0.6400076", "0.59792304", "0.58952934", "0.5888097", "0.5808284", "0.5806006", "0.5801247", "0.57660025", "0.5746992", "0.5736676", "0.5736101", "0.57240546", "0.57185507", "0.56993955", "0.5694084", "0.56916356", "0.5690784", "0.5688461", "0.56859887", "0.5669558", "0.56647...
0.0
-1
Modifies water/ion options to include solvents according to the
def handle_solvent_tests(test_case, do_copy=False): if not 'solvent_tests' in test_case: raise ValueError("Missing 'solvent_tests'") solvent_tests = test_case['solvent_tests'] # find the step containing SOLVENT_TEST_PLACEHOLDER placeholder = 'SOLVENT_TEST_PLACEHOLDER' found = False inde...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_config(cls, config, is_mode_config):\n if not is_mode_config:\n if 'enable_events' not in config:\n config['enable_events'] = 'ball_started'\n if 'disable_events' not in config:\n config['disable_events'] = 'ball_will_end'\n return super...
[ "0.55244476", "0.55244476", "0.5211806", "0.5174427", "0.51648545", "0.5157156", "0.50999045", "0.5090809", "0.50349927", "0.50240684", "0.5003229", "0.49945912", "0.49207282", "0.49151343", "0.49150056", "0.49043357", "0.4872846", "0.4868255", "0.48596564", "0.48412472", "0....
0.0
-1
Computes the content cost
def compute_content_cost(a_C, a_G): # Retrieve dimensions from a_G (≈1 line) m, n_H, n_W, n_C = a_G.get_shape().as_list() # Reshape a_C and a_G (≈2 lines) a_C_unrolled = tf.reshape(a_C, [m, n_H * n_W, n_C]) a_G_unrolled = tf.reshape(a_G, [m, n_H * n_W, n_C]) # compute the cost with tensorflow...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cost(self) -> float:", "def compute_cost(self, chrome):\n return 1", "def cost(self):\n\t\treturn self.g + self.h", "def compute_content_cost(self, a_C, a_G):\n\n m, n_H, n_W, n_C = a_G.get_shape().as_list()\n\n a_C_unrolled = tf.reshape(a_C, (n_H * n_W, n_C))\n a_G_unrolled =...
[ "0.76748216", "0.73723125", "0.689193", "0.68261766", "0.6787472", "0.6782727", "0.6749342", "0.6747946", "0.65489316", "0.6513681", "0.6508743", "0.6505938", "0.64938504", "0.6434525", "0.6429838", "0.64291674", "0.6428066", "0.64240986", "0.6412745", "0.6402376", "0.6370504...
0.6479049
13
Computes the overall style cost from several chosen layers
def compute_style_cost(model, STYLE_LAYERS): # initialize the overall style cost J_style = 0 for layer_name, coeff in STYLE_LAYERS: # Select the output tensor of the currently selected layer out = model[layer_name] # Set a_S to be the hidden layer activation from the layer we have...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_style_cost(model,style_wave, STYLE_LAYERS):\n\n # initialize the overall style cost\n J_style = 0\n\n for layer_name, coeff in STYLE_LAYERS:\n\n # Select the output tensor of the currently selected layer\n #out = model[layer_name]\n out = model.get_layer(layer_name).output...
[ "0.7501626", "0.7382344", "0.63541365", "0.62836343", "0.62559444", "0.6132296", "0.6114782", "0.6114248", "0.6106048", "0.608636", "0.60851204", "0.6052765", "0.6023517", "0.5955185", "0.59520197", "0.59369844", "0.593539", "0.5922794", "0.59108067", "0.5899719", "0.58480173...
0.7322137
2
Computes the total cost function
def total_cost(J_content, J_style, alpha=10, beta=40): J = alpha * J_content + beta * J_style return J
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_total_cost(state):\n pass", "def calculate_total_cost(state):\r\n return state.cost()", "def cost(self) -> float:", "def total_cost(self):\n return np.einsum('i->', self.c[self.s])", "def calcCostFun(self):\n\n self.start()\n F, K = self.model()\n \n r...
[ "0.8076102", "0.80038726", "0.7963573", "0.7839396", "0.76213026", "0.7587885", "0.7572381", "0.7552255", "0.7447264", "0.7335212", "0.73171985", "0.730358", "0.7302065", "0.7297157", "0.7279061", "0.7229969", "0.72176164", "0.721449", "0.7213855", "0.720213", "0.7183842", ...
0.0
-1
Deactivate an ApiOAuth2Application Does not delete the database record, but revokes all tokens and sets a flag that hides this instance from API
def deactivate(self, save=False): client = cas.get_client() # Will raise a CasHttpError if deletion fails, which will also stop setting of active=False. resp = client.revoke_application_tokens(self.client_id, self.client_secret) # noqa self.is_active = False if save: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revoke_api_access(application):\n try:\n file = open(PATH + '/../DB/access.json', 'r')\n accessData = json.load(file)\n if (application in accessData):\n accessData.pop(application, None)\n\n with open(PATH + '/../DB/access.json', 'w') as f:\n f.write(json.d...
[ "0.6420284", "0.64088273", "0.6401829", "0.6401829", "0.6192459", "0.6173356", "0.6137181", "0.6090798", "0.6071947", "0.6071947", "0.60594076", "0.5915336", "0.58965695", "0.5862787", "0.5858027", "0.58575356", "0.58293414", "0.5747239", "0.5745004", "0.57321835", "0.5720194...
0.7059044
0
Reset the secret of an ApiOAuth2Application Revokes all tokens
def reset_secret(self, save=False): client = cas.get_client() client.revoke_application_tokens(self.client_id, self.client_secret) self.client_secret = generate_client_secret() if save: self.save() return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resetSecret(self):\n self.secret = str(uuid())\n self.put()", "def _clear_secret_token_map():\n global _secret_token_map\n _secret_token_map = None", "def manage_clearSecrets(self, REQUEST):\n manager = getUtility(IKeyManager)\n manager.clear()\n manager.rotate()\n ...
[ "0.699256", "0.6872917", "0.6153157", "0.6107559", "0.59967816", "0.59598404", "0.5934698", "0.5888643", "0.58882296", "0.5865433", "0.5845431", "0.5785667", "0.57682496", "0.5740121", "0.5738762", "0.57173806", "0.5665614", "0.5649307", "0.56228507", "0.56142944", "0.5586983...
0.702098
0
Deactivate an ApiOAuth2PersonalToken Does not delete the database record, but hides this instance from API
def deactivate(self, save=False): client = cas.get_client() # Will raise a CasHttpError if deletion fails for any reason other than the token # not yet being created. This will also stop setting of active=False. try: resp = client.revoke_tokens({'token': self.token_id}) # no...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_auth_token():\n data = get_request_data(request)\n address = data.get(\"address\")\n token = data.get(\"token\")\n\n valid, message = is_token_valid(token, address)\n if not valid:\n return jsonify(error=message), 400\n\n force_expire_token(token)\n\n return jsonify(success=\...
[ "0.68359965", "0.68096167", "0.65469694", "0.6422617", "0.6284022", "0.6237951", "0.61001736", "0.60755134", "0.60667545", "0.60667545", "0.6003061", "0.59748185", "0.59192157", "0.5878691", "0.5849091", "0.5848954", "0.58168155", "0.5810158", "0.5800938", "0.57993716", "0.57...
0.7050593
0
Constructor set the file path
def __init__(self, path): self.csv_path = path # check if csv format is valid or not self.check_valid_csvformat(self.csv_path) """ empty dict to store all company names prepare initial company data in dictionary format """ self.company_data = dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, path, file):\n self.path = path\n self.file = file", "def __init__(self, path):\n self.path = os.path.abspath(path)", "def __init__(self, filepath):\n self.filepath = filepath", "def __init__(self, path):\n self.path = path", "def __init__(self, path):\...
[ "0.8336858", "0.8283488", "0.8017652", "0.80134624", "0.80134624", "0.80134624", "0.80134624", "0.80072695", "0.79191643", "0.79079074", "0.78379184", "0.7812701", "0.7712044", "0.7698701", "0.76643", "0.76627487", "0.76627487", "0.7616975", "0.75978684", "0.7526664", "0.7496...
0.0
-1
Calls the cvsfileUsage function to start parsing
def __call__(self): return self.csvfileUsage()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n parse_file(sys.argv[1])", "def main():\n parser = ArgumentParser(usage='%(prog)s [options] ecommonsMetadata.csv')\n parser.add_argument(\"-d\", \"--date\", dest=\"date\",\n help=\"Date on or after that an ETD was published for \\\n creating DOI...
[ "0.58680946", "0.584178", "0.56904954", "0.55948025", "0.55103976", "0.54529536", "0.5447621", "0.5420857", "0.5396767", "0.5378413", "0.5375421", "0.5359897", "0.53025967", "0.5297627", "0.52868927", "0.52581596", "0.52294654", "0.5224852", "0.5216758", "0.51756084", "0.5175...
0.6263405
0
Check if Header is correct
def check_valid_csv_header(self, row): obj = re.match(re.compile('^Year\,Month\,.'), ','.join(row)) if not obj: raise Exception("Invalid Headers must be `Year` `Month` Check Sample file")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_header(self, name, value):\r\n if value in self.headers.get(name, ''):\r\n return True\r\n return False", "def check_header(self, name, value):\r\n if value in self.headers.get(name, ''):\r\n return True\r\n return False", "def test_check_header(self)...
[ "0.74777883", "0.74777883", "0.7314567", "0.7220998", "0.7158477", "0.71231633", "0.71042866", "0.71036303", "0.7052667", "0.7031326", "0.70234644", "0.70112914", "0.69430315", "0.69109553", "0.6900488", "0.6896769", "0.6890224", "0.68511075", "0.6850088", "0.68461525", "0.68...
0.6272523
52
Check For valid csv data
def check_valid_csv_data(self, row): obj = re.match(re.compile('^[0-9]{4}\,[A-Z]{1}[a-z]{2}\,.'), ','.join(row)) if not obj: raise Exception("Invalid Data String must be like `1990` `Jan` Check Sample file")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_valid_csvformat(self, csv_path):\n with open(self.csv_path, \"rb+\") as file_obj:\n reader = csv.reader(file_obj, delimiter=',') # CSV DictReader object\n self.check_valid_csv_header(reader.next())\n self.check_valid_csv_data(reader.next())", "def validate_csv_s...
[ "0.80091965", "0.75875276", "0.75167954", "0.741095", "0.71336776", "0.70634043", "0.6948182", "0.68665993", "0.6859504", "0.67613226", "0.67475", "0.6734457", "0.67083627", "0.6599125", "0.6583989", "0.65218884", "0.6469705", "0.64656794", "0.6436142", "0.6427924", "0.640778...
0.7886953
1
Check if csv is in valid format with data
def check_valid_csvformat(self, csv_path): with open(self.csv_path, "rb+") as file_obj: reader = csv.reader(file_obj, delimiter=',') # CSV DictReader object self.check_valid_csv_header(reader.next()) self.check_valid_csv_data(reader.next())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_valid_csv_data(self, row):\n obj = re.match(re.compile('^[0-9]{4}\\,[A-Z]{1}[a-z]{2}\\,.'),\n ','.join(row))\n if not obj:\n raise Exception(\"Invalid Data String must be like `1990` `Jan` Check Sample file\")", "def validate_csv(filen...
[ "0.79888827", "0.77903473", "0.7676916", "0.73605514", "0.72107303", "0.69361657", "0.6886044", "0.68570256", "0.68204045", "0.67923874", "0.67035025", "0.65973264", "0.65804535", "0.6500226", "0.6483696", "0.644907", "0.6433415", "0.64274734", "0.63892037", "0.6351961", "0.6...
0.8132414
0
Prepare the company's data
def prepare_company_data(self, month, year, row, company_data): for key, value in row.items(): if not company_data[key]: company_data[key] = {'year':year, 'month':month, 'value':value} else: """main operation updating the company's data per year ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getCompaniesData(self, schema):\n try:\n self.cursor.execute(\"\"\"SELECT id, twitter, proven_score, slug FROM {schema}.vendors_vendor WHERE\n twitter <> ''\"\"\".format(schema=schema))\n data = self.cursor.fetchall()\n\n companies = []\n...
[ "0.6938614", "0.67131525", "0.67055386", "0.6524873", "0.63706404", "0.6255161", "0.6225849", "0.6220218", "0.62027955", "0.6075558", "0.5998771", "0.5954136", "0.59276706", "0.5911707", "0.5911581", "0.5889178", "0.5853898", "0.58073986", "0.5801998", "0.5798251", "0.5788507...
0.71914417
0
Read the file and parse it
def csvfileUsage(self): with open(self.csv_path, "rb+") as file_obj: reader = csv.DictReader(file_obj, delimiter=',') # CSV DictReader object """ reader.fieldnames returns header , slicing intial 'Month' and 'Year' header from list """ for com_nam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_file(self, file):\n return self.parse(file.read())", "def parse(self, filename):\n infile = file(filename)\n for line in infile:\n self.parseLine(line)", "def parse(self, infile):\r\n raise NotImplementedError()", "def _parse(self, infile):\n raise NotImple...
[ "0.7704631", "0.7608055", "0.7606781", "0.74729276", "0.73044264", "0.7196149", "0.71839684", "0.71827775", "0.7099208", "0.7099208", "0.7064892", "0.70613736", "0.7029887", "0.7019118", "0.69390094", "0.69175214", "0.69132525", "0.6905551", "0.6891379", "0.68839794", "0.6870...
0.0
-1
print result data in pretty format
def print_pretty(self, data): length = max(map(lambda x: len(x), data.keys())) print '+-------------------------------------+' print '| Company Name | Year | Month | Value |' print '+-------------------------------------+' for key, value in data.items(): print '| %s ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PrettyPrint(self):\r\n print(self.data)\r\n return", "def Display(self, unused_args, result):\n util.PrettyPrint(result)", "def Display(self, unused_args, result):\n util.PrettyPrint(result)", "def pretty_print(self):\n pt = PrettyTable()\n for i in self.files_summary:\n...
[ "0.7651632", "0.73510516", "0.73510516", "0.7142628", "0.7091028", "0.70429", "0.70243996", "0.7002873", "0.69559413", "0.69347566", "0.69135714", "0.68599814", "0.6835211", "0.682232", "0.6799566", "0.6789554", "0.6752801", "0.67316437", "0.6708856", "0.6648762", "0.6640318"...
0.718061
3
Takes as argument one URI from
def unpack(uri): conn = boto.connect_s3(anon=True, host='s3.amazonaws.com') bucket = conn.get_bucket('commoncrawl') key_ = Key(bucket, uri) file_ = warc.WARCFile(fileobj=GzipStreamFile(key_)) return file_
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, uri):\n\n self.uri = uri", "def url():\n ...", "def set_uri(self, uri):\r\n self.uri = uri", "def _get_url(self, absolute):", "def uri(self, uri):\n self._uri = uri", "def uri(self, uri):\n self._uri = uri", "def _uri(self):\n raise NotImplemente...
[ "0.6760875", "0.66227156", "0.657832", "0.65703005", "0.65467316", "0.65467316", "0.64905435", "0.64255947", "0.64193517", "0.63551694", "0.62846905", "0.62785953", "0.62359524", "0.62359524", "0.6218313", "0.61922807", "0.6122419", "0.6121087", "0.60790586", "0.6076218", "0....
0.0
-1
Iterates through WARC records of an unpacked file in a Spark job.
def extract_json(id_, iterator): for uri in iterator: file = unpack(uri) for record in file: if record['Content-Type'] == 'application/json': try: content = json.loads(record.payload.read()) yield content['Envelope'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redshift_file_loader(spark, tbname, tmpdir):\n filelist_rdd = redshift_loader(spark, tbname, tmpdir) \\\n .rdd.map(lambda x: Row(caseid=x.case_id, filepath=x.path + '/' + x.filename))\n return filelist_rdd", "def test_iterate_over_stream():\n archive = Archive()\n archive.commit(doc=DataFr...
[ "0.5444572", "0.5430409", "0.5317964", "0.5192848", "0.51737136", "0.5160396", "0.51200193", "0.5114372", "0.50979865", "0.50848365", "0.50716513", "0.5044458", "0.50402385", "0.5039158", "0.50273323", "0.50213903", "0.5004219", "0.4995018", "0.49946946", "0.499466", "0.49611...
0.0
-1
Takes WARC record and returns domain of target URI plus Counter for domains of outlinked pages if these exist.
def parse_links(record): try: page_url = record['WARC-Header-Metadata']['WARC-Target-URI'] page_domain = urlparse.urlparse(page_url).netloc links = record['Payload-Metadata']['HTTP-Response-Metadata']['HTML-Metadata']['Links'] out_links = Counter([urlparse.urlparse(url['url']).netloc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_domains(urls, screen_name, domains):\n\n def add_domain_to_dict(domains, domain_string):\n \"\"\" helper function\"\"\"\n domain = urlparse(unquote(domain_string)).netloc.replace('www.', '')\n domain = domain.split(':')[0]\n try:\n new_domain = get_domain(domain)\n except ValueError:...
[ "0.5832478", "0.5743405", "0.5526221", "0.54275036", "0.5161741", "0.51254606", "0.5115564", "0.50487834", "0.5029015", "0.49536353", "0.49229515", "0.49164706", "0.48799717", "0.48791456", "0.4861495", "0.48533532", "0.48137897", "0.4801171", "0.47810617", "0.4773569", "0.47...
0.68593603
0
Takes WARC record and outputs all pairs (domain, path) from URIs, if these exist. It searches both target URI and outlinks and does not distinguish between them.
def parse_urls(record): url_list = [] try: page_url = record['WARC-Header-Metadata']['WARC-Target-URI'] x = urlparse.urlparse(page_url) url_list += [(x.netloc, x.path)] except: pass try: links = record['Payload-Metadata']['HTTP-Response-Metadata']['HTML-Metada...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_links(record):\n try:\n page_url = record['WARC-Header-Metadata']['WARC-Target-URI']\n page_domain = urlparse.urlparse(page_url).netloc\n links = record['Payload-Metadata']['HTTP-Response-Metadata']['HTML-Metadata']['Links']\n out_links = Counter([urlparse.urlparse(url['url...
[ "0.648302", "0.58565474", "0.57382894", "0.56618035", "0.55831033", "0.55718136", "0.5427328", "0.5408748", "0.53590286", "0.53027636", "0.526104", "0.52590644", "0.5210608", "0.5188143", "0.5162076", "0.5156036", "0.51295507", "0.51037467", "0.50811", "0.5069011", "0.5066564...
0.6712598
0
Temporary ASCII encoding for human readable hex with ' ' as delimiter for detecting nonLatin unicode.
def hexify(c): try: s = c.encode("utf-8").encode("hex") except UnicodeDecodeError: s = 0 n = len(s) if n <= 2: return s a = ' - '.join([s[i:i+2] for i in range(0,n,2)]) return a[:-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_ascii(text):\n return re.sub(r'[^\\x00-\\x7F]+', ' ', text)", "def hexbyte(string):\n#\treturn repr(string)\n\ts = \"\"\n\tfor i in string:\n\t\tif (ord(i) >= ord('A') and ord(i) <= ord('z')) \\\n\t\t\tor (ord(i) >= ord('0') and ord(i) <= ord('9')) \\\n\t\t\tor (ord(i) == ord(\" \")):\n\t\t\ts += \"%s\...
[ "0.66453975", "0.65925515", "0.65499693", "0.64991313", "0.64508224", "0.637776", "0.63622725", "0.6336682", "0.63067186", "0.6247356", "0.6247335", "0.6172891", "0.6159729", "0.6143763", "0.61208767", "0.61158335", "0.611007", "0.6102653", "0.6097139", "0.60858274", "0.60734...
0.61688596
12
Takes domain and concatenates with path URIs separated by newlines..
def domain_string(domain, path_set): out = domain + '\n' + '\n'.join(list(path_set)) + '\n\n\n' return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_link(url_domain, url_path):\n\n # Ensure domain is not empty\n if url_domain.strip() == \"\":\n return url_path\n\n # Strip / at end of domain\n if url_domain[-1] == \"/\":\n url_domain = url_domain[0:-1]\n\n # Strip / at beginning of path\n if url_path[0] == \"/\":\n ...
[ "0.6588488", "0.6037963", "0.59932935", "0.58680135", "0.5814077", "0.58129615", "0.5769635", "0.5683123", "0.566781", "0.56072015", "0.55921346", "0.55277026", "0.5518288", "0.5502831", "0.5482606", "0.5472744", "0.545825", "0.54528075", "0.5439585", "0.5436488", "0.54126805...
0.71544874
0
Computes the excess nr bytes over nr characters in a domain string.
def nonlatin_detector(dom): str = domain_string(dom[0], dom[1]) N = len(str) hex = [c.encode('utf-8').encode('hex') for c in list(str)] return float(sum([len(h)/2 for h in hex]) - N)/N
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def len_unpadded(self) -> int:", "def _get_num_chars(a):\n if issubclass(a.dtype.type, str_):\n return a.itemsize // 4\n return a.itemsize", "def _model_string_maxlen():\n # hardcoded for convenience. Could be dynamically set in future.\n # the current longest is: BLOSUM62+I+G+X, i.e. 14 cha...
[ "0.5984497", "0.589638", "0.58957535", "0.58499557", "0.58037084", "0.57385695", "0.5657735", "0.5636777", "0.5635527", "0.5634374", "0.5584988", "0.5581181", "0.5567638", "0.55576235", "0.5543473", "0.55387914", "0.5511795", "0.5505335", "0.5472981", "0.5454402", "0.5447952"...
0.0
-1
Normalised 2char hex representation of 0255
def hx(i): a = hex(i)[2:] if len(a)<2: a = ''.join(['0',a]) return a
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def int2hex(n: int) -> str:", "def sanatize_hex(data: str) -> str:\n return data.replace(\"0x\", \"\").replace(\"0X\", \"\")", "def convertirHexadecimal(self):\n self.convertir(lambda c: hex(ord(c))[2:], sep=' ')", "def hexify(c):\n try:\n s = c.encode(\"utf-8\").encode(\"hex\")\n exce...
[ "0.7478835", "0.7241786", "0.72120225", "0.711506", "0.7042994", "0.70428777", "0.7005129", "0.68801385", "0.6858315", "0.6853162", "0.6843357", "0.68172914", "0.6791203", "0.6791164", "0.6763778", "0.6758954", "0.67498916", "0.67462385", "0.6711573", "0.66784096", "0.66678",...
0.7174581
3
Coarse first version of a feature vector for a string. A placeholder for stronger versions.
def string_features_v1(str): N = float(len(str)) if N==0: return None a = len(re.findall(r'/', str))/N b = len(re.findall(r'\.', str))/N c = len(re.findall(r'-', str))/N d = len(re.findall(r'_', str))/N cap = len(re.findall(r'[A-Z]', str))/N num = len(re.findall(r'[0-9]', str))/N ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feature_vector(features, vector):\n clean_features = set(features)\n new_features_vector = featurize(vector,clean_features)\n return new_features_vector", "def training(string):\n print(\"Training...\")\n vec = create_vector(string)\n print(\"Selecting features...\")\n feature_list = sel...
[ "0.6198624", "0.5924267", "0.54814017", "0.54337686", "0.53859985", "0.5342566", "0.5328747", "0.52908", "0.5278484", "0.5193796", "0.5187327", "0.5172308", "0.51401806", "0.512927", "0.5113244", "0.51110196", "0.50867546", "0.50867546", "0.5078367", "0.50766903", "0.505309",...
0.54504055
3
Symbol distribution of a hexalised string.
def string_features_hex(hexstr): out = dict([(x,0) for x in hexabet]) ct = dict(Counter(hexstr.split())) N = len(hexstr.split()) for k in out.keys(): if k in ct.keys(): out[k] += ct[k] out = [v[1] for v in sorted(out.iteritems(), key=lambda (k,v): k)] out = [float(x)/N for x ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _symbol(self,s):\n return self.symbollist[s%len(self.symbollist)]", "def customHashFunc(str):\n return sum(ord(chr) for chr in str)%128", "def H(s):\n return 'H_' + ''.join(['%02x' % ord(x) for x in s])", "def get_hash_code(s):\n h = 0\n n = len(s)\n for i, c in enumerat...
[ "0.60032827", "0.59784114", "0.59590006", "0.5900072", "0.5883766", "0.5832786", "0.58078927", "0.5785384", "0.5761886", "0.5714655", "0.5704629", "0.56721306", "0.5666979", "0.5638854", "0.5600783", "0.5577806", "0.5572179", "0.55721414", "0.55712956", "0.55402035", "0.55278...
0.5976867
2
Takes domain + set of paths as output by parse_urls() and applies extracts statistics of the signature string.
def domain_features(domain, path_set): return string_features_v2(domain_string(domain, path_set))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_stats():\r\n\r\n time_signature = {}\r\n time_verification = {}\r\n\r\n # this should speed up things\r\n message = \"Alice, send me 100 bucks. --Bob\"\r\n message = long(sha256(message).hexdigest(), 16)\r\n\r\n curvas = [(i, getattr(nist_curves, i)) for i in dir(nist_curves) if\r\n ...
[ "0.543832", "0.5280647", "0.51642716", "0.5056459", "0.495256", "0.48807248", "0.48625764", "0.48599264", "0.48568204", "0.47857365", "0.47223318", "0.47000122", "0.46585315", "0.46579164", "0.46506143", "0.46413884", "0.463814", "0.46201074", "0.46052003", "0.45923313", "0.4...
0.0
-1
Main entry point of the app
def main(args): unsorted_array = [] if args.order == 'ASC': unsorted_array = list(range(0, int(args.instancesize))) if args.order == 'DESC': unsorted_array = list(range(0, int(args.instancesize))) unsorted_array = list(reversed(unsorted_array)) if args.order == 'RAND': unsorted_array = list(range(0, int(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n app = App()\n app.run()", "def main():\n print(\"def main\")\n return APP.run()", "def main(args=None):\n app()\n return 0", "def main():\n CLI_APP.run()", "def main():\n app.run(debug=True)", "def entry_point():", "def entry_point():", "def entry_point():", "def s...
[ "0.8601892", "0.82477033", "0.8174292", "0.7943747", "0.7931633", "0.77617663", "0.77617663", "0.77617663", "0.77537346", "0.77359056", "0.7666645", "0.75611967", "0.75611967", "0.75611967", "0.7544734", "0.7544734", "0.7457229", "0.74511474", "0.7445474", "0.7421503", "0.736...
0.0
-1
Creates a DataFrame with polygones and IDs for all tax zones.
def createEmptyMapData(): with open('data/taxzone.json', 'r') as f: taxzones = json.load(f) polygons_shape = [shape(feature['geometry']) for feature in taxzones['features']] names = [feature['properties']['id'] for feature in taxzones['features']] map_data = pd.DataFrame({'poly': polygons_shape...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def taxa_data_frame(self):\n cols = list(self._taxa.keys())\n cols.remove(\"uid\")\n cols.remove(\"object\")\n df = DataFrame(self._taxa, columns=cols, index=self._taxa[\"uid\"])\n df.index.name = \"uid\"\n\n return df", "def taxi_zones(path, storage_options=None):\n ...
[ "0.6282922", "0.62614584", "0.6177866", "0.58757657", "0.58594614", "0.57724375", "0.5746732", "0.5704685", "0.57044125", "0.5677378", "0.56272644", "0.55792403", "0.5492265", "0.5476538", "0.54143095", "0.53428125", "0.53372324", "0.5313981", "0.52794796", "0.52559406", "0.5...
0.74269277
0
Appends a new column named 'field_name' to map_data. The data is read from json_file. Flag single_point_per_zone set True, will only read a single count per polygon.
def addJsonFileToMapData(json_file, field_name, map_data, single_point_per_zone=False): # Read the json file json_data = pd.io.json.read_json(json_file) json_data['points'] = json_data.apply(lambda row: Point(row.coords), axis=1) # Loop over all polygons in the map. poly_counts = [] for polygon...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def geojson2postgis(self, filepath, table_name, geo_type):\n map_data = gpd.GeoDataFrame.from_file(filepath)\n # Maybe you want to change link address\n link = \"postgresql://{0}:{1}@{3}:5432/{2}\".format(self.username, self.password, self.dbname, self.host)\n engine = create_engine(lin...
[ "0.561637", "0.55059373", "0.5413647", "0.52885896", "0.5211857", "0.5193927", "0.51066226", "0.5084411", "0.50838536", "0.50032544", "0.49953464", "0.49931327", "0.49827933", "0.4979779", "0.4963164", "0.49228954", "0.49089125", "0.4892675", "0.48825735", "0.48774529", "0.48...
0.8169456
0
Calculates an index for 'field_name' per tax zone and write to
def writeIndex(map_data, field_name, maximize=True): ids = map_data['id'] values = map_data[field_name] nominal_weight = 1.0 if maximize else -1.0 index = values / (nominal_weight * values.max()) toJson(field_name, pd.DataFrame({'id': ids, 'counts': index}))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_index_fields(self, doc, generator, obj, obj_weight):\n for field in self.fields + self.tags:\n # Trying to resolve field value or skip it\n # Отладочка:\n # print(field, field.resolve(obj))\n try:\n value = field.resolve(obj)\n ...
[ "0.6045815", "0.59405386", "0.57463485", "0.564753", "0.55667436", "0.5516358", "0.55148894", "0.5372689", "0.5284643", "0.52227765", "0.5101695", "0.5095111", "0.5091843", "0.50435126", "0.5030053", "0.49656203", "0.49575928", "0.49503458", "0.49441987", "0.49435893", "0.492...
0.579337
2
Calculates an index for 'field_name' per tax zone and write to
def writeTotalIndex(map_data): ids = map_data['id'] index = [0.0] * len(ids) colnames = ['cars', 'bikes', 'ages', 'parking', 'male_singles', 'female_singles', 'digging', 'freeparking'] weights = [-0.5, 0.5, 0.1, -0.5, 1.0, 1.0, -1.0, 0.25] for colname, weight in zip(colnames, weight...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_index_fields(self, doc, generator, obj, obj_weight):\n for field in self.fields + self.tags:\n # Trying to resolve field value or skip it\n # Отладочка:\n # print(field, field.resolve(obj))\n try:\n value = field.resolve(obj)\n ...
[ "0.60469466", "0.5940006", "0.579213", "0.5747278", "0.5647309", "0.5565693", "0.5516555", "0.5514874", "0.53720456", "0.52844715", "0.52218103", "0.51000774", "0.5094659", "0.5091636", "0.50427294", "0.5030341", "0.49658278", "0.495945", "0.49500096", "0.4943826", "0.4943691...
0.4619004
61
Error estimation. Calculations according to ANALYTICAL CHEMISTRY, VOL. 60, NO. 8, APRIL 15, 1988 notations
def error_estimation_simplex(vertex_vector_h, vertex_chi_sq_h, func): # print("\nvertex_vector") # print(vertex_vector_h) # print("\nvertex_chi_sq") # print(vertex_chi_sq_h) # temporary solution k, hh = vertex_vector_h.shape # hh = k-1 theta_0 = vertex_vector_h[0, :] m_q = numpy.zeros(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tracking_error(port_returns, market_returns):\n\n return np.std(port_returns - market_returns)", "def tracking_error(port_returns, market_returns):\n\n return np.std(port_returns - market_returns)", "def stderr(predicted, actual):\n return np.sqrt(mse(predicted, actual))", "def get_error(self, p...
[ "0.69430315", "0.69430315", "0.6911518", "0.6877277", "0.68557733", "0.6848958", "0.68399894", "0.6835873", "0.6823637", "0.68171746", "0.6803245", "0.68006253", "0.6743161", "0.6693619", "0.66766125", "0.66423595", "0.6633245", "0.6627338", "0.6619845", "0.6579423", "0.65755...
0.0
-1
Self attention layer with memory layernorm > attn > dropout > residual
def forward(self, input_, context, pos_emb, mask_tgt, mask_src, mems=None, incremental=False, incremental_cache=None): # incremental=False, incremental_cache=None, reuse_source=True): assert context is None, "This model does not have an context encoder" coin = True if se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(\n self,\n x: torch.Tensor,\n self_attn_mask: torch.Tensor = None,\n self_attn_padding_mask: torch.Tensor = None,\n need_weights: bool = False,\n pos_bias=None\n ):\n residual = x\n\n if self.layer_norm_first:\n ...
[ "0.65101606", "0.6506882", "0.6454085", "0.644183", "0.64174455", "0.63672817", "0.633365", "0.63287926", "0.63155437", "0.6293508", "0.62866867", "0.6259745", "0.6250611", "0.62303746", "0.61847997", "0.6182898", "0.61732996", "0.61547047", "0.6128263", "0.60605913", "0.6054...
0.0
-1
A message handler method may simply be a method with som kwargs. The kwargs will be given all incoming pipeline data, the bus and the incoming payload.
def MessageHandlerMethod(**kwargs): data: dict = kwargs['data'] bus: AbstractPikaBus = kwargs['bus'] payload: dict = kwargs['payload'] print(payload) if payload['reply']: payload['reply'] = False bus.Reply(payload=payload)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_message(**payload):\n handler_instance = message.MessageHandler(payload)\n handler_instance.handle()", "def _incoming_handler(self, context, message, fake_reply):\r\n return self._map[message.method](context, fake_reply, *message.args, **message.kwargs)", "def _handler(self, message):\n...
[ "0.70364314", "0.68466866", "0.67132837", "0.65455157", "0.65276337", "0.6499453", "0.64698917", "0.64215446", "0.64198", "0.63106513", "0.6194863", "0.61529726", "0.6119505", "0.6105504", "0.6038387", "0.60153407", "0.59553987", "0.59527606", "0.5943922", "0.5909026", "0.586...
0.7705003
0
derivative of tanh(x) = 1. (tanh(x) ^.2)
def d_tanh(x): return 1. - np.power(np.tanh(x), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def d_tanh(x):\n\n return 1 - x.tanh().pow(2)", "def d_tanh(x:float)->float:\n if not isinstance(x, numbers.Real):\n raise TypeError(\"Input value of invalid type\")\n\n return(1 - math.pow(math.tanh(x), 2))", "def tanh(x):\n return (1 - e ** (-2*x))/ (1 + e ** (-2*x))", "def tanh(x):\n ...
[ "0.83941805", "0.80225915", "0.7937077", "0.78862315", "0.78078306", "0.7777195", "0.7777195", "0.7744556", "0.75239104", "0.7510693", "0.74799824", "0.746419", "0.74618053", "0.7429449", "0.73665565", "0.7362666", "0.7334647", "0.72786546", "0.727234", "0.7268931", "0.721921...
0.8256705
1
layers should be list of neurons in each layer, ex. [2, 3, 1]
def __init__(self, layers, r_min, r_max, learn_rate): if not isinstance(layers, list) or len(layers) < 3: raise ValueError('invalid layer parammeter') self.layers = layers n_layer = len(layers) self.n_layer = n_layer self.r_min = r_min self.r_max = r_max ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(layers):", "def neural_net(self, layers):\n model = nn.Sequential()\n for l in range(0, len(layers) - 1):\n model.add_module(\"layer_\"+str(l), nn.Linear(layers[l],layers[l+1], bias=True))\n if l != len(layers) - 2:\n model.add_module(\"tanh_\"+str(l), n...
[ "0.70136875", "0.68148184", "0.6751892", "0.66633844", "0.6655421", "0.6595561", "0.65422", "0.6519088", "0.64663005", "0.646612", "0.63524765", "0.63213307", "0.63038063", "0.6303545", "0.6292076", "0.62888145", "0.628552", "0.6281839", "0.6280622", "0.6247004", "0.62343776"...
0.5791597
63
initialize wight from uniform distribution
def init_w(self, size): return np.random.uniform(self.r_min, self.r_max, size=size)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WeightInitializer():\n return np.random.uniform(-1, 1)", "def init_weights(self):\n \n self.w = np.random.randn(self.D) / np.sqrt(self.D)", "def initializeDistribution(self):\n if (self.lowerBoundUsed == False and self.upperBoundUsed == False):\n self._distribution = distribution1D...
[ "0.75663126", "0.75101614", "0.7399138", "0.7150266", "0.7104282", "0.6855432", "0.6811932", "0.680855", "0.68040025", "0.67960006", "0.6785514", "0.6735542", "0.6665591", "0.6612042", "0.66110617", "0.66074973", "0.660375", "0.66020495", "0.66020495", "0.6600997", "0.6600997...
0.71774215
3
backward propagation for 1 record.
def backward_prop(self, xs, scores, y): deltas = [] # output layer # print xs[-1].shape #assert(xs[-1].shape == ()) #assert(scores[-1].shape == ()) deltas = [] delta_L = -2 * (y - xs[-1]) * d_tanh(xs[-1]) # use reverse order first. reverse in the end ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backward(self, top, propagate_down, bottom):\n\t\tpass", "def backward(self, top, propagate_down, bottom):\r\n pass", "def backward(self):\n raise NotImplementedError", "def backward(self, top, propagate_down, bottom):\n pass", "def backward(self, top, propagate_down, bottom):\n ...
[ "0.7377122", "0.73723805", "0.73588955", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7331348", "0.7236625", "0.7236625", "0.7236625", "0.7182567", "0.7182567", ...
0.0
-1
ConnectionEndPoint a model defined in Swagger
def __init__(self, uuid: str=None, name: List[NameAndValue]=None, operational_state: str=None, lifecycle_state: str=None, termination_direction: str=None, termination_state: str=None, layer_protocol_name: str=None, connectivity_service_end_point: str=None, parent_node_edge_point: List[str]=None, client_node_edge_point:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_endpoint(self, *args):\n\t\traise NotImplementedError", "def _connectModel(self):\n pass", "def endpoint(self):\n return self.Endpoint", "def get_endpoint(self, oid):\n return self.get_object(CatalogEndpoint, ModelEndpoint, oid)", "def create_model_endpoint(\n cls,\n ...
[ "0.5856607", "0.5759765", "0.57243824", "0.5684644", "0.566107", "0.5629413", "0.55703115", "0.55450535", "0.55450535", "0.553446", "0.5505308", "0.55020016", "0.54950386", "0.54667014", "0.54559326", "0.5441568", "0.54361737", "0.5416471", "0.5397898", "0.5392145", "0.536093...
0.0
-1