query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Gets the end_action of this SubscriptionSuspensionCreate. When the suspension reaches the planned end date the end action will be carried out. This action is only executed when the suspension is ended automatically based on the end date. | def end_action(self):
return self._end_action | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_action(self, end_action):\n if end_action is None:\n raise ValueError(\"Invalid value for `end_action`, must not be `None`\")\n\n self._end_action = end_action",
"def planned_end_date(self):\n return self._planned_end_date",
"def end(self):\n # type: () -> datetim... | [
"0.6143122",
"0.5793038",
"0.5673183",
"0.55080134",
"0.5461245",
"0.5461245",
"0.5461245",
"0.545847",
"0.54330206",
"0.54330206",
"0.5424896",
"0.5364844",
"0.5364844",
"0.53592825",
"0.5262286",
"0.5255115",
"0.5213438",
"0.5212324",
"0.51485586",
"0.5137694",
"0.51369447"... | 0.6580785 | 0 |
Sets the end_action of this SubscriptionSuspensionCreate. When the suspension reaches the planned end date the end action will be carried out. This action is only executed when the suspension is ended automatically based on the end date. | def end_action(self, end_action):
if end_action is None:
raise ValueError("Invalid value for `end_action`, must not be `None`")
self._end_action = end_action | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_date(self, end_date):\n\n self._end_date = end_date",
"def end_date(self, end_date):\n\n self._end_date = end_date",
"def end_date(self, end_date):\n\n self._end_date = end_date",
"def end_date(self, end_date):\n\n self._end_date = end_date",
"def end_date(self, end_date... | [
"0.5936373",
"0.5936373",
"0.5936373",
"0.5936373",
"0.5936373",
"0.5936373",
"0.5936373",
"0.5936373",
"0.5866914",
"0.57698655",
"0.57370526",
"0.57332045",
"0.5727915",
"0.56884915",
"0.5685108",
"0.56798905",
"0.56798905",
"0.56798905",
"0.56483084",
"0.5638522",
"0.55196... | 0.7567335 | 0 |
Gets the note of this SubscriptionSuspensionCreate. The note may contain some internal information for the suspension. The note will not be disclosed to the subscriber. | def note(self):
return self._note | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_note(self):\r\n return self.__note",
"def get_note(self):\n return self.note",
"def note(self) -> str:\n return self.__note",
"def note(self) -> str:\n return self.__note",
"def note(self) -> str:\n return self.__note",
"def note(self):\n if self._simplec... | [
"0.7117262",
"0.7055138",
"0.6737177",
"0.6737177",
"0.6737177",
"0.6518097",
"0.6388679",
"0.6200899",
"0.6169843",
"0.6135926",
"0.5952921",
"0.5938423",
"0.59052694",
"0.58353114",
"0.58256793",
"0.58082664",
"0.5805374",
"0.5785396",
"0.5724418",
"0.5721736",
"0.5707965",... | 0.7211165 | 0 |
Sets the note of this SubscriptionSuspensionCreate. The note may contain some internal information for the suspension. The note will not be disclosed to the subscriber. | def note(self, note):
if note is not None and len(note) > 300:
raise ValueError("Invalid value for `note`, length must be less than or equal to `300`")
self._note = note | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_note(self):\n if self._report_data and self._report_data['note']:\n note = self._report_data['note']\n if note.get('createDateTime'):\n note['createDateTime'] = Report._to_report_datetime(note.get('createDateTime'))\n if note.get('expiryDateTime') and... | [
"0.65763193",
"0.63949037",
"0.63949037",
"0.63949037",
"0.63949037",
"0.63949037",
"0.6318726",
"0.62110776",
"0.61995065",
"0.6052707",
"0.603377",
"0.59962285",
"0.59353656",
"0.5909708",
"0.5909708",
"0.5909708",
"0.59027666",
"0.5827151",
"0.5797912",
"0.5792845",
"0.577... | 0.6840734 | 0 |
Gets the planned_end_date of this SubscriptionSuspensionCreate. The planned end date of the suspension identifies the date on which the suspension will be ended automatically. | def planned_end_date(self):
return self._planned_end_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def planned_end_date(self, planned_end_date):\n if planned_end_date is None:\n raise ValueError(\"Invalid value for `planned_end_date`, must not be `None`\")\n\n self._planned_end_date = planned_end_date",
"def planned_termination_date(self):\n return self._planned_termination_dat... | [
"0.67940325",
"0.6618622",
"0.6293864",
"0.6293864",
"0.6230565",
"0.6230565",
"0.6213361",
"0.6213361",
"0.6213361",
"0.6192062",
"0.6126461",
"0.6047898",
"0.6047435",
"0.6009267",
"0.5971236",
"0.596319",
"0.5941742",
"0.59058607",
"0.58910954",
"0.58020884",
"0.58003604",... | 0.791573 | 0 |
Sets the planned_end_date of this SubscriptionSuspensionCreate. The planned end date of the suspension identifies the date on which the suspension will be ended automatically. | def planned_end_date(self, planned_end_date):
if planned_end_date is None:
raise ValueError("Invalid value for `planned_end_date`, must not be `None`")
self._planned_end_date = planned_end_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_statement_end_date(self, end_date):\n end_date_to_set = None\n if end_date != \"\":\n end_date_to_set = end_date\n else:\n end_date_to_set = self.get_date(last_day_of_last_month=True)\n self.set_value_into_input_field(self.statement_end_date_locator, end_da... | [
"0.67294335",
"0.6711568",
"0.65507555",
"0.6507257",
"0.64512366",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6432217",
"0.6384521",
"0.6304877",
"0.6233103",
"0.6215956",
"0.6067937",
"0.59753764",
"0.5912095",
"0.5822383",... | 0.81324995 | 0 |
Sets the subscription of this SubscriptionSuspensionCreate. | def subscription(self, subscription):
if subscription is None:
raise ValueError("Invalid value for `subscription`, must not be `None`")
self._subscription = subscription | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscription(self, subscription):\n\n self._subscription = subscription",
"def subscription_id(self, subscription_id):\n\n self._subscription_id = subscription_id",
"def subscription_id(self, subscription_id):\n\n self._subscription_id = subscription_id",
"def subscription_id(self, s... | [
"0.73514724",
"0.65007716",
"0.65007716",
"0.65007716",
"0.6084177",
"0.6023973",
"0.60062104",
"0.5801773",
"0.57880664",
"0.55934745",
"0.5577292",
"0.5570897",
"0.5563788",
"0.54974383",
"0.54484826",
"0.54439104",
"0.54293483",
"0.5423903",
"0.5307691",
"0.5285355",
"0.52... | 0.71707314 | 1 |
String representation of the workspace | def __repr__(self):
return "<Workspace({0})>".format(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def workspace(self) -> str:\n return self._workspace",
"def workspaceInfo(self):\n pass",
"def name(self):\n return self.attributes.workspace.name",
"def __str__(self):\n\t\treturn \"'SEW object with workdir %s'\" % (self.workdir)",
"def __str__(self):\n string = \"\"\"\n ... | [
"0.73150843",
"0.7238596",
"0.6897872",
"0.6884405",
"0.6769728",
"0.66749203",
"0.6637215",
"0.6621079",
"0.64703304",
"0.6444655",
"0.6442687",
"0.6409415",
"0.64087206",
"0.639957",
"0.636927",
"0.63623023",
"0.6358274",
"0.630217",
"0.6301894",
"0.6288384",
"0.6274253",
... | 0.79356015 | 0 |
Removes preprocessing combinations that should not occur in a single pipeline. | def remove_incompatible_operations(pipelines):
def find_duplicates(pipelines):
for idx in range(len(pipelines)):
for idx_ in range(idx + 1, len(pipelines)):
if pipelines[idx] == pipelines[idx_]:
return idx
return -1
def _remove_illegal_combinati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_preprocessing(self):\n\n # For now, do nothing\n pass",
"def preprocess(self, cfg_pipeline):\n return",
"def _eliminate_common_key_with_none(stages, context, can_pack=lambda s: True):\n # type: (Iterable[Stage], TransformContext, Callable[[str], Union[bool, int]]) -> Iterable[S... | [
"0.61325556",
"0.59824824",
"0.56957024",
"0.56825066",
"0.5645361",
"0.5435082",
"0.5411837",
"0.53826714",
"0.5352468",
"0.5347234",
"0.5347234",
"0.5347234",
"0.53351414",
"0.5322323",
"0.53163415",
"0.53124636",
"0.5310005",
"0.53048676",
"0.53015953",
"0.5284387",
"0.528... | 0.61943585 | 0 |
reads input_filename and output_filename from command line. creates L4 object and returns the output if it always fired and the output based on the distribution given by the sigmoid function. returns the frequency of different neurons fired over a number of runs. create L23 object and returns what fired in a given run ... | def main():
# -------- input ------------------------
# get command line arguments into args array
args = sys.argv[1:]
if not args or len(args) > 2:
print "usage: input_filename output_filename"
sys.exit(1)
input_file = open(args[0], 'r')
output_filename = args[1]
# get parameters separate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(input_filepath, output_filepath):\n logger = logging.getLogger(__name__)\n logger.info('making final data set from raw data')",
"def main(input_filepath, output_filepath):\n logger = logging.getLogger(__name__)\n logger.info('making final data set from raw data')",
"def run(config, workdir... | [
"0.605931",
"0.605931",
"0.57579064",
"0.5723161",
"0.5692624",
"0.56384605",
"0.5591998",
"0.5568752",
"0.55570334",
"0.5528021",
"0.54544705",
"0.5442652",
"0.54408765",
"0.54330486",
"0.5428779",
"0.5377762",
"0.5329455",
"0.532752",
"0.53155154",
"0.5314784",
"0.53111833"... | 0.65101767 | 0 |
Compute the probability of a connection at EVERY LOCATION in the matrix Does not depend on the actual observed values of data | def compute_prob_matrix(tgt_latent, tgt_data, model_name='LogisticDistance'):
ss = tgt_latent['relations']['R1']['ss']
ass = tgt_latent['domains']['d1']['assignment']
hps = tgt_latent['relations']['R1']['hps']
data_conn = tgt_data['relations']['R1']['data']
N = data_conn.shape[0]
pred = np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_probability(prev_props : EdgeProps, curr_props : EdgeProps) -> float:\n d = Delay.__compute_delay(\n arrival_time = prev_props['arr_time'],\n next_departure_time = curr_props['dep_time'], \n ttype = prev_props['ttype'], \n ... | [
"0.5911384",
"0.58029",
"0.57641166",
"0.575981",
"0.5756224",
"0.5751847",
"0.57237226",
"0.572289",
"0.56258786",
"0.5621492",
"0.5568151",
"0.55451894",
"0.5514418",
"0.55129284",
"0.55073756",
"0.5503898",
"0.5477835",
"0.5472042",
"0.5439989",
"0.5433168",
"0.54328525",
... | 0.60475785 | 0 |
assumes m is one of the movements 'Up', 'Down', 'Left', 'Right', returns a Board resulting from the movement m | def childAfterMove(self, m):
indexOfZero = self.tiles.index(0)
initial = self.tiles[:]
child = Board(initial)
if m == 'Up':
assert(indexOfZero > 2)
temp = self.tiles[indexOfZero - 3]
child.tiles[indexOfZero] = temp
child.tiles[indexOfZero -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMove(self, board):\n pass",
"def get_move(moves):\n pass",
"def move(self, direction):\r\n direc = list(OFFSETS[direction])\r\n line = []\r\n dummy_board = self.board[:]\r\n if direction == 3:\r\n for i in range(self.height):\r\n self.... | [
"0.6781174",
"0.66301507",
"0.6560112",
"0.65389156",
"0.6438552",
"0.63536054",
"0.6336471",
"0.6326873",
"0.63040113",
"0.6285235",
"0.6271884",
"0.6262698",
"0.622721",
"0.6174536",
"0.61644375",
"0.61414325",
"0.612391",
"0.6094978",
"0.6090433",
"0.60757256",
"0.60735303... | 0.6940232 | 0 |
Returns true if (r,c) is on board, false otherwise. | def is_on_board(self, r, c):
return 0 <= r <= 7 and 0 <= c <= 7 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on_board(x: int, y: int) -> bool:\n return x >= 0 and x < BOARDWIDTH and y < BOARDHEIGHT",
"def inBoard(self, row, col):\n return 0 <= row < self.rows and 0 <= col < self.cols",
"def on_board(self, pos):\n i, j = pos\n return 0 <= i < COLS and 0 <= j < ROWS",
"def has_win(self,... | [
"0.7762859",
"0.75517225",
"0.75112927",
"0.74653816",
"0.7369882",
"0.73649544",
"0.73205835",
"0.7095848",
"0.70651495",
"0.70537746",
"0.70246136",
"0.7009773",
"0.6989529",
"0.6960644",
"0.6959121",
"0.6956892",
"0.69516766",
"0.6949291",
"0.691275",
"0.6909919",
"0.69020... | 0.90845925 | 0 |
Returns the color value of self_color's opponent. | def get_opponent_color(self, self_color):
return abs(self_color - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_opponent_color(self, mycolor):\n if mycolor == ChessGame.BLACK:\n return ChessGame.WHITE\n elif mycolor == ChessGame.WHITE:\n return ChessGame.BLACK\n else:\n raise NotImplementedError()",
"def player(self):\n return self._color",
"def getTur... | [
"0.75106376",
"0.74137187",
"0.7160636",
"0.7123983",
"0.69804937",
"0.6936204",
"0.6918651",
"0.6908823",
"0.6872566",
"0.6858778",
"0.684322",
"0.684322",
"0.684322",
"0.684322",
"0.6842772",
"0.6800654",
"0.6800654",
"0.6766684",
"0.66826147",
"0.6656713",
"0.6648412",
"... | 0.8906139 | 0 |
Returns the amount of self_color's discs on board. | def get_disk_count(self, self_color, board):
count = 0
for r in range(8):
for c in range(8):
if board[r][c] == self_color:
count += 1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_black_pieces(self):\n return self.num_black_pieces",
"def count_discs(self, player: Player) -> int:\n count = 0\n player_disc = disc.get_disc(player)\n for i in range(self.size):\n for j in range(self.size):\n if self._grid[i][j] == player_disc:\n... | [
"0.66852605",
"0.66430324",
"0.6342966",
"0.6210851",
"0.6190696",
"0.6121007",
"0.610449",
"0.5924346",
"0.59230477",
"0.59166294",
"0.58878237",
"0.58751136",
"0.58189535",
"0.5802374",
"0.5773629",
"0.575617",
"0.57365835",
"0.5736171",
"0.5729498",
"0.5720513",
"0.5717215... | 0.76983726 | 0 |
Check whether self_color has any valid moves in direction (delta) of (coords). | def check_moves(self, board, self_color, coords, delta):
found_opponent = False
for i in range(1, 8):
dr = coords[0] + i * delta[0]
dc = coords[1] + i * delta[1]
if self.is_on_board(dr, dc):
if board[dr][dc] == self_color:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_move(self, move_from, move_to, board):\n\n from_coordinates = JanggiGame.translate_to_grid(move_from)\n to_coordinates = JanggiGame.translate_to_grid(move_to)\n from_col = from_coordinates[0]\n from_row = from_coordinates[1]\n to_col = to_coordinates[0]\n to_r... | [
"0.6963955",
"0.6874568",
"0.6862489",
"0.6853493",
"0.673482",
"0.6734331",
"0.6709162",
"0.6708506",
"0.6673571",
"0.6617804",
"0.66103816",
"0.66061807",
"0.65898937",
"0.6579249",
"0.6572609",
"0.65449744",
"0.6529392",
"0.65056103",
"0.6483118",
"0.64825475",
"0.6477906"... | 0.7871493 | 0 |
Returns all moves self_color could make on the given board. | def find_possible_moves(self, board, self_color):
possible_moves = []
delta = [(0,-1), (-1,-1), (-1,0), (-1,1), (0,1), (1,1), (1,0), (1,-1)]
for r in range(len(board)):
for c in range(len(board[r])):
if board[r][c] == self_color:
for i in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_possible_moves(self):\r\n moves = []\r\n for i in range(8):\r\n for j in range(8):\r\n color = self.board[i][j][0]\r\n if (color == 'b' and not self.turn_white) or (color == 'w' and self.turn_white):\r\n p_type = self.board[i][j]... | [
"0.7883645",
"0.767973",
"0.75464517",
"0.7480288",
"0.74703455",
"0.7433279",
"0.73575103",
"0.7273743",
"0.72572374",
"0.7243118",
"0.723341",
"0.71530664",
"0.7130875",
"0.71287894",
"0.7128543",
"0.7122341",
"0.7116005",
"0.7108686",
"0.70947456",
"0.7019704",
"0.7010493"... | 0.84355676 | 0 |
Find discs that need to be flipped to update the board. | def find_flippable_disks(self, board, self_color, coords, delta):
found_opponent = False
flip_positions = []
for i in range(1, 8):
dr = coords[0] + i * delta[0]
dc = coords[0] + i * delta[1]
if self.is_on_board(dr, dc):
if board[dr][dc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flipper(pos, coul, state_board):\n\ttflips = []\n\tfor i in range(-1,2): # -1 to 1\n\t\tfor j in range(-1,2): #-1 to 1\n\t\t\tfor k in range(1,9): # 1 to 8\n\t\t\t\tif state_board[pos[0]+i*k][pos[1]+j*k] == 0 or state_board[pos[0]+i*k][pos[1]+j*k] == -1: # if the case is empty or out of bounds\n\t\t\t\t\tbreak... | [
"0.6389612",
"0.6263736",
"0.61926514",
"0.56448823",
"0.5501057",
"0.549984",
"0.54695046",
"0.54583836",
"0.5436001",
"0.5432135",
"0.53606504",
"0.53226405",
"0.5284864",
"0.5280242",
"0.5267073",
"0.525425",
"0.5233514",
"0.5232512",
"0.52298003",
"0.5218444",
"0.51716125... | 0.6420867 | 0 |
Returns a rough approximation of the amount of stable disks self_color has in a particular corner. | def get_stable_disks(self, board, self_color, corner_coords):
step_row = 1 if corner_coords[0] == 0 else -1
step_col = 1 if corner_coords[1] == 0 else -1
bound_row = abs(corner_coords[0] - 7)
bound_col = abs(corner_coords[1] - 7)
cur_row = corner_coords[0]
cur_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_disk_count(self, self_color, board):\r\n count = 0\r\n for r in range(8):\r\n for c in range(8):\r\n if board[r][c] == self_color:\r\n count += 1\r\n return count",
"def split_necessity(self):\n return max(self._color_var_rel) * sel... | [
"0.68481916",
"0.5906089",
"0.5816553",
"0.5672052",
"0.5643364",
"0.5552818",
"0.55456066",
"0.55377346",
"0.55131733",
"0.5477361",
"0.5455857",
"0.54394853",
"0.5436614",
"0.54305196",
"0.5416301",
"0.53964823",
"0.5382843",
"0.5376668",
"0.5370833",
"0.5350355",
"0.530487... | 0.72993684 | 0 |
Prints the information about control keys to the command line. | def print_controls(self):
print("TAKEOFF: {}".format(self._control_keys(COMMAND_TAKEOFF)))
print("LAND: {}".format(self._control_keys(COMMAND_LAND)))
print("EMERGENCY: {}".format(self._control_keys(COMMAND_EMERGENCY)))
print("HOVER: {}".format(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_controls(self):\n\n print('\\nControls: ')\n print(' ENTER - begin playback of MPO pattern')\n print(' p - go to previous sample')\n print(' n - go to next sample')\n print(' SPACE - Mark index of desired sub-trajectory')\n print(' q - quit pro... | [
"0.6690821",
"0.6412796",
"0.63261616",
"0.6192623",
"0.60906035",
"0.6070361",
"0.603995",
"0.5988708",
"0.595326",
"0.59040827",
"0.584231",
"0.5718754",
"0.56762505",
"0.56488466",
"0.56488466",
"0.56488466",
"0.56488466",
"0.5638558",
"0.5638558",
"0.5638558",
"0.5638558"... | 0.6862665 | 0 |
Returns a list of control keys for the given command. | def _control_keys(self, command):
return [key for key, comm in self.KEY_TO_COMMAND.items() if comm == command] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_commands(self, ctx):\n commands = self._iter_commands()\n return commands.keys()",
"def get_control_ids(self) -> List[str]:\n return self._control_dict.keys()",
"def list_commands(self, context):\n\t\treturn self.commands.keys()",
"def cli(ctx):\n return ctx.gi.cannedkeys.get_keys()"... | [
"0.6953709",
"0.6734895",
"0.6625436",
"0.6571796",
"0.6570962",
"0.6561314",
"0.65246344",
"0.65141964",
"0.6504601",
"0.6437386",
"0.6390944",
"0.62402505",
"0.6233641",
"0.6228321",
"0.6145984",
"0.61125696",
"0.6094259",
"0.6051538",
"0.5979562",
"0.5978968",
"0.5935132",... | 0.89397156 | 0 |
Reads raw corpus from `RAW_CORPUS_PATH`. | def get_raw_corpus():
with open(RAW_CORPUS_PATH, 'r') as f:
return f.read().splitlines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_raw_text(self, raw_path: str = None):\n\n if raw_path.rsplit(\".\")[-1] == \"json\":\n self.import_from_json(raw_path)\n return\n\n if raw_path is not None:\n self.raw_path = raw_path\n\n if self.raw_path is None:\n raise Exception(\"Found n... | [
"0.6848885",
"0.6403135",
"0.63154155",
"0.610387",
"0.608671",
"0.5862478",
"0.5852928",
"0.562985",
"0.56262004",
"0.5601899",
"0.5561709",
"0.5552782",
"0.55422187",
"0.5523861",
"0.5523692",
"0.5389133",
"0.53259766",
"0.53013366",
"0.52998686",
"0.5299813",
"0.5295166",
... | 0.8086149 | 0 |
Reads raw datetimes from `RAW_DATETIMES_PATH`. | def get_raw_datetimes():
raw_datetimes = []
with open(RAW_DATETIMES_PATH, 'r') as f:
for x in f.read().splitlines():
try:
raw_datetimes.append(datetime.datetime(year=int(x[1:5]), month=int(x[6:8]), day=int(x[9:11])))
except ValueError:
raw_datetime... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_times(self, slices=None):\n times = netCDF4.num2date(\n datetime.strptime(\n self.get_handler().SOURCE_START_DATE.split('.')[0],\n '%Y%m%d%H%M%S'\n )\n )\n return numpy.ma.array([times])",
"def get_raw_data():\n... | [
"0.6244591",
"0.61131406",
"0.60976774",
"0.58365625",
"0.58308834",
"0.5646238",
"0.5640784",
"0.56179684",
"0.54649955",
"0.5452194",
"0.53788567",
"0.5321501",
"0.52975816",
"0.5276463",
"0.52416366",
"0.52309686",
"0.5192991",
"0.5172008",
"0.5170778",
"0.51664054",
"0.51... | 0.774482 | 0 |
Transforms `raw_corpus` and `raw_dates` into a list of lists where each inner list is a timestamped article. | def get_raw_data():
raw_corpus = get_raw_corpus()
raw_datetimes = get_raw_datetimes()
raw_data = []
for i, raw_datetime in enumerate(raw_datetimes):
raw_data.append([raw_datetime, raw_corpus[i]])
return raw_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solr_transformed_dates(solr_client: Solr, parsed_dates: typing.List):\n return [solr_client._from_python(date) for date in parsed_dates] # pylint: disable=protected-access",
"def to_twodim_list(self):\n if self._timestampFormat is None:\n return self._timeseriesData\n\n datalist =... | [
"0.683058",
"0.6323778",
"0.6128271",
"0.60786724",
"0.60340846",
"0.602659",
"0.59372884",
"0.5706374",
"0.5697947",
"0.5654273",
"0.56450975",
"0.5622019",
"0.56163025",
"0.55910176",
"0.55910176",
"0.5584497",
"0.55833334",
"0.5565312",
"0.55243546",
"0.55132765",
"0.55013... | 0.72453225 | 0 |
Converts `article_sents` into a single string. | def get_article_str(article_sents):
article_str = ""
for nlp_sent in article_sents:
article_str += (' ' + nlp_sent.text + ' ')
return article_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_article_as_string(article,\n preprocess_type=PreprocessWordType.LEMMATIZE):\n article_string = ''\n for word in article.words:\n preprocessed_word = query_utils.preprocess_word(word, preprocess_type)\n if article_string == '':\n article_string = prepr... | [
"0.67486",
"0.612108",
"0.5690145",
"0.56773126",
"0.5410131",
"0.5308889",
"0.520001",
"0.51668775",
"0.5153415",
"0.5148386",
"0.5125402",
"0.50992966",
"0.5094515",
"0.5066397",
"0.50654906",
"0.50575686",
"0.5049806",
"0.5031486",
"0.5018384",
"0.49969393",
"0.49943385",
... | 0.8428992 | 0 |
Show detail of topology, device and more. Show [topology, device] | def do_show(self, args):
args = args.split(" ")
if args[0] == '':
print("Incorrect command.")
return
elif args[0] == 'device':
if len(args) < 2:
if len(self.topology.devices) == 0:
print("No device in this topology.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_device_information_long(self):\n\n for device in self._devices:\n print(\"\")\n if device['Device Type'].startswith(\"enclosu\"):\n if device.get('Device Type'):\n print(\"{0:>32}: {1}\".format(\"Device Type\", device['Device Type']))\n ... | [
"0.7024573",
"0.6975774",
"0.6967318",
"0.6879825",
"0.6828446",
"0.656477",
"0.6419597",
"0.63903284",
"0.63215077",
"0.6316704",
"0.631509",
"0.6278415",
"0.62708306",
"0.62081003",
"0.6189719",
"0.61110306",
"0.6107462",
"0.60931426",
"0.6081408",
"0.60599726",
"0.6034592"... | 0.75043815 | 0 |
Enter to device mode | def do_device(self, args):
self.device_command.cmdloop("Enter to device mode") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _turn_on_dev_mode(self):\n if self._device is not None:\n self._char_write(self._BLE_SERVICE_ANTI_DOS,\n [ord(c) for c in self._ANTI_DOS_MESSAGE])\n self._char_write(self._BLE_SERVICE_TX_POWER,\n [self._TX_POWER_VALUE])\n ... | [
"0.6871464",
"0.6374481",
"0.6312063",
"0.6263293",
"0.62074643",
"0.6196528",
"0.61516935",
"0.60767496",
"0.6055326",
"0.6039394",
"0.6032635",
"0.60067725",
"0.59976095",
"0.599694",
"0.58823013",
"0.5876625",
"0.5849049",
"0.58332497",
"0.5821363",
"0.57796013",
"0.577763... | 0.81906086 | 0 |
Enter to config mode | def do_config(self, args):
self.config_command.cmdloop("Enter to config mode") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GoToConfig(self):\n self.write_ack(MID.GoToConfig)",
"def state_choose_enter(cfg, app, win):",
"def state_chosen_enter(cfg, app, win):",
"def state_print_enter(cfg, app, win):",
"def state_processing_enter(cfg, app, win):",
"def config_mode(self, config_command=\"config\", pattern=\">config\")... | [
"0.72448474",
"0.7243817",
"0.7200898",
"0.6668514",
"0.6579885",
"0.6569821",
"0.6567963",
"0.6484108",
"0.64485",
"0.64465827",
"0.6421999",
"0.6413546",
"0.6402942",
"0.63392574",
"0.6282004",
"0.62720376",
"0.62643874",
"0.62643874",
"0.6227191",
"0.6213349",
"0.6186388",... | 0.81245357 | 0 |
Builds the enemy board. Arguments boardDimensions dimensions of the (square) enemy board. shipsAfloat the size and counts of the initial enemy fleet. | def __init__(self, boardDimensions, shipsAfloat):
self.enemyBoard = [[BoardState.OPEN for j in range(boardDimensions)] for i in range(boardDimensions)]
self.boardDimensions = boardDimensions
self.shipsAfloat = shipsAfloat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_board(y_size, x_size, game_board):\n\n for y_coordinate in range(1, y_size + 1):\n for x_coordinate in range(1, x_size + 1):\n game_board[(x_coordinate, y_coordinate)] = {0: {}, 1: {}, 2: {}}",
"def __init__(self, board_size=MAX_BOARD_SIZE, cell_size=MAX_CELL_SIZE, dead_color=DEAD... | [
"0.5798147",
"0.5782923",
"0.56396955",
"0.5630348",
"0.5585761",
"0.55785453",
"0.5550585",
"0.5549059",
"0.55364156",
"0.5524999",
"0.5519438",
"0.5479709",
"0.5463151",
"0.54622513",
"0.54564345",
"0.5421945",
"0.5414699",
"0.5409982",
"0.5408475",
"0.5398837",
"0.5394371"... | 0.7309646 | 0 |
For debugging purposes, prints the remaining ships afloat. | def printShipsAfloat(self):
logging.debug("ships afloat")
sb = []
for size in self.shipsAfloat:
number = self.shipsAfloat[size]
sb.append(str(size))
sb.append(":")
sb.append(str(number))
sb.append(" ")
logging.debug("".... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printShipsToSink(self):\r\n sb = []\r\n for sinkingShip in self.shipsToSink:\r\n shot = self.mapToShot(sinkingShip.bullseye)\r\n sb.append(str(shot))\r\n sb.append(\":\")\r\n sb.append(str(sinkingShip.size))\r\n sb.append(\" \")\r\n lo... | [
"0.6759293",
"0.61066717",
"0.6097267",
"0.60054314",
"0.59553313",
"0.58824235",
"0.5686818",
"0.5643296",
"0.56205136",
"0.56184435",
"0.5578437",
"0.5568185",
"0.5563322",
"0.55528456",
"0.5536101",
"0.5521141",
"0.55188745",
"0.5515266",
"0.5513358",
"0.54816514",
"0.5480... | 0.7785846 | 0 |
Updates internal state given the results of a shot. Arguments shot Shot of the form LetterNumber. hit True, if the shot was a hit. sunk Size of the sunk ship, if the shot sunk it. | def shotResult(self, shot, hit, sunk):
logging.debug("shot result: %s, hit: %d, sunk: %d" % (shot, hit, sunk))
coordinates = self.mapToCoordinates(shot)
# If a ship was sunk, remove it from the fleet.
if sunk:
sunk = str(sunk)
assert(self.shipsAfloat[sunk] >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ship_hit(si_settings,screen,stats,sb,ship,aliens,bullets):\n if stats.ships_left > 0:\n # Decrement ships_left.\n stats.ships_left -= 1\n #update Scoreboard\n sb.prep_ships()\n else:\n stats.game_active = False\n pygame.mouse.set_visible(True)\n #empties alien... | [
"0.61077094",
"0.6027895",
"0.59807974",
"0.5970617",
"0.5844651",
"0.58269143",
"0.57184863",
"0.56714153",
"0.5588444",
"0.5556509",
"0.5482947",
"0.54752976",
"0.5434543",
"0.53959507",
"0.5395703",
"0.53421646",
"0.53262115",
"0.5318554",
"0.531314",
"0.5285579",
"0.52829... | 0.682624 | 0 |
Maps a shot to x and y coordinates. | def mapToCoordinates(self, shot):
toks = shot.split("-")
return Coordinates(ord(toks[0]) - ord("A"), int(toks[1]) - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapToShot(self, coordinates):\r\n return chr(coordinates.x + ord(\"A\")) + \"-\" + str(coordinates.y + 1)",
"def map_loc_to_pixel((x, y), xc = 17.25, yc = 630, run = 17.25):\n xp, yp = xc + x*run, yc - y*run\n return (xp, yp)",
"def coord(self, x, y):\n origin_x = self._raster_meta['tra... | [
"0.7004169",
"0.6585423",
"0.6171817",
"0.6050263",
"0.6022578",
"0.59397626",
"0.59272003",
"0.59251267",
"0.5873501",
"0.58347553",
"0.5832571",
"0.58019704",
"0.57846975",
"0.5765359",
"0.5759559",
"0.57559067",
"0.5753961",
"0.57537895",
"0.5746078",
"0.57412815",
"0.5740... | 0.76549584 | 0 |
Maps x and y coordinates to a shot. | def mapToShot(self, coordinates):
return chr(coordinates.x + ord("A")) + "-" + str(coordinates.y + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapToCoordinates(self, shot):\r\n toks = shot.split(\"-\")\r\n return Coordinates(ord(toks[0]) - ord(\"A\"), int(toks[1]) - 1)",
"def ship_shoot(ship, x, y):\n click.echo('Ship %s fires to %s,%s' % (ship, x, y))",
"def map_loc_to_pixel((x, y), xc = 17.25, yc = 630, run = 17.25):\n xp, y... | [
"0.68749666",
"0.6218412",
"0.6204216",
"0.6002892",
"0.59659797",
"0.59609425",
"0.593582",
"0.59223795",
"0.5911508",
"0.5891407",
"0.58793396",
"0.57502717",
"0.5737297",
"0.5729335",
"0.57282853",
"0.57242876",
"0.5707542",
"0.57012147",
"0.5698053",
"0.56627136",
"0.5654... | 0.7167854 | 0 |
For debugging purposes, prints the ships that are sinking. | def printShipsToSink(self):
sb = []
for sinkingShip in self.shipsToSink:
shot = self.mapToShot(sinkingShip.bullseye)
sb.append(str(shot))
sb.append(":")
sb.append(str(sinkingShip.size))
sb.append(" ")
logging.debug("".join(sb)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sinkShips(self):\r\n while True:\r\n stillSinkingShips = False\r\n for i in range(len(self.shipsToSink) - 1, -1, -1):\r\n sunkShip, shipCoordinates = self.positionAndSinkShip(self.shipsToSink[i])\r\n if sunkShip:\r\n stillSinkingShip... | [
"0.6868434",
"0.60091615",
"0.5819216",
"0.57831025",
"0.57612616",
"0.5760116",
"0.5730516",
"0.5694207",
"0.5685576",
"0.5679152",
"0.56756943",
"0.5630776",
"0.5624161",
"0.56204444",
"0.5612648",
"0.56079024",
"0.5590641",
"0.5578884",
"0.5547372",
"0.55457723",
"0.553477... | 0.8498444 | 0 |
Weights the board by placing all remaining ships in all possible positions. The more ways a ship can be placed over a particular set of coordinates, the higher the weight. Positions that overlay previous hits are given extra weight. | def weightBoard(self):
directions = (Direction.East, Direction.South)
for size, count in self.shipsAfloat.items():
size = int(size)
for i in range(self.boardDimensions):
for j in range(self.boardDimensions):
for direction in directions:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postion_fleet(self, ships_positions, board):\n for cell in ships_positions:\n row = ord(cell[:1]) - ord('A')\n col = int(cell[1:]) - 1\n for i in range(row, row + self.total_rows_req):\n for j in range(col, col + self.total_column_req):\n ... | [
"0.7102829",
"0.7067783",
"0.65166754",
"0.65071094",
"0.64424324",
"0.6266532",
"0.6066007",
"0.5912358",
"0.572561",
"0.57133865",
"0.571108",
"0.56970054",
"0.5682629",
"0.5675079",
"0.56600696",
"0.56578845",
"0.5643913",
"0.56228065",
"0.5608582",
"0.5605877",
"0.5590811... | 0.8022364 | 0 |
Recursive function that positions a ship in a particular direction and applies the weights. Arguments coordinates The coordinate to check. size The size of the ship. weight The weight to apply if this coordinate can hold a ship. direction The direction to move as the ship is being placed. hitWeight The extra amount of ... | def weightShipSearch(self, coordinates, size, weight, direction, hitWeight):
if size == 0:
# Successfully searched the required size.
return True, hitWeight
if coordinates.x < 0 or coordinates.y < 0 or coordinates.x == self.boardDimensions or coordinates.y == self.boa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sinkShipSearch(self, coordinates, size, direction):\r\n if size == 0:\r\n # Successfully searched the required size.\r\n return True, []\r\n if coordinates.x < 0 or coordinates.y < 0 or coordinates.x == self.boardDimensions or coordinates.y == self.boardDimensions:\r\n ... | [
"0.5731691",
"0.5203796",
"0.48089176",
"0.47622883",
"0.47248405",
"0.46185344",
"0.44617125",
"0.43873248",
"0.4386601",
"0.4383292",
"0.4365558",
"0.43292725",
"0.43162784",
"0.43162185",
"0.4308138",
"0.43051094",
"0.4280897",
"0.4277226",
"0.42721885",
"0.42691907",
"0.4... | 0.7550492 | 0 |
Puts all of the weighted coordinates in a priority queue and selects the coordinate with the most weight. Return bestCoordinates The highest weighted coordinates. | def selectBestCoordinates(self):
coordinatesQueue = []
# It's highly likely that there are going to be a lot of coordinates with the same "most" weight. Rather
# than always choosing the leftmost coordinates, make a random choice by adding a random tie breaker to the
# priority.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_fitness(self):\n f = max(self.characters, key=operator.attrgetter('fitness'))\n self.best_fitness = round(f.fitness, 3)\n self.best_candidate = f",
"def get_best(self):\n scores, ids = self.sort_best()\n return scores[1], ids[1]",
"def best_bat(self):\n\n ... | [
"0.6071521",
"0.6039935",
"0.58864534",
"0.58477885",
"0.5797013",
"0.5676042",
"0.5628477",
"0.55944246",
"0.5588288",
"0.55880636",
"0.55558515",
"0.5525676",
"0.5525676",
"0.5525676",
"0.54964423",
"0.5489497",
"0.5471704",
"0.5466427",
"0.54595804",
"0.54568857",
"0.54528... | 0.7931314 | 0 |
Attempts to sink as many sinking ships as possible given the shot result. Arguments shot Shot of the form LetterNumber. hit True, if the shot was a hit. sunk Size of the sunk ship, if the shot sunk it. | def shotResult(self, shot, hit, sunk):
ShotSelector.shotResult(self, shot, hit, sunk)
coordinates = self.mapToCoordinates(shot)
if sunk:
self.shipsToSink.append(SinkingShip(coordinates, sunk))
self.sinkShips()
self.printShipsAfloat()
self.printShips... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shotResult(self, shot, hit, sunk):\r\n logging.debug(\"shot result: %s, hit: %d, sunk: %d\" % (shot, hit, sunk))\r\n coordinates = self.mapToCoordinates(shot)\r\n # If a ship was sunk, remove it from the fleet.\r\n if sunk:\r\n sunk = str(sunk)\r\n assert(self.... | [
"0.6546094",
"0.6270627",
"0.6220413",
"0.5889326",
"0.5881789",
"0.5799883",
"0.57032895",
"0.5695585",
"0.5620391",
"0.5610055",
"0.5579357",
"0.5547138",
"0.5538802",
"0.5500968",
"0.54043406",
"0.53991574",
"0.5375928",
"0.53510904",
"0.5305802",
"0.5302349",
"0.52896166"... | 0.69968224 | 0 |
Attempts to sink all sinking ships by positioning them in all possible positions . If there's not enough information to sink them, the board remains asis. For every ship that's sunk marks all of its coordinates as SUNK to prevent them from being used in subsequent shot selections. | def sinkShips(self):
while True:
stillSinkingShips = False
for i in range(len(self.shipsToSink) - 1, -1, -1):
sunkShip, shipCoordinates = self.positionAndSinkShip(self.shipsToSink[i])
if sunkShip:
stillSinkingShips = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positionAndSinkShip(self, sinkingShip):\r\n directions = [Direction.North, Direction.South, Direction.East, Direction.West]\r\n sunkShip = False\r\n shipCoordinates = None\r\n for direction in directions:\r\n tSunkShip, tShipCoordinates = self.sinkShip(sinkingShip.bullsEy... | [
"0.70138216",
"0.6665017",
"0.6649957",
"0.6581857",
"0.6460488",
"0.6365548",
"0.61918086",
"0.61489993",
"0.6130212",
"0.61247045",
"0.6064208",
"0.5848623",
"0.5781333",
"0.577842",
"0.5750796",
"0.57419527",
"0.572682",
"0.5720159",
"0.5629075",
"0.5614789",
"0.56005985",... | 0.83000946 | 0 |
Positions a sinking ship in all possible positions and tries to sink it. Arguments sinkingShip The ship to position. Returns sunkShip True if the ship was sunk, False if not. shipCoorindates Only valid if the ship was sunk, the coordinates of the sunk ship. | def positionAndSinkShip(self, sinkingShip):
directions = [Direction.North, Direction.South, Direction.East, Direction.West]
sunkShip = False
shipCoordinates = None
for direction in directions:
tSunkShip, tShipCoordinates = self.sinkShip(sinkingShip.bullsEye, sinkingShip.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sinkShips(self):\r\n while True:\r\n stillSinkingShips = False\r\n for i in range(len(self.shipsToSink) - 1, -1, -1):\r\n sunkShip, shipCoordinates = self.positionAndSinkShip(self.shipsToSink[i])\r\n if sunkShip:\r\n stillSinkingShip... | [
"0.6950931",
"0.60631305",
"0.58785766",
"0.5825624",
"0.56573665",
"0.5617272",
"0.55613524",
"0.5537164",
"0.5525837",
"0.549535",
"0.5424462",
"0.53371406",
"0.5328491",
"0.53082603",
"0.53073376",
"0.53026956",
"0.52963483",
"0.5286528",
"0.52810824",
"0.5252677",
"0.5246... | 0.7811943 | 0 |
Skips over the BULLSEYE before placing the sinking ship as the BULLSEYE will cause early search termination. Arguments bullsEye The coordinates of the shot that caused the ship to start sinking. size The size of the ship. direction The direction to move as the ship is being placed. Returns sunkShip True if the ship was... | def sinkShip(self, bullsEye, size, direction):
sunkShip, shipCoordinates = self.sinkShipSearch(Coordinates(bullsEye.x + direction.x, bullsEye.y + direction.y), size - 1, direction)
if sunkShip:
shipCoordinates.append(bullsEye)
return sunkShip, shipCoordinates | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sinkShipSearch(self, coordinates, size, direction):\r\n if size == 0:\r\n # Successfully searched the required size.\r\n return True, []\r\n if coordinates.x < 0 or coordinates.y < 0 or coordinates.x == self.boardDimensions or coordinates.y == self.boardDimensions:\r\n ... | [
"0.58415544",
"0.52179354",
"0.51744556",
"0.49338993",
"0.4874807",
"0.48674476",
"0.4732885",
"0.46843466",
"0.45478213",
"0.45308974",
"0.45002207",
"0.4419198",
"0.44042423",
"0.4400801",
"0.43920544",
"0.43743762",
"0.43740964",
"0.4360961",
"0.4356543",
"0.4354255",
"0.... | 0.7173418 | 0 |
Recursive function that positions a sinking ship in a particular direction to see if can be sunk. Arguments bullsEye The coordinates of the shot that caused the ship to start sinking. size The size of the ship. direction The direction to move as the ship is being placed. Returns sunkShip True if the ship was sunk, Fals... | def sinkShipSearch(self, coordinates, size, direction):
if size == 0:
# Successfully searched the required size.
return True, []
if coordinates.x < 0 or coordinates.y < 0 or coordinates.x == self.boardDimensions or coordinates.y == self.boardDimensions:
# Can't g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sinkShip(self, bullsEye, size, direction):\r\n sunkShip, shipCoordinates = self.sinkShipSearch(Coordinates(bullsEye.x + direction.x, bullsEye.y + direction.y), size - 1, direction)\r\n if sunkShip:\r\n shipCoordinates.append(bullsEye)\r\n return sunkShip, shipCoordinates",
"de... | [
"0.6850111",
"0.54134226",
"0.5392717",
"0.5219759",
"0.5036896",
"0.50010026",
"0.4920517",
"0.4919272",
"0.47853866",
"0.47571567",
"0.46850467",
"0.46844095",
"0.46821985",
"0.4675576",
"0.4668884",
"0.4647125",
"0.46391284",
"0.46350923",
"0.45468506",
"0.45452628",
"0.45... | 0.5980011 | 1 |
Purpose NOTE THAT THIS FUNCTION IS INTENDED TO BE USED FOR THE `apply()` METHOD OF A PANDAS DATAFRAME WITH THE AXIS PARAMETER SET TO `"columns"` or `1`. The purpose of this function is to take the information about an event and return as a int the starting point of the event. Something that is important to note is that... | def event_starting_point_extractor(row) -> int:
to_return = None
# First, define the variables that we will need for the rest of this
# function.
positions_list = literal_eval(row["positions"])
assert isinstance(positions_list, list)
assert 1 <= len(positions_list) <= 2
# Next, extract the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_ending_point_extractor(row) -> int:\n to_return = None\n # First, define the variables that we will need for the rest of this\n # function.\n positions_list = literal_eval(row[\"positions\"])\n assert isinstance(positions_list, list)\n assert 1 <= len(positions_list) <= 2\n\n # Next,... | [
"0.6105091",
"0.5720752",
"0.5614691",
"0.5605947",
"0.55807626",
"0.5570309",
"0.5512276",
"0.5461457",
"0.5446376",
"0.53841436",
"0.5370126",
"0.5357768",
"0.53466797",
"0.52359855",
"0.52021855",
"0.51934916",
"0.5181264",
"0.5181264",
"0.5181264",
"0.50866765",
"0.508135... | 0.69432586 | 0 |
Purpose NOTE THAT THIS FUNCTION IS INTENDED TO BE USED FOR THE `apply()` METHOD OF A PANDAS DATAFRAME WITH THE AXIS PARAMETER SET TO `"columns"` or `1`. The purpose of this function is to take the information about an event and return as a int the ending point of the event. Something that is important to note is that t... | def event_ending_point_extractor(row) -> int:
to_return = None
# First, define the variables that we will need for the rest of this
# function.
positions_list = literal_eval(row["positions"])
assert isinstance(positions_list, list)
assert 1 <= len(positions_list) <= 2
# Next, extract the st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_starting_point_extractor(row) -> int:\n to_return = None\n # First, define the variables that we will need for the rest of this\n # function.\n positions_list = literal_eval(row[\"positions\"])\n assert isinstance(positions_list, list)\n assert 1 <= len(positions_list) <= 2\n\n # Nex... | [
"0.61686385",
"0.5415751",
"0.5356658",
"0.52927125",
"0.51529205",
"0.51526916",
"0.5141919",
"0.5124614",
"0.5096792",
"0.5095719",
"0.50302047",
"0.50110096",
"0.500243",
"0.49752328",
"0.4970546",
"0.49601305",
"0.49375775",
"0.49232593",
"0.48982283",
"0.48747092",
"0.48... | 0.68056196 | 0 |
Purpose The purpose of this function is to take a DataFrame that contains all of the events of set piece sequences that belong to a particular cluster of interest and create a new DataFrame that for each event explicitly lists its starting point and ending point on the soccer pitch. | def cluster_positions_extractor(
cluster_events_df: pd.DataFrame) -> pd.DataFrame:
to_return = None
# First, validate the input data
ipv.parameter_type_validator(expected_type=pd.DataFrame,
parameter_var=cluster_events_df)
normed = cluster_events_df.reset_index(d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_sample_dataframe():\n ax_readings = []\n ay_readings = []\n az_readings = []\n mx_readings = []\n my_readings = []\n mz_readings = []\n gx_readings = []\n gy_readings = []\n gz_readings = []\n activity_list = [LABELS_NAMES[0] for _ in range(SEGMENT_TIME_SIZE)]\n\n\n for ... | [
"0.57482284",
"0.56927854",
"0.5451736",
"0.54411083",
"0.539259",
"0.53024316",
"0.5288239",
"0.5273695",
"0.5271883",
"0.52564204",
"0.5252375",
"0.5251818",
"0.52454084",
"0.5172984",
"0.5157079",
"0.51437426",
"0.50912386",
"0.50897837",
"0.5063519",
"0.50620985",
"0.5054... | 0.6459534 | 0 |
Purpose The purpose of this function is to take the positions (whether its the starting or ending as specified by the user) of the events that comprise the sequences that belong to the cluster of interest and conduct a 2dimensional binning so as to determine the spatial distribution of events in said cluster. | def cluster_positions_binning(
cluster_positions_df: pd.DataFrame, beginning_points=True) -> tuple:
to_return = None
# First, validate the input data
ipv.parameter_type_validator(expected_type=pd.DataFrame,
parameter_var=cluster_positions_df)
# Next, define the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, n_bins, segment, elements):\n\n # n_bins\n assert type(n_bins) is int\n assert n_bins > 0\n\n # segment\n assert type(segment) is list or type(segment) is tuple\n assert len(segment) == 2\n assert np.isscalar(segment[0]) and np.isscalar(segment[1]... | [
"0.56852734",
"0.5581037",
"0.55431163",
"0.54475576",
"0.5437623",
"0.54101694",
"0.5406706",
"0.53986126",
"0.5320614",
"0.53138363",
"0.5239041",
"0.5185479",
"0.51828754",
"0.51673204",
"0.51503664",
"0.51502055",
"0.5123758",
"0.5118751",
"0.51078063",
"0.5100034",
"0.50... | 0.5842902 | 0 |
Raise an exception for invalid tunnel range or malformed range. | def _parse_nexus_vni_range(self, tunnel_range):
for ident in tunnel_range:
if not self._is_valid_nexus_vni(ident):
raise exc.NetworkTunnelRangeError(
tunnel_range=tunnel_range,
error=_("%(id)s is not a valid Nexus VNI value.") %
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_one_range(r):\n if not _is_single_range(r):\n raise error.RangeSyntaxError(str(r))",
"def _check_range(r): \n if _is_single_range(r):\n _check_one_range(r)\n elif isinstance(r, collections.Sequence):\n for r2 in r:\n _check_one_range(r2)\n else:\n rai... | [
"0.6624532",
"0.6413814",
"0.6199758",
"0.61368984",
"0.6097965",
"0.607641",
"0.60197747",
"0.59626144",
"0.5958465",
"0.59397733",
"0.5909572",
"0.5895414",
"0.5871884",
"0.58117115",
"0.5792768",
"0.57913935",
"0.57842344",
"0.57842344",
"0.5781298",
"0.577995",
"0.576521"... | 0.68945503 | 0 |
Synchronize vxlan_allocations table with configured tunnel ranges. | def sync_allocations(self):
# determine current configured allocatable vnis
vxlan_vnis = set()
for tun_min, tun_max in self.tunnel_ranges:
vxlan_vnis |= set(six.moves.range(tun_min, tun_max + 1))
session = db_api.get_session()
with session.begin(subtransactions=True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_ranges(self,):\n self.ranges = list()\n # coredump: info target shows all sections in full detail\n # live debug: only file-backed sections are shown\n targetinfo = gdb.execute(\"info target\", False, True)\n for line in targetinfo.splitlines():\n line = line.strip()\n if line... | [
"0.524511",
"0.5159683",
"0.5064488",
"0.5003374",
"0.4980253",
"0.4976541",
"0.49230257",
"0.49073362",
"0.4881262",
"0.486306",
"0.48597613",
"0.48488852",
"0.48237342",
"0.47735462",
"0.47349444",
"0.4712839",
"0.47052684",
"0.46999648",
"0.4630769",
"0.46169844",
"0.46065... | 0.8001009 | 0 |
Initializing the form. We have to break down the skills list that was sent so that we can indicate what the valid choices are. | def __init__(self, *args, **kwargs):
# do pop first, so the parent doesn't get unexpected arguments.
skills = kwargs.pop('skills')
super(CharacterSkillForm, self).__init__(*args, **kwargs)
self.fields['skills'].choices = \
[(s.id, s.skill.name)
for header in s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_initial(self):\n initial = super(SkillsView, self).get_initial()\n ai = get_ai(\n self.request.session.get('token', False),\n self.kwargs['aiid']\n )\n initial = {\n 'skills': ai['linked_bots']\n }\n return initial",
"def __init__... | [
"0.6526162",
"0.63097054",
"0.58881307",
"0.58718127",
"0.584773",
"0.57678336",
"0.57535213",
"0.5733922",
"0.5721101",
"0.5705405",
"0.5692461",
"0.56911916",
"0.5627025",
"0.559385",
"0.5533806",
"0.55180943",
"0.55096644",
"0.5508936",
"0.5490525",
"0.54798377",
"0.544471... | 0.76746976 | 0 |
The size of the world communicator. | def world_size(self):
return self._wsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def world_size() -> int:\n return dist.get_world_size() if dist.is_initialized() else 1",
"def get_world_size() -> int:\n return collective.get_world_size()",
"def size():\n return int(os.environ['WORLD_SIZE'])",
"def get_world_size():\n if not torch.distributed.is_available():\n return 1\... | [
"0.8183484",
"0.8161533",
"0.7968778",
"0.7838551",
"0.7544292",
"0.75160927",
"0.7281078",
"0.72509223",
"0.7210917",
"0.7210917",
"0.7210917",
"0.7210812",
"0.72054684",
"0.7197497",
"0.71910495",
"0.71712273",
"0.7170887",
"0.7160263",
"0.7158934",
"0.71567965",
"0.7153045... | 0.81939703 | 0 |
The rank of this process in the world communicator. | def world_rank(self):
return self._wrank | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rank(self) -> int:\n return dist.get_rank()",
"def rank(self):\n return self._rank",
"def rank(self):\n return self._rank",
"def rank(self):\n return self._rank",
"def rank(self):\n return self._rank",
"def rank(self):\n return self._rank",
"def getRank... | [
"0.78776574",
"0.7876336",
"0.7876336",
"0.7876336",
"0.7876336",
"0.7876336",
"0.78501487",
"0.78450763",
"0.7805618",
"0.7785066",
"0.7780536",
"0.7763916",
"0.77480894",
"0.7724303",
"0.7718263",
"0.771391",
"0.76907665",
"0.7675124",
"0.76343757",
"0.76057",
"0.7599256",
... | 0.801047 | 0 |
The number of process groups. | def ngroups(self):
return self._ngroups | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_node_groups(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"num_node_groups\")",
"def num_node_groups(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"num_node_groups\")",
"def num_node_groups(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self,... | [
"0.81979567",
"0.7825811",
"0.7825811",
"0.7593607",
"0.74162036",
"0.74027264",
"0.73958987",
"0.729504",
"0.7193732",
"0.71907777",
"0.7045195",
"0.7004456",
"0.69894195",
"0.69244087",
"0.68316674",
"0.678754",
"0.67854625",
"0.67679214",
"0.66554826",
"0.6641968",
"0.6623... | 0.83494246 | 0 |
The size of the group containing this process. | def group_size(self):
return self._gsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_size(self):\n return len(self.groups)",
"def group_size_dist(self):\n return self.group_sizes() / self.group_sizes().sum()",
"def getGroupSize(Id):\r\n return \"Number of groups\"",
"def size(self):\n return self.size_number",
"def group_sizes(self):\n return se... | [
"0.7482762",
"0.7292368",
"0.7252224",
"0.7235323",
"0.72331035",
"0.71471894",
"0.7062642",
"0.6934623",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0.68790656",
"0... | 0.8637419 | 0 |
Distribute indivisible blocks of items between groups. Given some contiguous blocks of items which cannot be subdivided, distribute these blocks to the specified number of groups in a way which minimizes the maximum total items given to any group. Optionally weight the blocks by a power of their size when computing the... | def distribute_discrete(sizes, groups, pow=1.0):
chunks = np.array(sizes, dtype=np.int64)
weights = np.power(chunks.astype(np.float64), pow)
max_per_proc = float(distribute_partition(weights.astype(np.int64), groups))
target = np.sum(weights) / groups
dist = []
off = 0
curweight = 0.0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_uniform(totalsize, groups):\n ret = []\n for i in range(groups):\n myn = totalsize // groups\n off = 0\n leftover = totalsize % groups\n if ( i < leftover ):\n myn = myn + 1\n off = i * myn\n else:\n off = ((myn + 1) * leftove... | [
"0.689245",
"0.61154896",
"0.5870437",
"0.5869391",
"0.58351797",
"0.58224726",
"0.57872975",
"0.57095844",
"0.5696942",
"0.56960577",
"0.56809574",
"0.5656975",
"0.5649476",
"0.5628034",
"0.5624336",
"0.56135494",
"0.56011015",
"0.55793",
"0.5571817",
"0.5562723",
"0.5553862... | 0.7222635 | 0 |
Uniformly distribute items between groups. Given some number of items and some number of groups, distribute the items between groups in the most Uniform way possible. | def distribute_uniform(totalsize, groups):
ret = []
for i in range(groups):
myn = totalsize // groups
off = 0
leftover = totalsize % groups
if ( i < leftover ):
myn = myn + 1
off = i * myn
else:
off = ((myn + 1) * leftover) + (myn * (i ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_discrete(sizes, groups, pow=1.0):\n chunks = np.array(sizes, dtype=np.int64)\n weights = np.power(chunks.astype(np.float64), pow)\n max_per_proc = float(distribute_partition(weights.astype(np.int64), groups))\n\n target = np.sum(weights) / groups\n\n dist = []\n\n off = 0\n curw... | [
"0.72016066",
"0.64487475",
"0.62581235",
"0.622412",
"0.61074805",
"0.58833826",
"0.5873367",
"0.58550215",
"0.57324255",
"0.57185954",
"0.5712346",
"0.5675752",
"0.5650044",
"0.5643228",
"0.5635769",
"0.5634285",
"0.562649",
"0.5610099",
"0.5546628",
"0.554625",
"0.5526702"... | 0.798673 | 0 |
The toast.Comm over which the data is distributed. | def comm(self):
return self._comm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comm(self):\n return self.comm",
"def get_comm() -> Communication:\n return __default_comm",
"def GetComm(self):\n return _hypre.HypreParVector_GetComm(self)",
"def object_communicator():\n comm = MPI.COMM_WORLD",
"def GetComm(self):\n return _hypre.HypreParMatrix_GetComm... | [
"0.61659884",
"0.6069794",
"0.5846124",
"0.5728337",
"0.5702727",
"0.5535399",
"0.53622645",
"0.5292387",
"0.51455116",
"0.5064816",
"0.5057292",
"0.49910793",
"0.49418244",
"0.49387032",
"0.49278933",
"0.4907674",
"0.49075994",
"0.4895052",
"0.48310533",
"0.48227745",
"0.482... | 0.612058 | 1 |
Print information about the distributed data to the specified file handle. Only the rank 0 process writes. | def info(self, handle):
# Each process group gathers their output
groupstr = ""
procstr = ""
gcomm = self._comm.comm_group
wcomm = self._comm.comm_world
rcomm = self._comm.comm_rank
if wcomm.rank == 0:
handle.write("Data distributed over {} process... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_data():",
"def format(self, f):\n INFO = self.logger.info\n\n f.write(\"# Greenplum Database identifier for this master/segment.\\n\")\n f.write(\"# Do not change the contents of this file.\\n\")\n f.write('dbid = %d\\n' % self.dbid)\n INFO('wrote dbid: %d' % self.db... | [
"0.533129",
"0.5310704",
"0.5240423",
"0.5231672",
"0.5218582",
"0.51917535",
"0.5177688",
"0.51472735",
"0.5135112",
"0.51345277",
"0.51254356",
"0.5119048",
"0.5080074",
"0.5076334",
"0.5051235",
"0.5046454",
"0.50440407",
"0.5038391",
"0.50326645",
"0.5031325",
"0.50310373... | 0.5959142 | 0 |
Connect a method to this slot. | def connect(self, method):
key = (method.__func__, id(method.__self__))
self._dict[key] = method.__self__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self, slot):\r\n if inspect.ismethod(slot):\r\n instance = slot.__self__\r\n function = slot.__func__\r\n if instance not in self._methods:\r\n self._methods[instance] = set()\r\n if function not in self._methods[instance]:\r\n ... | [
"0.76193994",
"0.67152643",
"0.67026365",
"0.6241124",
"0.6180561",
"0.6174271",
"0.6174271",
"0.61111224",
"0.60996664",
"0.6064166",
"0.6064166",
"0.6021597",
"0.6018544",
"0.59857386",
"0.59537935",
"0.59430385",
"0.5863827",
"0.5855777",
"0.58509547",
"0.5847076",
"0.5820... | 0.7031321 | 1 |
Disconnect a method from this slot. | def disconnect(self, method):
key = (method.__func__, id(method.__self__))
if key in self._dict:
del self._dict[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _disconnect(self):\n raise NotImplementedError(\"ERROR: Unimplemented function.\")",
"def disconnect(self, slot):\n if self.is_connected(slot):\n self.slots.pop(self.slots.index(slot))",
"def disconnect(self):\n raise NotImplementedError('disconnect() is not implemented')",
... | [
"0.73672116",
"0.71853644",
"0.69441503",
"0.6936023",
"0.6936023",
"0.6859748",
"0.6830833",
"0.6797493",
"0.6797493",
"0.6711881",
"0.6648343",
"0.6539646",
"0.6523527",
"0.6523527",
"0.6523527",
"0.6523527",
"0.6523527",
"0.64713925",
"0.63750887",
"0.6365629",
"0.6272979"... | 0.7751953 | 0 |
To compute the geodesic distance to the walls in using \ a fastmarching method | def compute_wall_distance(self):
phi = sp.ones(self.image_red.shape)
if (len(self.mask_id[0])>0):
phi[self.mask_id] = 0
self.wall_distance = skfmm.distance(phi, dx=self.pixel_size)
grad = sp.gradient(self.wall_distance,edge_order=2)
grad_X = grad[1]/self.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_fast_marching(D,start_points):\n D_temp = np.copy(D)\n D_temp[start_points[0,:],start_points[1,:]] = 0\n return fmm.distance(D_temp) + 1e-15",
"def _computeDistance(self, mote, neighbor):\n\n return 1000*math.sqrt((mote.x - neighbor.x)**2 +\n (mote.y - nei... | [
"0.6176286",
"0.6150726",
"0.6150726",
"0.60788697",
"0.5812341",
"0.57557344",
"0.57368165",
"0.5719741",
"0.5710146",
"0.56776214",
"0.56411487",
"0.5639875",
"0.5636927",
"0.56183845",
"0.5616496",
"0.5609934",
"0.5602868",
"0.559367",
"0.5593239",
"0.5589662",
"0.5570916"... | 0.63437414 | 0 |
To plot the wall distances | def plot_wall_dist(self,id=1,dpi=150):
fig = plt.figure(id)
ax1 = fig.add_subplot(111)
ax1.imshow(self.image,interpolation='nearest',
extent=[self.xmin,self.xmax,self.ymin,self.ymax], origin='lower')
ax1.imshow(self.wall_distance,interpolation='nearest',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDistances():\n\n # If there's a wall in the way then there's no edge that way (probably)\n\n wallL, edgeL = getDistance(-45) # Left\n wallF, edgeF = getDistance( 0) # Forward\n wallR, edgeR = getDistance( 45) # Right\n\n panTilt.pan() # Recenter\n\n return wallL, edgeL, wallF, edgeF, ... | [
"0.6642078",
"0.62512195",
"0.5998224",
"0.59888494",
"0.59229547",
"0.5896411",
"0.5847392",
"0.57994545",
"0.57985526",
"0.5769744",
"0.57665414",
"0.5710313",
"0.57037246",
"0.5697214",
"0.5687254",
"0.56732756",
"0.56732756",
"0.56475973",
"0.563784",
"0.5581875",
"0.5537... | 0.7610848 | 0 |
Iter to a list of servers and instantiate Protocol class. | def set_servers(self, servers):
if isinstance(servers, six.string_types):
servers = [servers]
assert servers, "No memcached servers supplied"
self._servers = [Protocol(
server=server,
username=self.username,
password=self.password,
com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,server_list):\n self.workers=[]\n self.worker_by_name={}\n worker_id = 1\n for host,port in server_list:\n # Add the uid here can help with port conflicts, but only works\n # on Unix clusters. We really need to work out a daemon service\n ... | [
"0.6665561",
"0.5961506",
"0.58802676",
"0.582022",
"0.57430696",
"0.55884355",
"0.55266905",
"0.55143803",
"0.5494216",
"0.54644495",
"0.54373556",
"0.53618836",
"0.5360595",
"0.53562003",
"0.5351459",
"0.534337",
"0.53352594",
"0.5334474",
"0.53176737",
"0.53134704",
"0.531... | 0.6542367 | 1 |
Tests for Average Bioequivalence. | def test_average_bioequivalence():
# See 10.2 Example from Chow et al.
h = Average(delta=0.223, stdev=0.40, margin=0.05,
alpha=0.05, power=0.8, known_stdev=True)
h.calculate()
# Chow has 21, but they have the wrong z_beta/2. It should be 1.28,
# not 0.84. When that is fixed, the c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_avg_grade(self):\n\t\ts = Student_Analytics()\n\t\tself.assertEqual(s.classify_grade(s.avg_grade(3)),\"B\")",
"def test_avg_entanglement_fidelity_ensemble():\n # Test on emsemble.\n probs = [1.]\n states = [np.eye(2) / 2.]\n # Test on pauli choi matrix.\n krauss_ops = initialize_pauli_exa... | [
"0.6671989",
"0.64432764",
"0.64178544",
"0.62681234",
"0.62358105",
"0.62358105",
"0.61920863",
"0.6122437",
"0.6073407",
"0.60704947",
"0.60704947",
"0.60704947",
"0.6024898",
"0.6024063",
"0.6024063",
"0.6024063",
"0.59498715",
"0.5922118",
"0.58959824",
"0.5873126",
"0.58... | 0.8098406 | 0 |
Tests for Population Bioequivalence. | def test_population_bioequivalence():
# See 10.3 Example from Chow et al.
h = Population(l=-0.2966, stdev_11=0.2, stdev_tt=math.sqrt(0.17),
stdev_tr=math.sqrt(0.17), stdev_bt=0.4, stdev_br=0.4,
rho=0.75, alpha=0.05, power=0.8)
h.calculate()
assert h.n == 12 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compare_genomes_2(self):\n self.pmr_gnm.annotation_status = \"final\"\n self.pmr_gnm.name = \"Trixie\"\n import_genome.compare_genomes(self.genome_pair, self.eval_flags)\n count = count_status(self.genome_pair, \"error\", \"warning\")\n with self.subTest():\n ... | [
"0.6193102",
"0.61115116",
"0.6015876",
"0.59955764",
"0.5883219",
"0.58637136",
"0.5820107",
"0.5813707",
"0.5778114",
"0.5767895",
"0.57653195",
"0.57620484",
"0.573535",
"0.57301676",
"0.57206523",
"0.56827587",
"0.5657508",
"0.56414694",
"0.5628475",
"0.5628418",
"0.56154... | 0.78521746 | 0 |
get observables from stix2 json | def get_observables(stix_json, log):
objects = stix_json["objects"]
observables = []
for obj in objects:
observable = get_observable(obj, log)
if observable:
observables.append(observable)
return observables | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_servables(self):\n if not self._server_started() is True:\n print('Server not started at host %s, port %d' % (self.host, self.port))\n sys.exit(0)\n else:\n headers = {'Content-Type': 'application/json'}\n url = 'http://'+self.host+':'+str(self.por... | [
"0.62193173",
"0.5815124",
"0.55947036",
"0.5513718",
"0.53893983",
"0.53819305",
"0.53428006",
"0.52789974",
"0.50996727",
"0.50031304",
"0.49881196",
"0.49829662",
"0.49760333",
"0.49739003",
"0.4947553",
"0.49138665",
"0.49131507",
"0.49004713",
"0.4892729",
"0.48071638",
... | 0.7748714 | 0 |
Get observable type for a stix object | def get_observable_type(stix_obj, log):
obj_type = stix_obj[u"type"]
if obj_type == u"observed-data":
#
# so far all the observed-data has only one embedded obj
# if there is more, log the error
#
if len(stix_obj[u"objects"]) > 1:
log.error("Observed-data {} h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type ( self, object ):\n return self.type",
"def get_type ( self, object ):\n return self.type",
"def get_observable(stix_obj, log):\n res_obj = {}\n\n if stix_obj[u\"type\"] == \"relationship\":\n return None\n\n res_obj[u\"toxicity\"] = stix_obj.get(IBM_TOXICITY, \"\")\n... | [
"0.6467229",
"0.6467229",
"0.60474116",
"0.6035891",
"0.6021861",
"0.60110044",
"0.6003303",
"0.59633845",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
"0.5953436",
... | 0.8163599 | 0 |
Find a stix obj using obj_id | def find_object_by_id(stix_objects, obj_id):
ret_obj = None
for obj in stix_objects:
if obj["id"] == obj_id:
ret_obj = obj
break
return ret_obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object(id):",
"def find_by_id(object_id, items):\n for item in items:\n if object_id == item[\"id\"]:\n return item\n\n raise Exception(f\"Item with {object_id} not found\")",
"def object_for(objectid):",
"def get_object_by_id(self, object_list, object_id):\n obj = None... | [
"0.74366605",
"0.6660078",
"0.6613826",
"0.66030574",
"0.65227836",
"0.6500162",
"0.6412086",
"0.64099437",
"0.63752186",
"0.63266295",
"0.62988967",
"0.62979877",
"0.6282076",
"0.6247149",
"0.6232817",
"0.621489",
"0.6199346",
"0.6195045",
"0.61742485",
"0.61664426",
"0.6160... | 0.8400525 | 0 |
Find all leaf nodes below start_tag in the tag_table. Search from the start tag and down through the tag tree, until ending up at children that have no children of their own. Return the combined Series of these children. | def find_children(start_tag, tag_table):
pure_child = pd.Series([])
parents = pd.Series([start_tag])
while parents.shape[0] > 0:
pure_child = pd.concat([pure_child,
parents[~parents
.isin(tag_table['Parent'])]])
parents ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_children(search_tag, tag_list):\n list_return = []\n\n for tag in tag_list:\n if str(tag.parent) == str(search_tag):\n list_return.append(tag)\n list_return.extend(get_children(tag, tag_list))\n return list(set(list_return)) # This will return a list of unique element... | [
"0.60712296",
"0.59759665",
"0.5792263",
"0.56499445",
"0.5448759",
"0.54347426",
"0.5383377",
"0.536103",
"0.5359288",
"0.52728033",
"0.52625084",
"0.5240432",
"0.5222117",
"0.5203426",
"0.51802504",
"0.5170244",
"0.5154103",
"0.5152585",
"0.5125588",
"0.5117449",
"0.5116381... | 0.7850898 | 0 |
Cleans up a slug by removing slug separator characters that occur at the beginning or end of a slug. If an alternate separator is used, it will also replace any instances of the default '' separator with the new separator. | def _slug_strip(self,
value,
separator='-'):
separator = separator or ''
if separator == '-' or not separator:
re_sep = '-'
else:
re_sep = '(?:-|%s)' % re.escape(separator)
# Remove multiple instances and if an alternate sep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _slug_strip(value, separator='-'):\n separator = separator or ''\n if separator == '-' or not separator:\n re_sep = '-'\n else:\n re_sep = '(?:-|%s)' % re.escape(separator)\n # Remove multiple instances and if an alternate separator is provided,\n # replace the default '-' separato... | [
"0.8093289",
"0.7083839",
"0.67627585",
"0.6718731",
"0.6622538",
"0.6551716",
"0.65302366",
"0.6511013",
"0.64927936",
"0.64924055",
"0.6492133",
"0.6430577",
"0.6415602",
"0.63980514",
"0.6385788",
"0.63794196",
"0.63383615",
"0.6315635",
"0.6314748",
"0.6311437",
"0.630627... | 0.78587174 | 1 |
Calculates and stores a unique slug of ``value`` for an instance. ``slug_field_name`` should be a string matching the name of the field to store the slug in (and the field to check against for uniqueness). ``queryset`` usually doesn't need to be explicitly provided it'll default to using the ``.all()`` queryset from th... | def unique_slugify(instance,
value,
slug_field_name='slug',
queryset=None,
slug_separator='-'):
slug_field = instance._meta.get_field(slug_field_name)
slug = getattr(instance, slug_field.attname)
slug_le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_slugify(instance, value, slug_field_name='slug', queryset=None,\n slug_separator='-'):\n slug_field = instance._meta.get_field(slug_field_name)\n\n slug = getattr(instance, slug_field.attname)\n slug_len = slug_field.max_length\n\n # Sort out the initial slug, limiting its ... | [
"0.7676992",
"0.6218883",
"0.6207083",
"0.61557245",
"0.6017999",
"0.5916228",
"0.5716703",
"0.5674682",
"0.5611593",
"0.5576234",
"0.53269184",
"0.5287026",
"0.5262419",
"0.52261305",
"0.52043664",
"0.5179654",
"0.5138324",
"0.5138324",
"0.51121",
"0.5101838",
"0.50992155",
... | 0.7879291 | 0 |
iRep gc_content message calculate gc content over sequence windows | def _iRep_gc_content(seq, window = 5000, slide = 100):
# convert GC
replacements = {'G':1, 'C':1, 'A':0, 'T':0, 'N':0}
GC = [] # G - C
for base in seq:
try:
GC.append(replacements[base.upper()])
except:
GC.append(0)
# calculate gc content over sliding windows
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc_content(seq):\n return round( (seq.count('C') + seq.count('G')) / len(seq) * 100 , 6 )",
"def get_gc_content(sequence):\n # get the sequence length and \n # make all the sequence characters upper case\n seq_len, sequence = len(sequence), sequence.upper()\n # count all gs and cs\n c = seq... | [
"0.7346947",
"0.7220607",
"0.6958903",
"0.69466054",
"0.6928254",
"0.6875267",
"0.68252456",
"0.6799876",
"0.6799876",
"0.6786788",
"0.6718868",
"0.660639",
"0.6367929",
"0.6344572",
"0.62539244",
"0.6087192",
"0.60487205",
"0.60303813",
"0.59628457",
"0.59487265",
"0.5879270... | 0.7706852 | 0 |
RIGHT FROM iREP linear function for sorted coverage profile y = mx + b | def coverage_function(pars, X, data = None, printPs = False):
m = pars['m'].value
b = pars['b'].value
if printPs is True:
print('m: %s b: %s' % \
('{:,}'.format(int(m)), '{:,}'.format(int(b))))
results = [float(m * x) + b for x in X]
if data is None:
return np.asarray(res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_lineprofile(npix,rstar,xc,vgrid,A,veq,linewidth):\n vc=(np.arange(npix)-xc)/rstar*veq\n vs=vgrid[np.newaxis,:]-vc[:,np.newaxis]\n profile=1.-A*np.exp( -(vs*vs)/2./linewidth**2)\n return profile",
"def gaus_pol1(x, a, b, c, m, yint):\n return gaus(x, a, b, c) + lin(x, m, yint)",
"def Tes... | [
"0.6025226",
"0.6005712",
"0.5694815",
"0.5658959",
"0.56120896",
"0.5553306",
"0.554806",
"0.5538556",
"0.5525831",
"0.55137885",
"0.5503041",
"0.55006784",
"0.54923874",
"0.5491246",
"0.54875684",
"0.5486014",
"0.54742515",
"0.54602444",
"0.5458907",
"0.54526603",
"0.545169... | 0.6396224 | 0 |
Run each component of the PASCAL VOC dataset formatter in sequence. | def begin(self):
print("Renaming images to VOC data format...")
self.renamer.rename()
print("Renaming Complete.")
print("Splitting the data in to training/validation/test sets and creating text files respectively...")
self.data_splitter.split()
print("Data Splitting Compl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n (\n calibration_file,\n drs4_ped_file,\n time_calibration_file,\n systematic_correction_file,\n drive_log_file,\n run_summary_file,\n pedestal_ids_file,\n run_number,\n ) = data_sequence_cli_parsing()\n\n if options.verbose:\n lo... | [
"0.5771342",
"0.5765575",
"0.5497768",
"0.548974",
"0.5480084",
"0.547106",
"0.5441647",
"0.5418743",
"0.54071593",
"0.53904974",
"0.5355923",
"0.5344643",
"0.53241676",
"0.53178394",
"0.5260527",
"0.5237012",
"0.5234183",
"0.5232217",
"0.5231144",
"0.52279514",
"0.52246046",... | 0.5895718 | 0 |
Some groups were deleted, remove them from users principals. | def on_groups_deleted(event):
permission_backend = event.request.registry.permission
for change in event.impacted_objects:
group = change["old"]
bucket_id = event.payload["bucket_id"]
group_uri = utils.instance_uri(event.request, "group", bucket_id=bucket_id, id=group["id"])
pe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup_user_groups(event):\n name = event.object.name\n\n if name.startswith(\"group:\"):\n principals = get_principals()\n users_groups = [p for p in principals if name in principals[p].groups]\n for user_or_group in users_groups:\n principals[user_or_group].groups.remov... | [
"0.7971463",
"0.7591969",
"0.7588629",
"0.73583055",
"0.73583055",
"0.7355232",
"0.7186501",
"0.7186501",
"0.7132678",
"0.7087664",
"0.705803",
"0.69757986",
"0.69535804",
"0.69411594",
"0.69188416",
"0.68842256",
"0.68559927",
"0.6846518",
"0.68274677",
"0.67699003",
"0.6699... | 0.7736013 | 1 |
Some groups were changed, update users principals. | def on_groups_changed(event):
permission_backend = event.request.registry.permission
for change in event.impacted_objects:
if "old" in change:
existing_record_members = set(change["old"].get("members", []))
else:
existing_record_members = set()
group = change["n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups_update(self, mar, request):\n group_id = mar.viewed_user_auth.user_id\n member_ids_dict, owner_ids_dict = self._services.usergroup.LookupMembers(\n mar.cnxn, [group_id])\n owner_ids = owner_ids_dict.get(group_id, [])\n member_ids = member_ids_dict.get(group_id, [])\n if not permiss... | [
"0.6849886",
"0.6760221",
"0.66351527",
"0.65919024",
"0.6334146",
"0.62793535",
"0.6236597",
"0.6152543",
"0.61075574",
"0.60988516",
"0.60501474",
"0.60424423",
"0.6019404",
"0.6014997",
"0.5987296",
"0.5920208",
"0.5881497",
"0.5880628",
"0.5869055",
"0.5863141",
"0.585721... | 0.740874 | 0 |
read_json takes a list of str for the name of all json files. Uses the json to generate a Constituency objects that gets append to the Election constituency attribute | def read_json(self, json_files):
self.file_access.write_log("Attempting to read the json files {}".format(json_files))
for i in json_files:
self.constituency.append(self.file_access.read_election_json(i))
self.file_access.write_log("The {} json file has been added to the Constitu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_classification_json(fn):\n with open(fn) as f:\n classification_data = json.load(f)\n f.close()\n \n return classification_data",
"def read_json():\n try:\n rospack = rospkg.RosPack()\n file_path = rospack.get_path('autonomous') + \"/src/data.txt\"\n wi... | [
"0.65061456",
"0.6114574",
"0.6057887",
"0.5964582",
"0.5941496",
"0.59386635",
"0.5897578",
"0.5862386",
"0.58360434",
"0.5798207",
"0.5793471",
"0.5754497",
"0.5673281",
"0.5623062",
"0.5598817",
"0.55820906",
"0.55776715",
"0.55578196",
"0.55525863",
"0.5548048",
"0.554410... | 0.7654895 | 0 |
Confirm creation of a CountyMortgageData object from a CSV row. | def test_data_creation_from_base_row(self, mock_read_csv):
f = StringIO(self.data_header + self.data_row)
reader = csv.DictReader(f)
mock_read_csv.return_value = reader
load_values()
self.assertEqual(CountyMortgageData.objects.count(), 1)
county = CountyMortgageData.objec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_csv(self, user, row):\n if len(row) != 6:\n raise BadRequest(_(\"Invalid line\"))\n self.name = row[1].strip()\n self.target_host = row[2].strip()\n self.service, created = Service.objects.get_or_create(\n name=row[3].strip())\n self.enabled = (row[... | [
"0.65647215",
"0.6546224",
"0.62184423",
"0.61489475",
"0.6088905",
"0.6068437",
"0.59123445",
"0.5874923",
"0.587123",
"0.58576244",
"0.5758785",
"0.5727914",
"0.5639902",
"0.56310624",
"0.5628611",
"0.5628605",
"0.5627368",
"0.5611206",
"0.5606662",
"0.5591287",
"0.5553421"... | 0.66076845 | 0 |
Runs a backfill on a fixed number of objects. | def backfill(task, request, check_name, num_objects):
check = getattr(checks, check_name)(request.db)
target_object = getattr(packaging_models, check.hooked_object)
query = request.db.query(target_object.id).limit(num_objects)
request.log.info("Running backfill on %d %ss." % (num_objects, check.hooked_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _grow(self): \n limit = 0\n #Iterating through the list to find the number of elements\n for i in xrange(len(self)):\n if self._items[i] != self._fillValue:\n #There's an element at index i, so update the limit\n limit = i\n \n ... | [
"0.5782486",
"0.574313",
"0.55496156",
"0.54927135",
"0.5488854",
"0.54863733",
"0.5440862",
"0.5438565",
"0.5412206",
"0.5406161",
"0.540015",
"0.5367641",
"0.53450596",
"0.53275067",
"0.5306449",
"0.53035223",
"0.5301051",
"0.5275734",
"0.5271671",
"0.5263534",
"0.52617574"... | 0.5933235 | 0 |
Compares saved folders list with the current one | def get_folders_diff(self, folders):
missing_folders = list(set(self.saved_folders).difference(set(folders)))
added_folders = list(set(folders).difference(set(self.saved_folders)))
if any([missing_folders, added_folders]):
self.saved_folders = folders
return missing_folders, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmp_directories(self, dir_1='./', dir_2='./'):\n dirs_cmp = filecmp.dircmp(dir_1, dir_2)\n list_dirs_json = dict()\n path_in = self.make_path_in(dir_1, dir_2)\n\n equal_files_json = self.equal_files_to_json(\n dirs_cmp.same_files,\n ... | [
"0.6123963",
"0.6063844",
"0.6025782",
"0.6014728",
"0.5925235",
"0.5914503",
"0.5839932",
"0.5811035",
"0.57636356",
"0.57502395",
"0.5744658",
"0.5716511",
"0.56534886",
"0.5638854",
"0.56171244",
"0.5615707",
"0.5542048",
"0.5539833",
"0.55364084",
"0.55273443",
"0.5525409... | 0.6400781 | 0 |
Compares saved files data with the current files data | def get_files_diff(self, current_files_data):
if self.saved_files_data:
saved_files_paths, saved_files_hashes = zip(*self.saved_files_data.items())
else:
saved_files_paths, saved_files_hashes = [], []
if current_files_data:
current_files_paths, current_files_h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_files(self):\n\n first_backup_ids = set(self.first_source_data.keys())\n second_backup_ids = set(self.second_source_data.keys())\n\n for deleted_user_id in first_backup_ids.difference(second_backup_ids):\n self.changes[Constants.DELETED_USER]\\\n .append({... | [
"0.68501765",
"0.66970176",
"0.6690322",
"0.64321995",
"0.6393277",
"0.6354407",
"0.6287291",
"0.62570655",
"0.6238033",
"0.6206817",
"0.61869234",
"0.61782014",
"0.6162856",
"0.6142978",
"0.61206084",
"0.6094404",
"0.6058897",
"0.60207516",
"0.60071945",
"0.5990195",
"0.5985... | 0.67130214 | 1 |
Infinite checker to determine any files and folders changes | def check_folder_state(self):
while self:
diff = self.get_diff()
print(diff or 'No changes detected')
if diff:
self.parent.send_diff_data(diff)
time.sleep(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_changed_files(self) -> list[Path]:\n repos = [(self.open_repo(), self.git_directory)]\n # Check server and api dirs too\n # Normally these are ignored but we need to check these\n if (server_repo_path := Path(self.git_directory, \"Paper-Server\")).exists():\n repos... | [
"0.649415",
"0.6353063",
"0.6351424",
"0.63136977",
"0.6285552",
"0.6275514",
"0.62463176",
"0.621994",
"0.6208854",
"0.6180186",
"0.61614585",
"0.61113906",
"0.60959333",
"0.60786444",
"0.6073537",
"0.60468596",
"0.60426575",
"0.6011889",
"0.6000292",
"0.59920996",
"0.594031... | 0.7357654 | 0 |
get top k largest elements from each corressponding rows of matrix | def get_top_k(matrix,k):
assert k <= matrix.shape[1]
col_inds = np.argpartition(matrix, -k)[:,-k:].flatten()
row_inds = np.repeat(range(matrix.shape[0]),k)
vals = matrix[row_inds, col_inds]
return vals, col_inds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_top_k(vect, mat, k):\n resultant = np.dot(mat, vect)\n arglist = np.argsort(resultant)\n arglist = arglist[-1:(-1 - k):-1]\n return arglist, resultant",
"def top_k(m, k):\n ml = m.tolil()\n ms = [_top_k(d, r, k) for d, r in zip(ml.data, ml.rows)]\n return zip(*ms)",
"def get_tops... | [
"0.78078854",
"0.7482105",
"0.7286839",
"0.71473676",
"0.7088986",
"0.6973559",
"0.6957784",
"0.6926557",
"0.68686914",
"0.68671626",
"0.6864181",
"0.6754134",
"0.66880155",
"0.6621688",
"0.65671676",
"0.6561875",
"0.65489244",
"0.6497595",
"0.646024",
"0.6455032",
"0.6449004... | 0.76114184 | 1 |
get k random element from each corressponding rows of matrix | def get_random_k(matrix, k):
assert k <= matrix.shape[1]
col_inds = np.array([np.random.choice(matrix.shape[1],k) for _ in range(matrix.shape[0])]).flatten()
row_inds = np.repeat(range(matrix.shape[0]),k)
vals = matrix[row_inds, col_inds]
return vals, col_inds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _randomnk(m, n, k):\n a = np.random.random((m, n))\n for i in range(k, n):\n pars = np.random.random(k)\n a[:, i] = a[:, :k] @ pars\n return a",
"def initialize_clusters(points, k):\r\n return points[np.random.randint(points.shape[0], size=k)]",
"def randCent(data,k):\n index =... | [
"0.7244414",
"0.69032",
"0.65335214",
"0.6526351",
"0.6523111",
"0.6515291",
"0.6423375",
"0.63610154",
"0.6351249",
"0.6316154",
"0.6297875",
"0.62714523",
"0.6265273",
"0.6165894",
"0.61577964",
"0.6157002",
"0.6144533",
"0.6099416",
"0.6081216",
"0.6075068",
"0.60582954",
... | 0.74868983 | 0 |
Count records across batches. | def count_records(batches: List[Batch]) -> int:
return sum(b.current_size for b in batches) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_batches(self, instances: Iterable[Instance]) -> int:\n n_docs = len(set([instance[\"metadata\"][\"doc_key\"] for instance in instances]))\n return n_docs",
"def get_num_batches(self,batch_size):\r\n \r\n return len(self) // batch_size",
"def batch_size(self) -> int:\n ... | [
"0.71313673",
"0.6932072",
"0.6870095",
"0.67976797",
"0.66032314",
"0.6554192",
"0.6484331",
"0.64692736",
"0.64613444",
"0.6396987",
"0.63178724",
"0.62802833",
"0.62721443",
"0.62721443",
"0.62378734",
"0.62235904",
"0.62096214",
"0.61888677",
"0.61625093",
"0.61575264",
"... | 0.8504124 | 0 |
Crawl through the batches. Produces a generator function that yields (r.header, r.seq) for each record r across batches. Batches are crawled through their r.record_gen if self.doSort==False, otherwise using r.sorted. | def do_records(self, batches: List[Batch]) -> Iterator[Tuple[str, str]]:
if any(type(b) not in [Batch, BatchAppendable] for b in batches):
raise AssertionError()
if self.doSort:
generators = [
((str(r.header), str(r.seq)) for r in b.sorted(self.doSmart))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_batch(self, batches: List[Batch]) -> Iterator[Tuple[List[str], str]]:\n crawler = self.do_records(batches)\n\n try:\n first_record = next(crawler)\n except StopIteration:\n logging.error(\"nothing to crawl\")\n return\n\n current_seq = first_recor... | [
"0.71820664",
"0.57776165",
"0.5710268",
"0.57072127",
"0.5692253",
"0.5690749",
"0.56448466",
"0.56083345",
"0.56011665",
"0.55865467",
"0.55815995",
"0.5555864",
"0.5494762",
"0.54750973",
"0.5467062",
"0.54343045",
"0.54213136",
"0.5420634",
"0.5399811",
"0.5376439",
"0.53... | 0.74110866 | 0 |
Group records from batches based on sequence. Crawls into groups of records from input batches. | def do_batch(self, batches: List[Batch]) -> Iterator[Tuple[List[str], str]]:
crawler = self.do_records(batches)
try:
first_record = next(crawler)
except StopIteration:
logging.error("nothing to crawl")
return
current_seq = first_record[1]
cur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batches(data, batch_size) -> list:\n rv = []\n for idx, line in enumerate(data):\n if idx != 0 and idx % batch_size == 0:\n yield rv\n rv = []\n rv.append(line)\n yield rv",
"def do_records(self, batches: Lis... | [
"0.6201766",
"0.61394286",
"0.60248244",
"0.5968052",
"0.59213907",
"0.5915099",
"0.58367103",
"0.5821988",
"0.581675",
"0.57865965",
"0.5782162",
"0.5763047",
"0.5718872",
"0.5709953",
"0.57008743",
"0.5692128",
"0.56830883",
"0.5660939",
"0.5658205",
"0.5650884",
"0.5648578... | 0.6228171 | 0 |
Select the appropriate join function, based on the current mode. | def __set_join_function(self):
if self.mode == self.MODE.UNIQUE:
self.__join_function = self.join_unique
elif self.mode == self.MODE.SEQ_COUNT:
self.__join_function = self.join_sequence_count
elif self.mode == self.MODE.VEC_COUNT:
self.__join_function = self.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _select_mode(self):\n self.__check_mode()\n if self.mode[\"auto_mode\"]:\n self.mode_auto()\n elif self.mode[\"auto_mode\"] is None: # Do Nothing\n self.mode_standby()\n else:\n self.mode_manual()",
"def join(self) -> \"cocotb.triggers.Join\":\n ... | [
"0.54541767",
"0.5298494",
"0.5287994",
"0.5253134",
"0.5196433",
"0.51717496",
"0.5141866",
"0.50759524",
"0.50703716",
"0.50369006",
"0.49973783",
"0.49802926",
"0.4961307",
"0.4899268",
"0.4894296",
"0.48599124",
"0.48489833",
"0.47833675",
"0.47625113",
"0.47557896",
"0.4... | 0.7746332 | 0 |
Perform sequence counting through joining. Counts sequence occurrences. | def join_sequence_count(
headers: List[str], seq: str, OH: IO, **kwargs
) -> Tuple[str, int]:
batch = (seq, len(headers))
OH.write("%s\t%d\n" % batch)
return batch | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(seq):\n\treturn sum(1 for x in seq)",
"def count():",
"def count_sequences(self, size):\n raise NotImplementedError",
"def Counting(seq):\n\n #Scan the sequence, looking for motifs\n\n counting = {k: 0 for k in MOT} # Initialize the counting dictionary.\n # Scan all the motifs and f... | [
"0.69582546",
"0.62097913",
"0.605739",
"0.6015187",
"0.5959785",
"0.5924617",
"0.57749957",
"0.5665839",
"0.56234276",
"0.5620457",
"0.5549516",
"0.5546007",
"0.5545018",
"0.5525091",
"0.55207217",
"0.5505692",
"0.550143",
"0.54988235",
"0.5486474",
"0.5467682",
"0.5455928",... | 0.64208555 | 1 |
Join sequenceCount batches in parallel. | def __parallel_join(self, recordBatches: List[Batch], outpath: str) -> None:
kwargs = self._pre_join(outpath)
batcher = SeqCountBatcher.from_parent(self, self.batch_size)
batcher.doSort = self.doSort
print("Intermediate batching...")
batcher.do(recordBatches)
print("Join... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_sequence_count(\n headers: List[str], seq: str, OH: IO, **kwargs\n ) -> Tuple[str, int]:\n batch = (seq, len(headers))\n OH.write(\"%s\\t%d\\n\" % batch)\n return batch",
"def join(self, batches: List[Batch], outpath: str) -> None:\n if self.threads == 1:\n ... | [
"0.6463623",
"0.55326104",
"0.54898655",
"0.53560454",
"0.52667665",
"0.5244737",
"0.5173805",
"0.50776064",
"0.50258076",
"0.50120574",
"0.49834517",
"0.49575722",
"0.49538717",
"0.49265176",
"0.4919364",
"0.48957646",
"0.48888114",
"0.4872933",
"0.48429677",
"0.48294276",
"... | 0.69355303 | 0 |
Perform kjoining of batches. | def join(self, batches: List[Batch], outpath: str) -> None:
if self.threads == 1:
super().join(batches, outpath)
else:
self.__parallel_join(batches, outpath) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parallel_join(self, recordBatches: List[Batch], outpath: str) -> None:\n kwargs = self._pre_join(outpath)\n\n batcher = SeqCountBatcher.from_parent(self, self.batch_size)\n batcher.doSort = self.doSort\n print(\"Intermediate batching...\")\n batcher.do(recordBatches)\n ... | [
"0.6566977",
"0.60989094",
"0.57576424",
"0.540203",
"0.5401272",
"0.53988075",
"0.53314203",
"0.5316356",
"0.5256726",
"0.52000463",
"0.5192977",
"0.5165509",
"0.5111428",
"0.509478",
"0.5040657",
"0.5036986",
"0.50123674",
"0.50091857",
"0.5002618",
"0.49993095",
"0.4998663... | 0.6234955 | 1 |
Start batching the records. Batch seq.Sequence subclass batch.Batch records into seq.SequenceCounts batch.Batch instances. | def do(self, recordBatch: List[Batch]) -> None:
batchList = [
recordBatch[i : min(len(recordBatch), i + self.n_batches)]
for i in range(0, len(recordBatch), self.n_batches)
]
batches = Parallel(n_jobs=self.threads, verbose=11)(
delayed(SeqCountBatcher.build_ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_start(self, batch_idx, batch_data):\n self.batch = batch_idx",
"def _fillBatches(self):\n\n batchRE = r\"\"\"\n B\n (?P<observebatch>\\d+?)\n (?P<startend>[SE])\n (?P<sequence>\\d+?)\n _SR\n (?:_(?P<extraInjections>\\d+?|\\... | [
"0.70635146",
"0.672973",
"0.6591983",
"0.65474814",
"0.6227351",
"0.6181943",
"0.616198",
"0.61579263",
"0.6150017",
"0.61381686",
"0.60892963",
"0.605244",
"0.60366535",
"0.60299593",
"0.60185724",
"0.60083634",
"0.5928345",
"0.58852",
"0.5877978",
"0.58668387",
"0.5854245"... | 0.67457694 | 1 |
In this part, you need to try different distance functions you implemented in part 1.1 and different values of k (among 1, 3, 5, ... , 29), and find the best model with the highest f1score on the given validation set. | def tuning_without_scaling(self, distance_funcs, x_train, y_train, x_val, y_val):
best_f1 = 0
for name, func in distance_funcs.items():
for k in range(1, 30, 2):
model = KNN(k, func)
model.train(x_train, y_train)
valid_f1 = f1_score(y_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_best_k(X_train, y_train, X_test, y_test, min_k=1, max_k=25):\n best_k = 0\n best_score = 0.0\n for k in range(min_k, max_k+1, 2):\n knn = KNeighborsClassifier(n_neighbors=k)\n knn.fit(X_train, y_train)\n preds = knn.predict(X_test)\n f1 = f1_score(y_test, preds)\n ... | [
"0.7222877",
"0.6900722",
"0.6710727",
"0.66608876",
"0.6550627",
"0.65291595",
"0.65116113",
"0.64901376",
"0.64568204",
"0.644303",
"0.6424459",
"0.6413164",
"0.63255215",
"0.62936574",
"0.6276326",
"0.6232303",
"0.62189966",
"0.62153566",
"0.6194645",
"0.61713016",
"0.6168... | 0.7077753 | 1 |
This part is the same as "tuning_without_scaling", except that you also need to try two different scalers implemented in Part 1.3. More specifically, before passing the training and validation data to KNN model, apply the scalers in scaling_classes to both of them. | def tuning_with_scaling(self, distance_funcs, scaling_classes, x_train, y_train, x_val, y_val):
# You need to assign the final values to these variables
best_f1 = 0
for scaling_name, scaling_func in scaling_classes.items():
scaler = scaling_func()
x_train_scaled ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tuning_with_scaling(self, distance_funcs, scaling_classes, x_train, y_train, x_val, y_val):\n self.best_k = None\n self.best_distance_function = None\n self.best_model = None\n bestf = float(\"-inf\")\n self.best_scaler = None\n \n for s in scaling_classes.keys(... | [
"0.68935436",
"0.61498564",
"0.6074106",
"0.60027444",
"0.5959983",
"0.5950137",
"0.5849057",
"0.5829975",
"0.5805299",
"0.5801477",
"0.57977337",
"0.57452184",
"0.57352483",
"0.5732406",
"0.5709",
"0.57076544",
"0.5691176",
"0.56769305",
"0.5666044",
"0.5643244",
"0.56248814... | 0.68166316 | 1 |
Function for displaying all the available accounts at the home page | def all_accounts(request):
accounts = Account.objects.all()
return render(request, 'app/home.html', {'accounts': accounts}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_accounts(cls):\n return cls.account_list",
"def list_accounts(self):\n pass",
"def accounts():\n if not session.get('authed', False):\n flash(\"Please log in.\")\n return redirect(my_url('index'))\n account_ids = redis_client.smembers('%s-accounts' % session['phone... | [
"0.79639024",
"0.78714097",
"0.7488144",
"0.7481553",
"0.7406604",
"0.73886055",
"0.7223013",
"0.71588624",
"0.7116961",
"0.70824236",
"0.6985502",
"0.6905734",
"0.687565",
"0.68730795",
"0.6851584",
"0.67743534",
"0.6767352",
"0.6742166",
"0.6719278",
"0.66504353",
"0.663380... | 0.8378931 | 0 |
Function for selecting a source account, and sending the application to the next page where a destination account should be chosen | def select_account(request, account_id):
account = Account.objects.get(pk=account_id)
other_accounts = Account.objects.exclude(pk=account_id)
context = {
'source': account,
'destinations': other_accounts
}
return render(request, 'app/destination.html', context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_transfer(request):\n source = Account.objects.get(pk=int(request.POST.get('source-id', False)))\n destination = Account.objects.get(pk=int(request.POST.get('destination-id', False)))\n context = {\n 'source': source,\n 'destination': destination\n }\n return render(request,... | [
"0.6072919",
"0.5678098",
"0.559927",
"0.5527686",
"0.5519306",
"0.5226638",
"0.5185696",
"0.5179164",
"0.51324326",
"0.5109042",
"0.50586045",
"0.50556964",
"0.5055251",
"0.5048144",
"0.5034489",
"0.5032942",
"0.50032514",
"0.496251",
"0.4950748",
"0.49470022",
"0.49423796",... | 0.74542475 | 0 |
Function for retrieving the information about the source and destination accounts and sending the information to the transfer function | def prepare_transfer(request):
source = Account.objects.get(pk=int(request.POST.get('source-id', False)))
destination = Account.objects.get(pk=int(request.POST.get('destination-id', False)))
context = {
'source': source,
'destination': destination
}
return render(request, 'app/transf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transfer(self, origin, dest, amount):\n or_elem = 0\n de_elem = 0\n for elem in self.account:\n if origin == elem.id or origin == elem.name:\n or_elem = elem\n if dest == elem.id or dest == elem.name:\n de_elem = elem\n if or_elem ... | [
"0.6129466",
"0.59486693",
"0.5880699",
"0.57925147",
"0.57384783",
"0.5718324",
"0.5640389",
"0.56080145",
"0.55327165",
"0.5453918",
"0.54478085",
"0.5402419",
"0.5387087",
"0.5384199",
"0.53738874",
"0.5289498",
"0.52878386",
"0.5281779",
"0.52817446",
"0.5277293",
"0.5259... | 0.651096 | 0 |
Method for performing the transaction. If there is enough money in the source account the transaction is performed successfully and the money is transferred, otherwise, the transaction is unsuccessful and the money stays where it was. | def transfer_money(request):
source = Account.objects.get(pk=int(request.POST.get('source-id', False)))
destination = Account.objects.get(pk=int(request.POST.get('destination-id', False)))
amount = float(request.POST.get('amount', False))
enough_cash = source.available_cash >= amount
if enough_cash:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MakeMoneyTransfer(self, user_id_origin, user_id_beneficiary, amount_money):\n result_operation = self.OperateAccount(user_id_origin, (int(amount_money) * -1))\n if \"Error:\" in result_operation:\n return result_operation\n else:\n self.OperateAccount(user_id_benefici... | [
"0.66635925",
"0.66135406",
"0.64340895",
"0.63323474",
"0.63201946",
"0.6227278",
"0.61842847",
"0.61507404",
"0.61466444",
"0.6121741",
"0.610226",
"0.6071248",
"0.6053082",
"0.6041055",
"0.6032653",
"0.6019647",
"0.59909546",
"0.59867406",
"0.5973221",
"0.59658855",
"0.594... | 0.7401874 | 0 |
Plot a similarity matrix between a list of clusterings, using the provided scoring function. | def plot_sim_matrix(
clusterings: list, scoring: Callable[[object, object], object]
) -> object:
forDF = []
for c in clusterings:
cID = c.get_description()
for c2 in clusterings:
c2ID = c2.get_description()
forDF.append([cID, c2ID, scoring(c, c2).score])
df = pd.D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_results(results, labels, score):\n \n labels_dict = {k: i for i, k in enumerate(labels)}\n rmin, rmax = min(results)[0], max(results)[0]\n to_color = lambda x : 0.8 * (x - rmax) / (rmin - rmax) + 0.5\n\n result_matrix = np.zeros((8, len(labels_dict)))\n labels_dict = {k: i for i, k in e... | [
"0.6115021",
"0.59878033",
"0.59782255",
"0.5956138",
"0.59467465",
"0.5874676",
"0.586053",
"0.5834884",
"0.57424116",
"0.573193",
"0.5709266",
"0.56929475",
"0.5670776",
"0.5646054",
"0.5634125",
"0.5631307",
"0.5604918",
"0.5588165",
"0.55874056",
"0.5565134",
"0.5547118",... | 0.8091768 | 0 |
Plot the distribution of a property among all communities for a clustering, or a list of clusterings (violinplots) | def plot_com_stat(
com_clusters: list, com_fitness: Callable[[object, object, bool], object]
) -> object:
if isinstance(com_clusters, cdlib.classes.clustering.Clustering):
com_clusters = [com_clusters]
allVals = []
allNames = []
for c in com_clusters:
prop = com_fitness(c.graph, c, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_com_properties_relation(\n com_clusters: object,\n com_fitness_x: Callable[[object, object, bool], object],\n com_fitness_y: Callable[[object, object, bool], object],\n **kwargs: dict\n) -> object:\n if isinstance(com_clusters, cdlib.classes.clustering.Clustering):\n com_clusters = [... | [
"0.69917107",
"0.66400284",
"0.6561251",
"0.6510797",
"0.63470906",
"0.5974687",
"0.5937347",
"0.5919538",
"0.59160763",
"0.5881239",
"0.5858356",
"0.58553314",
"0.5830493",
"0.58162296",
"0.5800447",
"0.5793978",
"0.57730776",
"0.57651776",
"0.5757485",
"0.5740799",
"0.57268... | 0.7029017 | 0 |
Plot the relation between two properties/fitness function of a clustering | def plot_com_properties_relation(
com_clusters: object,
com_fitness_x: Callable[[object, object, bool], object],
com_fitness_y: Callable[[object, object, bool], object],
**kwargs: dict
) -> object:
if isinstance(com_clusters, cdlib.classes.clustering.Clustering):
com_clusters = [com_clusters... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_com_stat(\n com_clusters: list, com_fitness: Callable[[object, object, bool], object]\n) -> object:\n if isinstance(com_clusters, cdlib.classes.clustering.Clustering):\n com_clusters = [com_clusters]\n\n allVals = []\n allNames = []\n for c in com_clusters:\n prop = com_fitnes... | [
"0.6681499",
"0.6602194",
"0.6204443",
"0.6165348",
"0.61467725",
"0.609327",
"0.60596406",
"0.60276634",
"0.60208607",
"0.6020466",
"0.60039204",
"0.591291",
"0.59104687",
"0.5889127",
"0.587141",
"0.5845387",
"0.5842687",
"0.5842687",
"0.5842687",
"0.5832414",
"0.5796505",
... | 0.6935457 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.