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 |
|---|---|---|---|---|---|---|
Applies random color mask to given input image. | def random_colour_masks(image: np.array):
colours = [
[0, 255, 0],
[0, 0, 255],
[255, 0, 0],
[0, 255, 255],
[255, 255, 0],
[255, 0, 255],
[80, 70, 180],
[250, 80, 190],
[245, 145, 50],
[70, 150, 250],
[50, 190, 190],
]
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_mask(im, mask, color=(1, 0, 0)):\n masked = np.zeros(im.shape)\n for x, y in mask: masked[x][y] = color\n return masked",
"def addMaskImage(img):\r\n [h, w, c] = img.shape\r\n h_start = np.random.randint(h/2,h-1)\r\n w_start = np.random.randint(w/2, w-1)\r\n img[h_start:h-1, :,0]= ... | [
"0.69744325",
"0.68479043",
"0.6653597",
"0.6587677",
"0.653253",
"0.644138",
"0.6433334",
"0.6425598",
"0.63975954",
"0.6355787",
"0.6343776",
"0.6325185",
"0.63067794",
"0.62949806",
"0.62843984",
"0.62772554",
"0.62622845",
"0.6229754",
"0.62034327",
"0.61940217",
"0.61221... | 0.71775967 | 0 |
Visualizes prediction classes, bounding boxes, masks over the source image and exports it to output folder. | def visualize_prediction(
image: str,
masks,
boxes,
pred_cls,
rect_th: float = 3,
text_size: float = 3,
text_th: float = 3,
file_name: str = "inference_result.png",
):
# create output folder if not present
create_dir("output/")
# add bbox and mask to image if present
if l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _visualize_prediction(self, input, output, target):\n out_b1 = binary(output)\n out_b1 = impose_labels_on_image(input[0, 0, :, :], target[0, :, :], out_b1[0, 1, :, :])\n self.writer.add_image('output', make_grid(out_b1, nrow=8, normalize=False))",
"def visualize_image_prediction(image,\n... | [
"0.6950687",
"0.65381104",
"0.64658016",
"0.64365315",
"0.63709706",
"0.63340414",
"0.6260973",
"0.6257987",
"0.62485135",
"0.6241173",
"0.62216526",
"0.6170909",
"0.6166584",
"0.6165491",
"0.61395955",
"0.6133383",
"0.6118839",
"0.61138433",
"0.6113759",
"0.6082543",
"0.6081... | 0.6905549 | 1 |
Crops the predicted bounding box regions and exports them to output folder. | def crop_inference_bbox(image, boxes, file_name="cropped_inference_result"):
# create output folder if not present
create_dir("output/")
# crop detections
if len(boxes) > 0:
for ind in range(len(boxes)):
cropped_img = image[
int(boxes[ind][0][1]) : int(boxes[ind][1][1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exporting_cropped_images (fpath_tiff):\n src = rasterio.open(fpath_tiff, 'r')\n outfolder_irregular = '/train/irregular'\n outfolder_healthy = '/train/healthy'\n outfolder_concrete = '/train/concrete'\n outfolder_incomplete = '/train/incomplete'\n outfolder_other = '/t... | [
"0.6000429",
"0.59769034",
"0.5903341",
"0.58753145",
"0.58705914",
"0.58030313",
"0.5755639",
"0.5752636",
"0.5709903",
"0.5703744",
"0.56888646",
"0.5668789",
"0.56635773",
"0.56635773",
"0.56446755",
"0.562883",
"0.56010115",
"0.5571136",
"0.5528559",
"0.55171996",
"0.5500... | 0.64906526 | 0 |
Creates category id>name mapping from a coco annotation file. | def get_category_mapping_from_coco_file(coco_file_path: str) -> dict:
# check if coco file is valid and read it
(coco_dict, response) = read_and_validate_coco_annotation(coco_file_path)
# raise error if coco file is not valid
if not (response):
raise TypeError
coco_categories = coco_dict["... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_category_info_from_anno(anno_file, with_background=True):\n cats = []\n with open(anno_file) as f:\n for line in f.readlines():\n cats.append(line.strip())\n\n if cats[0] != 'background' and with_background:\n cats.insert(0, 'background')\n if cats[0] == 'background' an... | [
"0.64456666",
"0.6217465",
"0.6213983",
"0.6204705",
"0.61832976",
"0.6114472",
"0.60462743",
"0.5998794",
"0.596586",
"0.5962729",
"0.5960021",
"0.58677703",
"0.58615774",
"0.5853491",
"0.5826413",
"0.5825861",
"0.5769368",
"0.5730286",
"0.5600615",
"0.55968726",
"0.55927026... | 0.7166214 | 0 |
Takes single coco dataset file path, split images into trainval and saves as seperate coco dataset files. | def split_coco_as_train_val(
coco_file_path: str, target_dir: str, train_split_rate: float
):
# check if coco file is valid and read it
(coco_dict, response) = read_and_validate_coco_annotation(coco_file_path)
# raise error if coco file is not valid
if not (response):
raise TypeError
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_data(path_to_data, path_to_save_train,\n path_to_save_val, split_size = 0.1):\n \n folders = os.listdir(path_to_data)\n\n # get the data and split it\n for folder in folders:\n full_path = os.path.join(path_to_data, folder)\n images_paths = glob.glob(os.path.join(f... | [
"0.6767223",
"0.6766674",
"0.6721887",
"0.66965336",
"0.6577553",
"0.6528394",
"0.6492255",
"0.6409701",
"0.6390866",
"0.6370787",
"0.63393295",
"0.6304204",
"0.63032174",
"0.62837404",
"0.62496305",
"0.6246795",
"0.62207115",
"0.6187223",
"0.6179907",
"0.6172584",
"0.6171887... | 0.7158573 | 0 |
Saves a dict as yaml file. | def save_yaml(dict_file, yaml_path):
with open(yaml_path, "w") as file:
documents = yaml.dump(dict_file, file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(dikt):\n with open(SAVE_FILE_NAME, 'w') as save_file:\n yaml.safe_dump(dikt, save_file)",
"def save_yaml_to_file(i):\n\n import yaml\n\n fn = i['yaml_file']\n d = i['dict']\n\n try:\n # If using just dump and keys are in unicode,\n # pyyaml adds warning and makes prod... | [
"0.82348216",
"0.79898936",
"0.79564303",
"0.7664049",
"0.74451005",
"0.7425517",
"0.7238184",
"0.7232736",
"0.72081083",
"0.7199662",
"0.7193838",
"0.70849293",
"0.7078301",
"0.7078301",
"0.70539814",
"0.7035597",
"0.69795805",
"0.6960351",
"0.69413203",
"0.6937528",
"0.6903... | 0.83138406 | 0 |
Wrapper around `tqdm.tqdm` that optionally displays only on the main process. | def tqdm(main_process_only: bool = True, *args, **kwargs):
if not is_tqdm_available():
raise ImportError("Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`.")
disable = False
if main_process_only:
disable = PartialState().local_process_index == 0
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tqdm(*args, **kwargs):\n kwargs_ = dict(file=sys.stdout, disable=C.DISPLAY.PROGRESS.DISABLE, leave=False)\n kwargs_.update(kwargs)\n clear_tqdm()\n return tq.tqdm(*args, **kwargs_)",
"def tqdm_notebook(*args, **kwargs): # pragma: no cover\n from ._tqdm_notebook import tqdm_notebook as _tqdm_n... | [
"0.7338987",
"0.65732175",
"0.6251407",
"0.60839",
"0.6057334",
"0.5817028",
"0.56528646",
"0.56528646",
"0.5522953",
"0.54382324",
"0.54152805",
"0.54006755",
"0.5382825",
"0.5379074",
"0.53534347",
"0.5342401",
"0.527672",
"0.5274278",
"0.52671427",
"0.5219475",
"0.51885796... | 0.8139409 | 0 |
This function converts an ipython notebook to a .py file, removes the convert command, and copies the .py to the Anaconda directory where it can be imported by other notebooks. Don't forget to add ' end of .py file'. | def convert_to_py(fname):
exec_command("ipython nbconvert --to=python " + fname + ".ipynb")
f = open(fname + '.py', 'r')
all_lines = f.readlines()
f.close()
end_line_num = all_lines.index('# end of .py file\n')
f = open(fname + '.py', 'w')
f.writelines(all_lines[:end_line_num])
f.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_convert(args):\n try:\n file_path = args.file_name # os.path.join(static_path, args.file_name)\n if args.slides:\n config_path = os.path.join(static_path, \"config\", \"slides_config.py\")\n output = subprocess.check_output(\n [\n \... | [
"0.6690791",
"0.6655869",
"0.59970456",
"0.59338504",
"0.59105814",
"0.5771607",
"0.5758488",
"0.5513806",
"0.5423735",
"0.5398756",
"0.5371834",
"0.53497887",
"0.533573",
"0.5253323",
"0.52508056",
"0.5236259",
"0.52301824",
"0.5228149",
"0.52050316",
"0.51480156",
"0.503169... | 0.7036844 | 0 |
Return 8x3 list giving the rows, columns, diagonal, and antidiagonal of a 3x3 matrix. | def row_col_diag(arr):
three_sets = np.zeros((8,3), dtype=int)
for i in range(arr.shape[0]):
three_sets[i] = arr[i]
for i in range(arr.shape[1]):
three_sets[i+3] = arr[:,i]
three_sets[6] = np.diag(arr)
three_sets[7] = np.diag(np.flipud(arr))
return three_sets | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getdiag(self):\n out = []\n for x in xrange(0, self.lendiag()):\n out.append(self.retrieve(x))\n return out",
"def test_scanmatrixlines_3x3_returns16lists():\n expected = [\n [1, 2, 3], [4, 5, 6], [7, 8, 9],\n [1, 4, 7], [2, 5, 8], [3, 6, 9],\n [7], [4,... | [
"0.6542143",
"0.64369875",
"0.6270617",
"0.6098526",
"0.6096621",
"0.60538954",
"0.60484993",
"0.6033331",
"0.6016216",
"0.5939279",
"0.5934395",
"0.5915065",
"0.5816082",
"0.5778242",
"0.57632416",
"0.575525",
"0.5744145",
"0.5711642",
"0.57073534",
"0.57073534",
"0.57008743... | 0.7105803 | 0 |
Turn 1, 1, and 0 into, respectively, 'X', 'O', and ' '. | def xo_convert(n):
if n == 1:
return "X"
elif n == -1:
return "O"
else:
return " " | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opp(c):\n return 'x' if c == 'o' else 'o'",
"def x_pow_one(nom):\n\tif 'X' in nom and '^' not in nom:\n\t\treturn nom.replace('X', 'X^1')\n\treturn nom",
"def bin_to_char(exp):\n new_exp = \"\"\n for i in range(0,len(exp)):\n if exp[i] == \"1\":\n new_exp += \"#\"\n else:\... | [
"0.6210847",
"0.6182411",
"0.6099019",
"0.5970165",
"0.5955223",
"0.5952791",
"0.59230816",
"0.5864503",
"0.584585",
"0.581593",
"0.5792662",
"0.5771425",
"0.5751693",
"0.57507646",
"0.57293314",
"0.57267",
"0.57137376",
"0.5680069",
"0.56273484",
"0.562184",
"0.5616875",
"... | 0.7854444 | 0 |
Creates the image in OpenStack if it does not already exist | def create(self):
if self.image:
return self.image
import nova_utils
nova = nova_utils.nova_client(self.os_creds)
image_dict = None
try:
# TODO/FIXME - Certain scenarios, such as when the name has whitespace,
# the image with a given name is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def glance_create_new_image(glance, images_location, image_info, image_name_prefix=None):\n # image raw file path\n image_raw_source = image_info['image_raw_source']\n image_file = os.path.join(images_location, image_raw_source)\n\n if not os.path.isfile(image_file):\n logger.warning(\"image raw... | [
"0.6636871",
"0.6582884",
"0.6358659",
"0.6310891",
"0.6277768",
"0.62519765",
"0.62417156",
"0.62242746",
"0.61912566",
"0.61556125",
"0.6065953",
"0.605718",
"0.6038255",
"0.60134196",
"0.6013053",
"0.60043067",
"0.5977835",
"0.5965737",
"0.5945465",
"0.59138167",
"0.591309... | 0.71788144 | 0 |
Returns the image file reference. If the image file does not exist, download it | def __get_image_file(self):
if file_utils.file_exists(self.image_file_path):
return open(self.image_file_path, 'r')
else:
if not os.path.exists(self.download_path):
os.makedirs(self.download_path)
logger.info('Found existing image file')
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __download_image_file(self):\n if not file_utils.file_exists(self.image_file_path):\n logger.info('Downloading Image from - ' + self.image_url)\n return file_utils.download(self.image_url, self.download_path)",
"def download_image(filename):\n return ImageApiHandler.image_... | [
"0.8210503",
"0.76130706",
"0.73505574",
"0.6925539",
"0.6918392",
"0.69012165",
"0.6831053",
"0.6781228",
"0.67241114",
"0.6714646",
"0.66244733",
"0.66124684",
"0.6587157",
"0.65493",
"0.65449435",
"0.6515331",
"0.65109783",
"0.6509099",
"0.6494998",
"0.64621663",
"0.643112... | 0.81886154 | 1 |
Downloads the image file | def __download_image_file(self):
if not file_utils.file_exists(self.image_file_path):
logger.info('Downloading Image from - ' + self.image_url)
return file_utils.download(self.image_url, self.download_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_image(filename):\n return ImageApiHandler.image_handler.get(filename)",
"def download_image(self, url):\r\n file_path = os.path.join(self.temp_dir, 'image.png')\r\n urlretrieve(url, file_path)\r\n return file_path",
"def __get_image_file(self):\n if file_utils.fi... | [
"0.77523816",
"0.7711154",
"0.7289846",
"0.7198905",
"0.71218306",
"0.70532143",
"0.7027885",
"0.700101",
"0.69916904",
"0.69828",
"0.6942051",
"0.6933775",
"0.6932163",
"0.69152945",
"0.6915093",
"0.69147563",
"0.6903136",
"0.6877438",
"0.6865126",
"0.6805982",
"0.6801481",
... | 0.8033153 | 0 |
Get a single Manhua by its id | def manhuas_id_get(id): # noqa: E501
return query_manager.get_resource(id=id,
rdf_type_uri=MANHUA_TYPE_URI,
rdf_type_name=MANHUA_TYPE_NAME,
kls=Manhua) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, id):\n return Matstamm.find_by_id(id)",
"def get_object(id):",
"def get(self, _id):",
"def get(self,id):\r\n person = get_one(id=id)\r\n if not person:\r\n api.abort(404)\r\n else:\r\n return person",
"def get(cls, id):\n\n return cls.q... | [
"0.7278572",
"0.6999828",
"0.6932419",
"0.68721354",
"0.67988896",
"0.67988896",
"0.6786893",
"0.67067605",
"0.67003685",
"0.6599542",
"0.6571097",
"0.65241545",
"0.6489759",
"0.64433765",
"0.64374375",
"0.6410633",
"0.6384549",
"0.635959",
"0.6356493",
"0.63436085",
"0.63390... | 0.82101154 | 0 |
Private method for finding of download url and name of last version of frida server for android | def __get_url_and_name(self, arch: str):
page = requests.get(self.releases_url)
page_text = page.text
soup = BeautifulSoup(page_text, features="html.parser")
regex = re.compile('frida-server-[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}-android-' + arch, re.IGNORECASE)
frida_server_name = sou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_download_url(self):\n devpage = requests.get(DEVPAGE_URL)\n soup = BeautifulSoup(devpage.text, 'html.parser')\n rt = soup.find(id='rightcolumn')\n anchors = rt.findAll('a')\n for anchor in anchors:\n href = anchor.attrs['href']\n if href.endswith('.... | [
"0.6429049",
"0.6176465",
"0.6167387",
"0.6135402",
"0.6062519",
"0.59826505",
"0.59443015",
"0.5865929",
"0.58576757",
"0.5854857",
"0.58214295",
"0.57686764",
"0.5742846",
"0.57394814",
"0.5711802",
"0.56878114",
"0.5658921",
"0.5655116",
"0.56454843",
"0.5639779",
"0.56262... | 0.7424144 | 0 |
creates stochastic version of Gardner's gene toggle model | def create_model_gene_toggle(max_s1_copies=100, max_s2_copies=100):
s1_count = lambda s1, s2 : s1
s2_count = lambda s1, s2 : s2
s1_birth = lambda s1, s2 : 16.0/(1.0+s2)
s1_death = lambda s1, s2 : 1.0*s1
s2_birth = lambda s1, s2 : 50.0/(1.0+(s1**2.5))
s2_death = lambda s1, s2 : 1.0*s2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _hg_model_fn(features, labels, mode, params):\n is_training = (mode == tf.estimator.ModeKeys.TRAIN)\n weight_decay = params.weight_decay\n momentum = params.momentum\n decay_factor = params.decay_factor\n decay_step = params.decay_step\n init_learning_rate = params.init_learning_rate\n num... | [
"0.53975487",
"0.5394964",
"0.5384086",
"0.536451",
"0.5326402",
"0.52954835",
"0.52881545",
"0.52797973",
"0.5263367",
"0.5261843",
"0.52510035",
"0.52152216",
"0.52140915",
"0.5206617",
"0.51791567",
"0.5175483",
"0.5157839",
"0.5151441",
"0.5127721",
"0.5115076",
"0.507767... | 0.7586326 | 0 |
Denests an expression that contains nested square roots. | def sqrtdenest (expr):
expr = sympify(expr)
if expr.is_Pow and expr.exp is S.Half: #If expr is a square root
return denester([expr])[0]
return expr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def denester (nested):\n if all((n**2).is_Number for n in nested): #If none of the arguments are nested\n for f in subsets(len(nested)): #Test subset 'f' of nested\n p = prod(nested[i]**2 for i in range(len(f)) if f[i]).expand()\n if 1 in f and f.count(1) > 1 and f[-1]: p = -p\n ... | [
"0.6896922",
"0.6043629",
"0.59849846",
"0.5922657",
"0.59038043",
"0.5823445",
"0.58146596",
"0.5793079",
"0.57804644",
"0.57395005",
"0.5695278",
"0.5685111",
"0.5664562",
"0.5645821",
"0.5620064",
"0.56190675",
"0.5606242",
"0.55986995",
"0.5581013",
"0.5559273",
"0.554938... | 0.70765764 | 0 |
Denests a list of expressions that contain nested square roots. This method should not be called directly use 'denest' instead. | def denester (nested):
if all((n**2).is_Number for n in nested): #If none of the arguments are nested
for f in subsets(len(nested)): #Test subset 'f' of nested
p = prod(nested[i]**2 for i in range(len(f)) if f[i]).expand()
if 1 in f and f.count(1) > 1 and f[-1]: p = -p
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sum_expression(self):\n # The logic of SumExpression is checked in the above tests (which include\n # addition and subtraction). Here, we only check that constructing a\n # SumExpression flattens the list.\n structure_memoizer = {\n defaults.DENOMINATOR_LOWER_BOUND_KEY: 0.0,\n de... | [
"0.62695044",
"0.6142509",
"0.57942927",
"0.5488867",
"0.54754835",
"0.54533607",
"0.5403379",
"0.5387797",
"0.53272367",
"0.53124315",
"0.5282791",
"0.5224005",
"0.52176845",
"0.5194085",
"0.5188306",
"0.5179866",
"0.5165743",
"0.51421887",
"0.5111471",
"0.50850046",
"0.5078... | 0.66358936 | 0 |
Returns all possible subsets of the set (0, 1, ..., n1) except the empty set. | def subsets(n):
binary = lambda x: x>0 and binary(x>>1) + [x&1] or []
pad = lambda l: [0]*(n-len(l)) + l #Always returns a list of length 'n'
return [pad(binary(i)) for i in range(1, 2**n)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allSubsets(self):\n n = self.graph.n\n subsets = np.zeros((2**n,n))\n for i in range(2**n):\n binary = np.array(list(bin(i)[2:])).astype(float)\n if binary.shape[0] < n:\n padding = np.zeros(n-binary.shape[0])\n subsets[i,:] = np.append(... | [
"0.7304939",
"0.6939716",
"0.6939716",
"0.69092846",
"0.68856454",
"0.68767667",
"0.67554104",
"0.67149925",
"0.66519034",
"0.66332114",
"0.64102685",
"0.6401927",
"0.6380161",
"0.6379676",
"0.6356411",
"0.63498825",
"0.6328516",
"0.6322608",
"0.6320797",
"0.6247256",
"0.6236... | 0.7694586 | 0 |
Returns the product of all elements of n, as a Rational. | def prod(n):
product = S.One
for i in n:
product = product * i
return product | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiply(self, n): \n f_num = self.num*n.num\n f_den = self.den*n.den\n f = Fraction(f_num, f_den)\n return f.reduce()",
"def prod_of_nth(n):\n factorial = 1\n for i in range(1,n+1):\n factorial *= i\n return factorial",
"def __mul__(self, n):\n as... | [
"0.7174945",
"0.6563755",
"0.6436478",
"0.63774896",
"0.631241",
"0.62883914",
"0.62796164",
"0.62260956",
"0.62194073",
"0.6203918",
"0.61760634",
"0.61431354",
"0.61146164",
"0.61055475",
"0.6087843",
"0.6079033",
"0.60457134",
"0.6006618",
"0.59772867",
"0.59496444",
"0.59... | 0.7256208 | 0 |
Takes a name and returns an ID retrieved from the gGUIIDS dictionary. If the name is not in the dict, it's added. | def guiID(name):
if not gGUIIDS.has_key(name):
gGUIIDS[name] = wx.NewId()
return gGUIIDS[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_to_id(self, name, add_if_missing=False):\n if isinstance(name, basestring):\n # lookup name or assign new\n if name not in self.names:\n if not add_if_missing:\n raise ValueError(\"name \" + name + \" not found\")\n # Use an emp... | [
"0.6672799",
"0.6143603",
"0.6004908",
"0.5935843",
"0.588576",
"0.5862737",
"0.58363074",
"0.5768236",
"0.5768236",
"0.576694",
"0.57117486",
"0.55991846",
"0.5593386",
"0.5582992",
"0.5563325",
"0.55218446",
"0.55121285",
"0.5479918",
"0.5430901",
"0.5421324",
"0.54157084",... | 0.7906555 | 0 |
Concatenate each sample in samples horizontally, along axis 1. Return the resulting array. | def get_concatenated_row(samples):
return np.concatenate([sample for sample in samples], axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_concatenated_col(samples):\n return np.concatenate([sample for sample in samples], axis=0)",
"def concatenate(arrays, **kwargs):\n unit = unit_of(arrays[0])\n result = np.concatenate([to_unitless(arr, unit) for arr in arrays], **kwargs)\n return result * unit",
"def concat(xs, axis=1):\n ... | [
"0.72359675",
"0.6499968",
"0.6493327",
"0.6439808",
"0.619693",
"0.6166372",
"0.60156375",
"0.5976714",
"0.58696514",
"0.5841752",
"0.57607317",
"0.573856",
"0.5716519",
"0.5697366",
"0.565814",
"0.5611839",
"0.5608943",
"0.557394",
"0.5545506",
"0.55205667",
"0.55101043",
... | 0.7622855 | 0 |
Concatenate each sample in samples vertically, along axis 0. Return the resulting array. | def get_concatenated_col(samples):
return np.concatenate([sample for sample in samples], axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_concatenated_row(samples):\n return np.concatenate([sample for sample in samples], axis=1)",
"def concatonate(data):\n tmp = np.array(data)\n tmp = np.reshape(tmp, (tmp.shape[0] * tmp.shape[1], -1))\n return tmp",
"def wrap(self, samples):\n\n rows, cols = samples.shape[:2]\n ... | [
"0.6825311",
"0.60100585",
"0.5970394",
"0.5881012",
"0.57274216",
"0.5629702",
"0.55640787",
"0.5547741",
"0.55183864",
"0.5463207",
"0.5458389",
"0.5414258",
"0.5409394",
"0.5360371",
"0.5326923",
"0.5292973",
"0.5278876",
"0.5277933",
"0.5271905",
"0.5263208",
"0.52608395"... | 0.69898236 | 0 |
Callback for event_in msg | def eventInCallback(self, msg):
rospy.loginfo("event_in msg received")
self.event_in = msg.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_in_cb(self, msg):\n self.event = msg.data",
"def msg_event(self, event):\r\n pass",
"def event_receive(self,event):\n\n pass",
"def _handle_message(self, msg):\n self.event('message', msg)",
"def process_event(self, event):\r\n pass",
"def on_event(self, event):",... | [
"0.8662638",
"0.78358436",
"0.7139262",
"0.69602036",
"0.69505644",
"0.69212675",
"0.68724275",
"0.6847703",
"0.68112975",
"0.67634106",
"0.67600983",
"0.65930665",
"0.65206",
"0.6503782",
"0.64967126",
"0.6489662",
"0.6486914",
"0.6473191",
"0.64333844",
"0.64333844",
"0.642... | 0.8784337 | 0 |
True if a next page exists. | def has_next(self):
return self.page < self.pages | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_next(self):\n return self.current_page < self.pages",
"def has_next_page(self):\n if self.page_number == 0:\n return True\n\n return self.next_page_token is not None",
"def list_has_next_page(self, soup):\n\n # Check for the 'next page' element at the bottom of th... | [
"0.8679172",
"0.8661847",
"0.80350786",
"0.7795365",
"0.77713907",
"0.7578386",
"0.7563336",
"0.74716824",
"0.7424023",
"0.73894376",
"0.73567814",
"0.7348578",
"0.7318991",
"0.73121655",
"0.7292514",
"0.72168624",
"0.71238124",
"0.7098628",
"0.7048289",
"0.6925768",
"0.69049... | 0.86719596 | 1 |
Renames the Storage Element in the DBS. | def dbsApiImplRenameSE(self, storage_element_from, storage_element_to):
funcInfo = inspect.getframeinfo(inspect.currentframe())
seNameFrom = get_name(storage_element_from)
seNameTo = get_name(storage_element_to)
data = self._server._call ({ 'api' : 'updateSEName',
'storage_element_name_from... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_vg(self, new_name):\n self.metadata.rename_vg(new_name)",
"def name(self, new_name):\n self.rename(new_name)",
"def rename(self, new_name):\n\n self.__enforce_connected()\n current_url = self.url\n self._set_field(\"name\",new_name)\n self.set_json(self._htt... | [
"0.64199173",
"0.6355908",
"0.60965645",
"0.5981445",
"0.59720033",
"0.5965701",
"0.58491737",
"0.584779",
"0.584779",
"0.58017844",
"0.5783619",
"0.57192796",
"0.57183737",
"0.56618834",
"0.5659627",
"0.5656443",
"0.5645224",
"0.5639042",
"0.5623491",
"0.5615697",
"0.5606497... | 0.71032864 | 0 |
Returns a slip number starting at 1 and auto increments thereafter. NO RESET ON PROGRAM REDEPLOY only on deleting Slip entities. | def getSlipNum():
query = Slip.query()
results = query.fetch(limit = MAX_SLIPS)
temp = 0
for result in results:
if result.number > temp:
temp = result.number
slipNum = temp
slipNum += 1
return slipNum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self):\n _id = super(SchedulePhase, self).id\n return _id + 1",
"def _get_sprint_number() -> int:\n sprint = get_value_from_redis('sprint-number')\n if not sprint:\n sprint = JIRA_SPRINT\n return int(sprint)",
"def next_move(ttype):\n count = db.session.q... | [
"0.56331414",
"0.55639076",
"0.54039794",
"0.53689134",
"0.52841884",
"0.52100134",
"0.5177412",
"0.5177412",
"0.51675767",
"0.51634294",
"0.5161609",
"0.513854",
"0.51240927",
"0.5112452",
"0.51088494",
"0.51081693",
"0.5086091",
"0.508494",
"0.5073603",
"0.5061621",
"0.5052... | 0.66455674 | 0 |
Instantiates a new boat object and returns json string with its details. | def post(self):
parent_key = ndb.Key(Boat, "parent_boat")
boat_data = json.loads(self.request.body)
new_boat = Boat(id=None, name=boat_data['name'], type=boat_data['type'],
length=boat_data['length'], at_sea=True, parent=parent_key)
new_boat.put()
new_boat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n query = Boat.query()\n results = query.fetch(limit = MAX_BOATS)\n boat_dicts = []\n for match in results:\n boat_dicts.append({'id': match.id, 'name': match.name, 'type': match.type,\n 'length': match.length, 'at_sea': match.at_s... | [
"0.6134405",
"0.5953638",
"0.58842367",
"0.5856151",
"0.5779485",
"0.5639422",
"0.5606406",
"0.5595455",
"0.5578063",
"0.55134076",
"0.5495442",
"0.5480072",
"0.53981155",
"0.53549975",
"0.5312522",
"0.5308995",
"0.5296416",
"0.5265275",
"0.52622354",
"0.52611625",
"0.5233775... | 0.6180553 | 0 |
Returns json string with Boat entity details by id. | def get(self, id=None):
if id:
boat = test4ValidEntity(id)
if boat == None:
self.response.set_status(404)
else:
boat_dict = boat.to_dict()
self.response.headers['Content-Type'] = 'application/json'
self.response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, id):\n return {'id': id}",
"def get_item(id):\n return jsonify(id=id, name='name', number=123)",
"def companies_by_id(id):\n res = requests.get('http://0.0.0.0:5002/company/{}/products'.format(id))\n return jsonify(res.json())",
"def get(id):\n elements = Advertisements().get... | [
"0.6378625",
"0.6359808",
"0.61525065",
"0.6144673",
"0.6111232",
"0.60792804",
"0.607883",
"0.60710144",
"0.60687",
"0.6054664",
"0.59475464",
"0.59396726",
"0.59264404",
"0.58963346",
"0.58800006",
"0.58496755",
"0.5830119",
"0.5822737",
"0.5814824",
"0.57946306",
"0.578758... | 0.75867003 | 0 |
Deletes a Boat entity. | def delete(self, id=None):
if id:
boat = test4ValidEntity(id)
if boat == None:
self.response.set_status(404)
else:
if boat.at_sea == False:
query = Slip.query(Slip.current_boat == boat.id)
result = query.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_boat(self):\n pass",
"def delete(self, id=None):\n if id:\n slip = test4ValidEntity(id)\n if slip == None:\n self.response.set_status(404)\n else:\n if slip.current_boat != None:\n \"\"\" Tests for a B... | [
"0.6431189",
"0.6331093",
"0.6189687",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6158346",
"0.6120139",
"0.6097573",
"0.6080516",
"0.60249275",
"0.60249275",
"0.60249275",
"0.60249275",
"0.5943314",
"0.5942308",... | 0.7158646 | 0 |
Mutates user supplied Boat entity properties by id. Unaddressed properties remain. | def patch(self, id=None):
if id:
boat = test4ValidEntity(id)
if boat == None:
self.response.set_status(404)
else:
boat_data = json.loads(self.request.body)
if 'name' in boat_data:
boat.name = boat_data['name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(table, id_):\n ID = 0\n ids = [item[ID] for item in table]\n if id_ not in ids:\n raise ValueError(\"The given ID not in the table.\")\n titles_sales = [\"Name: \", \"Birth Year: \"]\n inputs = ui.get_inputs(titles_sales, \"Specify new properties\")\n for index, item in enumerat... | [
"0.60556465",
"0.5540154",
"0.5538673",
"0.5526356",
"0.5473278",
"0.54686195",
"0.54657865",
"0.5454497",
"0.54063725",
"0.52172124",
"0.5209413",
"0.5209413",
"0.5175859",
"0.5163642",
"0.5153528",
"0.5133642",
"0.5127958",
"0.5118953",
"0.5105042",
"0.5085077",
"0.5072867"... | 0.5941151 | 1 |
Mutates user supplied Boat entity properties by id. Unaddressed properties, where allowed, become None (null). Returns updated Boat entity json string. | def put(self, id=None):
if id:
boat = test4ValidEntity(id)
if boat == None:
self.response.set_status(404)
else:
boat_data = json.loads(self.request.body)
if 'name' in boat_data:
boat.name = boat_data['name']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, id=None):\n if id:\n boat = test4ValidEntity(id)\n if boat == None:\n self.response.set_status(404)\n else:\n boat_data = json.loads(self.request.body)\n if 'name' in boat_data:\n boat.name = boa... | [
"0.642934",
"0.58710945",
"0.57078266",
"0.5431871",
"0.5274404",
"0.5214651",
"0.5195765",
"0.5161442",
"0.50988567",
"0.5096104",
"0.50762004",
"0.5066248",
"0.50660175",
"0.5055261",
"0.5034231",
"0.5026359",
"0.502098",
"0.50012106",
"0.49968147",
"0.49965915",
"0.4989595... | 0.61614597 | 1 |
Returns an array of json objects representing all Boat entities. | def get(self):
query = Boat.query()
results = query.fetch(limit = MAX_BOATS)
boat_dicts = []
for match in results:
boat_dicts.append({'id': match.id, 'name': match.name, 'type': match.type,
'length': match.length, 'at_sea': match.at_sea })
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n return {'bills': [bill.json() for bill in BillModel.find_all()]}",
"def jsonify_all(cls):\n return jsonify(accounts=[account.as_dict() for account in cls.query.all()])",
"def TOBS():\n session = Session(engine)\n # Query all passengers\n\n TOBS = session.query(Measuremen... | [
"0.66011316",
"0.65072656",
"0.63690925",
"0.63595057",
"0.62545437",
"0.6199981",
"0.6179565",
"0.6169542",
"0.613204",
"0.61151505",
"0.6094793",
"0.608647",
"0.6081628",
"0.6066895",
"0.6056461",
"0.6009723",
"0.5975167",
"0.5933342",
"0.5926198",
"0.59116733",
"0.58876383... | 0.681285 | 0 |
Returns json string with Slip entity details by id. | def get(self, id=None):
if id:
slip = test4ValidEntity(id)
if slip == None:
self.response.set_status(404)
else:
slip_dict = slip.to_dict()
slip_dict['departure_history'] = {}
slip_dict['departure_history']['depar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item(id):\n return jsonify(id=id, name='name', number=123)",
"def get(self, id):\n return {'id': id}",
"def get_one_stock(id):\r\n print(\"<get_one_stock()>\")\r\n print(\"id: \", id)\r\n stocks = Stock.objects(id=id).first()\r\n return jsonify(json.loads(stocks.to... | [
"0.66123515",
"0.6180184",
"0.5928225",
"0.5881289",
"0.58054954",
"0.57594967",
"0.5753017",
"0.5671553",
"0.56611335",
"0.5634447",
"0.56203264",
"0.5611418",
"0.55989206",
"0.5598792",
"0.5573988",
"0.55618095",
"0.55421466",
"0.5537874",
"0.55092967",
"0.54937154",
"0.548... | 0.67899144 | 0 |
Deletes a Slip entity. If slip was occupied, returns that Boat entity's json string. | def delete(self, id=None):
if id:
slip = test4ValidEntity(id)
if slip == None:
self.response.set_status(404)
else:
if slip.current_boat != None:
""" Tests for a Boat "docked" in slip to be deleted. if found, sets the
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Delete(self):\n self.__context.builder.BlipDelete(self.GetWaveId(),\n self.GetWaveletId(),\n self.GetId())\n return self.__context.RemoveBlip(self.GetId())",
"def remove(self, spo, context=None):\n\n uri = self.rest_servic... | [
"0.60876894",
"0.57072854",
"0.5664537",
"0.5424277",
"0.53834593",
"0.53725517",
"0.53673273",
"0.5352611",
"0.5321147",
"0.5274949",
"0.5266084",
"0.5247238",
"0.52407867",
"0.52098083",
"0.5192416",
"0.5168681",
"0.51632714",
"0.51488656",
"0.5146871",
"0.51223814",
"0.511... | 0.6559253 | 0 |
Mutates user supplied Slip entity properties by id. Unaddressed properties remain. Returns updated Slip entity json string. | def patch(self, id=None):
if id:
slip = test4ValidEntity(id)
if slip == None:
self.response.set_status(404)
else:
slip_data = json.loads(self.request.body)
if 'number' in slip_data:
""" Test for Slip number a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, id=None):\n if id:\n slip = test4ValidEntity(id)\n if slip == None:\n self.response.set_status(404)\n else:\n slip_data = json.loads(self.request.body)\n if 'number' in slip_data:\n \"\"\" Test for... | [
"0.58525246",
"0.5443223",
"0.5127894",
"0.5005448",
"0.49910688",
"0.4909347",
"0.4842506",
"0.48118356",
"0.4784188",
"0.47828564",
"0.47294396",
"0.46688277",
"0.4649701",
"0.46442547",
"0.46272856",
"0.46249476",
"0.4617809",
"0.45987448",
"0.45408234",
"0.45397025",
"0.4... | 0.61305434 | 0 |
Mutates user supplied Slip entity properties by id. Unaddressed properties, where allowed, become None (null). Returns updated Slip entity json string. | def put(self, id=None):
if id:
slip = test4ValidEntity(id)
if slip == None:
self.response.set_status(404)
else:
slip_data = json.loads(self.request.body)
if 'number' in slip_data:
""" Test for requested Slip ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, id=None):\n if id:\n slip = test4ValidEntity(id)\n if slip == None:\n self.response.set_status(404)\n else:\n slip_data = json.loads(self.request.body)\n if 'number' in slip_data:\n \"\"\" Test f... | [
"0.5986681",
"0.5305798",
"0.49620193",
"0.48357922",
"0.47986293",
"0.47317642",
"0.47040105",
"0.47010326",
"0.46749356",
"0.4651737",
"0.46378273",
"0.46107113",
"0.45864484",
"0.45753363",
"0.45692047",
"0.4544636",
"0.4535495",
"0.4522036",
"0.45060802",
"0.44929498",
"0... | 0.582127 | 1 |
Manage a Boat Departure. Returns json of affected Slip details or ignores if requested departure Boat ID does not match requested Slip's current_boat ID. | def patch(self, id=None):
if id:
boat2Depart = test4ValidEntity(id)
if boat2Depart == None:
self.response.set_status(404)
else:
requestBody = json.loads(self.request.body)
query = Slip.query(Slip.number == requestBody['number'])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, id=None):\n if id:\n slip = test4ValidEntity(id)\n if slip == None:\n self.response.set_status(404)\n else:\n slip_data = json.loads(self.request.body)\n if 'number' in slip_data:\n \"\"\" Test for... | [
"0.6218137",
"0.60290563",
"0.53608197",
"0.529036",
"0.5263001",
"0.5204306",
"0.5138205",
"0.5055655",
"0.50181365",
"0.4956566",
"0.49363345",
"0.49132457",
"0.49068174",
"0.4871912",
"0.4846284",
"0.48194218",
"0.4819195",
"0.48055452",
"0.47923288",
"0.47755215",
"0.4752... | 0.63698965 | 0 |
This function creates and saves the game skeleton demo level. | def create_level(self, name):
# Create a level object
level = Level()
size_y=8
size_x=10
# Separates static and non static parts
# This will speed up network games, since only the non static part will be
# sent on the network
level_static = soya.World(level)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_file(self, sub):\n fileout = os.path.join(self.saving_dir, 'output_skeleton_' + str(sub) + '.nii.gz')\n print('writing altered skeleton to', fileout)\n aims.write(self.skel, fileout)",
"def setupLevel(self):\n\n self.state = GameState.SETUP\n\n # vado a leggere il dizi... | [
"0.6555112",
"0.63954264",
"0.60957974",
"0.59587157",
"0.595166",
"0.5925911",
"0.5789536",
"0.5764247",
"0.57258284",
"0.572253",
"0.5666389",
"0.56209296",
"0.56123316",
"0.5584476",
"0.5532978",
"0.5499502",
"0.54859984",
"0.5485555",
"0.54709125",
"0.5452631",
"0.5421089... | 0.6491367 | 1 |
Route to update project the function has two operations based on the request method. | def update_project(id):
if request.method == "POST":
result = update_project_to_db(
id,
request.form["title"],
request.form["link"],
request.form["description"]
)
flash(result)
return redirect(url_for("portfolio"))
else:
pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateProjects(request):\n\n updater = ProjectUpdater()\n updater.run()\n return http.HttpResponse(\"Ok\")",
"def update(self,request,pk = None):\n return Response({'http_method':'PUT'})",
"def update(self, request, pk=None): #update a specific object\n return Response({'http_method': 'PUT... | [
"0.7155244",
"0.6591015",
"0.6561205",
"0.64658177",
"0.64653176",
"0.6429136",
"0.6314935",
"0.62550044",
"0.6197096",
"0.6190579",
"0.6131291",
"0.6110216",
"0.61091644",
"0.61053795",
"0.6087666",
"0.6058647",
"0.602651",
"0.602456",
"0.60025024",
"0.5998193",
"0.5983591",... | 0.6630064 | 1 |
Route to add project. The function has two operations based on the request method | def add_project():
if request.method == "POST":
result = add_project_to_db(
request.form["title"],
request.form["link"],
request.form["description"]
)
flash(result)
return redirect(url_for("portfolio"))
else:
return render_template("add... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects_route():\n response_object = {'status': 'success'}\n if request.method == 'POST':\n post_data = request.get_json()\n if post_data is not None:\n add_project(post_data)\n response_object['message'] = 'Project added!'\n else:\n response_object['pro... | [
"0.71713793",
"0.6893478",
"0.6753157",
"0.66714686",
"0.6621897",
"0.64958745",
"0.64496964",
"0.6436584",
"0.63982916",
"0.63779765",
"0.6225331",
"0.61893666",
"0.6065161",
"0.60603213",
"0.60536176",
"0.6027334",
"0.5993403",
"0.59387577",
"0.5909622",
"0.58471173",
"0.57... | 0.72942376 | 0 |
Basic test to make sure the home directory is returned. Also checks to see if the passed in project_name is appended to the path in the returned value. | def test_find_home_directory():
dir = find.home_direcotry()
nt.ok_(os.path.exists(dir))
project_name = 'test'
dir = find.home_direcotry(project_name)
project_name = ".{0}".format(project_name)
nt.ok_(dir.endswith(project_name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_projects_dir():\n # assert path.get_projects_dir() == '/home/pfanelli/python-devel'\n pass",
"def test_get_home_directory(self, subprocess_mock, _, _2):\n subprocess_mock.return_value = b'HOME_DIRECTORY'\n self.assertEqual('HOME_DIRECTORY',\n iossim_util.get_home_dire... | [
"0.683315",
"0.6561728",
"0.6349326",
"0.62901163",
"0.6190666",
"0.6129038",
"0.6125085",
"0.6117744",
"0.6084706",
"0.60805786",
"0.6034056",
"0.6018535",
"0.5919452",
"0.59177035",
"0.59023166",
"0.58581406",
"0.58504355",
"0.5825954",
"0.5818992",
"0.58094126",
"0.5795476... | 0.7624633 | 0 |
Test to make sure the system config directory is returned. Also checks to see if the passed in project_name is appended to the path in the returned value. | def test_find_system_config_directory():
dir = find.system_config_directory()
nt.ok_(os.path.exists(dir))
project_name = 'test'
dir = find.system_config_directory(project_name)
nt.ok_(dir.endswith(project_name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_project_config_directory():\n dir = find.project_config_directory(False)\n nt.ok_(os.path.exists(dir))\n\n dir = find.project_config_directory()\n nt.ok_(dir.endswith('config'))",
"def test_config_get(self):\n test_name = sys._getframe().f_code.co_name\n self.env.config.se... | [
"0.71266794",
"0.66663754",
"0.6475454",
"0.6352774",
"0.6328156",
"0.631857",
"0.62289643",
"0.61653954",
"0.6149517",
"0.61000323",
"0.6091144",
"0.6088514",
"0.6035728",
"0.6010017",
"0.5962612",
"0.5958839",
"0.595415",
"0.5898134",
"0.5865054",
"0.5847888",
"0.5824562",
... | 0.78222615 | 0 |
Test to make sure the project directory is returned. Also checks to be sure that 'config is appended to the returned value. | def test_find_project_config_directory():
dir = find.project_config_directory(False)
nt.ok_(os.path.exists(dir))
dir = find.project_config_directory()
nt.ok_(dir.endswith('config')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_projects_dir():\n # assert path.get_projects_dir() == '/home/pfanelli/python-devel'\n pass",
"def test_find_system_config_directory():\n dir = find.system_config_directory()\n nt.ok_(os.path.exists(dir))\n\n project_name = 'test'\n dir = find.system_config_directory(project_name)\n... | [
"0.73030764",
"0.7246068",
"0.700198",
"0.6881496",
"0.6849748",
"0.67954606",
"0.6739453",
"0.6699555",
"0.6686036",
"0.6663459",
"0.6623424",
"0.6605419",
"0.6453499",
"0.6422474",
"0.6410907",
"0.63848305",
"0.6329559",
"0.6272082",
"0.626627",
"0.6255891",
"0.6252284",
... | 0.78609085 | 0 |
Test to make sure that three config directories are returned. | def test_find_config_directories():
dirs = find.config_directories('test')
nt.eq_(len(dirs), 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_result_directories(self):\n pass",
"def test_config():\n if not os.path.exists(CONFIG_DIR):\n raise mupub.BadConfiguration('Configuration folder not found.')\n if not os.path.exists(_CONFIG_FNM):\n raise mupub.BadConfiguration('Configuration file not found.')\n if not o... | [
"0.6819444",
"0.65486413",
"0.6503178",
"0.6452762",
"0.6326768",
"0.62709665",
"0.62600607",
"0.62281007",
"0.62278634",
"0.6211113",
"0.61404324",
"0.611129",
"0.61100394",
"0.60971874",
"0.6079131",
"0.6072936",
"0.6057406",
"0.605582",
"0.6047787",
"0.6046509",
"0.6040891... | 0.8166695 | 0 |
Test to make sure that the multiple config files are being found | def test_find_multiple_config_files():
config_files = ['~/test__dodai__config.test', '~/test__dodai__config.cfg']
non_exist_file = '~/test__dodai_config'
good_files = []
# touch the files
for config_file in config_files:
path = os.path.expanduser(config_file)
good_files.append(path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_config():\n if not os.path.exists(CONFIG_DIR):\n raise mupub.BadConfiguration('Configuration folder not found.')\n if not os.path.exists(_CONFIG_FNM):\n raise mupub.BadConfiguration('Configuration file not found.')\n if not os.path.exists(getDBPath()):\n raise mupub.BadConfig... | [
"0.7504495",
"0.74272",
"0.7217084",
"0.71978724",
"0.7190491",
"0.71879476",
"0.711771",
"0.7064929",
"0.7038326",
"0.7013736",
"0.69715494",
"0.6963111",
"0.69172424",
"0.68899876",
"0.6855246",
"0.6827429",
"0.6785877",
"0.67457724",
"0.67337656",
"0.66984266",
"0.6672201"... | 0.7510122 | 0 |
This iterator waits until there is potentially new tip information. New tip information means a new peer connected or a new block arrived. Then it yields the peer with the highest total difficulty. It continues indefinitely, until this service is cancelled. | async def wait_tip_info(self) -> AsyncIterator[BaseChainPeer]:
if self.is_cancelled:
raise ValidationError("%s is cancelled, new tip info is impossible", self)
elif not self.is_running:
await self.events.started.wait()
with self._subscriber() as new_tip_event:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _match_predictive_node_requests_to_peers(self) -> None:\n # If self._queen_tracker terminates we need to exit as well, so check that on every\n # iteration.\n while self.manager.is_running and self._queen_tracker.get_manager().is_running:\n try:\n batch_id, ... | [
"0.5500915",
"0.5470931",
"0.5319006",
"0.5311231",
"0.5291946",
"0.521966",
"0.5215341",
"0.5215341",
"0.5193207",
"0.5080636",
"0.50669307",
"0.50526375",
"0.500329",
"0.500004",
"0.4986424",
"0.4966308",
"0.4956242",
"0.49543557",
"0.49460462",
"0.49340892",
"0.49252045",
... | 0.7476101 | 0 |
Inserts tweet into tweets collection | def insert_tweet(status):
status['replies'] = []
return db.tweets.insert(status) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_tweet(self, tweet):\r\n self.tweets.append(tweet)",
"def insert_tweet(value):\n execute(query=_query['ins_tweet'],\n value=value,\n single=False)\n\n id_value = [[element[0]]for element in value]\n\n execute(query=_query['ins_sentiment'],\n value=id_value,... | [
"0.747348",
"0.7430668",
"0.7240626",
"0.717541",
"0.7118906",
"0.7073895",
"0.6995458",
"0.6932403",
"0.6901207",
"0.6721981",
"0.65963966",
"0.65462726",
"0.65457416",
"0.652735",
"0.6409189",
"0.640749",
"0.6347634",
"0.6325132",
"0.62893474",
"0.62866",
"0.6234218",
"0.... | 0.74408054 | 1 |
Adds a reply to the saved tweet | def add_tweet_reply(tweet_id, user, text):
reply = {'user': user, 'text': text}
return db.tweets.update(
{'id_str': tweet_id}, {'$push': {'replies': reply}}, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_reply(self, comment):\n\t\tpass",
"def reply_to_tweet():\n\n print('retrieving and replying to tweets...')\n all_mentions = api.mentions_timeline()\n\n # The content of the reply that the bot will send.\n rap_message = ' yo yo yo yo'\n\n for mention in reversed(all_mentions):\n\n #... | [
"0.6981421",
"0.6746584",
"0.6701164",
"0.65988404",
"0.6539125",
"0.6533228",
"0.6533228",
"0.65100837",
"0.64546037",
"0.63149333",
"0.61954737",
"0.61765563",
"0.6176331",
"0.6119121",
"0.6108011",
"0.61018324",
"0.6095213",
"0.60768723",
"0.6070904",
"0.60695225",
"0.6035... | 0.7729473 | 0 |
Creates a components dict for the google geocoder | def create_google_components(status):
components = None
if status['place']:
split = status['place']['full_name'].split(',')
components = {
'locality': split[0].strip(),
'administrative_area': split[1].strip(),
'country': status['place']['country']
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def components_map(self):\r\n raise NotImplementedError",
"def fetch(self, radius: int) -> dict:\n # convert radius integer to string\n radius: str = f\"{radius}mi\" \n # set empty dict\n geocodes: dict = {}\n # iterate through instantiated locations list\n # set ... | [
"0.59961295",
"0.58848774",
"0.5472175",
"0.52825177",
"0.52088803",
"0.5155671",
"0.5066724",
"0.5063108",
"0.50595534",
"0.50516945",
"0.5017744",
"0.5011075",
"0.49679703",
"0.49611756",
"0.49348325",
"0.4923301",
"0.49214232",
"0.49026912",
"0.4897452",
"0.4863266",
"0.48... | 0.64234304 | 0 |
Callback fired on data from the Twitter streaming API. Filters out tweets with RTs or urls in them, geocodes them if they have location information, and pushes the geocoded tweets out to connected clients | def tweet_callback(status):
if status[-3].endswith('}'):
status = json.loads(status)
if tweet_is_valid(status):
if CLIENTS:
status = geocode_status(status)
broadcast(status) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_tweet(tweet):\n global start_date\n global end_date\n global geo_enabled_tweets\n global retweets\n\n # Check for filters before processing any further\n if args.filter and tweet.source:\n if not args.filter.lower() in tweet.source.lower():\n return\n\n tw_date = ... | [
"0.6893244",
"0.6432158",
"0.64183885",
"0.62337077",
"0.6224815",
"0.61122423",
"0.61118174",
"0.6083181",
"0.606989",
"0.60397",
"0.6024835",
"0.60062283",
"0.5928235",
"0.5867464",
"0.5866802",
"0.58547837",
"0.5847184",
"0.5831476",
"0.5820497",
"0.58133286",
"0.57719487"... | 0.6440632 | 1 |
Get all player properties | def player_properties(self):
return self.properties.GetAll(self.player_interface) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProperties():",
"def getPropertiesAll():",
"def _get_player_info(self):\n return [player._player_info() for player in self.players.values()]",
"def get_properties():",
"def get_players(self):\r\n return self.players.values()",
"def get_properties(self):\n return self.propertie... | [
"0.70561594",
"0.7029557",
"0.7014769",
"0.69219154",
"0.68711734",
"0.6756985",
"0.6735967",
"0.6679412",
"0.66471547",
"0.6595262",
"0.65539634",
"0.65072423",
"0.65060073",
"0.65060073",
"0.64347965",
"0.6346386",
"0.6327121",
"0.62983334",
"0.62983334",
"0.6272479",
"0.62... | 0.898955 | 0 |
open media from URI and start playback | def open(self, uri):
try:
self.player.OpenUri(uri)
except AttributeError as ex:
raise UnsupportedOperation(
f'{self.name} does not support opening URIs') from ex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, uri):\n if self.p:\n self.p.stop()\n self.p = self.vlc.media_player_new(uri)\n Player._finished = False\n e = self.p.event_manager()\n e.event_attach(vlc.EventType.MediaPlayerEndReached, self.__end_reached, None)\n if (not '://' in uri or uri.star... | [
"0.69650835",
"0.6877499",
"0.6683258",
"0.6447326",
"0.64142007",
"0.63149434",
"0.63062537",
"0.62950337",
"0.6292141",
"0.6209253",
"0.60831624",
"0.6058879",
"0.60428107",
"0.6024753",
"0.6005289",
"0.59741634",
"0.59693086",
"0.59693086",
"0.59669644",
"0.5965879",
"0.59... | 0.74241686 | 0 |
Get the list of available MPRIS2 services | def get_services():
services = []
bus = pydbus.SessionBus()
for s in bus.get('.DBus').ListNames():
if s.startswith(MprisService.mpris_base):
services.append(s)
return services | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_services(self):\r\n return get_service_list()",
"def available_services(self) -> list[str]:\r\n return self.services",
"def getServices(self):\n pass",
"def list_services(ctx):\n pass",
"def available_services(cls) -> List[str]:\n ret = []\n for (_, name, _) in... | [
"0.7494182",
"0.7366018",
"0.7262642",
"0.72475517",
"0.7116699",
"0.7058195",
"0.698019",
"0.694159",
"0.69262844",
"0.6915469",
"0.68327886",
"0.666419",
"0.6658179",
"0.66437644",
"0.6617939",
"0.65888256",
"0.65527135",
"0.64693516",
"0.645205",
"0.64206463",
"0.64191586"... | 0.7681787 | 0 |
Convert track length in microseconds into human readable format | def track_length_string(length):
return str(timedelta(microseconds=length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_to_string(value):\n if value == gst.CLOCK_TIME_NONE:\n return \"--:--:--.---\"\n ms = value / gst.MSECOND\n sec = ms / 1000\n ms = ms % 1000\n mins = sec / 60\n sec = sec % 60\n hours = mins / 60\n mins = mins % 60\n return \"%02d:%02d:%02d.%03d\" % (hours, mins, sec, ms)... | [
"0.64983374",
"0.6474109",
"0.6469716",
"0.6338871",
"0.6206818",
"0.61407804",
"0.61407804",
"0.61238563",
"0.603152",
"0.60117567",
"0.59859645",
"0.5964505",
"0.59626114",
"0.5934192",
"0.5932881",
"0.59158444",
"0.59021026",
"0.5892526",
"0.58827716",
"0.5862022",
"0.5857... | 0.72623426 | 0 |
Remove romans numbers from a quote. | def clean_num(quote):
for char in ROMAN:
quote = quote.replace(*char)
return quote | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_numbers_fun(self):\n self.doc = re.sub(\"[0-9]\", \"\", self.doc)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.translate(No... | [
"0.6802162",
"0.67661715",
"0.67661715",
"0.67661715",
"0.65662754",
"0.65186864",
"0.65051675",
"0.6495161",
"0.6374237",
"0.6357037",
"0.63561016",
"0.6348042",
"0.6322571",
"0.6312734",
"0.6128238",
"0.6105336",
"0.60863405",
"0.6003035",
"0.58949673",
"0.58674973",
"0.580... | 0.8168946 | 0 |
Convert a text to ASCII format. | def to_ascii(text):
return re.sub(r'[^\x00-\x7F]+', ' ', text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __unicode_to_ascii(text):\n line = unicodedata.normalize('NFKD', text)\n return ''.join(c for c in line if not unicodedata.combining(c))",
"def _flatten_to_ascii(txt):\r\n if isinstance(txt, str):\r\n txt = txt.decode('utf-8')\r\n return unicodedata.normalize('NFKD', txt).encode('ASCII... | [
"0.6927363",
"0.687013",
"0.64326686",
"0.6421335",
"0.640143",
"0.6400809",
"0.6353484",
"0.6336575",
"0.62252617",
"0.6219304",
"0.6185122",
"0.61767006",
"0.6172326",
"0.6120976",
"0.6010914",
"0.5968668",
"0.5958699",
"0.5954476",
"0.593581",
"0.59327143",
"0.59102607",
... | 0.7760155 | 0 |
Clean up the text from a ```` quote element. | def process_quote_text(quote_text):
quote_text = quote_text.replace('―', '').replace('\n\n', '\n')
quote_text = quote_text[:-1] if quote_text[-1] == '\n' else quote_text
for char in HTML:
quote_text = quote_text.replace(*char)
return quote_text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_text(text):\n return text.replace('\\n', '').replace('\"', '')",
"def initial_quotes(self, text):\n\n quote_finder = re.compile(r\"\"\"\n ( # Start group capture\n (\"|“|&\\#8220;) # A double quote\n | ... | [
"0.6924355",
"0.6894347",
"0.68927824",
"0.68723285",
"0.6872247",
"0.6835093",
"0.67228824",
"0.66282713",
"0.63394177",
"0.6337055",
"0.6335682",
"0.6283214",
"0.62645966",
"0.62553567",
"0.6253903",
"0.6252699",
"0.6246763",
"0.62458956",
"0.62109214",
"0.6181878",
"0.6181... | 0.746589 | 0 |
Split an href and retrieve the author's name and its key. | def parse_author_href(href):
author_parts = href.split('/')[-1].split('.')
key = author_parts[0]
author_name = author_parts[1].replace('_', ' ')
return author_name, key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_author(html_soup):\n auth_text = html_soup.find('div', attrs = {\"class\" : \"author\"}).text.split(\"|\")\n for i in auth_text:\n if 'By' in i:\n auth_text_split = i.split()\n auth_text_split = auth_text_split[auth_text_split.index('By')+1:auth_text_split.index('By')+3]\... | [
"0.64172477",
"0.6224456",
"0.61805755",
"0.61738443",
"0.6171362",
"0.61090887",
"0.57969236",
"0.57669604",
"0.573891",
"0.5724362",
"0.5689637",
"0.5636948",
"0.56326914",
"0.56212753",
"0.5613059",
"0.5584283",
"0.55722445",
"0.555239",
"0.55041575",
"0.55039084",
"0.5486... | 0.86064184 | 0 |
Serialize a list in ASCII format, so it can be saved as a JSON. | def serialize_list(list_raw):
list_serialized = []
for value in list_raw:
if isinstance(value, list):
list_serialized.append(serialize_list(value))
elif isinstance(value, dict):
list_serialized.append(serialize_dict(value))
else:
list_serialized.append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_list(list_data, path, lineterminator='\\n', encoding=None, mode='w'):\n with open(path, mode) as f:\n list_data = [item + lineterminator for item in list_data]\n if encoding is not None:\n list_data = [item.encode(encoding) for item in list_data]\n\n f.writelines(list_da... | [
"0.69977295",
"0.69112235",
"0.68876225",
"0.68486106",
"0.6791603",
"0.67712677",
"0.66618836",
"0.6654723",
"0.6545836",
"0.65312964",
"0.6502697",
"0.64593536",
"0.6425355",
"0.64149016",
"0.6390966",
"0.6359837",
"0.6293224",
"0.62871563",
"0.6230964",
"0.62002784",
"0.62... | 0.73018533 | 1 |
Serialize a list in ASCII format, so it can be saved as a JSON. | def serialize_list(list_raw):
list_serialized = []
for value in list_raw:
if isinstance(value, list):
list_serialized.append(serialize_list(value))
elif isinstance(value, dict):
list_serialized.append(serialize_dict(value))
else:
list_serialized.append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_list(list_data, path, lineterminator='\\n', encoding=None, mode='w'):\n with open(path, mode) as f:\n list_data = [item + lineterminator for item in list_data]\n if encoding is not None:\n list_data = [item.encode(encoding) for item in list_data]\n\n f.writelines(list_da... | [
"0.699641",
"0.6911219",
"0.68891096",
"0.6848675",
"0.67918223",
"0.67718494",
"0.6662254",
"0.66567713",
"0.65459096",
"0.65335584",
"0.6503121",
"0.645965",
"0.6425915",
"0.6414398",
"0.63929796",
"0.63601375",
"0.6294473",
"0.62877816",
"0.62299633",
"0.6200803",
"0.62008... | 0.73022383 | 0 |
Return a schedule which measures the requested qubits according to the given instruction mapping and measure map, or by using the defaults provided by the backendV1. | def _measure_v1(
qubits: List[int],
inst_map: InstructionScheduleMap,
meas_map: Union[List[List[int]], Dict[int, List[int]]],
qubit_mem_slots: Optional[Dict[int, int]] = None,
measure_name: str = "measure",
) -> Schedule:
schedule = Schedule(name=f"Default measurement schedule for qubits {qubit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure(\n qubits: List[int],\n backend=None,\n inst_map: Optional[InstructionScheduleMap] = None,\n meas_map: Optional[Union[List[List[int]], Dict[int, List[int]]]] = None,\n qubit_mem_slots: Optional[Dict[int, int]] = None,\n measure_name: str = \"measure\",\n) -> Schedule:\n\n # backend... | [
"0.70415074",
"0.694117",
"0.6068416",
"0.5905929",
"0.5543027",
"0.5331215",
"0.5095064",
"0.5033579",
"0.49605042",
"0.48733565",
"0.47713682",
"0.47615978",
"0.4757743",
"0.4753119",
"0.47397727",
"0.47301975",
"0.47144768",
"0.46818984",
"0.4673623",
"0.463696",
"0.461113... | 0.7321922 | 0 |
Return a schedule which measures the requested qubits according to the given target and measure map, or by using the defaults provided by the backendV2. | def _measure_v2(
qubits: List[int],
target: Target,
meas_map: Union[List[List[int]], Dict[int, List[int]]],
qubit_mem_slots: Dict[int, int],
measure_name: str = "measure",
) -> Schedule:
schedule = Schedule(name=f"Default measurement schedule for qubits {qubits}")
if isinstance(meas_map, li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _measure_v1(\n qubits: List[int],\n inst_map: InstructionScheduleMap,\n meas_map: Union[List[List[int]], Dict[int, List[int]]],\n qubit_mem_slots: Optional[Dict[int, int]] = None,\n measure_name: str = \"measure\",\n) -> Schedule:\n\n schedule = Schedule(name=f\"Default measurement schedule f... | [
"0.68220955",
"0.6573847",
"0.6006834",
"0.5501297",
"0.5030022",
"0.50073725",
"0.47666526",
"0.47343415",
"0.47234833",
"0.46335405",
"0.4628351",
"0.4601694",
"0.45817143",
"0.45776293",
"0.45147318",
"0.44863975",
"0.44642326",
"0.4463367",
"0.44403467",
"0.44367078",
"0.... | 0.7432348 | 0 |
Return a Schedule which measures all qubits of the given backend. | def measure_all(backend) -> Schedule:
# backend is V2.
if isinstance(backend, BackendV2):
qubits = list(range(backend.num_qubits))
else:
qubits = list(range(backend.configuration().n_qubits))
return measure(qubits=qubits, backend=backend) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pulse_schedule(backend: IBMQBackend) -> Schedule:\n config = backend.configuration()\n defaults = backend.defaults()\n inst_map = defaults.instruction_schedule_map\n\n # Run 2 experiments - 1 with x pulse and 1 without\n x = inst_map.get('x', 0)\n measure = inst_map.get('measure', range(c... | [
"0.66667795",
"0.5666289",
"0.5489311",
"0.5294971",
"0.52392757",
"0.5196187",
"0.50862503",
"0.5060072",
"0.5027779",
"0.4976724",
"0.49552643",
"0.49435383",
"0.49327588",
"0.49213088",
"0.49122518",
"0.4867355",
"0.4866859",
"0.4860552",
"0.48551446",
"0.48330986",
"0.483... | 0.82172567 | 0 |
this method compute the approximated moments of a wrightfisher process after gen generations. If store is true, all moments used in the computations are stored is the moments attribute such that self.moments[i, j, k, l, m, n, o, p] is the ith moment of the wrightfisher process after j generations from an initial freque... | def compute_moments(self, gen, store=True):
# the last moment generation already computed is
last_gen = self.moments.shape[1] - 1
# if the moment is already computed, return it
if last_gen >= gen:
return self.moments[:, gen, ]
# otherwise do the recursion
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _construct_mom_stuff(self):\n a = self.mom_mix_rate\n dist_mean = self.GN.dist_mean\n dist_cov = self.GN.dist_cov\n # Get the generated sample observations for this batch, transformed\n # linearly into the desired space for moment matching...\n X_b = T.dot(self.GN.outp... | [
"0.5578582",
"0.5424871",
"0.5365875",
"0.5365875",
"0.53259766",
"0.5321996",
"0.5301589",
"0.5287845",
"0.5287845",
"0.52732825",
"0.5256292",
"0.5183499",
"0.5171409",
"0.51407486",
"0.5116536",
"0.5102273",
"0.50714815",
"0.5045087",
"0.5026461",
"0.49676678",
"0.4946218"... | 0.7055621 | 0 |
this method compute the approximated fixations probabilities of a wrightfisher process after gen generations. app is a string indicating how to approximate transitions and integrate them in these computations. If store is true, all probabilities used in the computations are stored is the fix_proba attribute such that s... | def compute_fixations(self, gen, app = 'beta_tataru',
store = True, **kwargs):
# setting the approximation recursion
self.app = app
# the last fixation probability computed is
last_gen_fix = self.fix_proba.shape[1] - 1
# if the probability is a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def propose(self):\n\n\n fb = 0.0\n changed_any = False\n\n while not changed_any:\n new = copy(self) ## Now we just copy the whole thing\n\n for w in self.all_words():\n if flip(self.propose_p):\n try:\n ... | [
"0.48199168",
"0.47175395",
"0.47008735",
"0.46337798",
"0.46286178",
"0.45170808",
"0.45046583",
"0.4494042",
"0.44697076",
"0.44640133",
"0.44437954",
"0.44316712",
"0.44096234",
"0.44018438",
"0.43755022",
"0.43748388",
"0.43502957",
"0.4346338",
"0.43419045",
"0.43342885",
... | 0.70409745 | 0 |
Sort np.array by column. | def sort_by_col(array, idx=1):
order = np.argsort(array[:, idx])[::-1]
return array[order] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(headers, data): # extension\n\tcolumn_matrix=data.get_data(headers) # get raw matrix data for numeric values\n\tprint \"\\n before sorting \\n \"\n\tprint column_matrix\n\t\n\tcolumn_matrix=column_matrix.tolist()\n\tcolumn_array=np.asarray(column_matrix)\n\t\n\tcolumn_array.sort(axis=0)\n\t\n\tprint \"\\n... | [
"0.72792816",
"0.68471915",
"0.6842164",
"0.66743934",
"0.6556128",
"0.6435283",
"0.6383058",
"0.63643396",
"0.6342741",
"0.62759876",
"0.6222461",
"0.6124097",
"0.606763",
"0.6065433",
"0.60635644",
"0.6037835",
"0.6035828",
"0.5991915",
"0.59912336",
"0.59626365",
"0.595118... | 0.7863806 | 0 |
Convert row of pd.DataFrame to variables. | def row_to_vars(row):
img_id = row["img_id"]
conf = row["confidence"]
iou = np.array(row["iou"])
difficult = np.array(row["difficult"])
crowd = np.array(row["crowd"])
order = np.argsort(iou)[::-1]
return img_id, conf, iou, difficult, crowd, order | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_row(self, row) :\n\n self.row_id += 1\n data = [self.row_id]\n\n if type(row) == type({}) :\n data.extend(row.get(col, None) for col in self.cols[1:])\n elif type(row) in [type([]), type(())] :\n data.extend(row)\n elif type(row) == RowReference... | [
"0.59126335",
"0.56355083",
"0.5585188",
"0.5584195",
"0.5535919",
"0.55313474",
"0.550168",
"0.5469533",
"0.54181707",
"0.53959996",
"0.5389221",
"0.5388655",
"0.53874075",
"0.5379879",
"0.53376657",
"0.5313978",
"0.52934957",
"0.5256191",
"0.5234749",
"0.52314323",
"0.52254... | 0.60037434 | 0 |
Check the repos before the backup commences. | def pre_backup_check(repos):
for repo in 'local', 'remote':
repos[repo].check()
# TODO: Check the ordering of this is deterministic
most_recent_archive = repos[repo].list_archives()[-1]
repos[repo].check_archive(most_recent_archive) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkGit(directory):",
"def check_repo(self):\n if not os.path.exists(self.path):\n log.error(\"no dots repository found at '{}'\".format(self.path))\n if not os.path.exists(self.files_path):\n log.error(\"corrupted repository, the 'files' subfolder is missing\")\n ... | [
"0.64440554",
"0.63667125",
"0.63261837",
"0.6066444",
"0.6035908",
"0.60099196",
"0.5995399",
"0.59861237",
"0.5983702",
"0.59335965",
"0.5928428",
"0.5857033",
"0.5840177",
"0.57988983",
"0.5776676",
"0.57754505",
"0.5773697",
"0.57731676",
"0.577156",
"0.57604474",
"0.5744... | 0.82011116 | 0 |
Perform a backup to the specified repo, and validate the files. | def perform_backup(repo, archive_name, config, logger):
repo.backup(archive_name, config['backup_source_paths'])
integrity_failure = False
for check in config.get('check_files', []):
check_command = [os.path.join('check_commands', check['command'])]
path = os.path.join(
config['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_backup_check(repos):\n for repo in 'local', 'remote':\n repos[repo].check()\n\n # TODO: Check the ordering of this is deterministic\n most_recent_archive = repos[repo].list_archives()[-1]\n repos[repo].check_archive(most_recent_archive)",
"def test_backup_only(self):\n ... | [
"0.62302047",
"0.5959753",
"0.5957811",
"0.5861498",
"0.57466793",
"0.5734922",
"0.5635272",
"0.5594395",
"0.5587171",
"0.55635685",
"0.54897755",
"0.5474992",
"0.5465246",
"0.5372894",
"0.5349092",
"0.5341547",
"0.53170043",
"0.53014684",
"0.52790445",
"0.52441865",
"0.52139... | 0.7684872 | 0 |
Retrieve the stop words for vectorization Feel free to modify this function | def stop_words():
return get_stop_words('es') + get_stop_words('ca') + get_stop_words('en') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStopWords(self):\n\t\treturn self.stop_words",
"def get_stop_words(self):\n self._normalize_params()\n return self.stop_words",
"def getStopWords():\n import os\n cur_dir = os.getcwd()\n\n dk_addition = [line.rstrip('\\n') for line in open(os.path.join(cur_dir,'utils','danish_stop... | [
"0.76995164",
"0.7694002",
"0.7495476",
"0.7411517",
"0.7385416",
"0.7310153",
"0.7292719",
"0.7272324",
"0.720781",
"0.72043383",
"0.71629584",
"0.71625566",
"0.7147034",
"0.71461827",
"0.7064063",
"0.69907856",
"0.6974882",
"0.6970869",
"0.6969426",
"0.6963172",
"0.696132",... | 0.7706719 | 0 |
Sets the app_id of this SharedSecretsStore. | def app_id(self, app_id):
self._app_id = app_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_id(self, app_id):\n self._app_id = app_id",
"def setAppID(self, appid):\n\t\tself.config.APP_ID = appid",
"def application_id(self, application_id):\n\n self._application_id = application_id",
"async def slashtagset_appid(self, ctx: commands.Context, id: int = None):\n app_id = i... | [
"0.8030798",
"0.7907268",
"0.72013015",
"0.711682",
"0.6553479",
"0.65487945",
"0.63896734",
"0.6226906",
"0.6072402",
"0.59553057",
"0.5932596",
"0.58469903",
"0.5838617",
"0.58236474",
"0.5753086",
"0.5753086",
"0.5690268",
"0.5654728",
"0.5654728",
"0.5654728",
"0.55475783... | 0.79765457 | 1 |
Sets the ca_cert of this SharedSecretsStore. | def ca_cert(self, ca_cert):
self._ca_cert = ca_cert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ca_cert_path(self, ca_cert_path: str):\n\n self._ca_cert_path = ca_cert_path",
"def console_ca_cert(self, console_ca_cert):\n\n self._console_ca_cert = console_ca_cert",
"def cert(self, value):\n self._cert = value",
"def client_cert(self, client_cert):\n\n self._client_cert =... | [
"0.70366275",
"0.69069916",
"0.66452664",
"0.64642173",
"0.615436",
"0.60478634",
"0.58376104",
"0.5587908",
"0.5587908",
"0.5510349",
"0.53918797",
"0.53680134",
"0.53367555",
"0.5236249",
"0.5180108",
"0.51549375",
"0.5105433",
"0.508126",
"0.5059504",
"0.5050953",
"0.50126... | 0.8026556 | 0 |
Sets the client_cert of this SharedSecretsStore. | def client_cert(self, client_cert):
self._client_cert = client_cert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_x509_cert_url(self, client_x509_cert_url):\n\n self._client_x509_cert_url = client_x509_cert_url",
"def client_certificate_id(self, client_certificate_id):\n\n self._client_certificate_id = client_certificate_id",
"def client_id(self, client_id):\n\n self._client_id = client_id"... | [
"0.6916911",
"0.6538688",
"0.6388087",
"0.6388087",
"0.6388087",
"0.6388087",
"0.6272879",
"0.61620885",
"0.6154874",
"0.59240377",
"0.5855223",
"0.5651909",
"0.5651909",
"0.5648323",
"0.5564449",
"0.55489093",
"0.5483793",
"0.5316402",
"0.523795",
"0.52187634",
"0.5173961",
... | 0.81401896 | 0 |
Sets the credential_id of this SharedSecretsStore. | def credential_id(self, credential_id):
self._credential_id = credential_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credential(self, credential):\n\n self._credential = credential",
"def credential(self, credential):\n\n self._credential = credential",
"def store_client_credentials(self, client_id, credentials):\n if self._dry_run:\n return\n if type(client_id) == unicode:\n ... | [
"0.65154755",
"0.65154755",
"0.6216953",
"0.61650056",
"0.5938336",
"0.58274084",
"0.57338697",
"0.57093775",
"0.568957",
"0.56819266",
"0.56121373",
"0.5577215",
"0.55734926",
"0.55087495",
"0.5478372",
"0.5451043",
"0.54476315",
"0.5434649",
"0.53920776",
"0.5381632",
"0.53... | 0.80363697 | 0 |
Get elements in request and inject them in args_view or kwargs_view. | def inject(self, request: BaseRequest, args_view: list, kwargs_view: dict): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_view(self, view, request, *args, **kwargs):\n view.request = request\n view.args = args\n view.kwargs = kwargs\n return view",
"def setup_view(view, request, *args, **kwargs):\n\n view.request = request\n view.args = args\n view.kwargs = kwargs\n ... | [
"0.64548486",
"0.63946515",
"0.6385206",
"0.62623554",
"0.6136606",
"0.6119369",
"0.59940606",
"0.59673434",
"0.589182",
"0.581749",
"0.5788581",
"0.5761854",
"0.5758536",
"0.57168823",
"0.5716371",
"0.5703287",
"0.5641552",
"0.5633383",
"0.56281084",
"0.5625707",
"0.56136554... | 0.79954726 | 0 |
Returns a hash of attributes which have changed from the old_version to the new_version. Restricts the attributes compared to the list of interesting_attrs passed in. | def changed_attrs(old_version, new_version, interesting_attrs):
# Use an OrderedDict so that we preserve the order from interesting_attrs
changed = OrderedDict()
for attr in interesting_attrs:
if attr in old_version and attr not in new_version:
changed[attr] = [old_version[attr], None]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed_attrs_by_version(model, interesting_attrs):\n changed = OrderedDict()\n history = reversion.get_for_object(model).order_by(\"revision__date_created\")\n for index, version in enumerate(history):\n # We're only interested in changes\n if index > 0:\n try:\n ... | [
"0.7093283",
"0.63105875",
"0.62489676",
"0.61689854",
"0.6082315",
"0.60821235",
"0.60707515",
"0.5973482",
"0.5956527",
"0.5847145",
"0.57240915",
"0.5629343",
"0.5622167",
"0.5589115",
"0.5551084",
"0.55124044",
"0.55024457",
"0.5489399",
"0.54752064",
"0.5451373",
"0.5446... | 0.84187317 | 0 |
Returns an English string describing a hash of changes, drawn from a dictionary of transition descriptions. | def changes_as_string(changed_attrs, transitions):
changes = []
if not changed_attrs:
return ''
for attr, change in changed_attrs.items():
for transition_description, possible_transitions in transitions[attr].items():
for transition in possible_transitions:
if tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_state_diff_message(iden: int, event: Event) -> str:\n return _cached_state_diff_message(event).replace(IDEN_JSON_TEMPLATE, str(iden), 1)",
"def get_trans_dict(self):\n translated = dict([(k,v) for (k,v) in self._trans_dict.items() if k is not v])\n frm = \" \".join([ c + ' |' for c in... | [
"0.5954077",
"0.5944224",
"0.58483756",
"0.58483756",
"0.56275684",
"0.55849534",
"0.5567776",
"0.55649203",
"0.5451454",
"0.5323222",
"0.53109807",
"0.5302474",
"0.5242349",
"0.5242349",
"0.523923",
"0.5228049",
"0.5206012",
"0.51797116",
"0.51464754",
"0.51434886",
"0.51280... | 0.6373962 | 0 |
Produce an ordered dictionary of changed attrs for a model, keyed by version | def changed_attrs_by_version(model, interesting_attrs):
changed = OrderedDict()
history = reversion.get_for_object(model).order_by("revision__date_created")
for index, version in enumerate(history):
# We're only interested in changes
if index > 0:
try:
old = histo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed_attrs(old_version, new_version, interesting_attrs):\n # Use an OrderedDict so that we preserve the order from interesting_attrs\n changed = OrderedDict()\n for attr in interesting_attrs:\n if attr in old_version and attr not in new_version:\n changed[attr] = [old_version[attr... | [
"0.74727905",
"0.6438466",
"0.64251757",
"0.64148694",
"0.63640875",
"0.62945694",
"0.5877305",
"0.5853865",
"0.5761615",
"0.57073545",
"0.5665202",
"0.55875015",
"0.55512357",
"0.5547303",
"0.5520776",
"0.55064106",
"0.5505713",
"0.546988",
"0.5458309",
"0.544397",
"0.543465... | 0.8237712 | 0 |
Return a list of changes in English for a given model. | def changes_for_model(model):
change_strings = []
for version, changes in changed_attrs_by_version(model, model.REVISION_ATTRS).items():
change_string = changes_as_string(changes, model.TRANSITIONS)
if change_string:
change_strings.append({
"user": version.revision.us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history(self, id):\n lm, previous_versions = h.get_model_and_previous_versions('MorphemeLanguageModel', id)\n if lm or previous_versions:\n return {'morpheme_language_model': lm,\n 'previous_versions': previous_versions}\n else:\n response.status_in... | [
"0.55791515",
"0.55296826",
"0.5505239",
"0.54076606",
"0.5240658",
"0.5239974",
"0.5236164",
"0.5233433",
"0.51919174",
"0.51505697",
"0.5029553",
"0.50116163",
"0.49868023",
"0.49377528",
"0.49096978",
"0.48631215",
"0.48531693",
"0.4844625",
"0.4843526",
"0.48364088",
"0.4... | 0.7259947 | 0 |
Convert a base 32 string to an integer | def base32_to_int(s):
mistyped = False
if s.find('o') > -1 or s.find('i') > -1 or s.find('l') > -1:
s = s.replace('o', '0').replace('i', '1').replace('l', '1')
mistyped = True
decoded = 0
multi = 1
while len(s) > 0:
decoded += multi * base32_digits.index(s[-1:])
multi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hex2int(r: str) -> int:",
"def bin2int(r: str) -> int:",
"def base36_to_int(s: str):\n # To prevent overconsumption of server resources, reject any\n # base36 string that is longer than 13 base36 digits (13 digits\n # is sufficient to base36-encode any 64-bit integer)\n if len(s) > 13:\n ... | [
"0.783031",
"0.7773133",
"0.7620709",
"0.75134236",
"0.75118244",
"0.73315924",
"0.7288714",
"0.7273519",
"0.7217547",
"0.71261877",
"0.71135163",
"0.7068918",
"0.70656765",
"0.6995284",
"0.69599956",
"0.69458324",
"0.6936514",
"0.6910038",
"0.6902294",
"0.6878195",
"0.68748"... | 0.8473583 | 0 |
Converts an integer to a base32 string | def int_to_base32(i):
enc = ''
while i >= 32:
i, mod = divmod(i, 32)
enc = base32_digits[mod] + enc
enc = base32_digits[i] + enc
return enc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char32_t(n):\n return int(n).to_bytes(32, byteorder='little', signed=False)",
"def int2hex(n: int) -> str:",
"def encode_i32(value: int) -> bytes:\n return int_to_le_bytes(value, NUMERIC_CONSTRAINTS[CLTypeKey.I32].LENGTH, True)",
"def encode_u32(value: int) -> bytes:\n return int_to_le_bytes(val... | [
"0.72810096",
"0.7087469",
"0.70650214",
"0.7059178",
"0.6979534",
"0.6882167",
"0.68775755",
"0.68682367",
"0.67978215",
"0.6706196",
"0.6661549",
"0.66425776",
"0.66322464",
"0.662629",
"0.6607996",
"0.6601673",
"0.6540795",
"0.6535475",
"0.6533861",
"0.6529681",
"0.651574"... | 0.8403315 | 0 |
Check that the raw feed is the full XML document | def test_raw_feed(self):
self.assertEqual(self.feed.feed.raw[:6].decode('utf-8'), "<?xml ") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_good_enough_xml(self, resp):\n content_type = resp.headers['Content-Type'].lower()\n \n return (resp.status_code == 200 \n and content_type is not None \n and content_type.find('xml') > -1)",
"def check_rss_dom_structure(doc):\n if isinstance(doc, type... | [
"0.6856743",
"0.65518546",
"0.6428907",
"0.6350477",
"0.62410676",
"0.60915834",
"0.6087781",
"0.60498935",
"0.5918418",
"0.5895832",
"0.58815116",
"0.58612406",
"0.5837969",
"0.5769733",
"0.57486796",
"0.56863636",
"0.5678783",
"0.56738734",
"0.5595063",
"0.55606997",
"0.554... | 0.7514746 | 0 |
Returns the Ghanaian name of the user when based on inputted birthdate. When user answers yes, the meaning of the name will be displayed | def get_ghname():
#Place Day and Name in dictonaries, one for male and female
fem_gh_name = {"Monday": "Adwoa", "Tuesday": "Abena", "Wednesday": "Akua", "Thursday": "Yaa", "Friday": "Afua", "Saturday": "Ama", "Sunday": "Akosua"}
male_gh_name = {"Monday": "Kwadwo/Kojo", "Tuesday": "Kwabena", "Wednesday": "K... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def happy_birthday(name):\n print(\"Happy Birthday to you!\")\n print(\"Happy Birthday to you!\")\n print(\"Happy Birthday, dear \" + name + \".\")\n print(\"Happy Birthday to you!\")",
"def happy_birthday(name, age: hug.types.number = 1):\n return \"Happy {age} Birthday {name}!\".format(**locals(... | [
"0.6952868",
"0.6743409",
"0.61124504",
"0.60920054",
"0.5872237",
"0.5853385",
"0.58432305",
"0.5835405",
"0.5811491",
"0.57774514",
"0.5771373",
"0.57697767",
"0.5742696",
"0.56782097",
"0.56620866",
"0.5659846",
"0.56561166",
"0.5644445",
"0.5635021",
"0.5591319",
"0.55558... | 0.7638637 | 0 |
Return the meaning of user's name based on the week_day parameter | def get_name_meaning(week_day):
dict_meaning = {'Tuesday': "Full of fire and determination, inspirer, risk-taker, will go through a period of uncertainty that will lead to change", "Monday": "The peacemaker, calm and cool, satisfied when doing things to help others, rarely bored""", "Wednesday": "Loving, able to br... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weekday_name(day_of_week):\n\n weekday_names = [\n 'Sunday', \n 'Monday', \n 'Tuesday', \n 'Wednesday', \n 'Thursday', \n 'Friday', \n 'Saturday']\n \n if day_of_week < 1 or day_of_week > 7:\n return 'None! Sowwy.'\n\n if day_of_week == 1:\n ... | [
"0.69684196",
"0.66607773",
"0.66087294",
"0.6585144",
"0.6446677",
"0.63943785",
"0.63613486",
"0.6343028",
"0.6343028",
"0.6283567",
"0.62727726",
"0.6233579",
"0.62119097",
"0.618736",
"0.6144941",
"0.61427206",
"0.60637295",
"0.59701353",
"0.5966777",
"0.59397113",
"0.593... | 0.74635184 | 0 |
Retrieves the specified metadata from the metadata server. | def get_metadata(key=''):
response, content = httplib2.Http().request(
'%s/%s' % (METADATA_BASE_URL, key),
headers={'Metadata-Flavor': 'Google'},
method='GET',
)
if response['status'] == '404':
raise NotFoundError(response, content)
return content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_metadata(self, route: str):\n data = await self.http.get_metadata(route)\n return data",
"def fetch_metadata(requests_impl=requests):\n\n print(f'fetching metadata at {Network.METADATA_URL}')\n return requests_impl.get(Network.METADATA_URL).json()",
"def get_metadata(self):\... | [
"0.7245699",
"0.7151928",
"0.7104588",
"0.696615",
"0.6956422",
"0.6926909",
"0.68931544",
"0.6870761",
"0.6794623",
"0.67537457",
"0.67467815",
"0.66921633",
"0.6678577",
"0.6670239",
"0.66276926",
"0.6622276",
"0.6594163",
"0.6577797",
"0.6537819",
"0.65259176",
"0.6484931"... | 0.72082514 | 1 |
Acknowledges the receipt of messages on a Cloud Pub/Sub subscription. | def acknowledge(self, subscription, project, ack_ids):
response, content = self._http.request(
'%s/%s/subscriptions/%s:acknowledge' % (
PUBSUB_BASE_URL, project, subscription),
body=json.dumps({'ackIds': ack_ids}),
method='POST',
)
if response['status'] == '404':
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def acknowledge(self, *event_messages, bus_client: \"BusClient\"):\n pass",
"def on_subscribe(self, mqtt_client, userdata, mid, granted_qos):\n logging.debug(\"DEBUG - subscribe ack received\")",
"def MessageAck(self, request, context):\n context.code(beta_interfaces.StatusCode.UNIMPLEME... | [
"0.62813425",
"0.6150225",
"0.6145892",
"0.6101863",
"0.60896355",
"0.603904",
"0.6010502",
"0.5991581",
"0.5966796",
"0.5925992",
"0.58987975",
"0.586228",
"0.582372",
"0.5721523",
"0.5721523",
"0.55810386",
"0.55795044",
"0.5551798",
"0.5529495",
"0.5479159",
"0.54706067",
... | 0.68074644 | 0 |
Validate model spec Raises SpecError If the spec is not wellformatted. | def validate(self):
logger.debug("Validating spec: %s", self._spec)
try:
validate(instance=self._spec, schema=MODEL_SPEC_SCHEMA)
except ValidationError as e:
raise SpecError(e.message) from e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swagger_content_validator(spec_body):\n version = spec_body['swagger']\n if version.startswith('1'):\n return 'Deprecated Swagger version. Please visit http://swagger.io for information on upgrading to Swagger 2.0'\n\n with open(config.JSON_SCHEMA) as schema:\n swagger_schema = json.load... | [
"0.61822677",
"0.60357326",
"0.5775823",
"0.53280115",
"0.52456456",
"0.51503146",
"0.51440585",
"0.51136863",
"0.510787",
"0.5099875",
"0.50923747",
"0.5076183",
"0.5076088",
"0.5070361",
"0.50431174",
"0.5036382",
"0.499781",
"0.499263",
"0.49831238",
"0.49813223",
"0.49691... | 0.7007413 | 0 |
Return Model artifact URI | def model_uri(self) -> str:
return self._spec["model"]["uri"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_artifact(self):\n pass",
"def get_single_uri(artifact_list: List[Artifact]) -> Text:\n return get_single_instance(artifact_list).uri",
"def get_repository_uri(self) -> str:\n raise NotImplementedError",
"def uri(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"uri\")",... | [
"0.6964888",
"0.66325843",
"0.64528686",
"0.63969576",
"0.6376586",
"0.6343797",
"0.63117784",
"0.6284732",
"0.6249571",
"0.62446123",
"0.62372655",
"0.6217305",
"0.62148327",
"0.62148327",
"0.62148327",
"0.62148327",
"0.62148327",
"0.62148327",
"0.6201441",
"0.62008864",
"0.... | 0.7396116 | 0 |
Return preprocessing transform if exists | def pre_processing(self) -> Optional[Callable]:
if (
"transforms" not in self._spec
or "pre" not in self._spec["transforms"]
):
# Passthrough
return lambda x: x
f = find_class(self._spec["transforms"]["pre"])
return f(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_preprocessing(name):\n if name not in preprocessing_fn_map.keys():\n raise ValueError('Preprocessing name [%s] was not recognized.' % name)\n\n return preprocessing_fn_map[name].preprocess_image",
"def get_transform_fn():",
"def _build_preprocessing(self):\n\n # For now, do nothing\... | [
"0.7144515",
"0.6530584",
"0.64988124",
"0.6475517",
"0.6416115",
"0.63836473",
"0.63563347",
"0.61520123",
"0.6150919",
"0.6044033",
"0.60155463",
"0.60155463",
"0.60155463",
"0.60155463",
"0.60155463",
"0.5983216",
"0.59528327",
"0.5942889",
"0.593253",
"0.5911872",
"0.5861... | 0.7789364 | 0 |
Return postprocessing transform if exists | def post_processing(self) -> Optional[Callable]:
if (
"transforms" not in self._spec
or "post" not in self._spec["transforms"]
):
# Passthrough
return lambda x: x
f = find_class(self._spec["transforms"]["post"])
return f(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transform_fn():",
"def pre_processing(self) -> Optional[Callable]:\n if (\n \"transforms\" not in self._spec\n or \"pre\" not in self._spec[\"transforms\"]\n ):\n # Passthrough\n return lambda x: x\n f = find_class(self._spec[\"transforms\"... | [
"0.6352982",
"0.63442636",
"0.58065474",
"0.5791054",
"0.5751158",
"0.5738636",
"0.56980866",
"0.56887895",
"0.5667745",
"0.5642095",
"0.5613712",
"0.5607904",
"0.5549039",
"0.55453587",
"0.5538673",
"0.5520472",
"0.5499307",
"0.5463468",
"0.5452866",
"0.5443362",
"0.54308534... | 0.7251341 | 0 |
Return a UDF from a given ModelSpec | def udf_from_spec(spec: ModelSpec):
if spec.version != "1.0":
raise SpecError(
f"Only spec version 1.0 is supported, got {spec.version}"
)
if spec.flavor == "pytorch":
from rikai.spark.sql.codegen.pytorch import generate_udf
return generate_udf(spec)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model(model: str) -> Any:\n try:\n model_function = eval(model)\n except (NameError, AttributeError) as err:\n sys.exit(f'{err}. Accepted models from {tf}, {sm}, {tfa}, {tfc}')\n return model_function",
"def get_vit_fn(model, num_classes, spatial_res):\n model = model.lower()\n a... | [
"0.6317344",
"0.6238467",
"0.62369287",
"0.60278875",
"0.5895729",
"0.5788726",
"0.55613315",
"0.5557939",
"0.5516528",
"0.55142033",
"0.54652625",
"0.54648143",
"0.5380108",
"0.53742975",
"0.53681487",
"0.5325461",
"0.5320433",
"0.5294789",
"0.52846104",
"0.52822757",
"0.526... | 0.78834236 | 0 |
Register a given UDF with the give Spark session under the given name. | def register_udf(spark: SparkSession, udf: Callable, name: str) -> str:
func_name = f"{name}_{secrets.token_hex(4)}"
spark.udf.register(func_name, udf)
logger.info(f"Created model inference pandas_udf with name {func_name}")
return func_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_function(self, function, name=None):\n if name:\n self[name] = function\n else:\n self[function.__name__] = function",
"def register_function(self, function, name=None):\n if name is None:\n name = function.__name__\n self.funcs[name] = fu... | [
"0.6381424",
"0.6292242",
"0.6274659",
"0.5750347",
"0.5739359",
"0.5733467",
"0.56409955",
"0.55877364",
"0.5564187",
"0.5543627",
"0.5542775",
"0.55320764",
"0.5518689",
"0.5453414",
"0.5418701",
"0.5416483",
"0.54028904",
"0.53713137",
"0.52891856",
"0.52680963",
"0.518479... | 0.816824 | 0 |
Initialize a Database with an open connection to the history database. | def __init__(self):
if Database.filename is None:
Database.filename = Config().GetString('HISTORY_DB')
if Database.filename is None:
logging.error('Missing ASH_CFG_HISTORY_DB variable?')
self.connection = sqlite3.connect(Database.filename)
self.connection.row_factory = sqlite3.Row
self.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_database(self):\n init_database(self.engine)",
"def init_database(self):\n # init_database(self.engine)",
"def __init__(self, *args, **kwargs):\n self.database = args[0] if len(args) else kwargs.get('database', 'jping.db')\n is_new = not os.path.exists(self.database)\n ... | [
"0.7012494",
"0.6909706",
"0.6851727",
"0.6823973",
"0.6813911",
"0.6800843",
"0.6735885",
"0.67349523",
"0.6691175",
"0.6688016",
"0.66699165",
"0.66486233",
"0.66061836",
"0.6600309",
"0.6582314",
"0.65171427",
"0.64984584",
"0.6497574",
"0.6490289",
"0.6479513",
"0.6465936... | 0.763907 | 0 |
clean the ad block and link block | def clean_spam(doc):
for tag in doc.find_all(["div","ol", "dl", "ul", "table", "section"]):
if no_block_children(tag) and is_ad_block(tag):
tag.extract() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_link():",
"def delete_ad_text_block(self, table):\n index = 0\n for tr in table:\n index +=1\n if tr.get_attribute('class') == 'ad-text-block':\n del table[index-1]\n return table",
"def horde_cleanup(self):",
"def clean(c):",
"def clean(... | [
"0.5931258",
"0.5751617",
"0.5729552",
"0.5715315",
"0.5449242",
"0.5448983",
"0.5392261",
"0.535174",
"0.53408563",
"0.5286636",
"0.52634615",
"0.5252743",
"0.5208404",
"0.5206515",
"0.5206432",
"0.5198738",
"0.51939416",
"0.51939416",
"0.51939416",
"0.51933086",
"0.51892257... | 0.68033314 | 0 |
Load Stack instance from Experiment. | def test01_load_stack(self):
stack = self.experiment.load_stack(self.experiment.stack_ids[0])
self.assertTrue(isinstance(stack, Stack)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(cls, path: str):\n with open(path, \"r\") as f:\n run_data = json.load(f)\n return Experiment.load_from_dict(run_data)",
"def load_experiment(file_name: str):\n exp = Experiment2P()\n # initialize the lazy-load objects with empty lists\n exp.tail_data = ... | [
"0.62029076",
"0.6123275",
"0.6102033",
"0.588782",
"0.57467204",
"0.57370037",
"0.5539117",
"0.5354052",
"0.5341585",
"0.5298622",
"0.5291302",
"0.5280798",
"0.5170319",
"0.5166367",
"0.5153034",
"0.51518595",
"0.5143899",
"0.51388705",
"0.51269186",
"0.5107662",
"0.5100894"... | 0.75396556 | 0 |
This method is called at deinitialization time | def deinit(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def deinit(self) -> None:",
"def d... | [
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8598001",
"0.8460669",
"0.8460669",
"0.80290407",
"0.78885597",
"0.78108764",
"0.7737444",
"0.7614071",
"0.7612964",
"0.7602854",
"0.7587629",
"0.75617516",... | 0.8913745 | 0 |
Construct a Slurm command to run the given sbatch script in a parseable way. This returns a sequence of commandline arguments that can be passed directly to subprocess.run(). This function passes parsable to sbatch to force the output to an easily machinereadable format; note however that even with this flag errors are... | def build_sbatch_command(
script_path: Path,
*,
dependencies: Sequence[SlurmJobID] = (),
job_name: Optional[str] = None,
log_dir: Optional[Path] = None,
email: Optional[Email] = None,
mail_types: Sequence[MailType] = (),
extra_sbatch_args: Sequence[str] = (),
script_args: Sequence[st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submitSlurmScript(commands_list, outputName = None):\n longString = \";\".join(commands_list)\n print(longString.replace(\";\", \"\\n\"))\n if outputName is not None:\n sCommand = 'sbatch -p short -c 1 -t 0-11:59 --mem=60G --mail-user=Jerry_Yang@hms.harvard.edu \\\n --output {out... | [
"0.6520527",
"0.6046256",
"0.59337866",
"0.5885702",
"0.5820681",
"0.57094526",
"0.56163365",
"0.5544981",
"0.5541964",
"0.5485391",
"0.5475854",
"0.5465947",
"0.5405424",
"0.5392933",
"0.536621",
"0.53590006",
"0.5328773",
"0.5317938",
"0.5304243",
"0.5289871",
"0.52894807",... | 0.7210597 | 0 |
Construct a Bash command to run the given sbatch script. This returns a sequence of commandline arguments that can be passed directly to subprocess.run(). Note the sbatch commands are ignored. | def build_bash_command(
script_path: Path,
*,
# pylint:disable=unused-argument
dependencies: Sequence[SlurmJobID] = (),
job_name: Optional[str] = None,
log_dir: Optional[Path] = None,
email: Optional[Email] = None,
mail_types: Sequence[MailType] = (),
extra_sbatch_args: Sequence[str]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_sbatch_command(\n script_path: Path,\n *,\n dependencies: Sequence[SlurmJobID] = (),\n job_name: Optional[str] = None,\n log_dir: Optional[Path] = None,\n email: Optional[Email] = None,\n mail_types: Sequence[MailType] = (),\n extra_sbatch_args: Sequence[str] = (),\n script_arg... | [
"0.65440714",
"0.59753895",
"0.5942126",
"0.5696643",
"0.5603739",
"0.5468804",
"0.5436128",
"0.5372883",
"0.5347866",
"0.5340703",
"0.5326278",
"0.52864385",
"0.5263525",
"0.5238756",
"0.5226932",
"0.5214312",
"0.5206341",
"0.51938975",
"0.51719457",
"0.51584595",
"0.5135931... | 0.6852868 | 0 |
Echo the given command returning it unchanged. If passed, save_to should be the path to a file. When passed the command will also append the output to the given file. | def echo_command(command: Sequence[str], *, save_to: Optional[Path]) -> Sequence[str]:
output = " ".join(shlex.quote(part) for part in command)
print(output)
if save_to is not None:
with save_to.open(mode="a", encoding="utf-8") as save_to_file:
print(output, file=save_to_file)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_command(cmd, output_file):\n global txt_output_dir\n output_path = os.path.join(txt_output_dir, output_file)\n print \"doing: %s > %s\" % (cmd, output_path)\n output = check_output(cmd.split(\" \"))\n with open(output_path, \"w\") as f:\n f.write(output)",
"def help_save(self):\n ... | [
"0.6414438",
"0.5620966",
"0.5580521",
"0.55630916",
"0.54647315",
"0.54493",
"0.54357255",
"0.5429927",
"0.541318",
"0.5368313",
"0.5360812",
"0.5334565",
"0.5324181",
"0.5257833",
"0.525267",
"0.5240965",
"0.52371734",
"0.5206752",
"0.51941127",
"0.51866156",
"0.5181104",
... | 0.78671086 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.