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 |
|---|---|---|---|---|---|---|
Add permissions to all DAGs. Creates 'can_read', 'can_edit', and 'can_delete' permissions for all DAGs, along with any `access_control` permissions provided in them. This does iterate through ALL the DAGs, which can be slow. See `sync_perm_for_dag` if you only need to sync a single DAG. | def create_dag_specific_permissions(self) -> None:
perms = self.get_all_permissions()
dagbag = DagBag(read_dags_from_db=True)
dagbag.collect_dags_from_db()
dags = dagbag.dags.values()
for dag in dags:
root_dag_id = dag.parent_dag.dag_id if dag.parent_dag else dag.dag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_perm_for_dag(\n self,\n dag_id: str,\n access_control: dict[str, Collection[str]] | None = None,\n ) -> None:\n dag_resource_name = permissions.resource_name_for_dag(dag_id)\n for dag_action_name in self.DAG_ACTIONS:\n self.create_permission(dag_action_name... | [
"0.71445847",
"0.6928385",
"0.6225734",
"0.618926",
"0.59796953",
"0.5897693",
"0.5667359",
"0.55808985",
"0.5536757",
"0.5498319",
"0.5476887",
"0.54443544",
"0.5367707",
"0.5366856",
"0.5364191",
"0.53560907",
"0.53519815",
"0.5307616",
"0.5281192",
"0.5278737",
"0.52778745... | 0.7489947 | 0 |
Add missing permissions to the table for admin. Admin should get all the permissions, except the dag permissions because Admin already has Dags permission. Add the missing ones to the table for admin. | def update_admin_permission(self) -> None:
session = self.appbuilder.get_session
dag_resources = session.scalars(
select(Resource).where(Resource.name.like(f"{permissions.RESOURCE_DAG_PREFIX}%"))
)
resource_ids = [resource.id for resource in dag_resources]
perms = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_missing_perms(self) -> None:\n\n # pylint: disable=import-outside-toplevel\n from superset.connectors.sqla.models import SqlaTable\n from superset.models import core as models\n\n logger.info(\"Fetching a set of all perms to lookup which ones are missing\")\n all_pvs =... | [
"0.69647944",
"0.66457176",
"0.6399103",
"0.6032672",
"0.6023026",
"0.5861807",
"0.5824052",
"0.5797001",
"0.5669763",
"0.5656293",
"0.5622083",
"0.56155336",
"0.55685437",
"0.5565045",
"0.54963064",
"0.5486159",
"0.54558253",
"0.5441496",
"0.5438132",
"0.54299444",
"0.540083... | 0.6819034 | 1 |
Initialize default and custom roles with related permissions. 1. Init the default role(Admin, Viewer, User, Op, public) with related permissions. 2. Init the custom role(daguser) with related permissions. | def sync_roles(self) -> None:
# Create global all-dag permissions
self.create_perm_vm_for_all_dag()
# Sync the default roles (Admin, Viewer, User, Op, public) with related permissions
self.bulk_sync_roles(self.ROLE_CONFIGS)
self.add_homepage_access_to_custom_roles()
# i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_roles(self):\n self.role_owner = Role.objects.get_or_create(\n name=PROJECT_ROLE_OWNER, rank=ROLE_RANKING[PROJECT_ROLE_OWNER]\n )[0]\n self.role_delegate = Role.objects.get_or_create(\n name=PROJECT_ROLE_DELEGATE, rank=ROLE_RANKING[PROJECT_ROLE_DELEGATE]\n ... | [
"0.71640617",
"0.69580996",
"0.6330744",
"0.62119347",
"0.61950326",
"0.6079152",
"0.60608494",
"0.6044329",
"0.60235196",
"0.59742445",
"0.59428924",
"0.59159476",
"0.5888189",
"0.5868204",
"0.58649665",
"0.5847457",
"0.58105373",
"0.580332",
"0.57923406",
"0.5730404",
"0.57... | 0.7069346 | 1 |
Sync permissions for given dag id. The dag id surely exists in our dag bag as only / refresh button or DagBag will call this function. | def sync_perm_for_dag(
self,
dag_id: str,
access_control: dict[str, Collection[str]] | None = None,
) -> None:
dag_resource_name = permissions.resource_name_for_dag(dag_id)
for dag_action_name in self.DAG_ACTIONS:
self.create_permission(dag_action_name, dag_resour... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sync_dag_view_permissions(self, dag_id: str, access_control: dict[str, Collection[str]]) -> None:\n dag_resource_name = permissions.resource_name_for_dag(dag_id)\n\n def _get_or_create_dag_permission(action_name: str) -> Permission | None:\n perm = self.get_permission(action_name, dag... | [
"0.69756424",
"0.6454632",
"0.607378",
"0.5552861",
"0.5497927",
"0.5473163",
"0.5398732",
"0.51111424",
"0.5103682",
"0.50776064",
"0.4782709",
"0.47417465",
"0.46969014",
"0.46962237",
"0.46481147",
"0.46422902",
"0.4602091",
"0.45997083",
"0.4581264",
"0.45444247",
"0.4469... | 0.8022313 | 0 |
Set the access policy on the given DAG's ViewModel. | def _sync_dag_view_permissions(self, dag_id: str, access_control: dict[str, Collection[str]]) -> None:
dag_resource_name = permissions.resource_name_for_dag(dag_id)
def _get_or_create_dag_permission(action_name: str) -> Permission | None:
perm = self.get_permission(action_name, dag_resource... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_perm_for_dag(\n self,\n dag_id: str,\n access_control: dict[str, Collection[str]] | None = None,\n ) -> None:\n dag_resource_name = permissions.resource_name_for_dag(dag_id)\n for dag_action_name in self.DAG_ACTIONS:\n self.create_permission(dag_action_name... | [
"0.5678417",
"0.5498908",
"0.53634614",
"0.525106",
"0.5222352",
"0.52205503",
"0.5167241",
"0.5149371",
"0.51167226",
"0.5108002",
"0.50590044",
"0.5043949",
"0.50261927",
"0.50103194",
"0.50053406",
"0.49526137",
"0.48841444",
"0.48699006",
"0.4852434",
"0.48339957",
"0.480... | 0.57381666 | 0 |
Create permvm if not exist and insert into FAB security model for alldags. | def create_perm_vm_for_all_dag(self) -> None:
# create perm for global logical dag
for resource_name in self.DAG_RESOURCES:
for action_name in self.DAG_ACTIONS:
self._merge_perm(action_name, resource_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_vpc_if_policy_group(self, name, aep_name):\n policy_group_mo = AccBndlGrp('uni/infra/funcprof/', name, lagT='node')\n self.commit(policy_group_mo)\n # if attachable entity profile does not exists, creates a new one\n class_query = ClassQuery('infraAttEntityP')\n class_... | [
"0.58854306",
"0.5420295",
"0.51205784",
"0.5104541",
"0.50927716",
"0.5074957",
"0.50747347",
"0.5033376",
"0.4975094",
"0.4972838",
"0.48911983",
"0.48370972",
"0.4829802",
"0.48251015",
"0.48227528",
"0.4808085",
"0.4798749",
"0.47678334",
"0.47611704",
"0.4758598",
"0.474... | 0.5463835 | 1 |
Initialize a primative parser. | def __init__(self):
self.prim_parser = parser.Parser() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kw):\n self.parser = Parser(*args, **kw)",
"def __init__(self, parser=None):",
"def __init__(self):\n print \"You asked for a Parser!\"",
"def __init__(self, parser: Any = None):",
"def __init__(self):\n Parser.__init__(self)\n self.__line_number = 0 ... | [
"0.6944528",
"0.66409266",
"0.66263324",
"0.6401875",
"0.6371824",
"0.61412036",
"0.6126739",
"0.60916764",
"0.60392183",
"0.60321903",
"0.59601814",
"0.5923435",
"0.5907228",
"0.5870026",
"0.5801741",
"0.57332784",
"0.572136",
"0.5712518",
"0.57117873",
"0.5708687",
"0.57005... | 0.8043076 | 0 |
Parse the PRINT statement. The arguments of print can be a primative or arithmetic expression. | def parse_print(self, words):
print_obj = Print()
input_str = ' '.join(words)
obj = self.prim_parser.parse_arith_expr(input_str)
if obj:
print_obj.arg = obj
else:
obj = self.prim_parser.parse_primative_obj(input_str)
if obj:
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_print(self, cmd):\n try:\n print(self.EvalExpression(cmd))\n except:\n pass",
"def pprint(*args, **kwargs):\n if PRINTING:\n print(*args, **kwargs)",
"def _run_print(self):\n instruction = self.bytecode.code[self.ip]\n input_type = self.bytecode.code[self.ip + 1]\... | [
"0.5450321",
"0.54257673",
"0.5296611",
"0.5223602",
"0.51722485",
"0.5059355",
"0.5012089",
"0.49853182",
"0.49688977",
"0.4929221",
"0.49207166",
"0.4889229",
"0.4842015",
"0.47861603",
"0.47843853",
"0.4772744",
"0.47649443",
"0.47477672",
"0.47368357",
"0.47303003",
"0.47... | 0.7103151 | 0 |
Parse the LET statement args. The arguments are a variable, "=", and an expression. | def parse_let(self, words):
let_obj = Let()
obj_var = self.prim_parser.parse_var(words[0])
if obj_var:
let_obj.var = obj_var
if words[1] == '=':
rest = words[2:]
rest_str = ' '.join(words[2:])
arith_expr_obj = self.prim_par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_arguments(args):",
"def parse_args(args_text: Text) -> Args:\n return tuple(\n interp_value_from_string(a) for a in args_text.split(';') if a.strip())",
"def parse_arguements():\r\n\r\n info = \"Perform LLE on a given X matrix of data and optional Y labels\"\r\n parser = argparse.Argument... | [
"0.56393695",
"0.5488855",
"0.5391135",
"0.536646",
"0.53150535",
"0.5247378",
"0.52155995",
"0.5206109",
"0.5205791",
"0.5194514",
"0.5180917",
"0.51377404",
"0.51271456",
"0.51270646",
"0.5068318",
"0.5052861",
"0.50487244",
"0.504253",
"0.5022233",
"0.5016177",
"0.5016102"... | 0.59192336 | 0 |
Parse the GOTO statement. The argument can be anything that evaluates to a number label. | def parse_goto(self, words):
goto_obj = Goto()
input_str = ' '.join(words)
obj = self.prim_parser.parse_arith_expr(input_str)
if obj:
goto_obj.label = obj
else:
obj = self.prim_parser.parse_num(input_str)
if obj:
goto_obj.labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cg_goto(self, cmd):\n label = self.makeLabel(cmd)\n self.asm(unindent(f\"\"\"\n @{label}\n 0;JMP\n \"\"\"))",
"def goto(n):\n n = int('{}'.format(n))\n get_controller().step_to(n)",
"def goto(action, value, error_handle):\n print_info(\"failed: failur... | [
"0.59043664",
"0.571691",
"0.5656129",
"0.5361607",
"0.535743",
"0.53304034",
"0.52985924",
"0.51921517",
"0.5165587",
"0.51377875",
"0.5116282",
"0.5073228",
"0.50564355",
"0.5052013",
"0.49735686",
"0.4971201",
"0.49217594",
"0.49034017",
"0.48185778",
"0.4752092",
"0.47519... | 0.6092517 | 0 |
Parse the NEXT statement. | def parse_next(self, words):
next_obj = Next()
if len(words) == 1:
var_obj = self.prim_parser.parse_var(words[0])
if var_obj:
next_obj.var = var_obj
else:
raise StatementParseError(
'Invalid NEXT statement var {0}.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_next_instruction(self) -> None:\n instruction = self.program[self.pointer]\n opcode = instruction % 100\n if opcode == 99:\n self.halt = True\n\n self.modes = instruction // 100\n\n if opcode == 1:\n self.op_sum()\n if opcode == 2:\n ... | [
"0.62025493",
"0.603383",
"0.603383",
"0.60183877",
"0.5960151",
"0.5826634",
"0.5793032",
"0.5793032",
"0.5746273",
"0.57045674",
"0.5698597",
"0.56563187",
"0.5653924",
"0.5641119",
"0.56398654",
"0.5605107",
"0.56033105",
"0.55152005",
"0.5478389",
"0.54605097",
"0.5419138... | 0.69342494 | 0 |
Parse the IFTHEN statement. | def parse_ifthen(self, words):
ifthen_obj = IfThen()
if len(words) == 5:
arg1_obj = self.prim_parser.parse_primative_obj(words[0])
bool_op_obj = self.prim_parser.parse_bool_op(words[1])
arg2_obj = self.prim_parser.parse_primative_obj(words[2])
then_flag =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseIfStatement( ): # parse rountine for the if and uses the if class to print out the appropriate string\n\n\ttok = tokens.peek( )\n\tif debug: print( \"ifStatement: \", tok )\n\tstart = match( \"if\" )\n\texpr = expression( )\n\tblk = parseBlock( )\n\telseblk = None\n\ttok = tokens.peek( )\n\tif tok == \"el... | [
"0.688943",
"0.64483243",
"0.6328138",
"0.63113165",
"0.62778693",
"0.59737927",
"0.58829176",
"0.58608335",
"0.5852734",
"0.5815672",
"0.5770163",
"0.57656604",
"0.57615894",
"0.57266235",
"0.5684156",
"0.56465256",
"0.5621939",
"0.5607341",
"0.55948055",
"0.55742",
"0.55658... | 0.7190795 | 0 |
Parse the END statement. | def parse_end(self, words):
end_obj = End()
if words:
raise StatementParseError(
'The END statement should have no extra words: {0}.'.format(
words))
return end_obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end():\n return EndBlock()",
"def parse_footer(self): # -> tuple[list[Unknown], Literal['']]:\n ...",
"def parse(self, tokens):\n self.tokens = tokens\n self.tokens.append(END())\n t = self.e()\n self.expect(END)\n return t",
"def endComment():\r\n\tglobal sET... | [
"0.6380834",
"0.62347376",
"0.6156883",
"0.60980904",
"0.60832125",
"0.60414135",
"0.6007475",
"0.59288806",
"0.59009564",
"0.58169407",
"0.57706946",
"0.56779563",
"0.56779563",
"0.56710136",
"0.56252414",
"0.5613877",
"0.55523235",
"0.5547321",
"0.55277026",
"0.55220705",
"... | 0.7269551 | 0 |
Parse a set of statement words. The label line number has already been removed and the first word is the statement keyword. The rest of the words are the statement arguments. | def parse_statement(self, words):
keyword = words[0]
rest = words[1:]
if keyword == 'PRINT':
obj = self.parse_print(rest)
elif keyword == 'LET':
obj = self.parse_let(rest)
elif keyword == 'GOTO':
obj = self.parse_goto(rest)
elif keywo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseStmt(line):\n print(\"Statement\")\n index=0\n if line[0] == 's':\n print(\"Set\")\n index += 4\n rest = line[index:]\n cmds = str.split(rest, ',')\n parseSet(cmds)\n elif line[0] == 'h':\n ... | [
"0.573954",
"0.5613782",
"0.5517276",
"0.5517276",
"0.52339894",
"0.5123275",
"0.49992552",
"0.49817768",
"0.49817768",
"0.4913706",
"0.49128622",
"0.48561028",
"0.4813784",
"0.47896823",
"0.47804374",
"0.4778509",
"0.47712478",
"0.47417298",
"0.4740112",
"0.47180837",
"0.471... | 0.6375764 | 0 |
Trap JSON decoding failures and provide more detailed errors Remove ')]}' XSS prefix from data if it is present, then decode it as JSON and return the results. | def decode_json(raw):
# Gerrit's REST API prepends a JSON-breaker to avoid XSS vulnerabilities
if raw.text.startswith(")]}'"):
trimmed = raw.text[4:]
else:
trimmed = raw.text
# Try to decode and bail with much detail if it fails
try:
decoded = json.loads(trimmed)
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_json(raw):\n\n # Gerrit's REST API prepends a JSON-breaker to avoid XSS vulnerabilities\n if raw.text.startswith(\")]}'\"):\n trimmed = raw.text[4:]\n else:\n trimmed = raw.text\n\n # Try to decode and bail with much detail if it fails\n try:\n decoded = json.loads(tr... | [
"0.6794312",
"0.6583596",
"0.6417889",
"0.6340136",
"0.62537545",
"0.6229566",
"0.6154212",
"0.6125549",
"0.6063384",
"0.6061887",
"0.60408986",
"0.6032854",
"0.5998402",
"0.59870005",
"0.5962834",
"0.5893691",
"0.5891434",
"0.5890469",
"0.58832896",
"0.5878274",
"0.5867642",... | 0.67851794 | 1 |
Query the Gerrit REST API | def query_gerrit(offset=0):
url = 'https://review.opendev.org/changes/'
LOG.debug('fetching %s', url)
raw = requests.get(
url,
params={
'n': '100',
'start': offset,
'q': 'project:openstack/governance is:open',
'o': [
'ALL_REVISI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_gerrit(method, params={}, verbose=0):\n\n return decode_json(requester(\"%s/%s\" % (GERRIT_BASE, method),\n params=params,\n headers={'Accept': 'application/json'},\n verbose=verbose))",
"def _query(actio... | [
"0.77562743",
"0.6120338",
"0.60652655",
"0.566763",
"0.56369096",
"0.5617672",
"0.557019",
"0.5536899",
"0.55219513",
"0.55080754",
"0.5492061",
"0.54717964",
"0.54580337",
"0.54435146",
"0.54301286",
"0.5413435",
"0.54131085",
"0.5411413",
"0.5411413",
"0.53971434",
"0.5370... | 0.6680208 | 1 |
Determines the satellite number for a given date. | def _get_goes_sat_num(self, date):
goes_operational = {
2: TimeRange("1981-01-01", "1983-04-30"),
5: TimeRange("1983-05-02", "1984-07-31"),
6: TimeRange("1983-06-01", "1994-08-18"),
7: TimeRange("1994-01-01", "1996-08-13"),
8: TimeRange("1996-03-21", "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_goes_sat_num(self, date):\n\n # GOES-17 is operational but currently does not provide Level 2 data\n # GOES-16 start date is based on the availability of regular level 1b data\n suvi_operational = {\n 16: TimeRange(\"2018-06-01\", parse_time(\"now\")),\n }\n\n ... | [
"0.7167133",
"0.6191373",
"0.59824467",
"0.59554714",
"0.5927746",
"0.58375365",
"0.5829639",
"0.579904",
"0.5788288",
"0.5535905",
"0.54828674",
"0.54560727",
"0.5452765",
"0.5443098",
"0.5432317",
"0.54228646",
"0.5382635",
"0.53717595",
"0.5346957",
"0.53393257",
"0.533135... | 0.7115077 | 1 |
Determines the best satellite number for a given date. | def _get_goes_sat_num(self, date):
# GOES-17 is operational but currently does not provide Level 2 data
# GOES-16 start date is based on the availability of regular level 1b data
suvi_operational = {
16: TimeRange("2018-06-01", parse_time("now")),
}
results = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_goes_sat_num(self, date):\n goes_operational = {\n 2: TimeRange(\"1981-01-01\", \"1983-04-30\"),\n 5: TimeRange(\"1983-05-02\", \"1984-07-31\"),\n 6: TimeRange(\"1983-06-01\", \"1994-08-18\"),\n 7: TimeRange(\"1994-01-01\", \"1996-08-13\"),\n 8... | [
"0.74015623",
"0.56602454",
"0.5434096",
"0.5408103",
"0.5402877",
"0.53601795",
"0.53103787",
"0.52805215",
"0.5273263",
"0.5166013",
"0.5148456",
"0.5140715",
"0.5115912",
"0.5089272",
"0.50828665",
"0.50501645",
"0.50464404",
"0.4998767",
"0.49792892",
"0.49729776",
"0.497... | 0.74445915 | 0 |
Calculates the loglikelihood of neighboring solutions of a batch of nodes by changing their membership. If a higher loglikelihood was achieved the best solution will be returned, else a tuple of three np.nan is returned. | def calc_node_neigh_solutions(event_dict, n_classes, duration, node_membership, log_lik_init, node_batch):
best_neigh = (np.nan, np.nan, np.nan)
log_lik = log_lik_init
# node_membership = node_membership.copy()
for n_i in node_batch:
n_i_class = node_membership[n_i]
# Adding a constra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_full_log_likelihood(bp_events, node_membership, mu, alpha, beta, duration, num_classes,\n add_com_assig_log_prob=False):\n ll = 0\n for b_i in range(num_classes):\n for b_j in range(num_classes):\n bp_size = len(np.where(node_membership == b_i)[0]) * len... | [
"0.6380167",
"0.61678493",
"0.6130389",
"0.61122036",
"0.59834164",
"0.59834164",
"0.5842508",
"0.5807362",
"0.5767984",
"0.5747156",
"0.5727282",
"0.5678164",
"0.5648807",
"0.5646092",
"0.5632708",
"0.5607198",
"0.5598938",
"0.558566",
"0.55793875",
"0.55783534",
"0.5550739"... | 0.68580836 | 0 |
Performs local search / hill climbing to increase loglikelihood of the model by switching the community of a single node at a time. | def block_local_search(event_dict, n_classes, node_membership_init, duration, max_iter=100, n_cores=-1,
return_fitted_param=False, verbose=False):
n_nodes = len(node_membership_init)
nodes = np.arange(n_nodes)
node_membership = node_membership_init
# estimate initial params of bl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_local_community(G, seed_node, weight, debug_log=False):\n nodes_in_community = seed_node if isinstance(seed_node, list) else [seed_node]\n modularity = edge_modularity(G, nodes_in_community=nodes_in_community, weight=weight)\n neighbor_edges = get_neighbor_edges(G, nodes_in_community=nodes_in_com... | [
"0.5958453",
"0.5573722",
"0.5491155",
"0.5486477",
"0.54507476",
"0.5270489",
"0.5265971",
"0.5214528",
"0.5209087",
"0.51547647",
"0.5126377",
"0.5099805",
"0.5061796",
"0.505253",
"0.5044211",
"0.49928075",
"0.49840775",
"0.49137068",
"0.48985308",
"0.48884547",
"0.4882067... | 0.5771196 | 1 |
Make Status comparable with self by code | def __eq__(self, other: Union[int, Status]):
if isinstance(other, int):
return self.code == other
return isinstance(other, self.__class__) and self.code == other.code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self: \"Status\", other: \"Status\") -> bool: # type: ignore\n self_type = type(self)\n other_type = type(other)\n\n if self_type is InProgress and other_type is InProgress:\n return self.progress == other.progress # type: ignore\n else:\n return self_... | [
"0.6859543",
"0.6738789",
"0.6598233",
"0.6417689",
"0.6345078",
"0.6310382",
"0.63007295",
"0.62662905",
"0.61624473",
"0.6147009",
"0.6132704",
"0.61120963",
"0.61000186",
"0.6042819",
"0.6041936",
"0.5995533",
"0.5994983",
"0.5986107",
"0.59528095",
"0.59277666",
"0.591593... | 0.6897788 | 0 |
failed reason of the bulk insert task. | def failed_reason(self):
return self._infos.get(BulkInsertState.FAILED_REASON, "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_failure_reason(self) -> str:\n return pulumi.get(self, \"import_failure_reason\")",
"def _message_failed_job(self):\n self.ensure_one()\n return _(\"Something bad happened during the execution of the job. \"\n \"More details in the 'Exception Information' section.\... | [
"0.68418854",
"0.62447983",
"0.6241091",
"0.61471653",
"0.6106991",
"0.6001903",
"0.59929",
"0.5870454",
"0.5813409",
"0.5633343",
"0.56094086",
"0.55935335",
"0.55862993",
"0.55839294",
"0.5577333",
"0.55691516",
"0.5561922",
"0.551973",
"0.55102104",
"0.55077887",
"0.550495... | 0.83458185 | 0 |
target collection's name of the bulk insert task. | def collection_name(self):
return self._infos.get(BulkInsertState.IMPORT_COLLECTION, "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_name(self):\n pass",
"def thread_insert_data(collection_to_insert, collection_name):\n for item in collection_to_insert:\n insert_data_to_collection(item, collection_name)",
"def insert_task():\n try:\n task = get_task_from_request_form(request)\n result = mongo.db.ta... | [
"0.6016323",
"0.55878556",
"0.54873735",
"0.54751295",
"0.5362512",
"0.53117585",
"0.52913535",
"0.52896",
"0.52852416",
"0.5263717",
"0.5206333",
"0.51969993",
"0.5184043",
"0.5139039",
"0.5137758",
"0.51221275",
"0.50949633",
"0.5092773",
"0.5090364",
"0.50835437",
"0.50536... | 0.7637074 | 0 |
target partition's name of the bulk insert task. | def partition_name(self):
return self._infos.get(BulkInsertState.IMPORT_PARTITION, "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_name(self):\n pass",
"def task_name(self) -> str:\n return self._task_name",
"def TaskBaseName(cls, task):\n if not task: return None\n return os.path.basename(task)",
"def partitionname(self) :\n\t\ttry :\n\t\t\treturn self._partitionname\n\t\texcept Exception as e:\n\t\t\traise... | [
"0.642006",
"0.5991149",
"0.57977974",
"0.5696203",
"0.5643535",
"0.56396157",
"0.5575479",
"0.55660444",
"0.5543619",
"0.5543344",
"0.5462731",
"0.5421342",
"0.5402544",
"0.5358951",
"0.5286111",
"0.52766335",
"0.52726984",
"0.52697146",
"0.5253021",
"0.52260923",
"0.5208673... | 0.71681 | 0 |
A readable string converted from the timestamp when this task is created. | def create_time_str(self):
ts = time.localtime(self._create_ts)
return time.strftime("%Y-%m-%d %H:%M:%S", ts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creation_time_str(self):\n return \"%Y/%m/%d %I:%M:%S\".format(self.creation_time)",
"def creation_timestamp(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"creation_timestamp\")",
"def created_time(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"created_time\")",
"... | [
"0.7777843",
"0.73781943",
"0.73427457",
"0.73427457",
"0.733272",
"0.733272",
"0.73199356",
"0.73199356",
"0.73199356",
"0.7313272",
"0.7313272",
"0.7313272",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",
"0.7303396",... | 0.7573687 | 1 |
Creates a User based on input from HTML page, returns a confirmation of their login and what is currently in their pantry. | def make_user():
names = request.args.get('names', 1, type=str) #raw text input from HTML page
global db
global current_user
current_user = User(names, db)
# Adding the user to the db occurs in the user class,
# only in the get_pantry method
str_pantry = current_user.get_pantry()
if str_pantry == "": ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user():\n if request.method == 'POST':\n PLAN.create_user(request.form['fname'],\n request.form['lname'],\n request.form['username'],\n request.form['password'],\n request.form['email'])\n re... | [
"0.67911476",
"0.6687623",
"0.6670097",
"0.6576688",
"0.65273166",
"0.6521119",
"0.65059036",
"0.63679117",
"0.6336169",
"0.62900233",
"0.6285918",
"0.6281631",
"0.6260428",
"0.62550753",
"0.6240885",
"0.62408364",
"0.62045276",
"0.620404",
"0.6189837",
"0.6176125",
"0.616785... | 0.6709298 | 1 |
Given a list of ingredients, adds these ingredients to current user's pantry. | def update_pantry():
pantry_ingredients = request.args.get('pantry', '', type=str) #raw input from HTML page of ingredients
global current_user
current_user.pantry.make_pantry(pantry_ingredients) #calls recipe_program function make_pantry()
current_user.pantry.save_pantry()
return jsonify(pantry = pantry_ingr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ingredients(self, ingredients: [Ingredient]):\n self.ingredients = ingredients",
"def add_ingredient_to_recipe(cls, new_count, ingredients_dict, recipe_id):\n\n for i in range(1, (new_count+1)):\n item = ingredients_dict[i][0]\n measure = ingredients_dict[i][1]\n ... | [
"0.66322947",
"0.5902966",
"0.5876643",
"0.58038753",
"0.55976385",
"0.5445218",
"0.53158426",
"0.5289061",
"0.5242519",
"0.5237167",
"0.52076864",
"0.51996523",
"0.5175513",
"0.5174235",
"0.5161576",
"0.51343304",
"0.51291",
"0.5117913",
"0.50955284",
"0.50773734",
"0.506931... | 0.6216724 | 1 |
Given the max total cook time from html, returns a confirmation of this time, and sets global time variable | def timed_recipes():
time = request.args.get('time', 0, type=int) #raw input from HTML page
global time_global
time_global = time #sets global time to inputted time, for use in search function
return jsonify(cooktime=time_global) #returns a confirmation of the input tiime | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_time(self, amt):\n amtOfTime = amt + 1\n Publisher().sendMessage(\"update\", amtOfTime)",
"def setSubmitTime(t):",
"def time_until(self, cookies):\n cost = cookies - self._current_cookies\n time = 0.0\n if cost > 0.0:\n time = math.ceil(cost/self._cps)\n ... | [
"0.58636785",
"0.58126634",
"0.5734073",
"0.5726692",
"0.5678101",
"0.5631498",
"0.5614202",
"0.56048214",
"0.55501574",
"0.554194",
"0.5524732",
"0.55029875",
"0.54991966",
"0.5428994",
"0.5405343",
"0.5398133",
"0.5343726",
"0.5329316",
"0.53012264",
"0.52985454",
"0.529389... | 0.6744248 | 0 |
Extract topk entities given seeds. | def get_topk_extracted_ent(self, seeds, alpha, topk):
#tf.logging.info('Start ppr')
ppr_scores = csr_personalized_pagerank(seeds, self.data.adj_mat_t_csr,
alpha)
#tf.logging.info('End ppr')
sorted_idx = np.argsort(ppr_scores)[::-1]
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tops(similarities, k):\n tops = similarities.argsort(axis=1)[:, :k].tolist()\n return tops",
"def topk(vec, k):\n vec = torch.topk(vec, k)\n return vec.view(-1).data.tolist()",
"def get_top_featured_entries(number=5):\n return list(Entry.published.filter(featured=True)[:number])",
"def... | [
"0.6067031",
"0.59501433",
"0.56342024",
"0.56280166",
"0.56253827",
"0.5582722",
"0.55795217",
"0.55525213",
"0.55328137",
"0.5528902",
"0.5520351",
"0.54736173",
"0.5471133",
"0.54636014",
"0.5440023",
"0.5429825",
"0.53809315",
"0.5375162",
"0.53751266",
"0.533664",
"0.532... | 0.6884426 | 0 |
Sorts urls into groups based on shared url directory paths. | def group_by_dir(urlist):
dir_groups = {}
for url in urlist:
net_subdir, filename = url_unquote(url).rsplit('/',1)
if net_subdir in dir_groups:
dir_groups[net_subdir].append((url, filename))
else:
dir_groups[net_subdir] = [(url, filename)]
return dir_groups | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_urls(urls):\n order = {\"css\": 0, \"js\": 1}\n urls.sort(key=lambda x: order.get(x.rsplit(\".\")[-1].lower(), 2))\n return urls",
"def sorting_urls(train_imgs, test_imgs, val_imgs):\n\n # Get the bad urls\n bad_urls = get_bad_urls()\n # Get Dev data-set\n dev_imgs = get_dev_entitie... | [
"0.57895535",
"0.5670673",
"0.5564441",
"0.54175895",
"0.53898895",
"0.53325456",
"0.53169215",
"0.5315415",
"0.53019637",
"0.5280857",
"0.52352136",
"0.51627064",
"0.51559484",
"0.51417136",
"0.5128693",
"0.5127541",
"0.51115924",
"0.5106754",
"0.50983864",
"0.5086738",
"0.5... | 0.690476 | 0 |
Compute and return some property from the config options. Use in a template as config. {{ '{{' }} config.computed_some_property {{ '}}' }} | def computed_some_property(config):
return config.something + 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_value(name):\n def get():\n try:\n return config.get('yourls', name)\n except (NoOptionError, NoSectionError):\n return None\n return get",
"def get_prop(name: str, optional: bool = False) -> str:\n config = os.environ.get(name, app.config.get(name))\n i... | [
"0.58720696",
"0.5688264",
"0.5646648",
"0.5464817",
"0.5446991",
"0.54390156",
"0.53303957",
"0.53082174",
"0.52847975",
"0.52617794",
"0.52528036",
"0.5231562",
"0.5209172",
"0.51441497",
"0.51429886",
"0.51114094",
"0.509669",
"0.5087842",
"0.5084989",
"0.5078126",
"0.5040... | 0.7533298 | 0 |
Validate that the driver configuration is sane/complete Return (status, message) if there is a problem or (None, None) if there are no issues. Delete this function if it's not needed. | def custom_assess_status_check(self):
options = self.options
# can check options.thing to ensure that it makes sense
# if wrong return 'blocked', "The driver is badly configured ..."
return None, None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateConfig(self):\n ## (boolean with the result of the validation, eventual error message)\n return (True, '')",
"def _validate_config(self):\n pass",
"def validate_config(self):\n pass",
"def validate_config(self):\n pass",
"def _check_config(self):",
"def chec... | [
"0.64212245",
"0.608745",
"0.60780764",
"0.60780764",
"0.5963149",
"0.5936095",
"0.58347476",
"0.5826374",
"0.5778542",
"0.5762001",
"0.5713054",
"0.56735516",
"0.5649959",
"0.56488603",
"0.5648123",
"0.5642532",
"0.5586238",
"0.55713135",
"0.55353975",
"0.55154055",
"0.54976... | 0.6580841 | 0 |
Assuming that the configuration data is valid, return the configuration data for the principal charm. | def get_config_for_principal(self, auth_data):
# If there is no auth_data yet, then we can't write our config.
if not auth_data:
return {}
# If the state from the assess_status is not None then we're blocked,
# so don't send any config to the principal.
state, message... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_config_data(self, cr, uid):\n\n model_conf = self.pool.get('customer.support.settings')\n args = [('selected', '=', True)] \n ids = model_conf.search(cr, uid, args)\n config = model_conf.browse(cr, uid, ids[0])\n\n return {\n 'tor_api_key': config.tor_api_k... | [
"0.59209836",
"0.5861069",
"0.54529774",
"0.542924",
"0.5428179",
"0.5417673",
"0.54086673",
"0.5405804",
"0.5397979",
"0.53960115",
"0.5393643",
"0.532532",
"0.53216976",
"0.53216976",
"0.53216976",
"0.53216976",
"0.53216976",
"0.53216976",
"0.53216976",
"0.53216976",
"0.532... | 0.66414106 | 0 |
Test requesting an empty, default node using a Component. | def testInfoEmptyDefaultNodeComponent(self):
self.stream_start(mode='component',
jid='tester.localhost',
plugins=['xep_0030'])
self.recv("""
<iq type="get" id="test">
<query xmlns="http://jabber.org/protocol/disco#info" />
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init_empty_node():\n from dll import Node\n new_node = Node()\n assert new_node.value is None",
"def test_empty_node():\n try:\n Node({})\n except Exception as e:\n assert str(e) == 'input info has more than 1 entry!'\n # create node with empty connection\n try:\n ... | [
"0.66112286",
"0.6523052",
"0.6461104",
"0.61584496",
"0.59600675",
"0.59370893",
"0.5814065",
"0.5803736",
"0.5758269",
"0.57452965",
"0.57452965",
"0.5716095",
"0.5696055",
"0.5685341",
"0.56674856",
"0.5646907",
"0.56448424",
"0.55874735",
"0.5577212",
"0.5576971",
"0.5574... | 0.6988443 | 0 |
Results for info queries directed to a particular node MUST include the node in the query response. | def testInfoIncludeNode(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
self.xmpp['xep_0030'].static.add_node(node='testing')
self.recv("""
<iq to="tester@localhost/resource" type="get" id="test">
<query xmlns="http://jabber.org/pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __disco_info(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n node=None\n info=self.disco_get_info(node,iq)\n if isinstance(info,DiscoInfo):\n resp=iq.make_result_response()\n self.... | [
"0.6733756",
"0.6596269",
"0.6055855",
"0.5941904",
"0.5860143",
"0.5851458",
"0.58275557",
"0.57836586",
"0.5761637",
"0.5755889",
"0.5730647",
"0.56020886",
"0.5503883",
"0.55025244",
"0.5459274",
"0.5458452",
"0.54305786",
"0.54279375",
"0.53848815",
"0.53615916",
"0.53319... | 0.7001901 | 0 |
Results for items queries directed to a particular node MUST include the node in the query response. | def testItemsIncludeNode(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
self.xmpp['xep_0030'].static.add_node(node='testing')
self.recv("""
<iq to="tester@localhost/resource" type="get" id="test">
<query xmlns="http://jabber.org/p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def localQuery(self,node,REQUEST=None, **kw):\n kw['path'] = '/'.join(node.getPhysicalPath())\n return ZCatalog.searchResults(self, REQUEST, **kw)",
"def __disco_items(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n... | [
"0.6396363",
"0.6289037",
"0.61644876",
"0.60375875",
"0.5958757",
"0.5912728",
"0.5889202",
"0.57394123",
"0.55327314",
"0.55124384",
"0.54693735",
"0.54070544",
"0.5401821",
"0.5362063",
"0.53572315",
"0.532478",
"0.53014815",
"0.52646244",
"0.5233796",
"0.52228504",
"0.518... | 0.70169383 | 0 |
Test using a dynamic info handler for a particular JID. | def testDynamicInfoJID(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
def dynamic_jid(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoInfo()
result['node'] = node
result.add_identity('client', 'console', name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testOverrideJIDInfoHandler(self):\n self.stream_start(mode='client',\n plugins=['xep_0030'])\n\n def dynamic_jid(jid, node, ifrom, iq):\n result = self.xmpp['xep_0030'].stanza.DiscoInfo()\n result['node'] = node\n result.add_identity('clie... | [
"0.603616",
"0.5224581",
"0.5204453",
"0.5167123",
"0.50931525",
"0.50643635",
"0.4940391",
"0.49184337",
"0.49126655",
"0.488274",
"0.48677832",
"0.48579577",
"0.48276332",
"0.48139375",
"0.48109928",
"0.4763304",
"0.4754561",
"0.47542498",
"0.474684",
"0.47033742",
"0.47029... | 0.6074457 | 0 |
Test overriding a JID info handler. | def testOverrideJIDInfoHandler(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
def dynamic_jid(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoInfo()
result['node'] = node
result.add_identity('client', 'consol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDynamicInfoJID(self):\n self.stream_start(mode='client',\n plugins=['xep_0030'])\n\n def dynamic_jid(jid, node, ifrom, iq):\n result = self.xmpp['xep_0030'].stanza.DiscoInfo()\n result['node'] = node\n result.add_identity('client', 'co... | [
"0.5675587",
"0.5537099",
"0.54448056",
"0.5395349",
"0.5346919",
"0.53391",
"0.5268721",
"0.51122886",
"0.50774336",
"0.5047395",
"0.50276953",
"0.5019117",
"0.5018244",
"0.5018244",
"0.5015036",
"0.50043046",
"0.49973047",
"0.49818295",
"0.49638623",
"0.4939039",
"0.4936528... | 0.726444 | 0 |
Test overriding the global JID info handler. | def testOverrideGlobalInfoHandler(self):
self.stream_start(mode='component',
jid='tester.localhost',
plugins=['xep_0030'])
def dynamic_global(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoInfo()
result['node... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testOverrideJIDInfoHandler(self):\n self.stream_start(mode='client',\n plugins=['xep_0030'])\n\n def dynamic_jid(jid, node, ifrom, iq):\n result = self.xmpp['xep_0030'].stanza.DiscoInfo()\n result['node'] = node\n result.add_identity('clie... | [
"0.6870358",
"0.54498476",
"0.5428008",
"0.53908557",
"0.5370121",
"0.52585053",
"0.5192192",
"0.5162853",
"0.51565474",
"0.5142715",
"0.5131223",
"0.5112319",
"0.5112319",
"0.5111863",
"0.51048714",
"0.50948215",
"0.50879955",
"0.5078496",
"0.5074785",
"0.50513303",
"0.50245... | 0.5859276 | 1 |
Test sending a discoinfo query to another entity and receiving the result. | def testGetInfoRemote(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
events = set()
def handle_disco_info(iq):
events.add('disco_info')
self.xmpp.add_event_handler('disco_info', handle_disco_info)
self.xmpp.wrap(self.xmpp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __disco_info(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n node=None\n info=self.disco_get_info(node,iq)\n if isinstance(info,DiscoInfo):\n resp=iq.make_result_response()\n self.... | [
"0.6199992",
"0.6011163",
"0.6003741",
"0.59166396",
"0.58798325",
"0.56821346",
"0.5621804",
"0.5620803",
"0.5614971",
"0.5555766",
"0.5552566",
"0.55466306",
"0.5536039",
"0.55310833",
"0.5511466",
"0.55068636",
"0.5483223",
"0.54768014",
"0.5472417",
"0.5466013",
"0.543676... | 0.694831 | 0 |
Test using a dynamic items handler for a particular JID. | def testDynamicItemsJID(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
def dynamic_jid(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoItems()
result['node'] = node
result.add_item('tester@localhost', node='f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testOverrideJIDItemsHandler(self):\n self.stream_start(mode='client',\n plugins=['xep_0030'])\n\n def dynamic_jid(jid, node, ifrom, iq):\n result = self.xmpp['xep_0030'].stanza.DiscoItems()\n result['node'] = node\n result.add_item('tester... | [
"0.6029902",
"0.55530435",
"0.54791045",
"0.54502743",
"0.5430259",
"0.532237",
"0.52918226",
"0.527074",
"0.51665753",
"0.51387405",
"0.5137336",
"0.51323307",
"0.51175356",
"0.50867325",
"0.5077828",
"0.50663286",
"0.5026798",
"0.50260264",
"0.49849564",
"0.49659404",
"0.49... | 0.6357774 | 0 |
Test overriding a JID items handler. | def testOverrideJIDItemsHandler(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
def dynamic_jid(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoItems()
result['node'] = node
result.add_item('tester@localhost',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item(self, item_name):\n\tself.log.info('Not implemented yet... Sorry!')\n\tpass",
"def testOverrideGlobalItemsHandler(self):\n self.stream_start(mode='component',\n jid='tester.localhost',\n plugins=['xep_0030'])\n\n def dynamic_global(jid, nod... | [
"0.62347704",
"0.6178297",
"0.5937533",
"0.5896504",
"0.5749715",
"0.56762606",
"0.5633245",
"0.56151956",
"0.55781144",
"0.55640936",
"0.5548436",
"0.5520043",
"0.5515242",
"0.5451386",
"0.54217774",
"0.5370774",
"0.5364858",
"0.5345353",
"0.5321662",
"0.5310886",
"0.5262798... | 0.75180954 | 0 |
Test overriding the global JID items handler. | def testOverrideGlobalItemsHandler(self):
self.stream_start(mode='component',
jid='tester.localhost',
plugins=['xep_0030'])
def dynamic_global(jid, node, ifrom, iq):
result = self.xmpp['xep_0030'].stanza.DiscoItems()
result['no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testOverrideJIDItemsHandler(self):\n self.stream_start(mode='client',\n plugins=['xep_0030'])\n\n def dynamic_jid(jid, node, ifrom, iq):\n result = self.xmpp['xep_0030'].stanza.DiscoItems()\n result['node'] = node\n result.add_item('tester... | [
"0.73689735",
"0.6308142",
"0.60755616",
"0.58666635",
"0.57607436",
"0.5755129",
"0.5733778",
"0.566231",
"0.5598811",
"0.55508614",
"0.55326015",
"0.54916745",
"0.5477484",
"0.5468347",
"0.5459972",
"0.5378309",
"0.53369355",
"0.53179693",
"0.53076214",
"0.52763283",
"0.525... | 0.680608 | 1 |
Test sending a discoitems query to another entity and receiving the result. | def testGetItemsRemote(self):
self.stream_start(mode='client',
plugins=['xep_0030'])
events = set()
results = set()
def handle_disco_items(iq):
events.add('disco_items')
results.update(iq['disco_items']['items'])
self.xmpp.add... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __disco_items(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n node=None\n items=self.disco_get_items(node,iq)\n if isinstance(items,DiscoItems):\n resp=iq.make_result_response()\n ... | [
"0.61279446",
"0.6030953",
"0.5861904",
"0.5858192",
"0.5838408",
"0.58140504",
"0.5798844",
"0.57639545",
"0.56897074",
"0.5598579",
"0.55827343",
"0.5550136",
"0.5541892",
"0.55156195",
"0.5513321",
"0.55097985",
"0.54703015",
"0.54435825",
"0.5436962",
"0.54357976",
"0.542... | 0.6962557 | 0 |
Use nlp to find nouns | def get_nouns(self):
blob = TextBlob(self.raw_string)
for word, tag in blob.tags:
if tag in ['NNP', 'NN']:
self.nouns.append(word.lemmatize()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def en_noun(t, label):\r\n s = label\r\n p = []\r\n is_uncountable = False\r\n \r\n # http://en.wiktionary.org/wiki/Template:en-noun\r\n head = t.arg(\"head\", label)\r\n p1 = t.arg(0)\r\n p2 = t.arg(1)\r\n \r\n if p1 == \"-\":\r\n # uncountable\r\n is_uncountable = True... | [
"0.6937712",
"0.66080606",
"0.65842813",
"0.6570473",
"0.6529023",
"0.65285176",
"0.65189445",
"0.6494391",
"0.64555836",
"0.6421015",
"0.6328846",
"0.63044935",
"0.62987053",
"0.62668496",
"0.62601346",
"0.624385",
"0.6186396",
"0.6117331",
"0.6102974",
"0.60977507",
"0.6090... | 0.7032321 | 0 |
Petty prints using custom pprint class, formatting unicode characters | def pprint(self):
PrettyPrintUnicode().pprint(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pprint(self):\n return pformat(repr(self))",
"def my_pprint(obj, intend = 0):\n if isinstance(obj, dict):\n for key, value in obj.items():\n print(intend*\" \"+str(key)+\" : \")\n my_pprint(value, intend = intend + 4)\n print()\n elif isinstance(obj, list):\n ... | [
"0.66020364",
"0.6575941",
"0.65425223",
"0.6515464",
"0.6514521",
"0.6511368",
"0.64873034",
"0.64807445",
"0.6480072",
"0.63610697",
"0.6347487",
"0.62914324",
"0.62842274",
"0.62714124",
"0.62701565",
"0.6250059",
"0.6238075",
"0.6182242",
"0.6147328",
"0.6147328",
"0.6144... | 0.7337591 | 0 |
Perform rankbased inverse normal transform to a numeric Pandas series | def inverse_rank_norm(values):
#values = pd.Series([5, 7, 2, 1, 1])
quantiles = (values.rank()-0.5)/(len(values))
return ss.norm.ppf(quantiles) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_normal_transform(M):\n R = stats.mstats.rankdata(M, axis=1) # ties are averaged\n if isinstance(M, pd.DataFrame):\n Q = pd.DataFrame(stats.norm.ppf(R/(M.shape[1]+1)), index=M.index, columns=M.columns)\n else:\n Q = stats.norm.ppf(R/(M.shape[1]+1))\n return Q",
"def inverse_... | [
"0.6803572",
"0.6684169",
"0.6475664",
"0.6429937",
"0.64156497",
"0.6389941",
"0.63249725",
"0.6258048",
"0.6213609",
"0.6208294",
"0.61738485",
"0.6168609",
"0.60991716",
"0.6039526",
"0.6039526",
"0.6025522",
"0.6025522",
"0.6025522",
"0.59954333",
"0.5985897",
"0.59778994... | 0.7054932 | 0 |
Log `engine.state.metrics` with given `engine` and `tag`. | def log_metrics(engine: Engine, tag: str) -> None:
metrics_format = "{0} [{1}/{2}]: {3}".format(
tag, engine.state.epoch, engine.state.iteration, engine.state.metrics
)
engine.logger.info(metrics_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_metrics(metrics, step=None):\n mlflow.log_metrics(metrics, step=step)",
"def log_metric(self, name, val, step):\n raise NotImplementedError",
"def log_metric(self, name, val):\n raise NotImplementedError",
"def log_metrics(self, metrics, step=None, epoch=None, prefix=None):\n ... | [
"0.6240059",
"0.61237293",
"0.604995",
"0.6007885",
"0.5990969",
"0.58237666",
"0.5668803",
"0.5643581",
"0.5567732",
"0.5474371",
"0.53737664",
"0.5357524",
"0.5344699",
"0.5297509",
"0.52917963",
"0.52677846",
"0.52462256",
"0.52296853",
"0.520308",
"0.5174085",
"0.5163968"... | 0.86053985 | 0 |
Setup logger with `ignite.utils.setup_logger()`. | def setup_logging(config: Any) -> Logger:
green = "\033[32m"
reset = "\033[0m"
logger = setup_logger(
name=f"{green}[ignite]{reset}",
level=logging.DEBUG if config.debug else logging.INFO,
format="%(name)s: %(message)s",
filepath=config.output_dir / "training-info.log",
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logging():\n log.setup('keystone')",
"def setup_log(self):\n self.logger, _ = get_logger(\"datatransform\")",
"def setup_logger(self):\n setup_logger(logger, 'mayavi.log', mode=self.log_mode)",
"def setup_logger():\n root = logging.getLogger()\n root.setLevel(LOGGING_LEVEL)\n... | [
"0.791117",
"0.72085685",
"0.71950054",
"0.71890855",
"0.7155964",
"0.71218204",
"0.70645064",
"0.7047346",
"0.7046134",
"0.70337045",
"0.70297927",
"0.7022614",
"0.7021542",
"0.70177054",
"0.7013548",
"0.7011018",
"0.7008532",
"0.70057917",
"0.69638646",
"0.6959906",
"0.6954... | 0.7727292 | 1 |
If something is not a list already make it one, otherwise simply return something | def aslist(something):
return something if isinstance(something, list) else [something] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listify(value):\n if isinstance(value, list):\n return value\n else:\n return [value]",
"def listify(arg):\n if isinstance(arg, list):\n return arg\n else:\n return [arg]",
"def listify(supposed_lst:object=None):\n\tif (supposed_lst is not None):\n\t\tif (not isinsta... | [
"0.7072959",
"0.70661867",
"0.7043395",
"0.68962115",
"0.6856602",
"0.65573055",
"0.6549759",
"0.64554024",
"0.64472896",
"0.6420959",
"0.6384629",
"0.63443786",
"0.6334466",
"0.6304437",
"0.6287558",
"0.62678397",
"0.62678397",
"0.62678397",
"0.62564147",
"0.6251007",
"0.623... | 0.7201694 | 0 |
Convert a schema name like DISCOVER_SCHEMA_ROWSETS into a method name like getSchemaRowsets. 1. split into parts by _ | def schemaNameToMethodName(schemaName):
parts = schemaName.split("_")
def replace(what):
if what == "DBSCHEMA": return "DBSchema"
elif what == "MDSCHEMA": return "MDSchema"
elif what == "DISCOVER": return ""
return what.lower().capitalize()
return "get" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolver(schema):\n name = schema.__name__\n if name.endswith(\"Schema\"):\n return name[:-6] or name\n return name",
"def split_fqn(fqn_name):\n try:\n schema, table = fqn_name.split('.')\n except Exception as e:\n logger.error(\"Failed to split name %s into schema and ta... | [
"0.6052163",
"0.5584583",
"0.5581645",
"0.5529912",
"0.5454102",
"0.54007065",
"0.5299308",
"0.52945566",
"0.5244302",
"0.5170896",
"0.513098",
"0.5112123",
"0.50779843",
"0.5071181",
"0.5046438",
"0.5041104",
"0.50338566",
"0.5025325",
"0.49718887",
"0.49697247",
"0.49661854... | 0.7809508 | 0 |
Perform linting of the source code | def lint(ctx):
print('Running linting...')
ctx.run('pylint metrics') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lint():\n toolkit.lint(exclude=[\"__init__.py\"])",
"def lint(self):\n raise NotImplementedError()",
"def lint(session):\n session.install(\"pre-commit\")\n session.run(\"pre-commit\", \"run\", \"--all-files\")",
"def lint():\n load_env_vars('dev')\n from tools.static_code_analysis ... | [
"0.78138644",
"0.7574533",
"0.75095797",
"0.73593503",
"0.7336891",
"0.73338914",
"0.7326553",
"0.7140035",
"0.71232647",
"0.7041895",
"0.7038825",
"0.69987965",
"0.6986155",
"0.68960625",
"0.6859346",
"0.6848015",
"0.68006235",
"0.6749812",
"0.6739455",
"0.66621584",
"0.6630... | 0.7750827 | 1 |
Print the build metrics | def metrics(_):
collector = BuildsCollector()
build_metrics, headers = collector.get_metrics_table()
print(tabulate(build_metrics, headers=headers)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_metrics(result):\n logging.log(LOG_LEVEL_OUTPUT_INFO,\n '------------------------------------------------')\n logging.log(LOG_LEVEL_OUTPUT_INFO, ' KEY METRICS: ')\n logging.log(LOG_LEVEL_OUTPUT_INFO,\n '------------------------------------------------')\n logging.log(LOG_LEV... | [
"0.66079473",
"0.6216928",
"0.61909086",
"0.6101186",
"0.6092159",
"0.60817313",
"0.60801643",
"0.60618484",
"0.6012806",
"0.60062146",
"0.5972601",
"0.59628373",
"0.590147",
"0.5889636",
"0.5878473",
"0.5874653",
"0.5874362",
"0.58222145",
"0.5803442",
"0.57945627",
"0.57895... | 0.7843801 | 0 |
A hypothesis decorator to return a list of strategies | def strategy_lists(
draw,
strategies=axl.short_run_time_strategies,
min_size=1,
max_size=len(axl.short_run_time_strategies),
):
strategies = draw(
lists(sampled_from(strategies), min_size=min_size, max_size=max_size)
)
return strategies | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate():\n strategies = []\n\n # Add RFind strategies (2 meta-strategies P0 and P'0 for each)\n limits=[50, 20, 10]\n sources = ['his', 'our', 'dna']\n for limit in limits:\n for source in sources:\n strategies.extend(\n generate_meta_strategy_pair(\n RFind... | [
"0.6420899",
"0.64178324",
"0.6409105",
"0.6397985",
"0.63713485",
"0.6353364",
"0.6328641",
"0.63274527",
"0.63161695",
"0.6315755",
"0.6308805",
"0.63070786",
"0.6305257",
"0.62779176",
"0.62447643",
"0.62254936",
"0.62023383",
"0.6199375",
"0.6199375",
"0.61949295",
"0.616... | 0.6516299 | 0 |
A hypothesis decorator to return a probabilistic ending spatial tournament. | def prob_end_spatial_tournaments(
draw,
strategies=axl.short_run_time_strategies,
min_size=1,
max_size=10,
min_prob_end=0,
max_prob_end=1,
min_noise=0,
max_noise=1,
min_repetitions=1,
max_repetitions=20,
):
strategies = draw(
strategy_lists(
strategies=str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prob_end_tournaments(\n draw,\n strategies=axl.short_run_time_strategies,\n min_size=1,\n max_size=10,\n min_prob_end=0,\n max_prob_end=1,\n min_noise=0,\n max_noise=1,\n min_repetitions=1,\n max_repetitions=20,\n seed=None,\n):\n strategies = draw(\n strategy_lists(\... | [
"0.5512576",
"0.5420276",
"0.51442975",
"0.51415604",
"0.51293325",
"0.5061573",
"0.5054858",
"0.5026072",
"0.49884802",
"0.4959208",
"0.49386254",
"0.49306422",
"0.4901441",
"0.4869079",
"0.48479176",
"0.4831503",
"0.48310497",
"0.4826288",
"0.48154637",
"0.47833726",
"0.478... | 0.5754266 | 0 |
Reads the todo file and returns a list of Todos. The "id" of each todo refers to the zeroindexed line number of that todo. | def read_file(filename) -> List[Todo]:
with pathlib.Path(filename).expanduser().open('r') as fp:
return [Todo(_id, line) for _id, line in enumerate(fp)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_todo_file(self):\n\n todo = []\n in_progress = []\n done = []\n if os.path.exists('TODO.txt'):\n todo_fp = open('TODO.txt', 'r')\n state = 0\n line = todo_fp.readline()\n while line:\n line = line.strip()\n ... | [
"0.7641383",
"0.700214",
"0.69354475",
"0.66047204",
"0.6499556",
"0.6346317",
"0.6282412",
"0.6131096",
"0.6125421",
"0.6125067",
"0.60897225",
"0.60823214",
"0.59966564",
"0.5938333",
"0.5918086",
"0.5897514",
"0.5896833",
"0.58917236",
"0.58791345",
"0.5829496",
"0.5820293... | 0.7736592 | 0 |
Execute a streaming pull and process alerts through the `callback`. The streaming pull happens in a background thread. A `queue.Queue` is used to communicate between threads and enforce the stopping condition(s). | def stream_alerts(
self, user_filter=None, user_callback=None, **user_kwargs
):
# callback doesn't accept kwargs. set attribute instead.
kwargs = self._add_default_kwargs(**user_kwargs)
self.callback_kwargs = {
"user_filter": user_filter,
"user_callback": user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poll(self):\n msgs = self._read()\n\n if msgs and self.callback:\n for msg in msgs:\n self.callback(msg)",
"def run(self) -> None:\n\n # Track the last timestamp we see. When we fetch_stream() again on the\n # next iteration, we'll start from that timest... | [
"0.61305285",
"0.5998114",
"0.5995203",
"0.59786123",
"0.5935737",
"0.58937454",
"0.5872686",
"0.5779626",
"0.5744613",
"0.57423276",
"0.5741257",
"0.5733788",
"0.5603486",
"0.5582575",
"0.5575072",
"0.5562684",
"0.5542272",
"0.5539083",
"0.55306304",
"0.55262667",
"0.5523324... | 0.6254242 | 0 |
Shutdown the streaming pull in the background thread gracefully. | def _stop(self):
self.streaming_pull_future.cancel() # Trigger the shutdown.
self.streaming_pull_future.result() # Block until the shutdown is complete. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutdown(self):\n self.socket_thread.stop()",
"def shutdown(self):\n if not self.stop_event.is_set():\n self.stop_event.set()\n\n if self.pusher_thread:\n self.pusher_thread.join()",
"def stop(self):\n self.stream.stop()\n self.running = False",
"d... | [
"0.73357934",
"0.7293376",
"0.71127105",
"0.7077128",
"0.7065803",
"0.6975906",
"0.6962216",
"0.69553834",
"0.6936233",
"0.69217414",
"0.6897765",
"0.6868899",
"0.6749683",
"0.67419726",
"0.6732005",
"0.67256993",
"0.6673746",
"0.6632645",
"0.66272914",
"0.6618546",
"0.659153... | 0.79213 | 0 |
Process a single alert; run user filter; save alert; acknowledge Pub/Sub msg. Used as the callback for the streaming pull. | def callback(self, message):
kwargs = self.callback_kwargs
if kwargs['return_msg']:
self._callback_return_full_message(message)
return
# unpack
try:
alert_dict, metadata_dict = self._unpack(message)
except Exception as e:
self._lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stream_alerts(\n self, user_filter=None, user_callback=None, **user_kwargs\n ):\n # callback doesn't accept kwargs. set attribute instead.\n kwargs = self._add_default_kwargs(**user_kwargs)\n self.callback_kwargs = {\n \"user_filter\": user_filter,\n \"user_... | [
"0.6618315",
"0.5814011",
"0.5618752",
"0.5581755",
"0.53606147",
"0.52934784",
"0.52241296",
"0.5218121",
"0.5183818",
"0.5162959",
"0.5151981",
"0.5137493",
"0.5113881",
"0.5081569",
"0.50672615",
"0.5028629",
"0.50246",
"0.5020632",
"0.50062454",
"0.5003933",
"0.50038975",... | 0.6836282 | 0 |
Save the alert to a database. | def save_alert(self, alert):
self.database_list.append(alert) # fake database for demo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\n self.db.commit()",
"def save(self):\n self.__db.commit()",
"def save_db(self) -> None:",
"def persist_alert(self, alert_type):\n session = db_session()\n\n alert = models.Alert()\n alert.alert_type = alert_type\n alert.entity_id = self.config.entity... | [
"0.70432657",
"0.70321536",
"0.6991143",
"0.6970373",
"0.6906388",
"0.6876018",
"0.68100935",
"0.674678",
"0.67295766",
"0.67234564",
"0.66731614",
"0.661583",
"0.660977",
"0.660977",
"0.660977",
"0.660977",
"0.660977",
"0.660977",
"0.660977",
"0.660977",
"0.6566645",
"0.65... | 0.84834534 | 0 |
Try to create the subscription. | def _create_subscription(self):
try:
self.client.create_subscription(
name=self.subscription_path, topic=self.topic_path
)
except NotFound:
# suitable topic does not exist in the Pitt-Google project
raise ValueError(
(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_create(self):\n subscription = self.client().subscription(\n self.properties[self.QUEUE_NAME],\n subscriber=self.properties[self.SUBSCRIBER],\n ttl=self.properties[self.TTL],\n options=self.properties[self.OPTIONS]\n )\n self.resource_id_s... | [
"0.79522216",
"0.79236335",
"0.766891",
"0.7175027",
"0.7131221",
"0.7044523",
"0.696727",
"0.67897534",
"0.6780519",
"0.6774319",
"0.6662607",
"0.6634457",
"0.6628242",
"0.6611634",
"0.6575175",
"0.6550009",
"0.65446806",
"0.6515999",
"0.64871514",
"0.6451727",
"0.64171314",... | 0.8017699 | 0 |
Delete the subscription. This is provided for the user's convenience, but it is not necessary and is not automatically called. Storage of unacknowledged Pub/Sub messages does not result in fees. Unused subscriptions automatically expire; default is 31 days. | def delete_subscription(self):
try:
self.client.delete_subscription(subscription=self.subscription_path)
except NotFound:
pass
else:
self._log_and_print(f'Deleted subscription: {self.subscription_path}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_subscription(self, subscription_id):\n url = '{}/v2/subscriptions/{}'.format(self.url, subscription_id)\n print(url)\n r = requests.delete(url, headers=self.headers_v2)\n if r.status_code == 204:\n return 'success'\n return r.json()",
"def delete(self, org... | [
"0.68542045",
"0.66849315",
"0.6553755",
"0.6462307",
"0.6337273",
"0.6276553",
"0.62238497",
"0.60828495",
"0.6030626",
"0.6027652",
"0.599798",
"0.5763129",
"0.5689989",
"0.55739135",
"0.55646366",
"0.5527481",
"0.55102307",
"0.5483406",
"0.5458787",
"0.54338235",
"0.542660... | 0.7547199 | 0 |
Should return a list of title cased names, each name appears only once | def dedup_and_title_case_names(names):
return list(set(name.title() for name in names)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dedup_and_title_case_names(names):\n names1 =[]\n for n in names:\n if n.title() not in names1:\n names1.append(n.title())\n return names1\n # return [n.title() for n in names if n.title() not in names1]\n pass",
"def dedup_and_title_case_names(names):\n my_names = set(names... | [
"0.82403964",
"0.8028632",
"0.7952886",
"0.7666392",
"0.71184033",
"0.6779802",
"0.67301315",
"0.6570068",
"0.6475094",
"0.642649",
"0.6370992",
"0.6320935",
"0.6289419",
"0.62875795",
"0.62639284",
"0.6213404",
"0.6199757",
"0.61732936",
"0.61606234",
"0.61318856",
"0.612566... | 0.8039771 | 1 |
Returns names list sorted desc by surname | def sort_by_surname_desc(names):
names = dedup_and_title_case_names(names)
return sorted(names, key=lambda name: name.split(' ')[-1], reverse=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_surname_desc(names):\n names = dedup_and_title_case_names(names)\n split_names = [name.split(' ') for name in names]\n return [\" \".join(x) for x in (sorted(split_names, key = lambda x: x[1], reverse=True))]",
"def sort_by_surname_desc(names):\n names = dedup_and_title_case_names(names)\... | [
"0.85138637",
"0.8494503",
"0.8393841",
"0.8254867",
"0.7045284",
"0.68591815",
"0.68037444",
"0.67713994",
"0.6424156",
"0.64197683",
"0.6416577",
"0.63984555",
"0.63561875",
"0.63063484",
"0.63006693",
"0.62879753",
"0.62536865",
"0.6237204",
"0.6220415",
"0.61567885",
"0.6... | 0.8625484 | 0 |
Returns the shortest first name (str). You can assume there is only one shortest name. | def shortest_first_name(names):
names = dedup_and_title_case_names(names)
return sorted([name.split()[0] for name in names], key=len)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_first_name(names):\n names = dedup_and_title_case_names(names)\n split_names = [name.split(' ') for name in names]\n first_name = [first for first, last in split_names]\n shortest = first_name[0]\n for name in first_name:\n if len(name) < len(shortest):\n shortest = na... | [
"0.8495962",
"0.8405887",
"0.8365317",
"0.81789523",
"0.78514916",
"0.7568302",
"0.7427178",
"0.7414167",
"0.741108",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.72852665",
"0.7... | 0.84295845 | 1 |
gname points to a graph stored (pickled) on disk. | def load_graph( gname ):
return NX.read_gpickle( gname ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_graph(self, path):\n if path.split('.')[-1]=='gexf':\n nx.write_gexf(self.graph, path)\n else:\n nx.write_gpickle(self.graph, path)",
"def load_graph(graphname,path='./data/',mname='A'):\n\n\tdata=sio.loadmat(path+graphname)\n\treturn data[mname]",
"def load_graph(s... | [
"0.6715936",
"0.63711464",
"0.63242835",
"0.6148255",
"0.6132365",
"0.6122497",
"0.6104714",
"0.5913933",
"0.5835921",
"0.57587785",
"0.5712477",
"0.5708755",
"0.56999767",
"0.5680423",
"0.5680423",
"0.5680423",
"0.5680423",
"0.5676791",
"0.565727",
"0.56568235",
"0.5630545",... | 0.7118238 | 0 |
updates min, max, total with the given value | def update(self, value):
if value < self.min:
self.min = value
if value > self.max:
self.max = value
self.total += value
self.instances += 1
self.values.append(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_values(self):\n # have to reset params to 0 when recalculating\n self.total_weight = self.total_price = self.total_value = self.total_fitness = 0\n for index, value in enumerate(self.item_stats):\n if value == 1:\n self.total_weight += self.items[index].wei... | [
"0.6380112",
"0.615847",
"0.60419434",
"0.6009748",
"0.59425825",
"0.5924577",
"0.5918863",
"0.5868015",
"0.5866125",
"0.58211535",
"0.5773228",
"0.5773018",
"0.567507",
"0.56311446",
"0.5615232",
"0.5568014",
"0.55477995",
"0.5547022",
"0.5535163",
"0.55029064",
"0.54945266"... | 0.71427345 | 0 |
Test that causal convolutions only operate on leftward inputs | def test_causal_convolution(conv1d_placeholder, spatial_onehot, output_size, width):
conv_layer = Convolution((3, output_size), lambda x: 1, padding="causal")
output = conv_layer(conv1d_placeholder)
output_width = output.axes.find_by_name("W")[0].length
assert output_width == width, "Causal convolution ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_conv_layer_forward():\n #Setup layer and inputs\n conv = BinConv2d(2,1, [2,2],stride=1, bias=False)\n conv.weight.data.copy_(torch.Tensor([ [0.5,- 0.5] , [-0.5, 0.5],\\\n [1,-1] , [0.5, 0.5],]).view(1,2,2,2))\n\n\n inputs = torch.Tensor([ [1.1,2.1],[... | [
"0.59120655",
"0.5800435",
"0.5779887",
"0.5771272",
"0.5761186",
"0.57230026",
"0.56933904",
"0.5679137",
"0.5663168",
"0.5662883",
"0.5660113",
"0.5638398",
"0.56129354",
"0.56058097",
"0.56007946",
"0.55871105",
"0.5583951",
"0.55634624",
"0.5547827",
"0.55430686",
"0.5529... | 0.64589345 | 0 |
Test that axes into a conv are the same as axes out | def test_axis_preservation(conv1d_placeholder, output_size):
conv_layer = Convolution((3, output_size), lambda x: 1)
output = conv_layer(conv1d_placeholder)
assert output.axes == conv1d_placeholder.axes, ("Output axes are not the same as input axes: "
"{} ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_axis_introduction(conv1d_no_channel_axis, output_size, channel_axis):\n conv_layer = Convolution((3, output_size), lambda x: 1)\n output = conv_layer(conv1d_no_channel_axis)\n t_axes = conv1d_no_channel_axis.axes + channel_axis\n assert output.axes.is_equal_set(t_axes), (\"Output axes ... | [
"0.70866376",
"0.7026903",
"0.6671873",
"0.63404804",
"0.6334404",
"0.6294378",
"0.6264213",
"0.62374765",
"0.6234195",
"0.61577",
"0.6156835",
"0.6155365",
"0.61525667",
"0.60497",
"0.60024923",
"0.6000393",
"0.59903127",
"0.5989085",
"0.5983982",
"0.59728414",
"0.59622973",... | 0.7441477 | 0 |
Test that a channel axis is added when it doesn't exist in the input | def test_channel_axis_introduction(conv1d_no_channel_axis, output_size, channel_axis):
conv_layer = Convolution((3, output_size), lambda x: 1)
output = conv_layer(conv1d_no_channel_axis)
t_axes = conv1d_no_channel_axis.axes + channel_axis
assert output.axes.is_equal_set(t_axes), ("Output axes are not in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_alternate_channel_axes(conv1d_placeholder, output_size, channel_axis):\n channel_axis.name = \"channel\"\n assert len(conv1d_placeholder.axes.find_by_name(\"channel\")) == 1\n\n conv_layer = Convolution((3, output_size), lambda x: 1)\n with pytest.raises(IncompatibleAxesError):\n conv_l... | [
"0.68041444",
"0.5978892",
"0.59068304",
"0.58510864",
"0.5820264",
"0.5708535",
"0.5601582",
"0.55839527",
"0.55391574",
"0.5538313",
"0.5525261",
"0.5506493",
"0.5473106",
"0.5469562",
"0.5443375",
"0.5383108",
"0.53624815",
"0.5343262",
"0.5339166",
"0.53092283",
"0.527701... | 0.71101326 | 0 |
Test that spatial axis names are modifiable | def test_alternate_spatial_axes(conv1d_placeholder, output_size, width_axis):
width_axis.name = "time"
assert len(conv1d_placeholder.axes.find_by_name("time")) == 1
conv_layer = Convolution((3, output_size), lambda x: 1)
with pytest.raises(IncompatibleAxesError):
conv_layer(conv1d_placeholder)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_bad_name(self):\n dim = Dimension(\"yolo\", \"uniform\", -3, 4, shape=(4, 4))\n with pytest.raises(TypeError):\n dim.name = 4",
"def setAxisName(name, axes='XYZ'):\n dislin.name(name, axes)",
"def test_saved_sgrid_attributes(self):\n u1_var = self.target.U1\n ... | [
"0.62136984",
"0.6049257",
"0.59505177",
"0.5885029",
"0.587727",
"0.58177626",
"0.57560587",
"0.5734578",
"0.5728373",
"0.5708425",
"0.5682878",
"0.5643425",
"0.56203425",
"0.5597272",
"0.55956787",
"0.55829436",
"0.55688053",
"0.55611026",
"0.55029243",
"0.54853517",
"0.548... | 0.619606 | 1 |
Test that channel axis names are modifiable | def test_alternate_channel_axes(conv1d_placeholder, output_size, channel_axis):
channel_axis.name = "channel"
assert len(conv1d_placeholder.axes.find_by_name("channel")) == 1
conv_layer = Convolution((3, output_size), lambda x: 1)
with pytest.raises(IncompatibleAxesError):
conv_layer(conv1d_pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_axis_introduction(conv1d_no_channel_axis, output_size, channel_axis):\n conv_layer = Convolution((3, output_size), lambda x: 1)\n output = conv_layer(conv1d_no_channel_axis)\n t_axes = conv1d_no_channel_axis.axes + channel_axis\n assert output.axes.is_equal_set(t_axes), (\"Output axes ... | [
"0.6249024",
"0.592017",
"0.58970207",
"0.5892294",
"0.58472556",
"0.5733948",
"0.57240987",
"0.567717",
"0.5633438",
"0.5605331",
"0.55340713",
"0.5515224",
"0.5501755",
"0.5449305",
"0.5431168",
"0.5381191",
"0.53764176",
"0.5358835",
"0.5335394",
"0.5330941",
"0.5266454",
... | 0.6457107 | 0 |
Test that the dilated convolution layer output matches expected. This test compares the maximum output value to an expected max output value. The expected value is computed based on the dilation parameter. The test also checks that the output size matches the expected size based on the dilaton parameter value. | def test_dilated_conv(dilation):
image_size = 3
batch_size = 1
init_val = 0.1
conv_size = 3
pad = 3
N_filters = 1
image_channels = 3
model = Sequential([Convolution((conv_size, conv_size, N_filters),
filter_init=ConstantInit(val=init_val),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _VerifyValues(\n self,\n input_sizes=None,\n filter_sizes=None,\n strides=None,\n dilations=None,\n padding=None,\n data_format_src=\"NHWC\",\n data_format_dst=\"NHWC\",\n expected=None,\n ):\n\n total_size_1 = np.prod(input_sizes)\n ... | [
"0.64663506",
"0.6339015",
"0.6257454",
"0.61735374",
"0.6152628",
"0.61100185",
"0.60942584",
"0.60613877",
"0.6036121",
"0.5997487",
"0.591609",
"0.59005904",
"0.58983564",
"0.5894166",
"0.58659226",
"0.5855777",
"0.583677",
"0.5803536",
"0.577784",
"0.5746447",
"0.57333267... | 0.78776544 | 0 |
basic test of deconv fprop. ngraph/tests/test_conv.py tests ng.deconvolution bprop | def test_deconv():
# filter params
R, S = 5, 5
fshape = (R, S, 1)
strides = 2
filter_val_nz = np.arange(1, R * S + 1).reshape(R, S)
filter_val = np.zeros(fshape)
filter_val[:, :, 0] = filter_val_nz
deconv = Deconvolution(fshape,
filter_init=ConstantInit(filte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_conv_inverts_deconv(transformer_factory, input_size, filter_size, padding, stride):\n\n # convolutions whose output size are not an even multiple of stride cannot be exactly inverted\n a = (input_size + sum(padding) - filter_size) % stride\n conv_output = utils.conv_output_dim(input_size, filter_... | [
"0.650111",
"0.6170416",
"0.6147471",
"0.60740656",
"0.5956182",
"0.5948169",
"0.5885975",
"0.5847327",
"0.58391535",
"0.58207595",
"0.5816805",
"0.58126575",
"0.57973516",
"0.5785438",
"0.57493794",
"0.57127476",
"0.5711217",
"0.56995",
"0.569624",
"0.5642262",
"0.56382316",... | 0.6862476 | 0 |
Test that conv and deconv are inverse operations given the same parameters | def test_conv_inverts_deconv(transformer_factory, input_size, filter_size, padding, stride):
# convolutions whose output size are not an even multiple of stride cannot be exactly inverted
a = (input_size + sum(padding) - filter_size) % stride
conv_output = utils.conv_output_dim(input_size, filter_size, pad... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inverse_transform(self):",
"def test__inverse_transform_continuous(self):",
"def test_inverse_c(self):\n for q in self.all:\n self.assertTrue((q * q.inverse()).almost_equal(q.inverse()*q))",
"def test_functional_inverse(self, dim):\n M = np.random.rand(dim, dim)\n ass... | [
"0.73368603",
"0.71729094",
"0.68075156",
"0.66037315",
"0.6594968",
"0.64753395",
"0.6474013",
"0.6347338",
"0.6347338",
"0.62833875",
"0.62619966",
"0.61940867",
"0.6166104",
"0.6166104",
"0.61169124",
"0.6046706",
"0.6046706",
"0.6030973",
"0.5981622",
"0.5976751",
"0.5969... | 0.7238191 | 1 |
Create a new receiver object. | def __new__(cls, rtype, cluster_id=None, action=None, **kwargs):
if rtype == consts.RECEIVER_WEBHOOK:
from senlin.engine.receivers import webhook
ReceiverClass = webhook.Webhook
elif rtype == consts.RECEIVER_MESSAGE:
from senlin.engine.receivers import message
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_receiver_no_id(source_id=None, **kwargs):\n return acquire.Receiver(source_id=None, **kwargs)",
"def _from_object(cls, receiver):\n kwargs = {\n 'id': receiver.id,\n 'name': receiver.name,\n 'user': receiver.user,\n 'project': receiver.project,\... | [
"0.70990366",
"0.67225856",
"0.66829747",
"0.65813774",
"0.63713026",
"0.62152827",
"0.61773187",
"0.5897912",
"0.58591956",
"0.58540297",
"0.5778976",
"0.5712958",
"0.5694952",
"0.56846017",
"0.56715405",
"0.56713593",
"0.5661827",
"0.56467944",
"0.56467944",
"0.5628301",
"0... | 0.7392701 | 0 |
Store the receiver in database and return its ID. | def store(self, context, update=False):
timestamp = timeutils.utcnow(True)
self.created_at = timeutils.utcnow(True)
values = {
'id': self.id,
'name': self.name,
'type': self.type,
'user': self.user,
'project': self.project,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_receivers_id(self):\n return self.__receivers_id",
"def insert(self):\n item = self.create()\n return item.id",
"def create(cls, sender, recipient, body, timestamp=None):\n if timestamp is None:\n timestamp = datetime.datetime.utcnow()\n msg = cls(sender,... | [
"0.6423932",
"0.5876769",
"0.5797933",
"0.5710716",
"0.5706996",
"0.56506854",
"0.5634671",
"0.5573839",
"0.5572288",
"0.553507",
"0.5532543",
"0.5480858",
"0.5480858",
"0.5480858",
"0.54778296",
"0.5473655",
"0.5473655",
"0.54736364",
"0.5444757",
"0.5444757",
"0.54426414",
... | 0.69515216 | 0 |
Construct a receiver from receiver object. | def _from_object(cls, receiver):
kwargs = {
'id': receiver.id,
'name': receiver.name,
'user': receiver.user,
'project': receiver.project,
'domain': receiver.domain,
'created_at': receiver.created_at,
'updated_at': receiver.updat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_receiver_no_id(source_id=None, **kwargs):\n return acquire.Receiver(source_id=None, **kwargs)",
"def __new__(cls, rtype, cluster_id=None, action=None, **kwargs):\n if rtype == consts.RECEIVER_WEBHOOK:\n from senlin.engine.receivers import webhook\n ReceiverClass = we... | [
"0.71256065",
"0.6681739",
"0.6624353",
"0.61288947",
"0.5840496",
"0.570091",
"0.5698267",
"0.5570594",
"0.55004007",
"0.5460564",
"0.5394144",
"0.53751534",
"0.5333654",
"0.53211445",
"0.5306747",
"0.53045243",
"0.53045243",
"0.52950823",
"0.52561927",
"0.5206004",
"0.51457... | 0.747322 | 0 |
Build connection params for specific user and project. | def _build_conn_params(self, user, project):
service_creds = senlin_context.get_service_credentials()
params = {
'username': service_creds.get('username'),
'password': service_creds.get('password'),
'auth_url': service_creds.get('auth_url'),
'user_domain_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_connection_params(self, host, port, db):\r\n\r\n kwargs = {\r\n \"db\": db,\r\n \"parser_class\": self.get_parser_cls(),\r\n \"password\": self.options.get('PASSWORD', None),\r\n }\r\n\r\n if host == \"unix\":\r\n kwargs.update({'path': port... | [
"0.6681274",
"0.6415917",
"0.64074725",
"0.6044565",
"0.59719354",
"0.5750442",
"0.57281107",
"0.5702612",
"0.56912225",
"0.5690372",
"0.5643423",
"0.56048477",
"0.5570526",
"0.5529019",
"0.55210865",
"0.551333",
"0.5467593",
"0.54630786",
"0.5452627",
"0.54466474",
"0.544164... | 0.76817983 | 0 |
Registers an obj to this registry When locked, a RuntimeError is raised When an object with the name exists, and overwrite_existing is False, a RuntimeError is raised When the object does not extend IRegistryContent, a ValueError is raised When the object NAMEattribute is not set, a ValueError is raised | def register(
self,
obj: typing.Union[IRegistryContent, typing.Type[IRegistryContent]],
overwrite_existing=True,
):
if self.locked:
raise RuntimeError(f"registry {self.name} is locked!")
if not (
isinstance(obj, IRegistryContent)
if not s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(self, obj, name=None):\n if not name:\n name = obj.__name__\n if name in self._registry:\n raise KeyError(\"Name '%s' has been registered in '%s'!\" %\n (name, self._name))\n\n # logging.vlog(1, \"Registering %s (%s) in %s.\", name, obj, self._name)\n self._re... | [
"0.7712725",
"0.71682245",
"0.70870656",
"0.69742715",
"0.6501139",
"0.642957",
"0.63914746",
"0.6340303",
"0.6338703",
"0.63272023",
"0.62428355",
"0.6232373",
"0.61719275",
"0.61291784",
"0.6081065",
"0.6008799",
"0.5974267",
"0.59550905",
"0.59465",
"0.5944888",
"0.5938793... | 0.8434839 | 0 |
Converts individual C01 file to TIF using bfconvert. | def cellomics2tiff((file_in,dir_out)):
file_out = cutils.getTifPath(file_in,dir_out)
# don't repeat conversion if converted file exists
# and is newer than the original data
if os.path.isfile(file_out) \
and os.stat(file_out).st_mtime > os.stat(file_in).st_mtime:
return
if plat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asc_to_gtif(i_dir):\n\n # Set search for all files with suffix in specified folder\n q = join(i_dir, \"*.asc\")\n # List of all TIF files\n asc_fps = glob.glob(q)\n\n # Loop over all files\n for item in asc_fps:\n # Open ASC file\n data = np.loadtxt(item, delimiter=\";\")\n\n ... | [
"0.58994037",
"0.5708016",
"0.5645735",
"0.5637907",
"0.5601799",
"0.5523944",
"0.54352075",
"0.5245638",
"0.52050906",
"0.52050906",
"0.5131295",
"0.51254326",
"0.509316",
"0.50552475",
"0.5052939",
"0.5020321",
"0.49904832",
"0.4942433",
"0.49388912",
"0.49288186",
"0.49224... | 0.6668941 | 0 |
Constructs a shortened representation of a PdObject. | def short_repr(obj: PdObject, length_guide: int = 8) -> str:
if isinstance(obj, list):
lower_length_guide = (length_guide + 1) // 2
if len(obj) > 2 * length_guide:
return "[{}, ({} more), {}]".format(
", ".join(short_repr(e, lower_length_guide) for e in obj[:length_gu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pformat(object):\r\n return PrettyPrinter().pformat(object)",
"def stringReco(obj):\n name = obj.get_name()\n name = obj._pid if (name is None) else name\n return (\"pdg: \" + name + \" E: \" + str(obj._E)\n + \" px: \" + str(obj._px) + \" py: \" + str(obj._py)\n + \" pz: \"... | [
"0.5644744",
"0.5611544",
"0.5591873",
"0.54736",
"0.54563993",
"0.53513646",
"0.53206956",
"0.53024477",
"0.52644145",
"0.5253599",
"0.5235866",
"0.52308536",
"0.5215566",
"0.52139914",
"0.5204089",
"0.51857984",
"0.5153454",
"0.5145673",
"0.51341456",
"0.5121201",
"0.511272... | 0.62185085 | 0 |
Return the count, sum, and sum of squares, deeply accumulated over the object. | def pd_deep_stats(obj: PdObject) -> Tuple[int, Union[int, float, complex], Union[int, float, complex]]:
if isinstance(obj, Block):
raise TypeError('Cannot deeply accumulate stats over block ' +
repr(obj))
if isinstance(obj, (Char, int, float, complex)):
v = num.numerify(obj)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_fun(obj):\n list_memory_sum = 0 # used to calculate total memory occupied by list elements\n for item in obj:\n if type(item) != dict:\n list_memory_sum = list_memory_sum + norm_fun(item)\n else:\n list_memory_sum = list_memory_sum + dict_fun(item)\n return li... | [
"0.6165658",
"0.6074642",
"0.5960235",
"0.59523267",
"0.5946558",
"0.5885655",
"0.58521736",
"0.57811224",
"0.57755905",
"0.5774179",
"0.5719372",
"0.5719372",
"0.5719372",
"0.5719372",
"0.566922",
"0.56002814",
"0.559825",
"0.5564518",
"0.5548685",
"0.5547149",
"0.55294913",... | 0.652207 | 0 |
Calculate and return the acceptance rate of the proposal. Returns | def get_acceptance(self):
return self.count_accepted / self.count_proposed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acceptance_rate(self):\n total = float(self.accepted + self.rejected)\n return self.accepted / total",
"def acceptance_fraction(self):\n return float(self._accepted / self.num_iterations)",
"def acceptance_fraction(self):\n return self.sampler.acceptance_fraction",
"def accept... | [
"0.8237646",
"0.7138192",
"0.71306014",
"0.69210577",
"0.6664414",
"0.6460886",
"0.62920713",
"0.6223292",
"0.6203049",
"0.6135156",
"0.6112492",
"0.5974629",
"0.5866377",
"0.5857397",
"0.575626",
"0.5755724",
"0.5665877",
"0.5657661",
"0.5641951",
"0.5625141",
"0.56085306",
... | 0.7540025 | 1 |
Calculate and return the illegal proposal rate of this proposal. (Proposing values outside the support of the parameter space e.g covariances < 0) Returns | def get_illegal(self):
return self.count_illegal / self.count_proposed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def penalty(self):\n assert len(self.weights) == len(self.means), \"Dimensions!\"\n out = np.exp(self.data['riskfree'] * self.data['maturity'])\n for weight, mean in zip(self.weights, self.means):\n out -= weight * np.exp(mean * self.data['maturity'])\n return (out**2).mean()... | [
"0.61560255",
"0.61219674",
"0.60336506",
"0.59619415",
"0.5867981",
"0.5866423",
"0.5817501",
"0.58053184",
"0.5801318",
"0.5792975",
"0.57858485",
"0.5781058",
"0.57493556",
"0.5713597",
"0.5710124",
"0.5701755",
"0.5694844",
"0.5671048",
"0.56675017",
"0.56662416",
"0.5652... | 0.6779935 | 0 |
Propose a new set of gmm parameters. Calls each proposal function one after another. | def propose(self, X, gmm, target, n_jobs=1):
new_gmm = gmm
for _ in xrange(self.propose_iterations):
if self.propose_mean is not None:
new_gmm = self.propose_mean.propose(X, new_gmm, target, n_jobs)
if self.propose_covars is not None:
new_gmm = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gpbandits(model, data, iters=10, kernel='se', cl=0.1, v=0.0, num_samples=500, verbose=True, best_model_log=False):\n\n num_dims = model.num_dims # number of hyperparameter dimensions\n\n # initial model evaluation\n points = model.encode()[np.newaxis,:]\n scores = np.array([model.train_test_cv(data... | [
"0.6288661",
"0.6088569",
"0.5891187",
"0.5777578",
"0.57462066",
"0.5741664",
"0.5720792",
"0.56987095",
"0.5695706",
"0.56813467",
"0.56514174",
"0.56160617",
"0.5612685",
"0.5612685",
"0.55843073",
"0.55429906",
"0.551866",
"0.5515407",
"0.5506441",
"0.55028486",
"0.548709... | 0.72234386 | 0 |
Sets the current node to the given data and assigns the node as a leaf node | def setData(self,data):
self.data=data
self.leaf=True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_data(self, node_data):\n\n self._node_data = node_data",
"def insert_node(self, data):\n\t\tif self.root is None:\n\t\t\tself.root = Node(data)\n\t\telse:\n\t\t\tcurrent_node = self.root\n\t\t\twhile current_node.next is not None:\n\t\t\t\tcurrent_node = current_node.next\n\t\t\tcurrent_node.next... | [
"0.70346564",
"0.6833494",
"0.6730778",
"0.6714654",
"0.66997105",
"0.65295124",
"0.63632095",
"0.63567376",
"0.6312098",
"0.6311947",
"0.63067853",
"0.62925583",
"0.6279957",
"0.62610626",
"0.625829",
"0.6252369",
"0.62375367",
"0.62080336",
"0.619256",
"0.6182957",
"0.61570... | 0.77952176 | 0 |
Sets the split attribute and split value to the current node | def setSplit(self,split):
self.split=split | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, attribute):\n if attribute not in self.attributes:\n raise KeyError('Attribute not present in node')\n \n self.split_attr = attribute\n \n # list() is used to make a copy of the list instead of pointing to the same list\n child_attributes = list(... | [
"0.7075071",
"0.6009954",
"0.59733343",
"0.59363616",
"0.5901629",
"0.5762262",
"0.5728003",
"0.55657804",
"0.55646825",
"0.5537182",
"0.551015",
"0.5344667",
"0.5314403",
"0.5285725",
"0.5230963",
"0.5223967",
"0.5204766",
"0.51964456",
"0.5193168",
"0.5177903",
"0.51655376"... | 0.69429463 | 1 |
Sets the given node to greater value of the current node | def setGreater(self,Node):
self.greater=Node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gt__(self, other: 'MaxNode') -> bool:\n if self.priority == other.priority:\n return self.value < other.value\n return self.priority < other.priority",
"def __gt__(self, other: 'MinNode') -> bool:\n if self.priority == other.priority:\n return self.value > other.v... | [
"0.6773434",
"0.67291725",
"0.6492923",
"0.6459286",
"0.64502484",
"0.6394402",
"0.6299902",
"0.6269281",
"0.6263838",
"0.623945",
"0.6228478",
"0.62032765",
"0.5915307",
"0.5913338",
"0.5901221",
"0.58720595",
"0.585558",
"0.58470595",
"0.5845788",
"0.58243996",
"0.58213806"... | 0.82811105 | 0 |
Sets the given node to lesser link of the current node | def setLesser(self,Node):
self.lesser=Node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linked_node(self, value):\n self._linked_node = value",
"def move_ant(self, node_to_visit):\n self.actual_node = node_to_visit\n self.remember_visited_node(node_to_visit)",
"def _switch_nodes(self, walker):\n walker.prev.next = walker.next \n walker.next = walker.... | [
"0.6257754",
"0.61906594",
"0.6186895",
"0.60881466",
"0.6046128",
"0.6041979",
"0.59969556",
"0.5941199",
"0.5892048",
"0.5874085",
"0.5778439",
"0.57763374",
"0.57636875",
"0.5724862",
"0.56946915",
"0.56720793",
"0.56540406",
"0.56457955",
"0.56115913",
"0.5611262",
"0.557... | 0.7686591 | 0 |
Converts the given csv file of a tree into list | def treeList(tree):
with open(tree) as fp:
line = fp.read()
nodesList = line.strip().split(',')
return nodesList | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_tree(csv_data: List[List[str]], order: List[str]) -> List[NodeList]:\n tree = []\n\n for row in csv_data:\n branch = generate_branch(row, order)\n if not branch:\n continue\n\n branch[0], root_result = level_exists(branch[0], tree)\n\n for i in range(len(br... | [
"0.71949446",
"0.6465496",
"0.6309598",
"0.62743926",
"0.6224334",
"0.6217084",
"0.62085897",
"0.6135008",
"0.61179715",
"0.61113775",
"0.6101576",
"0.6098895",
"0.6097796",
"0.6075376",
"0.6022257",
"0.5948729",
"0.5923453",
"0.5913197",
"0.5897696",
"0.5892974",
"0.58911306... | 0.72178835 | 0 |
It plots a graph of decision boundary for all the data samples in the classes | def decisionBoundary(root, figure, fileName):
stepValue = 0.001
classClassification = [1, 2, 3, 4]
colorClassification = ['b', 'g', 'r', 'm']
markerClassification = ['x', '+', '*', 'o']
classesList = ["Bolts", "Nuts", "Rings", "Scraps"]
decisionPlot = figure.add_subplot(111)
attributeValues,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotBoundary(self,X,Y,axis=None):\n if len(self.theta) != 3: raise ValueError('Data & model must be 2D');\n ax = X.min(0),X.max(0); ax = (ax[0][0],ax[1][0],ax[0][1],ax[1][1]);\n ## TODO: find points on decision boundary defined by theta0 + theta1 X1 + theta2 X2 == 0\n x1b = np.array... | [
"0.7012952",
"0.6911963",
"0.6594613",
"0.6533057",
"0.65208495",
"0.6514652",
"0.65101475",
"0.65086174",
"0.6432394",
"0.6432042",
"0.6407054",
"0.63388914",
"0.6319624",
"0.6305352",
"0.62987405",
"0.62423414",
"0.6223323",
"0.6214983",
"0.6184689",
"0.6180739",
"0.6155504... | 0.7111119 | 0 |
Helper method for padding the input number so that program can maintain symmetry in tables | def padding(input_value, value):
padding_value = str(input_value)
for i in range(value - len(str(input_value))):
padding_value += " "
return padding_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(number, width=0):\n return str(number).zfill(width)",
"def get_pad1(n):\n if n < 10:\n return \" \"\n if n < 100:\n return \" \"\n if n < 1000:\n return \" \"\n return \"\"",
"def padding_zeroes(number, length_string):\n return str(number).zfill(length_string)"... | [
"0.7694465",
"0.7258582",
"0.7234789",
"0.7135013",
"0.70261407",
"0.6954748",
"0.6911326",
"0.6909492",
"0.68428165",
"0.6823084",
"0.68187344",
"0.681711",
"0.6802245",
"0.6777663",
"0.6709971",
"0.6627718",
"0.6591441",
"0.65827405",
"0.65770954",
"0.65270615",
"0.65061265... | 0.7383802 | 1 |
Calculates the profit from the confusion matrix | def profitCalculation(confusion_matrix):
numberofClasses = 4
profits = [[20, -7, -7, -7], [-7, 15, -7, -7], [-7, -7, 5, -7], [-3, -3, -3, -3]]
totalProfit = 0
for count in range(numberofClasses):
for counter in range(numberofClasses):
totalProfit += confusion_matrix[count][counter] *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profit_curve(cost_benefit_mat, y_pred_proba, y_true):\n n_obs = float(len(y_true))\n # Make sure that 1 is going to be one of our thresholds\n\n thresholds = np.linspace(0,1,101)\n profits = []\n for threshold in thresholds:\n y_predict = y_pred_proba >= threshold\n confusion_matri... | [
"0.68429047",
"0.6588161",
"0.6383195",
"0.62662387",
"0.62233555",
"0.617524",
"0.6172645",
"0.61560917",
"0.61267865",
"0.61042863",
"0.60839117",
"0.60539186",
"0.60437346",
"0.60431606",
"0.59532946",
"0.5939802",
"0.5924911",
"0.5886583",
"0.5864573",
"0.58506",
"0.58411... | 0.8248979 | 0 |
The lines are getting split and parsed to gather the required information. a Edge with the data of lines is getting created. The list is appended by this edge | def createEdge(lines, list):
res = lines.split('\\n')
mains = res[0].split(' ')
sid = mains[3]
sid = sid[4:-1]
ssource = mains[4]
ssource = ssource[8:-1]
starget = mains[5]
starget = starget[8:-2]
slabel = ''
i = 2
while ('key=' in res[i]):
i = i + 1
if ('EdgeLa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineToList(self, line):\n raise NotImplementedError",
"def parse_lines(self, lines):\n assert isinstance(lines, Iterable)\n\n for line in lines:\n name, values = self.parse_line(line)\n self.add(name, values)",
"def prepare_lines_data(self):\n for l_hd in s... | [
"0.63740003",
"0.6287413",
"0.62869203",
"0.6241954",
"0.62419176",
"0.61737263",
"0.61737263",
"0.61737263",
"0.6111498",
"0.5984311",
"0.59755605",
"0.596852",
"0.59572536",
"0.5953377",
"0.5927684",
"0.59248614",
"0.5886327",
"0.5864776",
"0.58360136",
"0.5832824",
"0.5829... | 0.6507163 | 0 |
creates a Relation with the given parameter | def createRelation(rid, rlabel, list, x, y):
relation = Relation(rid, rlabel, x, y)
list.append(relation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def declare_relation(self,\n rel_name,\n domain_type,\n range_type,\n trainable = False,\n dense = False):\n if rel_name in self._declaration:\n raise RelationNameError(rel_name, 'Multiple declarat... | [
"0.6203038",
"0.61803585",
"0.59780806",
"0.5964317",
"0.59502816",
"0.5891712",
"0.587325",
"0.5832663",
"0.5781058",
"0.5695156",
"0.56259346",
"0.55553883",
"0.54986626",
"0.5438117",
"0.54175186",
"0.5413704",
"0.5407033",
"0.5391687",
"0.53306854",
"0.52989084",
"0.52787... | 0.7199586 | 0 |
Hydrate a ViewIO into the constructor arguments for View. | def hydrate_arguments(cls, view_io: ViewIO) -> Dict:
return {
**super().hydrate_arguments(view_io),
# TODO: should we add this here? probably not: "software_system"
"paper_size": view_io.paper_size,
"automatic_layout": AutomaticLayout.hydrate(view_io.automatic_lay... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_view(self, view, request, *args, **kwargs):\n view.request = request\n view.args = args\n view.kwargs = kwargs\n return view",
"def setup_view(view, request, *args, **kwargs):\n\n view.request = request\n view.args = args\n view.kwargs = kwargs\n ... | [
"0.6241447",
"0.62288916",
"0.6197663",
"0.6184966",
"0.6031715",
"0.57787627",
"0.57195693",
"0.5683868",
"0.5610492",
"0.5606469",
"0.5535032",
"0.5503669",
"0.5500431",
"0.54453224",
"0.53948295",
"0.53366286",
"0.5272058",
"0.5234212",
"0.5200459",
"0.5178498",
"0.5131439... | 0.71726805 | 0 |
Return the relationship views contained by this view. | def relationship_views(self) -> Iterable[RelationshipView]:
return set(self._relationship_views) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def views(self):\n return self._views",
"def getViews(self):\n return list(self.__views)",
"def child_views(self):\n return self.children",
"def getViews(self):\n return list(self.__views.keys())",
"def other_views(cls):\n return cls.__other_views",
"def getReachableVie... | [
"0.7207797",
"0.71174836",
"0.69009525",
"0.68892264",
"0.6824849",
"0.6787118",
"0.678279",
"0.6724912",
"0.65338415",
"0.64794517",
"0.6432522",
"0.63637567",
"0.6284232",
"0.6266386",
"0.6243599",
"0.62266636",
"0.6214038",
"0.6122439",
"0.6109116",
"0.6089614",
"0.6069089... | 0.861147 | 0 |
Add all relationships involving the given element to this view. | def _add_relationships(self, element: Element) -> None:
elements: Set[str] = {v.id for v in self.element_views}
for relationship in element.get_efferent_relationships():
if relationship.destination.id in elements:
self._relationship_views.add(
Relationshi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def add_relationship(self, relationship):\n self.relationships[relationship.parent].append(relationship)",
"def _add_element(self, element: Element, add_relationships: bool) -> ElementView:\n if element not in self.model:\n raise RuntimeError(\n ... | [
"0.63140434",
"0.6036017",
"0.6033511",
"0.5894598",
"0.54866344",
"0.5441199",
"0.5249128",
"0.5248479",
"0.52381414",
"0.52308077",
"0.52253497",
"0.52209246",
"0.5182565",
"0.5141708",
"0.5135262",
"0.51191837",
"0.5117873",
"0.5116992",
"0.51102453",
"0.50909835",
"0.5083... | 0.8321654 | 0 |
Copy the layout information from another view, including child views. | def copy_layout_information_from(self, source: "View") -> None:
if not self.paper_size:
self.paper_size = source.paper_size
for source_element_view in source.element_views:
destination_element_view = self.find_element_view(
element=source_element_view.element
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_layout( self ):",
"def test_copying_dynamic_view_layout(empty_viewset):\n source_viewset = empty_viewset\n source_view = source_viewset.create_dynamic_view(key=\"dyn1\", description=\"test\")\n source_view.paper_size = PaperSize.A4_Landscape\n\n target_viewset = ViewSet(model=empty_viewset... | [
"0.5935125",
"0.5920447",
"0.58474386",
"0.5801851",
"0.57843786",
"0.56659687",
"0.5598473",
"0.54099834",
"0.53438044",
"0.53059226",
"0.52955204",
"0.5243661",
"0.5236582",
"0.51705223",
"0.5160853",
"0.5154584",
"0.51248074",
"0.510902",
"0.50980395",
"0.50895196",
"0.505... | 0.7830946 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.