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 |
|---|---|---|---|---|---|---|
Disable the OLED click. | def disable():
ret = _LIB.oled_click_disable()
if ret < 0:
raise Exception("oled click disable failed") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _led_disable():\n # type: () -> None\n GPIO.output(LED_nOE, GPIO.HIGH)",
"def disable():\n ret = _LIB.led_matrix_click_disable()\n if ret < 0:\n raise Exception(\"led matrix click disable failed\")",
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light",
"def t... | [
"0.809518",
"0.7531012",
"0.7469522",
"0.72568923",
"0.7174813",
"0.71696955",
"0.71069515",
"0.71025395",
"0.70688444",
"0.70502096",
"0.704196",
"0.70280635",
"0.70278597",
"0.6998497",
"0.6984781",
"0.6962407",
"0.69579947",
"0.6957407",
"0.6956076",
"0.6949486",
"0.694127... | 0.8671251 | 0 |
Returns the score for a word. Assumes the word is a valid word. The score for a word is the sum of the points for letters in the word, multiplied by the length of the word, PLUS 50 points if all n letters are used on the first turn. Letters are scored as in Scrabble; A is worth 1, B is worth 3, C is worth 3, D is worth... | def getWordScore(word, n):
score = 0
for letters in word:
if letters in SCRABBLE_LETTER_VALUES:
score += SCRABBLE_LETTER_VALUES[letters]
if len(word) == n:
return (score * len(word)) + 50
else:
return score * len(word) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getWordScore(word, n):\n score = 0\n for letter in word:\n score += SCRABBLE_LETTER_VALUES[letter]\n score *= len(word)\n if len(word) == n:\n score += 50\n return score",
"def get_word_score(word, n=7):\n score = 0\n\n for i in word:\n score += SCRABBLE_LETTER_VALUE... | [
"0.84181976",
"0.82934874",
"0.8220061",
"0.8052078",
"0.8041427",
"0.7843509",
"0.7650167",
"0.7636099",
"0.7610513",
"0.75861526",
"0.7409019",
"0.7204724",
"0.70169866",
"0.70130014",
"0.6928664",
"0.6779603",
"0.67548424",
"0.67543375",
"0.67239964",
"0.66737604",
"0.6667... | 0.8374879 | 1 |
Returns a random hand containing n lowercase letters. At least n/3 the letters in the hand should be VOWELS. Hands are represented as dictionaries. The keys are letters and the values are the number of times the particular letter is repeated in that hand. | def dealHand(n):
hand={}
numVowels = n / 3
for i in range(numVowels):
x = VOWELS[random.randrange(0,len(VOWELS))]
hand[x] = hand.get(x, 0) + 1
for i in range(numVowels, n):
x = CONSONANTS[random.randrange(0,len(CONSONANTS))]
hand[x] = hand.get(x, 0) + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_hand(n):\n hand = {}\n num_vowels = n // 3\n\n for i in range(num_vowels):\n x = VOWELS[random.randrange(0, len(VOWELS))]\n hand[x] = hand.get(x, 0) + 1\n\n for i in range(num_vowels, n):\n x = CONSONANTS[random.randrange(0, len(CONSONANTS))]\n hand[x] =... | [
"0.78006905",
"0.7678525",
"0.7669588",
"0.74499804",
"0.6461991",
"0.6153672",
"0.60777944",
"0.60667515",
"0.60564005",
"0.5998895",
"0.59673965",
"0.59573287",
"0.59163105",
"0.59163105",
"0.59163105",
"0.5879762",
"0.58750254",
"0.584636",
"0.5825631",
"0.58003813",
"0.57... | 0.76973146 | 1 |
Generates a JWT token valid for 10 minutes using the private key. | def generate_jwt_token(private_pem: bytes, app_id: int) -> str:
private_key = jwcrypto.jwk.JWK.from_pem(private_pem)
payload = {"iss": app_id}
duration = datetime.timedelta(minutes=10)
return python_jwt.generate_jwt(payload, private_key, "RS256", duration) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_jwt_token(self):\n import jwt\n from datetime import datetime, timedelta\n from django.conf import settings\n\n dt = datetime.now() + timedelta(days=60)\n\n token = jwt.encode({\n 'id': self.pk,\n 'username': self.username,\n 'exp': ... | [
"0.7184967",
"0.7133718",
"0.6737407",
"0.67275083",
"0.6704615",
"0.65334314",
"0.6511841",
"0.64169765",
"0.64080316",
"0.6331098",
"0.62940425",
"0.62615675",
"0.6237678",
"0.621826",
"0.6174233",
"0.6108475",
"0.60688114",
"0.6027714",
"0.6024385",
"0.59928554",
"0.595844... | 0.7318258 | 0 |
Generates an installation access token using a JWT token and an installation id. An installation access token is valid for 1 hour. | def generate_installation_access_token(jwt_token: str, installation_id) -> str:
headers = {
"Authorization": f"Bearer {jwt_token}",
"Accept": "application/vnd.github.machine-man-preview+json",
"User-Agent": USER_AGENT,
}
url = f"https://api.github.com/app/installations/{installation_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_access_token():\n return do_build_access_token(tenant_id='intility_tenant_id')",
"def get_token(app_id, installation_id):\n token_url = f\"{API_BASE_URL}/app/installations/{installation_id}/access_tokens\"\n temp_state = str(uuid.uuid4())\n private_key = get_private_key()\n\n # Required ... | [
"0.6996901",
"0.6979113",
"0.6809183",
"0.67003566",
"0.6534887",
"0.6493192",
"0.6465398",
"0.6324435",
"0.6281636",
"0.62720484",
"0.6217066",
"0.62050366",
"0.61707485",
"0.6150757",
"0.61372226",
"0.60964096",
"0.6017347",
"0.6011306",
"0.592635",
"0.59209037",
"0.5904168... | 0.8433338 | 0 |
Reads a private PEM file from an S3 bucket. | def get_pem(bucket_name: str, bucket_key: str) -> bytes:
s3 = boto3.resource("s3")
s3.Bucket(bucket_name).download_file(bucket_key, "/tmp/key.pem")
with open("/tmp/key.pem", "rb") as f:
return f.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_s3_file(bucket, key):\r\n try:\r\n s_3 = boto3.client('s3')\r\n file = s_3.get_object(Bucket=bucket, Key=key)\r\n file_body = file['Body'].read().decode(\"utf-8\")\r\n return file_body\r\n\r\n except (FileNotFoundError, IndexError, SystemExit, OSError, IOError) as err:\r\... | [
"0.7351964",
"0.7110344",
"0.70346",
"0.6955667",
"0.69070524",
"0.6842378",
"0.6714841",
"0.6691865",
"0.6596183",
"0.6484976",
"0.6464774",
"0.62390226",
"0.62254405",
"0.62190664",
"0.62123066",
"0.6198812",
"0.616393",
"0.61633474",
"0.6101623",
"0.60783464",
"0.60682744"... | 0.74012285 | 0 |
Returns the maximum number of kubernetes jobs | def get_maximum_number_of_allowed_k8s_jobs(dry_run: bool = False) -> int:
retval = 5000
JSON_PATH = r"'{.spec.hard.count/jobs\.batch}'"
cmd = f'kubectl get resourcequota gke-resource-quotas -o=jsonpath={JSON_PATH}'
if not dry_run:
try:
p = safe_exec(cmd)
if p.stdout:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobserver_max_jobs():\n\n if _MakeJobServer._singleton is not None:\n return _MakeJobServer._singleton.num_jobs\n else:\n return 0",
"def maximum_number_of_workers(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"maximum_number_of_workers\")",
"def maximum_number_of_worke... | [
"0.78179955",
"0.75503117",
"0.7508189",
"0.73179954",
"0.7272363",
"0.7165923",
"0.7165923",
"0.7165923",
"0.7165923",
"0.7165923",
"0.70873964",
"0.69605875",
"0.6936822",
"0.6898711",
"0.6891758",
"0.6864941",
"0.6856878",
"0.68284523",
"0.6810833",
"0.6802255",
"0.6756869... | 0.8028468 | 0 |
Return a list of persistent volume ids for a kubernetes cluster. Kubeconfig file determines the cluster that will be contacted. | def get_persistent_volumes(k8s_ctx: str) -> List[str]:
cmd = f'kubectl --context={k8s_ctx} get pv -o json'
p = safe_exec(cmd)
try:
dvols = json.loads(p.stdout.decode())
except Exception as err:
raise RuntimeError('Error when parsing listing of Kubernetes persistent volumes ' + str(err))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_persistent_disks(k8s_ctx: str, dry_run: bool = False) -> List[str]:\n cmd = f'kubectl --context={k8s_ctx} get pv -o json'\n if dry_run:\n logging.info(cmd)\n else:\n p = safe_exec(cmd)\n if p.stdout:\n pds = json.loads(p.stdout.decode())\n return [i['spec... | [
"0.66107404",
"0.6445898",
"0.5872532",
"0.5834013",
"0.57105106",
"0.57075375",
"0.5590087",
"0.5556461",
"0.55296147",
"0.5528321",
"0.5513306",
"0.5472359",
"0.54522735",
"0.54383785",
"0.54374796",
"0.542925",
"0.53947073",
"0.53806466",
"0.5363869",
"0.5344736",
"0.53418... | 0.69992113 | 0 |
Return a list of persistent disks for a kubernetes cluster. Kubeconfig file determines the cluster that will be contacted. | def get_persistent_disks(k8s_ctx: str, dry_run: bool = False) -> List[str]:
cmd = f'kubectl --context={k8s_ctx} get pv -o json'
if dry_run:
logging.info(cmd)
else:
p = safe_exec(cmd)
if p.stdout:
pds = json.loads(p.stdout.decode())
return [i['spec']['csi']['vo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ceph_disk():\n disks = []\n for srv in get_srv_list():\n cfg = get_srv_config(srv)\n for key in ['osd_data', 'osd_journal', 'mds_data', 'mon_data']:\n mnt_point = cfg[key]\n disk = get_disk_by_mountpoint(find_mount_point(mnt_point))\n if disk not in disk... | [
"0.69804466",
"0.65357673",
"0.62569875",
"0.6242567",
"0.6178439",
"0.6145541",
"0.61331636",
"0.61212426",
"0.61172605",
"0.6103872",
"0.6091794",
"0.6074201",
"0.6053231",
"0.597123",
"0.5810261",
"0.57258034",
"0.5673861",
"0.56392694",
"0.5635887",
"0.55451983",
"0.55267... | 0.73454463 | 0 |
Submit kubernetes jobs using yaml files in the provided path. | def submit_jobs(k8s_ctx: str, path: pathlib.Path, dry_run=False) -> List[str]:
retval = list()
if not path.exists():
raise RuntimeError(f'Path with kubernetes jobs "{path}" does not exist')
if path.is_dir():
num_files = len(os.listdir(str(path)))
if num_files == 0 and not dry_run:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit_jobs_with_retries(k8s_ctx: str, path: pathlib.Path, dry_run=False) -> List[str]:\n return submit_jobs(k8s_ctx, path, dry_run)",
"def main():\n parser = argparse.ArgumentParser()\n parser.add_argument('--file', '-f',\n type=argparse.FileType('r'),\n ... | [
"0.6221261",
"0.5811291",
"0.5430136",
"0.54265577",
"0.53359383",
"0.52959836",
"0.5294317",
"0.52891713",
"0.52890307",
"0.5270789",
"0.52489644",
"0.52117705",
"0.5200493",
"0.5173163",
"0.5100042",
"0.5079487",
"0.5079471",
"0.5078372",
"0.5067541",
"0.50371045",
"0.50299... | 0.72203076 | 0 |
Delete all kubernetes jobs, persistent volume claims, and persistent volumes. | def delete_all(k8s_ctx: str, dry_run: bool = False) -> List[str]:
commands1 = [f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=setup',
f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=blast']
commands2 = [f'kubectl --context={k8s_ctx} delete pvc -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_jobs(self):\n jobs = self.get_jobs(self.age)\n print('Jobs queued for delete: ', jobs)\n for job in jobs:\n try: \n body = k_client.V1DeleteOptions(propagation_policy='Background')\n self.kube_v1_batch_client.delete_namespaced_job(job, body=b... | [
"0.7011506",
"0.6865935",
"0.6693092",
"0.66884226",
"0.66858184",
"0.6641274",
"0.65057886",
"0.64343244",
"0.642385",
"0.6397125",
"0.63845754",
"0.6333038",
"0.6206506",
"0.61990374",
"0.6195",
"0.6106106",
"0.61037713",
"0.60304976",
"0.60248446",
"0.6022556",
"0.59941286... | 0.75015736 | 0 |
Delete finalizers to ensure PV and PVC get deleted | def delete_finalizers(k8s_ctx: str, dry_run: bool = False):
cmd = f'kubectl --context={k8s_ctx} get pv,pvc -o=NAME'
for storage_obj in run_commands([cmd], dry_run):
cmd = f'kubectl --context={k8s_ctx} patch {storage_obj} -p '
cmd += '{"metadata":{"finalizers":null}}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finalizer():\n for resource_type in pods, pvcs, storageclasses, secrets:\n for resource in resource_type:\n resource.delete()\n resource.ocp.wait_for_delete(resource.name)\n if pools:\n # Delete only the RBD pool\n pools[0].delete()\n... | [
"0.78778726",
"0.68315476",
"0.639127",
"0.63186175",
"0.62764853",
"0.6226027",
"0.6223201",
"0.61615956",
"0.61301416",
"0.612153",
"0.6120431",
"0.6120431",
"0.6120431",
"0.6109426",
"0.6105209",
"0.60924125",
"0.60924125",
"0.60924125",
"0.6078456",
"0.6068378",
"0.606651... | 0.7561303 | 1 |
Retrieve information about PV and PVC from kubectl and log it for debugging purposes. | def inspect_storage_objects_for_debugging(k8s_ctx: str, dry_run: bool = False):
cmd = f'kubectl --context={k8s_ctx} get pv,pvc -o=NAME'
for storage_obj in run_commands([cmd], dry_run):
cmd = f'kubectl --context={k8s_ctx} describe {storage_obj}'
if dry_run:
logging... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_pv_by_pvc_name_description(namespace, k8s_cli, retries):\n pv_output = \"\"\n error_template = \"Namespace '{}': Failed to get {} resource: {{}}.\".format(namespace, \"PersistentVolumeClaim\")\n volumes_names = get_pv_names(k8s_cli, namespace, error_template)\n for volume in volumes_names:\... | [
"0.61853266",
"0.5792927",
"0.5758242",
"0.57081366",
"0.5688722",
"0.5639404",
"0.55854255",
"0.5542733",
"0.55318034",
"0.5493715",
"0.5396289",
"0.53871465",
"0.53501064",
"0.5298621",
"0.5275156",
"0.5263584",
"0.5230812",
"0.5208932",
"0.51616544",
"0.5160978",
"0.515081... | 0.6945199 | 0 |
Delete all volume snapshots associated with the kubernetes cluster | def delete_volume_snapshots(k8s_ctx: str, dry_run: bool = False):
# We are not using --force=true here to do a graceful deletion. Volume
# snapshot does not need to wait for any pod or job to be deleted and it
# is fine if deletion takes some time. --ignore-not-found defaults to true
# if --all is used.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snap_delete_all(mnode):\n cmd = \"gluster snapshot delete all --mode=script\"\n return g.run(mnode, cmd)",
"def delete_volume_snapshot(volume_snapshots):\n if type(volume_snapshots) is not list:\n volumes = [volume_snapshots]\n command = 'cinder snapshot-delete %s' % \\\n \" \... | [
"0.72916466",
"0.694778",
"0.6632236",
"0.66130334",
"0.6478083",
"0.6477406",
"0.63046324",
"0.62845635",
"0.62041503",
"0.6171982",
"0.6118543",
"0.6096079",
"0.6044555",
"0.60432434",
"0.60415065",
"0.6008003",
"0.59782016",
"0.5899641",
"0.5896192",
"0.5867627",
"0.586752... | 0.8123454 | 0 |
Return a list of kubernetes jobs | def get_jobs(k8s_ctx: str, selector: Optional[str] = None, dry_run: bool = False) -> List[str]:
cmd = 'kubectl --context={k8s_ctx} get jobs -o json'
if selector is not None:
cmd += f' -l {selector}'
if dry_run:
logging.info(cmd)
return list()
p = safe_exec(cmd)
if not p.stdo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_jobs():\n\n name_to_job_details = redis_controller.get_name_to_job_details()\n return list(name_to_job_details.values())",
"def jobs():\n result = []\n out = subprocess.check_output([\"/bin/launchctl\", \"list\"]).decode()\n for row in out.splitlines()[1:]:\n result.append(Job(row)... | [
"0.79306775",
"0.7741598",
"0.7518071",
"0.7471795",
"0.7458499",
"0.74025124",
"0.73712224",
"0.7338191",
"0.7267556",
"0.72309756",
"0.72155577",
"0.72155577",
"0.72001016",
"0.7166212",
"0.706977",
"0.70534074",
"0.7034029",
"0.7031616",
"0.70106757",
"0.69732976",
"0.6967... | 0.84486145 | 0 |
Wait for the job to return successfully or raise a TimeoutError after specified number of attempts | def _wait_for_job(k8s_ctx: str, job_file: pathlib.Path, attempts: int = 30, secs2wait: int = 60, dry_run: bool = False) -> None:
for counter in range(attempts):
if _job_succeeded(k8s_ctx, job_file, dry_run):
break
time.sleep(secs2wait)
else:
raise TimeoutError(f'{job_file} t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _wait_retry(self) -> None:\n # Sleep 2^tries + 0…tries*3 seconds between retries\n self.retry_task = asyncio.create_task(\n asyncio.sleep(2 ** min(9, self.tries) + random.randint(0, self.tries * 3))\n )\n await self.retry_task\n self.retry_task = None",
"de... | [
"0.6805994",
"0.67427564",
"0.66825926",
"0.6454168",
"0.6368625",
"0.6354731",
"0.63537157",
"0.63452667",
"0.63171816",
"0.6291563",
"0.62773556",
"0.6274619",
"0.6184791",
"0.61747164",
"0.6170765",
"0.6160677",
"0.6152056",
"0.6144066",
"0.61388767",
"0.61302525",
"0.6112... | 0.7734525 | 0 |
Checks whether the job file passed in as an argument has succeeded or not. Returns true if the job succeeded, false otherwise. If the job failed, a RuntimeError is raised. | def _job_succeeded(k8s_ctx: str, k8s_job_file: pathlib.Path, dry_run: bool = False) -> bool:
if not k8s_job_file.exists():
raise FileNotFoundError(str(k8s_job_file))
cmd = f'kubectl --context={k8s_ctx} get -f {k8s_job_file} -o json'
if dry_run:
logging.info(cmd)
return True
p ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isJobRunning ( self ):\n #cmd = \"qstat \" + str(self.jobid)\n \n #magicString='Unknown Job Id' ### magicString _might_ need to be changed if Torque version changes\n #(output, error) = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()\... | [
"0.67143625",
"0.66477233",
"0.6379032",
"0.6379032",
"0.6247778",
"0.62245816",
"0.6209879",
"0.6126895",
"0.6095487",
"0.60941005",
"0.60333455",
"0.60249513",
"0.6003191",
"0.5996906",
"0.59792376",
"0.59495425",
"0.5948564",
"0.5945208",
"0.5917747",
"0.590241",
"0.588247... | 0.6971786 | 0 |
Verify that the k8s job succeeded | def _ensure_successful_job(k8s_ctx: str, k8s_job_file: pathlib.Path, dry_run: bool = False) -> None:
if not k8s_job_file.exists():
raise FileNotFoundError(str(k8s_job_file))
cmd = f'kubectl --context={k8s_ctx} get -f {k8s_job_file} -o json'
if dry_run:
logging.info(cmd)
return
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _job_succeeded(k8s_ctx: str, k8s_job_file: pathlib.Path, dry_run: bool = False) -> bool:\n if not k8s_job_file.exists():\n raise FileNotFoundError(str(k8s_job_file))\n\n cmd = f'kubectl --context={k8s_ctx} get -f {k8s_job_file} -o json'\n\n if dry_run:\n logging.info(cmd)\n return... | [
"0.7243436",
"0.6838614",
"0.6621957",
"0.661534",
"0.6345359",
"0.6335698",
"0.6323335",
"0.6229853",
"0.62206024",
"0.61564785",
"0.6155526",
"0.6098027",
"0.6045814",
"0.6034818",
"0.6030602",
"0.60113835",
"0.6005282",
"0.59931767",
"0.5990048",
"0.59655994",
"0.59544134"... | 0.71603185 | 1 |
Check whether persistent volume snapshot is ready | def _snapshot_ready(k8s_ctx: str, k8s_spec_file: pathlib.Path, dry_run: bool = False) -> bool:
if not k8s_spec_file.exists():
raise FileNotFoundError(str(k8s_spec_file))
cmd = f'kubectl --context={k8s_ctx} get -f {k8s_spec_file} -o json'
if dry_run:
logging.info(cmd)
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapshot_volumes(self) -> bool:\n return pulumi.get(self, \"snapshot_volumes\")",
"def _IsReady(self):\n return self._GetPod()['status']['phase'] != 'Pending'",
"def _wait_until_volume_available(self, volume, maybe_in_use=False):\n ok_states = [\"creating\"] # it's ok to wait if the volum... | [
"0.6778808",
"0.6521101",
"0.63207036",
"0.6315146",
"0.6265592",
"0.622958",
"0.61976886",
"0.61875296",
"0.6180802",
"0.6176623",
"0.61693776",
"0.61398023",
"0.6051415",
"0.6027882",
"0.60233265",
"0.60011977",
"0.5982842",
"0.5962757",
"0.5861081",
"0.5847211",
"0.5834819... | 0.68950456 | 0 |
Wait for the PVC snapshot to be ready or raise a TimeoutError after specified number of attempts. | def _wait_for_snapshot(k8s_ctx: str, spec_file: pathlib.Path, attempts: int = 30, secs2wait: int = 20, dry_run: bool = False) -> None:
for counter in range(attempts):
if _snapshot_ready(k8s_ctx, spec_file, dry_run):
break
time.sleep(secs2wait)
else:
raise TimeoutError(f'{spec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_pvc(k8s_ctx: str, pvc_name: str, attempts: int = 30, secs2wait: int = 20, dry_run: bool = False) -> None:\n for counter in range(attempts):\n if _pvc_bound(k8s_ctx, pvc_name, dry_run):\n break\n time.sleep(secs2wait)\n else:\n raise TimeoutError(f'Waiting for PVC ... | [
"0.68641895",
"0.65287995",
"0.6082232",
"0.60197186",
"0.6005225",
"0.59622586",
"0.5947616",
"0.5915617",
"0.58709437",
"0.57942975",
"0.57836044",
"0.57385135",
"0.5725081",
"0.5724657",
"0.56830114",
"0.5620255",
"0.5616016",
"0.55936587",
"0.5574639",
"0.5546054",
"0.552... | 0.76268655 | 0 |
Check whether a persistent volume claim is bound to a kubernetes node | def _pvc_bound(k8s_ctx: str, pvc_name: str, dry_run: bool = False) -> bool:
cmd = f'kubectl --context={k8s_ctx} get pvc {pvc_name} -o json'
if dry_run:
logging.info(cmd)
return True
p = safe_exec(cmd)
if not p.stdout:
return False
json_output = json.loads(p.stdout.decode(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_booted_from_volume(self, instance, disk_mapping=None):\n return not bool(instance.get('image_ref'))",
"def can_handle(self, rsm_ctx):\n return rsm_ctx.instance.type == NODE_TYPE_QUOTA",
"def can_reach_metadata_server():\n try:\n http_client = _obtain_http_client(hostname=_METADA... | [
"0.57044387",
"0.55365884",
"0.551062",
"0.54884076",
"0.5434074",
"0.54069275",
"0.5402176",
"0.5394375",
"0.53685576",
"0.5321871",
"0.5291866",
"0.5244603",
"0.52340746",
"0.52208585",
"0.52021044",
"0.5195634",
"0.5176338",
"0.5152459",
"0.50973433",
"0.50880367",
"0.5085... | 0.63240516 | 0 |
Wait for the persistent volume claim to be bound to an instance. A bound PVC means that a persistent disk has been created. | def wait_for_pvc(k8s_ctx: str, pvc_name: str, attempts: int = 30, secs2wait: int = 20, dry_run: bool = False) -> None:
for counter in range(attempts):
if _pvc_bound(k8s_ctx, pvc_name, dry_run):
break
time.sleep(secs2wait)
else:
raise TimeoutError(f'Waiting for PVC {pvc_name} ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wait_until_volume_available(self, volume, maybe_in_use=False):\n ok_states = [\"creating\"] # it's ok to wait if the volume is in this\n tries = 0\n if maybe_in_use:\n ok_states.append(\"in_use\")\n logger.info(\"Volume: %s is in state: %s\", volume.name, volume.state)\... | [
"0.5896992",
"0.5781035",
"0.5712666",
"0.56834656",
"0.56729543",
"0.56464386",
"0.5645018",
"0.5619778",
"0.55979586",
"0.55502456",
"0.53824466",
"0.5378539",
"0.5355347",
"0.5350618",
"0.53472906",
"0.5329603",
"0.53034407",
"0.5259739",
"0.5248038",
"0.5234132",
"0.52156... | 0.630798 | 0 |
Initialize storage for ElasticBLAST cluster | def initialize_storage(cfg: ElasticBlastConfig, query_files: List[str] = [], wait=ElbExecutionMode.WAIT) -> None:
use_local_ssd = cfg.cluster.use_local_ssd
if use_local_ssd:
initialize_local_ssd(cfg, query_files, wait)
else:
initialize_persistent_disk(cfg, query_files, wait) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_beeswax_db(cls):\n global _INITIALIZED\n if _INITIALIZED:\n return\n\n make_query(cls.client, 'CREATE DATABASE IF NOT EXISTS %(db)s' % {'db': cls.db_name}, wait=True)\n make_query(cls.client, 'CREATE DATABASE IF NOT EXISTS %(db)s_other' % {'db': cls.db_name}, wait=True)\n\n if cls.load... | [
"0.61822534",
"0.61604846",
"0.61142486",
"0.61103785",
"0.6019239",
"0.600666",
"0.59842885",
"0.59343857",
"0.57664347",
"0.5744994",
"0.57356334",
"0.5724775",
"0.57101536",
"0.57081795",
"0.5696668",
"0.56931335",
"0.5670077",
"0.56564623",
"0.5631872",
"0.5608877",
"0.56... | 0.74047345 | 0 |
Initialize Persistent Disk for ElasticBLAST execution | def initialize_persistent_disk(cfg: ElasticBlastConfig, query_files: List[str] = [], wait=ElbExecutionMode.WAIT) -> None:
# ${LOGDATETIME} setup_pd start >>${ELB_LOGFILE}
db, db_path, _ = get_blastdb_info(cfg.blast.db,
cfg.gcp.get_project_for_gcs_downloads())
if not db... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_storage(cfg: ElasticBlastConfig, query_files: List[str] = [], wait=ElbExecutionMode.WAIT) -> None:\n use_local_ssd = cfg.cluster.use_local_ssd\n if use_local_ssd:\n initialize_local_ssd(cfg, query_files, wait)\n else:\n initialize_persistent_disk(cfg, query_files, wait)",
"d... | [
"0.69325453",
"0.6751443",
"0.6751443",
"0.6653742",
"0.6350506",
"0.63132924",
"0.5965553",
"0.5893428",
"0.588529",
"0.58253783",
"0.58102304",
"0.5791366",
"0.57175225",
"0.5694924",
"0.5682932",
"0.56052977",
"0.5575009",
"0.5567323",
"0.5530617",
"0.54932505",
"0.5454839... | 0.71941566 | 0 |
Label disk with given claim with standard labels | def label_persistent_disk(cfg: ElasticBlastConfig, pv_claim: str) -> None:
use_local_ssd = cfg.cluster.use_local_ssd
if use_local_ssd:
return
dry_run = cfg.cluster.dry_run
cluster_name = cfg.cluster.name
labels = cfg.cluster.labels
get_pv_cmd = f'kubectl --context={cfg.appstate.k8s_ctx}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_base_image_labels(driver, user_disk, img_name, branch, target):\n\n dashes = [i for i, c in enumerate(img_name) if c=='-']\n cf_version = img_name[dashes[0]+1:dashes[3]]\n build_id = img_name[dashes[-1]+1:]\n\n driver.ex_set_volume_labels(user_disk,\n {'cf_version': cf_version, 'branch':... | [
"0.5758011",
"0.56702936",
"0.5651301",
"0.54146427",
"0.5399197",
"0.53988075",
"0.5323684",
"0.52344555",
"0.5222524",
"0.52210075",
"0.51896286",
"0.51797324",
"0.515616",
"0.51407397",
"0.5139695",
"0.51392925",
"0.5135739",
"0.5114927",
"0.50736207",
"0.50625324",
"0.505... | 0.6934975 | 0 |
Creates a k8s job to submit BLAST jobs | def submit_job_submission_job(cfg: ElasticBlastConfig):
dry_run = cfg.cluster.dry_run
subs = {
'K8S_JOB_SUBMIT_JOBS' : K8S_JOB_SUBMIT_JOBS,
'ELB_DOCKER_IMAGE' : ELB_CJS_DOCKER_IMAGE_GCP,
'ELB_GCP_PROJECT' : cfg.gcp.project,
'ELB_GCP_ZONE' : cfg.gcp.zone,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_job(api_instance, job):\n api_response = api_instance.create_namespaced_job(\n body=job, namespace=\"default\", pretty=True\n )\n logger.info(\"Job created with status='%s'\" % str(api_response.status))\n return api_response",
"def _create_job(self,\n name,\n ... | [
"0.65601635",
"0.6456106",
"0.64101607",
"0.62889904",
"0.60392916",
"0.5989142",
"0.59834176",
"0.59480613",
"0.59373564",
"0.5935629",
"0.5929065",
"0.58854586",
"0.58693117",
"0.5855808",
"0.5849256",
"0.579629",
"0.5764425",
"0.5734367",
"0.5733252",
"0.5725296",
"0.57196... | 0.67617774 | 0 |
Create a new product for the scenario It would be deleted at the tearDown | def setUp(self):
super().setUp()
list_of_product_types = [
'default_product_variant',
'multiple_product_variants',
'ceo_title'
]
self.new_product = eval(f"get_new_product_with_" \
f"{list_of_product_types[randint(0, len(list_of_product_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_01_product_create(self):\n # Create new product with a replacement product\n product = self.create_product()\n\n # Check recently was created product with default 'In Development'\n # value state and that the replacement was assigned. This case also\n # check the read te... | [
"0.7601618",
"0.752833",
"0.7353155",
"0.72841406",
"0.7263181",
"0.7074391",
"0.7024802",
"0.699035",
"0.69720995",
"0.69443333",
"0.6904304",
"0.684024",
"0.6830409",
"0.6829515",
"0.68056715",
"0.68019325",
"0.6705739",
"0.6702876",
"0.66581947",
"0.6651187",
"0.66456455",... | 0.75885576 | 1 |
in addition to default tearDown delete new product that was created in setUp | def tearDown(self):
ProcessRequest(f"products/{self.product_id}.json").send_request(
'DELETE', continue_on_error=True)
super().tearDown() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDownClass(self):\n self.product_id = None",
"def tearDown(self):\n del self.new",
"def tearDown(self):\n util.delete_mocks()",
"def tearDown(self):\n util.delete_mocks()",
"def tearDown(self):\n util.delete_mocks()",
"def tearDown(self):\n util.delete_moc... | [
"0.7673542",
"0.76476455",
"0.7402727",
"0.7402727",
"0.7402727",
"0.7402727",
"0.7402727",
"0.7402727",
"0.7268774",
"0.7223385",
"0.72121155",
"0.7198862",
"0.7184747",
"0.7164011",
"0.7163723",
"0.7111245",
"0.71104",
"0.71104",
"0.71104",
"0.70951384",
"0.7086183",
"0.7... | 0.7786658 | 0 |
This function performs an histogram equalization of a given image | def histogram_equalize(im_orig):
color_flag = False
image = im_orig
if len(im_orig.shape) == 3: #RGB image
color_flag = True
y_im = rgb2yiq(im_orig)
image = y_im[:, :, 0]
image *= NORMALIZE
hist_orig, bins = np.histogram(image, range(BINS))
hist_cum = np.cumsum(hist_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equalise_hist(image, bin_count=256):\n # TODO: your histogram equalization code\n #define arrays\n image = img_as_ubyte(image)\n row,col = image.shape\n new_image = np.zeros((row,col),dtype='uint8') \n\n # compute the value of each grayscale,and save in image_hist \n image_hist = np.bincount(image.flatt... | [
"0.81590986",
"0.8098537",
"0.8089895",
"0.79471034",
"0.7874277",
"0.7826743",
"0.7749235",
"0.769595",
"0.76528543",
"0.7423789",
"0.7374871",
"0.7359829",
"0.735687",
"0.7356559",
"0.73502856",
"0.73391485",
"0.7225304",
"0.722211",
"0.72127074",
"0.7191898",
"0.7184982",
... | 0.81297153 | 1 |
Determines if natural number N is prime by trial division. | def trial_div(n: int) -> bool:
if n == 1:
return False
i = 2
while i**2 <= n:
if n % i == 0:
return False
i += 1
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def prime_t(n: int) -> bool:\n tests = set(range(2, int(math.sqrt(n) + 1)))\n non_factors = set(takewhile(lambda i: n % i != 0, tests))\n return tests == non_factors",
"def prime_t(n: int) -> bool:\n tests = set(range(2, int(math.sqrt(n) + 1)))\n non_fa... | [
"0.75904524",
"0.7572783",
"0.7572783",
"0.7533633",
"0.75022924",
"0.74241966",
"0.73947245",
"0.73647577",
"0.73487324",
"0.7345413",
"0.7342212",
"0.72686034",
"0.7251062",
"0.72339666",
"0.7232719",
"0.72271216",
"0.72271216",
"0.7186987",
"0.71865153",
"0.7166788",
"0.71... | 0.7699925 | 0 |
Generates the LucasLehmer sequence. | def lucas_lehmer() -> Generator[int, None, None]:
seed = 4
while True:
yield seed
seed = seed**2 - 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Lucas(input) :\n\n # if input == 0 :\n\n # return 2\n # elif input == 1 :\n\n # return 1\n\n # else :\n\n # return Lucas(input-1) + Lucas(input-2)\n\n\n return sum_series(input,2,1)",
"def generate_random_MT_Lune_samp():\n # 1. Get randomly varied Lune parameters (g... | [
"0.5769175",
"0.57630914",
"0.5601627",
"0.55063254",
"0.5457792",
"0.54477936",
"0.53614664",
"0.5287758",
"0.5262873",
"0.52039135",
"0.5178368",
"0.51434594",
"0.5132669",
"0.51296896",
"0.508006",
"0.50615644",
"0.50557595",
"0.50262654",
"0.5007828",
"0.5002165",
"0.4987... | 0.68218356 | 0 |
Determines if Mersenne number 2^N 1 is prime via the LucasLehmer primality test. | def ll_primality(n: int) -> bool:
if n <= 2 or not trial_div(n):
return False
luc_leh = lucas_lehmer()
for _ in range(n - 1):
ll = next(luc_leh)
return ll % (2**n - 1) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n return mr_prime(n)",
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n=936):\n if n < 3: return False\n for i in range(2, n):\n if n % i == 0:\n return False\n ... | [
"0.7239062",
"0.7073942",
"0.7019739",
"0.70070904",
"0.7005515",
"0.6946308",
"0.6864864",
"0.68361056",
"0.678722",
"0.6734504",
"0.6730105",
"0.6687569",
"0.66823626",
"0.667622",
"0.6668467",
"0.6650945",
"0.6643008",
"0.6626922",
"0.661976",
"0.66106534",
"0.6610468",
... | 0.7341868 | 0 |
Converts a NumPy image to a tf.Summary.Value object. | def image_to_tf_summary_value(image, tag):
curr_image = np.asarray(image, dtype=np.uint8)
height, width, n_channels = curr_image.shape
# If monochrome image, then reshape to [height, width]
if n_channels == 1:
curr_image = np.reshape(curr_image, [height, width])
s = io.BytesIO()
matplotlib_pyplot().imsa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_to_image_summary(array, format=\"png\"):\n height, width, channels = array.shape\n image = Image.fromarray(array)\n\n with io.BytesIO() as memf:\n image.save(memf, format=format)\n image_string = memf.getvalue()\n return tf.Summary.Image(\n height=height,\n width=w... | [
"0.6867479",
"0.65719885",
"0.64364594",
"0.6324988",
"0.6231608",
"0.6231608",
"0.6148279",
"0.6141953",
"0.6138373",
"0.61298656",
"0.6080713",
"0.6017898",
"0.60149074",
"0.60149074",
"0.60149074",
"0.60122037",
"0.59977126",
"0.5987593",
"0.59382886",
"0.5902842",
"0.5889... | 0.8311787 | 0 |
Optionally converts images from hooks_args to image summaries. | def convert_predictions_to_image_summaries(hook_args):
decode_hparams = hook_args.decode_hparams
if not decode_hparams.display_decoded_images:
return []
predictions = hook_args.predictions[0]
# Display ten random inputs and outputs so that tensorboard does not hang.
all_summaries = []
rand_predictions ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_stage(self, images):\n\n for i, image in enumerate(images):\n pass\n # logging_tags = logs.image_config_to_tags(image, self.group_by_keywords)",
"def multi_run_wrapper(args):\n\treturn img_preprocessing(*args)",
"def __call__(self, images, targets):\n pass",
"def pr... | [
"0.57442975",
"0.57011163",
"0.5521036",
"0.53856045",
"0.5378818",
"0.5378818",
"0.5353799",
"0.531765",
"0.52791244",
"0.52719086",
"0.5230224",
"0.52281237",
"0.52281237",
"0.5207086",
"0.5201962",
"0.5174777",
"0.51720655",
"0.51613",
"0.5155435",
"0.51528734",
"0.5152154... | 0.69051784 | 0 |
Generator for images that takes image and labels lists and creates pngs. | def image_generator(images, labels):
if not images:
raise ValueError("Must provide some images for the generator.")
width, height, _ = images[0].shape
for (enc_image, label) in zip(encode_images_as_png(images), labels):
yield {
"image/encoded": [enc_image],
"image/format": ["png"],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_generator(img_list):\n while True:\n img = random.choice(img_list)\n label = os.path.basename(os.path.dirname(img)) # add label function according to the dataset tree\n img = preprocess_image(img)\n yield img, label",
"def batch(img_path, gt_path,img_list, batch, total_s... | [
"0.8013157",
"0.7169892",
"0.71564656",
"0.702399",
"0.68695503",
"0.6713235",
"0.6668822",
"0.66558856",
"0.6632258",
"0.65799594",
"0.65589684",
"0.6515779",
"0.65155697",
"0.65101016",
"0.64978045",
"0.6496326",
"0.64884",
"0.6485673",
"0.64815027",
"0.6465144",
"0.6454243... | 0.80332494 | 0 |
Creates an empty AsDes. | def __init__(self, *args):
_BRepAlgo.BRepAlgo_AsDes_swiginit(self,_BRepAlgo.new_BRepAlgo_AsDes(*args)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_empty_trace(self):\n self.data = np.zeros(0, dtype=np.float32)\n self.header = SEGYTraceHeader(header=None, endian=self.endian)",
"def _create_empty_segy_file_object(self):\n self.textual_file_header = b''\n self.binary_file_header = None\n self.traces = []",
"def... | [
"0.5758801",
"0.5586419",
"0.5519884",
"0.5494886",
"0.5454309",
"0.54006606",
"0.53879",
"0.5323445",
"0.52917165",
"0.528022",
"0.5211821",
"0.51626563",
"0.5152615",
"0.51504207",
"0.51392835",
"0.5120089",
"0.5102294",
"0.5096787",
"0.5087933",
"0.5048822",
"0.5039879",
... | 0.5758028 | 1 |
Returns True if (S1> and has common Descendants. Stores in the Commons Descendants. | def HasCommonDescendant(self, *args):
return _BRepAlgo.BRepAlgo_AsDes_HasCommonDescendant(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isAllIncluded(S1, S2):\n return False if len(set(S1).intersection(S2)) != len(set(S1)) else True",
"def is_found_in_parents(mcs, name, parents):\n for parent in parents:\n\n for cls in reversed(parent.__mro__):\n\n if hasattr(cls, name):\n return True\n\... | [
"0.58216304",
"0.57693666",
"0.56457704",
"0.54126",
"0.53150624",
"0.53035873",
"0.5301044",
"0.5265569",
"0.5263396",
"0.5238863",
"0.52369124",
"0.5216553",
"0.5201471",
"0.51886964",
"0.5182887",
"0.5174848",
"0.5164969",
"0.5162364",
"0.5154515",
"0.5146251",
"0.5138688"... | 0.5984507 | 0 |
Returns the first shape involved in this Boolean operation. | def Shape1(self, *args):
return _BRepAlgo.BRepAlgo_BooleanOperation_Shape1(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ShapeFrom(self, *args):\n return _BRepAlgo.BRepAlgo_BooleanOperations_ShapeFrom(self, *args)",
"def shape(self):\n return self.active.shape",
"def Shape(self, *args):\n return _BRepAlgo.BRepAlgo_BooleanOperations_Shape(self, *args)",
"def get_output_shape(self):\n return self.... | [
"0.69976586",
"0.67969745",
"0.6770878",
"0.6766901",
"0.6766901",
"0.6725859",
"0.67074716",
"0.67057925",
"0.66768235",
"0.6671902",
"0.6587406",
"0.6587406",
"0.65293986",
"0.65240335",
"0.64601064",
"0.6452454",
"0.6452454",
"0.6452454",
"0.64200085",
"0.6357087",
"0.6352... | 0.6905269 | 1 |
Returns the second shape involved in this Boolean operation. | def Shape2(self, *args):
return _BRepAlgo.BRepAlgo_BooleanOperation_Shape2(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ShapeFrom(self, *args):\n return _BRepAlgo.BRepAlgo_BooleanOperations_ShapeFrom(self, *args)",
"def Shape(self, *args):\n return _BRepAlgo.BRepAlgo_BooleanOperations_Shape(self, *args)",
"def Shape1(self, *args):\n return _BRepAlgo.BRepAlgo_BooleanOperation_Shape1(self, *args)",
"def... | [
"0.7164068",
"0.70292205",
"0.696538",
"0.6760701",
"0.6375149",
"0.6258295",
"0.6258295",
"0.6172665",
"0.61283445",
"0.6042824",
"0.60409766",
"0.60409766",
"0.60409766",
"0.60370505",
"0.6007792",
"0.6001082",
"0.5968415",
"0.59486276",
"0.59486276",
"0.5940918",
"0.588824... | 0.7778657 | 0 |
returns compounds of Edge connected with section, which contains sections between faces contained in S1 and S2. returns an empty list of Shape if S1 or S2 do not contain face. calls GetSectionEdgeSet() if it has not already been done | def GetSectionEdgeSet(self, *args):
return _BRepAlgo.BRepAlgo_DSAccess_GetSectionEdgeSet(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shared_edges(self, face_selector1: _face_selector_types,\n face_selector2: _face_selector_types) -> Sequence[Edge]:\n other_faces = self.find_faces(face_selector2)\n\n result_edges = []\n for face in self.find_faces(face_selector1):\n for edge in face.edges:\... | [
"0.6410287",
"0.55884326",
"0.55351377",
"0.5522345",
"0.55068785",
"0.5343045",
"0.5311352",
"0.53073007",
"0.5303514",
"0.5291458",
"0.52785116",
"0.52631366",
"0.52371",
"0.5231882",
"0.5201273",
"0.51927465",
"0.51717657",
"0.5161595",
"0.512026",
"0.51042163",
"0.5084441... | 0.56942534 | 1 |
GetValue(BRepAlgo_DataMapNodeOfDataMapOfShapeBoolean self) > Standard_Boolean | def GetValue(self):
return _BRepAlgo.BRepAlgo_DataMapNodeOfDataMapOfShapeBoolean_GetValue(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __bool__(self):\n return bool(self.get_value())",
"def __bool__(self):\n raise RuntimeError(\"Cannot evaluate CrypTensors to boolean values\")",
"def __bool__(self):\n raise RuntimeError(\"Cannot evaluate BinarySharedTensors to boolean values\")",
"def SetValue(self, *args):\n ... | [
"0.6632537",
"0.65650076",
"0.6527329",
"0.64361316",
"0.6419467",
"0.6400087",
"0.6373707",
"0.637024",
"0.6366055",
"0.63470244",
"0.6285019",
"0.62832886",
"0.62286204",
"0.62076914",
"0.62011594",
"0.6153996",
"0.6111137",
"0.6075253",
"0.60686135",
"0.60634077",
"0.60227... | 0.7905299 | 0 |
SetValue(BRepAlgo_DataMapNodeOfDataMapOfShapeBoolean self, Standard_Boolean value) | def SetValue(self, *args):
return _BRepAlgo.BRepAlgo_DataMapNodeOfDataMapOfShapeBoolean_SetValue(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetValue(self):\n return _BRepAlgo.BRepAlgo_DataMapNodeOfDataMapOfShapeBoolean_GetValue(self)",
"def test_setitem_bool(self):\n random.seed(12345)\n nside_coverage = 32\n nside_map = 128\n pxnums = np.arange(0, 2000)\n pxvalues = np.ones(pxnums.size, dtype=bool)\n ... | [
"0.74341255",
"0.67324233",
"0.668604",
"0.63878953",
"0.63041806",
"0.63035727",
"0.62389475",
"0.62142",
"0.619102",
"0.61905813",
"0.6144637",
"0.60952264",
"0.6080537",
"0.6070081",
"0.60686034",
"0.59739524",
"0.59568506",
"0.59503865",
"0.59209836",
"0.5920271",
"0.5913... | 0.8526055 | 0 |
NYI returns true if W is a Wire standard. W must belong to the list returned by MakeBlock. | def IsWire(self, *args):
return _BRepAlgo.BRepAlgo_EdgeConnector_IsWire(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isWatt(self):\n return _libsbml.Unit_isWatt(self)",
"def test_wireable_object(self):\n result = attributeAsLDIF(\"dn\", WireableObject())\n self.assertEqual(result, b\"dn: wire\\n\")",
"def wwn(self) -> SmartSsdWwn:\n return self._wwn",
"def CanBalanceWithWater(self):\n ... | [
"0.5597362",
"0.55873543",
"0.5548783",
"0.55013156",
"0.54576916",
"0.53746676",
"0.5354919",
"0.5347618",
"0.52789843",
"0.5266089",
"0.51734984",
"0.51449096",
"0.513721",
"0.50930214",
"0.50891733",
"0.5074785",
"0.5068847",
"0.50615853",
"0.5049344",
"0.50426847",
"0.504... | 0.6148025 | 0 |
Remove to set of images. | def Remove(self, *args):
return _BRepAlgo.BRepAlgo_Image_Remove(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_images(self):\n hardware_components.log_method(self, \"remove_images\")\n communication_object = self._get_control_software().connection\n communication_object.remove_all()",
"def remove(self, done=False, verbose=True):\n return _image.image_remove(self, done, verbose)",
... | [
"0.75192356",
"0.73298836",
"0.7317633",
"0.72680634",
"0.70345575",
"0.70180535",
"0.6974491",
"0.694794",
"0.6942505",
"0.6920568",
"0.6883206",
"0.6673236",
"0.6662014",
"0.66038215",
"0.66038215",
"0.66038215",
"0.65617543",
"0.6498469",
"0.6489149",
"0.64788216",
"0.6478... | 0.7645537 | 0 |
Add as const edge, E can be in the result. | def AddConstEdge(self, *args):
return _BRepAlgo.BRepAlgo_Loop_AddConstEdge(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addEdge(self, e):\n v = e.either()\n w = e.other(v)\n self._validateVertex(v)\n self._validateVertex(w)\n self._adj[v].add(e)\n self._adj[w].add(e)\n self._E += 1",
"def add_edge(self, e):\n a, b = e\n self[a][b] = e\n self[b][a] = e",
"def add_edge(self, e):\n ... | [
"0.7211913",
"0.6675955",
"0.667085",
"0.6334199",
"0.62683904",
"0.6137948",
"0.6120605",
"0.6069564",
"0.60568464",
"0.6040104",
"0.60051143",
"0.5988388",
"0.59750146",
"0.5960292",
"0.5952103",
"0.5939984",
"0.5931788",
"0.5870777",
"0.58619887",
"0.5810366",
"0.579694",
... | 0.6939654 | 1 |
Add as a set of const edges. | def AddConstEdges(self, *args):
return _BRepAlgo.BRepAlgo_Loop_AddConstEdges(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddConstEdge(self, *args):\n return _BRepAlgo.BRepAlgo_Loop_AddConstEdge(self, *args)",
"def addEdges(self, edges):\n for edge in edges:\n self.addEdge(edge[0], edge[1], edge[2])",
"def add_all_edges(self):\n for n1 in self.vertices():\n for n2 in self.vertices():\n ... | [
"0.7046306",
"0.64266396",
"0.63983893",
"0.6357126",
"0.6321411",
"0.62738585",
"0.6187922",
"0.60680056",
"0.59887",
"0.5985752",
"0.597097",
"0.5963551",
"0.596135",
"0.59137535",
"0.58819777",
"0.5788639",
"0.5775192",
"0.5719451",
"0.56963676",
"0.5694593",
"0.56856745",... | 0.7485751 | 0 |
Cut the edge in several edges on the vertices. | def CutEdge(self, *args):
return _BRepAlgo.BRepAlgo_Loop_CutEdge(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cut_edge_based_on_other_edge(bm, edge, other_edge, cut_direction):\n new_edges = []\n new_verts = []\n target_faces = []\n for v in edge.verts:\n split_point = v.co + cut_direction\n e, new_vert = split_edge_at_point_from_closest_vert(other_edge, v, split_point)\n e = bmesh.ops... | [
"0.62837875",
"0.6094797",
"0.6000174",
"0.59297794",
"0.59142405",
"0.5832908",
"0.5784323",
"0.5767214",
"0.57564753",
"0.57304054",
"0.57289046",
"0.5636046",
"0.5623915",
"0.5606259",
"0.55841815",
"0.55755126",
"0.55632216",
"0.5559399",
"0.5559359",
"0.55513865",
"0.551... | 0.7193409 | 0 |
Sets the maximum distance between target shape and shape to project. If this condition is not satisfied then corresponding part of solution is discarded. if MaxDist < 0 then this method does not affect the algorithm | def SetMaxDistance(self, *args):
return _BRepAlgo.BRepAlgo_NormalProjection_SetMaxDistance(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetMaxTolerance(self, *args):\n return _ShapeUpgrade.ShapeUpgrade_ShapeDivide_SetMaxTolerance(self, *args)",
"def SetMaxTolerance(self, *args):\n return _ShapeUpgrade.ShapeUpgrade_Tool_SetMaxTolerance(self, *args)",
"def target_mode(self):\r\n if not self.in_target_mode:\r\n ... | [
"0.5773515",
"0.55397105",
"0.537085",
"0.53070605",
"0.5186212",
"0.5132834",
"0.51288295",
"0.5102438",
"0.50803",
"0.503841",
"0.49928033",
"0.4985218",
"0.4962091",
"0.49406153",
"0.49362886",
"0.4915126",
"0.4903148",
"0.4903148",
"0.48885536",
"0.4883879",
"0.48513916",... | 0.63957596 | 0 |
Define options for the computation of further intersections which will be performed by the function Build in this framework. By default, no parametric 2D curve (pcurve) is defined for the elementary edges of the result. If ComputePCurve1 equals true, further computations performed in this framework with the function Bu... | def ComputePCurveOn2(self, *args):
return _BRepAlgo.BRepAlgo_Section_ComputePCurveOn2(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ComputePCurveOn1(self, *args):\n return _BRepAlgo.BRepAlgo_Section_ComputePCurveOn1(self, *args)",
"def PricingAddCurves(builder, curves):\n return AddCurves(builder, curves)",
"def TransformPCurve(self, *args):\n return _ShapeBuild.ShapeBuild_Edge_TransformPCurve(self, *args)",
"def cur... | [
"0.63747",
"0.6279916",
"0.5839161",
"0.5615367",
"0.5537828",
"0.5535059",
"0.54384214",
"0.53751516",
"0.53667706",
"0.5359382",
"0.52979684",
"0.52934253",
"0.5215703",
"0.5175247",
"0.5162741",
"0.5156271",
"0.51324844",
"0.51028144",
"0.5075227",
"0.5058656",
"0.50237304... | 0.6815839 | 0 |
Make the variable for the problem. Use the function self.new_cnf_code(step, name, object) to make whatever codes for CNF variables you need to make your control knowledge for the Logistics problem. You can make variables which mean anything if you can think of constraints to make that enforce that meaning. As an exampl... | def make_control_knowledge_variables(self, horizon):
# You might want to save your variables here, or feel free to make as
# many data structures as you need to keep track of them.
self.control_fluent_codes = {}
""" *** YOUR CODE HERE *** """
# DID NOT DEFINE ANY EXTRA VARIABL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.name = ''\n self.variables = []\n self.assumptions = []\n self.guarantees = []",
"def variabilize(self):\n if self.nvars>=0:\n pass #already done\n else:\n varTab = syt.SymbolTable()\n def convertArgs(args):\n ... | [
"0.56510055",
"0.5419212",
"0.5407943",
"0.52857524",
"0.52654815",
"0.52528906",
"0.52507615",
"0.5224148",
"0.51912344",
"0.5181718",
"0.51804876",
"0.51642627",
"0.51620805",
"0.513914",
"0.5131809",
"0.5116504",
"0.5077894",
"0.50545853",
"0.5040229",
"0.5036804",
"0.5015... | 0.62422013 | 0 |
Make an encoding of self.problem for the given horizon. For this encoding, we have broken this method up into a number of submethods that you need to implement. (LogisticsEncoding, int, str, str) > None | def encode(self, horizon, exec_semantics, plangraph_constraints):
super().encode(horizon, exec_semantics, plangraph_constraints)
self.make_control_knowledge_variables(horizon)
self.make_control_knowledge(horizon) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encoder(ne, nj):\n #contrainte sup les equipes ne peuvent pas s'affronter elles-meme\n contrainte = ''\n for e in range(ne):\n for j in range(nj):\n contrainte += str(-codage(ne,nj,j,e,e))+' 0\\n'\n return contrainte+encoderC1(ne, nj) +'\\n'+ encoderC2(ne, nj)+'\\n'+ \\\n ... | [
"0.49800134",
"0.49576762",
"0.49297398",
"0.48456433",
"0.48439774",
"0.47990614",
"0.4773234",
"0.4755465",
"0.46668708",
"0.46619892",
"0.4660449",
"0.463804",
"0.46357062",
"0.46022564",
"0.45864835",
"0.45528847",
"0.4546904",
"0.45393407",
"0.45337522",
"0.4525348",
"0.... | 0.5831212 | 0 |
Tail the stdout of the process and remember it. Stores the lines of output produced by the process in self.logs and signals that a new line was read so that it can be picked up by consumers. | def tail(self):
for line in iter(self.proc.stdout.readline, ''):
if len(line) == 0:
break
if self.log_filter(line.decode('ASCII')):
continue
if self.verbose:
logging.debug(f"{self.prefix}: {line.decode().rstrip()}")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stdout_reader(self):\n self._is_launched.wait()\n stdout_iterator = iter(self._popen.stdout.readline, b\"\")\n for line in stdout_iterator:\n self._log(\"raw\", \"stdout : {0}\".format(line.strip()))\n self.stdout_queue.put_nowait(line.strip())\n self.stdout_q... | [
"0.7018636",
"0.68938357",
"0.64648557",
"0.63040227",
"0.61803836",
"0.611249",
"0.6055522",
"0.6042259",
"0.60367477",
"0.59178376",
"0.589845",
"0.58607674",
"0.5854063",
"0.577992",
"0.5725091",
"0.56646895",
"0.56633466",
"0.56391853",
"0.5608646",
"0.5590531",
"0.555853... | 0.8187086 | 0 |
Look for `regex` in the logs. | def is_in_log(self, regex, start=0):
ex = re.compile(regex)
for l in self.logs[start:]:
if ex.search(l):
logging.debug("Found '%s' in logs", regex)
return l
logging.debug("Did not find '%s' in logs", regex)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matchLogAgainstRegex(self, log):\n\n matchedString = ''\n\n if not log:\n # no log provided\n raise ValueError('no log provided')\n\n # try regex matching\n regexMatches = self.compiledRegex.findall(log)\n\n # get specified match based on idx num\n ... | [
"0.6812222",
"0.6396781",
"0.6323904",
"0.6270402",
"0.6225342",
"0.61722404",
"0.60080373",
"0.5975386",
"0.5958538",
"0.5957004",
"0.5957004",
"0.5954759",
"0.5909928",
"0.5905066",
"0.59044474",
"0.58903766",
"0.5873692",
"0.58668035",
"0.5854508",
"0.58435524",
"0.581534"... | 0.68955874 | 0 |
Look for `regexs` in the logs. We tail the stdout of the process and look for each regex in `regexs`, starting from last of the previous waitedfor log entries (if any). We fail if the timeout is exceeded or if the underlying process exits before all the `regexs` were found. If timeout is None, no timeout is applied. | def wait_for_logs(self, regexs, timeout=TIMEOUT):
logging.debug("Waiting for {} in the logs".format(regexs))
exs = [re.compile(r) for r in regexs]
start_time = time.time()
pos = self.logsearch_start
while True:
if timeout is not None and time.time() > start_time + t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_log(self, regex, timeout=TIMEOUT):\n return self.wait_for_logs([regex], timeout)",
"def extract_values(self):\n log_unmatched = []\n stdout_unmatched = []\n stderr_unmatched = []\n result = True\n\n regex_sources = []\n if self.logpath and self.cfg.lo... | [
"0.6554087",
"0.5195102",
"0.51535976",
"0.51490176",
"0.5125376",
"0.50308865",
"0.49729815",
"0.4920727",
"0.4881864",
"0.48079687",
"0.47824997",
"0.47792268",
"0.4773751",
"0.4764229",
"0.47570693",
"0.4744247",
"0.47347224",
"0.471532",
"0.46489775",
"0.4641251",
"0.4617... | 0.74728626 | 0 |
Reorganize chain by creating a fork at height=[height] and remine all mempool transactions into [height + shift], where shift >= 0. Returns hashes of generated blocks. Note that tx's that become invalid at [height] (because coin maturity, locktime etc.) are removed from mempool. The length of the new chain will be orig... | def simple_reorg(self, height, shift=0):
hashes = []
fee_delta = 1000000
orig_len = self.rpc.getblockcount()
old_hash = self.rpc.getblockhash(height)
if height + shift > orig_len:
final_len = height + shift
else:
final_len = 1 + orig_len
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mine_reorg(self, length):\n\n # make sure all invalidated blocks are node0's\n self.generatetoaddress(self.nodes[0], length, self.nodes[0].get_deterministic_priv_key().address)\n for x in self.nodes[0].p2ps:\n x.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 1... | [
"0.64595574",
"0.58120793",
"0.56435055",
"0.561937",
"0.56143004",
"0.5595991",
"0.54888064",
"0.5484174",
"0.5313484",
"0.5154968",
"0.5067081",
"0.5065475",
"0.50483334",
"0.5036218",
"0.50244987",
"0.4982427",
"0.49731052",
"0.49571624",
"0.49556592",
"0.4946499",
"0.4944... | 0.794877 | 0 |
Deploy a revault setup with {n_stakeholders} stakeholders, {n_managers} managers and optionally fund it with {funding} sats. | def deploy(self, n_stakeholders, n_managers, funding=None, csv=None):
(conf_stk, conf_man) = get_participants(n_stakeholders, n_managers)
if csv is None:
# More than 6 months
csv = random.randint(1, 26784)
stk_nodes = []
for i in range(len(conf_stk)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(token_addr: str, box_addr: str) -> None:\n print(f\"\\nSetting up Contracts....\")\n tokenContract = pytezos.contract(token_addr)\n print(f\"-- Performing Initial Mint to Admin : {pub_key_hash}\")\n tokenContract.initialMint(None).inject(_async=False)\n print(\"-- Funding Fishcake Box Cont... | [
"0.5813184",
"0.5735331",
"0.56949604",
"0.5574248",
"0.55136925",
"0.54119915",
"0.5382259",
"0.5361257",
"0.5349573",
"0.5346696",
"0.5290507",
"0.5271076",
"0.52404386",
"0.52240694",
"0.52200854",
"0.5217702",
"0.5209116",
"0.5172304",
"0.5167198",
"0.5145933",
"0.5142364... | 0.76175135 | 0 |
add insert statement to the set. | def add_insert_sql(self, stmt: str) -> 'StatementSet':
self._j_statement_set.addInsertSql(stmt)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_statement() -> str:\n pass",
"async def _insert_stmt(self):\n raise NotImplementedError",
"def insert(statement: str) -> []:\n raise NotImplementedError",
"def insert(self):\n pass",
"def insert(self):\n self.getDbRecord().insert()\n\n return",
"def in... | [
"0.73348004",
"0.7282123",
"0.7104033",
"0.70376384",
"0.67192733",
"0.66953015",
"0.6664766",
"0.6629884",
"0.65293306",
"0.6495636",
"0.6481297",
"0.643897",
"0.6429661",
"0.6397608",
"0.63722914",
"0.6366629",
"0.63188213",
"0.6221601",
"0.6208461",
"0.6191863",
"0.6189242... | 0.80597764 | 0 |
Creates a dataset with n_series data series that are each simulated for samples_per_series time steps. The timesteps are delta_t seconds apart. | def create_dataset(n_series=51, samples_per_series=1001, save_to_disk=True):
delta_t = 0.01
x0_in = np.random.random((n_series//2))
x0_out = np.random.random((n_series-n_series//2)) + np.pi - 1
x0 = np.concatenate([x0_in, x0_out])
msd = MassSpringDamper(x=x0, x_dt=tf.zeros_like(x0)) # compute all t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_ensemble_time_series(dsys, n_traj, len_traj):\n\n for i in range(n_traj):\n # Training initial condition.\n x0_train = normal(loc=0.0, scale=1.0, size=(dsys.A.shape[1]))\n\n # Run simulation to generate dataset.\n t, _, x = dlsim(dsys, np.zeros((len_traj, dsys.inputs)), ... | [
"0.65548915",
"0.6483605",
"0.61622024",
"0.60135025",
"0.5952278",
"0.59478754",
"0.5932897",
"0.58320725",
"0.58142924",
"0.5810814",
"0.58012944",
"0.579603",
"0.57907796",
"0.57790065",
"0.57643455",
"0.5731143",
"0.5673035",
"0.5666023",
"0.56609744",
"0.56574816",
"0.56... | 0.70332897 | 0 |
Calculates total energy of a massspringdamper system given a state. | def total_energy(state, k=1, m=1):
return 0.5*k*state[..., 0]*state[..., 0]+0.5*m*state[..., 1]*state[..., 1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def E(self, state):\n \n if state==0: # Invalid state has no energy\n return 0\n return sum([self.calcDistance(state[i+1], state[i]) for i in range(len(state)-1)])",
"def energy(self, state):\n return _modeller.mod_state_optimizer_energy(self._modpt,\n ... | [
"0.72978914",
"0.6800482",
"0.67240715",
"0.6545475",
"0.647643",
"0.63820916",
"0.6224594",
"0.6218873",
"0.6209779",
"0.6199031",
"0.6194541",
"0.61923784",
"0.61691",
"0.6158798",
"0.6013328",
"0.6004666",
"0.5997395",
"0.59853816",
"0.5841618",
"0.5840448",
"0.57865363",
... | 0.7182555 | 1 |
Computes the relative energy drift of x_pred w.r.t. x_true | def relative_energy_drift(x_pred, x_true, t=-1):
energy_pred = total_energy(x_pred[t])
energy_true = total_energy(x_true[t])
return (energy_pred-energy_true) / energy_true | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_phase_difference(y_true, y_pred):\n\n diff = y_pred - y_true\n diff -= tf.multiply(\n tf.cast(tf.greater_equal(diff, dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n diff += tf.multiply(\n tf.cast(tf.less(diff, -dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n return d... | [
"0.61286956",
"0.6123985",
"0.60035336",
"0.5856947",
"0.5804698",
"0.5800761",
"0.5794037",
"0.5790036",
"0.57635224",
"0.5752601",
"0.56845367",
"0.5673297",
"0.5668639",
"0.56648374",
"0.5648307",
"0.5620171",
"0.5612428",
"0.56122655",
"0.5608644",
"0.5602617",
"0.5596544... | 0.8591493 | 0 |
Computes the relative phase error of x_pred w.r.t. x_true. This is done by finding the locations of the zero crossings in both signals, then corresponding crossings are compared to each other. | def relative_phase_error(x_pred, x_val):
ref_crossings = zero_crossings(x_val[:, 0])
pred_crossings = zero_crossings(x_pred[:, 0])
t_ref = np.mean(np.diff(ref_crossings)) * 2
t_pred = np.mean(np.diff(pred_crossings)) * 2
phase_error = t_ref/t_pred - 1
if len(pred_crossings) < len(ref_crossings) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_phase_difference(y_true, y_pred):\n\n diff = y_pred - y_true\n diff -= tf.multiply(\n tf.cast(tf.greater_equal(diff, dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n diff += tf.multiply(\n tf.cast(tf.less(diff, -dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n return d... | [
"0.6281197",
"0.59099185",
"0.58893096",
"0.5852402",
"0.5812844",
"0.57776743",
"0.5741355",
"0.571223",
"0.5664011",
"0.551934",
"0.5496603",
"0.5488607",
"0.5486976",
"0.5474592",
"0.5464117",
"0.5453587",
"0.54014504",
"0.53790504",
"0.536854",
"0.5364881",
"0.533917",
... | 0.80148506 | 0 |
Find indices of zeros crossings | def zero_crossings(x):
return np.array(np.where(np.diff(np.sign(x)))[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_cross_elems(x, y):\n assert (x.size == y.size), \"x and y must have equal size!\"\n indices = np.arange(x.size)[zero_cross_boolean_index(y)]\n\n return Zero_Cross_Intervals(x[indices],\n x[indices + 1],\n y[indices],\n ... | [
"0.69026285",
"0.66425437",
"0.66288316",
"0.6570189",
"0.65314287",
"0.6530191",
"0.64993614",
"0.64742637",
"0.6454947",
"0.6424364",
"0.6378439",
"0.6375406",
"0.6299005",
"0.62695843",
"0.622959",
"0.61957747",
"0.6192994",
"0.61845845",
"0.6160345",
"0.61368203",
"0.6043... | 0.7078362 | 0 |
Set authentication for the Webhook. Can be either a app or user token. | def authenticate(self, auth_token: str) -> None:
self.__authenticate = True
self.__auth_token = auth_token
if not self.callback_url.startswith('https'):
raise Exception('HTTPS is required for authenticated webhook.\n'
+ 'Either use non authenticated webhoo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_hook(self):\n pass",
"def authentication(self, authentication):\n self._authentication = authentication",
"def set_requests_auth(self):\n self.__auth = OAuth2(token=self.bearer_token)",
"def enable_auth(self):\n\n self._api_manager.enable_auth()",
"def for_aut... | [
"0.6512903",
"0.6280482",
"0.6232747",
"0.6179822",
"0.6173788",
"0.6144986",
"0.60863155",
"0.60844374",
"0.60590637",
"0.60274845",
"0.5969733",
"0.5961362",
"0.5910693",
"0.5896948",
"0.5857367",
"0.5832172",
"0.5830799",
"0.5819944",
"0.5808844",
"0.5794098",
"0.57879853"... | 0.63118255 | 1 |
Subscribe to user follow topic. Set only from_id if you want to know if User with that id follows someone.\n Set only to_id if you want to know if someone follows User with that id.\n Set both if you only want to know if from_id follows to_id.\n | def subscribe_user_follow(self,
from_id: Union[str, None],
to_id: Union[str, None],
callback_func: Union[Callable[[UUID, dict], None], None]) -> Tuple[bool, UUID]:
param_dict = {"first": 1,
"from_id":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow_me(self, action = 'follow_topic'):\n data = {\n 'params' : json.dumps({\n 'topic_id' : self.soup.find('div', id = 'zh-topic-desc')['data-resourceid']\n }),\n '_xsrf' : self.session.getCookie()['_xsrf'],\n 'method' : action\n ... | [
"0.6426532",
"0.6417592",
"0.6319717",
"0.6229763",
"0.6068537",
"0.592255",
"0.5917339",
"0.59045386",
"0.59028536",
"0.58812976",
"0.58408505",
"0.58146167",
"0.5809982",
"0.5805806",
"0.5790301",
"0.5789063",
"0.57648915",
"0.57457554",
"0.5718259",
"0.56877375",
"0.566789... | 0.7383402 | 0 |
Unsubscribe from Channel Ban Change Events Topic | def unsubscribe_channel_ban_change_events(self, uuid: UUID) -> bool:
return self._generic_unsubscribe('/moderation/banned/events', uuid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(self, channel, update_handler=None):\n pass",
"def cb_stop(self, update, context):\n\n print(f\"Unsubscribing chat_id '{upd... | [
"0.7299835",
"0.7299835",
"0.7299835",
"0.7299835",
"0.7299835",
"0.7290285",
"0.69569016",
"0.69497174",
"0.6807146",
"0.6805143",
"0.67663234",
"0.67325085",
"0.6711645",
"0.667798",
"0.6638506",
"0.64776814",
"0.6413881",
"0.63525087",
"0.6308385",
"0.63021916",
"0.6288255... | 0.7349533 | 0 |
Unsubscribe from Hype Train Events Topic | def unsubscribe_hype_train_events(self, uuid: UUID) -> bool:
return self._generic_unsubscribe('/hypetrain/events', uuid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(receiver):",
"def unsubscribe(self):\n pass # pragma: no cover",
"def unsubscribeFromEvent(eventName,subscriber):",
"def unsubscribe(self, subject):\n ... | [
"0.73012006",
"0.73012006",
"0.73012006",
"0.73012006",
"0.73012006",
"0.72183186",
"0.7197908",
"0.6796366",
"0.67903614",
"0.67750937",
"0.67750937",
"0.6706016",
"0.6649363",
"0.6633316",
"0.662526",
"0.6577521",
"0.6576188",
"0.65284336",
"0.65141696",
"0.65022695",
"0.64... | 0.7315941 | 0 |
Says when a member joined. | async def joined(self, ctx, member: discord.Member):
await ctx.send('{0.name} joined in {0.joined_at}'.format(member)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def on_member_join(self, member: Member):\n\n if not self._is_tracked(member.guild, EventPriority.join):\n return\n\n em = self.em_base(\n member,\n f\"User {member.mention} ({member.name}) joined\",\n EventColors.join.value\n )\n\n em.a... | [
"0.78859025",
"0.7684899",
"0.76168865",
"0.76168865",
"0.76168865",
"0.76117444",
"0.7605289",
"0.7578849",
"0.7570187",
"0.7469505",
"0.7328319",
"0.72358775",
"0.7097512",
"0.6860103",
"0.6832718",
"0.66840136",
"0.664821",
"0.65940976",
"0.65013736",
"0.64450365",
"0.6405... | 0.7771115 | 1 |
Given a triangulation object and a field `q` defined at the vertices of the triangulation, return integral |grad q|^2 dx | def square_gradient(tri, q):
finder = tri.get_trifinder()
interp = LinearTriInterpolator(tri, q, trifinder = finder)
integral = 0.0
num_triangles, _ = np.shape(tri.triangles)
for n in range(num_triangles):
ele = tri.triangles[n, :]
x = tri.x[ele]
y = tri.y[ele]
a ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradh(self,q):\n gx = self.d_i(q) / self.e1u\n gy = self.d_j(q) / self.e2v\n #\n return gx,gy",
"def integrate_dphi_phi(self, i, j):\n def func(x):\n return self.shape_function_deriv(i, x) * self.shape_function(j, x)\n i, err = quadrature(func, -1, 1)\n ... | [
"0.61055577",
"0.588669",
"0.5814507",
"0.57111114",
"0.5700496",
"0.5698189",
"0.56779283",
"0.5656769",
"0.5652398",
"0.5644207",
"0.5642131",
"0.56034553",
"0.5586597",
"0.55844885",
"0.5546834",
"0.5504967",
"0.5503718",
"0.54716414",
"0.54594284",
"0.5456545",
"0.5454004... | 0.6430995 | 0 |
Registers a (namespace URI, alias) mapping in a global namespace alias map. Raises NamespaceAliasRegistrationError if either the namespace URI or alias has already been registered with a different value. This function is required if you want to use a namespace with an OpenID 1 message. | def registerNamespaceAlias(namespace_uri, alias):
global registered_aliases
if registered_aliases.get(alias) == namespace_uri:
return
if namespace_uri in list(registered_aliases.values()):
raise NamespaceAliasRegistrationError(
'Namespace uri %r already registered' % (namespace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAlias(self, namespace_uri, desired_alias, implicit=False):\n if isinstance(namespace_uri, bytes):\n namespace_uri = str(namespace_uri, encoding=\"utf-8\")\n # Check that desired_alias is not an openid protocol field as\n # per the spec.\n assert desired_alias not in OP... | [
"0.7010636",
"0.6806219",
"0.610108",
"0.5974404",
"0.57496196",
"0.570408",
"0.5661323",
"0.5641835",
"0.55364525",
"0.55100685",
"0.54919547",
"0.5460767",
"0.5418688",
"0.53622675",
"0.53546315",
"0.53462195",
"0.5308682",
"0.527205",
"0.5271993",
"0.5242364",
"0.5229331",... | 0.7908426 | 0 |
Set the OpenID namespace URI used in this message. | def setOpenIDNamespace(self, openid_ns_uri, implicit):
if isinstance(openid_ns_uri, bytes):
openid_ns_uri = str(openid_ns_uri, encoding="utf-8")
if openid_ns_uri not in self.allowed_openid_namespaces:
raise InvalidOpenIDNamespace(openid_ns_uri)
self.namespaces.addAlias(o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fixNS(self, namespace):\n if isinstance(namespace, bytes):\n namespace = str(namespace, encoding=\"utf-8\")\n\n if namespace == OPENID_NS:\n if self._openid_ns_uri is None:\n raise UndefinedOpenIDNamespace('OpenID namespace not set')\n else:\n ... | [
"0.6426755",
"0.62954724",
"0.6164264",
"0.6050303",
"0.6050303",
"0.5984669",
"0.59691775",
"0.5940983",
"0.5940983",
"0.5894546",
"0.58075154",
"0.57805187",
"0.576387",
"0.576387",
"0.5745174",
"0.5741338",
"0.57310665",
"0.57230777",
"0.5672933",
"0.56456596",
"0.56197655... | 0.7747692 | 0 |
Create a Message from a KVForm string | def fromKVForm(cls, kvform_string):
return cls.fromOpenIDArgs(kvform.kvToDict(kvform_string)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromString(line: Union[bytes, str]) -> SBSMessage:\n if isinstance(line, bytes):\n line = line.decode()\n\n values = line.rstrip(DELIMITER).split(\",\")\n\n if len(FieldNames) != len(values):\n raise Exception(\n \"Incorrect number of msg fields. \"\n f\"Expected {l... | [
"0.57645077",
"0.5688823",
"0.56552196",
"0.5643596",
"0.5618665",
"0.5617855",
"0.56144583",
"0.5580899",
"0.5577902",
"0.55517954",
"0.5543949",
"0.5539514",
"0.5533499",
"0.55125445",
"0.5456577",
"0.5455207",
"0.54431003",
"0.5441704",
"0.54322344",
"0.54081976",
"0.53713... | 0.6811829 | 0 |
Return all arguments with openid. in front of namespaced arguments. bytes | def toPostArgs(self):
args = {}
# Add namespace definitions to the output
for ns_uri, alias in self.namespaces.items():
if self.namespaces.isImplicit(ns_uri):
continue
if alias == NULL_NAMESPACE:
ns_key = 'openid.ns'
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getArgs(self, namespace):\n namespace = self._fixNS(namespace)\n args = []\n for ((pair_ns, ns_key), value) in self.args.items():\n if pair_ns == namespace:\n if isinstance(ns_key, bytes):\n k = str(ns_key, encoding=\"utf-8\")\n e... | [
"0.6365776",
"0.59016585",
"0.58178616",
"0.5766803",
"0.5735688",
"0.5670085",
"0.5667718",
"0.56496716",
"0.5622981",
"0.5534717",
"0.5495901",
"0.5444868",
"0.5425289",
"0.5410966",
"0.5409317",
"0.54073656",
"0.5405866",
"0.5405073",
"0.5404213",
"0.5399564",
"0.5351973",... | 0.6745914 | 0 |
Generate an xwwwurlencoded string | def toURLEncoded(self):
args = sorted(self.toPostArgs().items())
return urllib.parse.urlencode(args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_query_string(self):\n \n query_items = {}\n \n for key, val in self.__dict__.iteritems():\n if not key.startswith('_'):\n query_items[key] = val.encode('utf-8')\n \n return urllib.urlencode(query_items)",
"def to_postdata(request):... | [
"0.5808472",
"0.57913643",
"0.5773916",
"0.57650715",
"0.57605106",
"0.5748529",
"0.57311493",
"0.56504",
"0.55804265",
"0.5517981",
"0.5515183",
"0.5464793",
"0.5397268",
"0.53861",
"0.53720844",
"0.5360866",
"0.5342282",
"0.5324426",
"0.5311394",
"0.52979195",
"0.528327",
... | 0.5803152 | 1 |
Get the key for a particular namespaced argument | def getKey(self, namespace, ns_key):
namespace = self._fixNS(namespace)
if namespace == BARE_NS:
return ns_key
ns_alias = self.namespaces.getAlias(namespace)
# No alias is defined, so no key can exist
if ns_alias is None:
return None
if ns_alias... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corresponding_key_for_object(arg_schema: Dict[str, Any]) -> str:\n return arg_schema['schema']['new_key_for_argument']",
"def getArg(self, namespace, key, default=None):\n namespace = self._fixNS(namespace)\n args_key = (namespace, key)\n try:\n return self.args[args_ke... | [
"0.6990061",
"0.6727239",
"0.6724652",
"0.6566283",
"0.65627825",
"0.6446762",
"0.6391834",
"0.63013256",
"0.6270743",
"0.62667465",
"0.6264716",
"0.61936885",
"0.6190331",
"0.607806",
"0.6064705",
"0.6060848",
"0.60452914",
"0.6038849",
"0.6035953",
"0.6026025",
"0.601438",
... | 0.6781975 | 1 |
Set a single argument in this namespace | def setArg(self, namespace, key, value):
assert key is not None
assert value is not None
namespace = self._fixNS(namespace)
# try to ensure that internally it's consistent, at least: str -> str
if isinstance(value, bytes):
value = str(value, encoding="utf-8")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setParameter(self, name, value):",
"def __setitem__(self, arg, value):\n setattr(self.args, arg, value)",
"def _set_args(self, args):\n if not args:\n self.arg = None\n elif len(args) == 1:\n self.arg = args[0]\n else:\n self.arg = args",
"def ... | [
"0.7103958",
"0.70502704",
"0.6912513",
"0.68511933",
"0.6721404",
"0.67157024",
"0.6668933",
"0.66669136",
"0.65873015",
"0.65809786",
"0.65776145",
"0.65428585",
"0.65428585",
"0.65428585",
"0.65428585",
"0.65428585",
"0.6538274",
"0.6504318",
"0.6490057",
"0.6437055",
"0.6... | 0.7578816 | 0 |
Return an iterator over the namespace URIs | def iterNamespaceURIs(self):
return iter(self.namespace_to_alias) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterAliases(self):\n return iter(self.alias_to_namespace)",
"def namespaces(self):\n return [self._namespace_prefix]",
"def all_in_namespace(cls, ns):\n return filter_by_prefix(cls.all(), ns + ':')",
"def namespaces(self):\n return list(self._namespace_schemas.keys())",
"asy... | [
"0.6870897",
"0.6685352",
"0.6223801",
"0.6188847",
"0.6184657",
"0.61233354",
"0.6122067",
"0.6073421",
"0.6056552",
"0.6017647",
"0.5989113",
"0.5978699",
"0.59674186",
"0.5959256",
"0.5956481",
"0.59479284",
"0.58875895",
"0.58692926",
"0.5852249",
"0.57922745",
"0.5739497... | 0.8632694 | 0 |
Return an iterator over the aliases | def iterAliases(self):
return iter(self.alias_to_namespace) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aliases(self):\n return self.__aliases",
"def getAliases(self):",
"def iterNamespaceURIs(self):\n return iter(self.namespace_to_alias)",
"def query_aliases(self):\n\n result = set()\n\n infos = self.es_client.indices.get_alias(\n index='{}-*'.format(self.normalized_... | [
"0.73336315",
"0.71978825",
"0.7082749",
"0.704246",
"0.69749415",
"0.69117486",
"0.68409556",
"0.6807005",
"0.67619336",
"0.67586315",
"0.65434766",
"0.65251005",
"0.64194065",
"0.63572776",
"0.6298205",
"0.6276488",
"0.6267333",
"0.62299424",
"0.61920774",
"0.6123602",
"0.6... | 0.86531883 | 0 |
Add this namespace URI to the mapping, without caring what alias it ends up with | def add(self, namespace_uri):
# See if this namespace is already mapped to an alias
alias = self.namespace_to_alias.get(namespace_uri)
if alias is not None:
return alias
# Fall back to generating a numerical alias
i = 0
while True:
alias = 'ext' +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAlias(self, namespace_uri, desired_alias, implicit=False):\n if isinstance(namespace_uri, bytes):\n namespace_uri = str(namespace_uri, encoding=\"utf-8\")\n # Check that desired_alias is not an openid protocol field as\n # per the spec.\n assert desired_alias not in OP... | [
"0.64435095",
"0.63750935",
"0.6109068",
"0.6095447",
"0.6022318",
"0.5992828",
"0.5778283",
"0.57767075",
"0.5771834",
"0.5735369",
"0.568554",
"0.56455714",
"0.56407934",
"0.5635236",
"0.5556329",
"0.5487468",
"0.5453782",
"0.5439539",
"0.5429285",
"0.5421573",
"0.5385871",... | 0.7072294 | 0 |
move patients from waiting to triage | def callNurse():
triageRoom.append(waitingRoom.pop(0))
#sort(triageRoom,key=patient.triageNumer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def move(self):\n await self.wait(5)\n previous_task = self.miner_task\n self.miner_task = random.choice(\n [candidate for candidate in MinerType if candidate != self.miner_task]\n )\n self.say(f\"Moved from task {previous_task} to task {self.miner_task}\")",
"... | [
"0.5807499",
"0.57181096",
"0.56383467",
"0.55233204",
"0.52456886",
"0.5228011",
"0.51831496",
"0.51780653",
"0.51529205",
"0.5146072",
"0.5142629",
"0.5142618",
"0.5128126",
"0.512274",
"0.51103115",
"0.5101565",
"0.5060642",
"0.5050685",
"0.50319284",
"0.5019232",
"0.50100... | 0.5813368 | 0 |
Return all problem names that belong to the specified test set as list | def getTestSetByName(testset : str = TESTSET_MIPLIB2010) -> list:
try:
return _testsetdict[testset]
except IndexError:
raise IndexError("Unknown test set specifier {}".format(testset)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_a_list_of_testset_names() -> str:\n message = 'The available test sets are:'\n for testset in sorted(DATASETS.keys(), reverse=True):\n message += '\\n%20s: %s' % (testset, DATASETS[testset].get('description', ''))\n return message",
"def get_langpairs_for_testset(testset: str) -> List:\n ... | [
"0.6855921",
"0.65782523",
"0.6288914",
"0.58829206",
"0.5865857",
"0.5843167",
"0.5820474",
"0.5791785",
"0.57900167",
"0.5741455",
"0.5688786",
"0.564486",
"0.56263286",
"0.5622542",
"0.55753124",
"0.55678785",
"0.55395573",
"0.5508305",
"0.547427",
"0.54531366",
"0.5452073... | 0.7205281 | 0 |
return all valid test set identifiers | def getTestSets():
return list(_testsetdict.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTestsIds():\n with driver.session() as s:\n ids = s.write_transaction(getTestsId)\n\n tIds = []\n for idEl in ids:\n tIds.append(idEl[\"ID(t)\"])\n\n return tIds",
"def test_get_ids(self):\r\n lines = \"\"\">S74_1 E86FECS01CEVAV orig_bc=ACATGTCACGTG new_bc=ACATGTCACGTG bc_... | [
"0.6714933",
"0.64470106",
"0.6430311",
"0.6180012",
"0.61729527",
"0.613509",
"0.6104871",
"0.60966504",
"0.6089016",
"0.6084988",
"0.60646206",
"0.60646206",
"0.6046974",
"0.60027915",
"0.6000186",
"0.59887046",
"0.5985557",
"0.5958685",
"0.59212613",
"0.5874063",
"0.584645... | 0.6758547 | 0 |
Returns a list of directions with walls from unit (x, y). | def walls(self, x, y):
return [direction for direction in Compass if self._grid[y][x] & direction] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_walls(world):\r\n return set(((x,y) for x in range(world.get_width()) for y in range(world.get_height()) if world.is_wall((x,y))))",
"def walls (x, y):\n North = True\n West = True\n East = True\n South = True\n if x == 1:\n West = False\n if x == 3:\n East = False\n ... | [
"0.6931096",
"0.67324764",
"0.6677025",
"0.6662643",
"0.65038824",
"0.64544606",
"0.64346147",
"0.643258",
"0.6403339",
"0.6403339",
"0.6382812",
"0.6378806",
"0.63534755",
"0.63412195",
"0.6326087",
"0.6306027",
"0.6297865",
"0.6296912",
"0.62893313",
"0.6274893",
"0.627132"... | 0.7872111 | 0 |
Returns the neighbor of unit (x, y) in the given direction, if it exists. | def neighbor(self, x, y, direction):
if direction == Compass.NORTH:
if y > 0:
return (x, y-1)
elif direction == Compass.EAST:
if x < self.width - 1:
return (x+1, y)
elif direction == Compass.SOUTH:
if y < self.height - 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def see_neighbour(self, x, y, dx, dy):\r\n if self.grid[y][x] == '.' or (dx == 0 and dy == 0): # Makes looping easier\r\n return None\r\n x += dx\r\n y += dy\r\n while 0 <= x < self.width and 0 <= y < self.height:\r\n if self.grid[y][x] != '.':\r\n ... | [
"0.7152461",
"0.67528635",
"0.67314065",
"0.6406822",
"0.6211197",
"0.6211197",
"0.62099123",
"0.6173974",
"0.61151046",
"0.6108432",
"0.60893816",
"0.60839796",
"0.6080536",
"0.60654765",
"0.60411894",
"0.60186845",
"0.5971613",
"0.59698486",
"0.5959896",
"0.5959765",
"0.593... | 0.80897313 | 0 |
Generates a random maze using the recursive backtracking algorithm. | def recursive_backtrack(width=16, height=16) -> Maze:
maze = Maze(width=width, height=height, algorithm=None)
visited = [[False for _ in range(maze.width)] for _ in range(maze.height)]
# ensure only one entrance to the center squares
centerx = maze.width // 2 - 1
centery = maze.height // 2 - 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_maze(self):\r\n # reset the grid before generation\r\n self.initialize_grid()\r\n\r\n # choose the first cell to put in the visited list\r\n # see Step 1 of the algorithm.\r\n current = self.unvisited.pop(random.randint(0,len(self.unvisited)-1))\r\n self.visit... | [
"0.74878633",
"0.6845463",
"0.68291163",
"0.67794526",
"0.6772866",
"0.6768403",
"0.66348165",
"0.6616029",
"0.6605966",
"0.6581727",
"0.65716815",
"0.64793205",
"0.6440684",
"0.624309",
"0.6218164",
"0.6157984",
"0.6036416",
"0.6015916",
"0.60098726",
"0.6002533",
"0.5976529... | 0.6860484 | 1 |
Generates a maze using a randomized version of Prim's Algorithm. | def randomized_prims(width=16, height=16) -> Maze:
maze = Maze(width=width, height=height, algorithm=None)
visited = [[False for _ in range(maze.width)] for _ in range(maze.height)]
# ensure only one entrance to the center squares
centerx = maze.width // 2 - 1
centery = maze.height // 2 - 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_maze(dim, p):\n maze = []\n for i in range(dim):\n maze.append([])\n for j in range(dim):\n if(random.uniform(0, 1) < p):\n maze[i].append(1)\n else:\n maze[i].append(0)\n\n maze[0][0] = 0\n maze[dim - 1][dim - 1] = 0\n return... | [
"0.75691426",
"0.7045847",
"0.6857781",
"0.66844857",
"0.64299804",
"0.63144267",
"0.6273802",
"0.62688345",
"0.6187559",
"0.6180049",
"0.614384",
"0.61315477",
"0.6058598",
"0.6057205",
"0.60230833",
"0.60173345",
"0.6015078",
"0.60039353",
"0.6003372",
"0.59754616",
"0.5940... | 0.72561264 | 1 |
Generates a maze using Wilson's looperased random walk algorithm. | def wilsons_maze(width=16, height=16) -> Maze:
maze = Maze(width=width, height=height, algorithm=None)
visited = [[False for _ in range(maze.width)] for _ in range(maze.height)]
visited[0][0] = True
def loop_erased_random_walk(x, y):
"""
Take a random walk from unit (sx,sy) until we ru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(width=20, height=20):\n m = Maze(width, height)\n m.randomize()\n return m",
"def generate_maze(self):\r\n # reset the grid before generation\r\n self.initialize_grid()\r\n\r\n # choose the first cell to put in the visited list\r\n # see Step 1 of the... | [
"0.67708105",
"0.6556104",
"0.65384185",
"0.65105295",
"0.6488578",
"0.6312048",
"0.62315196",
"0.6209019",
"0.6135243",
"0.610975",
"0.6102821",
"0.60939026",
"0.60924953",
"0.60906166",
"0.60030806",
"0.5971497",
"0.5958963",
"0.5933859",
"0.5922739",
"0.5917373",
"0.589989... | 0.7545776 | 0 |
Take a random walk from unit (sx,sy) until we run into a visited unit, and remove any cycles from the path if/when it intersects itself. | def loop_erased_random_walk(x, y):
path = []
directions = []
while not visited[y][x]:
direction = random.choice(maze.neighbors(x, y))
nx, ny = maze.neighbor(x, y, direction)
while (nx, ny) in path:
path.pop()
directions.pop()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wilsons_maze(width=16, height=16) -> Maze:\n maze = Maze(width=width, height=height, algorithm=None)\n visited = [[False for _ in range(maze.width)] for _ in range(maze.height)]\n\n visited[0][0] = True\n\n def loop_erased_random_walk(x, y):\n \"\"\"\n Take a random walk from unit (sx... | [
"0.5669445",
"0.55742264",
"0.5537145",
"0.5513449",
"0.5472112",
"0.54696685",
"0.5321966",
"0.52884585",
"0.5284085",
"0.5250031",
"0.52147436",
"0.52095425",
"0.52093375",
"0.5178389",
"0.51754934",
"0.51659197",
"0.51580596",
"0.51013595",
"0.5019818",
"0.5010896",
"0.500... | 0.6616399 | 0 |
the function checks, if a permutation p, i.e. a list of colours like p = ['pink', 'yellow', 'green', 'red'] is consistent with the previous colours. Each previous colour permuation guess[0] compared (check()) with p has to return the same amount of blacks (rightly positioned colours) and whites (right colour at wrong p... | def inconsistent(p, guesses):
for guess in guesses:
res = check(guess[0], p)
(rightly_positioned, permutated) = guess[1]
if res != [rightly_positioned, permutated]:
return True # inconsistent
return False # i.e. consistent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answer_ok(a):\n (rightly_positioned, permutated) = a\n if (rightly_positioned + permutated > number_of_positions) \\\n or (rightly_positioned + permutated < len(colours) - number_of_positions):\n return False\n if rightly_positioned == 3 and permutated == 1:\n return False\n return True... | [
"0.66472465",
"0.6064803",
"0.6030187",
"0.5988332",
"0.5928046",
"0.5810799",
"0.5657002",
"0.5475401",
"0.5473486",
"0.5438479",
"0.54351574",
"0.5423985",
"0.54230165",
"0.5383598",
"0.5366832",
"0.53050816",
"0.52952015",
"0.5255458",
"0.523689",
"0.5223979",
"0.5222147",... | 0.6597506 | 1 |
This funtion gets an evaluation of the current guess, checks the consistency of this evaluation, adds the guess together with the evaluation to the list of guesses, shows the previous guesses and creates a ne guess | def new_evaluation(current_colour_choices):
rightly_positioned, permutated = get_evaluation()
if rightly_positioned == number_of_positions:
return(current_colour_choices, (rightly_positioned, permutated))
if not answer_ok((rightly_positioned, permutated)):
print("Input Error: Sorry, the input mak... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_guess(self, Guess):\n\n\t\t# pulls comparison from win check and assigns peg responses \n\n\t\t# returns a list to be in hint_response\n\n\t\t# displays as part of big display in view.\n\n\t\t\"\"\"Borrow the logic from win_check to implement eval_guess. Use variables right and wrong to \n\t\tevaluate. Ri... | [
"0.7248868",
"0.6583188",
"0.64794326",
"0.64139926",
"0.6123071",
"0.60716164",
"0.6006147",
"0.5981178",
"0.5953067",
"0.59431326",
"0.5941986",
"0.59280753",
"0.5866177",
"0.58647215",
"0.5862311",
"0.5850885",
"0.58037716",
"0.57967645",
"0.57883865",
"0.5781944",
"0.5733... | 0.6815338 | 1 |
Animation function. Takes the current frame number (to select the potion of data to plot) and a line object to update. | def animate(frame, line):
# Not strictly neccessary, just so we know we are stealing these from
# the global scope
global all_x_data, all_y_data
# We want up-to and _including_ the frame'th element
current_x_data = all_x_data[: frame + 1]
current_y_data = all_y_data[: frame + 1]
line.set_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def animate1Dframes(x, data):\n plt.ion() # Set the plot to animated. \n ax1 = plt.axes()\n line, = plt.plot(data[-1], x , '-*k')\n\n for u in data:\n line.set_xdata(u)\n plt.draw()\n #tm.sleep(0.25)",
"def animate(i):\r\n plot_x.set_data(history_samples[i][:, 0], history_s... | [
"0.77292675",
"0.72614247",
"0.72505695",
"0.6970664",
"0.6846777",
"0.6800257",
"0.66679996",
"0.66199565",
"0.65524817",
"0.6547357",
"0.6531983",
"0.6420023",
"0.6392908",
"0.6375818",
"0.6330665",
"0.6305474",
"0.6286024",
"0.6248007",
"0.6227651",
"0.6225863",
"0.6205546... | 0.76468295 | 1 |
An op to compute the length of a sequence. 0 are masked. | def retrieve_seq_length_op(data):
with tf.name_scope('GetLength'):
used = tf.sign(tf.reduce_max(tf.abs(data), reduction_indices=2))
length = tf.reduce_sum(used, reduction_indices=1)
length = tf.cast(length, tf.int32)
return length | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self) -> ir.IntegerValue:\n return ops.MapLength(self).to_expr()",
"def length(sequence):\r\n populated = tf.sign(tf.abs(sequence))\r\n length = tf.cast(tf.reduce_sum(populated, axis=1), tf.int32)\r\n mask = tf.cast(tf.expand_dims(populated, -1), tf.float32)\r\n return length, mask"... | [
"0.71625274",
"0.7082808",
"0.70349264",
"0.6893778",
"0.6871125",
"0.6785109",
"0.67817247",
"0.6643931",
"0.66114056",
"0.6494078",
"0.6493203",
"0.6493203",
"0.64920545",
"0.648977",
"0.6474978",
"0.6456874",
"0.6448589",
"0.64314854",
"0.64184487",
"0.64124024",
"0.639237... | 0.7716348 | 0 |
Define a function by a rewrite system. | def define(cls, function: Function, rules: RewriteSystem):
setattr(cls, function.symbol, function)
# TODO: Make sure RewriteSystem terminates
# TODO: Does composition of terminating rewrite systems terminate?
for rule in rules:
cls.add_rule(rule)
cls.definitions[funct... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_function(self, func):\n func.name = self.function_rewrites.get(func.name, func.name)\n return super(AccessCompiler, self).visit_function(func)",
"def __def_function__():\n pass",
"def wrapped(func):\n self.routes.append((path, {\n 'regex': re.compile('^' + r... | [
"0.70453715",
"0.62984306",
"0.61714536",
"0.585374",
"0.57631445",
"0.5763008",
"0.5754764",
"0.5739049",
"0.572244",
"0.571211",
"0.5690703",
"0.5689855",
"0.56534237",
"0.5652263",
"0.56320566",
"0.56306136",
"0.5609298",
"0.55959314",
"0.5584421",
"0.55726177",
"0.5551964... | 0.6912517 | 1 |
Decorator that takes a TheorySystem and adds sorts to Constants and Functions defined. | def Inductive(cls=None):
if cls is not None and not issubclass(cls, TheorySystem):
raise ValueError(
"Inductive decorator only works \
on classes that inherit TheorySystem."
)
@functools.wraps(cls)
def wrap(cls):
cls.sort = Sort(cls.__name__)
cls.rul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortby(self):\n ...",
"def orderby():\n pass",
"def _sort_definitions(orig_defs: List[Definition]) -> List[Definition]:\n definitions: List[Definition] = [definition for definition in orig_defs\n if isinstance(definition, Parameter)]\n definitions.extend(... | [
"0.5738267",
"0.5639993",
"0.5537029",
"0.54026973",
"0.5303816",
"0.52853185",
"0.5183392",
"0.51713866",
"0.5165641",
"0.5165641",
"0.5158325",
"0.5089632",
"0.5045029",
"0.5007571",
"0.49622414",
"0.4937734",
"0.49376684",
"0.49207813",
"0.49004227",
"0.48765743",
"0.48592... | 0.5885771 | 0 |
Obtain a TheorySystem from a sort. | def system_from_sort(s: Sort) -> Optional[TheorySystem]:
return _system_sort_map.get(s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sort_query(self, kind, order, is_number):\n pass",
"def test_parse_sort(self):\n old_type = Sort('sort', [\n Relationship('student', PersonSchema(), None),\n Relationship('school', StudentSchema(), None)],\n Attribute('title', SchoolSchema(), None), '+')\n ... | [
"0.48315117",
"0.48127127",
"0.4773293",
"0.46906564",
"0.46676126",
"0.4642743",
"0.4556032",
"0.4537334",
"0.45276597",
"0.45251364",
"0.4523657",
"0.45113435",
"0.45026153",
"0.4460235",
"0.44248357",
"0.44154066",
"0.43651977",
"0.43445125",
"0.4328574",
"0.4328547",
"0.4... | 0.72192395 | 0 |
Calculate the fooling ratio of attacks | def get_fool_ratio(self, test_acc, attack_accs):
return [round(100*((test_acc - attack_acc) / test_acc), 2) for attack_acc in attack_accs] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_damage(self) -> float:\n sum = 0\n for operator in self.__operators:\n if operator.is_alive:\n operator.experience += 1\n sum += operator.experience / 100\n return 0.1 + sum",
"def golden_ratio():\n return 1.61803398875",
"def set_defensiv... | [
"0.6468844",
"0.6419701",
"0.64027065",
"0.6392309",
"0.6361716",
"0.6286705",
"0.62861675",
"0.62798226",
"0.62680507",
"0.62259054",
"0.62143505",
"0.6197033",
"0.61885077",
"0.61466205",
"0.61228234",
"0.611322",
"0.61100066",
"0.61087966",
"0.6108751",
"0.60977983",
"0.60... | 0.65534633 | 0 |
Dispatches a hook dictionary on a given piece of data. | def dispatch_hook(key, hooks, hook_data):
hooks = hooks or dict()
if key in hooks:
try:
return hooks.get(key).__call__(hook_data) or hook_data
except Exception:
traceback.print_exc()
return hook_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch_hook(key, hooks, hook_data=None, **kwargs):\n # like requests.hooks.dispatch_hook\n hooks = hooks or dict()\n hooks = hooks.get(key)\n if hooks:\n if hasattr(hooks, '__call__'):\n hooks = [hooks]\n for hook in hooks:\n _hook_data = hook(hook_data, **kwar... | [
"0.74481755",
"0.6829305",
"0.61280715",
"0.61210513",
"0.59819674",
"0.59323394",
"0.57483125",
"0.5704683",
"0.5689838",
"0.5676677",
"0.55818295",
"0.5570244",
"0.55370414",
"0.5528388",
"0.54710704",
"0.54467523",
"0.5406375",
"0.5363602",
"0.53232306",
"0.5319977",
"0.52... | 0.7467904 | 0 |
Add a port mapping. | async def _async_add_port_mapping(
self, external_port: int, local_ip: str, internal_port: int
) -> None:
entry = [external_port, local_ip, internal_port]
self.added_port_mappings.append(entry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port_mapping(self, port_mapping):\n\n self._port_mapping = port_mapping",
"def add_port_gnmap(self, port_string):\n parts = port_string.split('/')\n port = parts[0]\n port_status = parts[1]\n protocol = parts[2]\n name = parts[4]\n service = parts[6]\n ... | [
"0.7490857",
"0.7266673",
"0.7083891",
"0.7012829",
"0.69441885",
"0.6719463",
"0.65730137",
"0.6556639",
"0.6530411",
"0.6514047",
"0.6406017",
"0.6303215",
"0.62523997",
"0.61982155",
"0.6185722",
"0.61799246",
"0.61799246",
"0.6176545",
"0.6130247",
"0.60711175",
"0.603177... | 0.77418405 | 0 |
Remove a port mapping. | async def _async_delete_port_mapping(self, external_port: int) -> None:
entry = external_port
self.removed_port_mappings.append(entry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_port(self, port):\n if port not in self.ports:\n return False\n del self.ports[port]\n return True",
"def port_delete(switch, port):\n client.port.delete(switch, port)",
"def delete_port(self, port):\r\n return self.delete(self.port_path % (port))",
"def r... | [
"0.7012401",
"0.68919563",
"0.6826929",
"0.68267936",
"0.66106075",
"0.6606275",
"0.65267193",
"0.64824533",
"0.6224275",
"0.6186114",
"0.61091745",
"0.60663605",
"0.6027865",
"0.602024",
"0.5986824",
"0.59401715",
"0.59329814",
"0.58928317",
"0.58843046",
"0.5880846",
"0.586... | 0.80357164 | 0 |
changes currency to the user choice and checks if currency symbols changed | def currency_symbol_should_change_with_currency(self, currency, symbol):
self.change_currency(currency)
assert self.wait_for_element(*self.CURRENCY_SYMBOL).text == symbol, "Currency symbol haven't changed" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_currency(self, currency):\n self.browser.find_element(*self.CURRENCY_PICKER).click()\n self.browser.find_element(By.CSS_SELECTOR, self.CURRENCY_CHOICE + f\"[name='{currency}']\").click()",
"def updateCurrency(self, currency: str, value: str) -> None:\n\n if currency == \"USDT\":\n... | [
"0.7762783",
"0.68542826",
"0.6782774",
"0.67133313",
"0.66576195",
"0.65601677",
"0.65410864",
"0.65389025",
"0.6477757",
"0.6396191",
"0.6315273",
"0.63026214",
"0.624808",
"0.62271553",
"0.61471874",
"0.61383265",
"0.6062019",
"0.60420394",
"0.60325086",
"0.60032094",
"0.6... | 0.68829626 | 1 |
Round trip a molecule to and from its attributes. | def test_attributes_to_openff_molecule():
mol: Molecule = Molecule.from_smiles("CC")
attributes = MoleculeAttributes.from_openff_molecule(molecule=mol)
mol2 = attributes.to_openff_molecule()
isomorphic, atom_map = Molecule.are_isomorphic(mol, mol2, return_atom_map=True)
assert isomorphic is True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_from_topology(self, molecule):\n topology = molecule.to_topology()\n molecule_copy = Molecule.from_topology(topology)\n assert molecule == molecule_copy",
"def test_to_from_topology(self, molecule):\n topology = molecule.to_topology()\n molecule_copy = Molecule.from... | [
"0.49963441",
"0.49963441",
"0.4897128",
"0.48742855",
"0.4872785",
"0.4872785",
"0.4825054",
"0.48211458",
"0.48048207",
"0.47521615",
"0.47101173",
"0.46881822",
"0.46784806",
"0.46585247",
"0.4654701",
"0.46520424",
"0.4611299",
"0.4603264",
"0.45798853",
"0.45765886",
"0.... | 0.5613074 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.