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 |
|---|---|---|---|---|---|---|
End setter. Raise exception if e position is nonexistent or occupied. | def end(self, e):
if e is not None:
if self.charMap[e[0]][e[1]].c in ["1", "3"]: # wall or start
print("[Error] Invalid end position.", file=sys.stderr)
raise UserInputException
try:
self.charMap[e[0]][e[1]] = CharMapCell(4)
ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end(self, end: pos.Pos) -> None:\n self.__end = end",
"def _set_end(self, coordinates):\n self._end = coordinates",
"def end(self) -> pos.Pos:\n return self.__end",
"def end (self):\n return self._end if self._end != self.inf else self.e",
"def end(self, end):\n\n sel... | [
"0.6942056",
"0.65282995",
"0.64921516",
"0.6274082",
"0.61936074",
"0.61936074",
"0.61936074",
"0.61865526",
"0.61027116",
"0.60362554",
"0.5967699",
"0.5932613",
"0.5924512",
"0.59088475",
"0.5858222",
"0.58360934",
"0.5801321",
"0.579298",
"0.579298",
"0.579298",
"0.578462... | 0.71403795 | 0 |
Reads map from file and save it at charMap attribute. Raise exception if map file is not found. | def read(self, filename):
try:
with open(filename) as f:
line = f.readline()
while line:
charLine = line.strip().split(',')
l = []
for c in charLine:
l.append(CharMapCell(c))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_map_file(filename):\n\n char_map = {}\n\n comment_pattern = r'#.*$'\n comment_regex = re.compile(comment_pattern)\n\n try:\n with open(filename) as mapfile:\n for line in mapfile:\n line = comment_regex.sub(\"\", line)\n line = line.strip()\n ... | [
"0.6719685",
"0.6276671",
"0.5967251",
"0.5937029",
"0.5818556",
"0.5798427",
"0.5779811",
"0.57254493",
"0.5720013",
"0.5699773",
"0.56770283",
"0.56561714",
"0.56312644",
"0.55790895",
"0.5568862",
"0.5544906",
"0.5523356",
"0.5522929",
"0.5499309",
"0.5497237",
"0.5479893"... | 0.70331043 | 0 |
Set cell as current for displaying reasons. | def set_current(self, cell):
if self.aux is not None:
self.charMap[self.aux[0]][self.aux[1]].is_current = False
self.aux = cell
self.charMap[cell[0]][cell[1]].is_current = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cell_change_current(self):\n\n # Add exception handling for case when new row is added to unmodified file to avoid crash\n try:\n if self.check_cell_change:\n row = self.csv_data_table.currentRow()\n col = self.csv_data_table.currentColumn()\n ... | [
"0.712428",
"0.6909218",
"0.6481031",
"0.64398044",
"0.6349584",
"0.62911284",
"0.62911284",
"0.6284106",
"0.60889435",
"0.6020969",
"0.5974405",
"0.5971483",
"0.59589314",
"0.594331",
"0.58936125",
"0.58742833",
"0.5872844",
"0.584892",
"0.58379185",
"0.5736245",
"0.57244974... | 0.7455061 | 0 |
Set all cells as not news for displaying reasons. | def clear_news(self):
for row in self.charMap:
for c in row:
c.is_new = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_cells(self):\n for index in range(0, 9):\n cell = getattr(self, 'cell_' + str(index))\n cell.config(state=DISABLED)",
"def cells_off(self):\n self.plotter.cells_off(self.ax)\n self.fig.canvas.draw()",
"def reset(self):\r\n self._cells = [ [0 for dum... | [
"0.63755906",
"0.5658254",
"0.55495757",
"0.55495477",
"0.5543785",
"0.55149907",
"0.55124176",
"0.549704",
"0.54951626",
"0.54830384",
"0.546032",
"0.5444433",
"0.54270226",
"0.53753173",
"0.537151",
"0.5365851",
"0.53350466",
"0.5330353",
"0.53057486",
"0.5303426",
"0.52900... | 0.6274183 | 1 |
Will perform the cv2 close operation on an image with a supplied kernel size. | def closeImage(aImg, aKernelSize):
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,
(aKernelSize, aKernelSize))
imgToClose = np.ndarray.copy(aImg)
return cv2.morphologyEx(imgToClose, cv2.MORPH_CLOSE, kernel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closing(img, kernel):\n return cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel)",
"def closing(img, kernel = (5,5)):\n\ttmp = grayscale(img)\n\tk = np.ones(kernel, np.uint8)\n\treturn cv2.morphologyEx(tmp, cv2.MORPH_CLOSE, k)",
"def morphologicalCloseImage(input_img, input_mode, stel=50, output_path=None)... | [
"0.71369916",
"0.70792645",
"0.671198",
"0.6522336",
"0.60474676",
"0.60404617",
"0.60299605",
"0.6013882",
"0.5999484",
"0.5999484",
"0.599614",
"0.599614",
"0.5957011",
"0.5887619",
"0.57013613",
"0.5606918",
"0.55500656",
"0.55485415",
"0.5494814",
"0.54410523",
"0.5425918... | 0.7415862 | 0 |
Takes a list of two ROI points and extracts the x,y pairs that makes up this ROI. | def xyFromROI(aROIPoints):
pt1 = aROIPoints[0]
pt2 = aROIPoints[1]
x0, y0 = pt1
x1, y1 = pt2
return x0, y0, x1, y1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def afficher_points_2D(set_points):\n X, Y = [p[0][0] for p in set_points], [p[0][1] for p in set_points]\n return(X, Y)",
"def convert_shapely_points_to_tuples(list_of_points) -> list:\n return [(p.x, p.y) for p in list_of_points]",
"def find_obstacle_loc(self, obstacle_list):\n\n x_obst =... | [
"0.66329336",
"0.6383057",
"0.6255719",
"0.62015814",
"0.61615396",
"0.6008022",
"0.6007293",
"0.5977887",
"0.5976967",
"0.59528244",
"0.5932191",
"0.5911589",
"0.59030205",
"0.5898188",
"0.5877641",
"0.586304",
"0.5857344",
"0.5854106",
"0.58280975",
"0.5813919",
"0.5803706"... | 0.73372746 | 0 |
Give blob and contour data and statistics for a supplied difference image. | def getBlobStatistics(aDiffImg):
# Avoid modifying original image, take a copy
diffToAnalyse = np.ndarray.copy(aDiffImg)
# Get the number of blobs present in the diff image
blobs, num_blobs = getBlobs(aDiffImg)
# Get the area of all blobs in picture
contours, hierarchy = cv2.findContours(diffT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_image_stats(self, image):\n ti = image\n image_data = ti.data\n if not ti.data:\n return ti\n ti.size = len(image_data)\n try:\n with connect(Blobby) as c:\n ti.shahash = c.get_data_bhash(image_data)\n except o.Exception, e... | [
"0.58736897",
"0.587175",
"0.5855929",
"0.57700926",
"0.57581383",
"0.5716692",
"0.5712425",
"0.5709784",
"0.56439084",
"0.55087656",
"0.5496739",
"0.5445337",
"0.5425442",
"0.5422044",
"0.53891593",
"0.5356671",
"0.5350178",
"0.5340862",
"0.53199863",
"0.5300444",
"0.5236212... | 0.6104837 | 0 |
Correctly update board with vertical capture | def test_makeCapture_vertical(self):
# Given
board = gamenode.GameNode()
startCoordinate = coordinate.Coordinate(4, 4)
captureCoordinate = coordinate.Coordinate(4, 5)
endCoordinate = coordinate.Coordinate(4, 6)
board.setState(startCoordinate, types.FOX)
board.setS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_board(board):",
"def _update_board(self):\n\n self.game_board.update_board(self.tetrino_set)",
"def update_board(self, mpos):\n pass",
"def update(match):\r\n \r\n \r\n coordinates= match.board\r\n \r\n rows=len(match.board)\r\n column=len(match.board[0])\r\n for x ... | [
"0.6425805",
"0.6328396",
"0.63144124",
"0.62630606",
"0.61620307",
"0.6100997",
"0.60915416",
"0.6063423",
"0.6010481",
"0.6000855",
"0.59570855",
"0.5950957",
"0.5938916",
"0.59062433",
"0.590119",
"0.589448",
"0.586444",
"0.5863165",
"0.58574224",
"0.58382803",
"0.583359",... | 0.6473007 | 0 |
Correctly handle capture over the same coordinate | def test_makeCapture_horizontal_same_coordinates(self):
# Given
board = gamenode.GameNode()
startCoordinate = coordinate.Coordinate(3, 3)
captureCoordinate = coordinate.Coordinate(3, 5)
board.setState(startCoordinate, types.FOX)
board.setState(captureCoordinate, types.GOO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapFrame(camera):\n return camera.read()[1]",
"def check_for_captures(self, selected_piece_coords, player):\n capture_coords = [] # a list of capture coords will be returned\n special_coords = [(0, 0), (0, 8), (8, 0), (8, 8), (4, 4)]\n neighbor_coords = [(selected_piece_coords[0]+1, sel... | [
"0.62073547",
"0.6043828",
"0.5825863",
"0.57963836",
"0.57198095",
"0.5678012",
"0.5608898",
"0.559589",
"0.5589825",
"0.55645317",
"0.55438054",
"0.5532692",
"0.5512359",
"0.5443185",
"0.53654444",
"0.536494",
"0.5356785",
"0.5356554",
"0.5350847",
"0.53404737",
"0.534016",... | 0.61416686 | 1 |
ReadConnectionFile parses file content | def test_readConnectionFile_parsing(self):
fake_data = ("3,1 1 3,2", "5,3 2 4,3")
with patch("builtins.open", mock_open(read_data="data")):
rules_obj = rules.Rules(test_mode=True)
actual_result = rules_obj.readConnectionFile("nonexistant_file",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(filename, conn):\n\n conn.send(open(filename).read())",
"def read_file(self):\n try:\n with open(self.file_name, 'r') as ach_file:\n file_contents = ach_file.read().replace('\\n', '').replace('\\r', '')\n\n self._parse_ach_file(file_contents)\n excep... | [
"0.6705614",
"0.663129",
"0.66100514",
"0.6560931",
"0.6560931",
"0.6504904",
"0.63073784",
"0.6230969",
"0.6161956",
"0.61591184",
"0.6083685",
"0.60218704",
"0.60149306",
"0.6009339",
"0.60074335",
"0.6005854",
"0.59724516",
"0.5966861",
"0.5955304",
"0.5914373",
"0.5902289... | 0.6774612 | 0 |
Connection line is properly parsed | def test_parseConnectionLine(self):
fake_connection = "5,3 2 4,3"
actual_result = rules.parseConnectionLine(fake_connection)
self.assertEqual(actual_result.startX, 5)
self.assertEqual(actual_result.startY, 3)
self.assertEqual(actual_result.direction, 2)
self.assertEqual(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse(self, line):\n comd, value = cmd.parse(line, CLIENT_PREFIX)\n if comd == 'reg':\n self.peername = value\n elif comd == 'eof':\n self._reset()\n msg = cmd.clientcmd(comd, value)\n msg = cmd.addFirst(msg, self.peername)\n self.sen... | [
"0.6803587",
"0.65556264",
"0.6434497",
"0.6407294",
"0.6296616",
"0.6289814",
"0.62807256",
"0.62698454",
"0.6261781",
"0.6125609",
"0.6038081",
"0.60051864",
"0.586589",
"0.58577013",
"0.58292764",
"0.5771236",
"0.5771236",
"0.5771236",
"0.5771236",
"0.5750047",
"0.57388276... | 0.67662257 | 1 |
IsACaptureP calls direction with correct args | def test_isACaptureP_direction_1(self, mock_captureHelper):
direction = 1
mock_captureHelper.return_value = True
rules_obj = rules.Rules(test_mode=True)
board = gamenode.GameNode()
foxCoordinate = coordinate.Coordinate(3, 3)
actual_result = rules_obj.isACaptureP(board, fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_isACaptureP_direction_2(self, mock_captureHelper):\n direction = 2\n mock_captureHelper.return_value = True\n rules_obj = rules.Rules(test_mode=True)\n board = gamenode.GameNode()\n foxCoordinate = coordinate.Coordinate(3, 3)\n actual_result = rules_obj.isACapture... | [
"0.7616921",
"0.74508667",
"0.74225676",
"0.7362415",
"0.7337908",
"0.73119944",
"0.73008204",
"0.7197092",
"0.7115965",
"0.67446953",
"0.59996974",
"0.5809121",
"0.5626506",
"0.559787",
"0.52908087",
"0.5219593",
"0.51766074",
"0.51409155",
"0.5096357",
"0.5073802",
"0.50342... | 0.7827176 | 0 |
IsACaptureP calls direction with correct args | def test_isACaptureP_direction_2(self, mock_captureHelper):
direction = 2
mock_captureHelper.return_value = True
rules_obj = rules.Rules(test_mode=True)
board = gamenode.GameNode()
foxCoordinate = coordinate.Coordinate(3, 3)
actual_result = rules_obj.isACaptureP(board, fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_isACaptureP_direction_1(self, mock_captureHelper):\n direction = 1\n mock_captureHelper.return_value = True\n rules_obj = rules.Rules(test_mode=True)\n board = gamenode.GameNode()\n foxCoordinate = coordinate.Coordinate(3, 3)\n actual_result = rules_obj.isACapture... | [
"0.7827176",
"0.74508667",
"0.74225676",
"0.7362415",
"0.7337908",
"0.73119944",
"0.73008204",
"0.7197092",
"0.7115965",
"0.67446953",
"0.59996974",
"0.5809121",
"0.5626506",
"0.559787",
"0.52908087",
"0.5219593",
"0.51766074",
"0.51409155",
"0.5096357",
"0.5073802",
"0.50342... | 0.7616921 | 1 |
IsACaptureP return False with a bad direction | def test_isACaptureP_bad_direction(self, mock_captureHelper):
mock_captureHelper.return_value = True
rules_obj = rules.Rules(test_mode=True)
board = gamenode.GameNode()
foxCoordinate = coordinate.Coordinate(3, 3)
direction = 20
actual_result = rules_obj.isACaptureP(board,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_existsCaptureP_no_capture(self, mock_isACaptureP):\n mock_isACaptureP.return_value = False\n rules_obj = rules.Rules(test_mode=True)\n foxOne = coordinate.Coordinate(5, 5)\n foxTwo = coordinate.Coordinate(3, 7)\n board = gamenode.GameNode()\n board.setState(foxOne... | [
"0.712023",
"0.7091089",
"0.7087022",
"0.6901648",
"0.6804134",
"0.67686427",
"0.67600137",
"0.67172676",
"0.6703477",
"0.6656205",
"0.6449109",
"0.5892749",
"0.5776631",
"0.5767976",
"0.57583785",
"0.5687516",
"0.568495",
"0.55937904",
"0.55921763",
"0.5576948",
"0.5561439",... | 0.78809065 | 0 |
When isACaptureP returns True, there must be a capture | def test_existsCaptureP_capture(self, mock_isACaptureP):
mock_isACaptureP.return_value = True
rules_obj = rules.Rules(test_mode=True)
foxOne = coordinate.Coordinate(5, 5)
foxTwo = coordinate.Coordinate(3, 7)
board = gamenode.GameNode()
board.setState(foxOne, types.FOX)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_existsCaptureP_no_capture(self, mock_isACaptureP):\n mock_isACaptureP.return_value = False\n rules_obj = rules.Rules(test_mode=True)\n foxOne = coordinate.Coordinate(5, 5)\n foxTwo = coordinate.Coordinate(3, 7)\n board = gamenode.GameNode()\n board.setState(foxOne... | [
"0.7213472",
"0.67100275",
"0.66877633",
"0.64083725",
"0.63236207",
"0.61772436",
"0.6169892",
"0.6114282",
"0.60935915",
"0.6044126",
"0.60277975",
"0.6020794",
"0.60195595",
"0.5987006",
"0.59656787",
"0.5963024",
"0.5920054",
"0.5840749",
"0.58303916",
"0.58218515",
"0.58... | 0.75167173 | 0 |
Return a dictionary of diffstat information for a diffset. | def diffstats(diffset):
counts = diffset.get_total_line_counts()
# TODO: Take into account the non raw counts review board might
# have to display information about replacement.
return {
'insert': counts.get('raw_insert_count', 0),
'delete': counts.get('raw_delete_count', 0),
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diffstat(self):\r\n url = '{0}/diffstat'.format(self.get_url())\r\n request = http.Request('GET', url)\r\n\r\n return request, parsers.parse_json",
"def diffstat(self):\n for diffstat in self._get_paged(\"diffstat\"):\n yield DiffStat(diffstat, **self._new_session_args)... | [
"0.70968556",
"0.666974",
"0.59959733",
"0.59312314",
"0.5841939",
"0.57571334",
"0.566059",
"0.5640931",
"0.563014",
"0.5592719",
"0.5575118",
"0.5567187",
"0.5483914",
"0.54734266",
"0.54181707",
"0.5389446",
"0.53859234",
"0.5384173",
"0.53651166",
"0.5353329",
"0.5309579"... | 0.8136382 | 0 |
Return a dictionary containing diffstat information. If no rev is provided, use the latest diffset. If the requesting user is the submitter, take any draft diffsets into account. | def get_diffstats(review_request, user, rev=None):
# Ensure we're working with the base review request, not a draft.
review_request = review_request.get_review_request()
if rev is None:
# If the user is the submitter we might want to use the draft diffset.
draft = review_request.get_draft(u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff(self, rev=None):\r\n args = []\r\n if rev is not None:\r\n args.append(\"-r %d\" % rev)\r\n out = self._authsvn('diff', args)\r\n return out",
"def diff(self, revision=None):\n if not revision:\n revision = Revision.latest_revision(self.instance)\... | [
"0.59980303",
"0.5838497",
"0.5777238",
"0.5759859",
"0.5542309",
"0.5527837",
"0.54685724",
"0.54519284",
"0.5437927",
"0.53403556",
"0.52737635",
"0.524713",
"0.52007115",
"0.52005863",
"0.51799476",
"0.51608956",
"0.51590776",
"0.51563096",
"0.5123263",
"0.51172936",
"0.51... | 0.74918723 | 0 |
Concatenate train set and test set, This may lead to data leakage, but we have to do that because some tricks suck as dummy code will be wrong | def ConcatDF(train_set, test_set):
df_all = pd.concat([train_set, test_set], sort=True).reset_index(drop=True)
df_all.trn_len = train_set.shape[0]
return df_all | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ConcatDF(train_set, test_set):\n return pd.concat([train_set, test_set], sort=True).reset_index(drop=True)",
"def get_training_and_testing_sets(data, Y):\r\n data = pd.concat([data, Y], axis=1)\r\n x,y=data.shape\r\n train_X_sub1=data[0:x//6]\r\n dev_X_sub1 = data[x//6:x//6 + x//12]\r\n tes... | [
"0.72702205",
"0.7119447",
"0.6611562",
"0.6522652",
"0.6515046",
"0.6469268",
"0.640398",
"0.6212674",
"0.6208587",
"0.6185535",
"0.6140687",
"0.60801977",
"0.59785014",
"0.59742194",
"0.59706175",
"0.59375256",
"0.5934598",
"0.593107",
"0.59287834",
"0.5923713",
"0.5889146"... | 0.7195508 | 1 |
Parses Conferences on wikicfp domain and follow links to actual conference page if link exists | def parse_wikicfp_page(self, response):
# Processing of individual CFP page within wikicfp
if re.search('cfp/servlet/event.showcfp', response.url): # Conference page
self.num_conf_crawled += 1
# Series information exists only for series crawl in wikicfp_all
response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_links(self, from_year):\n self.links = []\n self.titles = []\n self.speakers = []\n self.dates = []\n\n r = requests.get(self.calendar_url)\n soup = BeautifulSoup(r.text, \"html.parser\")\n\n if self.verbose:\n print(\"Getting links for press con... | [
"0.6242029",
"0.5957307",
"0.5563976",
"0.5432399",
"0.54143894",
"0.5413671",
"0.53456557",
"0.52990365",
"0.52787286",
"0.51410985",
"0.5128235",
"0.5118946",
"0.5101586",
"0.50898093",
"0.507496",
"0.5020961",
"0.49787804",
"0.49642515",
"0.4960764",
"0.4945461",
"0.494287... | 0.6074987 | 1 |
pick houses from self.env_set | def _pick_envs_to_load(self, split, max_envs, start_idx, in_order):
if split in ['val', 'test'] or in_order:
pruned_env_set = self.env_set[start_idx:start_idx+max_envs] # could be void if start_idx arrives end
else:
if max_envs < len(self.env_set):
env_inds = np.random.choice(len(self.env_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_households(self, attr, old, new):\n index = new[0]\n school_id = self.data.iloc[index].school_id\n # List all agents that have the same school id\n same_school = self.data[self.data.school_id == school_id].index\n self.source.selected.indices = list(same_school)",
"d... | [
"0.53169477",
"0.5086531",
"0.50442874",
"0.5043684",
"0.5027562",
"0.501078",
"0.50006616",
"0.4983505",
"0.4892833",
"0.48900834",
"0.4887874",
"0.48799852",
"0.48696637",
"0.4855021",
"0.48342144",
"0.48321876",
"0.48022148",
"0.47826496",
"0.47820404",
"0.47569978",
"0.47... | 0.5894043 | 0 |
idx qid, house question, answer qe, ae type attr path_ix nav_ids nav_types nav_ego_feats navs of (l, 3200) float32 nav_action_inputs navs of (l, ) int64 nav_action_outputs navs of (l, ) int64 nav_ego_imgs navs of (l, 224, 224, 3) uint8 if necessary | def __getitem__(self, index):
idx = self.available_idx[index]
qn = self.questions[idx]
qid = qn['id']
house = qn['house']
attr, room_attr = self.question_to_attribute(qn)
# encode question and answer
qe = self.encoded_questions[qn['h5_id']]
ae = self.encoded_questions[qn['h5_id']]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_paths(data, relation_level_words, qald=False,goldorpred='gold'):\n abstract_question = data[goldorpred]['abstract_question'].replace('<e>', 'entity1').replace('<l>', 'literal1')\n question = ei.vocabularize(nlutils.tokenize(abstract_question))\n\n \"\"\"======\"\"\"\n question_dep = []\n ... | [
"0.47627646",
"0.47548252",
"0.4704405",
"0.466417",
"0.46623504",
"0.4603262",
"0.45375147",
"0.45369682",
"0.45208377",
"0.4509831",
"0.4502285",
"0.449974",
"0.44854072",
"0.44819766",
"0.4477061",
"0.44590774",
"0.44526723",
"0.44371733",
"0.4418434",
"0.44158706",
"0.440... | 0.667768 | 0 |
this testcase proves that for list object '==' checks equality based on content checking, rather that reference checking | def testEquality(self):
list1 = [1,2]
list2 = [1,2]
# not the same object
self.assertIsNot(list1,list2)
self.assertNotEqual(id(list1),id(list2))
self.assertFalse(list1 is list2)
# but content is equal
self.assertEqual(list1,list2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_identity(self):\n pass",
"def check_lists_equal( list1, list2, assertobject ):\n assertEqualsImproved( len( list1 ), len( list2 ), assertobject )\n for element in list1:\n assertobject.assertIn( element, list2 )",
"def testMutable(self):\n alist = [1,2,3]\n aref = alist\... | [
"0.71370006",
"0.7099526",
"0.6874867",
"0.6859387",
"0.6776912",
"0.6727213",
"0.6631619",
"0.65954477",
"0.6538188",
"0.6502381",
"0.6497191",
"0.6493001",
"0.6463698",
"0.6459172",
"0.64429367",
"0.6437611",
"0.6419223",
"0.6414189",
"0.63548326",
"0.6349761",
"0.6301157",... | 0.7994808 | 0 |
Return an operator given the path to a database. | def loadOperator(pathToDb, loadCycle, loadNode, allowMissing=False):
# `import armi` doesn't work if imported at top
from armi import cases
if not os.path.exists(pathToDb):
raise ValueError(
f"Specified database at path {pathToDb} does not exist. \n\n"
"Double check that esc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operator(self):\n col = self.pos\n operators = [\"||\", \"&&\", \">>\", \"<<\", \"!=\", \">=\", \"<=\", \"==\", \"##\"] + \\\n [\"-\", \"+\", \"!\", \"*\", \"/\", \"|\", \"&\", \"^\", \"<\", \">\", \"?\", \":\", \"~\", \"#\", \"=\", \"%\"]\n try:\n index = self.match_... | [
"0.5361934",
"0.5345323",
"0.52730507",
"0.5133861",
"0.51303923",
"0.5125685",
"0.5095104",
"0.5086308",
"0.5076296",
"0.50663847",
"0.504918",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
... | 0.5978742 | 0 |
Convert database files between different versions. | def convertDatabase(
inputDBName: str,
outputDBName: Optional[str] = None,
outputVersion: Optional[str] = None,
nodes: Optional[List[Tuple[int, int]]] = None,
):
dbIn = databaseFactory(inputDBName, permission=Permissions.READ_ONLY_FME)
if dbIn.version == outputVersion:
runLog.important(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upgradedb(self, args):\n upgrade_db(args.dbfile)",
"def _convert_rosetta_db_to_basic_db(self):\n pass",
"def migrate(ctx, start_version, end_version):\n if ctx.obj['TYPE'] == 'file':\n if ctx.obj['DATA_FILE']:\n file_path = ctx.obj['DATA_FILE']\n else:\n ... | [
"0.63407254",
"0.6322698",
"0.61341935",
"0.60159844",
"0.57008606",
"0.567188",
"0.56600946",
"0.56428075",
"0.56238115",
"0.55924803",
"0.5589563",
"0.5580526",
"0.55748826",
"0.5569592",
"0.556925",
"0.55508006",
"0.5528553",
"0.55067235",
"0.5505626",
"0.54876965",
"0.547... | 0.68520933 | 0 |
Return the underlying h5py File that provides the backing storage for a database. This is done here because HDF5 isn't an official aspect of the base Database abstraction, and thus making this part of the base Database class interface wouldn't be ideal. However, we violate this assumption when working with "auxiliary" ... | def _getH5File(db):
if isinstance(db, Database3):
return db.h5db
else:
raise TypeError("Unsupported Database type ({})!".format(type(db))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_db(self):\n # if it is not open, open it.\n if self.h5file.isopen is True:\n return self.h5file\n else:\n self.h5file = tb.open_file(filename=self.filepath, mode='a')\n assert self.h5file.isopen\n return self.h5file",
"def hdf5_file(self):\n ... | [
"0.63894004",
"0.6325323",
"0.5979841",
"0.5845819",
"0.5709331",
"0.5573591",
"0.55464363",
"0.5419186",
"0.5413009",
"0.5404134",
"0.5402279",
"0.5396553",
"0.5393392",
"0.53786933",
"0.53507555",
"0.5344345",
"0.5339578",
"0.5317838",
"0.5294479",
"0.5289991",
"0.52769095"... | 0.72821635 | 0 |
Load magnitude of scattering vector, q, and intensity, I, data (and potentially error in I) from file and filter for values between q_min and q_max. | def load_scatter_curve(filename, q_min, q_max):
try:
scatter_data = read_sas_file(filename)
except:
print("Unable to load " + filename)
print("Check that the file exists, and contains lines with at least two columns of numberical data\n")
sys.exit(1)
qrange_mask = (scat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadDataFile(self, filename):\n self.magneticfield = MagneticField(filename)\n self._meqfile = filename\n\n wallR, wallZ = self.magneticfield.getWall()\n\n self.rmin, self.rmax = np.amin(wallR), np.amax(wallR)\n self.zmin, self.zmax = np.amin(wallZ), np.amax(wallZ)",
"def r... | [
"0.5680521",
"0.5428513",
"0.5353534",
"0.5295121",
"0.5253234",
"0.5213317",
"0.5192037",
"0.5187126",
"0.5159289",
"0.5138375",
"0.5130577",
"0.5127485",
"0.5093703",
"0.5088959",
"0.50883",
"0.50879556",
"0.5084919",
"0.5079182",
"0.50727534",
"0.5027459",
"0.5026445",
"... | 0.6320465 | 0 |
Read in a list of scattering curve files and return a list of dictionaries which contain the file name ('file'), an array of Q and I(Q) vales ('data'), the radius of gyration ('rg') and the crosssection ('rxs1'). | def read_scatter_curves(curve_files, units, param):
curves = []
for curve_file in curve_files:
curve = {}
curve['file'] = curve_file
# Read in the scattering curve
# Modeling is performed in angstroms so convert files in nm to a
if units == 'nm':
curve['da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_from_sc_file(axes, f, uf, true_max):\n f_combo_dict = collections.defaultdict(list)\n uf_combo_dict = collections.defaultdict(list)\n max_x = -10000\n max_y = -10000\n min_x = 10000\n min_y = 10000\n\n for fileType in [uf, f]:\n for i, item in enumerate(fileType):\n ... | [
"0.62675303",
"0.6176889",
"0.6142395",
"0.58858454",
"0.5876028",
"0.5847257",
"0.5815131",
"0.58049107",
"0.5796159",
"0.57542104",
"0.57402223",
"0.5739488",
"0.57298195",
"0.5717066",
"0.57040155",
"0.5665045",
"0.5653632",
"0.5630872",
"0.56305236",
"0.56249666",
"0.5598... | 0.72098076 | 0 |
Load yaml file containing the ranges for all analyses. | def process_qrange_file(filename):
f = open(filename, 'r')
q_ranges = yaml.load(f)
return q_ranges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_yaml_file(self, path):\n with path.open('r') as handle:\n data = load_yaml(handle)\n\n self.set_all(**self.SCHEMA.load(data).data)",
"def load_yaml(self):\n env = self.state.document.settings.env\n relpath, abspath = env.relfn2path(directives.path(self.arguments[0]... | [
"0.63422006",
"0.57995796",
"0.5766984",
"0.574815",
"0.573764",
"0.57361096",
"0.5614416",
"0.5582548",
"0.5572529",
"0.5568093",
"0.5553858",
"0.5536593",
"0.54736644",
"0.5459305",
"0.538914",
"0.53844225",
"0.53229624",
"0.53033197",
"0.52961624",
"0.52952296",
"0.5284542... | 0.68835 | 0 |
Match two scatter curves. Get intensity, I, values from one data set at the q (scaterring vector magnitude) values present in the other. Input is two q vs I scattering curves. Output is I values from the source data set matched to the q values of the target set. | def match_scatter_curves(target_data, source_data):
# Create list of calculated I values matched to the nearest experimental q
# Remember that the arrays in python start at 0, those in Fortran at 1
last_source = len(source_data)
last_target = len(target_data)
# Initialize array to hold the calcula... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_curves(target_data, source_data, q_min, q_max, chi2):\n\n if chi2:\n rfactor, scale = calculate_chi2(target_data, source_data, q_min, q_max)\n else:\n rfactor, scale = calculate_rfactor(\n target_data, source_data, q_min, q_max)\n\n return rfactor, scale",
"def calcu... | [
"0.56384337",
"0.5514092",
"0.5465273",
"0.5464144",
"0.54291075",
"0.54191035",
"0.5410992",
"0.5403209",
"0.53972155",
"0.5342674",
"0.53372824",
"0.532874",
"0.5325885",
"0.5307892",
"0.5297777",
"0.5290474",
"0.52871025",
"0.5279677",
"0.52782655",
"0.5225266",
"0.5209964... | 0.7495544 | 0 |
Compute comparison metric (R factor or Chi^2). Input is two q vs I scattering curves and the min/max q values to use to compare them. The target (experimental) curve is scaled to match the source (theoretical) one. This is because the theoretical curve is based on a calculation of I/Io. Output is the R factor and the s... | def compare_curves(target_data, source_data, q_min, q_max, chi2):
if chi2:
rfactor, scale = calculate_chi2(target_data, source_data, q_min, q_max)
else:
rfactor, scale = calculate_rfactor(
target_data, source_data, q_min, q_max)
return rfactor, scale | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_rfactor(target_data, source_data, q_min, q_max):\n\n matched_source_I = match_scatter_curves(target_data, source_data)\n\n # Get average I for experimental and calculated values over matched q range\n matched_no = len(matched_source_I)\n expt_avg = np.mean(target_data[0:matched_no, 1])\n ... | [
"0.68376523",
"0.6492629",
"0.55108064",
"0.5445589",
"0.5386808",
"0.5345272",
"0.53385323",
"0.52746767",
"0.52524316",
"0.52124363",
"0.51650137",
"0.5163609",
"0.51559365",
"0.5129782",
"0.5114901",
"0.51110995",
"0.50248575",
"0.50235295",
"0.5023434",
"0.5019229",
"0.50... | 0.79531777 | 0 |
Compute R factor comparing two scattering curves. Input is two q vs I scattering curves and the min/max q values to use to compare them. The target (experimental) curve is scaled to match the source (theoretical) one. This is because the theoretical curve is based on a calculation of I/Io. Output is the R factor and th... | def calculate_rfactor(target_data, source_data, q_min, q_max):
matched_source_I = match_scatter_curves(target_data, source_data)
# Get average I for experimental and calculated values over matched q range
matched_no = len(matched_source_I)
expt_avg = np.mean(target_data[0:matched_no, 1])
calc_avg ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_curves(target_data, source_data, q_min, q_max, chi2):\n\n if chi2:\n rfactor, scale = calculate_chi2(target_data, source_data, q_min, q_max)\n else:\n rfactor, scale = calculate_rfactor(\n target_data, source_data, q_min, q_max)\n\n return rfactor, scale",
"def calcu... | [
"0.7753233",
"0.58153874",
"0.5712545",
"0.53757167",
"0.5279661",
"0.52676696",
"0.52249604",
"0.51984113",
"0.5190254",
"0.51797056",
"0.5145067",
"0.5140006",
"0.5114124",
"0.510577",
"0.5075585",
"0.5032694",
"0.502384",
"0.5012232",
"0.49598452",
"0.4957949",
"0.4931579"... | 0.68906873 | 1 |
Compute Chi^2 comparing two scattering curves. Input is two q vs I scattering curves and the min/max q values to use to compare them. The target (experimental) curve is scaled to match the source (theoretical) one. This is because the theoretical curve is based on a calculation of I/Io. Output is the Chi^2 and the scal... | def calculate_chi2(target_data, source_data, q_min, q_max):
matched_source_I = match_scatter_curves(target_data, source_data)
# Get average I for experimental and calculated values over matched q
# range
matched_no = len(matched_source_I)
expt_avg = np.mean(target_data[0:matched_no, 1])
calc_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_curves(target_data, source_data, q_min, q_max, chi2):\n\n if chi2:\n rfactor, scale = calculate_chi2(target_data, source_data, q_min, q_max)\n else:\n rfactor, scale = calculate_rfactor(\n target_data, source_data, q_min, q_max)\n\n return rfactor, scale",
"def calcu... | [
"0.72039247",
"0.5903445",
"0.5728763",
"0.5679894",
"0.56745183",
"0.563039",
"0.5551781",
"0.5550915",
"0.5501156",
"0.5463921",
"0.5455437",
"0.5452026",
"0.5440274",
"0.54046345",
"0.5401157",
"0.5397274",
"0.5318091",
"0.53127307",
"0.5302951",
"0.52710074",
"0.52679455"... | 0.7524854 | 0 |
Linear fit x vs y data. calc_type (rg, rxs1, rxs2) determines value computed from gradient and intercept in Guinier and other analyses of small angle scattering curves. | def sas_curve_fit(x, y, calc_type):
result = {}
n = len(x)
if (n == 0) or (len(y) == 0):
err = "Error: No values to fit in " + calc_type + " calculation\n"
raise Exception(err)
#result['error'] = err
else:
# Linear fit to the input x and y values
#fit_coeffs = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linearfit_s1(x, y):\r\n x *= N.ones(1); y *= N.ones(1)\r\n mx = N.mean(x); my = N.mean(y)\r\n slope = 1.; yint = my-mx\r\n rl_slope, sd_slope, rl_yint, sd_yint, s_yint, cov = robust_linefit(x, y)\r\n \r\n return slope, sd_slope, yint, sd_yint, s_yint, cov",
"def linear_regression(self, x_da... | [
"0.64826363",
"0.6309423",
"0.6292486",
"0.6138011",
"0.6078534",
"0.59990513",
"0.59841806",
"0.5863627",
"0.5851407",
"0.58428884",
"0.5836996",
"0.5771239",
"0.5766344",
"0.5713542",
"0.56316483",
"0.5586694",
"0.55863845",
"0.55366975",
"0.5526817",
"0.5521595",
"0.55129"... | 0.7035865 | 0 |
Calculate the Rg and Rxs1 from linear fits to the functions of the input curve values (q, I). In the case of Rg the Guinier fit is to q^2 vs ln(I), for Rxs1 it is to q^2 vs ln(Iq). | def get_curve_descriptors(curve, rg_min, rg_max, rxs1_min, rxs1_max, *args):
# Fitting is performed on:
# q^2 vs ln(I) for Rg
# q^2 vs ln(I*q) for Rxs
x = curve[:, 0] ** 2
y_rg = np.log(curve[:, 1])
y_rxs = np.log(curve[:, 1] * curve[:, 0])
# Create mask to select range of q values for Rg ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sas_curve_fit(x, y, calc_type):\n\n result = {}\n\n n = len(x)\n\n if (n == 0) or (len(y) == 0):\n err = \"Error: No values to fit in \" + calc_type + \" calculation\\n\"\n raise Exception(err)\n #result['error'] = err\n else:\n # Linear fit to the input x and y values\n... | [
"0.605578",
"0.5877867",
"0.5832726",
"0.5832662",
"0.57186884",
"0.5693924",
"0.56421226",
"0.5623981",
"0.5517047",
"0.54979545",
"0.549774",
"0.54974747",
"0.54570127",
"0.5453601",
"0.541977",
"0.5409155",
"0.5367099",
"0.53388757",
"0.53322685",
"0.532931",
"0.5319078",
... | 0.5903254 | 1 |
RPC call, returns a list of tuples with sensors database (identifier, instant, activated, module name, description) | def listSensors(self, module=None):
if module:
try:
sensors = self.db.getModuleSensors(self.db.getModule(module))
except DoesNotExist:
return None
else:
sensors = self.db.getSensors()
# convert to list of tuples
return [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sensors():\n sensor_data = query_db('SELECT * FROM sensors')\n return jsonify(results=sensor_data)",
"def GET_sensors(self):\n self.sensors.GetAll()\n self.sensors.sensors['charging-state'] = \\\n pyrobot.CHARGING_STATES[self.sensors.sensors['charging-state']]\n print simplejson.dumps(sel... | [
"0.6393391",
"0.6253768",
"0.59395397",
"0.593439",
"0.5932335",
"0.58385205",
"0.56590295",
"0.5607915",
"0.5571273",
"0.5545934",
"0.54861724",
"0.54751205",
"0.5471921",
"0.546852",
"0.54496706",
"0.5435644",
"0.53989005",
"0.53935105",
"0.53745294",
"0.53367937",
"0.53067... | 0.6304722 | 1 |
RPC api call, lists all arguments of a sensor | def listSensorArgs(self, sensor=None):
returnvalue = None
if not sensor:
pass
else:
sensor = self.db.getSensorByIdent(sensor)
returnvalue = self.db.getSensorDict(sensor)
return returnvalue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpc_info():",
"def rpc(self) -> global___Rpc:",
"def calls_cmd(args):\n r = requete(\"VoiceService.VoiceApplication:getCallList\")\n if r is None or not 'status' in r:\n return\n\n r = r['status']\n if len(args) == 1 and args[0] == '?':\n return print(r[0].... | [
"0.6629112",
"0.59871316",
"0.57738215",
"0.57366514",
"0.5699133",
"0.5685285",
"0.5684429",
"0.5664077",
"0.56445086",
"0.54334176",
"0.5389509",
"0.5366804",
"0.53633016",
"0.5363134",
"0.5350959",
"0.53481513",
"0.5347571",
"0.533289",
"0.5327297",
"0.53271383",
"0.531899... | 0.62036693 | 1 |
Parse a $$math$$ block | def parse_block_math(self, m):
self.tokens.append({
'type': 'block_math',
'text': m.group(1)
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_math_cmd(self, line):\n self.E_str = \"parse_math_cmd\"\n line = line.strip()\n\n new_var_name, metadata_name = self.get_variable_name(line)\n\n # Split the line by =\n words = line.split('=')\n _, maths = words\n maths = maths.replace(\"$\", \"\")\n ... | [
"0.6627344",
"0.6515901",
"0.6399946",
"0.6230076",
"0.6224127",
"0.61547863",
"0.6136919",
"0.61289555",
"0.6112584",
"0.60356355",
"0.5937152",
"0.5899705",
"0.5892373",
"0.5864457",
"0.58395207",
"0.58043087",
"0.5791234",
"0.5728444",
"0.5706931",
"0.5688357",
"0.5681846"... | 0.78205043 | 0 |
`execute` must be implemented in every Python model. `execute` function receives a list of pb_utils.InferenceRequest as the only argument. This function is called when an inference is requested for this model. Depending on the batching configuration (e.g. Dynamic Batching) used, `requests` may contain multiple requests... | def execute(self, requests):
responses = []
for request in requests:
infer_outputs = pb_utils.get_input_tensor_by_name(
request, self.input_names[0])
im_infos = pb_utils.get_input_tensor_by_name(request,
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ExecuteBatch(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def ExecuteBatch(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n conte... | [
"0.6375495",
"0.6375495",
"0.6048663",
"0.59890074",
"0.5898378",
"0.5888777",
"0.5833882",
"0.5833882",
"0.5737521",
"0.5663895",
"0.5434578",
"0.5345063",
"0.5344431",
"0.5314354",
"0.527206",
"0.52704257",
"0.52529854",
"0.52165484",
"0.5213345",
"0.52020395",
"0.52017784"... | 0.64383364 | 0 |
Generate a WMI base a specific marker Trace marker is used to identify the underlying object | def wmi_trace_marker(marker: Enum) -> Struct:
return Struct(
"version" / Int16ul,
"type" / check_enum(marker),
"flags" / Const(0xc0, Int8ul)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return f\"Marker at {super().__repr__()}\"",
"def __repr__(self):\n return f\"Marker at {super().__repr__()}\"",
"def get_reflect_marker(self):\r\n return Marker((255, 255, 255), self._screen)",
"def export_base(self):\n \n return (self.typ + \" no \" + str... | [
"0.60454005",
"0.60230863",
"0.5618681",
"0.53838336",
"0.53631455",
"0.53274184",
"0.52811784",
"0.52787894",
"0.5269781",
"0.5246951",
"0.5200085",
"0.51915157",
"0.5154832",
"0.5153821",
"0.51111484",
"0.51029664",
"0.50822985",
"0.50801104",
"0.50572926",
"0.50393933",
"0... | 0.6092112 | 0 |
Configures correct locations for this arena | def configure_location(self):
# Set floor correctly
self.floor.set("pos", array_to_string(self.bottom_pos)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_locations():\n STATUS['locations']['monster'][0] = generate_random_coord(STATUS['grid_size'])\n STATUS['locations']['monster'][1] = generate_random_coord(STATUS['grid_size'])\n STATUS['locations']['weapon'][0] = generate_random_coord(STATUS['grid_size'])\n STATUS['locations']['weapon'][1] = gen... | [
"0.5902864",
"0.5788083",
"0.566627",
"0.5588298",
"0.55418116",
"0.55088085",
"0.5442755",
"0.54118943",
"0.53610355",
"0.53148246",
"0.53037614",
"0.5274148",
"0.5269604",
"0.5227204",
"0.52206093",
"0.5210463",
"0.52102774",
"0.51957375",
"0.51864976",
"0.51828134",
"0.517... | 0.6191456 | 0 |
Read dense Jester dataset and split train/test data randomly. | def read_jester_data(fname='jester-dense-subset-100x20.csv'):
logging.info('reading data')
try:
data = pd.read_csv(fname)
except IOError as err:
print str(err)
url = 'https://gist.github.com/macks22/b40ac9c685e920ad3ca2'
print 'download from: %s' % url
sys.exit(DATA_N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_train_test_split():\n # Load all documents\n conn = sq.connect(config.DB_FILE)\n documents = pd.read_sql_query('select pubmed_id, review_id, included, title, abstract from article ', conn)\n\n # Identify unique review IDs\n review_ids = documents['review_id'].unique()\n\n # Set seed for random sampli... | [
"0.6528886",
"0.64985585",
"0.6490711",
"0.64342165",
"0.6429354",
"0.6394741",
"0.6342159",
"0.6324972",
"0.6307256",
"0.62858176",
"0.6265146",
"0.6257298",
"0.6205019",
"0.620443",
"0.6178737",
"0.6150126",
"0.611777",
"0.60921246",
"0.60828966",
"0.6066437",
"0.60641325",... | 0.74138194 | 0 |
Construct the Probabilistic Matrix Factorization model using pymc3. Note that the `testval` param for U and V initialize the model away from 0 using a small amount of Gaussian noise. | def build_pmf_model(train, alpha=2, dim=10, std=0.01):
# Mean value imputation on training data.
train = train.copy()
nan_mask = np.isnan(train)
train[nan_mask] = train[~nan_mask].mean()
# Low precision reflects uncertainty; prevents overfitting.
# We use point estimates from the data to intial... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_test(nu, fsigma_T, fsigma_P, models_in, amps_in, params_in, models_fit, label):\n # Generate fake data with some \"true\" parameters\n (D_vec, Ninv) = gen_data(nu, fsigma_T, fsigma_P, models_in, amps_in, params_in)\n Ninv_sqrt = np.matrix(linalg.sqrtm(Ninv))\n (dust_params, sync_params, cmb_p... | [
"0.56138206",
"0.5586942",
"0.55433214",
"0.5351772",
"0.529997",
"0.52595276",
"0.5223859",
"0.5215091",
"0.52088547",
"0.5177972",
"0.51590854",
"0.50957006",
"0.5061981",
"0.5017527",
"0.49781993",
"0.49613118",
"0.49568832",
"0.4943264",
"0.4940687",
"0.49263063",
"0.4922... | 0.6167692 | 0 |
Build the original BPMF model, which we cannot sample from due to current limitations in pymc3's implementation of the Wishart distribution. | def build_bpmf_model(train, alpha=2, dim=10, std=0.01):
n, m = train.shape
beta_0 = 1 # scaling factor for lambdas; unclear on its use
# Mean value imputation on training data.
train = train.copy()
nan_mask = np.isnan(train)
train[nan_mask] = train[~nan_mask].mean()
logging.info('building... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_mod_bpmf_model(train, alpha=2, dim=10, std=0.01):\n n, m = train.shape\n beta_0 = 1 # scaling factor for lambdas; unclear on its use\n\n # Mean value imputation on training data.\n train = train.copy()\n nan_mask = np.isnan(train)\n train[nan_mask] = train[~nan_mask].mean()\n\n # We... | [
"0.72188264",
"0.61532706",
"0.6023628",
"0.5833241",
"0.5797192",
"0.5724574",
"0.5723442",
"0.5719858",
"0.5715735",
"0.56933236",
"0.56768894",
"0.56603485",
"0.56331044",
"0.5607353",
"0.55702585",
"0.55379814",
"0.55144966",
"0.5503024",
"0.5484061",
"0.5476444",
"0.5475... | 0.7269002 | 0 |
Build the modified BPMF model using pymc3. The original model uses Wishart priors on the covariance matrices. Unfortunately, the Wishart distribution in pymc3 is currently not suitable for sampling. This | def build_mod_bpmf_model(train, alpha=2, dim=10, std=0.01):
n, m = train.shape
beta_0 = 1 # scaling factor for lambdas; unclear on its use
# Mean value imputation on training data.
train = train.copy()
nan_mask = np.isnan(train)
train[nan_mask] = train[~nan_mask].mean()
# We will use sepa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_bpmf_model(train, alpha=2, dim=10, std=0.01):\n n, m = train.shape\n beta_0 = 1 # scaling factor for lambdas; unclear on its use\n\n # Mean value imputation on training data.\n train = train.copy()\n nan_mask = np.isnan(train)\n train[nan_mask] = train[~nan_mask].mean()\n\n logging.... | [
"0.6512337",
"0.60092825",
"0.567834",
"0.5658303",
"0.55903035",
"0.5580925",
"0.5573696",
"0.5532462",
"0.55020326",
"0.5474026",
"0.54726166",
"0.54643524",
"0.54269475",
"0.5414196",
"0.5403196",
"0.5379074",
"0.537768",
"0.53350365",
"0.5313411",
"0.52971154",
"0.5286176... | 0.6656812 | 0 |
Check if a line is header. | def _is_header(line):
line = line.strip()
if line.startswith('#') or line.startswith('track') or line.startswith(
'browser'): # BED header
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_header(line):\n return line[0] == '>'",
"def check_header(line):\n if line[:7] == '###### ':\n line = '<h6>' + line[7:] + '</h6>'\n elif line[:6] == '##### ':\n line = '<h5>' + line[6:] + '</h5>'\n elif line[:5] == '#### ':\n line = '<h4>' + line[5:] + '</h4>'\n elif li... | [
"0.90293974",
"0.79356164",
"0.7800237",
"0.7654996",
"0.7427677",
"0.7177651",
"0.71695125",
"0.7159226",
"0.7146845",
"0.7069064",
"0.70204705",
"0.70001435",
"0.69541633",
"0.6851527",
"0.68049",
"0.66462415",
"0.66202724",
"0.6611603",
"0.6611603",
"0.64868945",
"0.648689... | 0.8483625 | 1 |
Get proper read parser for the given format. | def get_read_parser(format):
format = format.lower()
if format == 'bed':
return BedReadParser
elif format == 'bedpe':
return BedPeReadParser
elif format == 'sam':
return SamReadParser
elif format == 'bam':
return BamReadParser
else:
raise ValueError(f"unkn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_parser(filepath, cfg):\n if not os.path.isfile(filepath):\n LOG.error('File not found: %s', filepath)\n return\n valid_parsers = importer.get_parsers(filepath, cfg)\n if not valid_parsers:\n LOG.error('No parsers found for file: %s', filepath)\n return\n\n if len(va... | [
"0.6131928",
"0.60937136",
"0.6045996",
"0.58665407",
"0.58590126",
"0.5809873",
"0.58025086",
"0.57651305",
"0.5758732",
"0.57091504",
"0.5667895",
"0.5651484",
"0.56421953",
"0.5586466",
"0.55685693",
"0.5534864",
"0.5503993",
"0.54882073",
"0.54529166",
"0.54084545",
"0.53... | 0.88633776 | 0 |
Test job addition and exist check | def test_job_exists():
with tempfile.TemporaryDirectory() as STATUS_DIR:
Status.add_job(STATUS_DIR, 'generation', 'test1',
job_attrs={'job_status': 'submitted'})
exists = Status.job_exists(STATUS_DIR, 'test1')
assert exists | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_job_addition():\n with tempfile.TemporaryDirectory() as STATUS_DIR:\n Status.add_job(STATUS_DIR, 'generation', 'test1')\n status1 = Status(STATUS_DIR).data['generation']['test1']['job_status']\n\n Status.add_job(STATUS_DIR, 'generation', 'test1',\n job_attrs={... | [
"0.72872704",
"0.7204852",
"0.68101156",
"0.66714615",
"0.6622515",
"0.66078657",
"0.6596242",
"0.65822595",
"0.6559245",
"0.64998597",
"0.64640236",
"0.6440778",
"0.64162385",
"0.6409369",
"0.63889015",
"0.6380754",
"0.63741344",
"0.6320242",
"0.62653357",
"0.62551504",
"0.6... | 0.7668623 | 0 |
Test job addition and exist check | def test_job_addition():
with tempfile.TemporaryDirectory() as STATUS_DIR:
Status.add_job(STATUS_DIR, 'generation', 'test1')
status1 = Status(STATUS_DIR).data['generation']['test1']['job_status']
Status.add_job(STATUS_DIR, 'generation', 'test1',
job_attrs={'job_status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_job_exists():\n with tempfile.TemporaryDirectory() as STATUS_DIR:\n Status.add_job(STATUS_DIR, 'generation', 'test1',\n job_attrs={'job_status': 'submitted'})\n exists = Status.job_exists(STATUS_DIR, 'test1')\n assert exists",
"def test_matching_jobs_existin... | [
"0.7668623",
"0.7204852",
"0.68101156",
"0.66714615",
"0.6622515",
"0.66078657",
"0.6596242",
"0.65822595",
"0.6559245",
"0.64998597",
"0.64640236",
"0.6440778",
"0.64162385",
"0.6409369",
"0.63889015",
"0.6380754",
"0.63741344",
"0.6320242",
"0.62653357",
"0.62551504",
"0.62... | 0.72872704 | 1 |
Test job addition and replacement | def test_job_replacement():
with tempfile.TemporaryDirectory() as STATUS_DIR:
Status.add_job(STATUS_DIR, 'generation', 'test1',
job_attrs={'job_status': 'submitted'})
Status.add_job(STATUS_DIR, 'generation', 'test1',
job_attrs={'addition': 'test',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_job_addition():\n with tempfile.TemporaryDirectory() as STATUS_DIR:\n Status.add_job(STATUS_DIR, 'generation', 'test1')\n status1 = Status(STATUS_DIR).data['generation']['test1']['job_status']\n\n Status.add_job(STATUS_DIR, 'generation', 'test1',\n job_attrs={... | [
"0.726686",
"0.6905744",
"0.6609184",
"0.6590907",
"0.64921033",
"0.6491962",
"0.6479421",
"0.6470252",
"0.6433977",
"0.63717645",
"0.6351452",
"0.63509756",
"0.62832236",
"0.62299746",
"0.6220371",
"0.62189835",
"0.6209426",
"0.620375",
"0.6172135",
"0.61520845",
"0.61494327... | 0.7602344 | 0 |
First, it finds the total amount of contacts for each listing_id. Second, it finds the top most contacted listings. | def find_top_five_most_contacted_listings_per_month(self):
available_dates = self.contacts.quer_distinct_components("contact_date", "Contacts")
available_listing_ids = self.contacts.quer_distinct_components("listing_id", "Contacts")
self.ordered = {}
for date in available_dates:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_listings(self):\n listing_ids = self.context.listing_ids\n if len(listing_ids) == 0:\n return\n listing_ids = [lid.lower() for lid in listing_ids]\n params = {\n 'limit': 0,\n 'offset': 0,\n 'lang': self.portal_state.language(),\n ... | [
"0.5714392",
"0.5504233",
"0.53158736",
"0.52735156",
"0.50318676",
"0.50244784",
"0.50148946",
"0.50043106",
"0.49452168",
"0.49347422",
"0.49322554",
"0.4921248",
"0.48818243",
"0.48799545",
"0.48490244",
"0.4818993",
"0.4793874",
"0.4769546",
"0.47455272",
"0.46993467",
"0... | 0.7177975 | 0 |
Resizes a mask using the given scale and padding. Typically, you get the scale and padding from resize_image() to ensure both, the image and the mask, are resized consistently. | def resize_mask(mask, scale, padding):
h, w = mask.shape[:2]
mask = scipy.ndimage.zoom(mask, zoom=[scale, scale, 1], order=0)
mask = np.pad(mask, padding, mode='constant', constant_values=0)
return mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize_mask(mask, scale, padding, crop=None):\n # Suppress warning from scipy 0.13.0, the output shape of zoom() is\n # calculated with round() instead of int()\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\")\n mask = scipy.ndimage.zoom(mask, zoom=[scale, scale, 1],... | [
"0.7524376",
"0.6026159",
"0.60111076",
"0.5996426",
"0.59808886",
"0.59013957",
"0.58934987",
"0.58934987",
"0.58655715",
"0.5847212",
"0.5544648",
"0.55316556",
"0.551225",
"0.55118865",
"0.5439356",
"0.5435618",
"0.5432131",
"0.5410762",
"0.5406681",
"0.5390748",
"0.538310... | 0.78870475 | 0 |
Parses an image info Numpy array to its components. See compose_image_meta() for more details. | def parse_image_meta(meta):
image_id = meta[:, 0]
image_shape = meta[:, 1:4]
window = meta[:, 4:8] # (x1, y1, x2, y2) window of image in in pixels
active_class_ids = meta[:, 8:]
return image_id, image_shape, window, active_class_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compose_image_meta(image_id, image_shape, window, active_class_ids):\n meta = np.array(\n [image_id] + # size=1\n list(image_shape) + # size=3\n list(window) + # size=4 (x1, y1, x2, y2) in image cooredinates\n list(active_class_ids) # size=num_classes\n ... | [
"0.6748621",
"0.6561383",
"0.65598667",
"0.6534875",
"0.6470997",
"0.64522445",
"0.63780797",
"0.63463354",
"0.6314436",
"0.61476094",
"0.6146815",
"0.61462486",
"0.6036927",
"0.5900449",
"0.58613026",
"0.5849691",
"0.5815929",
"0.57962304",
"0.57669264",
"0.57289296",
"0.564... | 0.7094157 | 0 |
Parses a tensor that contains image attributes to its components. See compose_image_meta() for more details. | def parse_image_meta_graph(meta):
image_id = meta[:, 0]
image_shape = meta[:, 1:4]
window = meta[:, 4:8]
active_class_ids = meta[:, 8:]
return [image_id, image_shape, window, active_class_ids] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_image_meta(meta):\n image_id = meta[:, 0]\n image_shape = meta[:, 1:4]\n window = meta[:, 4:8] # (x1, y1, x2, y2) window of image in in pixels\n active_class_ids = meta[:, 8:]\n return image_id, image_shape, window, active_class_ids",
"def parse_image_meta_graph(meta):\n image_id = ... | [
"0.68008",
"0.65505403",
"0.6446451",
"0.6419838",
"0.6342747",
"0.63355684",
"0.6240773",
"0.6208174",
"0.6024644",
"0.59972066",
"0.5969638",
"0.5958049",
"0.59364647",
"0.59085655",
"0.5898517",
"0.5863074",
"0.58350563",
"0.5811306",
"0.57912415",
"0.5774868",
"0.5693937"... | 0.67186666 | 1 |
Compute bounding boxes from masks. | def extract_bboxes(mask):
boxes = np.zeros([mask.shape[-1], 4], dtype=np.int32)
for i in range(mask.shape[-1]):
m = mask[:, :, i]
# Bounding box.
horizontal_indicies = np.where(np.any(m, axis=0))[0]
vertical_indicies = np.where(np.any(m, axis=1))[0]
if horizontal_indicies... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_bboxes(mask):\r\n boxes = np.zeros([mask.shape[-1], 4], dtype=np.int32)\r\n for i in range(mask.shape[-1]):\r\n m = mask[:, :, i]\r\n # Bounding box.\r\n horizontal_indicies = np.where(np.any(m, axis=0))[0]\r\n vertical_indicies = np.where(np.any(m, axis=1))[0]\r\n ... | [
"0.78467315",
"0.78130674",
"0.77246463",
"0.7462639",
"0.73268336",
"0.7318628",
"0.7165459",
"0.70358133",
"0.7027821",
"0.6983254",
"0.68408525",
"0.6769498",
"0.6769209",
"0.6680738",
"0.66408485",
"0.6610212",
"0.66068614",
"0.6589283",
"0.65518355",
"0.64983237",
"0.649... | 0.7821438 | 1 |
Calculates IoU of the given box with the array of the given boxes. | def compute_iou(box, boxes, box_area, boxes_area):
# Calculate intersection areas
x1 = np.maximum(box[0], boxes[:, 0])
x2 = np.minimum(box[2], boxes[:, 2])
y1 = np.maximum(box[1], boxes[:, 1])
y2 = np.minimum(box[3], boxes[:, 3])
intersection = np.maximum(x2 - x1, 0) * np.maximum(y2 - y1, 0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_iou(box, boxes):\n # Calculate intersection areas\n iou = [box.intersection(b).area / box.union(b).area for b in boxes]\n\n return np.array(iou, dtype=np.float32)",
"def compute_iou(box, boxes, box_area, boxes_area):\n # Calculate intersection areas\n y1 = np.maximum(box[0], boxes[:, 0... | [
"0.8233654",
"0.8116598",
"0.8116598",
"0.8116598",
"0.80252707",
"0.79859704",
"0.7928408",
"0.77582073",
"0.77385104",
"0.77119327",
"0.7706524",
"0.7639222",
"0.7638932",
"0.7638932",
"0.76373506",
"0.76087755",
"0.76022065",
"0.76022065",
"0.75603807",
"0.7515975",
"0.721... | 0.8128509 | 1 |
Computes IoU overlaps between two sets of boxes. | def compute_overlaps(boxes1, boxes2):
# Areas of anchors and GT boxes
area1 = (boxes1[:, 2] - boxes1[:, 0]) * (boxes1[:, 3] - boxes1[:, 1])
area2 = (boxes2[:, 2] - boxes2[:, 0]) * (boxes2[:, 3] - boxes2[:, 1])
# Compute overlaps to generate matrix [boxes1 count, boxes2 count]
# Each cell contains t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox_overlaps(bboxes1, bboxes2, mode='iou'):\n\n from icv.data.core.bbox import BBox\n assert mode in ['iou', 'iof']\n\n bboxes1 = np.array([np.array(b.bbox) if isinstance(b,BBox) else b for b in bboxes1])\n bboxes2 = np.array([np.array(b.bbox) if isinstance(b,BBox) else b for b in bboxes2])\n\n ... | [
"0.7990615",
"0.7887685",
"0.76905334",
"0.76589406",
"0.76580244",
"0.75641197",
"0.75641197",
"0.7538061",
"0.7536853",
"0.75354326",
"0.7535125",
"0.75168645",
"0.74753267",
"0.7447682",
"0.7441888",
"0.74396497",
"0.7353138",
"0.733241",
"0.7319857",
"0.7306891",
"0.72513... | 0.81738555 | 1 |
Compute refinement needed to transform box to gt_box. box and gt_box are [N, (x1, y1, x2, y2)] Return [dx, dy, dw, dh] | def box_refinement(box, gt_box):
width = box[:, 2] - box[:, 0]
height = box[:, 3] - box[:, 1]
center_x = box[:, 0] + 0.5 * width
center_y = box[:, 1] + 0.5 * height
gt_width = gt_box[:, 2] - gt_box[:, 0]
gt_height = gt_box[:, 3] - gt_box[:, 1]
gt_center_x = gt_box[:, 0] + 0.5 * gt_width
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_refinement(box, gt_box):\n box = box.astype(np.float32)\n gt_box = gt_box.astype(np.float32)\n\n height = box[:, 2] - box[:, 0]\n width = box[:, 3] - box[:, 1]\n center_y = box[:, 0] + 0.5 * height\n center_x = box[:, 1] + 0.5 * width\n\n gt_height = gt_box[:, 2] - gt_box[:, 0]\n gt... | [
"0.81049865",
"0.7526499",
"0.62191415",
"0.57420653",
"0.5706127",
"0.56717247",
"0.562894",
"0.5558623",
"0.55334824",
"0.547968",
"0.54709405",
"0.54709405",
"0.5417713",
"0.53789407",
"0.53714305",
"0.53692764",
"0.53563386",
"0.53544474",
"0.5354361",
"0.53206414",
"0.52... | 0.7666296 | 1 |
Performs recursive glob with given suffix and rootdir | def recursive_glob(rootdir='.', suffix=''):
return [os.path.join(looproot, filename)
for looproot, _, filenames in os.walk(rootdir)
for filename in filenames if filename.endswith(suffix)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_glob(rootdir=\".\", suffix=\"\"):\n return [\n os.path.join(looproot, filename)\n for looproot, _, filenames in os.walk(rootdir)\n for filename in filenames\n if filename.endswith(suffix)\n ]",
"def recursive_glob(rootdir=\".\", suffix=\"\"):\n return [\n ... | [
"0.8374254",
"0.8374254",
"0.83679426",
"0.8002211",
"0.7678985",
"0.7678985",
"0.7495349",
"0.69118714",
"0.6903835",
"0.6895921",
"0.6877239",
"0.6740461",
"0.66994315",
"0.6648505",
"0.6640057",
"0.66142553",
"0.66053486",
"0.6561372",
"0.6561199",
"0.6540212",
"0.6540034"... | 0.84430546 | 0 |
r""" Create a ``pandas`` DataFrame containing all the scalar metrics for each region, such as volume, sphericity, and so on, calculated by ``regionprops_3D``. | def props_to_DataFrame(regionprops):
# Parse the regionprops list and pull out all props with scalar values
metrics = []
reg = regionprops[0]
for item in reg.__dir__():
if not item.startswith('_'):
try:
if np.shape(getattr(reg, item)) == ():
metric... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regionprops_3D(im):\n results = regionprops(im)\n for i, obj in enumerate(results):\n a = results[i]\n b = RegionPropertiesPS(a.slice,\n a.label,\n a._label_image,\n a._intensity_image,\n ... | [
"0.61048806",
"0.5576475",
"0.5539143",
"0.5508476",
"0.53924125",
"0.5167129",
"0.51590127",
"0.5065291",
"0.5059763",
"0.50290626",
"0.5017758",
"0.49959457",
"0.49956805",
"0.4931202",
"0.49167672",
"0.49122393",
"0.48952475",
"0.48703",
"0.48633456",
"0.48622513",
"0.4855... | 0.69139946 | 0 |
r""" Create an image with each region colored according the specified ``prop``, as obtained by ``regionprops_3d``. | def prop_to_image(regionprops, shape, prop):
im = np.zeros(shape=shape)
for r in regionprops:
if prop == 'convex':
mask = r.convex_image
else:
mask = r.image
temp = mask * r[prop]
s = bbox_to_slices(r.bbox)
im[s] += temp
return im | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regionprops_3D(im):\n results = regionprops(im)\n for i, obj in enumerate(results):\n a = results[i]\n b = RegionPropertiesPS(a.slice,\n a.label,\n a._label_image,\n a._intensity_image,\n ... | [
"0.7339298",
"0.527748",
"0.51560384",
"0.50442445",
"0.49330938",
"0.4932856",
"0.4920493",
"0.48628363",
"0.48619524",
"0.48309898",
"0.48073664",
"0.4803175",
"0.478556",
"0.47659725",
"0.47488394",
"0.4733009",
"0.47046757",
"0.4699467",
"0.4686344",
"0.4663633",
"0.46441... | 0.7215293 | 1 |
r""" Calculates various metrics for each labeled region in a 3D image. This functions offers a few extras for 3D images that are not provided by the ``regionprops`` function in ``scikitimage``. | def regionprops_3D(im):
results = regionprops(im)
for i, obj in enumerate(results):
a = results[i]
b = RegionPropertiesPS(a.slice,
a.label,
a._label_image,
a._intensity_image,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computerecondensity(d3d, label, leafs=16, PIX=10, IMGMAX=40000):\n points = d3d[:, :2].copy()\n mx, MX = np.min(points[:, 0]), np.max(points[:, 0])\n my, MY = np.min(points[:, 1]), np.max(points[:, 1])\n if mx < 0:\n points[:, 0] += np.abs(mx)\n print(\"Neg pos for {}\".format(label))... | [
"0.5946176",
"0.5602765",
"0.5601565",
"0.5576514",
"0.55764306",
"0.5502203",
"0.54844123",
"0.5399035",
"0.53916234",
"0.53817475",
"0.53667015",
"0.5359348",
"0.5357632",
"0.53525645",
"0.5342931",
"0.53415495",
"0.5309446",
"0.5309116",
"0.5304132",
"0.53030264",
"0.53002... | 0.6498146 | 0 |
Returns the authentication token for the account. Alias for ``authToken``. | def authenticationToken(self):
return self.authToken | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_auth_token(self):\n\n __logger__.debug(\"Getting auth Token\")\n return self.keystone_client.auth_ref['token']['id']",
"def get_auth_token(self):\n return self.do_rpc('get_authorization',\n username=self._username,\n passwo... | [
"0.7686397",
"0.750086",
"0.74594945",
"0.73901206",
"0.7239347",
"0.72390926",
"0.72006875",
"0.71328807",
"0.70678824",
"0.70447904",
"0.6959449",
"0.69372714",
"0.68875",
"0.6856795",
"0.6856795",
"0.6797055",
"0.67745656",
"0.6751469",
"0.67221653",
"0.67173845",
"0.67052... | 0.7754439 | 0 |
Remove the specified user from your friends. | def removeFriend(self, user):
user = user if isinstance(user, MyPlexUser) else self.user(user)
url = self.FRIENDUPDATE.format(userId=user.id)
return self.query(url, self._session.delete) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, user):\n self.packet.send_room([\"rp\", user.get_int_id(self.rooms),\n user.data.id], user.room)\n self.rooms[user.room][\"users\"].remove(user)",
"def unfriend(self, removee):\n remover_friends_list = self # person terminating the friendship\n ... | [
"0.75750345",
"0.73965544",
"0.73914206",
"0.73895204",
"0.7339403",
"0.7315023",
"0.7260339",
"0.7260339",
"0.7260339",
"0.72601575",
"0.71733886",
"0.71509176",
"0.71423334",
"0.7130265",
"0.7126609",
"0.7122609",
"0.7082952",
"0.7058855",
"0.7057249",
"0.7005578",
"0.69821... | 0.8430593 | 0 |
Remove the specified user from your home users. | def removeHomeUser(self, user):
user = user if isinstance(user, MyPlexUser) else self.user(user)
url = self.HOMEUSER.format(userId=user.id)
return self.query(url, self._session.delete) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n\n User.user_list.remove(self)",
"def del_user(self, username):\n pass",
"def ... | [
"0.79521203",
"0.79521203",
"0.79521203",
"0.77565557",
"0.7709008",
"0.7574918",
"0.7531358",
"0.7528389",
"0.7528268",
"0.74850774",
"0.74408567",
"0.74374604",
"0.74332905",
"0.7399435",
"0.7395641",
"0.7372773",
"0.73429793",
"0.7327085",
"0.7314497",
"0.73003787",
"0.728... | 0.8042959 | 0 |
Set a new Plex Home PIN for the account. | def setPin(self, newPin, currentPin=None):
url = self.HOMEUSER.format(userId=self.id)
params = {'pin': newPin}
if currentPin:
params['currentPin'] = currentPin
return self.query(url, self._session.put, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pin(self, pin):\n if pin not in range(0, 14):\n raise Exception(\"Incorrect pin {} selected. Pins available (0 to 13)\".format(pin))\n else:\n self.pin = pin\n self.gpio_pin = mraa.Gpio(pin)",
"def setManagedUserPin(self, user, newPin):\n user = user ... | [
"0.6153788",
"0.59974384",
"0.59864146",
"0.59733665",
"0.5963043",
"0.5556176",
"0.54505527",
"0.53750056",
"0.5373772",
"0.5263016",
"0.52329767",
"0.51979524",
"0.5164805",
"0.51487035",
"0.51427305",
"0.5126354",
"0.51152235",
"0.50755376",
"0.50694025",
"0.50654536",
"0.... | 0.6447556 | 0 |
Remove the Plex Home PIN for the account. | def removePin(self, currentPin):
return self.setPin('', currentPin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeManagedUserPin(self, user):\n user = user if isinstance(user, MyPlexUser) else self.user(user)\n url = self.MANAGEDHOMEUSER.format(userId=user.id)\n params = {'removePin': 1}\n return self.query(url, self._session.post, params=params)",
"def pin_delete(self, pin_id=None, pat... | [
"0.62562317",
"0.58166564",
"0.57057697",
"0.5650252",
"0.56384265",
"0.5570742",
"0.55672723",
"0.5551021",
"0.55282533",
"0.54866034",
"0.54462636",
"0.5323598",
"0.5253308",
"0.5240803",
"0.52063316",
"0.5173862",
"0.5155544",
"0.5143557",
"0.5123508",
"0.5076293",
"0.5070... | 0.64912397 | 0 |
Set a new Plex Home PIN for a managed home user. This must be done from the Plex Home admin account. | def setManagedUserPin(self, user, newPin):
user = user if isinstance(user, MyPlexUser) else self.user(user)
url = self.MANAGEDHOMEUSER.format(userId=user.id)
params = {'pin': newPin}
return self.query(url, self._session.post, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPin(self, newPin, currentPin=None):\n url = self.HOMEUSER.format(userId=self.id)\n params = {'pin': newPin}\n if currentPin:\n params['currentPin'] = currentPin\n return self.query(url, self._session.put, params=params)",
"def home_phone_number(self, home_phone_numbe... | [
"0.65767866",
"0.57163674",
"0.5661071",
"0.5636177",
"0.5433339",
"0.5433339",
"0.5417261",
"0.5402434",
"0.53720695",
"0.53613627",
"0.5345811",
"0.53364843",
"0.52735096",
"0.5249116",
"0.5218774",
"0.5218737",
"0.521368",
"0.518866",
"0.51820076",
"0.51588714",
"0.5135046... | 0.7289205 | 0 |
Remove the Plex Home PIN for a managed home user. This must be done from the Plex Home admin account. | def removeManagedUserPin(self, user):
user = user if isinstance(user, MyPlexUser) else self.user(user)
url = self.MANAGEDHOMEUSER.format(userId=user.id)
params = {'removePin': 1}
return self.query(url, self._session.post, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_user(self):\n\n if self.resin.auth.is_logged_in():\n self.wipe_application()\n self.resin.models.key.base_request.request(\n 'user__has__public_key', 'DELETE',\n endpoint=self.resin.settings.get('pine_endpoint'), login=True\n )",
"de... | [
"0.65838814",
"0.6372025",
"0.57685417",
"0.57436377",
"0.5727263",
"0.5636892",
"0.55725056",
"0.5459822",
"0.5396541",
"0.5375626",
"0.5361395",
"0.5360442",
"0.5341104",
"0.53383434",
"0.5330915",
"0.5303229",
"0.52842",
"0.5276797",
"0.5263307",
"0.5241363",
"0.5208179",
... | 0.7467859 | 0 |
Accept a pending friend invite from the specified user. | def acceptInvite(self, user):
invite = user if isinstance(user, MyPlexInvite) else self.pendingInvite(user, includeSent=False)
params = {
'friend': int(invite.friend),
'home': int(invite.home),
'server': int(invite.server)
}
url = MyPlexInvite.REQUESTS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_to_be_friends(self, user_id, target_id):\n if self.database is None:\n raise Exception(\"No database.\")\n if user_id is None or len(user_id) == 0:\n raise Exception(\"Bad parameter.\")\n if target_id is None or len(target_id) == 0:\n raise Exceptio... | [
"0.67236567",
"0.66429615",
"0.6618216",
"0.65635604",
"0.6490835",
"0.64125884",
"0.6369266",
"0.63692117",
"0.62710553",
"0.62471986",
"0.62229943",
"0.6143231",
"0.6126977",
"0.6117232",
"0.6062572",
"0.5978074",
"0.5969485",
"0.5958703",
"0.5903784",
"0.5852503",
"0.58430... | 0.8166146 | 0 |
Cancel a pending firend invite for the specified user. | def cancelInvite(self, user):
invite = user if isinstance(user, MyPlexInvite) else self.pendingInvite(user, includeReceived=False)
params = {
'friend': int(invite.friend),
'home': int(invite.home),
'server': int(invite.server)
}
url = MyPlexInvite.REQU... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_invite(client, invite_id):\n query_str = \"\"\"mutation CancelInvitePyApi($where: WhereUniqueIdInput!) {\n cancelInvite(where: $where) {id}}\"\"\"\n client.execute(query_str, {'where': {'id': invite_id}}, experimental=True)",
"def decline_invitation(self, user, group):\n if gro... | [
"0.68867844",
"0.66456467",
"0.6042282",
"0.6011541",
"0.59952796",
"0.59848875",
"0.58619255",
"0.58557665",
"0.583979",
"0.5766142",
"0.5740018",
"0.56128234",
"0.5551744",
"0.5465493",
"0.5451587",
"0.5449337",
"0.5407621",
"0.5361635",
"0.5342204",
"0.5327",
"0.531816",
... | 0.8217152 | 0 |
Converts a list of section objects or names to sectionIds needed for library sharing. | def _getSectionIds(self, server, sections):
if not sections: return []
# Get a list of all section ids for looking up each section.
allSectionIds = {}
machineIdentifier = server.machineIdentifier if isinstance(server, PlexServer) else server
url = self.PLEXSERVERS.format(machineI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makesection(section):\n s = []\n if section is None:\n return s\n try:\n for i in section.split(':'):\n s.append(int(i))\n except Exception as e:\n msg = 'Not able to convet section to list because %s' % e\n raise SpecError(msg)\n return s",
"def multiple... | [
"0.60895807",
"0.5815571",
"0.5697877",
"0.55596393",
"0.5502066",
"0.5341237",
"0.5244695",
"0.51733077",
"0.51356095",
"0.51254946",
"0.51153404",
"0.509933",
"0.5084965",
"0.5084539",
"0.50487703",
"0.503764",
"0.50344765",
"0.5019604",
"0.5013521",
"0.49887103",
"0.497200... | 0.6299416 | 0 |
Converts friend filters to a string representation for transport. | def _filterDictToStr(self, filterDict):
values = []
for key, vals in filterDict.items():
if key not in ('contentRating', 'label', 'contentRating!', 'label!'):
raise BadRequest(f'Unknown filter key: {key}')
values.append(f"{key}={'%2C'.join(vals)}")
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filter(self) -> str:\n\n return \";;\".join(self.filters)",
"def get_current_filters(self) -> str:\r\n return self.__filters_string",
"def metadata_filter_as_string(metadata_filter):\n if not isinstance(metadata_filter, dict):\n return metadata_filter\n\n additional = metadat... | [
"0.6735593",
"0.6284408",
"0.6256892",
"0.6255688",
"0.61947876",
"0.5896819",
"0.5744471",
"0.56985873",
"0.56510377",
"0.56335956",
"0.5488424",
"0.5478061",
"0.5414317",
"0.54086196",
"0.5398841",
"0.5337547",
"0.5289531",
"0.527011",
"0.52557015",
"0.52546054",
"0.5244179... | 0.6928889 | 0 |
Adds specified sync item for the client. It's always easier to use methods defined directly in the media | def sync(self, sync_item, client=None, clientId=None):
if not client and not clientId:
clientId = X_PLEX_IDENTIFIER
if not client:
for device in self.devices():
if device.clientIdentifier == clientId:
client = device
break
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(self, item):\n self.items.append(item)",
"def add(self, item):\n self.contents.append(item)",
"def _rc_add(self, mrl: MRL):\n self._rc_send('add %s' % mrl)\n # recache playlist\n self.get_playlist()",
"def add(self, item):",
"def addItem(*args):",
"def addI... | [
"0.6117482",
"0.6110298",
"0.5960986",
"0.57956463",
"0.5739922",
"0.5739922",
"0.5739922",
"0.5737603",
"0.5732767",
"0.56976056",
"0.569363",
"0.5682642",
"0.5682642",
"0.5677456",
"0.56541353",
"0.56399286",
"0.56388456",
"0.5636837",
"0.5572411",
"0.55590826",
"0.5551299"... | 0.67680466 | 0 |
Returns a str, a new "claimtoken", which you can use to register your new Plex Server instance to your account. | def claimToken(self):
response = self._session.get('https://plex.tv/api/claim/token.json', headers=self._headers(), timeout=TIMEOUT)
if response.status_code not in (200, 201, 204): # pragma: no cover
codename = codes.get(response.status_code)[0]
errtext = response.text.replace('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(self):\n return self.rpc.call(MsfRpcMethod.AuthTokenGenerate)['token']",
"def _generate_token(self):\n return sha1(\"%s#%s\" % (time(),\n self.app.cfg['sessions/secret'])).hexdigest()",
"def get_client_token(**_):\n return str(uuid.uuid4())",
"def g... | [
"0.6547049",
"0.6526151",
"0.64889586",
"0.6448134",
"0.6368943",
"0.62736434",
"0.6266498",
"0.6266498",
"0.6266498",
"0.62412906",
"0.6131142",
"0.61267006",
"0.610294",
"0.60728693",
"0.60686207",
"0.60686207",
"0.6048715",
"0.60401565",
"0.60223335",
"0.6018202",
"0.60128... | 0.69568545 | 0 |
Get Play History for all library sections on all servers for the owner. | def history(self, maxresults=None, mindate=None):
servers = [x for x in self.resources() if x.provides == 'server' and x.owned]
hist = []
for server in servers:
conn = server.connect()
hist.extend(conn.history(maxresults=maxresults, mindate=mindate, accountID=1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history(self, maxresults=None, mindate=None):\n server = self._server._server.resource(self._server.name).connect()\n return server.history(maxresults=maxresults, mindate=mindate,\n accountID=self._server.accountID, librarySectionID=self.sectionKey)",
"def history(s... | [
"0.6726731",
"0.6443011",
"0.63816136",
"0.6370995",
"0.6218271",
"0.6188942",
"0.6162286",
"0.60735977",
"0.6002831",
"0.59898585",
"0.59841716",
"0.597373",
"0.58652014",
"0.58424985",
"0.5832161",
"0.5830273",
"0.5830273",
"0.58065355",
"0.57905906",
"0.57822883",
"0.57505... | 0.67723 | 0 |
Returns True if the item is on the user's watchlist. | def onWatchlist(self, item):
return bool(self.userState(item).watchlistedAt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPlayed(self, item):\n userState = self.userState(item)\n return bool(userState.viewCount > 0) if userState.viewCount else False",
"def is_on_waiting_list(self):\n if self.user is None:\n return False\n if unicode(self.user._id) in self.barcamp.event.waiting_list:\n ... | [
"0.66236967",
"0.63791096",
"0.6310744",
"0.6258938",
"0.6136185",
"0.6087883",
"0.60839623",
"0.6078763",
"0.6075333",
"0.60364056",
"0.60264707",
"0.6020573",
"0.5992435",
"0.5992435",
"0.5989769",
"0.5968984",
"0.59473044",
"0.5939764",
"0.59225345",
"0.59178853",
"0.59042... | 0.8587729 | 0 |
Add media items to the user's watchlist | def addToWatchlist(self, items):
if not isinstance(items, list):
items = [items]
for item in items:
if self.onWatchlist(item):
raise BadRequest(f'"{item.title}" is already on the watchlist')
ratingKey = item.guid.rsplit('/', 1)[-1]
self.qu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, obj):\n try:\n EditMedia(self.dbstate, self.uistate, [], MediaObject())\n except WindowActiveError:\n pass",
"def test_adding_media_to_channel(self):\n videos = [\n make_video(title='test title', media_id='1'),\n make_video(title='tes... | [
"0.57887405",
"0.57843083",
"0.5721101",
"0.56794786",
"0.56581503",
"0.55463034",
"0.55322075",
"0.55276906",
"0.5501814",
"0.54705894",
"0.5467799",
"0.54159045",
"0.5352088",
"0.53216416",
"0.5313283",
"0.5272073",
"0.5267057",
"0.5243338",
"0.5243185",
"0.51880914",
"0.51... | 0.6427449 | 0 |
Remove media items from the user's watchlist | def removeFromWatchlist(self, items):
if not isinstance(items, list):
items = [items]
for item in items:
if not self.onWatchlist(item):
raise BadRequest(f'"{item.title}" is not on the watchlist')
ratingKey = item.guid.rsplit('/', 1)[-1]
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_playlists_in(path):\n\n for f in [f for f in os.listdir(path) if f.endswith('.m3u')]:\n os.remove(os.path.join(path, f))",
"def remove_songs(self):\n self.stop()\n self.listbox.delete(0, \"end\")\n pygame.mixer.music.stop()",
"def clean():\n\n tracks = []\n remov... | [
"0.63080066",
"0.63060296",
"0.5782847",
"0.5777922",
"0.5765917",
"0.5726394",
"0.5680854",
"0.5618816",
"0.56157017",
"0.56094664",
"0.55790895",
"0.55742043",
"0.5554767",
"0.5553096",
"0.5545259",
"0.5540396",
"0.553902",
"0.5528214",
"0.552145",
"0.552145",
"0.55011266",... | 0.6733222 | 0 |
Return True if the item is played on Discover. | def isPlayed(self, item):
userState = self.userState(item)
return bool(userState.viewCount > 0) if userState.viewCount else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isInPlay(self):\n return self.inPlay",
"def still_deciding(self):\n for player in self.players:\n if isinstance(player, user.User):\n if not player.has_played:\n return True\n return False",
"def remote(self):\n return self.getItunesA... | [
"0.64082015",
"0.62282306",
"0.60732615",
"0.60227174",
"0.59953195",
"0.5965395",
"0.5949092",
"0.59408605",
"0.5901996",
"0.5901996",
"0.589008",
"0.5888568",
"0.586191",
"0.5850891",
"0.58479637",
"0.5834604",
"0.5824554",
"0.57929164",
"0.57896614",
"0.5782654",
"0.577901... | 0.66849774 | 0 |
Link a device to the account using a pin code. | def link(self, pin):
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Plex-Product': 'Plex SSO'
}
data = {'code': pin}
self.query(self.LINK, self._session.put, headers=headers, data=data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_device_over_ble(devCtrl, discriminator, pinCode, nodeId=None):\n if nodeId is None:\n nodeId = random.randint(1, 1000000)\n\n try:\n devCtrl.ConnectBLE(int(discriminator), int(pinCode), int(nodeId))\n except exceptions.ChipStackException as ex:\n log.error(\"Connect device... | [
"0.587559",
"0.57496667",
"0.56169987",
"0.5383043",
"0.5366147",
"0.5315943",
"0.5300602",
"0.52975434",
"0.5265919",
"0.5238026",
"0.52354",
"0.5176752",
"0.50742453",
"0.5046556",
"0.5041817",
"0.50167",
"0.5006453",
"0.49984452",
"0.49813223",
"0.49634928",
"0.4952628",
... | 0.69169384 | 0 |
Convert a list of media objects to online metadata objects. | def _toOnlineMetadata(self, objs, **kwargs):
# TODO: Add proper support for metadata.provider.plex.tv
# Temporary workaround to allow reloading and browsing of online media objects
server = PlexServer(self.METADATA, self._token, session=self._session)
includeUserState = int(bool(kwargs.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_adhoc_medias(self, media_list, media_type):\n adhoc_medias = []\n media_id = 0\n for media in media_list:\n media_name = 'adhoc_media_' + media_type + '_' + self.viewport_name + '_' + str(media_id)\n adhoc_media = AdhocMedia()\n adhoc_media.id = medi... | [
"0.6491953",
"0.64446926",
"0.6356201",
"0.6197777",
"0.607783",
"0.585688",
"0.57791615",
"0.5754816",
"0.5718509",
"0.5706103",
"0.5706103",
"0.5687239",
"0.5585416",
"0.5576888",
"0.55728203",
"0.5518264",
"0.54846466",
"0.54290694",
"0.5418062",
"0.54137397",
"0.540778",
... | 0.67632294 | 0 |
Return the Plex OAuth url for login. | def oauthUrl(self, forwardUrl=None):
if not self._oauth:
raise BadRequest('Must use "MyPlexPinLogin(oauth=True)" for Plex OAuth login.')
headers = self._headers()
params = {
'clientID': headers['X-Plex-Client-Identifier'],
'context[device][product]': headers[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_oauth_authentication_url(request_token):\n return _FRIENDFEED_OAUTH_BASE + \"/authenticate?\" + \\\n urllib.urlencode(dict(oauth_token=request_token[\"key\"]))",
"def authorize_login_url(self):\n\n return \"{site}{authorize_url}\" \\\n \"?response_type=code&client_id={clien... | [
"0.7395721",
"0.7188687",
"0.71606964",
"0.70837724",
"0.70610374",
"0.7044484",
"0.69741297",
"0.68810767",
"0.68794423",
"0.68794423",
"0.6801249",
"0.67777795",
"0.67777795",
"0.67540216",
"0.67245376",
"0.6701567",
"0.66954046",
"0.66855377",
"0.6673082",
"0.66082096",
"0... | 0.7806607 | 0 |
Starts the thread which monitors the PIN login state. | def run(self, callback=None, timeout=None):
if self._thread and not self._abort:
raise RuntimeError('MyPlexPinLogin thread is already running')
if self.expired:
raise RuntimeError('MyPlexPinLogin has expired')
self._loginTimeout = timeout
self._callback = callbac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n self.synchronizer = SyncThread(self.api, self.sync_dir)\n self.synchronizer.start()\n self.tray.on_login()",
"def start(self):\n \n self.thread.start()\n self.state = \"running\"",
"def on_start(self):\n self.login()",
"def on_start(self):\n... | [
"0.6769861",
"0.64573824",
"0.6383869",
"0.6383869",
"0.6383869",
"0.6383869",
"0.63040185",
"0.6264163",
"0.61168617",
"0.6013585",
"0.5917714",
"0.5874773",
"0.5859461",
"0.58173347",
"0.5816324",
"0.5807674",
"0.5768907",
"0.57597697",
"0.5750825",
"0.5745972",
"0.57169974... | 0.6739606 | 1 |
Waits for the PIN login to succeed or expire. | def waitForLogin(self):
if not self._thread or self._abort:
return False
self._thread.join()
if self.expired or not self.token:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, callback=None, timeout=None):\n if self._thread and not self._abort:\n raise RuntimeError('MyPlexPinLogin thread is already running')\n if self.expired:\n raise RuntimeError('MyPlexPinLogin has expired')\n\n self._loginTimeout = timeout\n self._callba... | [
"0.609509",
"0.58995926",
"0.5862068",
"0.58566433",
"0.57962024",
"0.5782627",
"0.5772155",
"0.5720976",
"0.5663411",
"0.56209844",
"0.561488",
"0.5590879",
"0.553974",
"0.5501239",
"0.54725665",
"0.54720837",
"0.5464565",
"0.54463655",
"0.54337454",
"0.5412827",
"0.5401274"... | 0.6863656 | 0 |
Connects to the specified cls with url and token. Stores the connection information to results[i] in a threadsafe way. | def _connect(cls, url, token, session, timeout, results, i, job_is_done_event=None):
starttime = time.time()
try:
device = cls(baseurl=url, token=token, session=session, timeout=timeout)
runtime = int(time.time() - starttime)
results[i] = (url, token, device, runtime)
if X_PLEX_E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _connect(self, query):\n LOGGER.debug('Connecting to ' + self.url)\n return urllib.urlopen(self.url + '?' + query)",
"def _connect(self):\n\n try:\n response = requests.post(\n f\"https://{self.hostname}:{self.port}/{self._ENDPOINTS['tokens']}\",\n ... | [
"0.5749226",
"0.574414",
"0.5564632",
"0.55274254",
"0.54324937",
"0.5359193",
"0.52658355",
"0.5265485",
"0.5254839",
"0.5252927",
"0.5232325",
"0.5229557",
"0.52239203",
"0.5201088",
"0.51740134",
"0.51419693",
"0.51385665",
"0.51365185",
"0.513369",
"0.512383",
"0.51006496... | 0.6852977 | 0 |
Chooses the first (best) connection from the given _connect results. | def _chooseConnection(ctype, name, results):
# At this point we have a list of result tuples containing (url, token, PlexServer, runtime)
# or (url, token, None, runtime) in the case a connection could not be established.
for url, token, result, runtime in results:
okerr = 'OK' if result else 'ERR'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_first_connection(self):\n self.best_connection = []\n stations = list(self.grid.stations.values())\n\n # add a first station to the track \n for station in stations:\n self.track = Track(f\"greedy_track_{self.count}\", self.grid)\n self.track.add_station(... | [
"0.65833575",
"0.5903044",
"0.5626214",
"0.54772633",
"0.5463953",
"0.5455997",
"0.53981364",
"0.5351905",
"0.52869314",
"0.52664995",
"0.5259322",
"0.5254459",
"0.524534",
"0.5242426",
"0.5150927",
"0.5150927",
"0.51500577",
"0.5110211",
"0.51032764",
"0.50856036",
"0.506226... | 0.6846864 | 0 |
Sets the Online Media Source to "Disabled for Managed Users". | def optOutManaged(self):
if self.key == 'tv.plex.provider.music':
raise BadRequest(f'{self.key} does not have the option to opt out managed users.')
self._updateOptOut('opt_out_managed') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_mute(self):\n self.mute = False",
"async def disable(self, ctx):\n await self.config.guild(ctx.guild).auto.set(True)\n await ctx.send(_(\"Automatic voicechannel creation disabled.\"))",
"def disable_play_store(self):\n return self._disable_play_store",
"def disable(ctx... | [
"0.62032115",
"0.57203895",
"0.5661377",
"0.550994",
"0.5481648",
"0.5461425",
"0.5386781",
"0.53330046",
"0.5321535",
"0.52737826",
"0.5179086",
"0.517798",
"0.51469177",
"0.5144614",
"0.51438916",
"0.5143726",
"0.51397663",
"0.51338977",
"0.5125021",
"0.51136625",
"0.511196... | 0.6359012 | 0 |
Convert the constraint into the appropriate Constraint object. | def make_constraint(constraint):
if isinstance(constraint, str) and constraint == "array-like":
return _ArrayLikes()
if isinstance(constraint, str) and constraint == "sparse matrix":
return _SparseMatrices()
if isinstance(constraint, str) and constraint == "random_state":
return _Ran... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_constraint(cls, constraint):\n attrs = constraint.deconstruct()[2]\n del attrs['name']\n\n return cls(name=constraint.name,\n constraint_type=type(constraint),\n attrs=attrs)",
"def __init__(self, constraint: ConstraintExpr):\n self.constra... | [
"0.71897",
"0.62142295",
"0.6053933",
"0.60538065",
"0.59676236",
"0.5716293",
"0.57077557",
"0.5686693",
"0.5565292",
"0.55383",
"0.5535098",
"0.54835606",
"0.54016894",
"0.5269533",
"0.52447426",
"0.52201873",
"0.5187175",
"0.51860994",
"0.5160573",
"0.50934225",
"0.5074919... | 0.69177777 | 1 |
Add a deprecated mark to an option if needed. | def _mark_if_deprecated(self, option):
option_str = f"{option!r}"
if option in self.deprecated:
option_str = f"{option_str} (deprecated)"
return option_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_deprecated(self, dest: str, kwargs, print_warning: bool = True) -> None:\n removal_version = kwargs.get(\"removal_version\", None)\n if removal_version is not None:\n warn_or_error(\n removal_version=removal_version,\n entity=f\"option '{dest}' in {... | [
"0.6785955",
"0.67780274",
"0.670338",
"0.66554064",
"0.6550236",
"0.630168",
"0.62527436",
"0.6196838",
"0.61321324",
"0.5973347",
"0.59597474",
"0.5939626",
"0.5933445",
"0.58870196",
"0.58806485",
"0.5876633",
"0.58360225",
"0.58323735",
"0.57920855",
"0.57822007",
"0.5756... | 0.82811135 | 0 |
Gets new state from current state by appending a valid production rule. | def get_new_states_probs(self, state):
if not isinstance(state, states.ProductionRulesState):
raise TypeError('Input state shoud be an instance of '
'states.ProductionRulesState but got %s' % type(state))
production_rules_sequence = state.production_rules_sequence
if len(product... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_new_state(state, rules):\n closed_line = f'{state[-1]}{state}{state[0]}'\n listed = list(window(closed_line))\n new_state = ''.join(rules[stride] for stride in listed)\n return new_state",
"def append(self, state, symbol, action, destinationstate, production = None):\r\n if actio... | [
"0.63549554",
"0.5838318",
"0.54414475",
"0.5250689",
"0.5239543",
"0.51818705",
"0.5156978",
"0.51152897",
"0.5046735",
"0.4995275",
"0.4973245",
"0.49462128",
"0.49305478",
"0.4925647",
"0.48603725",
"0.4833016",
"0.48283416",
"0.48274276",
"0.4812447",
"0.48101223",
"0.480... | 0.5873246 | 1 |
Gets the leading power error. The leading power error is defined as abs(leading power difference at 0) + abs(leading power difference at inf). | def get_leading_power_error(self, state):
true_leading_at_0, true_leading_at_inf = (
metrics.evaluate_leading_powers_at_0_inf(
expression_string=state.get_expression(),
symbol=self._variable_symbol))
return (abs(true_leading_at_0 - self._leading_at_0)
+ abs(true_lead... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_power(self):\r\n x = self.query('POW?')\r\n if x == None: return None\r\n return float(x)",
"def _evaluate(self, state):\n leading_power_error = self.get_leading_power_error(state)\n if np.isfinite(leading_power_error):\n return -float(leading_power_error)\n else:\n ... | [
"0.6223684",
"0.61518496",
"0.59973663",
"0.5993435",
"0.5993435",
"0.59855384",
"0.5983528",
"0.5954963",
"0.59362435",
"0.5730163",
"0.5727557",
"0.5718702",
"0.5718261",
"0.56860334",
"0.5671874",
"0.5665454",
"0.5646993",
"0.56306994",
"0.5620838",
"0.56172",
"0.55122155"... | 0.8443688 | 0 |
creates a list of lists with groups of variables that have a pearson correlation bigger than corr_tresh among each other | def corrGroups(df:pd.DataFrame,corr_thresh:float=0.9) -> list:
corrMatrix = df.corr().abs()
corrMatrix.loc[:,:] = np.tril(corrMatrix, k=-1)
corrMatrix = corrMatrix[corrMatrix >= corr_thresh].dropna(how='all').dropna(axis=1,how='all')
corrMatrix['corr_groups'] = corrMatrix.apply(lambda x:sum([[x.na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_correlation(df, vars_to_corr, target_var) :\n\n\n mean = df[target_var].mean()\n sigma = df[target_var].std()\n\n correlation = []\n error = []\n\n for j in vars_to_corr :\n mean_j = df[j].mean()\n sigma_j = df[j].std()\n\n cov = (df[j] - mean_j) * (df[target_var] ... | [
"0.62173957",
"0.61023635",
"0.5877231",
"0.58633095",
"0.58384293",
"0.5704684",
"0.5679107",
"0.5643847",
"0.56356066",
"0.5618148",
"0.56030685",
"0.5599038",
"0.5563642",
"0.54343325",
"0.5409856",
"0.5384402",
"0.53606004",
"0.5351234",
"0.53277904",
"0.5318362",
"0.5315... | 0.67428017 | 0 |
Checks the time for advertising Patreon. | async def advertise_patreon(self) -> None:
current_ts = await utils.get_timestamp()
# Checks whether Patreon advertising event exists
if not await self.get_advertising_event(event_label='patreon_ad'):
# If not, creates it
return await self.insert_advertising_event(event_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_attack(self):\n now = time.time() * 1000\n if self.prev_time is None:\n return True\n else:\n next_time = self.prev_time + self.get_recharge\n if now >= next_time:\n return True\n else:\n return False",
"asyn... | [
"0.6274031",
"0.6194048",
"0.61901665",
"0.61806667",
"0.60662276",
"0.5878633",
"0.5875004",
"0.5789522",
"0.5676808",
"0.567079",
"0.56519186",
"0.56447655",
"0.5632327",
"0.5620847",
"0.558976",
"0.55415356",
"0.55282754",
"0.5484038",
"0.54835355",
"0.5457494",
"0.5435096... | 0.6391378 | 0 |
(ADM) Announces a message in the announcements channel using the bot. | async def announce(self, ctx):
await ctx.message.delete()
if len(ctx.message.content.split()) < 2:
return await ctx.send('You must inform all parameters!')
announce_channel = discord.utils.get(ctx.guild.channels, id=announcement_channel_id)
msg = ctx.message.content.split('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def announce(self, ctx, *, msg):\n if self._announce_msg is not None:\n await self.bot.say(\"Already announcing, wait until complete to\"\n \" issue a new announcement.\")\n else:\n self._announce_msg = msg",
"async def announcement(ctx, bot... | [
"0.6967236",
"0.6468096",
"0.576518",
"0.5730523",
"0.57184154",
"0.56924826",
"0.56363595",
"0.563563",
"0.56228656",
"0.5613768",
"0.5541273",
"0.5478032",
"0.5477188",
"0.54606646",
"0.5433697",
"0.5374674",
"0.53567344",
"0.53517914",
"0.533829",
"0.5317261",
"0.5314131",... | 0.75351304 | 0 |
Creates the ScheduledEvents table. | async def create_table_scheduled_events(self, ctx: commands.Context) -> None:
member = ctx.author
await ctx.message.delete()
if await self.check_scheduled_events_exists():
return await ctx.send(f"**Table `ScheduledEvents` already exists, {member.mention}!**")
mycur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_table(self):\n self.c.execute(\n \"\"\"CREATE TABLE IF NOT EXISTS {table} (\n id integer primary key,\n {event} integer,\n {desc} text,\n {date} text,\n {link} text)\n \"\"\".format(\n table=TABLE,\n ... | [
"0.6760438",
"0.66445494",
"0.6625416",
"0.6529982",
"0.64881086",
"0.64517707",
"0.64487267",
"0.6446051",
"0.62144834",
"0.6160995",
"0.61342657",
"0.6047282",
"0.6020282",
"0.59020716",
"0.58956474",
"0.5894661",
"0.5871112",
"0.5869499",
"0.5816645",
"0.5795914",
"0.57930... | 0.8704623 | 0 |
Checks whether the ScheduledEvents table exists. | async def check_scheduled_events_exists(self) -> bool:
mycursor, _ = await the_database()
await mycursor.execute("SHOW TABLE STATUS LIKE 'ScheduledEvents'")
exists = await mycursor.fetchone()
await mycursor.close()
if exists:
return True
else:
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def create_table_scheduled_events(self, ctx: commands.Context) -> None:\n\n member = ctx.author\n await ctx.message.delete()\n\n if await self.check_scheduled_events_exists():\n return await ctx.send(f\"**Table `ScheduledEvents` already exists, {member.mention}!**\")\n ... | [
"0.70320445",
"0.6886784",
"0.6687293",
"0.65553224",
"0.6387929",
"0.63771653",
"0.6334157",
"0.6333455",
"0.62896025",
"0.6260394",
"0.6249291",
"0.6241071",
"0.61995167",
"0.61830574",
"0.61741245",
"0.61682135",
"0.61477774",
"0.61429816",
"0.6095434",
"0.607051",
"0.6070... | 0.87525564 | 0 |
Checks whether the advertising time is due. | async def check_advertising_time(self, current_ts: int, event_label: str, ad_time: int) -> bool:
mycursor, _ = await the_database()
await mycursor.execute("""
SELECT * from ScheduledEvents
WHERE event_label = %s AND %s - event_ts >= %s
""", (event_label, current_ts, ad_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_attack(self):\n now = time.time() * 1000\n if self.prev_time is None:\n return True\n else:\n next_time = self.prev_time + self.get_recharge\n if now >= next_time:\n return True\n else:\n return False",
"def ... | [
"0.72752774",
"0.6964547",
"0.6849957",
"0.6738011",
"0.66971064",
"0.6653395",
"0.6607808",
"0.657862",
"0.6547221",
"0.65231436",
"0.6503476",
"0.64633894",
"0.64558476",
"0.64554447",
"0.645044",
"0.6448048",
"0.6444591",
"0.6404285",
"0.6402235",
"0.6397026",
"0.63682806"... | 0.73352146 | 0 |
Gets an advertising event. | async def get_advertising_event(self, event_label: str) -> List[Union[str, int]]:
mycursor, _ = await the_database()
await mycursor.execute("SELECT * FROM ScheduledEvents WHERE event_label = %s", (event_label,))
event = await mycursor.fetchone()
await mycursor.close()
return eve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_event(self):\r\n return self.events[0]",
"def get_event(self):\n return self.keys.events.get()",
"def event(self):\n return self.events[0]",
"def get_event(self, eventid):\n return self.s.query(Event).get(eventid)",
"def get(self, request):\n return self.serviceHa... | [
"0.6796218",
"0.6571147",
"0.6518009",
"0.6428353",
"0.6365014",
"0.6356171",
"0.6340592",
"0.6254626",
"0.6249749",
"0.61499524",
"0.611407",
"0.6099456",
"0.60907185",
"0.5956177",
"0.59288603",
"0.5909034",
"0.5888112",
"0.5860088",
"0.5835143",
"0.58041567",
"0.5797278",
... | 0.69491845 | 0 |
Inserts an advertising event. | async def insert_advertising_event(self, event_label: str, current_ts: int) -> None:
mycursor, db = await the_database()
await mycursor.execute("INSERT INTO ScheduledEvents (event_label, event_ts) VALUES (%s, %s)", (event_label, current_ts))
await db.commit()
await mycursor.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_event(self, content: Content):\n self.strg_ctrl.insert_event(self.feed_id, content)",
"def insertEvent(self, event):\r\n key=event.time\r\n newitem = [key, event]\r\n for i,item in enumerate(self.__agenda):\r\n if key < item[0]: \r\n self.__agenda.... | [
"0.66896",
"0.6435405",
"0.6179106",
"0.6176938",
"0.5847098",
"0.5748609",
"0.5719639",
"0.5614003",
"0.55954117",
"0.55807173",
"0.55591655",
"0.5534922",
"0.54850656",
"0.5472918",
"0.5435257",
"0.5365861",
"0.5321969",
"0.5307204",
"0.52931255",
"0.52748203",
"0.52549535"... | 0.6802399 | 0 |
Called when the other end calls write_eof() or equivalent. This callback may be exercised by the nc(1) client argument ``z``. | def eof_received(self):
logger.debug("EOF from client, closing.")
self.connection_lost(None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_eof(self):\n self._check_status()\n if not self._writable:\n raise TransportError('transport is not writable')\n if self._closing:\n raise TransportError('transport is closing')\n try:\n self._handle.shutdown(self._on_write_complete)\n e... | [
"0.6295354",
"0.61444765",
"0.59688306",
"0.59359473",
"0.58836323",
"0.57762265",
"0.5693101",
"0.5638879",
"0.56224006",
"0.56115675",
"0.55706316",
"0.55706316",
"0.55706316",
"0.55685127",
"0.55544186",
"0.55434436",
"0.5490538",
"0.5476318",
"0.54692584",
"0.54628587",
"... | 0.6340887 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.