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 |
|---|---|---|---|---|---|---|
Wrapper function to start the inference on y and z. This function is not supposed to directly invoked by an end user. | def _infer_yz(self, init_y, init_z, output_file):
cur_y = init_y
cur_z = init_z
a_time = time()
self.auto_save_sample(sample = (cur_y, cur_z))
for i in xrange(self.niter):
temp_cur_y = self._infer_y(cur_y, cur_z)
temp_cur_y, temp_cur_z = self._infer_z(tem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cl_infer_yz(self, init_y, init_z, output_file = None):\n cur_y = init_y.astype(np.int32)\n cur_z = init_z.astype(np.int32)\n\n self.auto_save_sample(sample = (cur_y, cur_z))\n for i in xrange(self.niter):\n a_time = time()\n temp_cur_y = self._cl_infer_y(cur_y... | [
"0.589718",
"0.5841131",
"0.58281916",
"0.5808526",
"0.57577205",
"0.5736017",
"0.5717912",
"0.5535805",
"0.5463504",
"0.54472786",
"0.5421766",
"0.5421502",
"0.5402596",
"0.5340407",
"0.5328742",
"0.5244675",
"0.52309954",
"0.5217376",
"0.5213875",
"0.52043194",
"0.51488495"... | 0.59301764 | 0 |
Sample new features for all rows using Metropolis hastings. (This is a heuristic strategy aiming for easy parallelization in an equivalent GPU implementation. We here have effectively treated the current Z as a snapshot frozen in time, and each new k is based on this frozen snapshot of Z. In a more correct procedure, w... | def _sample_k_new(self, cur_y, cur_z):
N = float(len(self.obs))
#old_loglik = self._loglik(cur_y, cur_z)
k_new_count = np.random.poisson(self.alpha / N)
if k_new_count == 0: return False
# modify the feature ownership matrix
cur_z_new = np.hstack((cur_z, np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_new_columns(X, Z, Y, alpha, ep, lamb, p, K, N, T, i, max_newK):\n \n # Sample new columns in Zi\n \n # compute m_{-i}\n m = (Z.sum(axis=0) - Z[i,:])\n empty_columns = [k for k in range(K) if m[k] == 0]\n # if no dish k is chosen by other customers, costomer i also\n # doesn't cho... | [
"0.66274726",
"0.6185109",
"0.57289964",
"0.5715932",
"0.56852275",
"0.56301945",
"0.5619551",
"0.55991393",
"0.5460645",
"0.5444992",
"0.54320073",
"0.54262096",
"0.54172486",
"0.54044193",
"0.53876543",
"0.53804684",
"0.5321355",
"0.53113747",
"0.5277671",
"0.527502",
"0.52... | 0.64646554 | 1 |
Calculate the loglikelihood of the nth data point given Y and Z. | def _loglik_nth(self, cur_y, cur_z, n):
assert(cur_z.shape[1] == cur_y.shape[0])
not_on_p = np.power(1. - self.lam, np.dot(cur_z[n], cur_y)) * (1. - self.epislon)
loglik = np.log(np.abs(self.obs[n] - not_on_p)).sum()
return loglik | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loglikelihood(self, y):\n raise NotImplementedError",
"def log_likelihood(self):\r\n return (-0.5 * self.num_data * self.output_dim * np.log(2.*np.pi) -\r\n 0.5 * self.output_dim * self.K_logdet + self._model_fit_term() + self.likelihood.Z)",
"def log_likelihood(self, X, Y):\n\t\tr... | [
"0.7193272",
"0.7144615",
"0.7043891",
"0.6851601",
"0.68203324",
"0.6800954",
"0.67291296",
"0.6706404",
"0.6616848",
"0.66157484",
"0.65218693",
"0.6515573",
"0.6510056",
"0.6490959",
"0.64753515",
"0.6462785",
"0.6418685",
"0.6412296",
"0.6387245",
"0.6386189",
"0.6367109"... | 0.7665492 | 0 |
Wrapper function to start the inference on y and z. This function is not supposed to directly invoked by an end user. | def _cl_infer_yz(self, init_y, init_z, output_file = None):
cur_y = init_y.astype(np.int32)
cur_z = init_z.astype(np.int32)
self.auto_save_sample(sample = (cur_y, cur_z))
for i in xrange(self.niter):
a_time = time()
temp_cur_y = self._cl_infer_y(cur_y, cur_z)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _infer_yz(self, init_y, init_z, output_file):\n cur_y = init_y\n cur_z = init_z\n\n a_time = time()\n self.auto_save_sample(sample = (cur_y, cur_z))\n for i in xrange(self.niter):\n temp_cur_y = self._infer_y(cur_y, cur_z)\n temp_cur_y, temp_cur_z = self... | [
"0.5929839",
"0.5839118",
"0.58282053",
"0.5805653",
"0.57556677",
"0.5734969",
"0.57152647",
"0.55324167",
"0.54623395",
"0.5445588",
"0.5421506",
"0.54195994",
"0.5403253",
"0.5339283",
"0.53270924",
"0.5242037",
"0.52311444",
"0.5216052",
"0.5212722",
"0.52046627",
"0.5146... | 0.5897031 | 1 |
Command line interface for the ``rsyncsystembackup`` program. | def main():
# Initialize logging to the terminal and system log.
coloredlogs.install(syslog=True)
# Parse the command line arguments.
context_opts = dict()
program_opts = dict()
dest_opts = dict()
try:
options, arguments = getopt.gnu_getopt(sys.argv[1:], 'bsrm:c:t:i:unx:fvqh', [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # Initialize logging to the terminal and system log.\n coloredlogs.install(syslog=True)\n # Parse the command line arguments.\n context_opts = dict()\n program_opts = dict()\n dest_opts = dict()\n try:\n options, arguments = getopt.gnu_getopt(sys.argv[1:], 'bsrm:c:t:i:unx:... | [
"0.6710343",
"0.62548107",
"0.6175569",
"0.61126995",
"0.59780735",
"0.5970921",
"0.59538436",
"0.59538436",
"0.59447503",
"0.589895",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152",
"0.5860152"... | 0.64647496 | 1 |
Explicitly enable an action and disable other implicit actions. | def enable_explicit_action(options, explicit_action):
options[explicit_action] = True
for implicit_action in 'backup_enabled', 'snapshot_enabled', 'rotate_enabled':
if implicit_action != explicit_action:
options.setdefault(implicit_action, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def handle_action(**kwargs):\n name = kwargs[NAME]\n automation = automations[name]\n enabled = kwargs.get(ENABLED, not automation.enabled)\n if enabled:\n automation.enable()\n else:\n automation.disable()",
"def _set_action_enabled(self, action, in... | [
"0.68031824",
"0.65995437",
"0.6066111",
"0.6066111",
"0.6066111",
"0.6066111",
"0.6066111",
"0.6066111",
"0.60182357",
"0.6017138",
"0.5991636",
"0.5845606",
"0.58450794",
"0.5838078",
"0.5829897",
"0.5778151",
"0.5739981",
"0.57232684",
"0.57156926",
"0.57156926",
"0.571569... | 0.76075464 | 1 |
Takes a list of field names, and returns a list of nicely formatted table titles. | def get_display_names(fields, capitalized=False):
results = []
for field in fields:
field_title = get_display_name(field, capitalized)
results.append(field_title)
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_table(table, fieldnames):\n print(\"{:<19}\".format(fieldnames[0]), end='')\n for field in fieldnames[1:]:\n print(\"{:>6}\".format(field), end='')\n print(\"\")\n for name, row in table.items():\n # Header column left justified\n print(\"{:<19}\".format(name), end='')\n ... | [
"0.6871915",
"0.6871915",
"0.6417853",
"0.6304534",
"0.62668073",
"0.62325233",
"0.61983275",
"0.6144832",
"0.6040282",
"0.60191685",
"0.5931529",
"0.5849001",
"0.5849001",
"0.5775046",
"0.5766711",
"0.5763292",
"0.5751408",
"0.5751408",
"0.5701488",
"0.5696667",
"0.5649977",... | 0.711296 | 0 |
Given a column_data dict, get dicts mapping the system_name to the display name, and vice versa. | def get_system_name_mappings(column_data):
system_name_to_display_name = {}
display_name_to_system_name = {}
for key, entry in column_data.items():
if entry.get("system_name", None) is not None:
system_name = entry.get("system_name")
else:
system_name = key
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colf(c):\r\n return {\r\n 'name' : c.name,\r\n 'desc' : (c.desc or \"\").replace(\"'\", \"''\"),\r\n }",
"def get_columns_display(self):\n columns = []\n for column in self.columns:\n if None != column.display.name:\n colum... | [
"0.6087931",
"0.60292625",
"0.6022475",
"0.5762219",
"0.5652063",
"0.56327933",
"0.55371183",
"0.5506569",
"0.5500618",
"0.547709",
"0.54569846",
"0.54528105",
"0.5434474",
"0.5424923",
"0.5396106",
"0.5357846",
"0.53569615",
"0.5332602",
"0.5326638",
"0.5316779",
"0.5301289"... | 0.8588411 | 0 |
Removes all duplicates and None values from a list. | def remove_duplicates_and_nones(items):
new_list = [item for item in items if item is not None]
return list(set(new_list)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeDuplicates(list):\n\treturn set((item for item in list))",
"def removeDuplicates(list):\n\treturn Set((item for item in list))",
"def remove_identical(list):\n seen = set()\n seen_add = seen.add\n return [x for x in list if not (x in seen or seen_add(x))]",
"def remove_duplicates(somelist)... | [
"0.7455466",
"0.7372526",
"0.73472977",
"0.7192396",
"0.70618576",
"0.6948841",
"0.68821234",
"0.67630893",
"0.67591316",
"0.6743797",
"0.6683802",
"0.66673774",
"0.6657598",
"0.6640538",
"0.6638222",
"0.65908176",
"0.65785956",
"0.65566224",
"0.6555285",
"0.6516476",
"0.6502... | 0.7970348 | 0 |
Creates a dictionary that has the filter strings as keys, and related datetimes as values. | def create_time_filter_dict() -> dict:
today = datetime.today()
today_as_date = today.date()
one_day_delta = timedelta(hours=24)
time_filter_dict = {
constants.DAY_BEFORE_YESTERDAY: (
today_as_date - one_day_delta * 2,
today_as_date - one_day_delta,
),
con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_data(\n start: Optional[Union[datetime.datetime, int]] = None,\n filters: Optional[List[str]] = None,\n) -> dict:\n data: dict = {}\n\n if filters:\n data[\"filter\"] = {\"type\": filters}\n if isinstance(start, int):\n data[\"idFrom\"] = start\n elif start:\n data... | [
"0.6385779",
"0.5957761",
"0.58336747",
"0.58105445",
"0.5808338",
"0.5777027",
"0.5760657",
"0.57158995",
"0.5694243",
"0.56899464",
"0.56899464",
"0.56832033",
"0.56714803",
"0.5659847",
"0.5642168",
"0.5632335",
"0.5590067",
"0.5587351",
"0.5568641",
"0.55325323",
"0.55176... | 0.7608746 | 0 |
Returns true if there is any field of type 'TIMESTAMP'. | def table_has_any_timestamp_fields(table_object) -> bool:
mapper = sqlalchemy.inspect(table_object)
for column in mapper.all_orm_descriptors:
try:
if isinstance(column.type, PSQL_TIMESTAMP) or isinstance(column.type, SQLITE_TIMESTAMP):
return True
except Exception:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_timestamp(self):\n return (self.data_type() & 0x100 == 0x100) and (self.raw_data_length() >= 8)",
"def is_timestamp(schema_obj):\n\n if isinstance(schema_obj, schema.Field):\n return is_timestamp(schema_obj.metadata)\n elif isinstance(schema_obj, schema.Struct):\n return schema_obj.full_na... | [
"0.7676365",
"0.72473943",
"0.6599346",
"0.6493311",
"0.64784414",
"0.64533824",
"0.630886",
"0.62777746",
"0.62386745",
"0.6226853",
"0.6129638",
"0.6124494",
"0.60754615",
"0.60557073",
"0.6023504",
"0.59107685",
"0.5893657",
"0.5820352",
"0.5776331",
"0.57724726",
"0.57400... | 0.85252184 | 0 |
Create 3level pipeline with class_decompose node | def get_refinement_pipeline():
node_scaling = PrimaryNode('scaling')
node_logit = SecondaryNode('logit', nodes_from=[node_scaling])
node_decompose = SecondaryNode('class_decompose', nodes_from=[node_logit, node_scaling])
node_rfr = SecondaryNode('rfr', nodes_from=[node_decompose])
node_xgboost = Sec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_pipeline(preprocessors, classifier):\n if isinstance(preprocessors, list):\n # support only preprocessing of lenght 2\n return make_pipeline(preprocessors[0], preprocessors[1], classifier)\n if preprocessors is None:\n return make_pipeline(classifier)\n\n return make_pipelin... | [
"0.5983119",
"0.5843614",
"0.57839996",
"0.5739851",
"0.57256347",
"0.569445",
"0.5607251",
"0.5537179",
"0.553605",
"0.5526478",
"0.5520708",
"0.5504406",
"0.5499795",
"0.54133075",
"0.5318656",
"0.53102267",
"0.5288985",
"0.5273689",
"0.52705014",
"0.5266595",
"0.52664846",... | 0.5871426 | 1 |
Kills the xdaqLauncher process on all the SOAP hosts defined in the symbolmap | def stopXDAQLaunchers(symbolMap, options):
for host in symbolMap.allHosts:
if options.verbose > 1: print "Stopping xdaqLauncher for %-20s on %s:%d" % (host.name, host.host, host.port)
sendCmdToLauncher(host.host, host.lport, 'STOPLAUNCHER') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill_all():\n compose_kill_all()",
"def kill(ctx, analytic_host, analytic_port):\n client = aceclient.ConfigClient(host=analytic_host, port=analytic_port)\n client.kill()",
"def startXDAQLaunchers(logfile, symbolMap, options):\n\tfor host in symbolMap.allHosts:\n\t\tmessage = \"Starting xdaqLaunch... | [
"0.637408",
"0.6331278",
"0.6238737",
"0.6155876",
"0.61291707",
"0.6109371",
"0.6087781",
"0.60408145",
"0.6015993",
"0.59950566",
"0.5888462",
"0.5883321",
"0.58810717",
"0.5874338",
"0.58612394",
"0.58458805",
"0.5841272",
"0.5837246",
"0.5834478",
"0.5813091",
"0.5793882"... | 0.781776 | 0 |
Starts an xdaqLauncher process on all the SOAP hosts defined in the symbolmap | def startXDAQLaunchers(logfile, symbolMap, options):
for host in symbolMap.allHosts:
message = "Starting xdaqLauncher for %-20s on %s:%d(LAUNCHER):%d(SOAP)" % (host.name, host.host, host.lport, host.port)
logfile.write(message + '\n')
if options.verbose > 0: print message
startXDAQLauncher(host.host,host.lport... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopXDAQLaunchers(symbolMap, options):\n\tfor host in symbolMap.allHosts:\n\t\tif options.verbose > 1: print \"Stopping xdaqLauncher for %-20s on %s:%d\" % (host.name, host.host, host.port)\n\t\tsendCmdToLauncher(host.host, host.lport, 'STOPLAUNCHER')",
"def execute(self):\n st.logger.info(\"Starting ... | [
"0.6316289",
"0.5262719",
"0.52569586",
"0.5253838",
"0.52495235",
"0.52454346",
"0.5192769",
"0.51920235",
"0.51144266",
"0.51067114",
"0.51049423",
"0.5088486",
"0.5041231",
"0.502548",
"0.50068074",
"0.50043696",
"0.4997102",
"0.49842492",
"0.49768406",
"0.49520165",
"0.49... | 0.7838263 | 0 |
Get the Kuali API award_id for the specified version (or null if Kuali cannot recognize the given award_id. Sometimes the Kuail id is different, so this is a way to get the Kuali Id so we can use it | def get_kuali_award_id (self, award_id):
# print '\nget_kuali_award_id: award_id = {}'.format(award_id)
info = self.get_kuali_award_info(award_id)
# print 'info is a {}'.format(type(info))
# print json.dumps(info, indent=3)
"""
if info is not None:
# on a tot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"version_id\")",
"def api_version_set_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"api_version_set_id\")",
"def version_id(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self... | [
"0.5669601",
"0.5644947",
"0.5572146",
"0.55681574",
"0.54926604",
"0.5424982",
"0.53911453",
"0.5365259",
"0.5362972",
"0.529779",
"0.52589697",
"0.5236814",
"0.5183578",
"0.5139324",
"0.51244664",
"0.5120607",
"0.5109156",
"0.49912667",
"0.49534857",
"0.4926251",
"0.488669"... | 0.70256037 | 0 |
Kuali only matches the last 5 characters, so a minimal version of a given award_id takes the last 5 chars of the given award_id after sanitizing it. | def get_minimal_award_id(self, award_id):
return self.sanitize_id(award_id)[-5:].upper() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_kuali_award_id (self, award_id):\n # print '\\nget_kuali_award_id: award_id = {}'.format(award_id)\n info = self.get_kuali_award_info(award_id)\n # print 'info is a {}'.format(type(info))\n # print json.dumps(info, indent=3)\n\n \"\"\"\n if info is not None:\n ... | [
"0.56981677",
"0.54890305",
"0.530687",
"0.5288465",
"0.52571994",
"0.5210429",
"0.51059014",
"0.49819526",
"0.49805164",
"0.49524722",
"0.49329552",
"0.48945466",
"0.48912853",
"0.48705077",
"0.48637292",
"0.48533317",
"0.48458296",
"0.48175868",
"0.47771263",
"0.47766015",
... | 0.7643676 | 0 |
Test given award_id against the skip_award_ids in config | def accept_award_id(self, award_id):
return not self.get_minimal_award_id(award_id) in self.skip_award_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_awards(user):\n\n valid = []\n for award in awards.ALL_AWARDS:\n\n # Valid award targets the user has earned\n targets = award.validate(user)\n for target in targets:\n\n date = util.now()\n post = target if isinstance(target, Post) else None\n ... | [
"0.54424304",
"0.5383964",
"0.52787364",
"0.51821446",
"0.51033694",
"0.50618356",
"0.50346214",
"0.49817416",
"0.49416718",
"0.4924621",
"0.4853972",
"0.48285246",
"0.48197645",
"0.4799761",
"0.47971004",
"0.47952697",
"0.477551",
"0.4759991",
"0.4740793",
"0.47354448",
"0.4... | 0.75333613 | 0 |
Reload given slot in next request | def reload_slot(slotnames, method = 'session'):
if not isinstance(slotnames, (tuple, list)):
slotnames = [slotnames]
bean = beans.Reload(
slot = slotnames
)
return push_bean(bean, method = method) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n if self.size() < 2: return\n idx = random.randint(0, 100) % 3\n if idx < 2:\n slot = self.slots[idx]\n if slot.get_state() == Slot.CLEAN:\n slot.set_state(Slot.DIRTY)\n # self.slots[idx] = slot",
"def reload(self):",
"def reload(self):",
"def receive_reloa... | [
"0.59261155",
"0.579679",
"0.579679",
"0.5667704",
"0.56408143",
"0.5556539",
"0.54900676",
"0.547919",
"0.5428959",
"0.53864604",
"0.5384466",
"0.5384466",
"0.5384466",
"0.53842074",
"0.5379379",
"0.53750956",
"0.5352296",
"0.53411967",
"0.53373516",
"0.5322005",
"0.53196245... | 0.7035707 | 0 |
Check if there is a valid range measurement. The ranges are accumulated in a counter that will increment on each edge of the echo (return) signal. If the count is not at least 2, then the range has not yet been measured, and is invalid. | def isRangeValid(self) -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_range(r): \n if _is_single_range(r):\n _check_one_range(r)\n elif isinstance(r, collections.Sequence):\n for r2 in r:\n _check_one_range(r2)\n else:\n raise error.RangeSyntaxError(str(r))",
"def __check_args_val(self):\n if self.__min_range < 0:\n ... | [
"0.63066536",
"0.618112",
"0.612251",
"0.60644126",
"0.6058516",
"0.6038112",
"0.6018616",
"0.58863693",
"0.5883105",
"0.58621013",
"0.58412915",
"0.58394814",
"0.57911783",
"0.5767024",
"0.5759247",
"0.5752649",
"0.573648",
"0.5732297",
"0.5712428",
"0.57031846",
"0.56989425... | 0.6878384 | 0 |
Get the range in inches from the ultrasonic sensor. | def getRangeInches(self) -> float:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_range(self):\r\n\t\tif self.battery_size == 70:\r\n\t\t\trange = 240\r\n\t\telif self.battery_size == 85:\r\n\t\t\trange = 270\r\n\t\t\t\r\n\t\tmessage = \"This car can go approx. \" + str(range)\r\n\t\tmessage += \" miles on a full charge.\"\r\n\t\tprint(message)",
"def get_range(self):\n if self... | [
"0.659789",
"0.6594538",
"0.6551424",
"0.65348697",
"0.6519224",
"0.6512357",
"0.6506367",
"0.63758546",
"0.6313422",
"0.6307522",
"0.62845397",
"0.6278194",
"0.62337327",
"0.62206554",
"0.60946774",
"0.60610116",
"0.606093",
"0.5962434",
"0.5936345",
"0.5908264",
"0.58799195... | 0.8102604 | 0 |
Get the range in millimeters from the ultrasonic sensor. | def getRangeMM(self) -> float:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRangeInches(self) -> float:\n ...",
"def get_range(self):\n if self.battery_size == 75:\n range = 260\n elif self.battery_size == 100:\n range = 315\n\n print(f'This car can go about {range} miles on a full charge.')",
"def get_range(self):\r\n\t\tif sel... | [
"0.6462022",
"0.6445826",
"0.6424191",
"0.6402999",
"0.6382009",
"0.6380849",
"0.6380303",
"0.63755566",
"0.63594264",
"0.6340446",
"0.6222819",
"0.62067294",
"0.61956245",
"0.61195254",
"0.60940075",
"0.60561734",
"0.60307753",
"0.5924822",
"0.58994776",
"0.58833086",
"0.587... | 0.68864626 | 0 |
Set the current DistanceUnit that should be used for the PIDSource interface. | def setDistanceUnits(self, units: Unit) -> None:
self.units = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_unit(self,unit):\n self.unit = unit",
"def measurement_unit(self, measurement_unit):\n\n self._measurement_unit = measurement_unit",
"def set_units(self, units):\n self.units = units",
"def set_distance(self):\n distance = self.gui.doubleSpinBox_distance.value()\n u... | [
"0.6926105",
"0.65910643",
"0.65705705",
"0.63681585",
"0.63088405",
"0.63088405",
"0.63088405",
"0.62139606",
"0.62139606",
"0.62139606",
"0.6166226",
"0.61576456",
"0.6138217",
"0.60676545",
"0.5938943",
"0.5925391",
"0.5922442",
"0.5916443",
"0.58996546",
"0.589325",
"0.58... | 0.7460237 | 0 |
Warn if the configured replay buffer size is too large. | def warn_replay_buffer_size(*, item: SampleBatchType, num_items: int) -> None:
if log_once("replay_buffer_size"):
item_size = item.size_bytes()
psutil_mem = psutil.virtual_memory()
total_gb = psutil_mem.total / 1e9
mem_size = num_items * item_size / 1e9
msg = ("Estimated max ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_buf_too_large(self):\n connection = Connection(Context(SSLv23_METHOD), None)\n with pytest.raises(ValueError) as exc_info:\n connection.send(VeryLarge())\n exc_info.match(r\"Cannot send more than .+ bytes at once\")",
"def _metadata_too_large(self):\n # currently t... | [
"0.60677063",
"0.57969433",
"0.5794766",
"0.5661886",
"0.56452185",
"0.56213117",
"0.5610429",
"0.5544855",
"0.5487711",
"0.5483159",
"0.544797",
"0.54424894",
"0.54298776",
"0.5427028",
"0.54172814",
"0.5414456",
"0.5412169",
"0.5403939",
"0.5357103",
"0.53543234",
"0.532918... | 0.71090895 | 0 |
Update priorities of sampled transitions. sets priority of transition at index idxes[i] in buffer to priorities[i]. | def update_priorities(self, idxes, priorities):
assert len(idxes) == len(priorities)
for idx, priority in zip(idxes, priorities):
assert priority > 0
assert 0 <= idx < len(self._storage)
delta = priority**self._alpha - self._it_sum[idx]
self._prio_change_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_priorities(self, idxes, priorities):\n assert len(idxes) == len(priorities)\n for ndx, priority in zip(idxes, priorities):\n assert priority > 0\n assert 0 <= ndx < len(self.memory)\n self.iter_sum[ndx] = priority ** self.alpha\n self.iter_min[nd... | [
"0.7280941",
"0.71658033",
"0.71581376",
"0.71581376",
"0.7075748",
"0.70220536",
"0.6980962",
"0.6799073",
"0.6607631",
"0.6557839",
"0.6351649",
"0.62263006",
"0.6114598",
"0.58433586",
"0.5759857",
"0.56959903",
"0.535149",
"0.5245115",
"0.52051663",
"0.51436406",
"0.51369... | 0.7185747 | 1 |
Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single argument which is a Pipeline object. Copied directly from redispy. | def transaction(self, func, *watches, **kwargs):
shard_hint = kwargs.pop('shard_hint', None)
value_from_callable = kwargs.pop('value_from_callable', False)
watch_delay = kwargs.pop('watch_delay', None)
with self.pipeline(True, shard_hint) as pipe:
while 1:
try... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execWrap(func):\n @wraps(func)\n def addAndExec(self, *args, **kwargs):\n execute = False\n if 'execute' in kwargs:\n execute = kwargs.pop('execute')\n if 'minimal_reset' in kwargs:\n minimal_reset = kwargs.pop('minimal_reset')\n ... | [
"0.53148216",
"0.5277638",
"0.5261236",
"0.5231447",
"0.52079254",
"0.51959705",
"0.5179855",
"0.51653",
"0.51292115",
"0.5121816",
"0.5111379",
"0.50960034",
"0.5044633",
"0.5024267",
"0.49387085",
"0.4937853",
"0.49340802",
"0.48331815",
"0.48177177",
"0.481186",
"0.4805152... | 0.8057213 | 0 |
Mock does not support command buffering so unwatch is a noop | def unwatch(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_main_watch_flag():\n with mock.patch('uflash.watch_file') as mock_watch_file:\n uflash.main(argv=['-w'])\n mock_watch_file.assert_called_once_with(None,\n uflash.flash,\n path_to_python=None,\n ... | [
"0.6332054",
"0.60854733",
"0.5928291",
"0.5909836",
"0.5903807",
"0.5864414",
"0.58261585",
"0.5795507",
"0.578597",
"0.57852924",
"0.57852924",
"0.57809085",
"0.5758983",
"0.57208",
"0.5681033",
"0.5626587",
"0.56217086",
"0.5621457",
"0.5621023",
"0.5595023",
"0.5588643",
... | 0.63843215 | 0 |
Return the value at key ``name``, raises a KeyError if the key doesn't exist. | def __getitem__(self, name):
value = self.get(name)
if value is not None:
return value
raise KeyError(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self, name):\n values = self.__get('values')\n return values[name]",
"def find_by_name(self, name):\n return self.get(name)",
"def get_value(name):\n\n named_value = get_named_value_raw(name)\n if named_value is not None:\n return named_value.value",
"def __geti... | [
"0.74732757",
"0.7470759",
"0.74203056",
"0.737142",
"0.735383",
"0.73243916",
"0.7243755",
"0.72153246",
"0.7122572",
"0.71200734",
"0.699127",
"0.6919871",
"0.6898846",
"0.68914413",
"0.68164665",
"0.670264",
"0.6695129",
"0.6671604",
"0.665578",
"0.6648965",
"0.6592327",
... | 0.81910616 | 0 |
Determine if it is okay to set a key. If the mode is None, returns True, otherwise, returns True of false based on the value of ``key`` and the ``mode`` (nx | xx). | def _should_set(self, key, mode):
if mode is None or mode not in ["nx", "xx"]:
return True
if mode == "nx":
if key in self.redis:
# nx means set only if key is absent
# false if the key already exists
return False
elif key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_key(self, key, value) -> True:\n\n if key in self.key_functs:\n # Validate the value\n real_val = self.key_functs[key](value)\n \n if real_val is not None:\n self.key_values[key] = real_val \n self.key_satified[key] = True\n ... | [
"0.64102256",
"0.62642246",
"0.6209774",
"0.60591066",
"0.58405906",
"0.58133566",
"0.57896006",
"0.57798964",
"0.5767637",
"0.5759848",
"0.5633752",
"0.5633752",
"0.55967325",
"0.5548191",
"0.5541892",
"0.55022657",
"0.5482541",
"0.54504484",
"0.54223025",
"0.54062855",
"0.5... | 0.819936 | 0 |
Set the value of ``key`` to ``value`` that expires in ``time`` milliseconds. ``time`` can be represented by an integer or a Python timedelta object. | def psetex(self, key, time, value):
return self.set(key, value, px=time) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setex(self, key, time, value):\n if not self.strict:\n # when not strict mode swap value and time args order\n time, value = value, time\n return self.set(key, value, ex=time)",
"def update_time(cls, key):\n key.put()",
"def expire_time(self, expire_time):\n\n ... | [
"0.7040453",
"0.70008814",
"0.6638151",
"0.6574844",
"0.6524216",
"0.64648604",
"0.6364181",
"0.6361585",
"0.626963",
"0.62682277",
"0.62282383",
"0.6220278",
"0.61583436",
"0.6135086",
"0.6088108",
"0.6060081",
"0.6027692",
"0.59981227",
"0.59852886",
"0.59852886",
"0.598528... | 0.72595423 | 0 |
Sets key/values based on a mapping if none of the keys are already set. Mapping can be supplied as a single dictionary argument or as kwargs. Returns a boolean indicating if the operation was successful. | def msetnx(self, *args, **kwargs):
if args:
if len(args) != 1 or not isinstance(args[0], dict):
raise RedisError('MSETNX requires **kwargs or a single dict arg')
mapping = args[0]
else:
mapping = kwargs
for key in mapping.keys():
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mset(self, *args, **kwargs):\n if args:\n if len(args) != 1 or not isinstance(args[0], dict):\n raise RedisError('MSET requires **kwargs or a single dict arg')\n mapping = args[0]\n else:\n mapping = kwargs\n for key, value in mapping.items()... | [
"0.68879855",
"0.61209124",
"0.6070162",
"0.5964655",
"0.58735603",
"0.5862097",
"0.58271444",
"0.57803005",
"0.5770855",
"0.5634866",
"0.56313485",
"0.56219554",
"0.5589811",
"0.5465565",
"0.5444904",
"0.5429195",
"0.53811026",
"0.5345851",
"0.53390455",
"0.5338022",
"0.5333... | 0.65423155 | 1 |
Set the bit at ``offset`` in ``key`` to ``value``. | def setbit(self, key, offset, value):
key = self._encode(key)
index, bits, mask = self._get_bits_and_offset(key, offset)
if index >= len(bits):
bits.extend(b"\x00" * (index + 1 - len(bits)))
prev_val = 1 if (bits[index] & mask) else 0
if value:
bits[ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(self, key, value):",
"def set(self, key, value):",
"def set_bit(x, k):\n\n return x | (1 << k)",
"def set(self, key, value):\n raise NotImplementedError",
"def getbit(self, key, offset):\n key = self._encode(key)\n index, bits, mask = self._get_bits_and_offset(key, offset)\n... | [
"0.6134272",
"0.6134272",
"0.59715444",
"0.5942624",
"0.5779687",
"0.5687319",
"0.5664457",
"0.5659524",
"0.5644084",
"0.5644084",
"0.564218",
"0.56098455",
"0.5609795",
"0.5606328",
"0.56026137",
"0.55904293",
"0.558548",
"0.5582235",
"0.5432808",
"0.5424066",
"0.54183215",
... | 0.8331223 | 0 |
Returns the bit value at ``offset`` in ``key``. | def getbit(self, key, offset):
key = self._encode(key)
index, bits, mask = self._get_bits_and_offset(key, offset)
if index >= len(bits):
return 0
return 1 if (bits[index] & mask) else 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setbit(self, key, offset, value):\n key = self._encode(key)\n index, bits, mask = self._get_bits_and_offset(key, offset)\n\n if index >= len(bits):\n bits.extend(b\"\\x00\" * (index + 1 - len(bits)))\n\n prev_val = 1 if (bits[index] & mask) else 0\n\n if value:\n ... | [
"0.6732826",
"0.66810805",
"0.62460935",
"0.6136394",
"0.5937557",
"0.57792",
"0.5751411",
"0.5693134",
"0.5644532",
"0.5614832",
"0.5540826",
"0.549021",
"0.54867125",
"0.5462624",
"0.5371628",
"0.5365751",
"0.535212",
"0.5333659",
"0.5326407",
"0.53229874",
"0.5322105",
"... | 0.8475952 | 0 |
Sends call to the function, whose name is specified by command. Used by Script invocations and normalizes calls using standard Redis arguments to use the expected redispy arguments. | def call(self, command, *args):
command = self._normalize_command_name(command)
args = self._normalize_command_args(command, *args)
redis_function = getattr(self, command)
value = redis_function(*args)
return self._normalize_command_response(command, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_function(self):\n try:\n arg_list = self.argument_list()\n function_dict = {}\n info = []\n for name_arg in arg_list:\n type_arg = self.arguments_type[name_arg]\n function_dict[name_arg] = utils.value_from_rpc(self.argument(n... | [
"0.67461723",
"0.6705813",
"0.6604294",
"0.6512697",
"0.6360923",
"0.6327566",
"0.6195903",
"0.6111162",
"0.60698766",
"0.5989694",
"0.59719986",
"0.5901155",
"0.5900953",
"0.5893763",
"0.589267",
"0.58679116",
"0.5820663",
"0.5779622",
"0.575355",
"0.5723605",
"0.57233727",
... | 0.7285501 | 0 |
Return a mocked 'PubSub' object | def pubsub(self, **kwargs):
if not self._pubsub:
self._pubsub = Pubsub(self, **kwargs)
return self._pubsub | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_publisher(self):\n self._signals = None\n\n topic = \"test\"\n subscriber = Subscriber(self._signals_handler, topic=topic)\n subscriber.open()\n\n publisher = Publisher(topic=topic)\n publisher.open()\n signals = [Signal({\"attr1\": 1})]\n publisher.... | [
"0.6158108",
"0.5998775",
"0.59268236",
"0.5877705",
"0.5842496",
"0.5837425",
"0.5816417",
"0.5805716",
"0.57750773",
"0.57750773",
"0.5762184",
"0.5752732",
"0.5723335",
"0.56852096",
"0.5682345",
"0.56751305",
"0.56651276",
"0.56516623",
"0.5650754",
"0.5625824",
"0.561820... | 0.6202938 | 0 |
Get (and maybe create) a hash by name. | def _get_hash(self, name, operation, create=False, decode=False):
return self._get_by_type(name, operation, create, b'hash', {}, decode=decode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def existing_hash(self, id):\r\n return self._read_sha_by_id(id)",
"def sdbm_hash(name):\n ret = 0\n for ii in name:\n ret = (ret * 65599 + ord(ii)) & 0xFFFFFFFF\n return hex(ret)",
"def _get_algorithm(name: str) -> Any:\n algo_cls = getattr(hashes, name.upper(), None) # hack: get class object... | [
"0.67152953",
"0.61589485",
"0.6137727",
"0.59149814",
"0.59149814",
"0.58886266",
"0.5857459",
"0.5830228",
"0.5754057",
"0.5748696",
"0.572688",
"0.57236224",
"0.5695691",
"0.5682205",
"0.5661031",
"0.563687",
"0.5634053",
"0.5620056",
"0.56150216",
"0.5608825",
"0.5596498"... | 0.75094104 | 0 |
Get (and maybe create) a redis data structure by name and type. | def _get_by_type(self, key, operation, create, type_, default, return_default=True, decode=False):
key = self._encode(key)
if self.type(key) in [type_, b'none']:
if create:
val = self.redis.setdefault(key, default)
if decode:
val = self._de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(**args):\n\tglobal _objstore\n\t_objstore = _objstore or ObjStore()\n\n\treturn _objstore.get(args['type'], args['name'])",
"def _get_data(data_type, table, force):\n if force or data_type not in _cache:\n _cache[data_type] =read_table(table)\n return _cache[data_type]",
"def findOrCreate(... | [
"0.6400278",
"0.56770957",
"0.56339157",
"0.5553604",
"0.55489254",
"0.5538565",
"0.5450116",
"0.5443798",
"0.54046303",
"0.53572154",
"0.52906203",
"0.5244328",
"0.52157265",
"0.5213861",
"0.51947993",
"0.5178807",
"0.5164404",
"0.5158025",
"0.51561177",
"0.5144226",
"0.5128... | 0.5786061 | 1 |
Translate range to valid bounds. | def _translate_range(self, len_, start, end):
start = int(start)
end = int(end)
if start < 0:
start += len_
start = max(0, min(start, len_))
if end < 0:
end += len_
end = max(-1, min(end, len_ - 1))
return start, end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isRangeValid(self) -> bool:\n ...",
"def _check_range(range_):\n try:\n if not isinstance(range_, list):\n range_ = list(range_)\n min_, max_ = range_\n except (ValueError, TypeError):\n raise TypeError(\"each range in ising_linear_ranges s... | [
"0.6792045",
"0.6740813",
"0.6739882",
"0.6569263",
"0.65664595",
"0.64536524",
"0.6420307",
"0.6340678",
"0.63313043",
"0.63270724",
"0.6320905",
"0.6298063",
"0.62930894",
"0.62848055",
"0.62519956",
"0.6236294",
"0.62218565",
"0.62152773",
"0.6167057",
"0.6131894",
"0.6113... | 0.7150845 | 0 |
Return a suitable aggregate score function. | def _aggregate_func(self, aggregate):
funcs = {"sum": add, "min": min, "max": max}
func_name = aggregate.lower() if aggregate else 'sum'
try:
return funcs[func_name]
except KeyError:
raise TypeError("Unsupported aggregate: {}".format(aggregate)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score_fn(self):\n raise NotImplementedError()",
"def make_score_fn(self):\n return self._score_fn",
"def agg(self, values, agg_func):\n assert len(values) > 0, \"Empty list of values\"\n f = agg_func.strip().lower()\n assert f in self.__AGGREGATIONS, \"Aggregation functio... | [
"0.6903806",
"0.6777869",
"0.6506195",
"0.64191926",
"0.62786025",
"0.6253399",
"0.6169718",
"0.6146417",
"0.60425067",
"0.6038827",
"0.5987032",
"0.5985893",
"0.5963838",
"0.5910903",
"0.5864561",
"0.5859613",
"0.58542806",
"0.58485496",
"0.5847737",
"0.58378357",
"0.5816855... | 0.70793754 | 0 |
Mock common.util.redis_client so we can return a MockRedis object instead of a Redis object. | def mock_redis_client(**kwargs):
return MockRedis(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_strict_redis_client(**kwargs):\n return MockRedis(strict=True, **kwargs)",
"def test_redisdb_get_client():\n test_redisdb = RedisClient()\n test_redisdb.client = \"mock_client\"\n\n test_redisdb_client = test_redisdb.get_client()\n assert test_redisdb_client == \"mock_client\"",
"def _C... | [
"0.8197153",
"0.8122069",
"0.791009",
"0.791009",
"0.76025003",
"0.75907195",
"0.7473811",
"0.7251885",
"0.7233809",
"0.7131985",
"0.71069694",
"0.70074874",
"0.69635284",
"0.6934647",
"0.6865683",
"0.6864632",
"0.6750619",
"0.67405236",
"0.66737646",
"0.666578",
"0.66268206"... | 0.91479844 | 0 |
Mock common.util.redis_client so we can return a MockRedis object instead of a StrictRedis object. | def mock_strict_redis_client(**kwargs):
return MockRedis(strict=True, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_redis_client(**kwargs):\n return MockRedis(**kwargs)",
"def test_redisdb_get_client():\n test_redisdb = RedisClient()\n test_redisdb.client = \"mock_client\"\n\n test_redisdb_client = test_redisdb.get_client()\n assert test_redisdb_client == \"mock_client\"",
"def _CreateRedisClient(sel... | [
"0.9086748",
"0.806707",
"0.7959537",
"0.7959537",
"0.77429706",
"0.77351975",
"0.74805474",
"0.73356754",
"0.720046",
"0.7193512",
"0.7130242",
"0.71208245",
"0.69707495",
"0.6922421",
"0.6919194",
"0.6900505",
"0.6892305",
"0.67665774",
"0.6732179",
"0.6644773",
"0.66403073... | 0.859045 | 1 |
Convert a bunch of arguments to be modints mod p. | def modp(p, *args):
return [modint(a, p) for a in args] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mod(p):\n return (p[0]**2 + p[1]**2 + p[2]**2)**0.5",
"def mod(numbers):\n result = numbers[0]\n for i in numbers[1:]:\n result = result % i\n return result",
"def mod_inv(a,p):\r\n\r\n for i in range(1,p):\r\n if (i*a)%p==1: return i\r\n raise ValueError(str(a)+\" has no in... | [
"0.65537137",
"0.61288244",
"0.6011858",
"0.59562004",
"0.5943602",
"0.56930816",
"0.56716883",
"0.5630104",
"0.5585334",
"0.5563822",
"0.5539628",
"0.5500951",
"0.54368883",
"0.5409419",
"0.5376827",
"0.53651255",
"0.5364745",
"0.53604364",
"0.5349904",
"0.5329728",
"0.53292... | 0.83662033 | 0 |
Makes a random field element and multiplies the base point by it. This forms a key pair. | def generate_key(self, rand = random.SystemRandom()):
k = rand.randrange(0, self.n - 1)
return k, self.base_mul(k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computeSecretKey(g, p):\r\n \"\"\"You will need to implement this function.\"\"\"\r\n return random.randint(1, p-1)",
"def generate_keys(self):\n\n\t\tmin_ext = 1 << self.size_ext - 1\n\t\tmax_ext = 1 << self.size_ext\n\t\t\n\t\t\t\n\t\t# step 1 : chose random primary numbers p and q\n\t\tn = generate_... | [
"0.6333974",
"0.62462646",
"0.6156392",
"0.61443454",
"0.60328287",
"0.6014512",
"0.59524864",
"0.5952345",
"0.5935608",
"0.5813784",
"0.5767382",
"0.57640827",
"0.5721004",
"0.5679608",
"0.56794393",
"0.5671089",
"0.5670806",
"0.5652684",
"0.5651378",
"0.5634336",
"0.5617178... | 0.7090892 | 0 |
Multiplies scalar d by the base point. | def base_mul(self, d):
return self.point_mul(d, self.G) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_mul(self, d, P):\n Q = point.inf()\n for i in range(d.bit_length()):\n if (1 << i) & d:\n Q = self.point_add(Q, P)\n P = self.point_double(P)\n return Q",
"def __imul__(self, d_value: float):\n self.set_value(self.get_value() * d_value)\n... | [
"0.67197615",
"0.66238266",
"0.63616204",
"0.61848956",
"0.61848956",
"0.59910935",
"0.5847913",
"0.58364666",
"0.5803313",
"0.5783168",
"0.5760679",
"0.5731173",
"0.56942767",
"0.5625842",
"0.5594093",
"0.5585463",
"0.558509",
"0.55427283",
"0.554114",
"0.55357194",
"0.55332... | 0.8486849 | 0 |
Point multiplication of P by a scalar d. This is trivial doubleandadd. It has gaping side channels which will leak d to anybody watching. | def point_mul(self, d, P):
Q = point.inf()
for i in range(d.bit_length()):
if (1 << i) & d:
Q = self.point_add(Q, P)
P = self.point_double(P)
return Q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_mul(self, d):\n return self.point_mul(d, self.G)",
"def penalty_brute_force(\r\n D_mul: Iterable[np.ndarray], sp: Iterable[Union[int, float]]\r\n) -> np.ndarray:\r\n\r\n if len(sp) != len(D_mul):\r\n raise ValueError(\r\n \"Number of smoothing parameters must be equal to n... | [
"0.67979366",
"0.63474745",
"0.60301435",
"0.5976904",
"0.5928561",
"0.57186306",
"0.5703848",
"0.5692015",
"0.5641626",
"0.55559283",
"0.5518361",
"0.55151975",
"0.5501478",
"0.5494158",
"0.5485141",
"0.54826105",
"0.5480263",
"0.5462061",
"0.5457237",
"0.544474",
"0.5442257... | 0.74579954 | 0 |
Returns true if P satisfies the curve equation. | def point_on_curve(self, P):
x, y = modp(self.p, P.x, P.y)
lhs = y ** 2
rhs = x ** 3 + x * self.a + self.b
return lhs == rhs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_point_on_curve(self, P):\n x, y, = P[0], P[1]\n left = y * y\n right = (x * x * x) + (self.a * x) + self.b\n return (left - right) % self.p == 0",
"def whetherOn(self, P):\n if isinstance(P, list):\n if len(P) == 2:\n if self.ch == 0:\n ... | [
"0.77516717",
"0.73257875",
"0.72985697",
"0.6743118",
"0.6743118",
"0.6743118",
"0.6743118",
"0.6743118",
"0.6743118",
"0.66668874",
"0.65820754",
"0.6507073",
"0.64489925",
"0.64489925",
"0.64489925",
"0.6436246",
"0.6435313",
"0.62782043",
"0.6234391",
"0.6234391",
"0.6079... | 0.7759136 | 0 |
Returns the points with given x coordinate. | def points_at_x(self, x):
x, = modp(self.p, x)
rhs = x ** 3 + x * self.a + self.b
y = rhs.sqrt()
return point.xy(int(x), int(y)), point.xy(int(x), -int(y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPointValues(a, Y, x):\n raise NotImplementedError('getPoint not implemented')",
"def x_points(self):\n return self._x_points",
"def getXPoint(self, x):\n # Find the correct parameter\n t = (x - self.p0.x) / self.d.x\n return self.point(t)",
"def get_points_in_range(s... | [
"0.7419202",
"0.72134995",
"0.6982298",
"0.6770743",
"0.66090107",
"0.6284259",
"0.6271994",
"0.62603056",
"0.6205067",
"0.61887723",
"0.6174185",
"0.6170933",
"0.61351204",
"0.613188",
"0.6098287",
"0.60876954",
"0.60692036",
"0.60692036",
"0.60246706",
"0.60244715",
"0.6015... | 0.76503134 | 0 |
Takes a dictionary game state as inputs, wwwextracts and returns the values of that dict in a tuple | def get_values(state):
keys = ['player_ammo', 'player_block', 'player_prev',
'comp_ammo', 'comp_block', 'comp_prev']
return tuple([state[key] for key in keys]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(url):\n soup = fetch_url(url)\n result = {}\n if soup:\n text = text_from_html(soup)\n text = re.sub(' +', ' ', text)\n result_list = pos_text(text)\n\t#print \"result_list\", result_list\n\tword_tuple = []\n\tfor x in result_list:\n\t res = hash_word(x)\n\t word_tuple... | [
"0.5509158",
"0.55000025",
"0.5382152",
"0.5288873",
"0.5052048",
"0.5014089",
"0.49913195",
"0.49819207",
"0.49453604",
"0.48833665",
"0.4868014",
"0.48380366",
"0.48375234",
"0.47892305",
"0.4780504",
"0.4775641",
"0.47500134",
"0.47470203",
"0.4741439",
"0.47385085",
"0.47... | 0.58605653 | 0 |
list all documetns in coll | def list_all(mongo_collection):
return [doc for doc in mongo_collection.find()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all(mongo_collection):\n docs = []\n list_all = mongo_collection.find()\n for i in list_all:\n docs.append(i)\n return docs",
"def get_all_documents(self, collection):\n\n return self.client[self.db][collection].find()",
"def get_all(collection):\n data = []\n f... | [
"0.73730826",
"0.68168217",
"0.66327924",
"0.6589942",
"0.642226",
"0.6372828",
"0.63533735",
"0.61743975",
"0.6075899",
"0.6062464",
"0.6040362",
"0.6026113",
"0.59542215",
"0.59509087",
"0.5925475",
"0.59254205",
"0.5917495",
"0.5917443",
"0.5882291",
"0.5874069",
"0.585076... | 0.77565086 | 0 |
Runs RPCA with an rclr preprocessing step | def rpca(in_biom: str, output_dir: str,
min_sample_depth: int, rank: int) -> None:
# import table
table = load_table(in_biom)
# filter sample to min depth
def sample_filter(val, id_, md): return sum(val) > min_sample_depth
table = table.filter(sample_filter, axis='sample')
table = tab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ExecRapi(options, args, prep_data): # pylint: disable=W0613\n (mainloop, server) = prep_data\n try:\n mainloop.Run()\n finally:\n server.Stop()",
"def run_preprocessing(run):\n def _process(run):\n \"\"\" Process a run/flowcell and transfer to analysis server\n :param taca.illum... | [
"0.5839349",
"0.55255485",
"0.5516698",
"0.54086316",
"0.52634037",
"0.5048639",
"0.49863264",
"0.4977144",
"0.49452505",
"0.492501",
"0.4918108",
"0.4908721",
"0.48868296",
"0.48605832",
"0.4854571",
"0.4845153",
"0.48418036",
"0.48395613",
"0.48393843",
"0.483885",
"0.48367... | 0.560842 | 1 |
Initialize stream variables and output stream. channels [default=1] Amount of channels to use in audio sample_size [default=1] Size of each sample frame_rate [default=44100] The frame_rate to use for input and output period_size [default=320] periode size of each buffer. | def __init__(self, channels=1, sample_size=1, frame_rate=44100, period_size=320):
self.channels = channels
self.frame_size = self.channels * sample_size
self.frame_rate = frame_rate
self.period_size = period_size
self.create_output_stream() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, chunk=512, audio_format=pyaudio.paInt16, channels=1, rate=44100):\n self.CHUNK = chunk\n self.FORMAT = audio_format\n self.CHANNELS = channels\n self.RATE = rate\n self.recorder = pyaudio.PyAudio()\n self.stream = None\n self.streaming_mode = Fals... | [
"0.73017293",
"0.7080278",
"0.70181805",
"0.67840534",
"0.6669335",
"0.6568012",
"0.6503089",
"0.64523774",
"0.6185531",
"0.6074465",
"0.601397",
"0.59632283",
"0.59410733",
"0.59069043",
"0.5877795",
"0.58641905",
"0.585574",
"0.5806011",
"0.5755223",
"0.5746444",
"0.5725815... | 0.8239414 | 0 |
Detroy input stream to prevent memory issues. | def destroy_input_stream(self):
# Destroy the stream
del self.inp
# Garbage collect
gc.collect() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_stream(s):\n s.truncate(0)\n s.seek(0)\n return s",
"def finalize(self):\r\n self.stream.finalize()",
"def reset_output(self):\r\n self.output.seek(0)\r\n self.output.truncate(0)",
"def close_file_deserializer(self):\n if self._input_file:\n self._inp... | [
"0.66395247",
"0.64044696",
"0.63813037",
"0.63527256",
"0.6342004",
"0.6325318",
"0.6256812",
"0.62027556",
"0.61736",
"0.61630183",
"0.6154856",
"0.61299396",
"0.6100422",
"0.608274",
"0.6031595",
"0.60282236",
"0.59990877",
"0.5993038",
"0.5992711",
"0.5988521",
"0.5987833... | 0.84508026 | 0 |
Execute the actual filter over the buffer. | def execute_filter(self, b, a, buffer, pre_buffer):
timing = time.time()
pre_buffer = np.concatenate([pre_buffer, buffer])
# Execute the filter onto the buffer.
output = signal.lfilter(b, a, pre_buffer)
# Only return the output based on the current buffer (drop pre_buffer)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filter(self, image):\n pass",
"def apply(self, *args):\n return _ida_hexrays.microcode_filter_t_apply(self, *args)",
"def apply(self, *args):\n return _ida_hexrays.udc_filter_t_apply(self, *args)",
"def _apply_command_filter(self, message, command, params):\n\n for h in ... | [
"0.6438522",
"0.6272982",
"0.62232995",
"0.6150621",
"0.6018157",
"0.60126346",
"0.59804815",
"0.5938357",
"0.59299964",
"0.58873695",
"0.58680874",
"0.57971156",
"0.5738858",
"0.572744",
"0.5716776",
"0.56781876",
"0.565808",
"0.56385845",
"0.5618333",
"0.5601541",
"0.558160... | 0.6922687 | 0 |
Realtime linear filter Execute a filter over the audio captured with the microfone. | def rt_lfilter(self, b, a, run_time):
# Store the start time of the filter to determine duration.
start_time = time.time()
# Set up an input stream, stored in object, to be removed after
# the filter is completed.
self.create_input_stream()
# Used to determen the comput... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def low_pass(\n client,\n event,\n smoothing: P('float', 'smoothing', min_value = 0.0, max_value = 5.0),\n):\n player = get_player_or_abort(client, event)\n \n filter = LowPass(smoothing)\n player.add_filter(filter)\n await player.apply_filters()\n \n return create_filter_added_... | [
"0.587776",
"0.583457",
"0.58185333",
"0.57974803",
"0.5704711",
"0.5667839",
"0.5620706",
"0.5563404",
"0.5548904",
"0.5450814",
"0.54273856",
"0.5390272",
"0.5382107",
"0.5376354",
"0.53695923",
"0.53295034",
"0.5314303",
"0.5302382",
"0.5293999",
"0.5290784",
"0.5288348",
... | 0.62792546 | 0 |
Register an arithmetic function | def _register_arithmetic_agg(
name: str,
np_name: str,
doc: str = ""
) -> Callable:
@register_func(None, context=Context.EVAL)
def _arithmetric(x: Iterable, na_rm: bool = False) -> Iterable:
"""Arithmetric function"""
# na_rm not working for numpy functions
# with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cg_inline_arith(self, fn):\n if fn == 'add':\n op = '+'\n elif fn == 'sub':\n op = '-'\n elif fn == 'and':\n op = '&'\n elif fn == 'or':\n op = '|'\n else:\n raise ValueError(f\"Unknown arithmetic function: {fn}\")\n ... | [
"0.62589186",
"0.6246807",
"0.6167025",
"0.60787255",
"0.60751885",
"0.600658",
"0.5996473",
"0.59872395",
"0.5986125",
"0.5982866",
"0.5981943",
"0.58931524",
"0.5859415",
"0.58511823",
"0.58330065",
"0.582692",
"0.581231",
"0.5794341",
"0.5775267",
"0.5761453",
"0.57301486"... | 0.6256668 | 1 |
Scaling and Centering of a numeric data frame See Details in `?scale` in `R` | def scale(
x: DataFrame,
center: Union[bool, Iterable[NumericType]] = True,
# pylint: disable=redefined-outer-name
scale: Union[bool, Iterable[NumericType]] = True
) -> DataFrame:
# center
ncols = x.shape[1]
center_is_true = center is True
out_attrs = {}
if center is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(self):",
"def b_scale_object():\n \n bpy.ops.transform.resize(value=(7.5,1,1), constraint_axis=(True,False,False))\n bpy.ops.transform.resize(value=(1,7.5,1), constraint_axis=(False,True,False))\n bpy.ops.transform.resize(value=(1,1,3.5), constraint_axis=(False,False,True))\n bpy.ops.obj... | [
"0.6920497",
"0.6591868",
"0.64508224",
"0.6385619",
"0.6365562",
"0.6359531",
"0.63552594",
"0.6347289",
"0.6346869",
"0.6332709",
"0.63127536",
"0.6287987",
"0.6282563",
"0.6279836",
"0.6270358",
"0.62600076",
"0.62529635",
"0.6227997",
"0.6226499",
"0.62169534",
"0.6216052... | 0.7370166 | 0 |
Calculate sum of a data frame by row | def row_sums(
x: DataFrame,
na_rm: bool = False,
# dims: int = 1,
# weights = None,
# freq = None,
# n = None
) -> Iterable[NumericType]:
return x.agg(sum, axis=1, na_rm=na_rm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rowsums (self):\n return self.values.sum (axis=0)",
"def sum_across_rows(grid):\n pass",
"def sum(self, rows: List[Row], column: NumberColumn) -> Number:\n cell_values = [row.values[column.name] for row in rows if row.values[column.name] is not None]\n if not cell_values:\n ... | [
"0.7509148",
"0.661522",
"0.64623153",
"0.63493603",
"0.6348554",
"0.6276837",
"0.6244",
"0.6215493",
"0.61611474",
"0.6156394",
"0.6156394",
"0.6156394",
"0.6156394",
"0.6106475",
"0.6021458",
"0.60182256",
"0.60144675",
"0.59970164",
"0.5995113",
"0.598929",
"0.5902073",
... | 0.7031475 | 1 |
Calculate mean of a data frame by row | def row_means(
x: DataFrame,
na_rm: bool = False,
# dims: int = 1,
# weights = None,
# freq = None,
# n = None
) -> Iterable[NumericType]:
return x.agg(mean, axis=1, na_rm=na_rm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(df):\r\n\r\n\tdf_mean_dict = dict()\r\n\r\n\tfor i, col in enumerate(df.columns):\r\n\t\tdf_mean_dict[col] = df[col].mean()\r\n\r\n\tdf_mean = pd.DataFrame(df_mean_dict, index=['Mean'])\r\n\tpd.set_option('precision', 2) # set output display precision in 2 decimal places\r\n\r\n\treturn df_mean",
"def ... | [
"0.74602455",
"0.7090631",
"0.6879813",
"0.6868309",
"0.66716504",
"0.6502999",
"0.6502999",
"0.6477061",
"0.6441888",
"0.6439017",
"0.6419833",
"0.6413621",
"0.6397802",
"0.635502",
"0.63425446",
"0.6301332",
"0.6301332",
"0.6301332",
"0.6301332",
"0.6301332",
"0.6301332",
... | 0.7330926 | 1 |
Returns the point with minimum y coordinate and the leftmost incase of a tie from a set of points | def point_with_min_y(points):
min_idx = None
for a,coord in enumerate(points):
if min_idx == None:
min_idx = a
P0_Y = coord[1]
P0_X = coord[0]
elif coord[1] < P0_Y:
# look for the point with lowest y co-ordinate
min_idx = a
P0_X = coord[0]
P0_Y = coord[1]
elif (coord[1] == P0_Y) & (coord... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min_point(points):\r\n smallest_point_index = 0\r\n for i in range(1, len(points)):\r\n if points[i][1] < points[smallest_point_index][1]:\r\n smallest_point_index = i\r\n elif points[i][0] > points[smallest_point_index][0] and points[i][1] == points[smallest_point_index][1]... | [
"0.707037",
"0.699314",
"0.6715234",
"0.6711315",
"0.6644662",
"0.6453589",
"0.63578993",
"0.63509",
"0.6318644",
"0.6313508",
"0.62379265",
"0.62342405",
"0.6233294",
"0.6218077",
"0.6181975",
"0.6154132",
"0.60536945",
"0.605085",
"0.6030735",
"0.60122937",
"0.6001025",
"... | 0.79324806 | 0 |
Returns list of polar angle between pi and pi calculated with respect to P0 point with lowest x and y coordinate | def polar_angle(points):
polar_angle = []
for each in points:
dy = each[1] - P0[1]
dx = each[0] - P0[0]
polar_angle.append(atan2(dy, dx))
return polar_angle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polar_angle(self, p0, p1=None):\n if p1 == None:\n p1 = anchor\n y_span = p0[1] - p1[1]\n x_span = p0[0] - p1[0]\n return atan2(y_span, x_span)",
"def get_angle(pf, p0=np.array([0, 0]), pi=None):\n if pi is None:\n pi = p0 + np.array([0, 1])\n v0 = np.array... | [
"0.76473796",
"0.7277185",
"0.7208022",
"0.69455487",
"0.690743",
"0.6707919",
"0.65994924",
"0.65846366",
"0.6584543",
"0.6584364",
"0.65201706",
"0.6481771",
"0.6480161",
"0.6446643",
"0.6443673",
"0.6426213",
"0.6402879",
"0.6402307",
"0.6397779",
"0.6397171",
"0.63949645"... | 0.8046352 | 0 |
Returns sorted list of points with polar angle sorted in counterclockwise direction. For points with same polar angle the farthest point | def sort_by_polar_angle_v2(pts):
### make a copy of points array to avoid corruption
### of original points array
copy_pts = []
for each in pts:
if each not in copy_pts:
copy_pts.append(each)
P0_idx = copy_pts.index(P0)
del copy_pts[P0_idx]
# Call polar_angle function to calculate polar angle
# of poin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_polar_angle(points):\n\n\t# Call polar_angle function to calculate polar angle\n\t# of points with respect to P0\n\n\tp = polar_angle(points)\n\tpolar_angle_arr = np.asarray(p)\n\n\n\tvals1, idx_start1, count1 = np.unique(polar_angle_arr, return_counts=True,\n\t return_in... | [
"0.82687664",
"0.71577483",
"0.669116",
"0.66877276",
"0.66829246",
"0.66374314",
"0.6576989",
"0.65653133",
"0.6399161",
"0.6223939",
"0.6220039",
"0.6206402",
"0.6201003",
"0.615975",
"0.6109623",
"0.6109226",
"0.6102652",
"0.60979277",
"0.60727745",
"0.60479337",
"0.602870... | 0.74319017 | 1 |
Returns sorted order of points array. This is initial version of sort_by_polar_angle function. | def sort_by_polar_angle(points):
# Call polar_angle function to calculate polar angle
# of points with respect to P0
p = polar_angle(points)
polar_angle_arr = np.asarray(p)
vals1, idx_start1, count1 = np.unique(polar_angle_arr, return_counts=True,
return_index=True)
idx_sorte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_polar_angle_v2(pts):\n\n\t### make a copy of points array to avoid corruption\n\t### of original points array\n\tcopy_pts = []\n\tfor each in pts:\n\t\tif each not in copy_pts:\n\t\t\tcopy_pts.append(each)\n\n\tP0_idx = copy_pts.index(P0)\n\tdel copy_pts[P0_idx]\n\n\n\t# Call polar_angle function to ca... | [
"0.78802127",
"0.7644447",
"0.737789",
"0.6947764",
"0.6925398",
"0.67864764",
"0.67256737",
"0.6528599",
"0.6528058",
"0.6483474",
"0.6315765",
"0.62791044",
"0.62571245",
"0.6080361",
"0.6009305",
"0.6008643",
"0.6003338",
"0.59828657",
"0.5978858",
"0.59370565",
"0.5920326... | 0.80695266 | 0 |
Returns the cross product of points of p0,p1 and p2. The value returned is +ve, ve or 0 | def cross_product(p0,p1,p2):
return (((p1[0]-p0[0])*(p2[1]-p0[1]))-((p2[0]-p0[0])*(p1[1]-p0[1]))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossProduct(self, p1, p2):\n return (p1.x * p2.y - p1.y * p2.x)",
"def cross(v1: Vec2, v2: Vec2) -> float:\n return v1.x * v2.x + v1.y * v2.y",
"def cross_product(v1, v2):\n return cg3d_vector.CG3dVector(\n v1[1] * v2[2] - v2[1] * v1[2],\n v1[2] * v2[0] - v2[2] * v1[0],\n ... | [
"0.8138234",
"0.769888",
"0.7548699",
"0.7309561",
"0.7254616",
"0.72241324",
"0.6959252",
"0.6931294",
"0.6925192",
"0.6903619",
"0.6861726",
"0.68126595",
"0.67831093",
"0.67740345",
"0.6760308",
"0.67376053",
"0.6660316",
"0.663867",
"0.6633338",
"0.6600308",
"0.6576896",
... | 0.79832125 | 1 |
Work In Progress file to read points from text file | def read_points():
points = []
f = open(r'sample_points.txt')
while True:
nstr = f.readline()
if len(nstr) == 0:
break
line = nstr.rstrip('\n').split(', ')
# print(line)
points.append((round(float(line[0]),3),round(float(line[1]),3)))
print(points)
return points | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Read_Points_From_File(self, fileName):\n\n try:\n fp = open(fileName, 'r')\n\n origSys = pyproj.Proj(init=\"epsg:4326\")\n newSys = pyproj.Proj(init=\"epsg:2436\")\n\n for line, content in enumerate(fp):\n if line > 5:\n lineF... | [
"0.6334811",
"0.60073906",
"0.6003255",
"0.5967956",
"0.5950193",
"0.57709646",
"0.57257795",
"0.5718577",
"0.56645167",
"0.5650985",
"0.56320554",
"0.56218404",
"0.5569511",
"0.55292434",
"0.5521947",
"0.5521935",
"0.5521935",
"0.55167156",
"0.549243",
"0.54831827",
"0.54570... | 0.6247986 | 1 |
Test if saving the parsed email to a file works. | def test_save_email(self):
with self.assertRaises(IOError):
self.email.save_email('')
self.email.save_email('./saved_email.txt')
os.remove('./saved_email.txt') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_email(self):\n self.email.open_path = './original_email.txt'\n self.email.open_email()\n self.email.parse_email()\n sample_email = open('./parsed_email.txt', 'r')\n parsed_email = sample_email.read()\n sample_email.close()\n self.assertMultiLineEqual(... | [
"0.6921741",
"0.6209958",
"0.62086725",
"0.59228194",
"0.58849394",
"0.5832932",
"0.57969725",
"0.57173645",
"0.5702918",
"0.5672153",
"0.56604254",
"0.5653853",
"0.56329435",
"0.5602592",
"0.5600006",
"0.55841273",
"0.55676734",
"0.5549899",
"0.55429465",
"0.5497677",
"0.549... | 0.74363846 | 0 |
Test if adding/retrieving/removing fields behaves as expected. | def test_mutate_field(self):
# Test adding a field
with self.assertRaises(ValueError):
self.email.add_field('', '')
self.email.add_field(self.key, self.regex)
found_key = False
found_regex = r''
for field in self.email.fields:
if field['key'] == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fields(self):\n\n class Foo(Model):\n field1 = StringField()\n field2 = IntegralField()\n\n assert hasattr(Foo, \"_fields\")\n assert type(Foo._fields) is dict\n\n assert not hasattr(Foo, \"field1\")\n assert \"field1\" in Foo._fields\n asser... | [
"0.7511457",
"0.68359107",
"0.682029",
"0.6745773",
"0.6717722",
"0.6690729",
"0.66839385",
"0.6664653",
"0.6661748",
"0.6651163",
"0.6633194",
"0.6629849",
"0.66218936",
"0.66110474",
"0.65984964",
"0.6595212",
"0.6576265",
"0.65719557",
"0.65701216",
"0.65672344",
"0.655896... | 0.7345983 | 1 |
function zips eig val and vecs and sort them simultaneously, calculates fractions of explained variance and returns fracs and eigvecs sorted by eigvalues in descending order. | def calculateVarianceExplainedSort(eig_vals, eig_vecs):
#####################################
# check if there are any negative eigvals, there should not be any presumably ...
if (eig_vals < 0.0).any():
print "BEWARE: There are some negative eigvals in the PCA analysis!"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eig_vals_vects_hermitian(matrix, sort='imag'):\n # if len(matrix) < 10:\n # print '\\nFinding eigvals, matrix = ', matrix\n eigval, eigvect = np.linalg.eig(matrix)\n # use imaginary part to get ascending order of eigvals\n if sort == 'imag':\n si = np.argsort(np.imag(eigval))\n eli... | [
"0.65877235",
"0.6392305",
"0.6318281",
"0.6127951",
"0.59290147",
"0.5907462",
"0.59019166",
"0.5846667",
"0.57880616",
"0.5778562",
"0.57603914",
"0.5756846",
"0.5673226",
"0.5635329",
"0.561321",
"0.55256283",
"0.5511209",
"0.54514724",
"0.543964",
"0.5428279",
"0.5415944"... | 0.78201956 | 0 |
takes eigen vectors in a sorted order and stacks them to create a projection matrix W | def getProjectionMatrix(sorted_eigvecs):
matrix_w = np.vstack(sorted_eigvecs).transpose()
return matrix_w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPrincipalVectors(A): #\n VT=np.linalg.eig(np.matmul(A.T,A))\n sort = sorted(zip(VT[0],VT[1].T.tolist()),reverse=True)\n values,vectors = zip(*sort)\n return vectors,values",
"def project_to_eigenvectors(X, vecs):\n\n return (X-np.mean(X, axis=0)).dot(np.transpose(vecs)) #PCA assumes that th... | [
"0.619044",
"0.6182332",
"0.6092334",
"0.5932291",
"0.58610845",
"0.5616195",
"0.56129956",
"0.5603881",
"0.5576646",
"0.55684084",
"0.555519",
"0.5544827",
"0.55148864",
"0.55141866",
"0.54980725",
"0.5478833",
"0.54428184",
"0.54386044",
"0.54267216",
"0.5403919",
"0.539064... | 0.72957283 | 0 |
Generate a random square avatar | def generate_avatar(self, fp, fn, size=256, min_border=10):
assert isinstance(size, int), 'Size is expected as a integer'
# size - 2*border = chunk*5
border = chunk = None
for chunk in reversed(range(1, size)):
border = (size - (chunk*5)) / 2
# check if border is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_random_avatar():\n avatar_names = os.listdir(PATH)\n avatar_path = random.choice([avatar_image for avatar_image in avatar_names\n if os.path.isfile(os.path.join(PATH,avatar_image))])\n return PATH_RELATIVE+avatar_path",
"def randomBitmap(size):\n\n b = bitmap(s... | [
"0.69083303",
"0.63502973",
"0.626283",
"0.62326896",
"0.6220544",
"0.6186475",
"0.6179389",
"0.60321116",
"0.60214233",
"0.5975341",
"0.5968107",
"0.5943212",
"0.593212",
"0.58947456",
"0.588886",
"0.5879447",
"0.58475035",
"0.58074456",
"0.579071",
"0.5788108",
"0.57723665"... | 0.6357736 | 1 |
Get database URI from env variables | def build_db_uri() -> str:
return "{DB_DRIVER}://{DB_USERNAME}:{DB_PASSWD}@{DB_HOST}:{DB_PORT}/{DB_NAME}".format(**{
'DB_DRIVER': os.environ.get('DB_DRIVER', ''),
'DB_HOST': os.environ.get('DB_HOST', ''),
'DB_PORT': os.environ.get('DB_PORT', ''),
'DB_NAME': os.environ.get('DB_NAME',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database_uri(env):\r\n return (\r\n \"{dialect}+{driver}://{user}:{password}@{host}:{port}/{database}?charset={charset}\"\r\n ).format(\r\n dialect=configfile.get(\"database\", \"dialect\"),\r\n driver=configfile.get(\"database\", \"driver\"),\r\n user=configfile.get(\"databas... | [
"0.85305816",
"0.8009774",
"0.79821914",
"0.7916366",
"0.7882772",
"0.7568635",
"0.73102343",
"0.7302216",
"0.7186416",
"0.7153592",
"0.71178126",
"0.7074838",
"0.7062991",
"0.7060992",
"0.7054957",
"0.6913101",
"0.68327826",
"0.6814017",
"0.67569375",
"0.6755593",
"0.6727294... | 0.8187962 | 1 |
Load data from redis. restrict to just the fields specified. | def load(self, fields=None, pipe=None):
if fields is None:
fields = self.default_fields
if fields == 'all':
return self._load_all(pipe=pipe)
if fields == 'defined':
fields = [k for k in self.fields.keys()]
if not fields:
return
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_load(key: object) -> object:\n if key is None:\n return None\n value = red.redis.get(key)\n if value is not None:\n return json.loads(value)\n return None",
"def load(self):\n the_redis = DARedis()\n cases = the_redis.get_data(self.user_cases_key) or {}\n ... | [
"0.608604",
"0.5668427",
"0.5665812",
"0.5508199",
"0.54859394",
"0.5481122",
"0.54310274",
"0.5369943",
"0.5167853",
"0.5166409",
"0.5154141",
"0.5112487",
"0.5085804",
"0.5064839",
"0.50622594",
"0.5014305",
"0.500048",
"0.4992059",
"0.49888816",
"0.49807858",
"0.49759835",... | 0.60511994 | 1 |
Increment a field by a given amount. Return the future Also update the field. | def incr(self, field, amount=1, pipe=None):
with self._pipe(pipe) as pipe:
core = self.core(pipe=pipe)
new_amount = core.hincrby(self.key, field, amount)
ref = core.hget(self.key, field)
def cb():
self._data[field] = ref.result
pipe.o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment(self, amount):\n pass",
"def inc(self):\n with self.mutex:\n self.value += 1\n return self.value",
"async def increment(self):\n async with self.lock:\n self.counter += 1",
"def increment(self, inc):\n self.done += inc",
"def get_in... | [
"0.6919463",
"0.6758298",
"0.6581432",
"0.64960593",
"0.64107007",
"0.6356003",
"0.63339984",
"0.62881875",
"0.6266638",
"0.62426984",
"0.62116575",
"0.61939013",
"0.61820185",
"0.61680764",
"0.60818183",
"0.602935",
"0.6007613",
"0.59995073",
"0.5954526",
"0.59300846",
"0.58... | 0.7268633 | 0 |
update the data in the Struct. This will update the values in the underlying redis hash. After the pipeline executes, the changes will be reflected here in the local struct. If any values in the changes dict are None, those fields will be removed from redis and the instance. The changes should be a dictionary represent... | def update(self, changes, pipe=None):
if not changes:
return
if self.key_name in changes:
raise InvalidOperation('cannot update the redis key')
deletes = {k for k, v in changes.items() if IS(v, None)}
updates = {k: v for k, v in changes.items() if k not in delet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update(self, data: Dict[str, Any], fields_to_modify: List[str]):\n pass",
"def data_dict_update(self, change):\n self.data_dict = change['value']",
"def _update_object(self, data_dict):\r\n pass",
"def update(self):\n data = self.serialize()\n\n self.validate(data)\n\n... | [
"0.6297742",
"0.618329",
"0.6097033",
"0.59804624",
"0.5897436",
"0.5897436",
"0.5897436",
"0.5897436",
"0.58957064",
"0.58495677",
"0.5746015",
"0.57220393",
"0.571625",
"0.5675254",
"0.5653404",
"0.5640808",
"0.5640808",
"0.5619323",
"0.5615951",
"0.5613986",
"0.55939525",
... | 0.6497137 | 0 |
remove some fields from the struct. This will remove data from the underlying redis hash object. After the pipe executes successfully, it will also remove it from the current instance of Struct. | def remove(self, fields, pipe=None):
if not fields:
return
if self.key_name in fields:
raise InvalidOperation('cannot remove the redis key')
with self._pipe(pipe) as pipe:
core = self.core(pipe=pipe)
core.hdel(self.key, *fields)
def ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, data, config=None, pipeline=None):\n del data[self.field]\n return data",
"def cleanup(self, data):\n tmp = copy.copy(data)\n for field in ('log_entries', 'instances',\n 'picked_instances', 'saved_instances',\n 'terminated_instan... | [
"0.65890133",
"0.6110975",
"0.60161936",
"0.59390527",
"0.5849796",
"0.5828954",
"0.55936456",
"0.5531085",
"0.5518675",
"0.550303",
"0.5449249",
"0.5430388",
"0.539532",
"0.53821003",
"0.5290053",
"0.52878803",
"0.5273899",
"0.527231",
"0.5272292",
"0.5272292",
"0.52714515",... | 0.676269 | 0 |
MonkeyPatch the core json encoder library. This isn't as bad as it sounds. We override the default method so that if an object falls through and can't be encoded normally, we see if it is a Future object and return the result to be encoded. I set a special attribute on the Struct object so I can tell that's what it is.... | def _json_default_encoder(func):
@wraps(func)
def inner(self, o):
try:
return o._redpipe_struct_as_dict # noqa
except AttributeError:
pass
return func(self, o)
return inner | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jsonify(obj):\n raise NotImplementedError",
"def JsonComplexEncoder(obj):\n if isinstance(obj, bytes):\n return str(obj)\n else:\n return obj",
"def _cast(obj):\n if isinstance(obj, Future):\n return obj\n else:\n return NonFuture(obj)",
"def _json_compat_obj_en... | [
"0.6539842",
"0.63273984",
"0.6231542",
"0.60518885",
"0.5884403",
"0.57575303",
"0.5733367",
"0.5730615",
"0.57100755",
"0.5682164",
"0.5680823",
"0.5680091",
"0.5659079",
"0.5657843",
"0.5656514",
"0.56510496",
"0.5612438",
"0.56083405",
"0.5590826",
"0.5590826",
"0.5590826... | 0.6640832 | 0 |
Reads the toy file and returns a dictionary of Toys. | def read_toys(toy_file, num_toys):
toy_dict = {}
with open(toy_file, 'rb') as f:
fcsv = csv.reader(f)
fcsv.next() # header row
for row in fcsv:
new_toy = Toy(row[0], row[1], row[2])
toy_dict[new_toy.id] = new_toy
if len(toy_dict) != num_toys:
print '\... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_typos_moe(file_name):\n \n # log = logging.getLogger(\"robust_ner\")\n\n file_path = os.path.join(f\"resources/typos/\", f\"{file_name}\")\n\n typos = dict()\n for line in open(file_path):\n line = line.strip().split()\n\n if len(line) != 2:\n #log.warning(f\"len(li... | [
"0.58557427",
"0.58372825",
"0.57190096",
"0.5689246",
"0.5590042",
"0.5534718",
"0.544049",
"0.5433953",
"0.54234475",
"0.54081047",
"0.53837466",
"0.53530794",
"0.53501314",
"0.53445625",
"0.53396946",
"0.53390104",
"0.5331413",
"0.5293893",
"0.5291115",
"0.52606446",
"0.52... | 0.76875705 | 0 |
Add or update problem feedback in the database. | def upsert_feedback(pid, feedback):
db = api.db.get_conn()
uid = api.user.get_user()["uid"]
# Make sure the problem actually exists.
if not api.problem.get_problem(pid, {"pid": 1}):
raise PicoException("Problem not found", 404)
team = api.user.get_team(uid=uid)
solved = pid in api.pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_feedback(\n self, feedback_result: FeedbackResult = None, **kwargs\n ) -> None:\n\n if feedback_result is None:\n feedback_result = FeedbackResult(**kwargs)\n else:\n feedback_result.update(**kwargs)\n\n self.db.insert_feedback(feedback_result=feedback_r... | [
"0.603016",
"0.58254933",
"0.57722336",
"0.57555676",
"0.57140225",
"0.5572872",
"0.5563124",
"0.5531207",
"0.5522428",
"0.5448811",
"0.5413555",
"0.541353",
"0.5407989",
"0.53947586",
"0.5386834",
"0.53706306",
"0.5361914",
"0.5353861",
"0.53487045",
"0.532453",
"0.5318528",... | 0.69547176 | 0 |
waits for flask to be up then return port | def get_flask_port_when_up(path:str) -> int:
import time
while not os.path.exists(path):
print("flask config missing")
time.sleep(0.5)
pass
while True:
import json
import requests
line='{"port":-1}'
with open(path,"r") as f:
line=f.readline... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backend_up():\n for _ in range(100):\n if open_port(FLASKHOST, FLASKPORT):\n return True\n else:\n time.sleep(0.1)\n return False",
"def wait_for_port_bind(self):\n if self.starter_port is not None:\n count = 0\n while count < 10:\n ... | [
"0.6932444",
"0.67489624",
"0.6611164",
"0.6522352",
"0.6425988",
"0.63676864",
"0.63523734",
"0.6323518",
"0.63126135",
"0.6273612",
"0.6272051",
"0.6196385",
"0.6194378",
"0.617741",
"0.61688644",
"0.6160174",
"0.61485267",
"0.60756266",
"0.6074559",
"0.60597545",
"0.604266... | 0.7603855 | 0 |
Convert AR coefs to power spectrum PF=(AR,NP) | def lpcar2pf(ar, p=None):
ar = np.array(ar)
ar0 = ar.reshape(1, -1)
nf, p1 = ar0.shape
if p == None:
p = p1 - 1
pf = (np.abs((np.fft.rfft(ar0, n=2 * p + 2)).T ))** (-2)
return pf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power_spectrum_fn(p, fmag, otf):\n\n val = p[2]**2 * p[0]**2 * np.abs(fmag) ** (-2 * p[1]) * np.abs(otf)**2 + p[3]\n\n return val",
"def fourierNP(img):\n\tgray = grayscale(img)\n\tf = np.fft.fft2(gray)\n\tfshift = np.fft.fftshift(f)\n\tmagnitude_spectrum = 20*np.log(np.abs(fshift)) # RETURN THIS\n ... | [
"0.57708985",
"0.5765037",
"0.5709861",
"0.5656812",
"0.5566508",
"0.5516762",
"0.54874104",
"0.5478666",
"0.5353813",
"0.5330095",
"0.52834123",
"0.528239",
"0.52156276",
"0.5184602",
"0.5162014",
"0.5135625",
"0.51327455",
"0.51030964",
"0.5099156",
"0.50969255",
"0.5088748... | 0.6563868 | 0 |
''' This method is used to submit any SAS code. It returns the Log and Listing as a python dictionary. code the SAS statements you want to execute results format of results, HTML is default, TEXT is the alternative | def submit(self, code: str, results: str ="html", prompt: dict = None) -> dict:
prompt = prompt if prompt is not None else {}
#odsopen = b"ods listing close;ods html5 (id=saspy_internal) file=STDOUT options(bitmap_mode='inline') device=svg; ods graphics on / outputfmt=png;\n"
odsopen = b"ods listin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def JOBSUBMIT_Send_Approval_Request (parameters, curdir, form, user_info=None):\n global rn,sysno\n # variables declaration\n doctype = re.search(\".*/([^/]*)/([^/]*)/[^/]*$\",curdir).group(2)\n otheraddresses = parameters['addressesDAM']\n categformat = parameters['categformatDAM']\n # retrieve ... | [
"0.53046346",
"0.5229528",
"0.51356655",
"0.5057509",
"0.5043196",
"0.5041219",
"0.5035221",
"0.5007719",
"0.4975286",
"0.49649438",
"0.49527308",
"0.49176943",
"0.49173185",
"0.49138692",
"0.4903642",
"0.49004853",
"0.48980325",
"0.4885968",
"0.48853356",
"0.48741412",
"0.48... | 0.77607024 | 0 |
this method is used to get the current, full contents of the SASLOG | def saslog(self):
return self._log | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_log(self):\n return self._get_log('full')",
"def get_log(self):\n\n open_lf = open(self.logfile, 'r')\n log_str = open_lf.read()\n sys.stdout.write(log_str)\n\n return log_str",
"def getLog(self):\n return self.session.request('diag/log/')",
"def getLog(self... | [
"0.6716842",
"0.6622381",
"0.6473253",
"0.64604974",
"0.64604974",
"0.63233083",
"0.63185394",
"0.63185394",
"0.6308118",
"0.6308118",
"0.6308118",
"0.6307658",
"0.62076575",
"0.6197285",
"0.61778253",
"0.60820335",
"0.6015971",
"0.6012905",
"0.59916514",
"0.59420884",
"0.594... | 0.7634604 | 0 |
table the name of the SAS Data Set libref the libref for the Data Set, defaults to WORK, or USER if assigned Returns True it the Data Set exists and False if it does not | def exist(self, table: str, libref: str ="") -> bool:
code = 'data _null_; e = exist("'
if len(libref):
code += libref+"."
code += "'"+table.strip()+"'n"+'"'+");\n"
code += 'v = exist("'
if len(libref):
code += libref+"."
code += "'"+table.strip()+"'n"+'"'+", 'VIEW... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settable(self) -> bool:\n return self._data_provider.settable",
"def table_check(tablename, path):\n instance = arcno(path)\n tablelist = [i for i,j in instance.actual_list.items()]\n return True if tablename in tablelist else False",
"def check_table(cur, table: str) -> bool:\n table_da... | [
"0.6417946",
"0.6010929",
"0.595191",
"0.59469557",
"0.5905696",
"0.5900016",
"0.5783866",
"0.5755238",
"0.574544",
"0.5735661",
"0.56482804",
"0.56480753",
"0.5647277",
"0.5624122",
"0.5620948",
"0.56011397",
"0.5600648",
"0.55759686",
"0.5546934",
"0.5517704",
"0.5487832",
... | 0.663143 | 0 |
This method will import a csv file into a SAS Data Set and return the SASdata object referring to it. | def read_csv(self, file: str, table: str, libref: str ="", nosub: bool =False, opts: dict = None) -> '<SASdata object>':
opts = opts if opts is not None else {}
code = "filename x "
if file.lower().startswith("http"):
code += "url "
code += "\""+file+"\";\n"
code += "proc impo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_data(csv_file):\n # skips bad lines\n data = pd.read_csv(csv_file, error_bad_lines=False)\n return data",
"def importData(filename):\r\n data = pd.read_csv(filename)\r\n return data",
"def load_dataset_from(csv_file: str) -> pd.DataFrame:\n\n print(\">>> LOADING DATASET FROM FILE {... | [
"0.68314445",
"0.67352456",
"0.6658218",
"0.66515833",
"0.65661275",
"0.6534114",
"0.6511873",
"0.6446048",
"0.63951087",
"0.6374643",
"0.6363363",
"0.6357798",
"0.63493466",
"0.63354695",
"0.63033444",
"0.630099",
"0.6286501",
"0.6206751",
"0.6200097",
"0.6184981",
"0.617446... | 0.6930716 | 0 |
This method will export a SAS Data Set to a file in CSV format. file the OS filesystem path of the file to be created (exported from the SAS Data Set) table the name of the SAS Data Set you want to export to a CSV file libref the libref for the SAS Data Set. dsopts a dictionary containing any of the following SAS data ... | def write_csv(self, file: str, table: str, libref: str ="", nosub: bool =False, dsopts: dict = None, opts: dict = None) -> 'The LOG showing the results of the step':
dsopts = dsopts if dsopts is not None else {}
opts = opts if opts is not None else {}
code = "filename x \""+file+"\";\n"
code +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sasdata2dataframeCSV(self, table: str, libref: str ='', dsopts: dict = None, tempfile: str=None, tempkeep: bool=False, **kwargs) -> '<Pandas Data Frame object>':\n dsopts = dsopts if dsopts is not None else {}\n opts = kwargs.pop('opts', {})\n\n logf = ''\n lstf = ''\n logn ... | [
"0.66209966",
"0.63582015",
"0.6283966",
"0.62344563",
"0.6183888",
"0.6128453",
"0.607725",
"0.6059441",
"0.60586417",
"0.60416883",
"0.6022971",
"0.60149896",
"0.599973",
"0.59947485",
"0.5960262",
"0.5940778",
"0.5940564",
"0.5883237",
"0.58814836",
"0.58724374",
"0.586061... | 0.7258989 | 0 |
This method uploads a local file to the SAS servers file system. localfile path to the local file to upload remotefile path to remote file to create or overwrite overwrite overwrite the output file if it exists? permission permissions to set on the new file. See SAS Filename Statement Doc for syntax | def upload(self, localfile: str, remotefile: str, overwrite: bool = True, permission: str = '', **kwargs):
valid = self._sb.file_info(remotefile, quiet = True)
if valid is None:
remf = remotefile
else:
if valid == {}:
remf = remotefile + self._sb.hostsep + localfile.rpar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _upload_file(sftp, local_file, remote_file) -> None:\n # Check if local_file is a file-like object and use the proper\n # paramiko function to upload it to the remote machine.\n if hasattr(local_file, \"read\"):\n sftp.putfo(local_file, remote_file)\n else:\n sftp.put(local_file, remo... | [
"0.7273038",
"0.71682787",
"0.71497375",
"0.7120039",
"0.70452714",
"0.7043328",
"0.69804233",
"0.6934774",
"0.6870072",
"0.68168294",
"0.677053",
"0.67665577",
"0.67614627",
"0.66550744",
"0.6652943",
"0.6636349",
"0.6598481",
"0.6503538",
"0.639001",
"0.6362613",
"0.6344701... | 0.7458046 | 0 |
This method downloads a remote file from the SAS servers file system. localfile path to the local file to create or overwrite remotefile path to remote file tp dpwnload overwrite overwrite the output file if it exists? | def download(self, localfile: str, remotefile: str, overwrite: bool = True, **kwargs):
logf = ''
logn = self._logcnt()
logcodei = "%put E3969440A681A24088859985" + logn + ";"
logcodeo = "\nE3969440A681A24088859985" + logn
logcodeb = logcodeo.encode()
valid = self._sb.file_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_file(self, remote_file):\n remote_file.download()",
"def download_file(remote_file, local_file=None, key_filename=None, hostname=None, username=None) -> None:\n if local_file is None: # pragma: no cover\n local_file = remote_file\n with get_connection(\n hostname=hostname... | [
"0.73069274",
"0.7010151",
"0.68758935",
"0.6848238",
"0.6842906",
"0.6805998",
"0.67763066",
"0.6710499",
"0.6663412",
"0.6574687",
"0.64849985",
"0.63890874",
"0.6382778",
"0.63727486",
"0.6351935",
"0.635087",
"0.6321441",
"0.63193655",
"0.6313233",
"0.631125",
"0.62871647... | 0.792253 | 0 |
This method imports a Pandas Data Frame to a SAS Data Set, returning the SASdata object for the new Data Set. df Pandas Data Frame to import to a SAS Data Set table the name of the SAS Data Set to create libref the libref for the SAS Data Set being created. Defaults to WORK, or USER if assigned keep_outer_quotes for ch... | def dataframe2sasdata(self, df: '<Pandas Data Frame object>', table: str ='a',
libref: str ="", keep_outer_quotes: bool=False,
embedded_newlines: bool=False,
LF: str = '\x01', CR: str = '\x02', colsep: str = '\x03',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sasdata2dataframe(self, table: str, libref: str ='', dsopts: dict = None, rowsep: str = '\\x01',\n colsep: str = '\\x02', **kwargs) -> '<Pandas Data Frame object>':\n dsopts = dsopts if dsopts is not None else {}\n\n method = kwargs.pop('method', None)\n if method and m... | [
"0.6586761",
"0.62313336",
"0.5794725",
"0.55714405",
"0.522601",
"0.5211053",
"0.51933384",
"0.5075218",
"0.5029232",
"0.5018042",
"0.5003599",
"0.49961883",
"0.4971483",
"0.49654067",
"0.49595985",
"0.49221733",
"0.4903401",
"0.48962492",
"0.48591605",
"0.48576063",
"0.4849... | 0.7079916 | 0 |
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. table the name of the SAS Data Set you want to export to a Pandas Data Frame libref the libref for the SAS Data Set. rowsep the row seperator character to use; defaults to '\x01' colsep the column seperator character to use; d... | def sasdata2dataframe(self, table: str, libref: str ='', dsopts: dict = None, rowsep: str = '\x01',
colsep: str = '\x02', **kwargs) -> '<Pandas Data Frame object>':
dsopts = dsopts if dsopts is not None else {}
method = kwargs.pop('method', None)
if method and method.lower(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sasdata2dataframeDISK(self, table: str, libref: str ='', dsopts: dict = None,\n rowsep: str = '\\x01', colsep: str = '\\x02', tempfile: str=None, \n tempkeep: bool=False, **kwargs) -> '<Pandas Data Frame object>':\n dsopts = dsopts if dsopts is not N... | [
"0.70405406",
"0.6566006",
"0.65296793",
"0.57948315",
"0.5692542",
"0.56485796",
"0.56460404",
"0.55945253",
"0.55105525",
"0.549946",
"0.5459452",
"0.53893137",
"0.53694314",
"0.5321232",
"0.5298519",
"0.5260691",
"0.5247505",
"0.5224124",
"0.5205334",
"0.51963335",
"0.5184... | 0.72130156 | 0 |
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. table the name of the SAS Data Set you want to export to a Pandas Data Frame libref the libref for the SAS Data Set. dsopts data set options for the input SAS Data Set opts a dictionary containing any of the following Proc Exp... | def sasdata2dataframeCSV(self, table: str, libref: str ='', dsopts: dict = None, tempfile: str=None, tempkeep: bool=False, **kwargs) -> '<Pandas Data Frame object>':
dsopts = dsopts if dsopts is not None else {}
opts = kwargs.pop('opts', {})
logf = ''
lstf = ''
logn = self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sasdata2dataframe(self, table: str, libref: str ='', dsopts: dict = None, rowsep: str = '\\x01',\n colsep: str = '\\x02', **kwargs) -> '<Pandas Data Frame object>':\n dsopts = dsopts if dsopts is not None else {}\n\n method = kwargs.pop('method', None)\n if method and m... | [
"0.7188617",
"0.7171367",
"0.586467",
"0.5774161",
"0.5673016",
"0.5539111",
"0.54826665",
"0.5470404",
"0.5359042",
"0.5340799",
"0.52800405",
"0.52727836",
"0.52664286",
"0.5252045",
"0.52296436",
"0.5227256",
"0.5224205",
"0.5219505",
"0.5192112",
"0.5115612",
"0.5115612",... | 0.7368683 | 0 |
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. table the name of the SAS Data Set you want to export to a Pandas Data Frame libref the libref for the SAS Data Set. dsopts data set options for the input SAS Data Set rowsep the row seperator character to use; defaults to '\x... | def sasdata2dataframeDISK(self, table: str, libref: str ='', dsopts: dict = None,
rowsep: str = '\x01', colsep: str = '\x02', tempfile: str=None,
tempkeep: bool=False, **kwargs) -> '<Pandas Data Frame object>':
dsopts = dsopts if dsopts is not None else {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sasdata2dataframe(self, table: str, libref: str ='', dsopts: dict = None, rowsep: str = '\\x01',\n colsep: str = '\\x02', **kwargs) -> '<Pandas Data Frame object>':\n dsopts = dsopts if dsopts is not None else {}\n\n method = kwargs.pop('method', None)\n if method and m... | [
"0.7406415",
"0.7345396",
"0.5852222",
"0.565165",
"0.54005325",
"0.5383105",
"0.5363693",
"0.5356092",
"0.52389103",
"0.5227003",
"0.52125216",
"0.51133496",
"0.5106238",
"0.5102311",
"0.5025597",
"0.50212723",
"0.5010264",
"0.4983982",
"0.49452177",
"0.492366",
"0.49126095"... | 0.7481177 | 0 |
Adds the current value of deltaFloat to data. | def apply_delta_float(self):
if not self._randomValFlag:
newData = self.data + self.deltaFloat
self._deltaPrevAbs.insert(0, self.deltaFloat)
self._deltaPrevPer.insert(0, (((newData / self.data) - 1) * 100))
self.data += self.deltaFloat
self.deltaFloat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addFloat(self, f):\n self._buf.push(_F_STRUCT.pack(f))",
"def add_value(self, val: float):\n self._mtx.acquire()\n self._buffer.append(val)\n self._sum += val\n\n if self._cur_elem_count < self._frame_size:\n self._cur_elem_count += 1\n else:\n ... | [
"0.6543692",
"0.60176265",
"0.60126406",
"0.59379596",
"0.5471914",
"0.5466207",
"0.544169",
"0.5429392",
"0.5381496",
"0.5367352",
"0.5307887",
"0.529859",
"0.5296971",
"0.5274561",
"0.526971",
"0.5233629",
"0.52096385",
"0.52011985",
"0.51992357",
"0.51963955",
"0.517645",
... | 0.66633326 | 0 |
Removes a directed edge between the Vertex and . The method function as a wrapper function for the remove_child and remove_parent methods of the Vertex. | def remove_edge(self, pVertex):
try:
del self._parents[pVertex]
except AttributeError:
raise EdgeError(3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_edge(self, edge: Edge) -> Edge:",
"def remove(self):\n if isinstance(self, Vertex):\n self.graph.remove_vertex(self)\n else:\n self.graph.remove_edge(self)",
"def remove_edge(self, pVertex, cVertex):\n\n try:\n cVertex.remove_edge(pVertex)\n ... | [
"0.76903325",
"0.75361705",
"0.7380666",
"0.7339967",
"0.73398453",
"0.7175563",
"0.7174292",
"0.70186806",
"0.6895772",
"0.6796558",
"0.6796465",
"0.67593",
"0.67577744",
"0.67472106",
"0.6747051",
"0.67301416",
"0.67231965",
"0.67171067",
"0.66037357",
"0.65449786",
"0.6516... | 0.7550405 | 1 |
Calculates 'deltaFloat' based on a greedychild paradigm. When using the greedychild transform paradigm, deltaFloat is calculated by pulling relevant data from the parent nodes. | def transform(self):
for pVertex in self._parents:
tData = self._parents[pVertex]
tKey = tData[0]
tData = tData[1:]
if tKey >= 0 and tKey <= 5:
pDelta = pVertex._deltaPrevAbs[0]
elif tKey >= 6 and tKey <= 11:
pDelta = p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_delta_float(self):\n\n if not self._randomValFlag:\n newData = self.data + self.deltaFloat\n self._deltaPrevAbs.insert(0, self.deltaFloat)\n self._deltaPrevPer.insert(0, (((newData / self.data) - 1) * 100))\n self.data += self.deltaFloat\n sel... | [
"0.53165233",
"0.528606",
"0.5263463",
"0.5116239",
"0.51025546",
"0.50871253",
"0.5061172",
"0.49952903",
"0.49876884",
"0.49238497",
"0.48586497",
"0.48569632",
"0.48569632",
"0.48569632",
"0.48569632",
"0.48202544",
"0.48031276",
"0.47805017",
"0.4746628",
"0.47331426",
"0... | 0.5577874 | 0 |
Initializes class data for the DiGraph. When the DiGraph is instantiated, it defaults to an empty state. However, the method takes _vertices as optional positional arguments. The _vertices in the arguments have their names extracted and are added to the DiGraph's dictionary of _vertices, indexed by their extracted name... | def __init__(self, *vertices):
self._vertices = {}
if len(vertices) != 0:
try:
for vertex in vertices:
vName = vertex.name
self._vertices[vName] = vertex
except AttributeError:
del self
raise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, vertices=None):\n\n self._vertices = dict() \n if vertices is not None:\n for label in vertices.keys():\n self.add_vertex(label)\n for label, heads in vertices.items():\n for head in heads:\n self.add_edg... | [
"0.7470028",
"0.7208808",
"0.7005627",
"0.70031106",
"0.6980636",
"0.6915064",
"0.691235",
"0.67800415",
"0.67535025",
"0.67501265",
"0.6665587",
"0.66510034",
"0.66337746",
"0.6609855",
"0.6481558",
"0.64623475",
"0.64536166",
"0.64010936",
"0.63390744",
"0.63289195",
"0.632... | 0.8032199 | 0 |
Test sending of first notification to Reps to fill reports. | def test_send_notification(self):
management.call_command('send_first_report_notification', [], {})
eq_(len(mail.outbox), 4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_send_notification_with_reports_filled(self, fake_requests_obj):\n # act like it's March 2012\n fake_date = datetime.datetime(year=2012, month=3, day=1)\n (fake_requests_obj.expects_call().returns(fake_date))\n\n management.call_command('send_second_report_notification', [], {})... | [
"0.7282793",
"0.6998844",
"0.69657487",
"0.69280744",
"0.6790066",
"0.6788113",
"0.676636",
"0.66872704",
"0.6670142",
"0.66388834",
"0.66236424",
"0.6470535",
"0.6445497",
"0.64040613",
"0.638898",
"0.63687027",
"0.63580495",
"0.63580495",
"0.6254688",
"0.61826825",
"0.61626... | 0.7791854 | 0 |
Test sending of second notification, with reports filled. | def test_send_notification_with_reports_filled(self, fake_requests_obj):
# act like it's March 2012
fake_date = datetime.datetime(year=2012, month=3, day=1)
(fake_requests_obj.expects_call().returns(fake_date))
management.call_command('send_second_report_notification', [], {})
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_send_notification(self):\n management.call_command('send_first_report_notification', [], {})\n eq_(len(mail.outbox), 4)",
"def send_notification(self):\n s1 = System()\n b1 = Books(\"1984\", \"George Orwell\", \"Harvill Secker\", \"1949\", \"0123456789123\")\n m1 = Mem... | [
"0.7743362",
"0.71214473",
"0.6979808",
"0.6886839",
"0.6880504",
"0.6845977",
"0.6814366",
"0.68137115",
"0.6703214",
"0.6592325",
"0.6591481",
"0.65565777",
"0.64688444",
"0.6442306",
"0.6411243",
"0.63932765",
"0.6378398",
"0.63436633",
"0.6312011",
"0.62923646",
"0.627122... | 0.7341328 | 1 |
Load Pretrained VGG Model into TensorFlow. | def load_vgg(sess, vgg_path):
# Use tf.saved_model.loader.load to load the model and weights
vgg_tag = 'vgg16'
vgg_input_tensor_name = 'image_input:0'
vgg_keep_prob_tensor_name = 'keep_prob:0'
vgg_layer3_out_tensor_name = 'layer3_out:0'
vgg_layer4_out_tensor_name = 'layer4_out:0'
vgg_layer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_vgg(sess, vgg_path):\n\n # Check if the VGG model exists\n if(not os.path.isfile(os.path.join(vgg_path, \"saved_model.pb\"))):\n assert False, \"Required VGG Model does not exist. Abort\"\n\n\n vgg_tag = ['vgg16']\n vgg_input_tensor_name = 'image_input:0'\n vgg_keep_prob_tensor_name ... | [
"0.80306226",
"0.77833533",
"0.7666854",
"0.76633936",
"0.76285857",
"0.7605451",
"0.7604318",
"0.76042914",
"0.7597137",
"0.7579625",
"0.7203619",
"0.70700145",
"0.7035601",
"0.69674075",
"0.6856475",
"0.6849419",
"0.6831706",
"0.6764241",
"0.6684255",
"0.66834015",
"0.66799... | 0.7810098 | 1 |
Fisher's exact test for a 2x2 contingency table a b c d | def fisherExact(table):
a,b = table[0]
c,d = table[1]
return binomialCoefficient(a+b,a)*binomialCoefficient(c+d,c)/binomialCoefficient(a+b+c+d,a+c) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fisher_alpha(self):\n c = array([4,3,4,0,1,0,2])\n obs = fisher_alpha(c)\n self.assertFloatEqual(obs, 2.7823795367398798)",
"def test_fisher(self):\r\n self.assertFloatEqual(fisher([0.073, 0.086, 0.10, 0.080, 0.060]),\r\n 0.0045957946540917905)",
... | [
"0.6474105",
"0.6468253",
"0.62325966",
"0.6164074",
"0.6134942",
"0.60962474",
"0.59154224",
"0.59131217",
"0.587417",
"0.58443964",
"0.57991296",
"0.56658447",
"0.56243724",
"0.5579691",
"0.5560056",
"0.55398977",
"0.5535389",
"0.5534766",
"0.5532628",
"0.5526189",
"0.55206... | 0.77271307 | 0 |
Create a decision function to select between left and right nodes. | def __init__(self, left, right, decision_function, class_label=None):
self.left = left
self.right = right
self.decision_function = decision_function
self.class_label = class_label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _left(node):\n return 2 * node + 1",
"def fn(node):\n if not node or node in (p, q): return node\n left, right = fn(node.left), fn(node.right)\n if left and right: return node \n return left or right",
"def fn(node):\n if node.val == 0: return (0, 1... | [
"0.6018027",
"0.5865462",
"0.58174527",
"0.57478505",
"0.5697109",
"0.5498822",
"0.54738206",
"0.54241675",
"0.53798527",
"0.5357778",
"0.53569853",
"0.5345739",
"0.5301062",
"0.5244427",
"0.5238367",
"0.522823",
"0.5199193",
"0.51949424",
"0.51864356",
"0.51825446",
"0.51489... | 0.6074558 | 0 |
Create a decision tree capable of handling the provided data. Tree is built fully starting from the root. | def build_decision_tree():
decision_tree_root = None
decision_tree_root = DecisionNode(None,None,lambda feature:feature[0]==1)
decision_tree_root.left = DecisionNode(None,None,None,1)
decision_tree_root.right = DecisionNode(None,None,lambda feature:feature[3]==1)
decision_tree_root.right.left = Dec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildDecisionTree(self, data):\n self.data = data\n self.decisionTree = self.buildTree(self.data, self.listAttributes)\n with open(\"decision_tree_model\", \"wb\") as f:\n pickle.dump(self.decisionTree, f, pickle.HIGHEST_PROTOCOL)\n return self.decisionTree",
"def t... | [
"0.7926691",
"0.74065554",
"0.73565054",
"0.7268611",
"0.7268153",
"0.68601626",
"0.6799035",
"0.67826897",
"0.67565954",
"0.67367846",
"0.6639301",
"0.65926003",
"0.6585882",
"0.6527274",
"0.6473357",
"0.6442004",
"0.64393604",
"0.64120007",
"0.6405199",
"0.63751113",
"0.637... | 0.7751115 | 1 |
Get the precision of a classifier compared to the correct values. | def precision(classifier_output, true_labels):
# TODO: finish this.
conf_matrix = confusion_matrix(classifier_output, true_labels)
return conf_matrix[0][0]/(conf_matrix[0][0] + conf_matrix[1][0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(self):\n self.overall_precision = precision_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_precision = precision_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
"def getP... | [
"0.78460306",
"0.77924854",
"0.7721495",
"0.7632088",
"0.7632088",
"0.7632088",
"0.7632088",
"0.7632088",
"0.7632088",
"0.76283264",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
"0.7591066",
... | 0.7981426 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.