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 |
|---|---|---|---|---|---|---|
Saves the certificate received from the ACME server. | def save_certificate(self, certificate_msg, cert_path, chain_path):
# pylint: disable=no-self-use
cert_chain_abspath = None
cert_fd, cert_file = le_util.unique_file(cert_path, 0o644)
cert_fd.write(certificate_msg.certificate.as_pem())
cert_fd.close()
logging.info(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_ca():\n cert_file = os.environ.get('HOME') + '/.cat_installer/ca.pem'\n debug(\"saving cert\")\n with open(cert_file, 'w') as cert:\n cert.write(Config.CA + \"\\n\")",
"def save(self, cert_path: Union[Path, str], key_path: Union[Path, str]):\n cert_path, key_path =... | [
"0.74817127",
"0.65581006",
"0.6307745",
"0.60205173",
"0.5927806",
"0.57918024",
"0.57918024",
"0.57851005",
"0.57696563",
"0.56250715",
"0.56107426",
"0.5609433",
"0.5546148",
"0.55320233",
"0.54473394",
"0.5437405",
"0.5384466",
"0.535513",
"0.5345903",
"0.5345903",
"0.530... | 0.6837719 | 1 |
Redirect all traffic from HTTP to HTTPS | def redirect_to_ssl(self, domains):
for dom in domains:
try:
self.installer.enhance(dom, "redirect")
except errors.LetsEncryptConfiguratorError:
logging.warn("Unable to perform redirect for %s", dom)
self.installer.save("Add Redirects")
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssl_redirect():\n if request.get_header('X-Forwarded-Proto', 'http') != 'https':\n redirect(request.url.replace('http://', 'https://', 1), code=301)",
"def filter_ssl(request):\n if request.scheme == 'https':\n return True\n else:\n return False",
"def configure_https(... | [
"0.83266073",
"0.6460562",
"0.64080423",
"0.6239703",
"0.61772585",
"0.61562127",
"0.6100595",
"0.60169566",
"0.59199893",
"0.5896638",
"0.5795509",
"0.559525",
"0.55919194",
"0.55564827",
"0.55251473",
"0.5416156",
"0.5414015",
"0.5356515",
"0.52997166",
"0.52648175",
"0.526... | 0.6540898 | 1 |
Validate Key and CSR files. Verifies that the client key and csr arguments are valid and correspond to one another. This does not currently check the names in the CSR due to the inability to read SANs from CSRs in python crypto libraries. If csr is left as None, only the key will be validated. | def validate_key_csr(privkey, csr=None):
# TODO: Handle all of these problems appropriately
# The client can eventually do things like prompt the user
# and allow the user to take more appropriate actions
# Key must be readable and valid.
if privkey.pem and not crypto_util.valid_privkey(privkey.pem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_ksr_with_ecdsa_key(self):\n xml = self._make_request()\n request = request_from_xml(xml)\n self.assertTrue(validate_request(request, self.policy))",
"def check_valid_request_ca(self):\n\n self.check_valid_request_common()\n\n alg = self.get_POW().getSignatureA... | [
"0.5793122",
"0.5567499",
"0.5563664",
"0.54629576",
"0.5213004",
"0.5204793",
"0.52000326",
"0.51986754",
"0.5176573",
"0.51447785",
"0.5073272",
"0.50686526",
"0.5049018",
"0.5035825",
"0.50102144",
"0.49965826",
"0.49935395",
"0.49776056",
"0.49547967",
"0.49430102",
"0.48... | 0.7342247 | 0 |
Initialize a CSR with the given private key. | def init_csr(privkey, names, cert_dir):
csr_pem, csr_der = crypto_util.make_csr(privkey.pem, names)
# Save CSR
le_util.make_or_verify_dir(cert_dir, 0o755)
csr_f, csr_filename = le_util.unique_file(
os.path.join(cert_dir, "csr-letsencrypt.pem"), 0o644)
csr_f.write(csr_pem)
csr_f.close()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, private_key):\n self._sk = ed25519.Ed25519PrivateKey.from_private_bytes(private_key.bytes)",
"def __init__(self, private_key):\n if private_key:\n if isinstance(private_key, str): # base58 encoded string\n self.private_key = PrivateKey.from_b58check(pri... | [
"0.6662595",
"0.6491684",
"0.62229824",
"0.6218045",
"0.5923589",
"0.5906157",
"0.580049",
"0.57604295",
"0.575124",
"0.5738973",
"0.5713784",
"0.5662543",
"0.5661739",
"0.56311226",
"0.55743027",
"0.55241275",
"0.5469996",
"0.5456663",
"0.54260355",
"0.5422248",
"0.5337203",... | 0.7133996 | 0 |
Return a prettyprinted list of authenticators. This is used to provide helpful feedback in the case where a user specifies an invalid authenticator on the command line. | def list_available_authenticators(avail_auths):
output_lines = ["Available authenticators:"]
for auth_name, auth in avail_auths.iteritems():
output_lines.append(" - %s : %s" % (auth_name, auth.description))
return '\n'.join(output_lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_credentials():\n creds = load_auth()\n max_username_len = max([len(c.username) for c in creds]) if len(creds) > 0 else 1\n long_format = f\"{{:{max_username_len}}} for {{}}\"\n for cred in creds:\n if len(cred.hostname) > 0:\n print(str.format(long_format, cred.username, cred... | [
"0.6331459",
"0.6163005",
"0.5650981",
"0.54799366",
"0.5428169",
"0.5371491",
"0.53567785",
"0.53187954",
"0.53137565",
"0.5212743",
"0.5212743",
"0.52097934",
"0.51771253",
"0.51708394",
"0.51660407",
"0.5134235",
"0.5134235",
"0.5134235",
"0.5087354",
"0.5084113",
"0.50451... | 0.7218606 | 0 |
Returns a valid installer if one exists. | def determine_installer(config):
installer = configurator.ApacheConfigurator(config)
try:
installer.prepare()
return installer
except errors.LetsEncryptNoInstallationError:
logging.info("Unable to find a way to install the certificate.")
return
except errors.LetsEncryptMi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installer_exists(self, platform):\n \n validations.validate_platform(platform)\n \n installer_filename = os.path.join(\n settings.CUSTOM_INSTALLER_ROOT,\n self.build_id,\n constants.PLATFORM_BUNDLES[platform]\n )\n\n if os.path.isfile(installer_filename):\n return True\n ... | [
"0.66745645",
"0.61030173",
"0.59760803",
"0.5898045",
"0.5839286",
"0.57858944",
"0.56931084",
"0.5667762",
"0.5666709",
"0.54954135",
"0.549522",
"0.5488774",
"0.5474611",
"0.5472997",
"0.54724383",
"0.54243165",
"0.5413747",
"0.5412831",
"0.53674227",
"0.53658205",
"0.5363... | 0.6644679 | 1 |
View checkpoints and associated configuration changes. | def view_config_changes(config):
rev = reverter.Reverter(config)
rev.recovery_routine()
rev.view_config_changes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view():\n\n checkpoint_ini = parse_checkpoint_ini()\n run_start = checkpoint_ini[\"refget_ena_checkpoint\"][\"run_start\"]\n msg = \"the ena-refget-scheduler is currently configured to run, starting \" \\\n + \"from \" + run_start\n print(msg)",
"def checkpoint():",
"def get_checkpoint... | [
"0.66507006",
"0.6285918",
"0.6065834",
"0.603866",
"0.58703905",
"0.5818231",
"0.5809555",
"0.57875395",
"0.57503515",
"0.5697601",
"0.5572607",
"0.547665",
"0.54625833",
"0.54475665",
"0.5433728",
"0.54157144",
"0.5384229",
"0.53772664",
"0.53664726",
"0.53506774",
"0.53380... | 0.6468744 | 1 |
Obtains the default parameters of a given function | def get_default_args(func):
signature = inspect.signature(func)
return {
k: v.default
for k, v in signature.parameters.items()
if v.default is not inspect.Parameter.empty
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_function_defaults(func: FunctionType) -> dict[str, Any]:\n # extracted bit from inspect.signature... ~20x faster\n pos_count = func.__code__.co_argcount\n arg_names = func.__code__.co_varnames\n\n defaults = func.__defaults__ or ()\n\n non_default_count = pos_count - len(defaults)\n posi... | [
"0.73477733",
"0.7288057",
"0.7280551",
"0.70169824",
"0.6875487",
"0.67511314",
"0.6725294",
"0.66951275",
"0.6673985",
"0.6574556",
"0.6523648",
"0.6504465",
"0.64853233",
"0.6465845",
"0.64602757",
"0.64588624",
"0.6443178",
"0.644025",
"0.6364359",
"0.6348473",
"0.6313806... | 0.8058185 | 0 |
Finds all intervals whose intersection with interval is not empty; also includes the two intervals the the most left and right if their bounds are directly adjacent to the interval. For example, if intervals | def _intersect_continuous(self, interval):
first = self.intervals.bisect_left(interval)
last = first
while first > 0 and \
self.intervals[first - 1].upper >= interval.lower:
first -= 1
while last < len(self.intervals) and \
self.intervals[last].low... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _intersect(self, interval):\n first = self.intervals.bisect_left(interval)\n last = first\n while first > 0 and \\\n self.intervals[first - 1].upper > interval.lower:\n first -= 1\n while last < len(self.intervals) and \\\n self.intervals[last].l... | [
"0.6984863",
"0.68426615",
"0.6547715",
"0.6345982",
"0.63416725",
"0.6314008",
"0.62963027",
"0.61132616",
"0.6088061",
"0.6055544",
"0.60514873",
"0.604896",
"0.6028177",
"0.59506124",
"0.5944684",
"0.5918375",
"0.59061253",
"0.58586055",
"0.58248776",
"0.5774604",
"0.57628... | 0.7120677 | 0 |
Returns the interval that contains the given value. | def find(self, value):
index = self.intervals.bisect_left(value)
if index < len(self.intervals) and self.intervals[index].lower == value:
return self.intervals[index]
if index > 0 and self.intervals[index - 1].contains(value):
return self.intervals[index - 1]
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sInterval(self, val):\n\n # NB: the support attribute has been added by precomputing __levels__\n if val in self.support:\n return self.support[val]\n else:\n return ()",
"def bucket_for_value(self, value):\n\n # bisect.bisect_left is wrong because the buckets ar... | [
"0.6415075",
"0.640243",
"0.6171111",
"0.58560824",
"0.5777766",
"0.5751155",
"0.5747634",
"0.5731073",
"0.57169926",
"0.5665486",
"0.56112486",
"0.5604937",
"0.5587684",
"0.5583798",
"0.5580682",
"0.554691",
"0.5525837",
"0.5458978",
"0.5443137",
"0.5435141",
"0.54153574",
... | 0.6968875 | 0 |
Returns true if the list of intervals has a nonempty intersection with the given interval. | def contains(self, interval):
first, last = self._intersect(interval)
return first != last | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonempty_intersection(list1, list2):\n return len(list(set(list1) & set(list2))) > 0",
"def contained(query, intervalset):\n for i in intervalset:\n if query == i:\n continue\n if query[0] <= i[0] and i[1] <= query[1] and i[1]-i[0] < query[1]-query[0]:\n return True\... | [
"0.6759993",
"0.6712391",
"0.6578984",
"0.63830465",
"0.6372813",
"0.63056445",
"0.6305205",
"0.62501127",
"0.6247075",
"0.61667806",
"0.61011416",
"0.60497814",
"0.6042947",
"0.6014867",
"0.5922014",
"0.59006834",
"0.58882004",
"0.58832395",
"0.5868606",
"0.5864699",
"0.5856... | 0.7866244 | 0 |
Takes a function which has an image as first parameter and additional parameters. It will build a user interface consisting of sliders for numeric parameters and parameters that are called "footprint" or "selem". | def interact(func,
image = None,
*args,
continuous_update: bool = True,
context:dict = None,
zoom_factor:float = 1.0,
zoom_spline_order:int = 0,
colormap:str = None,
display_min:float = None,
display_max... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_image_slider(self,root, col, image_lookup, **kwargs):\n \n #Identify the different band/date options for the image\n datelist = image_lookup.times\n self.img_datenumlist[col] = datelist\n datemax = max(datelist)\n datemin = min(datelist)\n self.img_temporal... | [
"0.59492314",
"0.58823377",
"0.5813102",
"0.5797266",
"0.5716682",
"0.57114846",
"0.5660098",
"0.5641918",
"0.5588622",
"0.55765605",
"0.55563134",
"0.5538563",
"0.5538563",
"0.5528758",
"0.55118835",
"0.5509392",
"0.55007565",
"0.5497184",
"0.54856676",
"0.5482365",
"0.54449... | 0.67661536 | 0 |
Copy contents of INPUT to OUTPUT. | def inout(input_, output_):
while True:
chunk = input_.read(1024)
if not chunk:
break
output_.write(chunk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pcopy(self, finput, foutput):\n try:\n shutil.copy(finput, foutput)\n return foutput\n except Exception, inst:\n logging.error('Error copying item %s %s' % (finput, inst))",
"def _copy_output(src: Graph, dst: Graph):\n for n_src, n_dst in zip(src.nodes, dst.n... | [
"0.6793041",
"0.65745205",
"0.63736385",
"0.6193358",
"0.6180845",
"0.6087838",
"0.6087838",
"0.6087838",
"0.596382",
"0.5952388",
"0.5817657",
"0.57952285",
"0.579044",
"0.5725272",
"0.55530125",
"0.5551684",
"0.54511976",
"0.54485655",
"0.53873134",
"0.53839195",
"0.5335937... | 0.66262114 | 1 |
Return WeightCategory.light if weight is below 100 | def get_weight_category(self) -> WeightCategory:
return WeightCategory.light if self.weight < 100 else WeightCategory.heavy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weight(val):\n if val < 2000:\n category = 1\n elif val < 2500:\n category = 2\n elif val < 3000:\n category = 3\n elif val < 3500:\n category = 4\n else:\n category = 5\n return category",
"def determine_category(weight):\n if weight < 52:\n ... | [
"0.7417987",
"0.73116785",
"0.70457524",
"0.610788",
"0.6036151",
"0.600965",
"0.5996372",
"0.59807",
"0.5918444",
"0.5912966",
"0.5852581",
"0.58522236",
"0.58402485",
"0.58194506",
"0.5818266",
"0.5797188",
"0.5759666",
"0.57498014",
"0.57498014",
"0.57470405",
"0.5733884",... | 0.83896846 | 0 |
Save the current pipeline filename string | def save(self, filename):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_pipeline(pipeline: PreprocessingPipeline, file_path: str) -> None:\n joblib.dump(pipeline, file_path)",
"def get_file_save_path(self):\n return self.out",
"def save(self, filename):\n Util.savePickle(self.V, filename + self.ext, overwrite=True)\n return filename + self.ext",
... | [
"0.68182653",
"0.6487675",
"0.63291246",
"0.632411",
"0.6312835",
"0.6152312",
"0.61260337",
"0.61059463",
"0.6092734",
"0.60699147",
"0.60628194",
"0.6051216",
"0.60487574",
"0.60321116",
"0.6029036",
"0.59778935",
"0.5952204",
"0.59511393",
"0.5950124",
"0.59428847",
"0.594... | 0.6555935 | 1 |
Generates the request URL from the current configuration | def _create_request_url():
url = 'http'
if _config['save']:
url += 's'
url += '://{}:{}/move'.format(_config['ip'], _config['port'])
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_url(self, **kwargs):\n path = self.url_path.format(**kwargs)\n return self.poolbot.generate_url(path)",
"def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])",
"def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])",
"def ... | [
"0.721824",
"0.7209331",
"0.7209331",
"0.69944406",
"0.6989675",
"0.69785815",
"0.69451505",
"0.68943244",
"0.68182325",
"0.67998934",
"0.67701226",
"0.67488253",
"0.67421484",
"0.6715558",
"0.66829664",
"0.6666364",
"0.66588897",
"0.6623801",
"0.66123635",
"0.6598798",
"0.65... | 0.7477527 | 0 |
Clamps a given value between 0 and 100. | def _clamp_percent(value):
if value < 0:
print("Less than 0 percent specified for extension. Clamping to 0")
value = 0
elif value > 100:
print("More than 100 percent specified for extension. Clamping to 100")
value = 100
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def progress(self, value: float) -> None:\n\n if not isinstance(value, (float, int)):\n raise TypeError(\"'progress' must be an int or a float\")\n\n if not 0.0 <= value <= 100.0:\n raise ValueError(\"'progress' must be between 0 and 100\")\n\n self.value = (self.minimum ... | [
"0.644391",
"0.6419334",
"0.6357371",
"0.63314104",
"0.6270618",
"0.6267849",
"0.6004641",
"0.59831536",
"0.59443235",
"0.587679",
"0.58697486",
"0.57907295",
"0.578396",
"0.5778939",
"0.5778939",
"0.57556087",
"0.57552505",
"0.57388103",
"0.5727426",
"0.57240736",
"0.5692986... | 0.6761129 | 0 |
Moves only finger 3 | def move_finger3(percent):
percent = _clamp_percent(percent)
_send_request(f3=percent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def touch_moved(self, touch):\n\t\tpass",
"def _onmove(self, event):",
"def swipe_up(self):\n self.swipe_sub(SWIPE_MATRIX[0])",
"def swipe_left(self):\n self.swipe_sub(SWIPE_MATRIX[2])",
"def swipe_down(self):\n self.swipe_sub(SWIPE_MATRIX[1])",
"def swipe_right(self):\n self.swipe_sub(SWIPE_... | [
"0.64191765",
"0.6339757",
"0.632178",
"0.6293377",
"0.6200789",
"0.61120355",
"0.604334",
"0.5952558",
"0.58822125",
"0.5872052",
"0.58482933",
"0.579677",
"0.57699287",
"0.5664202",
"0.5617458",
"0.56039137",
"0.56023604",
"0.55979705",
"0.55355144",
"0.55170023",
"0.54953"... | 0.6498123 | 0 |
Moves only finger 4 | def move_finger4(percent):
percent = _clamp_percent(percent)
_send_request(f4=percent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swipe_down(self):\n self.swipe_sub(SWIPE_MATRIX[1])",
"def swipe_up(self):\n self.swipe_sub(SWIPE_MATRIX[0])",
"def swipe_left(self):\n self.swipe_sub(SWIPE_MATRIX[2])",
"def swipe_right(self):\n self.swipe_sub(SWIPE_MATRIX[3])",
"def touch_moved(self, touch):\n\t\tpass",
"def swipe_custo... | [
"0.6689306",
"0.6638608",
"0.6551361",
"0.6368069",
"0.62984794",
"0.62259203",
"0.6206484",
"0.61248684",
"0.61006",
"0.59894186",
"0.5966782",
"0.59463024",
"0.59280175",
"0.59031177",
"0.57198715",
"0.56752115",
"0.5637842",
"0.56301886",
"0.56095576",
"0.56090075",
"0.559... | 0.6736132 | 0 |
Moves only finger 5 | def move_finger5(percent):
percent = _clamp_percent(percent)
_send_request(f5=percent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swipe_up(self):\n self.swipe_sub(SWIPE_MATRIX[0])",
"def swipe_down(self):\n self.swipe_sub(SWIPE_MATRIX[1])",
"def touch_moved(self, touch):\n\t\tpass",
"def swipe_left(self):\n self.swipe_sub(SWIPE_MATRIX[2])",
"def fingersUp(self):\n if self.results.multi_hand_landmarks:\n ... | [
"0.67952645",
"0.6657354",
"0.6362415",
"0.63382995",
"0.6288324",
"0.6212782",
"0.614672",
"0.6109046",
"0.61084604",
"0.6058535",
"0.6004932",
"0.60000765",
"0.5979154",
"0.59647727",
"0.5864887",
"0.58220947",
"0.57626927",
"0.57403046",
"0.5732824",
"0.57087994",
"0.56838... | 0.6947202 | 0 |
Moves all fingers specified. Unspecified fingers are not moved | def move_fingers(f1=None, f2=None, f3=None, f4=None, f5=None):
_send_request(f1=f1, f2=f2, f3=f3, f4=f4, f5=f5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fingersUp(self):\n if self.results.multi_hand_landmarks:\n myHandType = self.handType()\n fingers = []\n # Thumb\n if myHandType == \"Right\":\n if self.lmList[self.tipIds[0]][0] > self.lmList[self.tipIds[0] - 1][0]:\n fingers... | [
"0.59477055",
"0.5464951",
"0.54011834",
"0.53890765",
"0.538133",
"0.5363548",
"0.53362304",
"0.5334102",
"0.5320563",
"0.53048086",
"0.5253581",
"0.5234333",
"0.5226731",
"0.5207482",
"0.51770127",
"0.5175296",
"0.51630193",
"0.51505476",
"0.5148043",
"0.5097894",
"0.508835... | 0.66540396 | 0 |
Returns the extra property by deserializing json. | def extra_dejson(self):
obj = {}
if self.extra:
try:
obj = json.loads(self.extra)
except Exception as e:
self.log.exception(e)
self.log.error("Failed parsing the json for conn_id %s", self.conn_id)
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dehydrate_extra_info(self, bundle):\n extra_info = bundle.data[\"extra_info\"]\n return json.loads(extra_info)",
"def hydrate_extra_info(self, bundle):\n extra_info = bundle.data[\"extra_info\"]\n bundle.data[\"extra_info\"] = json.dumps(extra_info)\n return bundle",
"def... | [
"0.6902196",
"0.5978063",
"0.5851503",
"0.5814144",
"0.579946",
"0.5658456",
"0.5567919",
"0.5516422",
"0.5420939",
"0.5364987",
"0.5308122",
"0.52956736",
"0.528454",
"0.52662367",
"0.5247607",
"0.52170336",
"0.5194579",
"0.5184684",
"0.5183095",
"0.5161317",
"0.5160275",
... | 0.66149604 | 1 |
Performs asynchronous video annotation. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse` (results). | def AnnotateVideo(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AnnotateVideo(self, request, timeout, metadata=None, with_call=False, protocol_options=None):\n raise NotImplementedError()",
"def AnnotateVideo(self, request, context):\n context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)",
"def main(path):\n video_client = (video_intelligence_service_cli... | [
"0.7315971",
"0.70176625",
"0.65501726",
"0.6327487",
"0.59404576",
"0.5624183",
"0.52494824",
"0.5219432",
"0.5201209",
"0.5173514",
"0.51656777",
"0.51656777",
"0.50802267",
"0.50043",
"0.49611413",
"0.4937006",
"0.490764",
"0.49012944",
"0.48988557",
"0.4893339",
"0.487196... | 0.723071 | 1 |
Performs asynchronous video annotation. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse` (results). | def AnnotateVideo(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AnnotateVideo(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def AnnotateVideo(self, request, context):\n context.code(beta_interfaces.StatusCode.UNIMPLEM... | [
"0.72307897",
"0.70175517",
"0.6549578",
"0.63271254",
"0.59403425",
"0.56237847",
"0.52499396",
"0.521891",
"0.5198639",
"0.5172917",
"0.5165079",
"0.5165079",
"0.5078916",
"0.5003412",
"0.49612385",
"0.49378994",
"0.4906793",
"0.4901073",
"0.4897856",
"0.4893443",
"0.487146... | 0.73167396 | 0 |
Return current position in the playlist. | def current_position(self):
# It is an error to call playlist_current_pos when there are
# no entries in the playlist.
r = self.x.playlist_current_pos()
r.wait()
if r.iserror():
print r.get_error()
return None
else:
return r.get_dict()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pos(self):\n if self.player is not None and self.state == \"play\":\n return self.player.get_position() * self._length\n return 0",
"def getPos(self):\n return self.__current_pos",
"def getPosition(self):\n\t\treturn self._position",
"def getPosition(self):\n c ... | [
"0.72907823",
"0.72334886",
"0.71842074",
"0.70870906",
"0.70748407",
"0.70671594",
"0.70632356",
"0.70553964",
"0.7027637",
"0.69953215",
"0.6994251",
"0.6994251",
"0.69723934",
"0.6939658",
"0.6934166",
"0.6929382",
"0.6924035",
"0.69078207",
"0.6903585",
"0.6903585",
"0.68... | 0.8807843 | 0 |
Format the playlist. First we try to get imformation from id3v2, if it fails, then try id3, else we just display the file name. | def playlist(self):
def iconv(s):
encoding = self.options["id3_encoding"]
try:
if encoding:
return s.encode('latin1').decode(encoding).encode('utf-8')
else:
return s.encode('latin1')
except UnicodeEncodeE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_artist_playlist(data):\n\n return data['artist'].lower() + '.m3u'",
"def playlist_path(folder, listname):\n\n listname = listname.title().strip()\n for char in ['(', ')', '\\'', '\"', '[', ']']:\n listname = listname.replace(char, '')\n\n for char in [' ', '..', ',', '!', '%', '#', '$... | [
"0.6020709",
"0.5806393",
"0.5733228",
"0.56966054",
"0.56933445",
"0.5669772",
"0.5588807",
"0.5558669",
"0.55062515",
"0.5453322",
"0.54057676",
"0.5354579",
"0.53537184",
"0.5329299",
"0.5302947",
"0.5240767",
"0.51461214",
"0.51454216",
"0.5113975",
"0.51043195",
"0.50992... | 0.7094906 | 0 |
Return the path enterd by the user, and expand it to full path. Or return None if user haven't enter anything. | def _get_path(self, prompt):
# When input from vim, vim escapes some special characters,
# so we have to expand them first.
cwd = vim.eval('expand(getcwd())')
path = vim.eval('expand(input("%s", "", "file"))' % prompt)
if path == None or path == "":
return None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expandpath(path):\n return os.path.abspath(os.path.expanduser(path))",
"def ExpandPath(path):\n return os.path.realpath(os.path.expanduser(path))",
"def _expand_user(pathname):\n if pathname is None:\n return None\n return os.path.expanduser(pathname)",
"def _expand_path(self, path):\n ... | [
"0.701796",
"0.69979906",
"0.69848454",
"0.6846124",
"0.6750263",
"0.6637421",
"0.6621986",
"0.65670943",
"0.65670943",
"0.6548268",
"0.6530939",
"0.6514642",
"0.65087",
"0.64645237",
"0.6422876",
"0.64026284",
"0.63754237",
"0.63738966",
"0.6322379",
"0.6271761",
"0.6271761"... | 0.73424494 | 0 |
Remove all lines in the window. | def _clear_window(self):
self.buf[:] = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self):\r\n\r\n # Remove strip from window.\r",
"def clear():\n # TODO: this should actually create a stack of output so I can test each screen\n lines.clear()",
"def on_delete():\r\n del win.box[-1] # delete last line\r\n #del win.box[0:-1] # delete all lines \r",
"def clear(se... | [
"0.7301641",
"0.7279528",
"0.7139925",
"0.66498876",
"0.66300887",
"0.6614216",
"0.66036093",
"0.66000986",
"0.65959686",
"0.654497",
"0.6446526",
"0.6431307",
"0.6417026",
"0.6406483",
"0.64032495",
"0.6378448",
"0.63687396",
"0.6364384",
"0.63430387",
"0.63285035",
"0.63211... | 0.7381883 | 0 |
Refresh the play window. | def refresh_window(self):
self.buf[:] = self.player.playlist()
if self.prev_song != None:
self.refresh_mark() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n\n self.play_button.update()",
"def refresh(self) -> None:\n self.screen.refresh()",
"def refresh_screen(self):",
"def update(self):\n tic = time.time()\n if self.playing:\n self.show_frame()\n add_delay = np.maximum(1, self.delay - int(1000 * ... | [
"0.7166713",
"0.70254606",
"0.69841933",
"0.67970204",
"0.6679304",
"0.6632935",
"0.66300607",
"0.6615464",
"0.6589678",
"0.6472276",
"0.64674264",
"0.64280564",
"0.6319701",
"0.6315739",
"0.6311794",
"0.62941366",
"0.6293278",
"0.6285521",
"0.62836045",
"0.6272975",
"0.62462... | 0.8164715 | 0 |
Force the use of the Python implementation of the kernels | def usePython():
global kernels_imp
from .import _kernels_py
kernels_imp = _kernels_py | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def useCython():\n global kernels_imp\n if HAS_CYTHON:\n import _kernels\n kernels_imp = _kernels",
"def disable_custom_kernel():\n global _TF_ADDONS_PY_OPS\n _TF_ADDONS_PY_OPS = True",
"def enable_custom_kernel():\n global _TF_ADDONS_PY_OPS\n _TF_ADDONS_PY_OPS = False",
"def ... | [
"0.72462285",
"0.6898357",
"0.6800832",
"0.6573258",
"0.6546711",
"0.6196151",
"0.60771745",
"0.605744",
"0.6045068",
"0.60027415",
"0.5999834",
"0.5980022",
"0.59685665",
"0.5958165",
"0.59550774",
"0.58325624",
"0.5783384",
"0.57637435",
"0.57587177",
"0.57398534",
"0.57245... | 0.777145 | 0 |
Force the use of the Cython implementation of the kernels, if available | def useCython():
global kernels_imp
if HAS_CYTHON:
import _kernels
kernels_imp = _kernels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usePython():\n global kernels_imp\n from .import _kernels_py\n kernels_imp = _kernels_py",
"def enable_custom_kernel():\n global _TF_ADDONS_PY_OPS\n _TF_ADDONS_PY_OPS = False",
"def disable_custom_kernel():\n global _TF_ADDONS_PY_OPS\n _TF_ADDONS_PY_OPS = True",
"def run_cython(args)... | [
"0.7006426",
"0.6426009",
"0.6299531",
"0.6045827",
"0.6042446",
"0.5838073",
"0.5834325",
"0.5812497",
"0.57602876",
"0.5702271",
"0.56543547",
"0.55847263",
"0.55847263",
"0.5576387",
"0.551406",
"0.55089873",
"0.54912657",
"0.5465722",
"0.5465613",
"0.544372",
"0.543749",
... | 0.8665309 | 0 |
Returns some functionalities of a module that is declared in a MARA_XXX variable or function `module.MARA_XXX` can be a function that returns a list or dict a list a dict | def module_functionalities(module: types.ModuleType, MARA_XXX: str, type) -> []:
if MARA_XXX in dir(module):
functionalities = getattr(module, MARA_XXX)
if isinstance(functionalities, typing.Callable):
functionalities = functionalities()
if isinstance(functionalities, typing.Dict... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_Module(self, node):\n self.generic_visit(node)\n return self.functions",
"def get_functions():\n\treturn [f for f in globals() if f.startswith('make_')]",
"def get_function_list_from_modlist(self):\n function_list = []\n function_name_list = []\n for module in self.... | [
"0.56044304",
"0.5527872",
"0.5335388",
"0.5322824",
"0.5253143",
"0.5246537",
"0.5238433",
"0.52223736",
"0.52200794",
"0.519914",
"0.5157953",
"0.5104779",
"0.50816864",
"0.50669056",
"0.5032951",
"0.5019011",
"0.5016719",
"0.5014803",
"0.50049627",
"0.50009996",
"0.4997424... | 0.6977681 | 0 |
Searches for all declared click commands and adds them to the app, grouped by package | def register_commands(self):
for module in copy.copy(sys.modules).values():
for command in module_functionalities(module, 'MARA_CLICK_COMMANDS', click.Command):
if 'callback' in command.__dict__ and command.__dict__['callback']:
package = command.__dict__['callbac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands():",
"def register_cli_commands(app):\n app.cli.add_command(init_events_command)",
"def register_target_commands():\n for plugin_cls in env.plugins.values():\n # Add target group to root commands. E.g. create `nursery vbox`\n cli.add_command(plugin_cls.cli_entry_func, plugin_cl... | [
"0.6072847",
"0.6044353",
"0.6014297",
"0.6014281",
"0.6011811",
"0.5989786",
"0.5964724",
"0.5949766",
"0.5949766",
"0.5949766",
"0.5949766",
"0.58894944",
"0.5863761",
"0.5849069",
"0.5799717",
"0.57687044",
"0.5768184",
"0.57478505",
"0.574516",
"0.57421625",
"0.5730498",
... | 0.74958783 | 0 |
Adds a global layout with navigation etc. to pages | def register_page_layout(self):
def after_request(r: flask.Response):
if isinstance(r, response.Response):
r.set_data(layout.layout(r))
return r
self.after_request(after_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_aqa_layout():\n\n layout = html.Div(\n [\n # html.Div(\n # id=server.config['NAVBAR_CONTAINER_ID'],\n # children=[\n # navbar\n # ],\n # # id=\"header\",\n # # children=[\n # #... | [
"0.6608332",
"0.6538365",
"0.65128875",
"0.6435",
"0.63568664",
"0.59828746",
"0.597046",
"0.5889812",
"0.5854213",
"0.58331037",
"0.58001673",
"0.5751567",
"0.57339054",
"0.57183653",
"0.5718219",
"0.5707796",
"0.57010144",
"0.5686978",
"0.5686766",
"0.56370133",
"0.5602372"... | 0.6710435 | 0 |
Disable caching for dynamic content (not static files). | def disable_caching(self):
def after_request(r: flask.Response):
if 'Cache-Control' not in r.headers:
r.headers['Cache-Control'] = 'no-store'
return r
self.after_request(after_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def never_cache_preview(response):\n response.cache_control.max_age = 0\n response.cache_control.no_cache = True\n response.cache_control.must_revalidate = True\n response.cache_control.no_store = True\n return response",
"def never_cache_preview(self, response):\n response.cache_control.ma... | [
"0.7092343",
"0.70306313",
"0.690711",
"0.6602129",
"0.6305631",
"0.6288433",
"0.62292707",
"0.6228628",
"0.62192315",
"0.62074226",
"0.618343",
"0.61324775",
"0.59976",
"0.58603257",
"0.57819825",
"0.576283",
"0.57446533",
"0.5743523",
"0.5735214",
"0.5721677",
"0.567774",
... | 0.7300828 | 0 |
Sets up error pages for all http exceptions | def register_error_handlers(self):
def error_handler(error):
if not isinstance(error, exceptions.HTTPException):
error = exceptions.InternalServerError()
return response.Response(bootstrap.card(body=_.span[_.p(style='color:#888')[error.description or ''],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_page(e):\n \n return render_template('error-page.html'), 404",
"def error(self, environ, start_response):\n \n \"Generate an error report\"\n status = '200 Handle error'\n headers = [('Content-type','text/html')]\n start_response(status, headers)\n trace ... | [
"0.7027386",
"0.69139487",
"0.6871281",
"0.6850971",
"0.6837334",
"0.68211776",
"0.6773725",
"0.6649318",
"0.6513413",
"0.6511387",
"0.65087426",
"0.64759547",
"0.63982475",
"0.6384036",
"0.6358062",
"0.63567585",
"0.6349047",
"0.63481885",
"0.63280517",
"0.6322861",
"0.63191... | 0.71211606 | 0 |
Caches calls to flask.url_for because it's kind of slow | def patch_flask_url_for(self):
original_url_for = flask.url_for
flask.url_for = functools.lru_cache(maxsize=None)(original_url_for) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_busting_url_for(app, old_url_for, bust_extensions=True):\n\n if not bust_extensions:\n return old_url_for\n\n url_default = cache_busting_url_defaults_factory(app, bust_extensions)\n\n def url_for_wrapper(endpoint, **values):\n url_default(endpoint, values)\n return old_url_... | [
"0.6512673",
"0.60595435",
"0.594461",
"0.5918268",
"0.5722673",
"0.57085675",
"0.5698482",
"0.5518071",
"0.54887503",
"0.5421004",
"0.53958017",
"0.5387166",
"0.5387166",
"0.5371704",
"0.5352413",
"0.53180844",
"0.5313078",
"0.53075707",
"0.5295109",
"0.5282865",
"0.5254678"... | 0.79611677 | 0 |
Register a new command to a mara flask app. Args | def register_command(app: MaraApp, command: click.Command, package: str):
if isinstance(command, click.MultiCommand):
app.cli.add_command(command)
else:
command.name = package + '.' + command.name
app.cli.add_command(command) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_register(self, app_path=None):\n if app_path:\n app_path = os.path.abspath(app_path)\n else:\n app_path = os.getcwd()\n app_name = os.path.basename(app_path)\n rc = self.socket_command('register %s %s' % (app_name, app_path))\n return rc",
"def reg... | [
"0.6357048",
"0.61959845",
"0.60008824",
"0.5996493",
"0.5918416",
"0.58472395",
"0.5844733",
"0.58145416",
"0.58084494",
"0.5772932",
"0.5771889",
"0.57299614",
"0.5701481",
"0.56389594",
"0.5586934",
"0.5578795",
"0.5571675",
"0.5562538",
"0.5543351",
"0.55432576",
"0.55425... | 0.69254464 | 0 |
Collects and merges all instances of NavigationEntry | def combine_navigation_entries() -> navigation.NavigationEntry:
navigation_root = config.navigation_root()
def all_children(navigation_entry: navigation.NavigationEntry) -> {navigation.NavigationEntry}:
return functools.reduce(set.union, [all_children(child) for child in navigation_entry.children],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(self):\n rdr = Reader(self.config)\n rdr.read_string(utils.paste(single_line=False))\n if len(rdr.get_entry_collection().entries) == 0:\n self.visual.error(\"Zero items extracted from the collection to merge.\")\n return\n eids = []\n for entry in ... | [
"0.56151354",
"0.5239275",
"0.51825905",
"0.5168562",
"0.51249605",
"0.50111085",
"0.49857306",
"0.49561042",
"0.4939648",
"0.49259186",
"0.492225",
"0.4904463",
"0.48954496",
"0.48853442",
"0.48335615",
"0.4824833",
"0.47702527",
"0.4729195",
"0.46782616",
"0.4672069",
"0.46... | 0.6902916 | 0 |
Apply a processing method (in "filtering", "removal", and "reconstruction" module) to multiple sinograms or multiple slices in parallel. | def apply_method_to_multiple_sinograms(data, method, para, ncore=None,
prefer="threads"):
if ncore is None:
ncore = np.clip(mp.cpu_count() - 1, 1, None)
else:
ncore = np.clip(ncore, 1, None)
if not isinstance(para, list):
para = tuple(list([para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(dataset, f):\n logger.info('processing dataset ({0})'.format(len(dataset.samples)))\n for sample in dataset.samples:\n sample.proc = f(sample.image)",
"def _parallel_transform(self, **kwargs):\n self.clean_input_references()\n data = np.asarray([self.x, self.y]).swapaxes(0,... | [
"0.6452649",
"0.5789003",
"0.5785394",
"0.5679618",
"0.5607772",
"0.55986285",
"0.5585968",
"0.5559735",
"0.5530524",
"0.54978085",
"0.5460731",
"0.54582155",
"0.5395217",
"0.5357475",
"0.5324024",
"0.5298265",
"0.52925944",
"0.5287494",
"0.52723575",
"0.5265221",
"0.52371544... | 0.687348 | 0 |
Sort grayscales of an image using an index array provided. e.g. axis=0 is to sort each column. | def sort_backward(mat, mat_index, axis=0):
if axis == 0:
mat = np.transpose(mat)
mat_index = np.transpose(mat_index)
mat_comb = np.asarray(np.dstack((mat_index, mat)))
mat_comb_sort = np.asarray(
[row[row[:, 0].argsort()] for row in mat_comb])
mat_sort = mat_comb_sort[:, :, 1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_sort():\n to_concat = []\n for centroid_rgb, cluster in itertools.izip(centroids_rgb, self.clusters):\n # no need to revisit ratio\n new_idxed_arr = tf.concat(1,[tf.slice(cluster, [0,0], [-1,2]),\n tf.tile(tf.... | [
"0.6611781",
"0.59149987",
"0.5908737",
"0.5722982",
"0.56885856",
"0.5682432",
"0.5657325",
"0.56233776",
"0.5588275",
"0.5572546",
"0.5521448",
"0.54415333",
"0.5436674",
"0.541334",
"0.5359485",
"0.53582484",
"0.53416955",
"0.53336537",
"0.53295296",
"0.52899086",
"0.52670... | 0.6041535 | 1 |
Create a 2d window from the 1D Butterworth window. | def make_2d_butterworth_window(width, height, u, v, n):
xcenter = np.ceil(width / 2.0) - 1.0
ycenter = np.int16(np.ceil(height / 2.0) - 1)
xlist = np.arange(width) - xcenter
window = 1.0 / (1.0 + np.power(xlist / u, 2 * n))
row1 = ycenter - np.int16(v)
row2 = ycenter + np.int16(v) + 1
window... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_2d_damping_window(width, height, size, window_name=\"gaussian\"):\n xcenter = np.ceil(width / 2.0) - 1.0\n xlist = np.arange(width) - xcenter\n if window_name == \"butter\":\n window = 1.0 - 1.0 / (1.0 + np.power(xlist / size, 2))\n else:\n window = 1.0 - np.exp(-xlist ** 2 / (2 ... | [
"0.7059521",
"0.6416937",
"0.6311304",
"0.6150198",
"0.5939637",
"0.58738095",
"0.5861688",
"0.5794663",
"0.5789335",
"0.5786792",
"0.5675906",
"0.56686616",
"0.56457996",
"0.553664",
"0.5521011",
"0.55055463",
"0.5476828",
"0.5446436",
"0.5443772",
"0.54400194",
"0.54275703"... | 0.7624349 | 0 |
Apply 2D wavelet decomposition. | def apply_wavelet_decomposition(mat, wavelet_name, level=None):
(nrow, ncol) = mat.shape
max_level = int(
min(np.floor(np.log2(nrow / 16.0)), np.floor(np.log2(ncol / 16.0))))
if (level is None) or (level > max_level) or (level < 1):
level = max_level
return pywt.wavedec2(mat, wavelet_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def waverec2(coeffs: list, wavelet: pywt.Wavelet) -> torch.Tensor:\n _, _, rec_lo, rec_hi = get_filter_tensors(\n wavelet, flip=False, device=coeffs[0].device,\n dtype=coeffs[0].dtype\n )\n filt_len = rec_lo.shape[-1]\n rec_filt = construct_2d_filt(lo=rec_lo, hi=rec_hi)\n\n res_ll = co... | [
"0.62614673",
"0.59200215",
"0.5882183",
"0.5871252",
"0.5861618",
"0.5827009",
"0.58093065",
"0.576397",
"0.5734702",
"0.5710951",
"0.5707806",
"0.5675571",
"0.5626172",
"0.559099",
"0.55336034",
"0.5517627",
"0.55100024",
"0.5463128",
"0.545735",
"0.5455791",
"0.5446567",
... | 0.63937974 | 0 |
Apply 2D wavelet reconstruction. | def apply_wavelet_reconstruction(data, wavelet_name, ignore_level=None):
if ignore_level is not None:
level = len(data[1:])
if level >= ignore_level > 0:
data[-ignore_level] = tuple(
[np.zeros_like(v) for v in data[-ignore_level]])
return pywt.waverec2(data, wavelet_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def waverec2(coeffs: list, wavelet: pywt.Wavelet) -> torch.Tensor:\n _, _, rec_lo, rec_hi = get_filter_tensors(\n wavelet, flip=False, device=coeffs[0].device,\n dtype=coeffs[0].dtype\n )\n filt_len = rec_lo.shape[-1]\n rec_filt = construct_2d_filt(lo=rec_lo, hi=rec_hi)\n\n res_ll = co... | [
"0.611545",
"0.5956124",
"0.58984673",
"0.5615998",
"0.55477166",
"0.55310637",
"0.54952914",
"0.540846",
"0.5387496",
"0.53681135",
"0.53132504",
"0.5295372",
"0.5292433",
"0.52886367",
"0.5280714",
"0.5280384",
"0.52797097",
"0.5272976",
"0.5249801",
"0.5245885",
"0.5240446... | 0.6055833 | 1 |
Create a 2D Gaussian window. | def make_2d_gaussian_window(height, width, sigma_x, sigma_y):
xcenter = (width - 1.0) / 2.0
ycenter = (height - 1.0) / 2.0
y, x = np.ogrid[-ycenter:height - ycenter, -xcenter:width - xcenter]
window = np.exp(
-(x ** 2 / (2 * sigma_x ** 2) + y ** 2 / (2 * sigma_y ** 2)))
return window | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_window(n1, n2, sig=1, mu=0):\r\n x, y = np.meshgrid(np.linspace(-1, 1, n1), np.linspace(-1, 1, n2))\r\n d = np.sqrt(x * x + y * y)\r\n g = np.exp(-((d - mu) ** 2 / (2.0 * sig ** 2)))\r\n return g",
"def make_2d_damping_window(width, height, size, window_name=\"gaussian\"):\n xcenter =... | [
"0.7276683",
"0.6490135",
"0.646621",
"0.6196657",
"0.6057666",
"0.5948625",
"0.5936483",
"0.58805376",
"0.5854782",
"0.57774085",
"0.57506824",
"0.574685",
"0.57253414",
"0.5724446",
"0.5675455",
"0.56753045",
"0.56702775",
"0.5629053",
"0.5621158",
"0.5620497",
"0.56152564"... | 0.8027462 | 0 |
Apply a regularization filter using the method in Ref. [1]. Note that it's computationally costly. | def apply_regularization_filter(mat, alpha, axis=1, ncore=None):
if ncore is None:
ncore = np.clip(mp.cpu_count() - 1, 1, None)
if axis == 0:
mat = np.transpose(mat)
(nrow, ncol) = mat.shape
sijmat = calculate_regularization_coefficient(ncol, alpha)
mat = np.asarray(Parallel(n_jobs=n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_regularization(self, w, loss, gradient, regularization, lambda_, m):\n if regularization == 'l2':\n loss += lambda_ / (2 * m) * np.squeeze(w.T.dot(w))\n gradient += lambda_ / m * w\n elif regularization == 'l1':\n loss += lambda_ / (2 * m) * np.sum(np.abs(w)... | [
"0.6744347",
"0.6413927",
"0.6278393",
"0.62710255",
"0.61086816",
"0.5934986",
"0.58300555",
"0.5664429",
"0.55879325",
"0.5580832",
"0.5567977",
"0.55582017",
"0.5493147",
"0.5489993",
"0.54706573",
"0.5416242",
"0.5392259",
"0.5382913",
"0.5379253",
"0.53769124",
"0.537318... | 0.6635745 | 1 |
Transform a 1dwindow to 2dwindow. Useful for designing a Fourier filter. | def transform_1d_window_to_2d(win_1d):
width0 = len(win_1d)
if width0 % 2 == 0:
width = width0 + 1
else:
width = width0
center = width // 2
xlist = (1.0 * np.flipud(np.arange(width)) - center)
ylist = (1.0 * np.arange(width) - center)
x_mat, y_mat = np.meshgrid(xlist, ylist)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_2d_butterworth_window(width, height, u, v, n):\n xcenter = np.ceil(width / 2.0) - 1.0\n ycenter = np.int16(np.ceil(height / 2.0) - 1)\n xlist = np.arange(width) - xcenter\n window = 1.0 / (1.0 + np.power(xlist / u, 2 * n))\n row1 = ycenter - np.int16(v)\n row2 = ycenter + np.int16(v) + 1... | [
"0.62260526",
"0.6209474",
"0.6045855",
"0.60327876",
"0.5964988",
"0.5868593",
"0.58601874",
"0.58100694",
"0.57268065",
"0.56924224",
"0.55942947",
"0.55822676",
"0.5581943",
"0.55804086",
"0.554665",
"0.553414",
"0.54564714",
"0.5444648",
"0.5437239",
"0.5431811",
"0.54315... | 0.7334662 | 0 |
To check if there is a sample in a sinogram using the "doublewedge" property of the Fourier transform of the sinogram (Ref. [1]). | def detect_sample(sinogram, sino_type="180"):
check = True
if not (sino_type == "180" or sino_type == "360"):
raise ValueError("!!! Use only one of two options: '180' or '360'!!!")
if sino_type == "180":
sinogram = 1.0 * np.vstack((sinogram, np.fliplr(sinogram)))
sino_fft = np.abs(fft.ff... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sinusoid():\n generator = SignalGenerator(sr=100)\n data = generator.sinusoid(noise_stds=[0, 0, 0])\n freq_features = FrequencyFeature(data, sr=100)\n freq_features.fft().peaks()\n dom_freqs = freq_features.dominant_frequency(n=1)\n dom_freqs_second = freq_features.dominant_frequency(n=2... | [
"0.6393702",
"0.6336775",
"0.59539115",
"0.5945163",
"0.5863214",
"0.57758826",
"0.57501787",
"0.57374036",
"0.56885993",
"0.5666726",
"0.56422687",
"0.5627452",
"0.5620702",
"0.560367",
"0.5596088",
"0.5537708",
"0.5524099",
"0.5483683",
"0.5445321",
"0.54259104",
"0.5408239... | 0.7428693 | 0 |
Locate slice indices in gridrows given a slice index of the reconstruction data as a whole. | def locate_slice(slice_idx, height, overlap_metadata):
g_nrow = overlap_metadata.shape[0] + 1
side = overlap_metadata[0, 0, 1]
overlap_list = overlap_metadata[:, 0, 0]
if side == 1:
list_slices = [(np.arange(i * height, i * height + height) -
np.sum(overlap_list[0: i])) f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_grid_cell_indexes(proj, xs, ys, bounding_box):\n # Unpack values from the projection\n eq_rad = proj.semi_major_axis\n polar_rad = proj.semi_minor_axis\n h = proj.perspective_point_height + eq_rad\n lon0 = proj.longitude_of_projection_origin\n \n # Unpack values from the area we want ... | [
"0.5958152",
"0.59219956",
"0.5869313",
"0.5835724",
"0.57764643",
"0.56907445",
"0.5667128",
"0.56579983",
"0.56376743",
"0.5613551",
"0.5586603",
"0.55799395",
"0.55456376",
"0.5506378",
"0.55003256",
"0.54753995",
"0.54753995",
"0.54635495",
"0.54426223",
"0.54423785",
"0.... | 0.6077597 | 0 |
For visually finding the centerofrotation (COR) using converted 360degree sinograms from a 180degree sinogram at different CORs (Ref. [1]). | def find_center_visual_sinograms(sino_180, output, start, stop, step=1,
zoom=1.0):
(nrow, ncol) = sino_180.shape
output_name = losa.make_folder_name(output, name_prefix="Find_center",
zero_prefix=3)
output_base = output + "/" + output_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_corls():\n datar = data_from_fits(\"752_1_373_r.fits\")\n datar = other_object(datar)\n datag = data_from_fits(\"752_1_373_g.fits\")\n datag = other_object(datag)\n corl = correlate2d(datar, datag, mode=\"same\")\n plt.figure()\n plt.imshow(corl)\n\n datar = data_from_fits(\"752_1_... | [
"0.61447555",
"0.5897692",
"0.5861517",
"0.5743229",
"0.57168496",
"0.57027197",
"0.5699856",
"0.5693365",
"0.56487817",
"0.56342936",
"0.55531335",
"0.5528865",
"0.5495297",
"0.548835",
"0.54341674",
"0.5429243",
"0.54054964",
"0.5403633",
"0.5390816",
"0.538958",
"0.5378961... | 0.666108 | 0 |
For visually finding the centerofrotation (COR) using reconstructed slices at different CORs. | def find_center_visual_slices(sinogram, output, start, stop, step=1, zoom=1.0,
method="dfi", gpu=False, angles=None,
ratio=1.0, filter_name="hann", apply_log=True,
ncore=None):
output_name = losa.make_folder_name(output, name_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resetCoronalSegment(self):\r\n #research\r\n profprint()\r\n sGreen = slicer.mrmlScene.GetNodeByID(\"vtkMRMLSliceNodeGreen\")\r\n if sGreen == None :\r\n sGreen = slicer.mrmlScene.GetNodeByID(\"vtkMRMLSliceNode3\")\r\n reformatLogic = slicer.vtkSlicerReformatLogic()\r\n #sGreen.SetSliceV... | [
"0.6325203",
"0.58658427",
"0.56629187",
"0.5608353",
"0.5597403",
"0.55535376",
"0.55319536",
"0.5510736",
"0.5472733",
"0.5467159",
"0.54252744",
"0.5421264",
"0.5417943",
"0.541789",
"0.5403625",
"0.5399282",
"0.53945535",
"0.53796023",
"0.5379341",
"0.53721356",
"0.537169... | 0.62349164 | 1 |
The handshake process matches the user and the socketio session Through this process the message queues for that user are declared and the consumption of messages is started | def handshake_handler(json):
# json object contains the session cookie, thus identifying the sender
# Handshake the request sid with the user identifier, through the json[data] cookie
# get_cache(cookie) -> if there is proceed and get userid from the cache
userid = get_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startProtocol(self):\n #init state trackers\n self.initialMessageSentToServer = False\n self.sentPacketToPeerPublicAndPrivateAddresses = False\n self.mirroredBackWhicheverPacketMadeIt = False\n self.peerConnectionEstablished = False\n #init peer info\n self.peer... | [
"0.5875316",
"0.5857201",
"0.57918805",
"0.57423913",
"0.573058",
"0.56563413",
"0.5626399",
"0.56111974",
"0.56111974",
"0.56111974",
"0.5533881",
"0.5515904",
"0.5515652",
"0.55117786",
"0.551157",
"0.55037475",
"0.5501519",
"0.5468767",
"0.54663426",
"0.54431546",
"0.54213... | 0.7422356 | 0 |
Return a DataFrame given a list of high resolution segments from the Swiftly Speed Maps API. | def speed_map_segs_to_df(seg_list):
# Put segment list into DataFrame
df = pd.DataFrame(seg_list)
# Seperate the start and end coords from pathLocs
temp_df = pd.DataFrame(df['pathLocs'].to_list())
temp_df.rename({0: 'start', 1: 'end'}, axis=1, inplace=True)
# Put start coords into a dataframe
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hr_radar_dap_data(dap_urls, st_list, jd_start, jd_stop):\n df_list = []\n for url in dap_urls:\n # Only look at 6 km hf radar.\n if ('http://hfrnet.ucsd.edu/thredds/dodsC/HFRNet/USWC/' in url and\n \"6km\" in url and \"GNOME\" in url):\n print(url)\n # Ge... | [
"0.5936215",
"0.56862307",
"0.5648172",
"0.55322653",
"0.5432056",
"0.5384885",
"0.53832304",
"0.5362796",
"0.53531665",
"0.5300193",
"0.5292622",
"0.52650505",
"0.52353716",
"0.5187068",
"0.51829803",
"0.51782346",
"0.5153698",
"0.5131983",
"0.51062036",
"0.5103662",
"0.5057... | 0.7108869 | 0 |
Return a GeoJSON given a list of high resolution segments from the Swiftly Speed Maps API. | def speed_map_segs_to_geojson(seg_list):
# Initialize a new GeoJSON object
new_geojson = {
'type': 'FeatureCollection',
'features': []
}
# Dont work on the input list
seg_list_copy = copy.deepcopy(seg_list)
# Iterativley build the features of the new GeoJSON object
for i, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advsOverview(request,userId):\n \n if request.method==\"GET\":\n allAdvs = []\n #this is awful\n advs = Adventure.objects.filter(owner_id=userId).all()\n for adv in advs:\n advCoordinates = []\n distance = 0\n startTime = None\n endT... | [
"0.6235419",
"0.6081462",
"0.6015348",
"0.5920778",
"0.57573026",
"0.5612119",
"0.55306166",
"0.54667974",
"0.54614043",
"0.5446105",
"0.5430375",
"0.5392269",
"0.5296717",
"0.529613",
"0.52856684",
"0.5256154",
"0.5251992",
"0.52286536",
"0.5205448",
"0.5195705",
"0.5180397"... | 0.6811476 | 0 |
Ensures indicies on the substrates, materials, and elastic collections | def ensure_indicies(self):
# Search indicies for materials
self.materials.ensure_index(self.materials.key)
self.materials.ensure_index(self.materials.last_updated_field)
# Search indicies for elasticity
self.elasticity.ensure_index(self.elasticity.key)
self.elasticity.en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_indices_several_existing_items(self):\r\n control_ids = ['PC.354', 'PC.355', 'PC.356', 'PC.481', 'PC.593']\r\n exp_control_indices = [0, 1, 2, 3, 4]\r\n\r\n fast_ids = ['PC.607', 'PC.634', 'PC.635', 'PC.636']\r\n exp_fast_indices = [5, 6, 7, 8]\r\n\r\n obs_control = ... | [
"0.58049315",
"0.56701416",
"0.5613258",
"0.5420278",
"0.5391838",
"0.5370564",
"0.53663456",
"0.53554654",
"0.5310201",
"0.5292106",
"0.52858096",
"0.5280453",
"0.527632",
"0.52642715",
"0.52510947",
"0.52295274",
"0.52262866",
"0.5214343",
"0.52126086",
"0.51982284",
"0.518... | 0.7426437 | 0 |
Get a conventional standard structure from doc["structure"]. | def conventional_standard_structure(doc):
s = Structure.from_dict(doc["structure"])
spga = SpacegroupAnalyzer(s, symprec=0.1)
return spga.get_conventional_standard_structure() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def structure(self):\n return load_node(self.get_attribute('structure'))",
"def getStructure(sname):\n x = resolve(vs_defs, sname.split(\".\"))\n if x is not None:\n return x()\n\n return None",
"def get_structure(self):\n return self.structure",
"def doc(obj):\n return Docum... | [
"0.64130175",
"0.62737346",
"0.62535506",
"0.601774",
"0.6005177",
"0.59398437",
"0.5928909",
"0.59152204",
"0.58974653",
"0.5746717",
"0.57194525",
"0.57026905",
"0.57026905",
"0.57026905",
"0.57026905",
"0.56830233",
"0.5657347",
"0.553292",
"0.55165386",
"0.55031043",
"0.5... | 0.834834 | 0 |
Return the number of milliseconds to run this search function on this list. | def time_search(search_fn, mylist, key):
start = time.time()
search_fn(mylist, key)
end = time.time()
return (end - start) * 1000 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed_time_in_seconds_for_search_problem(self):\n return self._elapsed_time_in_seconds_for_search_problem",
"def get_timeout(self) -> int:",
"def time(self):\n return self._clock() - self._starttime",
"def time(self) -> int:\n pass",
"def service_time(self):\r\n return (se... | [
"0.69653517",
"0.6133668",
"0.6107392",
"0.6045637",
"0.5974755",
"0.59680486",
"0.5963348",
"0.59627384",
"0.59096307",
"0.5894296",
"0.5891837",
"0.5886801",
"0.58718956",
"0.5868244",
"0.5867287",
"0.58652496",
"0.58347446",
"0.5833163",
"0.58197075",
"0.5803122",
"0.58020... | 0.7113912 | 0 |
Compare the running time of linear_search and binary_search for input sizes as given. The key for each search should be 1. The list to search for each size contains the numbers from 0 to n1, sorted in ascending order. You'll use the time_search function to time each call. | def compare_search(sizes=[1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7]):
print(sizes)
return [(size,
time_search(linear_search, list(range(int(size))), -1),
time_search(binary_search, list(range(int(size))), -1)) for size in sizes] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_search(search_fn, mylist, key):\n\tstart = time.time()\n\tsearch_fn(mylist, key)\n\tend = time.time()\n\treturn (end - start) * 1000",
"def performance():\n\tn = 1024\n\twhile n < 5000000: \n\t\tsorted = range(n)\n\t\tnow = time()\n\n\t\t# Code whose performance is to be evalutated\n\t\tbs_contains(sort... | [
"0.6561665",
"0.6133756",
"0.60755837",
"0.57541203",
"0.5704894",
"0.5673662",
"0.56366175",
"0.5595335",
"0.5534451",
"0.54922026",
"0.5450171",
"0.54492134",
"0.5442166",
"0.53734094",
"0.5365476",
"0.5349727",
"0.5329049",
"0.5314567",
"0.5281045",
"0.5254504",
"0.5251631... | 0.76939213 | 0 |
Decide whether to keep or discard an ngram. | def filter_ngram(gram, mode='any'):
filtered = [filter_word(w) for w in gram]
if mode == 'any':
return any(filtered)
elif mode == 'all':
return all(filtered)
elif mode == 'ends':
return filtered[0] or filtered[-1]
else:
raise ValueError('Invalid mode: %s' % mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngram(self,phrase,n,unity=\"w\"):\n return self._support.ngram(phrase,n,unity)",
"def n_gram_option(input_data, n_gram, option=1000):\n for line_idx, line_val in enumerate(input_data):\n if not \" \" in line_val:\n \n\n if n_gram.get(line_val, None) != None:\n ... | [
"0.5924189",
"0.57237387",
"0.5710335",
"0.5710335",
"0.55848086",
"0.5535557",
"0.5516005",
"0.544658",
"0.5414042",
"0.53289163",
"0.53094155",
"0.5297959",
"0.527334",
"0.5271123",
"0.52598864",
"0.5235549",
"0.5232021",
"0.5218824",
"0.5195931",
"0.5172209",
"0.51709676",... | 0.66496295 | 0 |
Load examples from preprocessed file. One example per line, JSON encoded. | def load_data(filename):
# Load JSON lines
with open(filename, encoding='utf-8') as f:
examples = [json.loads(line) for line in f]
return examples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_examples(file_name):\n for line in read_file(file_name):\n yield json.loads(line)",
"def _load(examples, f):\n\n for l in f:\n json_example = json.loads(l)\n if FLAGS.mode == 'long_answers' and not has_long_answer(json_example):\n continue\n\n ... | [
"0.72500736",
"0.7250054",
"0.7097928",
"0.66731703",
"0.66235256",
"0.6539321",
"0.64405644",
"0.6298599",
"0.6227813",
"0.6202703",
"0.61640966",
"0.6120336",
"0.60204387",
"0.60204387",
"0.60204387",
"0.59889525",
"0.5982625",
"0.59795433",
"0.5959568",
"0.59421396",
"0.59... | 0.76169467 | 0 |
Put all the words in embedding_file into a set. | def index_embedding_words(embedding_file):
words = set()
with open(embedding_file, encoding='utf-8') as f:
for line in f:
w = Dictionary.normalize(line.rstrip().split(' ')[0])
words.add(w)
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_embedding_words(self, embedding_file):\n words = set()\n with open(embedding_file) as f:\n for line in f:\n w = TokenDictionary.normalize(line.rstrip().split(' ')[0])\n words.add(w)\n return words",
"def index_embedding_words(embedding_file)... | [
"0.794059",
"0.77424127",
"0.71832764",
"0.6847565",
"0.6797833",
"0.6797833",
"0.67908615",
"0.66975415",
"0.6492973",
"0.64509046",
"0.64481515",
"0.64321977",
"0.6387313",
"0.6382758",
"0.63629246",
"0.6338612",
"0.6336183",
"0.6335779",
"0.63091797",
"0.6261961",
"0.62484... | 0.7770482 | 1 |
Count and return the most common question words in provided examples. | def top_question_words(args, examples, word_dict):
word_count = Counter()
for ex in examples:
for w in ex['question']:
w = Dictionary.normalize(w)
if args.uncased_question:
w = w.lower()
if w in word_dict:
word_count.update([w])
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_top_n_words_same_frequency(self):\n expected = ['happy', 'man']\n actual = get_top_n_words({'happy': 2, 'man': 2}, 2)\n self.assertEqual(expected, actual)\n expected = ['happy']\n actual = get_top_n_words({'happy': 2, 'man': 2}, 1)\n self.assertEqual(expected,... | [
"0.6657793",
"0.641209",
"0.6387407",
"0.6353765",
"0.62865704",
"0.62178177",
"0.6145147",
"0.6104864",
"0.6097784",
"0.6067329",
"0.6034453",
"0.601861",
"0.5998447",
"0.59949565",
"0.59864545",
"0.59542423",
"0.5938399",
"0.59287757",
"0.59230274",
"0.591873",
"0.59036577"... | 0.7939996 | 0 |
Test if a regex pattern is contained within a text. | def regex_match(text, pattern):
try:
pattern = re.compile(
pattern,
flags=re.IGNORECASE + re.UNICODE + re.MULTILINE,
)
except BaseException:
return False
return pattern.search(text) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(text: str, pattern: str) -> bool:\n assert isinstance(text, str), 'text is not a string: {}'.format(text)\n assert isinstance(pattern, str), 'pattern is not a string: {}'.format(text)\n # COMPLEXITY: O(n) b/c we are using find_index method which is O(n)\n return find_index(text, pattern) i... | [
"0.76868325",
"0.7390794",
"0.7355733",
"0.7318198",
"0.722891",
"0.7105045",
"0.677656",
"0.6678091",
"0.66497165",
"0.6560992",
"0.65590525",
"0.65290797",
"0.6509348",
"0.64882684",
"0.6469936",
"0.6453154",
"0.6418693",
"0.63359195",
"0.63333386",
"0.6293117",
"0.62666094... | 0.81599885 | 0 |
Read all data from filename and use split to create a list. | def read_data(filename):
with open(filename, 'r') as f:
return f.read().split() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openandsplit(filename):\n try:\n with open(filename,\"r\") as f:\n return f.read().split(\"\\n\")\n except IOError as e:\n raise ErrorPL(\"Can't open file \"+ filename+\"\\n\"+str(e))",
"def open_and_read_file(filename):\n \n file_class = open(filename)\n file_list = f... | [
"0.76280206",
"0.73630095",
"0.7314334",
"0.7304427",
"0.7260631",
"0.7258315",
"0.72361034",
"0.72287875",
"0.7146539",
"0.7124925",
"0.71236354",
"0.6985995",
"0.69688886",
"0.69407725",
"0.69330597",
"0.69281423",
"0.69143754",
"0.68746626",
"0.6872434",
"0.68485224",
"0.6... | 0.78456914 | 0 |
Checks for the Authorization header should be case insensitive. | def test_from_request_is_case_insensitive_checking_for_auth(self):
url = "http://sp.example.com/"
params = {
'oauth_version': "1.0",
'oauth_nonce': "4572616e48616d6d65724c61686176",
'oauth_timestamp': "137131200",
'oauth_consumer_key': "0685bd9184jfhq22",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_header_keyword(self):\n\n valid = False\n if self.headers[0].upper() == \"NAME\":\n valid = True\n if self.headers[0] != \"NAME\":\n msg = f'File keyword \"NAME\" provided as {self.headers[0]}'\n self.store_validation_issue(\"warn\", ms... | [
"0.6388695",
"0.63255477",
"0.60735303",
"0.5978333",
"0.5968382",
"0.5946468",
"0.5943898",
"0.59404963",
"0.59225476",
"0.59042424",
"0.59042424",
"0.58795345",
"0.58698285",
"0.5839023",
"0.578281",
"0.57625395",
"0.5757034",
"0.5751667",
"0.5730555",
"0.57196844",
"0.5649... | 0.7189953 | 0 |
Test getting an access token via GET. | def test_access_token_get(self):
client = oauth.Client(self.consumer, None)
resp, content = client.request(self._uri('request_token'), "GET")
self.assertEqual(int(resp['status']), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_o_auth_access_token(self):\n pass",
"def test_get_token(self):\n token = self.client.get_token()\n assert_equals(token, self.client.token)",
"def test_get_main_route_auth():\n set_token(client, \"user0011\")\n\n response = client.get(url)\n assert response.status_cod... | [
"0.76568395",
"0.7429985",
"0.73414433",
"0.73345524",
"0.7263971",
"0.7200799",
"0.71125346",
"0.7103763",
"0.7101721",
"0.70631826",
"0.69881374",
"0.69393295",
"0.6927918",
"0.69090766",
"0.6886684",
"0.6856418",
"0.68210703",
"0.6714766",
"0.66905516",
"0.6686085",
"0.666... | 0.8664422 | 0 |
Test getting an access token via POST. | def test_access_token_post(self):
client = oauth.Client(self.consumer, None)
resp, content = client.request(self._uri('request_token'), "POST")
self.assertEqual(int(resp['status']), 200)
res = dict(parse_qsl(content))
self.assertTrue(b'oauth_token' in res)
self.assertTr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_access_token_get(self):\n client = oauth.Client(self.consumer, None)\n resp, content = client.request(self._uri('request_token'), \"GET\")\n\n self.assertEqual(int(resp['status']), 200)",
"def test_access_methods_with_token(self):\n\n print(\" --------------------------- Test... | [
"0.7674852",
"0.7449955",
"0.7377488",
"0.73707163",
"0.72851264",
"0.7250134",
"0.7222699",
"0.71662414",
"0.7144512",
"0.7139295",
"0.7127388",
"0.7072923",
"0.69646573",
"0.6958414",
"0.69164485",
"0.69096816",
"0.6883355",
"0.68730617",
"0.67757076",
"0.6771992",
"0.67618... | 0.8571272 | 0 |
A test of a twolegged OAuth POST request. | def test_two_legged_post(self):
resp, content = self._two_legged("POST")
self.assertEqual(int(resp['status']), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_access_token_post(self):\n client = oauth.Client(self.consumer, None)\n resp, content = client.request(self._uri('request_token'), \"POST\")\n\n self.assertEqual(int(resp['status']), 200)\n\n res = dict(parse_qsl(content))\n self.assertTrue(b'oauth_token' in res)\n ... | [
"0.76461965",
"0.7064442",
"0.6829727",
"0.68285996",
"0.68041694",
"0.66751415",
"0.6666033",
"0.66531557",
"0.66219807",
"0.6578144",
"0.6532915",
"0.65196204",
"0.65167254",
"0.6514781",
"0.6471154",
"0.6463814",
"0.6435324",
"0.64250934",
"0.64070314",
"0.64056474",
"0.63... | 0.7382128 | 1 |
A test of a twolegged OAuth GET request. | def test_two_legged_get(self):
resp, content = self._two_legged("GET")
self.assertEqual(int(resp['status']), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_without_oauth(self):\n self.client = trovebox.Trovebox(host=self.test_host)\n self._register_uri(httpretty.GET)\n response = self.client.get(self.test_endpoint)\n self.assertNotIn(\"authorization\", self._last_request().headers)\n self.assertEqual(response, self.test... | [
"0.74864566",
"0.73454106",
"0.7334162",
"0.68933874",
"0.6850984",
"0.668996",
"0.66713697",
"0.65946645",
"0.6531386",
"0.6506468",
"0.6465292",
"0.64266616",
"0.6378605",
"0.63771456",
"0.63727075",
"0.6361027",
"0.63093585",
"0.6287715",
"0.6283159",
"0.6273944",
"0.62675... | 0.7523463 | 0 |
Plot dendrogram using specific input parameters. | def plot_dendrogram(*args, **kwargs):
max_d = kwargs.pop('max_d', None)
if max_d and ('color_threshold' not in kwargs): kwargs['color_threshold'] = max_d
annotate_above = kwargs.pop('annotate_above', 0)
# Compute the dendrogram
ddata = dendrogram(*args, **kwargs)
# Plot the dendrogram
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dendogram(self):\r\n \r\n plt.figure(figsize=(20, 7))\r\n dendrogram = sch.dendrogram(sch.linkage(self.X, method='ward'))\r\n plt.title(\"Dendograms\")\r\n plt.axhline(linestyle='--', y=5) \r\n plt.show()",
"def plot_dendrogram(model, **kwargs):\n # create the count... | [
"0.77314174",
"0.7678704",
"0.68494743",
"0.6567777",
"0.63771343",
"0.6060847",
"0.5955653",
"0.5902121",
"0.581735",
"0.5803824",
"0.5779356",
"0.57590264",
"0.56777257",
"0.56767434",
"0.5661856",
"0.5637162",
"0.56288165",
"0.56181276",
"0.5610945",
"0.55912787",
"0.55876... | 0.7867592 | 0 |
Return a query that resolves to entity's equipment slots and their equipped items. | def get_slots_query(scene: GameScene, entity: int):
def query():
paper_doll: PaperDoll = scene.cm.get_one(PaperDoll, entity)
equipment = paper_doll.get_equipment()
return [
(k, scene.cm.get_one(Entity, v))
for k, v in equipment.items()
]
return query | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equipments(self):\n selection = self.object.equipment_set\n return {\n 'selection': selection.all(),\n 'count': selection.count()\n }",
"def equipments(self):\n selection = Equipment.objects.filter(responsible__location_id=self.object.id)\n return {\n ... | [
"0.64733803",
"0.64156085",
"0.63525635",
"0.6284163",
"0.61037105",
"0.5982486",
"0.58956254",
"0.5886098",
"0.58447266",
"0.58190703",
"0.5753358",
"0.5551546",
"0.5501165",
"0.545697",
"0.54522926",
"0.5410814",
"0.5398921",
"0.53424585",
"0.5320571",
"0.52489144",
"0.5211... | 0.78593564 | 0 |
Scale pandas series so that it starts at one. | def scale_to_start(x):
x = (x + eps) / (x[0] + eps)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(x: pd.Series, a: int = 1) -> pd.Series:\n # todo check this implementation is right\n assert isinstance(x.index, pd.MultiIndex)\n return x.groupby(level=0).apply(lambda e: a * e / e.abs().sum())",
"def normalize_series(series):\n return (series - series.mean()) / (series.max() - series.min(... | [
"0.6413065",
"0.61761564",
"0.6088046",
"0.59685457",
"0.592122",
"0.5915396",
"0.589249",
"0.58240604",
"0.5803719",
"0.579567",
"0.57951194",
"0.5727549",
"0.5704661",
"0.5680435",
"0.5680435",
"0.5679397",
"0.5677543",
"0.567528",
"0.56672496",
"0.5646413",
"0.5616768",
... | 0.6404997 | 1 |
Step. w1 new action of portfolio weights e.g. [0.1,0.9,0.0] y1 price relative vector also called return e.g. [1.0, 0.9, 1.1] | def _step(self, w1, y1,y1_short):
#reajust the return y1 using the sign of w1
#if is negative means we shorted so the return is the inverse
y1_aux=y1.copy()
for i in range(len(w1)):
if(w1[i]<0):
y1_aux[i]=y1_short[i]
y1=y1_aux.copy()
#pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _step(self, action):\n\n np.testing.assert_almost_equal(\n action.shape,\n (len(self.sim.asset_names) + 1,)\n )\n\n # normalise just in case\n action = np.clip(action, -1, 1)\n\n weights = action # np.array([cash_bias] + list(action)) # [w0, w1...]\n ... | [
"0.6440915",
"0.6263853",
"0.6195804",
"0.6153045",
"0.6153045",
"0.6153045",
"0.6075158",
"0.5877056",
"0.58768123",
"0.5874016",
"0.585022",
"0.58432",
"0.57908666",
"0.57753766",
"0.57610744",
"0.5712122",
"0.57070655",
"0.5706866",
"0.5701995",
"0.5694994",
"0.5688777",
... | 0.74794483 | 0 |
Step the env. Actions should be portfolio [w0...] Where wn is a portfolio weight from 0 to 1. The first is cash_bias cn is the portfolio conversion weights see PortioSim._step for description | def _step(self, action):
np.testing.assert_almost_equal(
action.shape,
(len(self.sim.asset_names) + 1,)
)
# normalise just in case
action = np.clip(action, -1, 1)
weights = action # np.array([cash_bias] + list(action)) # [w0, w1...]
weights /=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\n actions = action.reshape(2, 2)\n action = {'GoalieBrain': actions[0], 'StrikerBrain': actions[1]}\n #action = {'GoalieBrain': [5, 5], 'StrikerBrain': [2, 2]}\n #print(action)\n info = self.env.step(action)\n\n state0 = info[self.brain_names[0]].ve... | [
"0.68640393",
"0.65686697",
"0.6320189",
"0.6159753",
"0.6095992",
"0.5931882",
"0.59014386",
"0.5891507",
"0.5866128",
"0.5833102",
"0.5819931",
"0.5783964",
"0.5777357",
"0.5737463",
"0.57298595",
"0.57188094",
"0.56945664",
"0.5688277",
"0.5669561",
"0.564269",
"0.56312287... | 0.70463437 | 0 |
adds a block to the game board | def addBlock(self, aBlock: gp.Block):
if self.blocks[aBlock.y][aBlock.x] != None:
raise MovementError('game board space not empty')
self.blocks[aBlock.y][aBlock.x] = aBlock
self.groundSprites.append(aBlock.sprite) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_block(self):\n old_block = self.curr_block\n self.curr_block = self.gen_new_block()\n add_edge(old_block, self.curr_block)",
"def addBlock(self, newBlock):\n newBlock.index = len(self.chain)\n newBlock.previousHash = self.chain[-1].hash\n newBlock.mineBlock(s... | [
"0.74275833",
"0.73965067",
"0.7351386",
"0.72376084",
"0.71132094",
"0.7105376",
"0.7105181",
"0.695177",
"0.69213814",
"0.6910296",
"0.69086367",
"0.67938924",
"0.676055",
"0.6747705",
"0.66910845",
"0.66554767",
"0.66342205",
"0.66189307",
"0.6592169",
"0.6586685",
"0.6582... | 0.79169446 | 0 |
remove a block from the game board | def removeBlock(self, aBlock: gp.Block):
for y, row in iter(self.blocks):
for x, block in iter(row):
if block is aBlock:
self.blocks[y][x] = None
self.playerSprites.remove(aBlock.sprite)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_block(self, block):\n raise NotImplementedError()",
"def remove(self, block):\n try:\n self.blocks[block.height]\n except:\n raise ValueError(\"cant remove block: \" + str(block))\n\n removed = False\n for b in self.blocks[block.height]:\n ... | [
"0.7926322",
"0.7645249",
"0.75476116",
"0.7303854",
"0.72671723",
"0.7248479",
"0.71942407",
"0.71165335",
"0.6963678",
"0.69616514",
"0.6880072",
"0.6824668",
"0.66764283",
"0.658766",
"0.6549952",
"0.6521457",
"0.64556485",
"0.64442575",
"0.6432679",
"0.64207613",
"0.63903... | 0.78278923 | 1 |
Get any credentials this network will require to call `self.connect()` return True if we should connect, False if we're missing credentials | def credentials(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_credentials(self):\n return self.username and self.password and self.url and self.xml_rpc",
"def credentials_work(self):\n\n good = True\n try:\n self.authenticate_client()\n except cloudpassage.CloudPassageAuthentication:\n good = False\n return g... | [
"0.760887",
"0.6839418",
"0.6799266",
"0.6790826",
"0.67659384",
"0.64997184",
"0.6377289",
"0.6206759",
"0.6160997",
"0.60966825",
"0.60938746",
"0.60234827",
"0.60135293",
"0.598305",
"0.5979347",
"0.5966003",
"0.59603834",
"0.59487385",
"0.5940354",
"0.5928015",
"0.5919524... | 0.700792 | 1 |
get_dist_hash(m, ndigits = 2, dist = euclidean) | def get_dist_hash(m, ndigits=2,dist=euclidean):
# defaultdict is awesome :D
# http://docs.python.org/library/collections.html#collections.defaultdict
h = defaultdict(set)
# Also, itertools.combinations is sweet:
# http://docs.python.org/library/itertools.html#itertools.combinations
# Sets of sets in python are t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calHash(n, m):\n return int(m*BloomFilter.ln2/n)",
"def hash_double(d):\n # initialize table\n table = [\"-\"] * 19\n # consider each integer k in the input\n for k in d:\n # if k is already in the table this is a duplicate so move to next integer in the input\n # note this check... | [
"0.7238171",
"0.6154226",
"0.60909957",
"0.60473114",
"0.5986369",
"0.59453547",
"0.59321535",
"0.5930312",
"0.5900604",
"0.5867328",
"0.58435297",
"0.5799067",
"0.5797306",
"0.57755774",
"0.57735664",
"0.57682014",
"0.575886",
"0.57382077",
"0.5715772",
"0.5687155",
"0.56868... | 0.8705319 | 0 |
Convert two dates into FITS form. | def dates_to_fits(date_begin: astropy.time.Time, date_end: astropy.time.Time) -> dict[str, Any]:
cards: dict[str, Any] = {}
if date_begin is None and date_end is None:
# no date headers can be written
return cards
cards["TIMESYS"] = "TAI"
date_avg = None
if date_begin is not None a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def <start>/<end>(<start>/<end>)\ndef calc_temps(start_date, end_date):",
"def create_date_features(df = None, date = None):\n #TODO",
"def test_dhms2day():\n\td = [0,737072]\n\th = [7,16]\n\tm = [12,43]\n\ts = [0.0,25.12]\n\td_true = [0.3,737072.696818518569]\n\td_test = date_functions.dhms2day(d,h,m,s)\n\... | [
"0.5444038",
"0.52135473",
"0.50762457",
"0.5037834",
"0.50093937",
"0.5005923",
"0.48731226",
"0.48378378",
"0.48328555",
"0.48273432",
"0.4779675",
"0.4766034",
"0.4759127",
"0.4741502",
"0.4736468",
"0.47330937",
"0.47284263",
"0.47045803",
"0.47045118",
"0.4695387",
"0.46... | 0.5965578 | 0 |
Convert an `ObservationInfo` to something suitable for writing to a FITS file. | def info_to_fits(obs_info: ObservationInfo) -> tuple[dict[str, Any], dict[str, str]]:
cards = {}
comments = {}
if obs_info.instrument is not None:
cards["INSTRUME"] = obs_info.instrument
comments["INSTRUME"] = "Name of instrument"
cards.update(dates_to_fits(obs_info.datetime_begin, obs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_as_fits(self, filename):",
"def NRMtoOifits2(dic, filename=None, saveoifdir=None, verbose=False):\n\n if dic is not None:\n pass\n else:\n cprint('\\nError NRMtoOifits2 : Wrong data format!', on_color='on_red')\n return None\n\n datadir = saveoifdir\n if datadir is None:... | [
"0.5901343",
"0.55383444",
"0.5399921",
"0.5389736",
"0.53472286",
"0.5327982",
"0.52982223",
"0.5265522",
"0.52338046",
"0.52318347",
"0.52260786",
"0.52062744",
"0.51810855",
"0.516371",
"0.51312494",
"0.5096261",
"0.5095043",
"0.50736105",
"0.50581586",
"0.5025533",
"0.502... | 0.65353936 | 0 |
Convert an `ObservationGroup` to something suitable for writing to a FITS file. | def group_to_fits(obs_group: ObservationGroup) -> tuple[dict[str, Any], dict[str, str]]:
cards = {}
comments = {}
oldest, newest = obs_group.extremes()
instruments = obs_group.property_values("instrument")
if len(instruments) == 1:
cards["INSTRUME"] = list(instruments)[0]
comments[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spatialimg_to_hdfgroup(h5group, spatial_img):\n try:\n h5group['data'] = spatial_img.get_data()\n h5group['affine'] = spatial_img.get_affine()\n\n if hasattr(h5group, 'get_extra'):\n h5group['extra'] = spatial_img.get_extra()\n\n hdr = spatial_img.get_header()\n ... | [
"0.5683999",
"0.55572706",
"0.5301093",
"0.525534",
"0.5245077",
"0.51543736",
"0.5123626",
"0.51179385",
"0.50982887",
"0.50785214",
"0.5073691",
"0.5035622",
"0.503406",
"0.502949",
"0.50294584",
"0.5029338",
"0.50175965",
"0.5009671",
"0.49671787",
"0.49169508",
"0.4848423... | 0.58926046 | 0 |
Test case for uploadcustomerpurchasefile Upload a datafile to the database | def test_uploadcustomerpurchasefile(self):
testfile = os.path.join(os.getcwd(), '..', 'test_input_file.dat')
in_file = open(testfile, 'rb')
filec = in_file.read()
in_file.close()
data = dict(upfile=(BytesIO(filec), testfile))
response = self.client.open(
'/v1/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_file(self):\n pass",
"def test_upload_file1(self):\n pass",
"def test_file_upload(self):\n\n with tempfile.NamedTemporaryFile() as test_file:\n test_file.write(\n u'date,category,employee name,employee address,expense description,pre-tax amount,tax... | [
"0.71124935",
"0.7003443",
"0.69382745",
"0.68294257",
"0.65373904",
"0.6479264",
"0.6444684",
"0.6440641",
"0.6440494",
"0.6370586",
"0.6267277",
"0.626658",
"0.62224",
"0.6196826",
"0.61960346",
"0.6194793",
"0.61846846",
"0.61803937",
"0.61583513",
"0.6156429",
"0.6155767"... | 0.8667951 | 0 |
find the contact pairs using rayshooting the finally returned number of contact pairs may be smaller than the given max_samples due to the min_dist constraint | def plan_contact_pairs(objcm,
max_samples=100,
min_dist_between_sampled_contact_points=.005,
angle_between_contact_normals=math.radians(160),
toggle_sampled_points=False):
contact_points, face_ids = objcm.sample_surface(nsam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(ctx, pcs, centroids, radius, max_samples):\n pc_length = pcs.pow(2).sum(dim=1, keepdim=True)\n c_length = centroids.pow(2).sum(dim=1).unsqueeze(-1)\n # (batch_size, num_centroids, num_points)\n dists = centroids.permute(0, 2, 1).bmm(pcs).mul(-2).add(pc_length).add(c_length)\... | [
"0.60845715",
"0.57906955",
"0.5725386",
"0.5697456",
"0.5669618",
"0.5663296",
"0.5614479",
"0.5595651",
"0.5501937",
"0.5455074",
"0.5417552",
"0.540363",
"0.5336711",
"0.53304464",
"0.5311603",
"0.5288702",
"0.52718616",
"0.5261164",
"0.5239604",
"0.52297735",
"0.52278495"... | 0.68266153 | 0 |
Return atomic positions flattened to a single long vector. | def position(self):
return self.atoms.reshape((1,-1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractCoords(self):\n if not self.rank:\n logging.info('Extracting atomic poitions')\n\n # Extract coordinates from liggghts\n self.lmp.command('variable x atom x')\n x = Rxn.lmp.extract_variable(\"x\", \"group1\", 1)\n\n self.lmp.command('variable y atom y')\n y = Rxn.lmp.extract_varia... | [
"0.6010096",
"0.5818172",
"0.55662423",
"0.5398406",
"0.536053",
"0.5349115",
"0.5345898",
"0.53417856",
"0.5341239",
"0.5317327",
"0.5244844",
"0.5206288",
"0.5156032",
"0.51075137",
"0.5106316",
"0.508289",
"0.5074672",
"0.5070674",
"0.50612575",
"0.5057421",
"0.5051576",
... | 0.6047393 | 0 |
Generate a supercell of the given shape | def supercell(self, shape):
l,m,n = shape
mult = l*m*n
supercell = atomic_set()
supercell.name = "SUPERCELL %dx%dx%d %s"%(l,m,n,self.name)
supercell.unit_cell = multiply(self.unit_cell,array([[l,l,l],[m,m,m],[n,n,n]]))
supercell.recip_cell = linalg.inv(supercell.unit_cell)
supercell.num_at... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_super_cell(structure, sc):\n assert isinstance(structure,SimulationCell)\n\n supercell = SimulationCell()\n supercell.structure_comment = \"{}x{}x{}\".format(sc[0],sc[1],sc[2])\n\n # set lattice parameter\n supercell.a0 = structure.a0\n\n # set h_matrix\n H = np.zeros(shape=[3,3])\n ... | [
"0.69278324",
"0.62515634",
"0.59457195",
"0.59072906",
"0.5863371",
"0.5863371",
"0.5846176",
"0.57975006",
"0.5677492",
"0.5601938",
"0.5537469",
"0.5446191",
"0.5442399",
"0.54056865",
"0.540546",
"0.5393445",
"0.53356487",
"0.5328883",
"0.53148663",
"0.5306923",
"0.530221... | 0.80416167 | 0 |
Performs Gaussian mutation operation on single individual in floating point gene representation, Mutation works by drawing N samples from random normal distribution add adding in to individual | def gaussian_standard_mutation(individual: np.array, mutation_strength: float = 0.1) -> np.array:
offset = np.random.randn(individual.shape[0])
return mutation_strength * offset + individual | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GausianMutator(individual, sigma, indpb):\n for idx, gene in enumerate(individual):\n if rand.random() > indpb:\n dtype = gene.type\n if dtype == bool:\n gene.value(not gene.value())\n continue\n\n min_value, max_value = gene.min, gene.ma... | [
"0.6953742",
"0.6785388",
"0.6733355",
"0.6634463",
"0.6590448",
"0.6504163",
"0.6475615",
"0.6459582",
"0.6452504",
"0.6423",
"0.64207935",
"0.63494",
"0.63157177",
"0.6290326",
"0.61561704",
"0.6119536",
"0.61141557",
"0.60903174",
"0.60860413",
"0.607217",
"0.60557055",
... | 0.71980053 | 0 |
set a MPL 2D line with the current properties | def refresh_mpl_line(self, line=None):
if line:
self.set_label(self.label,line=line)
self.set_color(self.color,line=line)
self.set_style(self.style,line=line)
self.set_marker(self.marker,line=line)
self.set_markersize(self.markersize,line=line)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy_line(**kwargs):\r\n return matplotlib.lines.Line2D(range(1), range(1), **kwargs)",
"def line_layer(self):\n screen_origin = self.ids.mapview.get_window_xy_from(lat1, lon1, self.ids.mapview.zoom)\n screen_destination = self.ids.mapview.get_window_xy_from(lat2, lon2, self.ids.mapview.zoo... | [
"0.6784515",
"0.6469363",
"0.6380737",
"0.6380691",
"0.63785547",
"0.6337284",
"0.63101614",
"0.63029855",
"0.6286078",
"0.62731916",
"0.6246099",
"0.6189246",
"0.61175376",
"0.6097782",
"0.6095507",
"0.6092207",
"0.60890585",
"0.6074678",
"0.60609996",
"0.6051972",
"0.604790... | 0.67503726 | 1 |
Initialize this hash table with the given initial size | def __init__(self, init_size=8):
self.size = 0
self.buckets = [LinkedList() for i in range(init_size)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.size = 1000\n self.hash_table = [None] * self.size",
"def __init__(self):\n self.size = 10000\n self.hashmap = [None] * self.size",
"def __init__(self):\n self.size = 997\n self.hash_set = [None] * self.size",
"def __init__(self, init_size=... | [
"0.7625478",
"0.7113677",
"0.70874226",
"0.69846207",
"0.69701767",
"0.6797548",
"0.66975087",
"0.6619758",
"0.6565475",
"0.6541959",
"0.65221006",
"0.6510889",
"0.65039045",
"0.65039045",
"0.64488906",
"0.64266133",
"0.64266133",
"0.64266133",
"0.6391668",
"0.63877314",
"0.6... | 0.71887976 | 1 |
Return a string representation of this hash table | def __repr__(self):
# return 'HashTable({})'.format(self.length())
return 'HashTable({})'.format(str(self.buckets)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return 'HashTable({!r})'.format(self.items())",
"def __str__(self):\n sorted_table = InferenceUtils.get_n_best(self._table, max(len(self._table), 1))\n\n result = []\n for key, value in sorted_table.items():\n result.append('P(%s):=%f\\n' % (str(key), ... | [
"0.79308164",
"0.74436367",
"0.7432012",
"0.73263085",
"0.72215545",
"0.7204184",
"0.7199753",
"0.70514524",
"0.69706225",
"0.69571924",
"0.6938565",
"0.69228333",
"0.69082063",
"0.6906212",
"0.69056886",
"0.6889079",
"0.6888168",
"0.68758166",
"0.68698984",
"0.6867483",
"0.6... | 0.7646024 | 1 |
Return the length of this hash table by traversing its buckets | def length(self):
# TODO: Count number of key-value entries in each of the buckets
return self.size
# for bucket in self.buckets(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n # Loop through all buckets\n # Count number of key-value entries in each bucket\n\n # could be done with 1 line with comprehension\n # return sum(bucket.length() for bucket in self.buckets)\n\n total_entries = 0\n\n for linked_list in self.buckets:\n ... | [
"0.8196889",
"0.7354919",
"0.67591745",
"0.6755394",
"0.66716623",
"0.6581744",
"0.6569131",
"0.64765406",
"0.64482945",
"0.6391652",
"0.6391652",
"0.6382363",
"0.6345732",
"0.633304",
"0.6317982",
"0.630891",
"0.630891",
"0.62934667",
"0.62756234",
"0.62677693",
"0.62677693"... | 0.80892974 | 1 |
Get the number of speaker. | def get_speaker_number(self):
return len(self.metadata) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speak_number(self, last_spoken):\n if len(self[last_spoken]) == 1:\n speak = 0\n else:\n speak = self[last_spoken][-1] - self[last_spoken][-2]\n self[speak].append(self.turn)\n return speak",
"def get_player_num(self):\r\n return self.player_control.ge... | [
"0.6344667",
"0.62268364",
"0.6164745",
"0.60414964",
"0.5970395",
"0.59317493",
"0.5908165",
"0.58780193",
"0.5858826",
"0.5858826",
"0.58388895",
"0.5824054",
"0.5814928",
"0.58080494",
"0.57934064",
"0.577267",
"0.5764836",
"0.5737723",
"0.5737723",
"0.57179546",
"0.570742... | 0.8410368 | 0 |
Extract features on the fly from the recording given a list of peaks. | def compute_features_from_peaks(
recording,
peaks,
feature_list=["ptp", ],
feature_params={},
ms_before=1.,
ms_after=1.,
**job_kwargs,
):
job_kwargs = fix_job_kwargs(job_kwargs)
extract_dense_waveforms = ExtractDenseWaveforms(recording, ms_before=ms_before, ms_after=ms_after, retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSequenceFeatures(seqfile, summitpeaks, peaks, spidx, l, rthresh):\n numpeaks = len(peaks)\n rv = np.zeros((numpeaks, 5, l),dtype=float)\n idx = np.zeros((numpeaks), dtype=object)\n curidx = 0\n with open(seqfile, 'r') as f:\n while True:\n try:\n metadata = ne... | [
"0.6437217",
"0.5768453",
"0.5732548",
"0.56912565",
"0.5545577",
"0.55048656",
"0.55048656",
"0.54857504",
"0.5482461",
"0.54725873",
"0.54630655",
"0.5439477",
"0.54186547",
"0.5408545",
"0.53973013",
"0.53863794",
"0.53823954",
"0.53769153",
"0.537691",
"0.5366612",
"0.536... | 0.760075 | 0 |
Perform a web search using the Google search engine | def google(self, input):
args = input.args or ""
parser = self.OptionParser()
parser.add_option("-d", "-r", "--results", dest="results", default=1, type="int")
(options, args) = parser.parse_args(args.split())
if not args:
raise self.BadInputError()
query = " ".join(args).encode('utf-8'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(self, q, start = 0, num = 10):\n\n\t\turl = 'http://www.google.com/xhtml?'\n\t\tquery = urllib.urlencode({'q':q, 'start':start, 'num':num})\n\n\t\tresult = self.get(url + query)\n\t\tcontent = result.read()\n\n\t\ttokens = re.findall(\n\t\t\t'<a\\s+accesskey=\"\\d+\"\\s+href=\"(.*?)\"\\s*>(.*?)</a>(.*?)... | [
"0.74887747",
"0.74752176",
"0.7322287",
"0.72437656",
"0.7189023",
"0.7171273",
"0.7099594",
"0.7098142",
"0.6947797",
"0.6858723",
"0.6830658",
"0.6821851",
"0.67763865",
"0.67453104",
"0.6737927",
"0.6730006",
"0.66904783",
"0.6686727",
"0.66683257",
"0.6662914",
"0.665662... | 0.77345496 | 0 |
Remove any attributes that are attached to this node. | def clear_attrs(self):
self._attributes.clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_attributes(self):\n self.attrs = etad.AttributeContainer()",
"def clearAttributes(self):\n return _libsbml.XMLToken_clearAttributes(self)",
"def clear(self):\n return _libsbml.XMLAttributes_clear(self)",
"def unload(self) -> None:\n for attr in self._attrs:\n ... | [
"0.83119124",
"0.7783767",
"0.76036274",
"0.7556265",
"0.75244236",
"0.72934055",
"0.7272183",
"0.7272183",
"0.7170382",
"0.716937",
"0.71447265",
"0.69456106",
"0.6938337",
"0.6871192",
"0.68062806",
"0.6792149",
"0.6710853",
"0.6679157",
"0.6601412",
"0.6591504",
"0.6578142... | 0.8408423 | 0 |
Set all outputs at once, removing anything that was there previously. Note that information about outputs is not stored in the serialized graph. When instantiating a serialized graph, TensorFlow will use its own shape inference to infer the number, type, and shape of the operator's outputs. | def set_outputs_from_pairs(self, new_outputs: Iterable[Tuple[tf.DType,
tf.shape]]):
self._outputs = []
i = 0
for (dtype, shape) in new_outputs:
self._outputs.append(tensor.Tensor(self, i, dtype, shape))
i += 1
self._graph.increme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_outputs(self):\n self.outputs = []",
"def __set_outputs__(self):\n self.__set_in_out_var__(None, 1)",
"def _transform_outputs(self) -> None:\n self.outputs = None if self.outputs == {} else self.outputs",
"def remove_all_outputs(self):\n self._outs.clear()",
"def infer... | [
"0.7129268",
"0.6815716",
"0.67562294",
"0.6748822",
"0.6679875",
"0.65920573",
"0.6488515",
"0.64647996",
"0.627314",
"0.6230754",
"0.6196514",
"0.6119864",
"0.6037847",
"0.60307074",
"0.598133",
"0.5952038",
"0.5944296",
"0.5926865",
"0.592278",
"0.59152335",
"0.588814",
... | 0.68547803 | 1 |
Use TensorFlow's shape and dtype inference to determine the number of outputs as well as their shapes and dtypes, based on the node's op type string, its attribute values, and what inputs are connected to it. Inference will only function properly if the currentlyloaded version of TensorFlow knows about the specified op... | def infer_outputs(self):
# TF lack a supported API for invoking shape inference directly,
# so we instantiate a dummy graph and create a dummy Operation object
temp_graph = tf.Graph()
with temp_graph.as_default():
input_placeholders = [tf.placeholder(shape=t.shape, dtype=t.dtype) for
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_inference(self):\n raise NotImplementedError(\"This function must be implemented by each op\")",
"def infer_shape(inputs, mod=None):\n out_type = infer_type(inputs, mod=mod)\n checked_type = out_type.checked_type\n if hasattr(checked_type, 'shape'):\n # Regular operator that outpu... | [
"0.62308145",
"0.60860705",
"0.5967714",
"0.5905423",
"0.5850196",
"0.5759562",
"0.5748881",
"0.55758107",
"0.5548156",
"0.55435973",
"0.55306804",
"0.5485855",
"0.5472647",
"0.54594404",
"0.54586744",
"0.54510325",
"0.5430746",
"0.54155576",
"0.5410137",
"0.54068655",
"0.538... | 0.7529744 | 0 |
Set all input at once, converting TensorFlow stringformat inputs into `Tensor` objects. All nodes referenced in the input strings must be present in the parent graph. | def set_inputs_from_strings(self, new_inputs: Iterable[str],
set_control_inputs: bool = True):
self._inputs = _decode_inputs(new_inputs, self._graph)
if set_control_inputs:
self._control_inputs = _decode_control_inputs(new_inputs, self._graph)
self._graph.increment_versio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, str_input: str, **kwargs) -> 'torch.tensor':",
"def set_inputs(self, new_inputs: Iterable[tensor.Tensor]):\n for t in new_inputs:\n if t.graph != self.graph:\n raise ValueError(\"Tensor {} points to graph {}, but this node is in a \"\n \"different graph {}\"... | [
"0.642068",
"0.6214423",
"0.61656475",
"0.60358316",
"0.5947922",
"0.5894804",
"0.56819355",
"0.5630046",
"0.5506179",
"0.54667187",
"0.5428107",
"0.53790903",
"0.5298283",
"0.529457",
"0.52481",
"0.52474445",
"0.52258575",
"0.5201906",
"0.5198419",
"0.5193988",
"0.51848245",... | 0.6462545 | 0 |
Extract and decode the inputs in a list of TensorFlow input specification strings. Skips over control inputs. | def _decode_inputs(inputs: Iterable[str], g: 'graph.Graph') -> List[
tensor.Tensor]:
# Input names in the protobuf take three forms:
# "^node_name" --> Control input from indicated node
# "node_name" --> Input from output number 0 of indicated node
# "node_name:ix" --> Input from output number <ix> of i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_control_inputs(inputs: Iterable[str], g: 'graph.Graph') -> List[\n Node]:\n # Control inputs start with \"^\". Skip everything else and strip off the\n # leading caret character\n control_input_names = [n[1:] for n in inputs if n.startswith(\"^\")]\n return [g[name] for name in control_input_names... | [
"0.62857395",
"0.57990235",
"0.5759292",
"0.5710552",
"0.5703565",
"0.56730574",
"0.56679714",
"0.5645313",
"0.5615229",
"0.5613884",
"0.5585734",
"0.5584618",
"0.55743283",
"0.5573157",
"0.5573157",
"0.5525622",
"0.54814094",
"0.5472601",
"0.54716367",
"0.54557717",
"0.54438... | 0.6953648 | 0 |
Extract and decode the control inputs in a list of TensorFlow input specification strings. Skips data inputs. | def _decode_control_inputs(inputs: Iterable[str], g: 'graph.Graph') -> List[
Node]:
# Control inputs start with "^". Skip everything else and strip off the
# leading caret character
control_input_names = [n[1:] for n in inputs if n.startswith("^")]
return [g[name] for name in control_input_names] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_inputs(inputs: Iterable[str], g: 'graph.Graph') -> List[\n tensor.Tensor]:\n # Input names in the protobuf take three forms:\n # \"^node_name\" --> Control input from indicated node\n # \"node_name\" --> Input from output number 0 of indicated node\n # \"node_name:ix\" --> Input from output ... | [
"0.6828303",
"0.5974251",
"0.5710084",
"0.56613046",
"0.5638093",
"0.5637403",
"0.5626847",
"0.5607357",
"0.5607357",
"0.5575951",
"0.55227053",
"0.55183804",
"0.55114716",
"0.55104005",
"0.5490225",
"0.54830337",
"0.5472033",
"0.54631436",
"0.5451295",
"0.5431369",
"0.538477... | 0.69665915 | 0 |
Convert a Python object or scalar value to a TensorFlow `tf.AttrValue` protocol buffer message. | def _python_type_to_attr_value(value: Any) -> tf.AttrValue:
# TODO(frreiss): Handle AttrValues that are lists
if isinstance(value, tf.AttrValue):
# TODO(frreiss): Should this case result in an error?
return value
# Scalar types, in the order they appear in the .proto file
elif isinstance(value, str):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_value(value):\n proto_value = proto.Value()\n if isinstance(value, int):\n proto_value.integer_value = value\n elif isinstance(value, float):\n proto_value.real_value = value\n elif isinstance(value, str):\n proto_value.string_value = value\n else:\n raise ProtoEr... | [
"0.6182536",
"0.59340006",
"0.5897383",
"0.5832336",
"0.57794446",
"0.57212096",
"0.57212096",
"0.56961167",
"0.5683621",
"0.5634957",
"0.56344485",
"0.56235605",
"0.56235605",
"0.5622986",
"0.5599108",
"0.559871",
"0.559871",
"0.559871",
"0.559871",
"0.55764854",
"0.55764854... | 0.7488524 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.