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 |
|---|---|---|---|---|---|---|
Test case for api_promote_post | def test_api_promote_post(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.Promotion()
path, method = default_api.api_promote_post(params)
self.assertEqual(path, '/api/promote')
self.assertEqual(method, 'POST') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post(self):\n pass",
"def test_smoker_post(self):\n pass",
"def test_post_user_post(self):\n pass",
"def test_promote_goes_no_further_than_done(self):\n todo = Todo.create(title=\"Thing to do\", status=Todo.CHOICES[-1][0])\n assert todo.status == todo.CHOICES[-1][0... | [
"0.6381156",
"0.62768924",
"0.6186299",
"0.6080127",
"0.60648495",
"0.59423923",
"0.5903473",
"0.58985007",
"0.5884698",
"0.58770335",
"0.58684766",
"0.5868241",
"0.5822002",
"0.57952636",
"0.5735996",
"0.572518",
"0.5721291",
"0.5715468",
"0.56378376",
"0.56373036",
"0.56297... | 0.88653123 | 0 |
Test case for api_promotions_get | def test_api_promotions_get(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.Promotion()
path, method = default_api.api_promotions_get(params)
self.assertEqual(path, '/api/promotions')
self.assertEqual(method, 'GET') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n app.logger.info(\"Request for promotions list\")\n promotion = []\n name = request.args.get(\"name\")\n description = request.args.get(\"description\")\n promo_code = request.args.get(\"promo_code\")\n if name:\n promotion = Promotions.find_by_n... | [
"0.59409016",
"0.57219326",
"0.56976277",
"0.5597588",
"0.55282253",
"0.5519187",
"0.55077225",
"0.5502402",
"0.5457423",
"0.54374766",
"0.54354423",
"0.5377362",
"0.5357199",
"0.5355699",
"0.5349281",
"0.5313175",
"0.5301036",
"0.5291509",
"0.52211195",
"0.5198851",
"0.51665... | 0.8312879 | 0 |
Test case for api_build_metrics_get | def test_api_build_metrics_get(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.MetricsRequest()
path, method = default_api.api_build_metrics_get(params)
self.assertEqual(path, '/api/metrics/builds')
self.assertEqual(method, 'GET') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_result_fields_with_metrics(cbcsdk_mock):\n api = cbcsdk_mock.api\n result = Result(api, initial_data=GET_RUN_RESULTS_RESP_1)\n metrics = result.metrics_\n assert metrics._info == {\"cpu\": 24.3, \"memory\": 8.0}",
"def test_metrics(client):\n response = client.get(\"/metrics\")\n asser... | [
"0.7185345",
"0.70361453",
"0.6999692",
"0.6963669",
"0.69537514",
"0.6777485",
"0.6712619",
"0.6622766",
"0.6521939",
"0.6513031",
"0.64969116",
"0.6484864",
"0.6482907",
"0.6441199",
"0.6406892",
"0.63881034",
"0.6368471",
"0.6339531",
"0.6260921",
"0.6234628",
"0.6190819",... | 0.8813328 | 0 |
Test case for api_remote_import_post | def test_api_remote_import_post(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.ModelImport()
path, method = default_api.api_remote_import_post(params)
self.assertEqual(path, '/api/remote/import')
self.assertEqual(method, 'POST') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_import_upload(self):\r\n self._login_admin()\r\n\r\n # verify we get the form\r\n res = self.app.get('/admin/import')\r\n self.assertTrue(\r\n '<form' in res.body,\r\n 'Should have a form in the body for submitting the upload')\r\n\r\n res = self._u... | [
"0.6340387",
"0.62975264",
"0.6129785",
"0.6082167",
"0.6075704",
"0.59829533",
"0.5974887",
"0.5939281",
"0.59220105",
"0.5799908",
"0.5782063",
"0.5755509",
"0.57277656",
"0.5705541",
"0.5701068",
"0.5679355",
"0.56710863",
"0.5662004",
"0.5627926",
"0.5620273",
"0.5619928"... | 0.87363845 | 0 |
Test case for api_repo_status_get | def test_api_repo_status_get(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.Params2()
path, method = default_api.api_repo_status_get(params)
self.assertEqual(path, '/api/repo_status')
self.assertEqual(method, 'GET') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_status(self):\n pass",
"def test_get_status(self):\n pass",
"def test_get_status(self):\n resp = self.build_api.getStatus().json()\n assert 'status' in resp\n assert 'message' in resp",
"def test_get_status(self):\n response = self.client.open(\n ... | [
"0.76847225",
"0.76847225",
"0.7624905",
"0.7335575",
"0.7133566",
"0.7124783",
"0.68932515",
"0.68918663",
"0.6867826",
"0.6845981",
"0.6791606",
"0.67886084",
"0.67723477",
"0.6749822",
"0.67219496",
"0.6644989",
"0.6614613",
"0.658524",
"0.6566437",
"0.6537004",
"0.6474428... | 0.87942904 | 0 |
Test case for api_report_result_post | def test_api_report_result_post(self):
default_api = DefaultApi(api_client=self.api_client)
params = dlrnapi_client.Params3()
path, method = default_api.api_report_result_post(params)
self.assertEqual(path, '/api/report_result')
self.assertEqual(method, 'POST') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_successful_report(self):\n from rest_framework.test import APIClient\n client = APIClient()\n response = client.post('/api/report/epic/', self.report,\n HTTP_AUTHORIZATION='Token ' + self.token_1,\n format='json')\n... | [
"0.71547884",
"0.7134954",
"0.6750663",
"0.6482854",
"0.6443237",
"0.6282149",
"0.62690705",
"0.6220305",
"0.62106735",
"0.62021273",
"0.6135198",
"0.6113796",
"0.6112314",
"0.6103845",
"0.60587716",
"0.60543984",
"0.60537034",
"0.60535234",
"0.6035478",
"0.5997932",
"0.59572... | 0.87548476 | 0 |
Create full matrix from an ablated (one factor removed) KTensor. | def _full_ablated(tt_factors, fac_num_to_remove):
# turn factors into tuple, then remove factor from each mode's matrix
factors = tuple(tt_factors)
factors = tuple([np.delete(f, fac_num_to_remove, axis=1) for f in factors])
# create a KTensor from tensortools to speed up some math
kt = KTen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_full_matrix(AB, BA, AA, BB):\n a_size, b_size = AB.shape\n\n full_mat = sparse.csc_matrix((a_size + b_size, a_size + b_size))\n full_mat[:a_size, :a_size] = AA\n full_mat[:a_size, a_size:] = AB\n full_mat[a_size:, :a_size] = BA\n full_mat[a_size:, a_size:] = BB\n\n return full_mat",
... | [
"0.62535655",
"0.6194362",
"0.5881765",
"0.57952917",
"0.56678134",
"0.56190974",
"0.5563654",
"0.55563956",
"0.5539287",
"0.55289817",
"0.5493376",
"0.546882",
"0.54683924",
"0.54578173",
"0.54480875",
"0.544805",
"0.5428051",
"0.5427213",
"0.5424056",
"0.5413035",
"0.539482... | 0.63164496 | 0 |
Initializes this compiler. Default for classes is all in the given directory or expects a list or tuple, otherwise and ValueError is thrown | def __init__(self, compiler_name, src_ext, dst_ext, sources=None, directory=_os.curdir):
if sources is not None and not isinstance(sources, (list, set, tuple)):
raise TypeError('sources must be an iterable')
self.compiler_name = compiler_name
self.src_ext = src_ext
self.dst_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_derived_class_folders(self):\n self.smooth_update_dir = self.opt_folder / \"SMOOTHED_UPDATES\"\n self.moment_dir = self.opt_folder / \"MOMENTS\"\n self.smoothed_model_dir = self.opt_folder / \"SMOOTHED_MODELS\"",
"def __init__(self, *paths):\r\n self.paths = paths",
... | [
"0.5769025",
"0.57047147",
"0.56077063",
"0.5606366",
"0.55970603",
"0.5477624",
"0.54756784",
"0.54678094",
"0.54382044",
"0.5425789",
"0.54102427",
"0.53504074",
"0.53469247",
"0.5345114",
"0.5299918",
"0.52958083",
"0.52947456",
"0.52946234",
"0.52822196",
"0.5268107",
"0.... | 0.6095816 | 0 |
Sets the path of this compiler to the given directory | def set_path(self, directory):
self.directory = directory | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetPath(self, directory):\r\n\r\n if directory is not None and exists(directory) and isdir(directory):\r\n self.directory = directory",
"def set_script_dir(self, path):\n self.script_dir = path",
"def set_directory_path(self, directory_path: str) -> None:\n self.directory_pa... | [
"0.7257609",
"0.7105358",
"0.7008451",
"0.68472654",
"0.6803677",
"0.67048776",
"0.6698584",
"0.6678834",
"0.66785187",
"0.6646457",
"0.66388613",
"0.6610648",
"0.65984744",
"0.659206",
"0.6573202",
"0.65296423",
"0.65239066",
"0.64913666",
"0.63866687",
"0.63670313",
"0.6328... | 0.746776 | 0 |
Adds the given flag to the list of flags | def add_flag(self, flag):
self.flags.append(flag) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, flag):\n\n try:\n # Resolve the flag\n flag = self.eset[flag]\n except KeyError:\n raise TypeError('Unknown bit flag %r' % flag)\n\n # Save the current bitflags\n previous = self.bitflags\n\n self.bitflags |= int(flag)\n self.... | [
"0.75960606",
"0.7376466",
"0.730766",
"0.70087034",
"0.68559486",
"0.6774737",
"0.6746336",
"0.63983494",
"0.6393685",
"0.63705426",
"0.63703865",
"0.6267221",
"0.59687865",
"0.58709884",
"0.5841526",
"0.57966334",
"0.5731052",
"0.57130134",
"0.5683149",
"0.5680459",
"0.5653... | 0.85671544 | 0 |
Clears the list of flags | def clear_flags(self):
self.flags.clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resetFlags():\r\n for flag in flags:\r\n flags[flag] = False",
"def clearAllCanSelectFlags(self):\n for key in self.canSelectFlags.keys():\n self.canSelectFlags[key] = 0",
"def reset() -> None:\n\t_flag.clear()",
"def clearAccessedFlags(self):\n pass",
"def _resetFlag... | [
"0.8162865",
"0.77293634",
"0.7115795",
"0.68962365",
"0.68583477",
"0.68233705",
"0.6815525",
"0.6761658",
"0.6682103",
"0.66317004",
"0.6561998",
"0.6549232",
"0.64430094",
"0.64430094",
"0.64283997",
"0.6389182",
"0.6374279",
"0.63340294",
"0.63226664",
"0.63033676",
"0.62... | 0.8602546 | 0 |
Compiles the source files in this directory with this compiler's | def compile(self, exclude=None, recurse=True, references=None, verbose=False):
from clay.shell.core import lsgrep
_os.chdir(self.directory)
sources = self.sources
if sources is None:
sources = [_os.path.splitext(x)[0] for x in lsgrep(self.src_ext, self.directory, recurse=re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_dir(path):\r\n to_compile = get_pyx_files(path)\r\n print(\"De:\",path)\r\n if to_compile:\r\n print(\"Se compilaran:\", list(map(os.path.basename,to_compile)))\r\n Cythonize.main( ['-a', '-i'] + to_compile )\r\n else:\r\n print(\"Nada para compilar\")",
"def compile(... | [
"0.7384383",
"0.6637735",
"0.6614796",
"0.6554956",
"0.6524108",
"0.6508908",
"0.6475297",
"0.6471648",
"0.6450059",
"0.6450059",
"0.6403609",
"0.63995343",
"0.63847154",
"0.63383234",
"0.6291639",
"0.6264601",
"0.62318736",
"0.6183617",
"0.6145199",
"0.61386466",
"0.6107049"... | 0.6854204 | 1 |
for a given image name, generate a respective file name, the output should be saved as; e.g. xd.jpg > xd_features.npy can be used to find the files for the regression part | def generate_file_name(old_file_name: str) -> str:
return old_file_name.split(".")[0] + '_features' + '.npy' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filename(images):\n image_file = {}\n for image in images:\n image_file[image['id']] = os.path.join('train2017', image['file_name'])\n return image_file",
"def createAllImageFiles(poly, name) :\n \n for i in range(len(poly.getPaths())):\n fileName = name + \"_\" + str(i) + \"... | [
"0.6532228",
"0.63980925",
"0.6393354",
"0.6317259",
"0.6311766",
"0.63059837",
"0.6289537",
"0.6256262",
"0.62549275",
"0.6253018",
"0.6176286",
"0.61517787",
"0.6143204",
"0.611888",
"0.6113079",
"0.6079711",
"0.60362726",
"0.6034775",
"0.6033952",
"0.6028542",
"0.6015237",... | 0.6681591 | 0 |
change the model, that will be used by the predictor; to get the model_names, refer to viable models at the top of this file | def select_model(model_name: str):
global predictor, currently_selected_model
predictor = FeatureExtractor(model_name)
currently_selected_model = model_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setOldModel(self,model):\n self.modelName = model\n oldModel = load_model(self.modelPath + \"/\" + model + \".hdf5\",\n custom_objects={'recall': recall,\n 'precision': precision,\n 'f1Score':f1Sc... | [
"0.70904213",
"0.69119847",
"0.67973185",
"0.6719595",
"0.6565851",
"0.6494036",
"0.6449818",
"0.6443918",
"0.6391521",
"0.6389185",
"0.63809407",
"0.6304095",
"0.6300939",
"0.62952447",
"0.6261975",
"0.62455255",
"0.6224973",
"0.6174949",
"0.6136979",
"0.61338425",
"0.607484... | 0.694931 | 1 |
Generates AppStream metadata of a specific kind | def _generate_metadata_kind(filename, targets=None, qa_group=None):
db = LvfsDatabase(os.environ)
db_firmware = LvfsDatabaseFirmware(db)
items = db_firmware.get_items()
store = appstream.Store('lvfs')
for item in items:
# filter
if item.target == 'private':
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_metadata_kind(filename, items, affidavit=None):\n store = appstream.Store('lvfs')\n for item in items:\n\n # add each component\n for md in item.mds:\n component = appstream.Component()\n component.id = md.cid\n component.kind = 'firmware'\n ... | [
"0.671694",
"0.60573244",
"0.57544136",
"0.5661377",
"0.56448686",
"0.5619563",
"0.5588338",
"0.55070674",
"0.5504906",
"0.5472223",
"0.5432367",
"0.54051733",
"0.5370304",
"0.53210187",
"0.53012925",
"0.5292331",
"0.5278983",
"0.52679557",
"0.5261438",
"0.52601606",
"0.52423... | 0.607395 | 1 |
updates metadata for a specific qa_group | def metadata_update_qa_group(qa_group):
# explicit
if qa_group:
filename = 'firmware-%s.xml.gz' % _qa_hash(qa_group)
_generate_metadata_kind(filename, qa_group=qa_group)
return [os.path.join(DOWNLOAD_DIR, filename)]
# do for all
db = LvfsDatabase(os.environ)
db_firmware = L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _metadata_update_group(group_id):\n\n # get all firmwares in this group\n firmwares = db.firmware.get_all()\n firmwares_filtered = []\n for f in firmwares:\n if f.target == 'private':\n continue\n if f.group_id != group_id:\n continue\n firmwares_filtered.... | [
"0.62396324",
"0.5877734",
"0.576575",
"0.57327974",
"0.57194453",
"0.56374407",
"0.56304944",
"0.54979336",
"0.5483407",
"0.5479937",
"0.54672974",
"0.5455434",
"0.54246724",
"0.54197586",
"0.54063433",
"0.5388485",
"0.5379117",
"0.5371604",
"0.5357497",
"0.5346416",
"0.5345... | 0.647164 | 0 |
Test KS test for insertion indices with a specified mode | def test_ks_test(mode):
indices = np.random.randint(0, 1000, 1000)
out = compute_indices_ks_test(indices, 1000, mode=mode)
assert all([o > 0.0 for o in out]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ks_test_undefined_mode():\n indices = np.random.randint(0, 1000, 1000)\n with pytest.raises(RuntimeError):\n compute_indices_ks_test(indices, 1000, mode=\"two-sided\")",
"def test_ks_test_empty_indices():\n out = compute_indices_ks_test([], 1000, mode=\"D+\")\n assert all(o is None fo... | [
"0.67841566",
"0.57195204",
"0.5679095",
"0.5437452",
"0.53641367",
"0.53341633",
"0.5320182",
"0.5270428",
"0.5263456",
"0.52053756",
"0.51995933",
"0.5183746",
"0.51783615",
"0.51379323",
"0.51002336",
"0.5085314",
"0.5072776",
"0.50716794",
"0.50716245",
"0.50713897",
"0.5... | 0.7882716 | 0 |
Test KS test for insertion indices with undefined mode | def test_ks_test_undefined_mode():
indices = np.random.randint(0, 1000, 1000)
with pytest.raises(RuntimeError):
compute_indices_ks_test(indices, 1000, mode="two-sided") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ks_test(mode):\n indices = np.random.randint(0, 1000, 1000)\n out = compute_indices_ks_test(indices, 1000, mode=mode)\n assert all([o > 0.0 for o in out])",
"def test_ks_test_empty_indices():\n out = compute_indices_ks_test([], 1000, mode=\"D+\")\n assert all(o is None for o in out)",
"... | [
"0.8165338",
"0.746027",
"0.6211018",
"0.61494595",
"0.5980731",
"0.58581066",
"0.58403915",
"0.58055747",
"0.5776113",
"0.57654226",
"0.5763633",
"0.57397044",
"0.5628826",
"0.55964756",
"0.55854005",
"0.55454636",
"0.5536922",
"0.5515122",
"0.5509714",
"0.5504265",
"0.54790... | 0.7853589 | 1 |
Test KS test for insertion indices with empty input array | def test_ks_test_empty_indices():
out = compute_indices_ks_test([], 1000, mode="D+")
assert all(o is None for o in out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ks_test(mode):\n indices = np.random.randint(0, 1000, 1000)\n out = compute_indices_ks_test(indices, 1000, mode=mode)\n assert all([o > 0.0 for o in out])",
"def test_ks_test_undefined_mode():\n indices = np.random.randint(0, 1000, 1000)\n with pytest.raises(RuntimeError):\n comput... | [
"0.70587337",
"0.65909284",
"0.6385907",
"0.5999898",
"0.5820923",
"0.5819541",
"0.57032824",
"0.56986374",
"0.5642348",
"0.5551414",
"0.55201554",
"0.54983246",
"0.5488126",
"0.5454441",
"0.54420024",
"0.54296124",
"0.5424802",
"0.54022473",
"0.53976005",
"0.5383299",
"0.536... | 0.8038088 | 0 |
Test the Bonferroni correction for pvalues | def test_bonferroni_correction():
p_values = np.linspace(0, 0.5, 4)
rejected, corrected, alpha = bonferroni_correction(p_values)
np.testing.assert_array_equal(corrected, np.array([0, 2 / 3, 1, 1]))
assert rejected.tolist() == [True, False, False, False]
assert alpha == 0.0125 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bonferroni_correction(self):\r\n pvals = array([.1, .7, .5, .3, .9])\r\n exp = pvals * 5.\r\n obs = bonferroni_correction(pvals)\r\n self.assertFloatEqual(obs, exp)",
"def bonferroni_correction(pvals):\r\n return (\r\n array(pvals, dtype=float) * len(pvals) # float... | [
"0.83021456",
"0.71167046",
"0.6553124",
"0.6406347",
"0.6259637",
"0.6220493",
"0.60953826",
"0.602094",
"0.5866166",
"0.5811663",
"0.58097947",
"0.5803982",
"0.5756479",
"0.5751217",
"0.57412875",
"0.5739286",
"0.5718708",
"0.5704229",
"0.5698823",
"0.56808656",
"0.5674409"... | 0.80394477 | 1 |
Convert ID sequences into mask matrices | def idseqs_to_mask(idseqs: List[List[int]],
n_seqlen: Optional[int] = None,
n_vocab_sz: Optional[int] = None,
ignore: Optional[List[int]] = [],
dtype: Optional[torch.dtype] = torch.bool,
dense: Optional[bool] = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_attention_mask(input_ids): \n attention_masks = [] \n\n # 1 for input and 0 for pad\n for seq in input_ids: \n attention_masks.append([float(i>0) for i in seq])\n\n return attention_masks",
"def mask_id(self):\n m = 2 * self.mask_full()\n m[0:self.size, 0:self.size] = s... | [
"0.68125015",
"0.6421516",
"0.59341574",
"0.59032476",
"0.583509",
"0.5829133",
"0.5744523",
"0.5729663",
"0.5697411",
"0.56960577",
"0.5669003",
"0.5659483",
"0.56362015",
"0.5635536",
"0.5617417",
"0.5606554",
"0.5605875",
"0.5604915",
"0.5577015",
"0.5563572",
"0.55454534"... | 0.6793221 | 1 |
Accepts a city and a country and prints a simple sentence with those values. | def describe_city(city, country='New Zealand'):
print(f"\nThe city of {city} is in {country}.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def city_country(city, country):\n print(f'\"{city.title()}, {country.title()}\"\\n')",
"def describe_city(city, country='canada'):\n print(f\"{city.title()} is in {country.title()}.\")",
"def describe_city(city, country='Germany'):\n\tprint(f'{city.title()} is in {country.title()}.')",
"def describe_c... | [
"0.856302",
"0.81208575",
"0.8088181",
"0.8051179",
"0.79706645",
"0.79012996",
"0.78986406",
"0.7809852",
"0.77355325",
"0.7704453",
"0.7686551",
"0.7686551",
"0.7685671",
"0.7684176",
"0.7679467",
"0.7600646",
"0.74408424",
"0.7436566",
"0.7406232",
"0.737946",
"0.73696256"... | 0.81209445 | 1 |
Constructor for the NasBackupParams class | def __init__(self,
backup_all_existing_snapshot=None,
blacklisted_ip_addrs=None,
continue_on_error=None,
encryption_enabled=None,
filtering_policy=None,
fld_config=None,
full_backup_snapshot_label=None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n include_cluster_scope_resources: pulumi.Input[bool],\n object_type: pulumi.Input[str],\n snapshot_volumes: pulumi.Input[bool],\n excluded_namespaces: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,\n ... | [
"0.64447784",
"0.6168862",
"0.61534363",
"0.6098209",
"0.6049831",
"0.5995434",
"0.5983703",
"0.5983703",
"0.5976207",
"0.597005",
"0.59328234",
"0.5924585",
"0.59173024",
"0.5862991",
"0.58594143",
"0.58371496",
"0.58366156",
"0.58322644",
"0.5827591",
"0.58213955",
"0.58141... | 0.6467344 | 0 |
Catch Ctrl+C signal to termiante workers | def init_worker():
signal.signal(signal.SIGINT, signal.SIG_IGN) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowCtrlC():\n signal.signal(signal.SIGINT, signal.SIG_DFL)",
"def signal_handler(*unused_argvs):\n sys.stderr.write(\"\\nCtrl^C caught, bailing...\\n\")\n sys.exit(0)",
"def worker_initializer():\n signal.signal(signal.SIGINT, signal.SIG_IGN)",
"def _init_worker():\n signal.signal(signal.SIG... | [
"0.7222166",
"0.72151893",
"0.7180323",
"0.71768016",
"0.6984043",
"0.6946091",
"0.69356275",
"0.6917393",
"0.6899606",
"0.6881529",
"0.6845854",
"0.6804447",
"0.67696905",
"0.6766118",
"0.67553",
"0.67504436",
"0.66279745",
"0.65575314",
"0.6528643",
"0.64279413",
"0.6398735... | 0.72294533 | 0 |
Update a readme file with supplied information. | def update_readme(readme: str, updated_metadata: dict = None, extra_lines: list = None):
metadata, lines = read_readme(readme)
if updated_metadata:
metadata = {**metadata, **updated_metadata}
if extra_lines:
lines = lines + extra_lines
write_readme(readme, metadata, lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_readme():\n\n temp = \"\"\"<head>\n <title>Unittest Results</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\" integrity=\... | [
"0.7689971",
"0.722182",
"0.70508206",
"0.6771436",
"0.6603375",
"0.65443844",
"0.6535205",
"0.6525045",
"0.6332471",
"0.6293604",
"0.62730294",
"0.6270745",
"0.6242984",
"0.6230076",
"0.6186949",
"0.6171401",
"0.61592084",
"0.61382926",
"0.60904527",
"0.6066599",
"0.6053936"... | 0.8195249 | 0 |
Bgzip file if requested. | def bgzip_and_name(fname, bgzip_file=True) -> str:
if bgzip_file:
ret = sp.check_call(f"bgzip {fname}", shell=True)
fname += ".gz"
if ret != 0:
raise Exception(f"Error bgzipping genome {fname}. Is pysam installed?")
return fname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compressIfNeeded(self):\n\n if self._mode == \"zip\":\n zip_folder(self._rootExportPath, self.getZipArchiveFullPath())",
"def zipFasta(self):\n utils.log(\"zipping {} ...\".format(self.fastaFileName))\n cmd = \"bgzip -f {}\".format(self.fastaFileName)\n utils.runCommand... | [
"0.64540195",
"0.61454713",
"0.61329705",
"0.6086035",
"0.5977188",
"0.5960336",
"0.58702797",
"0.5859002",
"0.58266616",
"0.57801116",
"0.5761597",
"0.575355",
"0.57480204",
"0.5744919",
"0.573051",
"0.5717974",
"0.56552184",
"0.5648838",
"0.5563235",
"0.5556836",
"0.555637"... | 0.6738823 | 0 |
Return (gzipped) file names in directory containing the given extension. | def glob_ext_files(dirname, ext="fa") -> list:
fnames = glob(os.path.join(dirname, f"*.{ext}*"))
return [f for f in fnames if f.endswith((ext, f"{ext}.gz"))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_names(path, extension='.json'):\n fn = os.listdir(path)\n l = []\n for f in fn:\n if f.endswith(extension, 4):\n l.append(f)\n l = sorted(l)\n return l",
"def list_all_files_with_extension(path, extension, do_unzip=True):\n files = []\n for file in os.listdir(p... | [
"0.7269909",
"0.71443665",
"0.71007",
"0.6931686",
"0.68851805",
"0.68763983",
"0.6823714",
"0.67866296",
"0.67852724",
"0.6752004",
"0.6724506",
"0.6646473",
"0.6645157",
"0.66420186",
"0.6624232",
"0.6605461",
"0.65348715",
"0.65346175",
"0.6510529",
"0.64909226",
"0.648030... | 0.77469283 | 0 |
filter a Fasta using the regex function. | def _apply_fasta_regex_func(infa, regex_func, outfa=None):
# move the original file to a tmp folder
out_dir = os.path.dirname(infa)
tmp_dir = mkdtemp(dir=out_dir)
old_fname = os.path.join(tmp_dir, "original") if outfa is None else infa
new_fname = os.path.join(tmp_dir, "filtered")
shutil.move(in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_fasta(\n infa: str,\n outfa: str = None,\n regex: str = \".*\",\n invert_match: Optional[bool] = False,\n) -> list:\n pattern = re.compile(regex)\n\n def keep(header):\n return bool(pattern.search(header)) is not invert_match\n\n return _apply_fasta_regex_func(infa, keep, out... | [
"0.65963423",
"0.6402181",
"0.6011408",
"0.600255",
"0.5881439",
"0.57979774",
"0.5762943",
"0.5755297",
"0.57551485",
"0.57547766",
"0.57397467",
"0.5717947",
"0.5692144",
"0.5634937",
"0.560354",
"0.5600734",
"0.5595965",
"0.5553075",
"0.55393845",
"0.5537095",
"0.55356854"... | 0.676315 | 0 |
Filter fasta file based on regex. | def filter_fasta(
infa: str,
outfa: str = None,
regex: str = ".*",
invert_match: Optional[bool] = False,
) -> list:
pattern = re.compile(regex)
def keep(header):
return bool(pattern.search(header)) is not invert_match
return _apply_fasta_regex_func(infa, keep, outfa) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_fasta_regex_func(infa, regex_func, outfa=None):\n # move the original file to a tmp folder\n out_dir = os.path.dirname(infa)\n tmp_dir = mkdtemp(dir=out_dir)\n old_fname = os.path.join(tmp_dir, \"original\") if outfa is None else infa\n new_fname = os.path.join(tmp_dir, \"filtered\")\n ... | [
"0.69491684",
"0.6156863",
"0.60775024",
"0.59450454",
"0.5645844",
"0.55811054",
"0.5563482",
"0.5525892",
"0.5522686",
"0.5514822",
"0.55063164",
"0.5468016",
"0.5430675",
"0.5412103",
"0.5391324",
"0.5378578",
"0.53772795",
"0.53680974",
"0.5331787",
"0.5308409",
"0.530364... | 0.6979984 | 0 |
Finds the age of the person on the photo, based on the filename | def find_age(str):
regex = r"_([0-9]+).+_([0-9]+)"
matches = re.search(regex, str)
if matches:
birth = matches.group(1)
picture = matches.group(2)
age = int(picture) - int(birth)
return age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_age(self, filepath):\n try:\n fileage = os.path.getmtime(filepath)\n return fileage\n except:\n return 0",
"def file_info(self, f):\n ld8 = self.ld8_extract(f) # get luna_date\n sid = self.sesid(ld8) # make luna_visitnum\n age =... | [
"0.6539053",
"0.63929635",
"0.6130632",
"0.6126099",
"0.60076624",
"0.59946716",
"0.5988924",
"0.5957687",
"0.5947357",
"0.5931525",
"0.5921615",
"0.5881921",
"0.5782887",
"0.57811505",
"0.5766714",
"0.5723021",
"0.57115793",
"0.5673089",
"0.5648261",
"0.56320405",
"0.5610792... | 0.68865573 | 0 |
Creates an array of images | def create_image_array(files_list):
im_array = np.array([np.array(cv2.imread(file)) for file in files_list])
return im_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makearray(self, *args, **kwargs):\n return _image.image_makearray(self, *args, **kwargs)",
"def gen_image(self, nimage):\n tmp = [0] * nimage\n for i in np.arange(nimage):\n tmp[i] = self.gen_one_image()\n \n return np.array(tmp)",
"def generate_images(\n n:... | [
"0.727521",
"0.7118611",
"0.7073577",
"0.70057833",
"0.69419736",
"0.689666",
"0.68892497",
"0.68005633",
"0.6778553",
"0.67391485",
"0.67278343",
"0.67162925",
"0.6715371",
"0.66987485",
"0.6670579",
"0.6658773",
"0.6611052",
"0.6609227",
"0.65959245",
"0.6590915",
"0.654894... | 0.7637464 | 0 |
Saves an array under the name 'filename' | def save_array(array, filename):
np.save(filename, array) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quick_save_array(data, file_name, delimiter=',', ):\n data.tofile(file_name, sep=delimiter)",
"def write_csv_file(array, filename):\n\tnp.savetxt(filename, array, delimiter=\",\")",
"def save_array(self, name: str, array: np.ndarray):\r\n np.savetxt(self._path_for_csv(name), array, delimiter=\",\... | [
"0.75969416",
"0.7330002",
"0.7201176",
"0.71752346",
"0.7159063",
"0.7140122",
"0.71392435",
"0.7069632",
"0.6940411",
"0.6934702",
"0.69181776",
"0.68739957",
"0.6849441",
"0.68114215",
"0.67789257",
"0.67586243",
"0.67484975",
"0.67466575",
"0.6678462",
"0.66758204",
"0.66... | 0.8585977 | 0 |
Resize an image to a square image (width = height = side) | def resize_image(image, side):
cv2.imshow("Original", image)
small = cv2.resize(image, (side,side), interpolation = cv2.INTER_AREA)
return small | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square(img):\n\n # image after making height equal to width\n squared_image = img\n\n # Get image height and width\n h = img.shape[0]\n w = img.shape[1]\n\n # In case height superior than width\n if h > w:\n diff = h-w\n if diff % 2 == 0:\n x1 = np.zeros(shape=(h, ... | [
"0.7255887",
"0.70602775",
"0.7035608",
"0.70195657",
"0.6944379",
"0.6938678",
"0.68413717",
"0.67514956",
"0.6735933",
"0.6733177",
"0.67089653",
"0.6696039",
"0.6657528",
"0.65651417",
"0.6562902",
"0.65581095",
"0.6549727",
"0.65445",
"0.6524752",
"0.651283",
"0.65066546"... | 0.74849427 | 0 |
Variant is the number of houses that has to be placed, resolution changes the size of the map and loops is the amount of rounds the algorithm shoud look for a better solution | def startGeneration(variant, resolution, loops):
# Check for valid resolution
if resolution % 2 != 0:
print ("Resolution should be an even integer.")
return
# Set high score:
if variant == 20:
high_score = 11365950
if variant == 40:
high_score = 17858670
if varia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_points_ascending_hillclimber(house, all_houses, waters, total_value_map):\n total_value_map_NEW = total_value_map\n\n # check in welke range het huis geplaats kan worden, niet kijkend naar water of andere \n rangex = MAXIMUM_WIDTH - house.width\n rangey = MAXIMUM_HEIGHT - house.length\n\n ... | [
"0.6033722",
"0.588629",
"0.58354026",
"0.57623374",
"0.5724886",
"0.56725067",
"0.5625394",
"0.5621047",
"0.56147605",
"0.56",
"0.55322355",
"0.55315334",
"0.5521285",
"0.5412654",
"0.5357182",
"0.53541523",
"0.53317034",
"0.5319103",
"0.52973694",
"0.52739733",
"0.5271306",... | 0.6851993 | 0 |
Input is a grid and an instance of the house class. It calls placeHouse function using random coordinates. | def genHome(grid, house):
house.random_x(grid)
house.random_y(grid)
return generic.placeHouse(grid, house) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_house(area, house):\n\n while_count = 0\n valid = False\n while not valid:\n\n # Get random bottom_left coordinates\n x = int(random.random() * (area.width - house.width + 1))\n y = int(random.random() * (area.height - house.height + 1))\n\n house.set_coordinates([x,y... | [
"0.6998493",
"0.6979279",
"0.6193127",
"0.6015307",
"0.59624696",
"0.59511083",
"0.5789173",
"0.57785887",
"0.5760649",
"0.57373405",
"0.5723482",
"0.56952333",
"0.56909704",
"0.5664013",
"0.5663497",
"0.5659337",
"0.56584257",
"0.56440085",
"0.5634831",
"0.5631952",
"0.56127... | 0.75639224 | 0 |
Mapping master_document_id to xtracta workflow id | def get_workflow_id(master_document_id):
workflow_id = WORKFLOW_MAPPING.get(master_document_id)
return workflow_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_workflows_id_get(self):\n pass",
"def workflow_id(self):\n if self._workflow_id is None and self.workflow_loaded():\n workflow, _ = self.get_workflow()\n self._workflow_id = workflow.id\n\n return self._workflow_id",
"def test_workflows_id_patch(self):\n ... | [
"0.59178025",
"0.58331275",
"0.5775823",
"0.57322353",
"0.56916577",
"0.55855453",
"0.55352056",
"0.5527326",
"0.55247635",
"0.54731137",
"0.54303414",
"0.53976077",
"0.52327216",
"0.52293485",
"0.5224544",
"0.51767606",
"0.51365936",
"0.51099974",
"0.51084536",
"0.51076734",
... | 0.7897448 | 0 |
Get document from XTRACTA based on document_id | def get_document_from_xtracta(document_id):
response = None
response = requests.post(XTRACTA['url']+"documents",
data={"submit":"Submit",\
"api_key":XTRACTA['key'],\
"document_id":document_id})
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_document(self, docid):\n raise NotImplementedError",
"def get_document_by_id(document_id):\n return Documents.query.filter_by(id=document_id).first()",
"def retrieve(document_id: str) -> Fulltext:\n return current_session().retrieve(document_id)",
"def document(self, document_id):\r\... | [
"0.7611445",
"0.7408272",
"0.7046423",
"0.68967134",
"0.6668736",
"0.6636387",
"0.66137767",
"0.6546737",
"0.65452653",
"0.6492808",
"0.6488995",
"0.6436565",
"0.6424351",
"0.64181244",
"0.63924766",
"0.63828534",
"0.63728637",
"0.635899",
"0.632777",
"0.6318808",
"0.6296382"... | 0.82048696 | 0 |
Upload document to XTRACTA based on document_id | def upload_document_to_xtracta(workflow, document_file):
response = None
file = {"userfile":document_file}
response = requests.post(XTRACTA['url']+"documents"+"/"+"upload",\
files=file, data={"submit":"Submit", "api_key":XTRACTA['key'],\
"workflow_id"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_doc():\n file = request.files[\"file\"]\n meta_data = {\"name\": request.form[\"name\"].lower()}\n file_id = save_file(meta_data, file)\n print('file-id: ' + file_id)\n index_after_uploading(file_id)\n return jsonify({\"file_id\": file_id})",
"def get_document_from_xtracta(document_... | [
"0.6871023",
"0.6805021",
"0.6690708",
"0.6596134",
"0.65866995",
"0.6406619",
"0.6367324",
"0.63114834",
"0.6254257",
"0.61851346",
"0.61786866",
"0.6057179",
"0.6016124",
"0.5928141",
"0.59106",
"0.5906524",
"0.58953094",
"0.5895309",
"0.58747303",
"0.58572143",
"0.5839104"... | 0.7220496 | 0 |
Return a day as a table cell. | def formatday(self, day, weekday, events):
events_from_day = events.filter(day__day=day)
events_html = "<ul>"
for event in events_from_day:
events_html += event.get_absolute_url() + "<br>"
events_html += "</ul>"
if day == 0:
return '<td class="noday">&nbs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatday(self, day, weekday):\r\n if day == 0:\r\n return '<td class=\"noday\"> </td>' # day outside month\r\n else:\r\n if len(self.worktimes.filter(day=weekday+1))==0:\r\n return '''\r\n <td class=\"%s\">\r\n <... | [
"0.67893255",
"0.64169925",
"0.6343143",
"0.6303392",
"0.62195915",
"0.59166765",
"0.590449",
"0.5881711",
"0.57823145",
"0.5748522",
"0.5743581",
"0.56981665",
"0.5686068",
"0.5662388",
"0.5661434",
"0.5656333",
"0.56043684",
"0.56010914",
"0.56006336",
"0.55943596",
"0.5575... | 0.66491044 | 1 |
Return a complete week as a table row. | def formatweek(self, theweek, events):
s = ''.join(self.formatday(d, wd, events) for (d, wd) in theweek)
return '<tr>%s</tr>' % s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatWeekHeader(self):\n s = ''.join(self.formatWeekDay(i) for i in self.iterweekdays())\n return '<tr>%s</tr>' % s",
"def formatweek(self, theweek, schedules):\n s = ''.join(self.formatday(d, wd, schedules) for (d, wd) in theweek)\n return '<tr>%s</tr>' % s",
"def formatweekhe... | [
"0.7189514",
"0.69993424",
"0.6893345",
"0.6708384",
"0.63470304",
"0.628649",
"0.6121799",
"0.6001106",
"0.59045076",
"0.5854563",
"0.5730193",
"0.5729441",
"0.566795",
"0.5629985",
"0.559184",
"0.55640805",
"0.5560718",
"0.55485463",
"0.5532377",
"0.5520608",
"0.5500528",
... | 0.71608937 | 1 |
Return a formatted month as a table. | def formatmonth(self, theyear, themonth, withyear=True):
events = Event.objects.filter(day__month=themonth)
v = []
a = v.append
a('<table border="0" cellpadding="0" cellspacing="0" class="month">')
a('\n')
a(self.formatmonthname(theyear, themonth, withyear=withyear))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatMonth(self, theyear, themonth, withyear=True):\n html = ('<table class=\"month\">\\n%s\\n%s\\n'\n % (self.formatMonthName(theyear, themonth,\n withyear=withyear), self.formatWeekHeader()))\n weeks = self.monthdatescalendar(theyear, themonth)\n fo... | [
"0.7134699",
"0.7002023",
"0.65425044",
"0.64765465",
"0.63949794",
"0.61361825",
"0.6074644",
"0.6062721",
"0.6062721",
"0.5965839",
"0.5939903",
"0.5879206",
"0.5876679",
"0.58666515",
"0.5848568",
"0.5828335",
"0.5827049",
"0.5825652",
"0.58041704",
"0.57771266",
"0.574493... | 0.7155175 | 0 |
Function to randomly select TOTAL_TEST_FILES from the POS_DIR_PATH and NEG_DIR_PATH | def get_test_train_files_split() -> str:
pos_files_list = [os.path.join(POS_DIR_PATH, file_name) for file_name in os.listdir(POS_DIR_PATH)]
neg_files_list = [os.path.join(NEG_DIR_PATH, file_name) for file_name in os.listdir(NEG_DIR_PATH)]
test_files_list = []
random_files_index = random.sample(range(le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_random_elements(\n basedir: str, n_dirs: int, n_files: int, onfail: str = \"raise\"\n) -> Tuple[List[Path], List[Path]]:\n alldirs = []\n allfiles = []\n for root, dirs, files in os.walk(str(basedir)):\n for d in dirs:\n alldirs.append(Path(root) / d)\n for file in f... | [
"0.60715747",
"0.5966422",
"0.5932681",
"0.5914077",
"0.58858365",
"0.5881185",
"0.5820345",
"0.5797507",
"0.5773249",
"0.57173306",
"0.57066214",
"0.57044",
"0.5703326",
"0.56919885",
"0.5687747",
"0.5682543",
"0.56691974",
"0.56612897",
"0.56592804",
"0.565059",
"0.5649891"... | 0.7139843 | 0 |
Function to count how many tokens are in the positive and negative lexicon word list passed in | def get_pos_neg_word_count(tokens: list, pos_lex_words: set, neg_lex_words: set) -> tuple:
positive_words = 0
negative_words = 0
for token in tokens:
if token and len(token) > 1 and\
(token not in string.punctuation) and\
not is_digit_regex(token):\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lexicon_features(tokens, feats):\n# feats['neg_words'] = 0;\n# feats['pos_words'] = 0;\n# tokens = list([token.lower() for token in tokens])\n# feats['neg_words'] , feats['pos_words'] = np.count_nonzero(np.in1d(tokens, list(neg_words))), np.count_nonzero(np.in1d(tokens, list(pos_words)))\n n... | [
"0.7245609",
"0.69737387",
"0.6767516",
"0.66683203",
"0.65738237",
"0.6470758",
"0.63966507",
"0.63769865",
"0.6356329",
"0.6353296",
"0.6329496",
"0.6297136",
"0.6279287",
"0.62308764",
"0.6209839",
"0.6166272",
"0.61583793",
"0.6126984",
"0.6107725",
"0.6107423",
"0.610390... | 0.8004957 | 0 |
Decorator for wrapping functions that enter a system context. This should decorate every method a user might call. This will allow us to add differentiation between what is a user error and what is a system failure. Furthermore, we will clean the exception trace so as to make more sense to the userallowing them to know... | def system_entry_point(wrapped, instance, args, kwargs):
try:
_CONTEXT_STACK.append(_SYSTEM_CONTEXT)
if _is_base_context():
try:
return wrapped(*args, **kwargs)
except FlyteScopedException as ex:
_reraise(ex.type, ex.value, ex.traceback)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_exceptions(callable):\r\n def wrapper(self, *args, **kwargs):\r\n try:\r\n return callable(self, *args, **kwargs)\r\n except EnvironmentError:\r\n # ENOENT (no such file or directory) gets raised on open().\r\n # ESRCH (no such process) can get raised on r... | [
"0.62283856",
"0.6204277",
"0.6075031",
"0.60119647",
"0.6009196",
"0.5977504",
"0.5926194",
"0.5922835",
"0.5898166",
"0.58828527",
"0.5882718",
"0.5881702",
"0.5851216",
"0.5849375",
"0.58470154",
"0.5820462",
"0.58026505",
"0.57045597",
"0.56874484",
"0.56868964",
"0.56848... | 0.66706175 | 0 |
Return a tuple of two ints from 1 or 2 intish things. | def _tuple_from_one_or_two_ints(self, v):
try:
a, b = [int(x) for x in v]
except TypeError:
a, b = int(v), int(v)
return (a,b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_tuple(v: Union[int, Tuple[int, int]]) ->Tuple[int, int]:\n if torch.jit.isinstance(v, int):\n return v, v\n else:\n return v",
"def _to_tuple(values: Union[int, Iterable[int]]) -> Tuple[int, ...]:\n try:\n return tuple(values)\n except TypeError:\n return (values,)"... | [
"0.7521668",
"0.71872586",
"0.67897296",
"0.66056657",
"0.6550124",
"0.6381458",
"0.63615984",
"0.63500184",
"0.63150114",
"0.6306386",
"0.6288212",
"0.6223996",
"0.6137928",
"0.61346763",
"0.6120724",
"0.61114156",
"0.6105132",
"0.60968715",
"0.6076315",
"0.6074093",
"0.6072... | 0.81066763 | 0 |
Returns dictionary of placeholders that must be fed. Only valid after network() has been run. | def placeholders(self):
rv = dict()
for stage in self.stages:
for name, ph_var in stage.placeholders:
rv[name] = ph_var
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def placeholders(self):\n x = [i.placeholder for i in self._input_desc]\n return x[0] if len(x) == 1 else x",
"def _validate_placeholders(self):\n if self.implementation.container is None:\n return\n\n valid_inputs = {} if self.inputs is None else self.inputs\n valid... | [
"0.6215448",
"0.6073801",
"0.592821",
"0.5835194",
"0.5761858",
"0.5752826",
"0.5747895",
"0.56185067",
"0.55785143",
"0.557546",
"0.5575306",
"0.5567209",
"0.5552609",
"0.5547895",
"0.5461414",
"0.54389316",
"0.5426337",
"0.5407213",
"0.5380769",
"0.5353769",
"0.5327057",
... | 0.6491004 | 0 |
Topic process(bot, trigger, from_topic, topic_reset) Process only topics of given channel. Split current topic using "|" as separator. We assume that first part of the split topic is reserved for current status. Thus whatever is contained in this part is replaced with current status. If no "|" separators exist, replace... | def parse_topic(bot, trigger, from_topic, topic_reset): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_topic_change(bot, trigger):\n\tif len(trigger.args) == 1:\n\t\treturn # Empty TOPIC gets the current topic.\n\tchannel = trigger.args[0]\n\tlog(bot, channel, '*** {} changes topic to \"{}\"', trigger.nick, trigger.args[1]);",
"def reset_topic(bot, trigger):\n global report\n\n if get_state():\n ... | [
"0.55901504",
"0.5492897",
"0.52117544",
"0.5190746",
"0.51528454",
"0.5146953",
"0.5138362",
"0.507733",
"0.50478727",
"0.5047027",
"0.5019809",
"0.50074124",
"0.49721324",
"0.4848447",
"0.4844749",
"0.47917017",
"0.4729333",
"0.4674787",
"0.46009457",
"0.45672083",
"0.45628... | 0.72231275 | 0 |
report_handler(bot, new_report) Process new report into topic. | def report_handler(bot, new_report):
event_count = report[2]
# Count events and take report & time
if event_count == 0:
event_count = new_report.count("|")
else:
event_count += new_report.count("|")
timestamp = datetime.now()
reporttime = timestamp.strftime("[%H:%M]")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_report_tg(bot, trigger):\n new_report = trigger.group(0).split(\"eporting: \")[1]\n\n # Check preliminaries and then call report handler\n if trigger.sender == CHANNEL:\n if get_state():\n if new_report is None:\n # Silly...\n bot.reply(\"Informatio... | [
"0.64067423",
"0.6079078",
"0.59823257",
"0.5917744",
"0.58443093",
"0.58145285",
"0.58028007",
"0.5755404",
"0.5718759",
"0.56281924",
"0.56260574",
"0.55986154",
"0.5579969",
"0.5579851",
"0.55763656",
"0.55205",
"0.5470385",
"0.5465731",
"0.54592896",
"0.54445344",
"0.5433... | 0.8357721 | 0 |
reset_topic(bot, trigger) Used to clear changes made to the topic by the bot. Also clears current report. | def reset_topic(bot, trigger):
global report
if get_state():
if is_reported():
for channel in bot.channels:
bot.msg(channel, "Clearing my changes from topic")
print("TOPIC RESET")
parse_topic(bot, trigger, 0, 1)
else:
bot.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_report_from_topic(bot, trigger):\n if trigger.sender == CHANNEL:\n if get_state():\n bot.write(('TOPIC',), CHANNEL)\n parse_topic(bot, trigger, 1, 0)\n else:\n bot.reply(\"Sensors indicate that you must be mistaken.\")\n else:\n bot.reply(\"You h... | [
"0.6828663",
"0.66188425",
"0.6498818",
"0.61289966",
"0.5740045",
"0.5717969",
"0.5678631",
"0.5288347",
"0.5264879",
"0.5252115",
"0.5218302",
"0.51682925",
"0.51637286",
"0.51555514",
"0.51157296",
"0.5100585",
"0.50775653",
"0.5051933",
"0.50357884",
"0.5031498",
"0.50274... | 0.90120465 | 0 |
take_report(bot, trigger) Preliminary sanity checks on new report after which the report is passed to handler. | def take_report(bot, trigger):
# Check preliminaries and then call report handler
if trigger.sender == CHANNEL:
if get_state():
if trigger.group(2) is None:
# Oh boy...
bot.reply("Information content zero..")
else:
# Take report and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_report_tg(bot, trigger):\n new_report = trigger.group(0).split(\"eporting: \")[1]\n\n # Check preliminaries and then call report handler\n if trigger.sender == CHANNEL:\n if get_state():\n if new_report is None:\n # Silly...\n bot.reply(\"Informatio... | [
"0.77184224",
"0.6597283",
"0.6471456",
"0.6050006",
"0.5949276",
"0.585307",
"0.5423698",
"0.5341602",
"0.53049964",
"0.5297914",
"0.52932143",
"0.529256",
"0.5291882",
"0.52771765",
"0.5246162",
"0.5241872",
"0.5194986",
"0.5186295",
"0.5183256",
"0.512548",
"0.51198107",
... | 0.7793067 | 0 |
take_report_tg(bot, trigger) Take report from telegram users. | def take_report_tg(bot, trigger):
new_report = trigger.group(0).split("eporting: ")[1]
# Check preliminaries and then call report handler
if trigger.sender == CHANNEL:
if get_state():
if new_report is None:
# Silly...
bot.reply("Information content zero..... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_report(bot, trigger):\n # Check preliminaries and then call report handler\n if trigger.sender == CHANNEL:\n if get_state():\n if trigger.group(2) is None:\n # Oh boy...\n bot.reply(\"Information content zero..\")\n else:\n # ... | [
"0.6437883",
"0.6085747",
"0.58172345",
"0.5489603",
"0.51390964",
"0.5100913",
"0.49046394",
"0.48993888",
"0.48883653",
"0.48822558",
"0.48745948",
"0.48617592",
"0.4833422",
"0.48287883",
"0.47916818",
"0.47651523",
"0.47533637",
"0.47409648",
"0.4722519",
"0.47202516",
"0... | 0.686354 | 0 |
tale_report_from_topic(bot, trigger) Process a report request from topic. | def take_report_from_topic(bot, trigger):
if trigger.sender == CHANNEL:
if get_state():
bot.write(('TOPIC',), CHANNEL)
parse_topic(bot, trigger, 1, 0)
else:
bot.reply("Sensors indicate that you must be mistaken.")
else:
bot.reply("You have to do this f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_topic(bot, trigger, from_topic, topic_reset):",
"def take_report_tg(bot, trigger):\n new_report = trigger.group(0).split(\"eporting: \")[1]\n\n # Check preliminaries and then call report handler\n if trigger.sender == CHANNEL:\n if get_state():\n if new_report is None:\n ... | [
"0.64785373",
"0.63892686",
"0.58351517",
"0.5721067",
"0.57095695",
"0.51564574",
"0.48008454",
"0.47865102",
"0.47159374",
"0.46900564",
"0.4626033",
"0.4594493",
"0.45877644",
"0.45565897",
"0.45409906",
"0.4495742",
"0.44656736",
"0.44615316",
"0.4446827",
"0.44167086",
"... | 0.7355818 | 0 |
play(sound) Play given sound from defined SOUNDDIR. If not specified, does nothing | def play(sound):
if SOUNDDIR != "":
call(["aplay", SOUNDDIR + sound]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_sound(self, sound):\n try:\n if self.se_volume != 0:\n self.sound_lib[sound].play()\n except:\n print \"Couldn't play the sound '\", sound, \"'!\"",
"def play_sound(self, sound) -> None:\n pass",
"def playSound(self,sound):\n sound.play(... | [
"0.82288665",
"0.81507856",
"0.8060567",
"0.79823667",
"0.761578",
"0.7580619",
"0.7477844",
"0.722535",
"0.72210425",
"0.72055215",
"0.7147864",
"0.7132323",
"0.7117206",
"0.70374626",
"0.70054907",
"0.70038426",
"0.6989375",
"0.69840586",
"0.6981598",
"0.69734263",
"0.69456... | 0.89302546 | 0 |
alert_signal(signum, stack) Function to be called when signal is received from doorbell | def alert_signal(signum, stack):
if get_state():
play(DOORBELL_SND) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler(signum, frame):\n m.signal()",
"def handler(signum, frame):\n logging.warning(\"Got a {} signal. Doing nothing\".format(signum))",
"def alarmhandler(signum, frame):\n signum = signum\n frame = frame\n raise AlarmException",
"def signal_handler(self, signum):\n raise Exception(... | [
"0.69552094",
"0.6942623",
"0.6794785",
"0.6709137",
"0.66343784",
"0.6615214",
"0.6613414",
"0.6583996",
"0.6574192",
"0.64988756",
"0.64925855",
"0.64427394",
"0.6378109",
"0.6301674",
"0.62608254",
"0.62308687",
"0.61666477",
"0.6140567",
"0.61354727",
"0.61339843",
"0.613... | 0.8009605 | 0 |
register a listener for eventClass type events The caller of EventManager.register must store the Connection which is returned in a list attribute in order for the listener to be automatically removed from the EventManager when that caller is deleted. | def register(self, eventClass, listener):
LOGGER.debug("register %s" % eventClass.__name__)
key = eventClass.__name__
if (hasattr(listener, '__self__') and
hasattr(listener, '__func__')):
# Wrap the callable if it is an instance method.
listener = Even... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_listener ( cls, listener, class_name = '' ):\n MetaHasTraits._listeners.setdefault( class_name, [] ).append( listener )",
"def register(self, event_type, callback,\n args=None, kwargs=None, details_filter=None,\n weak=False):\n if not six.callable(callback):\... | [
"0.63691604",
"0.62791574",
"0.60326046",
"0.6025486",
"0.6019247",
"0.5945441",
"0.59279853",
"0.5871596",
"0.5848477",
"0.58279526",
"0.5817841",
"0.57959986",
"0.57937294",
"0.57539785",
"0.57426494",
"0.57278997",
"0.56773615",
"0.56583154",
"0.5653645",
"0.5632728",
"0.5... | 0.76873153 | 0 |
Test the ability to split the dim_N_header fields | def test_split_dim_header():
hdr_in = Hdr_Ext.from_header_ext(
{'SpectrometerFrequency': [100.0, ],
'ResonantNucleus': ['1H', ],
'dim_5': 'DIM_DYN',
'dim_5_info': 'averages',
'dim_5_header': {'p1': [1, 2, 3, 4],
'p2': [0.1, 0.2, 0.3, 0.4]},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_split():\n nmrs = NIFTI_MRS(test_data_split)\n\n # Error testing\n # Wrong dim tag\n with pytest.raises(ValueError) as exc_info:\n nmrs_tools.split(nmrs, 'DIM_EDIT', 1)\n\n assert exc_info.type is ValueError\n assert exc_info.value.args[0] == \"DIM_EDIT not found as dimension tag.... | [
"0.70561",
"0.6739945",
"0.6581336",
"0.6157314",
"0.6076363",
"0.6067349",
"0.6037094",
"0.6031764",
"0.6013476",
"0.5951711",
"0.58882964",
"0.58772826",
"0.5867258",
"0.5857906",
"0.58556885",
"0.5738381",
"0.5737253",
"0.5734351",
"0.57198685",
"0.5713524",
"0.57126564",
... | 0.7777845 | 0 |
Test the ability to merge the dim_N_header fields | def test_merge_dim_header():
hdr_in_1 = Hdr_Ext.from_header_ext(
{'SpectrometerFrequency': [100.0, ],
'ResonantNucleus': ['1H', ],
'dim_5': 'DIM_DYN',
'dim_5_info': 'averages',
'dim_5_header': {'p1': [1, 2, 3, 4],
'p2': [0.1, 0.2, 0.3, 0.4]},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_split_dim_header():\n hdr_in = Hdr_Ext.from_header_ext(\n {'SpectrometerFrequency': [100.0, ],\n 'ResonantNucleus': ['1H', ],\n 'dim_5': 'DIM_DYN',\n 'dim_5_info': 'averages',\n 'dim_5_header': {'p1': [1, 2, 3, 4],\n 'p2': [0.1, 0.2, 0.3, ... | [
"0.7518095",
"0.63130283",
"0.6131983",
"0.60388684",
"0.5994544",
"0.59517586",
"0.5851797",
"0.58242273",
"0.5728598",
"0.5727216",
"0.5703473",
"0.568503",
"0.56473434",
"0.56400406",
"0.5592178",
"0.55870146",
"0.5554662",
"0.55400366",
"0.55224055",
"0.55090165",
"0.5445... | 0.78858435 | 0 |
Construct a new movement announcement. | def __init__(self, movement: Movement, message: str, user: User):
self.movement = movement
self.message = message
self.poster = user
self.created_time = datetime.now()
self.updated_time = None
self.removed_time = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self, pos):\n self.pos = pos",
"def make_movetext(self, input, start, end, elements):\n mt = Movetext()\n for e in elements:\n if type(e.wcomment) == str:\n wcomment = e.wcomment\n else:\n wcomment = \"\"\n\n mcomment = \"... | [
"0.5662564",
"0.5571824",
"0.541672",
"0.5415097",
"0.53581494",
"0.5340892",
"0.5337541",
"0.5314158",
"0.52858454",
"0.52231646",
"0.52023035",
"0.51937115",
"0.5163608",
"0.51530135",
"0.51489055",
"0.5131338",
"0.51310277",
"0.51046455",
"0.50937015",
"0.5085939",
"0.5084... | 0.6208744 | 0 |
Convert an announcement to json. | def to_json(self) -> dict:
json_dict = {
"id": self.id,
"movement_id": self.movement_id,
"poster": self.poster.to_json(),
"message": self.message,
"created_time": str(self.created_time.astimezone())
}
if self.updated_time:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json(self):\n if self.valid:\n return {\n 'articleID': self._id,\n 'ticker_symbol': self.ticker,\n 'published_date': self.pub_date,\n 'author_name': self.author,\n 'title': self.title,\n 'text': self.tex... | [
"0.6051779",
"0.6012607",
"0.5895918",
"0.5875261",
"0.57886094",
"0.5782429",
"0.57796854",
"0.5778346",
"0.5774402",
"0.57713",
"0.57579416",
"0.57488304",
"0.57150453",
"0.5713005",
"0.5689563",
"0.56489825",
"0.5632943",
"0.56286925",
"0.56113124",
"0.55800426",
"0.557394... | 0.6206867 | 0 |
Update the message of the announcement. | def update_message(self, message: str):
self.message = message
self.updated_time = datetime.now() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, msg):\n pass",
"def update(self, message):\n return self.request().update(message)",
"def update(self, msg):\n self.msgVar.set(msg)",
"def update(self, msg):\r\n self.msgVar.set(msg)",
"def update(self, msg):\r\n self.msgVar.set(msg)",
"async def update... | [
"0.7527086",
"0.7319726",
"0.718939",
"0.7075682",
"0.7075682",
"0.70619524",
"0.68893784",
"0.6799449",
"0.64309204",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
"0.6297348",
... | 0.7587067 | 0 |
Override to perform any special decoding before filter is applied | def _pre_filter_decode(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decoder(self):\n pass",
"def decode(self, encoded):",
"def _dinamic_decode(self):\n raise NotImplementedError",
"def decode(self): # pragma: no cover\n pass",
"def preprocess_raw(self):\n pass",
"def decode(data): #@NoSelf",
"def decode(self):\n if self._decoded:... | [
"0.6965735",
"0.67332125",
"0.6660794",
"0.65154576",
"0.64826334",
"0.6411799",
"0.6307839",
"0.6212253",
"0.6098016",
"0.6077169",
"0.6055751",
"0.60075444",
"0.5955589",
"0.5955589",
"0.592723",
"0.58944446",
"0.5846141",
"0.5846141",
"0.5846141",
"0.5763023",
"0.5763023",... | 0.8819532 | 0 |
RESTFUL call to obtain information about the currentlylogged in user, also provides information about how much of their email is currently imported. | def current_user(request):
client_id = os.environ['GOOGLE_CLIENT_ID']
scope = 'https://mail.google.com/ profile'
url = ''
if os.environ['ENV'] == 'dev':
url = TEST_OAUTH_CALLBACK
else:
url = "https://accounts.google.com/o/oauth2/auth?scope=%s&" \
"redirect_uri=%s&respo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_info():\n if session and session.get(\"email\") and session.get(\"display_name\"):\n email = session.get(\"email\")\n display_name = session.get(\"display_name\")\n data = dict(email=email, displayName=display_name)\n app.logger.debug(\"Success in getting log information... | [
"0.7246899",
"0.703527",
"0.6966072",
"0.6944442",
"0.6933036",
"0.6920569",
"0.68972135",
"0.6836678",
"0.681147",
"0.6780369",
"0.67173135",
"0.6663877",
"0.6654884",
"0.6628925",
"0.661826",
"0.66109914",
"0.6597784",
"0.65934384",
"0.6540971",
"0.652987",
"0.6522337",
"... | 0.7403401 | 0 |
the user wants to remove a word from their studylist | def remove(request, word_to_remove):
word_object = Word.objects.get(word__exact=word_to_remove)
word_to_learn = WordsToLearn.objects.filter(
user__id=request.user.id, word=word_object)
word_to_learn.delete()
return HttpResponseRedirect('/study') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter(q_words):\n filtered_words = [\"how\",\"what\"]\n for word in q_words:\n if word in filtered_words:\n q_words.remove(word)",
"def removeWord(self,category,word):\n\t\ttry:\n\t\t\tlist = self.dictData[category]\n\t\t\tlist.pop(list.index(word))\n\t\t\tself.__save()\n\t\texcept K... | [
"0.67881536",
"0.64333194",
"0.6248782",
"0.6224686",
"0.6219968",
"0.6188909",
"0.61815625",
"0.6160331",
"0.612381",
"0.61169577",
"0.6115707",
"0.60878754",
"0.60639286",
"0.6062924",
"0.60580707",
"0.6013443",
"0.59992397",
"0.5995951",
"0.59686553",
"0.59641165",
"0.5935... | 0.7295103 | 0 |
Name must be capitalized | def test_name_must_be_capitalized(self):
form = self.make_validator_form(name='PATRICK alves')
# O cleaned_data é um dicionário que armazena todos os valores do
# formulários já validados
self.assertEqual('Patrick Alves', form.cleaned_data['name']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name_must_be_capitalized(self):\n form = self.make_validated_form(name='HENRIQUE bastos')\n self.assertEqual('Henrique Bastos', form.cleaned_data['name'])",
"def test_name_must_be_capitalized(self):\r\n form = self.make_validated_form(name='DieGo MaraNhao')\r\n self. assertEq... | [
"0.8193219",
"0.8164763",
"0.8003153",
"0.76962405",
"0.745632",
"0.7340215",
"0.7321985",
"0.71422136",
"0.7129266",
"0.708505",
"0.7029354",
"0.7024253",
"0.69393677",
"0.69393677",
"0.69393677",
"0.6887481",
"0.6868966",
"0.68688947",
"0.6863508",
"0.6856835",
"0.6838902",... | 0.8274609 | 0 |
Test if this node is the network node. | def is_network_node():
return config.NODE_IP == config.NETWORK_NODE_IP | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_network_type(self, name):\n nt = self.config[\"networks\"].get(name)\n return bool(nt)",
"def has_node(self, name):\n return self.source_net.has_node(name)",
"def __contains__ (self, item):\n if isinstance(item, Node):\n item = item.id\n return item in self.network",
"... | [
"0.7338448",
"0.68739766",
"0.6680434",
"0.6630339",
"0.6630339",
"0.66011393",
"0.6267848",
"0.62573254",
"0.62540036",
"0.61622053",
"0.61584145",
"0.6156845",
"0.61213005",
"0.6108773",
"0.60500073",
"0.6039537",
"0.60387963",
"0.60387963",
"0.60387963",
"0.5994629",
"0.59... | 0.831017 | 0 |
Limit a given string to a specified length | def lim_str_len(string, length, end='...'):
if len(string) <= length:
return string
else:
return '{}{}'.format(string[:length - len(end)], end) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_max_length(self, string):\n newstring = string\n length = len(newstring)\n max_length = 63\n if length > max_length:\n newstring = newstring[0:max_length]\n\n return newstring",
"def test__limit_string_length(string, max_length):\n return limit_string_l... | [
"0.7902587",
"0.7835895",
"0.75604343",
"0.7514349",
"0.74940544",
"0.74157304",
"0.7361507",
"0.73120594",
"0.72713256",
"0.7262752",
"0.71534055",
"0.7017553",
"0.6987489",
"0.6956871",
"0.69386333",
"0.6928784",
"0.6910822",
"0.69106156",
"0.6901981",
"0.6878013",
"0.68769... | 0.80943525 | 0 |
Generate a unique, and very difficult to guess, project key. | def generate_project_key():
return shortuuid.ShortUUID().random(length=32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key():\n return str(uuid.uuid4())",
"def gen_api_key():\r\n m = hashlib.sha256()\r\n m.update(get_random_word(12))\r\n return unicode(m.hexdigest()[:12])",
"def generate_key():\n return get_token_generator().generate_token()",
"def generate_key(self):\n retu... | [
"0.79155785",
"0.7775702",
"0.7626928",
"0.750305",
"0.7375972",
"0.71838915",
"0.7182287",
"0.7178739",
"0.7053424",
"0.7009634",
"0.6993134",
"0.6992274",
"0.69627655",
"0.69268835",
"0.6890797",
"0.6881805",
"0.6874118",
"0.6863728",
"0.6855253",
"0.6817818",
"0.67374754",... | 0.91272426 | 0 |
Update the image for the project. | def update_image(self):
modified_since = (
dict(modified__gt=self.image_updated) if self.image_updated else {}
)
if self.image_path and self.image_path != "__uploaded__":
# Does the file need updating?
images = self.files.filter(
current=True, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_image(self, image):\n raise NotImplementedError()",
"def update_image(self):\n self.image = Image.fromarray(self.img)",
"def update_image_all_projects(self):\n projects = Project.objects.all(temporary=False)\n for project in projects:\n project.update_image()",... | [
"0.7685141",
"0.73662555",
"0.7222374",
"0.69448644",
"0.6820686",
"0.6818791",
"0.677097",
"0.6753897",
"0.6717046",
"0.6702262",
"0.66908646",
"0.6661354",
"0.66291267",
"0.65811455",
"0.6577313",
"0.655217",
"0.64976764",
"0.64719224",
"0.6462158",
"0.6462158",
"0.6392289"... | 0.7719839 | 0 |
Update the image of all projects. | def update_image_all_projects(self):
projects = Project.objects.all(temporary=False)
for project in projects:
project.update_image() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_project_data(project_name):\n project_path = context.__PROJECTS_PATH__+ '/' + project_name\n f = open(project_path+'/.project', 'r')\n project_data = json.load(f)\n f.close()\n\n image_count = len(os.listdir(project_path)) - 2\n\n if image_count > 0:\n\n img = Image.open('{}/{}.... | [
"0.6972187",
"0.6777449",
"0.6594918",
"0.6342221",
"0.6153103",
"0.6097519",
"0.6076489",
"0.6054905",
"0.59777665",
"0.59237146",
"0.5920237",
"0.59075",
"0.59057623",
"0.5903648",
"0.5901088",
"0.58525425",
"0.5830686",
"0.5823933",
"0.5811466",
"0.5807372",
"0.5804207",
... | 0.90420735 | 0 |
Get the scheduled deletion time of a temporary project. | def scheduled_deletion_time(self) -> Optional[datetime.datetime]:
if not self.temporary:
return None
delta = Project.TEMPORARY_PROJECT_LIFESPANS.get(
self.account.name, Project.TEMPORARY_PROJECT_LIFESPANS.get("default")
)
return self.created + delta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduled_deletion_warning(self) -> Optional[datetime.datetime]:\n time = self.scheduled_deletion_time\n return time - Project.TEMPORARY_PROJECT_WARNING if time else None",
"def delete_time(self) -> str:\n return pulumi.get(self, \"delete_time\")",
"def delete_time(self) -> str:\n ... | [
"0.6921164",
"0.6562803",
"0.6562803",
"0.6188812",
"0.58171326",
"0.5730795",
"0.5701719",
"0.5518333",
"0.55177927",
"0.5512329",
"0.54670966",
"0.5458026",
"0.54461396",
"0.5335375",
"0.53240615",
"0.5315584",
"0.5306388",
"0.5295981",
"0.5270675",
"0.5270596",
"0.5227072"... | 0.81216675 | 0 |
Get the scheduled time for a warning of deletion email to be send to project owner. | def scheduled_deletion_warning(self) -> Optional[datetime.datetime]:
time = self.scheduled_deletion_time
return time - Project.TEMPORARY_PROJECT_WARNING if time else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduled_deletion_time(self) -> Optional[datetime.datetime]:\n if not self.temporary:\n return None\n\n delta = Project.TEMPORARY_PROJECT_LIFESPANS.get(\n self.account.name, Project.TEMPORARY_PROJECT_LIFESPANS.get(\"default\")\n )\n return self.created + delta... | [
"0.6964856",
"0.6478921",
"0.6478921",
"0.63262975",
"0.61052036",
"0.5725044",
"0.5711345",
"0.5687409",
"0.5663868",
"0.5653854",
"0.5606957",
"0.56067246",
"0.55298257",
"0.5479845",
"0.5387236",
"0.5387061",
"0.537733",
"0.5360682",
"0.5312974",
"0.5282476",
"0.5270324",
... | 0.80382836 | 0 |
Get the main file for the project. The main file can be designated by the user (using the `main` field as the path). If no file matches that path (e.g. because it was removed), or if `main` was never set, then this defaults to the most recently modified file with path `main.` or `README.` if those are present. | def get_main(self):
if self.main:
try:
# Using `filter()` and indexing to get the first item is more robust that
# using `get()`. There should only be one item with path that is current
# but this avoids a `MultipleObjectsReturned` in cases when there ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMain(self):\n\n if self.__projects:\n return self.__projects[0]\n else:\n return None",
"def get_main_source(self):\n\t\tpath, loader = self.main\n\t\tif path is not None:\n\t\t\treturn loader.get_source(path)",
"def defaultFile(self):\n filename = _odb.getCurr... | [
"0.6912671",
"0.63616216",
"0.6164986",
"0.6089585",
"0.6066663",
"0.59985036",
"0.5891858",
"0.58236873",
"0.55907995",
"0.5402024",
"0.5329899",
"0.5312935",
"0.5272182",
"0.5242959",
"0.5234238",
"0.5114161",
"0.5106685",
"0.50861514",
"0.50775504",
"0.50709206",
"0.507092... | 0.7425918 | 0 |
Get the theme for the project. | def get_theme(self) -> str:
return self.theme or self.account.theme | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_theme():\n # Return None if theming is disabled\n if not is_comprehensive_theming_enabled():\n return None\n\n site_theme = get_current_site_theme()\n if not site_theme:\n return None\n try:\n return Theme(\n name=site_theme.theme_dir_name,\n ... | [
"0.77218676",
"0.756868",
"0.7343077",
"0.711062",
"0.70631874",
"0.70348823",
"0.68387085",
"0.66256326",
"0.65988183",
"0.654876",
"0.6471758",
"0.6386882",
"0.63486433",
"0.63153225",
"0.62846875",
"0.6231964",
"0.62230563",
"0.6190626",
"0.61657983",
"0.61640877",
"0.6141... | 0.8288318 | 0 |
Handle an event notification. Records the event and evaluates each project trigger. | def event(self, data: dict, source=None):
ProjectEvent.objects.create(project=self, data=data, source=source)
# TODO: Evaluate each project trigger
# #for trigger in self.triggers.all():
# trigger.evaluate(event=event, context=dict(event=event, source=source)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trigger_event(event):\n\n\tglobal update_local_events\n\trecord_trigger = True\n\n\tlogger.info(\"Event is potentially suitable for observation!\")\n\tif MAIL_NOTIFICATIONS_ON:\n\t\tlogger.info(\"Mailing event notification...\")\n\t\ttry:\n\t\t\tsend_mail_notification(event)\n\t\texcept Exception as ex:\n\t\t\... | [
"0.6982703",
"0.62325114",
"0.612688",
"0.57484126",
"0.5741762",
"0.5703489",
"0.570331",
"0.5697788",
"0.5667945",
"0.5661009",
"0.56453514",
"0.5602698",
"0.5601577",
"0.5578952",
"0.55578",
"0.5533698",
"0.5530482",
"0.55246097",
"0.54608643",
"0.5457123",
"0.5456523",
... | 0.6456528 | 1 |
Pull all the project's sources into its working directory. Groups sources by `order` (with `null` order first i.e. can be overridden). If there are more than one source in each group creates a `parallel` job having children jobs that `pull`s each source. Groups are then placed in a series job (if there is more than one... | def pull(self, user: User) -> Job:
# Do not create individual pull jobs here because series job children
# are run in order of their ids; so we need to sort into groups first.
groups: Dict[int, List] = {}
for source in self.sources.all():
order = source.order or 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull(args):\n do_all_projects(args + [\"pull\"])",
"def pull(targets, *keys):",
"def push_sources():\n ensure_src_dir()\n push_rev = getattr(env, 'push_rev', None)\n if push_rev is None:\n push_rev = datetime.datetime.now().strftime(\"%Y%m%d_%H%M%S\")\n local(\"git tag -a {0} -m \\\... | [
"0.5802862",
"0.5222017",
"0.5175938",
"0.51217717",
"0.50083756",
"0.49580196",
"0.48946944",
"0.48938698",
"0.4885122",
"0.48726898",
"0.48700982",
"0.48692283",
"0.48593602",
"0.48042524",
"0.47969273",
"0.47789612",
"0.47780585",
"0.47709864",
"0.4749284",
"0.47399348",
"... | 0.61282736 | 0 |
Reflow the dependencies between the project's files by rerunning jobs. For all `current` files that have `upstreams` creates a new job that reexecutes the original job. Because jobs can have `secrets` and callbacks to the original project, rather than creating a copy of the original job we go through the `File` method ... | def reflow(self, user: User) -> Optional[Job]:
subjobs = []
for file in self.files.filter(
current=True,
upstreams__isnull=False,
# Currently limited to convert jobs but in future there
# may be other jobs that create a derived file
# e.g. runn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _precache_reference_files(self, input_file):\n from .. import datamodels\n gc.collect()\n if self._is_association_file(input_file):\n return\n try:\n with datamodels.open(input_file) as model:\n pass\n except (ValueError, TypeError, IOErro... | [
"0.5435536",
"0.52989703",
"0.5218885",
"0.51945597",
"0.51398677",
"0.50693643",
"0.506141",
"0.5025757",
"0.50252265",
"0.50123876",
"0.49895275",
"0.49730432",
"0.496613",
"0.49546805",
"0.49308264",
"0.49184242",
"0.4908504",
"0.49012965",
"0.48830163",
"0.4880889",
"0.48... | 0.6498693 | 0 |
Pin the project's container image. Does not change the project's `container_image` field, but rather, returns a pinned version of it. The callback should use that value. | def pin(self, user: User, **callback) -> Job:
return Job.objects.create(
project=self,
creator=user,
method=JobMethod.pin.name,
params=dict(container_image=self.container_image,),
description=f"Pin container image for project '{self.name}'",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_container():\n return exec_fn(_update_container)",
"def _put_container_on_host(self, container_name):\n with hide(\"output\", \"warnings\", \"running\"):\n # first see if container is already present on host\n host_result = self._execute_root(\n \"docker ... | [
"0.4892535",
"0.47694457",
"0.4650474",
"0.46101207",
"0.46038973",
"0.45849597",
"0.4556329",
"0.45442688",
"0.45416212",
"0.44963834",
"0.4495275",
"0.4492923",
"0.44748017",
"0.44405603",
"0.44272813",
"0.4418504",
"0.44036055",
"0.44023618",
"0.43763033",
"0.43761548",
"0... | 0.7015722 | 0 |
Create a session job for the project. | def session(self, request: HttpRequest) -> Job:
job = Job.objects.create(
project=self,
creator=request.user if request.user.is_authenticated else None,
method=JobMethod.session.name,
params=dict(container_image=self.container_image),
description=f"Ses... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_job(self, context=None):\n return self._client.call_method(\n 'UserAndJobState.create_job',\n [], self._service_ver, context)",
"def createJob(self, joboptions, previousId=None):\n root = self.manifest.getRootResource()\n assert self.manifest.tosca\n j... | [
"0.631419",
"0.61037755",
"0.60672235",
"0.59948283",
"0.5993035",
"0.59315264",
"0.5915751",
"0.59131706",
"0.59121525",
"0.59017074",
"0.5868312",
"0.5839195",
"0.57926786",
"0.5777216",
"0.5776275",
"0.5771428",
"0.5747704",
"0.57435995",
"0.57095104",
"0.5693203",
"0.5688... | 0.8064805 | 0 |
Make the project create an owner. Makes sure each project has at least one owner. | def make_project_creator_an_owner(
sender, instance: Project, created: bool, *args, **kwargs
):
if sender is Project and created and instance.creator:
ProjectAgent.objects.create(
project=instance, user=instance.creator, role=ProjectRole.OWNER.name
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_owner(self):\n url = reverse(\n 'projectroles:api_role_create',\n kwargs={'project': self.project.sodar_uuid},\n )\n post_data = {\n 'role': PROJECT_ROLE_OWNER,\n 'user': str(self.assign_user.sodar_uuid),\n }\n response ... | [
"0.6795974",
"0.67435247",
"0.6457388",
"0.6397213",
"0.6334437",
"0.61915594",
"0.6109523",
"0.6071861",
"0.6055635",
"0.59651107",
"0.59185636",
"0.59049666",
"0.5854356",
"0.5853638",
"0.5830807",
"0.5797529",
"0.5782358",
"0.57266897",
"0.5696159",
"0.56787217",
"0.565595... | 0.7869675 | 0 |
Get the description of a project role. | def get_description(cls, role: "ProjectRole"):
return {
cls.READER.name: "Can view project, but not make edits or share with others.",
cls.REVIEWER.name: "Can view project files and leave comments, but not edit project or share with others.",
cls.EDITOR.name: "Can edit projec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_description(cls, role: \"AccountRole\"):\n return {\n cls.MEMBER.name: \"Can create, update and delete projects.\",\n cls.MANAGER.name: \"As for member and can create, update and delete teams.\",\n cls.OWNER.name: \"As for manager and can also add and remove users an... | [
"0.7792207",
"0.6987312",
"0.69184756",
"0.68976855",
"0.67182356",
"0.65315354",
"0.643556",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
"0.62512106",
... | 0.7914427 | 0 |
Get the role from a string. | def from_string(cls, role: str) -> "ProjectRole":
role = role.lower()
for r in cls:
if role == r.name.lower():
return r
raise ValueError('No project role matching "{}"'.format(role)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_role(text, guild = None):\n parsed = ID_RP.fullmatch(text)\n if (parsed is not None):\n role_id = int(parsed.group(1))\n try:\n role = ROLES[role_id]\n except KeyError:\n pass\n else:\n return role\n \n role = parse_role_mention(tex... | [
"0.71190786",
"0.6835649",
"0.6639244",
"0.6453106",
"0.64529836",
"0.6413376",
"0.63951063",
"0.63896227",
"0.6259766",
"0.62412035",
"0.62352717",
"0.62352717",
"0.62352717",
"0.6211062",
"0.6178344",
"0.61578375",
"0.6108778",
"0.6107524",
"0.6080702",
"0.6046944",
"0.6037... | 0.72234476 | 0 |
Returns the raw corpus as a long string. 'nr_files' says how much of the corpus is returned; default is 199, which is the whole corpus. | def get_corpus_text(nr_files=199):
fileids = nltk.corpus.treebank_raw.fileids()[:nr_files]
corpus_text = nltk.corpus.treebank_raw.raw(fileids)
corpus_text = corpus_text.replace(".START", "")
return corpus_text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_raw_corpus():\n with open(RAW_CORPUS_PATH, 'r') as f:\n return f.read().splitlines()",
"def constructReadCountsStr(samplesList, resultsPath, outRoot, stype):\n files = []\n for i in range(len(samplesList)):\n files.append(os.path.join(resultsPath, outRoot) + \".\" + stype + \".\" +... | [
"0.5845489",
"0.5356129",
"0.52977467",
"0.51715916",
"0.51683617",
"0.51463205",
"0.5103877",
"0.5073599",
"0.50058883",
"0.49874315",
"0.49868163",
"0.4972849",
"0.4881852",
"0.4833174",
"0.4830412",
"0.48244664",
"0.48116353",
"0.475429",
"0.4750338",
"0.47492743",
"0.4739... | 0.72962815 | 0 |
Returns the gold corpus as a list of strings. 'nr_files' says how much of the corpus is returned; default is 199, which is the whole corpus. | def get_gold_tokens(nr_files=199):
fileids = nltk.corpus.treebank_chunk.fileids()[:nr_files]
gold_tokens = nltk.corpus.treebank_chunk.words(fileids)
return fix_treebank_tokens(gold_tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corpus_text(nr_files=199):\n fileids = nltk.corpus.treebank_raw.fileids()[:nr_files]\n corpus_text = nltk.corpus.treebank_raw.raw(fileids)\n corpus_text = corpus_text.replace(\".START\", \"\")\n return corpus_text",
"def get_corpus():\n corpus_raw = []\n files = os.listdir()\n\n for ... | [
"0.68941635",
"0.6100084",
"0.5768867",
"0.5508093",
"0.55005074",
"0.54668933",
"0.54602385",
"0.54518676",
"0.5420774",
"0.54132926",
"0.5386534",
"0.5351961",
"0.5336444",
"0.52829045",
"0.5270027",
"0.5254968",
"0.5234643",
"0.52127033",
"0.520838",
"0.5193462",
"0.518718... | 0.6930744 | 0 |
Finds the chunks where test_tokens differs from gold_tokens. Prints the errors and calculates similarity measures. | def evaluate_tokenization(test_tokens, gold_tokens):
matcher = difflib.SequenceMatcher()
matcher.set_seqs(test_tokens, gold_tokens)
error_chunks = true_positives = false_positives = false_negatives = 0
print(" Token%30s | %-30sToken" % ("Error", "Correct"))
print("-" * 38 + "+" + "-" * 38)
for d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _diff(gold_tokens, pred_tokens):\n matcher = difflib.SequenceMatcher(None, gold_tokens, pred_tokens)\n a_lo = b_lo = 0\n for a_hi, b_hi, n in matcher.get_matching_blocks():\n if a_lo < a_hi or b_lo < b_hi:\n yield gold_tokens[a_lo:a_hi], pred_tokens[b_lo:b_hi]\n a_lo = a_hi + ... | [
"0.6527174",
"0.62255156",
"0.6006039",
"0.59620684",
"0.5928861",
"0.587654",
"0.5874386",
"0.5815653",
"0.58089805",
"0.57442725",
"0.564411",
"0.5521066",
"0.55191135",
"0.5479484",
"0.54474944",
"0.5424343",
"0.5417302",
"0.5396069",
"0.53927183",
"0.53886485",
"0.5379245... | 0.75287586 | 0 |
Returns the length of the corpus | def corpus_length(corpus):
corpus_len = len(corpus)
return corpus_len | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corpus_size():\n return ix.doc_count()",
"def get_length(self):\r\n return len(self.tweets)",
"def __len__(self):\n if self._words is None:\n return 0\n return len(self._words)",
"def __len__(self):\n return len(self.words)",
"def get_length_of_article(self):\n... | [
"0.86246103",
"0.7128457",
"0.711803",
"0.70741546",
"0.70083636",
"0.6877699",
"0.6864959",
"0.68288773",
"0.6719017",
"0.6706363",
"0.6685086",
"0.66821533",
"0.6680235",
"0.66707677",
"0.6659052",
"0.6654295",
"0.66518724",
"0.6644698",
"0.6623218",
"0.65752524",
"0.657241... | 0.9156975 | 0 |
Returns the number of types of the corpus | def number_types(corpus):
number_of_types = len(set(corpus))
return number_of_types | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corpus_size():\n return ix.doc_count()",
"def corpus_stats(self):\n print(\"Number of sentences: {}\".format(len(self.corpus.sents())))\n print(\"Token: {}\".format(len(self.corpus.words())))\n types = FreqDist(self.corpus.words())\n print(\"Types: {}\".format(len(types)))",
... | [
"0.762349",
"0.71802056",
"0.69813615",
"0.68990517",
"0.68193585",
"0.6785418",
"0.6478397",
"0.64172184",
"0.6361729",
"0.63225734",
"0.63215053",
"0.63175625",
"0.6286316",
"0.6242273",
"0.6241575",
"0.62144715",
"0.62034416",
"0.61651814",
"0.6163551",
"0.6149904",
"0.612... | 0.86536777 | 0 |
Returns the average token length of the corpus | def average_length(corpus):
token_size = 0
for i in corpus:
token_size += len(i)
return token_size/len(corpus) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_word_len(text):\r\n return np.mean(np.array([len(word) for word in tokenization(text)]))",
"def get_avg_word_length(self):\n words = self.blob.words\n average_word_length = np.mean(np.array([len(word) for word in words]))\n return average_word_length",
"def get_avg_sentence_len... | [
"0.7740834",
"0.76111984",
"0.7465189",
"0.7424989",
"0.73925495",
"0.7379742",
"0.7154015",
"0.7079485",
"0.69219846",
"0.6788959",
"0.6713551",
"0.6628082",
"0.6622776",
"0.65117276",
"0.6499887",
"0.648808",
"0.64503044",
"0.63774174",
"0.63654184",
"0.63253933",
"0.632013... | 0.91032505 | 0 |
Returns a tuple with the token with longest length and its length | def longest_token(corpus):
token_length = max([(len(x), x) for x in corpus])
long_token = [(len(i), i) for i in corpus if len(i) == token_length[0]]
return long_token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_word_length(words):",
"def token_length(self):\n return 32",
"def longest_word_len(text):\r\n return np.max(np.array([len(word) for word in tokenization(text)]))",
"def longest(self, n):\n return big_tags",
"def parse_len_token(self, token, context):\n match = Ftype_char... | [
"0.6989448",
"0.6604611",
"0.65495056",
"0.6322947",
"0.6315792",
"0.6271042",
"0.6225847",
"0.6206488",
"0.6204552",
"0.6153764",
"0.6150393",
"0.6148043",
"0.6115631",
"0.6096827",
"0.60948676",
"0.60551727",
"0.6030734",
"0.6026074",
"0.6018043",
"0.6005589",
"0.60053426",... | 0.79787576 | 0 |
Returns the number of hapaxes | def hapaxes(corpus):
fd = freq_dist(corpus)
length_hapaxes = len(fd.hapaxes())
return length_hapaxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hapax(self):\n return self.nlegomena(1)",
"def hapaxes_parts(corpus_parts):\n hapaxes = [] \n l = [] \n for part in corpus_parts:\n fd = freq_dist(part)\n hapaxes.append(fd.hapaxes())\n \n for x in range(len(hapaxes)): \n p = []\n for hapax in hapaxes[x]:\n ... | [
"0.71300244",
"0.69368875",
"0.6899001",
"0.67700213",
"0.6713909",
"0.66338396",
"0.66306466",
"0.6584287",
"0.6531329",
"0.6471116",
"0.64255387",
"0.63993526",
"0.63469976",
"0.6336948",
"0.6327612",
"0.6278651",
"0.6271024",
"0.62702435",
"0.62528473",
"0.62366015",
"0.62... | 0.77868515 | 0 |
Returns the 10 most frequent types of the corpus | def most_frequent(corpus):
fd = nltk.FreqDist(corpus)
return fd.most_common(10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_10_most_frequent_words(tokens):\n\n return FreqDist(word.lower() for word in tokens).most_common(10)",
"def print_most_frequent(ngrams, num=10):\r\n for n in sorted(ngrams):\r\n print('----- {} most common {}-grams -----'.format(num, n))\r\n for gram, count in ngrams[n].most_common(nu... | [
"0.7420908",
"0.68801576",
"0.6863302",
"0.6863302",
"0.6793732",
"0.6789225",
"0.6789225",
"0.67334443",
"0.67113686",
"0.67021793",
"0.66943693",
"0.66930974",
"0.66756886",
"0.6594498",
"0.6594149",
"0.6593065",
"0.65787506",
"0.6552879",
"0.64887744",
"0.6478066",
"0.6448... | 0.76018584 | 0 |
Calculates the percent of the total tokens in the corpus that constist of these types | def percentage_common_types (corpus):
total = sum([t[1] for t in most_frequent(corpus)])
return percentage(total, corpus_length(corpus)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_percentage(word, text):\n word_count = text.count(word)\n text_len = len(text)\n return percentage(word_count, text_len)",
"def _get_token_cnts(self, doc, doc_type):\n tokenized_doc = self.nlp(doc)\n self.stat_dict[doc_type][0].append(len([s for s in tokenized_doc.sents]))\n ... | [
"0.7122834",
"0.6609406",
"0.6508489",
"0.6426509",
"0.6370771",
"0.6364847",
"0.6266487",
"0.6084241",
"0.60529697",
"0.6052734",
"0.6027012",
"0.60187364",
"0.5996216",
"0.59940755",
"0.5989834",
"0.5947879",
"0.5946035",
"0.59456563",
"0.5928288",
"0.58380187",
"0.58172226... | 0.76858276 | 0 |
Returns a list that divides the corpus in 10 equally large subcorpora starting in 0 | def divide_corpus(corpus, number_of_partitions):
partition_length = corpus_length(corpus) / number_of_partitions
list_of_index = []
for i in range(number_of_partitions + 1):
list_of_index.append(partition_length*i)
list_of_index = [int(i) for i in list_of_index]
ind_bigr = nltk.bigrams(list_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_frequencies(num_words, documents):\n res = [0 for i in range(num_words)]\n sum = 0\n for word in documents:\n sum += 1\n tmp = set(word)\n for number in tmp:\n res[number] += 1\n \n res = [i / sum for i in res]\n return res",
"def strech_list(sector, subgraphs_):\n\n strechs=[]... | [
"0.55991673",
"0.5596885",
"0.5583748",
"0.5540588",
"0.55019647",
"0.5501352",
"0.5467884",
"0.54672116",
"0.5459272",
"0.54368347",
"0.5429263",
"0.54035556",
"0.53881025",
"0.5382939",
"0.53346455",
"0.5332272",
"0.5328042",
"0.53276277",
"0.53100634",
"0.5303269",
"0.5279... | 0.66362506 | 0 |
Returns the percentage of hapaxes for every partition | def percentage_hapaxes(corpus_parts, corpus):
percentage_h = []
count = 0
dv = divide_corpus(corpus, 10)
hapax_parts = hapaxes_parts(corpus_parts)
for x in hapax_parts:
percentage_h.append(percentage(x, len(dv[count])))
count += 1
return percentage_h | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ps (H) :\n p = np.array ([np.mean (np.diagonal (H, offset=k))\n for k in range (H.shape[0])])\n return p/np.sum(p)",
"def hapaxes_parts(corpus_parts):\n hapaxes = [] \n l = [] \n for part in corpus_parts:\n fd = freq_dist(part)\n hapaxes.append(fd.hapaxes())\n ... | [
"0.5896968",
"0.5892362",
"0.5866959",
"0.58635896",
"0.5844549",
"0.57622796",
"0.57277703",
"0.5724019",
"0.5721638",
"0.5704809",
"0.5675501",
"0.56264746",
"0.56017643",
"0.5570609",
"0.5560135",
"0.55325496",
"0.55276257",
"0.550061",
"0.54999614",
"0.5493106",
"0.548825... | 0.79433656 | 0 |
given the data obtained by the functions divide_corpus(corpus, number_of_partitions) and hapaxes_parts(corpus_parts), the graphic for the number of hapaxes per partition is plotted | def plots(corpus_parts, corpus):
"""
given the data obtained by the function percentage_hapaxes(dv_corpus, tokenized_corpus),
the graphic for the percentage of hapaxes per partition is plotted
"""
h_parts = hapaxes_parts(corpus_parts)
part_size = [x for x in range(len(h_parts))]
percent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hapaxes_parts(corpus_parts):\n hapaxes = [] \n l = [] \n for part in corpus_parts:\n fd = freq_dist(part)\n hapaxes.append(fd.hapaxes())\n \n for x in range(len(hapaxes)): \n p = []\n for hapax in hapaxes[x]:\n if hapax not in l:\n p.append(h... | [
"0.63274544",
"0.6236243",
"0.60902673",
"0.60751843",
"0.6013556",
"0.5849579",
"0.5765388",
"0.5748273",
"0.5698169",
"0.56906366",
"0.56627107",
"0.56146663",
"0.5596817",
"0.55957896",
"0.55932474",
"0.55843383",
"0.5578917",
"0.5569549",
"0.5569478",
"0.5563574",
"0.5557... | 0.806501 | 0 |
prints the result of each function in the corpus statistics part | def corpus_statistics(corpus, d_corp):
print('There are {} types of a total of {} tokens in the corpus.\n' .format(number_types(corpus), corpus_length(corpus)))
print('There average token length is {}.\n' .format(average_length(corpus)))
print('The longest token is {}.\n' .format(longest_token(corpus)))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corpus_stats(self):\n print(\"Number of sentences: {}\".format(len(self.corpus.sents())))\n print(\"Token: {}\".format(len(self.corpus.words())))\n types = FreqDist(self.corpus.words())\n print(\"Types: {}\".format(len(types)))",
"def compute_statistics(self):",
"def main():\n ... | [
"0.6597699",
"0.6429246",
"0.63254446",
"0.63020265",
"0.62856656",
"0.624625",
"0.62422293",
"0.61852133",
"0.61593163",
"0.6144798",
"0.612338",
"0.6114669",
"0.6085939",
"0.60662675",
"0.60401654",
"0.60325223",
"0.60199016",
"0.6014599",
"0.6006987",
"0.59975606",
"0.5994... | 0.6906636 | 0 |
Given a state dict, load the model's state. | def load_from_state_dict(self, state_dict):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model_state(model, model_state):\n model.load_state_dict(model_state, strict=True)",
"def _load_state(self, model_state: dict) -> bool:\n raise NotImplementedError",
"def load_state_dict(self, state_dict: Dict[str, torch.Tensor]):\n pass",
"def load_state(self, state):\n rais... | [
"0.8597909",
"0.77825034",
"0.77680033",
"0.76157165",
"0.75413203",
"0.7495061",
"0.74915165",
"0.7475301",
"0.7467834",
"0.7421826",
"0.7397422",
"0.738471",
"0.738471",
"0.7383446",
"0.7383446",
"0.7383446",
"0.73804945",
"0.73804945",
"0.7286066",
"0.7211727",
"0.7208458"... | 0.817902 | 1 |
the main method of the shell running the infinite loop, continuesly prompting for a command, then attempting to execute the issued command | def run(self):
# opening the infinite loop inside of a try statement, so that the SystemExit Exception can be caught
try:
while True:
# first fetching the user input
print(colors.magenta(colors.bold(self.prompt)), end="")
command = input()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _run_as_shell(self):\n\n while True:\n self.command = self.line_edition.run(self.history)\n if self.command:\n self.history.append(' '.join(self.command))\n\n self.command = self.command_parser.run(self.command)\n if not self.command:\n ... | [
"0.7212018",
"0.71252775",
"0.69162244",
"0.68478006",
"0.6828391",
"0.6728153",
"0.6725586",
"0.6681274",
"0.6654319",
"0.664994",
"0.6621521",
"0.66023403",
"0.66004086",
"0.6572758",
"0.6559836",
"0.6502827",
"0.64146936",
"0.6412568",
"0.6411801",
"0.6390982",
"0.63907796... | 0.7400878 | 0 |
Returns an iterator of number of code points in each grapheme of the string. | def grapheme_lengths(string):
return iter(len(g) for g in graphemes(string)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self) -> Iterator[Tuple[int, str]]:\n length = \"\"\n for c in super().__iter__():\n if c in CIGAR_CHARS:\n yield (int(length), c)\n length = \"\"\n else:\n length += c",
"def get_char_counts(string):\n counts = {}\n... | [
"0.63102376",
"0.6066801",
"0.58364946",
"0.5682218",
"0.56752527",
"0.5587007",
"0.5516279",
"0.5483019",
"0.5476278",
"0.5476278",
"0.5432439",
"0.54060763",
"0.5371684",
"0.5355845",
"0.5348796",
"0.5294735",
"0.5293246",
"0.5278698",
"0.5262752",
"0.5248184",
"0.52327317"... | 0.82796204 | 0 |
Call this function when your robot's endCompetition function is called | def endCompetition(self):
self.robot_exit = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def endGame(self):\n pass",
"def end(self, won, reason):\n pass\n # replace with your end logic",
"def api_end_game(self):\n pass",
"def end(self):\n winners = mafia.str_player_list(self.game.winners())\n logging.info(\"Game over! Winners: %s\" % winners)\n\n subject = \"... | [
"0.7232599",
"0.7144199",
"0.71317685",
"0.6907059",
"0.6723826",
"0.67085814",
"0.6685554",
"0.6543566",
"0.6540756",
"0.64884466",
"0.6481509",
"0.6480941",
"0.64758396",
"0.64678586",
"0.6394599",
"0.63707036",
"0.63701093",
"0.63545465",
"0.63460165",
"0.6345414",
"0.6324... | 0.8943719 | 0 |
This method implements the entire autonomous loop. Do not call this from ``TimedRobot`` as this will break the timing of your control loop when your robot switches to teleop. This function will NOT exit until autonomous mode has ended. If you need to execute code in all autonomous modes, pass a function or list of func... | def run(
self,
control_loop_wait_time: float = 0.020,
iter_fn: Union[Callable[[], None], Sequence[Callable[[], None]]] = None,
on_exception: Callable = None,
watchdog: Union[wpilib.Watchdog, SimpleWatchdog] = None,
) -> None:
if watchdog is not None:
watch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loop(self):\n\n # Set loop frequency\n rate = rospy.Rate(LOOP_FREQUENCY)\n\n # While the system is active...\n while not rospy.is_shutdown():\n\n # If current pose and waypoints are known...\n if not None in (self.pose, self.waypoints, self.waypoints_2d, self.w... | [
"0.57772887",
"0.571012",
"0.5682816",
"0.56716055",
"0.55617225",
"0.55325687",
"0.549369",
"0.5488872",
"0.54072434",
"0.5394649",
"0.5375031",
"0.53742313",
"0.53269994",
"0.5281366",
"0.5257357",
"0.5238456",
"0.522742",
"0.5222745",
"0.5217429",
"0.5214553",
"0.5200336",... | 0.7719447 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.