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 |
|---|---|---|---|---|---|---|
Return the list of users, optionally filtered by a predicate. | def users(self, predicate=None):
if predicate is None:
return self._get("users").json()
else:
return self._get("users/search", params={"predicate":predicate}).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_users(filter, api_site_parameter, page = 1, pagesize = 30, sort = 'reputation'):\n path = \"users\"\n results = __fetch_results(path, api_site_parameter, inname= filter, page = page, pagesize = pagesize, sort = sort)\n return results",
"def list_users(self, kwargs):\n verbose = kwargs.get... | [
"0.718876",
"0.69944775",
"0.69089013",
"0.68136847",
"0.67803323",
"0.6777134",
"0.6736814",
"0.66396964",
"0.66324025",
"0.65912765",
"0.6577068",
"0.6515583",
"0.6474354",
"0.64336705",
"0.64172804",
"0.63798445",
"0.6375672",
"0.6341821",
"0.6323259",
"0.6260486",
"0.6231... | 0.81320375 | 0 |
Return the list of components, optionally filtered by a predicate. | def components(self, predicate=None):
if predicate is None:
return self._get("components").json()
else:
return self._get("components/search", params={"predicate":predicate}).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_components(self,filt):\n comps = [self.components[i] for i in xrange(len(self.header)) if filt == self.header[i]]\n return comps",
"def filter(self, predicate):\n def _filter(iterator):\n while True:\n item = next(iterator)\n if predicate(item... | [
"0.6674913",
"0.59280175",
"0.57847",
"0.57690585",
"0.5722505",
"0.5720602",
"0.56805724",
"0.5619865",
"0.56110597",
"0.5601963",
"0.5591747",
"0.5566991",
"0.5561191",
"0.5532992",
"0.5496582",
"0.54930145",
"0.54552966",
"0.54481083",
"0.5440294",
"0.5438733",
"0.5350558"... | 0.6776347 | 0 |
Returns the component that is the parent of the passed in component. | def component_parent(self, component):
list = self.components("ANY children.identifier = '%s'" % _obj_id(component))
if len(list) > 0:
return list[0]
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parentComponent(self):\n return fusion.Component()",
"def get_parent(self):\n return self._find_by_locator().parent",
"def get_parent(self):\n if self.parent:\n return self.parent()\n else:\n return None",
"def get_parent(self):\n return self.paren... | [
"0.7491849",
"0.73969966",
"0.7335824",
"0.7116752",
"0.7116752",
"0.7116752",
"0.7111655",
"0.7023323",
"0.7023323",
"0.69511116",
"0.6929134",
"0.6915407",
"0.69085526",
"0.68869364",
"0.68481857",
"0.67514914",
"0.6736015",
"0.67348146",
"0.67278624",
"0.6721226",
"0.67155... | 0.8453336 | 0 |
Returns the immediate child components of the passed in component | def component_children(self, component):
return self.components("parent.identifier = '%s'" % _obj_id(component)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def components(self):\n return self._components",
"def components(self):\r\n children = self.container.findall(\"ComponentInstance\")\r\n return [XMLComponent(c) for c in children]",
"def get_recursive_components (self, comp_name):\r\n comp_list = []\r\n # Current component\r\n ... | [
"0.63954175",
"0.634758",
"0.6310204",
"0.6247878",
"0.62178755",
"0.61164606",
"0.61022353",
"0.60726184",
"0.59098697",
"0.59098697",
"0.5903744",
"0.58811057",
"0.5880784",
"0.5880784",
"0.5841002",
"0.58345646",
"0.5816388",
"0.5808206",
"0.5802079",
"0.5671715",
"0.56677... | 0.80775076 | 0 |
Return the list of all milestones, optionally filtered by a predicate | def milestones(self, predicate=None):
if predicate is None:
return self._get("milestones").json()
else:
return self._get("milestones/search", params={"predicate":predicate}).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_get_milestones_list(self):\n pass",
"def milestones(self):\r\n return milestones.Milestones(self)",
"def milestones(self):\r\n return IssueMilestones(self)",
"def get_public_milestones(self):\n # TODO: Assuming first server is good - need to make fallback logic\n ... | [
"0.6634532",
"0.63786525",
"0.60176355",
"0.60008043",
"0.5678339",
"0.56678134",
"0.52445894",
"0.5214817",
"0.5151322",
"0.51425946",
"0.5142451",
"0.50417787",
"0.49899873",
"0.49864954",
"0.49168158",
"0.486399",
"0.4834319",
"0.47452897",
"0.47217488",
"0.4703715",
"0.46... | 0.80855364 | 0 |
Returns only the milestones that are currently active (that is, those that either omit the start and end dates, or those with start and end dates where start < now < end). | def milestones_active(self, within_component=None):
if within_component is not None:
if isinstance(within_component, str):
within_component = self.components("identifier = %s" % within_component)[0]
predicate = """
(StartDate == nil || StartDate < NOW())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active (self, after = None, before = None):\n\n active = ActivityList()\n active.list = [actor for actor in self.list\n if (after == None or\n actor[\"period\"].end >= after) and\n (before == None or\n ... | [
"0.61798745",
"0.61652255",
"0.6027968",
"0.59534323",
"0.5700915",
"0.56925315",
"0.5610645",
"0.56026137",
"0.5589813",
"0.55476916",
"0.55194217",
"0.55154073",
"0.54779494",
"0.54456633",
"0.54270303",
"0.5396362",
"0.53825986",
"0.53591615",
"0.5356484",
"0.5319471",
"0.... | 0.7112044 | 0 |
Returns the list of priorities | def priorities(self):
return self._get("priorities").json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPriorityList(self):",
"def priorities(self) -> Optional[Iterable[str]]:\n\n return self.get_project_priorities()",
"def getPriority(self):",
"def id_priority_list(self):\n return self._id_priority_list",
"def init_priority(self):\n arr = []\n priority_dict = dict()\n\n ... | [
"0.82035583",
"0.79757464",
"0.71184015",
"0.69953656",
"0.6906988",
"0.66373295",
"0.6556149",
"0.6515386",
"0.6501138",
"0.6481751",
"0.6454467",
"0.6454467",
"0.6454467",
"0.6454467",
"0.63370156",
"0.63306737",
"0.63022155",
"0.626634",
"0.626634",
"0.6265599",
"0.6243470... | 0.8173191 | 1 |
Return the list of valid state transitions from state. | def state_transitions(self, state):
return self.states("ANY PreviousStates.identifier = '%s'" % _obj_id(state)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitions(self, from_state=None):\n return list(self.iter_transitions(from_state))",
"def transitions(self, state):\n if len(set(state)) < len(state):\n yield self.STOP_STATE\n return\n for hidx in xrange(self.num_players):\n for lidx in xrange(hidx):\n... | [
"0.7897553",
"0.7058213",
"0.6909843",
"0.6835081",
"0.67144054",
"0.67064613",
"0.6659277",
"0.65004504",
"0.6473224",
"0.6464462",
"0.6434455",
"0.64069766",
"0.6357915",
"0.63360065",
"0.6276572",
"0.6270292",
"0.6219843",
"0.6212978",
"0.61455226",
"0.6142549",
"0.6134658... | 0.73548394 | 1 |
Fetch a single problem. identifier should be an int representing the problem identifier to fetch. | def problem(self, identifier):
return self._get("problems/%d" % identifier).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_problem(identifier):\n problem = database.session.query(Problem, ProblemData).join(ProblemData)\n if is_pid(identifier):\n problem = problem.filter(Problem.pid == identifier).first()\n else:\n problem = problem.\\\n filter(Problem.shortname == identifier).first()\n\n... | [
"0.6831753",
"0.6268822",
"0.5826658",
"0.5733782",
"0.5718513",
"0.56838435",
"0.563037",
"0.55231625",
"0.5486525",
"0.5466694",
"0.5442252",
"0.5442006",
"0.5442006",
"0.53945965",
"0.5390215",
"0.5379254",
"0.5360963",
"0.5327507",
"0.5321211",
"0.52903354",
"0.52741504",... | 0.7195323 | 0 |
Search for a set of problems given a predicate. | def problem_search(self, predicate=None, savedQueryURL=None, includeDetail=False):
params = {}
if predicate is not None:
params["predicate"] = predicate
elif savedQueryURL is not None:
params["savedQuery"] = savedQueryURL
else:
raise Error("Ei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(self, predicate):\n return [d for d in self.iter_tree if predicate(d)]",
"def search_alg(query, questions_list, tag_list, language, difficulty):\n global user_flag\n list_return = [] # The list which we will be returning\n query_tags = []\n query_titels = []\n\n if not query:\n ... | [
"0.558807",
"0.518133",
"0.5118416",
"0.510903",
"0.51005197",
"0.5097114",
"0.50305724",
"0.48769644",
"0.484233",
"0.48394457",
"0.48163816",
"0.48043537",
"0.48016292",
"0.47515813",
"0.47459945",
"0.47293434",
"0.47038335",
"0.46879834",
"0.46831623",
"0.46495906",
"0.462... | 0.6172628 | 0 |
Create a new problem based on the provided problem data. | def problem_create(self, problem):
return self._post("problems", json=problem).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_problem():\n # Admin check\n if not current_user.admin == 1:\n return serve_error('You must be an admin to create problems',\n response_code=401)\n\n try:\n # Convert the JSON to python array of dictionaries\n cases = request.form['cases']\n ... | [
"0.6951319",
"0.6625024",
"0.6625024",
"0.6603956",
"0.6591881",
"0.63943565",
"0.63517785",
"0.5923711",
"0.5809345",
"0.5769485",
"0.5701272",
"0.56902915",
"0.5676844",
"0.5644496",
"0.5614058",
"0.56054026",
"0.55882806",
"0.556935",
"0.556253",
"0.5546477",
"0.5523147",
... | 0.7535201 | 0 |
Update an existing problem and add/update a keyword. | def problem_keyword_set(self, identifier, keyword, value=None):
self._put("problems/%d/keywords/%s" % (identifier, quote(keyword, safe="")), json=value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, problem_id):\n args = self.request.arguments\n x = args.pop('latitude')\n y = args.pop('longitude')\n args['location'] = create_location(x, y)\n self.sess.query(Problem).filter_by(id=int(problem_id)). \\\n update(args)\n\n self.sess.commit()\n\n ... | [
"0.61769944",
"0.58378965",
"0.56088656",
"0.5605392",
"0.5590597",
"0.54668194",
"0.5348828",
"0.5304439",
"0.52890366",
"0.526431",
"0.5261165",
"0.52269745",
"0.5192112",
"0.5146122",
"0.5120042",
"0.5079348",
"0.506978",
"0.50642264",
"0.505732",
"0.50392693",
"0.50340545... | 0.6982569 | 0 |
Update an existing problem and remove a keyword. | def problem_keyword_delete(self, identifier, keyword):
self._delete("problems/%d/keywords/%s" % (identifier, quote(keyword, safe=""))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_keyword_set(self, identifier, keyword, value=None):\n self._put(\"problems/%d/keywords/%s\" % (identifier, quote(keyword, safe=\"\")), json=value)",
"def delete(self, keyword, key):",
"async def delprob(self, ctx, problem_name):\n if not await problem_exists(ctx, problem_name):\n ... | [
"0.6466727",
"0.6054319",
"0.55775964",
"0.55644643",
"0.55415493",
"0.53721416",
"0.5298688",
"0.52898467",
"0.5261552",
"0.5184182",
"0.5147284",
"0.5146864",
"0.51035714",
"0.5096608",
"0.50747263",
"0.5059537",
"0.5046001",
"0.5015993",
"0.50112444",
"0.5003859",
"0.50038... | 0.71324074 | 0 |
Returns the set of relationships that the provided problem is a part of. | def problem_relationships(self, identifier):
return self._get("problems/%d/relationships" % identifier).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relations(self):\n return set(self.triples()[\"relation\"])",
"def relationships(self):",
"def get_relations(self):\n triples = list(self.get_triples())\n\n for s, p, o in triples:\n if not p.startswith(\"rel\"):\n s, o = int(s.id), int(o.id)\n ... | [
"0.70870245",
"0.6588074",
"0.6436843",
"0.6173217",
"0.6168484",
"0.6018063",
"0.5981662",
"0.5978576",
"0.5977961",
"0.59650034",
"0.5942173",
"0.5903671",
"0.58759755",
"0.57877916",
"0.57769465",
"0.576169",
"0.5740245",
"0.57243073",
"0.56790555",
"0.56746703",
"0.566652... | 0.69632775 | 1 |
Create a relationship between two problems. It is only necessary to establish one side of the relationship. The complimentary side of the relationship will be established automatically by the server. | def problem_relationship_add(self, src_identifier, relation_type, dst_identifier):
self._put("problems/%d/relationships" % src_identifier, json={"type" : relation_type, "problemIdentifier" : dst_identifier }) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_relation(self, left_node, rel, right_node):\n rel = Relationship(left_node, rel, right_node)\n self.graph.merge(rel)\n return",
"def relate(self, other):\n ...",
"def allow_relation(self, obj1, obj2, **hints):\n return True",
"def allow_relation(self, obj1, obj2,... | [
"0.61737007",
"0.6095098",
"0.5975486",
"0.5956993",
"0.5893868",
"0.5735954",
"0.57261753",
"0.56114084",
"0.55028147",
"0.5449277",
"0.538438",
"0.53711104",
"0.5345818",
"0.5305271",
"0.52893794",
"0.5283024",
"0.52736306",
"0.5254689",
"0.5251221",
"0.52238345",
"0.521808... | 0.6961868 | 0 |
Delete a relationship as returned by problem_relationships. | def problem_relationship_delete(self, src_identifier, relation_dict):
self._delete("problems/%d/relationships" % src_identifier, json=relation_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n _unset_related_objects_relations(self)\n self.deleted = now()\n self.save()\n\n return self",
"def delete_relationship(tx, node_value_1=None, node_value_2=None, node_type_1=None, node_type_2=None, relationship=None):\n if node_value_1 is None and node_type_1... | [
"0.62468123",
"0.6075937",
"0.60754156",
"0.6045664",
"0.5829113",
"0.57965726",
"0.5750567",
"0.57431644",
"0.57239985",
"0.5719725",
"0.56914794",
"0.563315",
"0.5614135",
"0.5602807",
"0.5601607",
"0.55926967",
"0.5554488",
"0.5542166",
"0.5538604",
"0.5506461",
"0.5501475... | 0.842289 | 0 |
Access the list of comments on the requested problem. | def problem_comments(self, identifier):
return self._get("problems/%d/comments" % identifier).json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments(self):\n raise NotImplementedError",
"def get_comments(self):\n\t\treturn self._client.get_comments(self)",
"def comments(self):\r\n return IssueComments(self)",
"def comments(self):\r\n return IssueComments(self)",
"def comments(self) -> list:\n return self._no... | [
"0.7727881",
"0.7471885",
"0.73331463",
"0.73331463",
"0.73330116",
"0.73051596",
"0.73051596",
"0.73051596",
"0.7230867",
"0.7223843",
"0.7126679",
"0.7126679",
"0.7103531",
"0.7061553",
"0.7025779",
"0.70209825",
"0.6987613",
"0.68704796",
"0.68501776",
"0.68501776",
"0.685... | 0.8174743 | 0 |
Returns a chunk of length of window_size and the end of the window size | def get_chunks(sequence, window_size, step=1):
# get the sequence length
k = len(sequence)
# get the index for each end and chunk
for i in range(0, k - window_size + 1, step):
# generate the end of the window
end = i + window_size
# get the slice of the sequence
chunk = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_chunks(sequence, window_size, step=1):\n k = len(sequence)\n for i in range(0, k - window_size + 1, step):\n end = i + window_size\n chunk = sequence[i:i + window_size]\n assert len(chunk) == window_size\n yield chunk, end",
"def next_window(self, window_size: int) -> It... | [
"0.6993197",
"0.6883627",
"0.6766788",
"0.67095524",
"0.6618862",
"0.65909404",
"0.6495501",
"0.64910275",
"0.64154613",
"0.63859916",
"0.6315355",
"0.6278746",
"0.6257563",
"0.62292266",
"0.6201356",
"0.6188974",
"0.61796284",
"0.6144587",
"0.6143719",
"0.6140929",
"0.612329... | 0.69789374 | 1 |
Function to count all umbigous bases in a sequence. Ambigous bases are bases that are not in the sequence alphabet, ie. 'ACGT' for DNA sequences. | def count_umbiguous_bases(sequence):
sequence = sequence.upper()
amb = ['N', 'R', 'Y', 'W', 'S', 'K', 'M']
return sum({base: sequence.count(base) for base in amb}.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_all_bases(sequence):\n # create a set of bases\n bases = set(sequence)\n all_bases = defaultdict(int)\n # iterates in the base set\n for base in bases:\n # count the bases in the sequence\n all_bases[base] = sequence.count(base)\n return all_bases",
"def get_bases_stats(... | [
"0.7385681",
"0.6816655",
"0.65618616",
"0.60834855",
"0.6077257",
"0.60242873",
"0.6008956",
"0.59128505",
"0.5824625",
"0.5747893",
"0.56719303",
"0.5662238",
"0.5654305",
"0.5579492",
"0.5552459",
"0.5552459",
"0.5543022",
"0.55394393",
"0.5512835",
"0.5503739",
"0.5458469... | 0.7984436 | 0 |
Calculates the at/gc ratio of a genome. | def get_at_gc_ratio(at, gc):
return at / gc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc_rate(dna: str, percent=False):\n c = Counter(dna)\n result = (c[\"G\"] + c[\"C\"]) / len(dna)\n return result * 100 if percent else result",
"def gc(self) -> float:\n g = self.count(\"G\")\n c = self.count(\"C\")\n return (g + c) / len(self) * 100",
"def calculate_gear_rati... | [
"0.6823025",
"0.6695999",
"0.6404715",
"0.6330023",
"0.6317178",
"0.6289386",
"0.6241849",
"0.6231716",
"0.6224794",
"0.6191345",
"0.603549",
"0.6034941",
"0.6000487",
"0.5982671",
"0.597742",
"0.58961",
"0.5885077",
"0.58844954",
"0.5851501",
"0.58212274",
"0.57130134",
"0... | 0.799837 | 0 |
GC Content in a DNA/RNA subsequence length k. In overlapp windows of lenght k. | def gc_content_sequence_window(sequence, as_overlap=False, k=20):
# make sequence upper case and getting the length of it
sequence, seq_len = sequence.upper(), len(sequence)
# the array-like object to collect the data
gc_content = []
# non overlap sequence length
non_overlap = range(0, len(seque... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc_content_along_the_chain(dna_sequence, window_size):\n sub_sequences = extract_sub_sequences(dna_sequence, window_size)\n gc_results = []\n for sub_sequence in sub_sequences:\n gc_results.append(gc_content(sub_sequence))\n return gc_results",
"def gc_var(sequence, as_overlap=False, k=20)... | [
"0.6752567",
"0.64076644",
"0.6161453",
"0.6118112",
"0.5984678",
"0.58789796",
"0.5851222",
"0.5846533",
"0.58085054",
"0.57129765",
"0.5636258",
"0.5616689",
"0.5599156",
"0.557875",
"0.5574082",
"0.5573126",
"0.5561715",
"0.5556962",
"0.5556962",
"0.5536127",
"0.5490504",
... | 0.74124485 | 0 |
Function to calculate the frequency of the codons in a sequence. | def codon_frequency(sequence, codon_table):
# initialize the counter with the list of triplets from codon_table
counter = Counter(dict([(c, 0) for c in codon_table]))
# create a list/array of all possible codons found in the input sequence
triplets = [sequence.upper()[i:i + 3] for
i in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def codon_frequency(seq, aminoacid):\n tmpList = []\n for i in range(0, len(seq) - 2, 3):\n if CodonTable[seq[i:i + 3]] == aminoacid:\n tmpList.append(seq[i:i + 3])\n\n freqDict = dict(Counter(tmpList))\n totalScore = sum(freqDict.values())\n for seq in freqDict:\n freqDict[... | [
"0.7567119",
"0.72417057",
"0.71978146",
"0.7188881",
"0.7131045",
"0.70670915",
"0.6903608",
"0.68454266",
"0.66870964",
"0.6682764",
"0.661773",
"0.6477869",
"0.6368345",
"0.63172907",
"0.62968326",
"0.62675095",
"0.62490714",
"0.62382305",
"0.6193833",
"0.6193833",
"0.6193... | 0.81066716 | 0 |
Calculates the gc content variance in a sequence according to a window of length k. | def gc_var(sequence, as_overlap=False, k=20):
# calculates the percent of gc content
gc = get_gc_content(sequence) * 100
# get the gc content in the window space as an array
gc_i = np.array(gc_content_sequence_window(sequence, as_overlap, k=k))
# get the len of the gc content in the window space
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc_content_sequence_window(sequence, as_overlap=False, k=20):\n # make sequence upper case and getting the length of it\n sequence, seq_len = sequence.upper(), len(sequence)\n # the array-like object to collect the data\n gc_content = []\n # non overlap sequence length\n non_overlap = range(0... | [
"0.63860196",
"0.6235115",
"0.60946256",
"0.57806844",
"0.57092375",
"0.5630119",
"0.5332496",
"0.5323007",
"0.5286635",
"0.5262322",
"0.52159446",
"0.5187272",
"0.5152176",
"0.5151929",
"0.5133126",
"0.5115792",
"0.5113375",
"0.50864863",
"0.5030746",
"0.5030157",
"0.5012101... | 0.755605 | 0 |
Returns the complement strand of the genome. | def get_strand_complement(sequence):
# make the sequence upper case
seq = sequence.upper()
# table to change the complement characters
change = str.maketrans('ACGT', 'TGCA')
return seq.translate(change) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_complement(nucleotide):\n if nucleotide=='A':\n \treturn 'T'\n if nucleotide=='C':\n \treturn 'G'\n if nucleotide=='T':\n \treturn 'A'\n if nucleotide=='G':\n \treturn 'C'",
"def get_strand_complement(sequence):\n seq = sequence.upper()\n change = str.maketrans('ACGT', 'TGCA... | [
"0.71287143",
"0.7112783",
"0.7098898",
"0.7065957",
"0.70642453",
"0.700329",
"0.69763005",
"0.68346596",
"0.6797956",
"0.673517",
"0.6713025",
"0.66734636",
"0.6657223",
"0.6595245",
"0.6563522",
"0.6555067",
"0.6521378",
"0.6405061",
"0.63837147",
"0.632016",
"0.63072795",... | 0.73389566 | 0 |
Returns the reverse complement strand of the genome. | def get_reverse_complement(sequence):
return get_strand_complement(sequence)[::-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_complement_strand(dna):\n assert (is_dna(dna))\n return ''.join(_rev_mapping[nn] for nn in dna[::-1])",
"def get_reverse_complement(sequence):\n seq = sequence.upper()\n return get_strand_complement(seq)[::-1]",
"def get_reverse_complement(dna):\n dna2 = get_complement(dna)\n dna3... | [
"0.764635",
"0.76432216",
"0.76206285",
"0.75781304",
"0.7459168",
"0.7373911",
"0.7336976",
"0.7114455",
"0.7025804",
"0.70229846",
"0.7021352",
"0.7019306",
"0.7013256",
"0.69664097",
"0.69514114",
"0.6932707",
"0.6928373",
"0.69146174",
"0.68675524",
"0.6778184",
"0.676679... | 0.7836419 | 0 |
Calculates a position in a sequence minimizing the skew. | def get_minimum_skew(sequence):
# start the array
min_skew = []
# calculates the sequence gc skew
skew = get_sequence_skew(sequence)
# get the minimized skew values
m_skew = min(skew)
# iterates to the length of the sequence
# to get the index positions
for idx in range(len(sequence... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_min_skew_position(genome):\n assert (is_dna(genome))\n skew = get_skew(genome)\n min_skew = min(skew)\n return [pos for (pos, sk) in enumerate(skew) if sk == min_skew]",
"def min_skew_positions(genome: str) -> list:\n\n min_skew = 0\n result = [0]\n\n curr_skew = 0\n for i in rang... | [
"0.67086536",
"0.62083524",
"0.5892266",
"0.5836606",
"0.56663465",
"0.5659582",
"0.5613757",
"0.55811",
"0.5522433",
"0.5512218",
"0.5506874",
"0.54924464",
"0.54878193",
"0.5467683",
"0.54343665",
"0.5357526",
"0.53443265",
"0.5343145",
"0.5330511",
"0.5313186",
"0.53067976... | 0.65810394 | 1 |
Make a plot from the base frequency distribution in a DNA sequence. | def plot_base_frequency_genome(x_data, y_data, x_label, y_label):
# color for the bases
base_markers = {"A": "b-",
"C": "r-",
"G": "g-",
"T": "y-",
"N": "k-"}
# drawing the plot
fig = plt.figure(figsize=(16, 8))
ax = fig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_composition(reads, base):\n assert base.upper() in set(\"ACGT\")\n\n \"\"\" Reports nucelotide frequencies at each position in the\n sam sequences\n \"\"\"\n # DNA_Alphabet=[\"A\",\"C\",\"T\",\"G\",\"N\"]\n all_nucs = []\n for read in reads:\n nucs = {} # Dictionary to sto... | [
"0.6750949",
"0.6312379",
"0.6261643",
"0.60959035",
"0.6060645",
"0.60301715",
"0.60301715",
"0.60301715",
"0.6027653",
"0.6027587",
"0.5995123",
"0.5985474",
"0.5812763",
"0.58085936",
"0.58050704",
"0.57880205",
"0.5758242",
"0.57470506",
"0.57378995",
"0.57230926",
"0.572... | 0.64471364 | 1 |
Calculates the base/nucleotide frequencies in a window of size window and step and make a plot of the base distribution along of the sequence length. | def base_content_slide_window(sequence, path, name, alphabet, window, step, plot=False):
# sequence as a string of upper cases characters
# bases as a set of upper cases characters
sequence, bases = sequence.upper(), alphabet
# initialize the dictionary container and the array
base_freqs = defaultdi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_counthist(counts, label, view_lim=[1e-6,1e0,1e0,1e5]):\n max_size = max(counts.values())\n num_chains = sum(counts.values())\n sizes = np.arange(1,max_size+1)\n freqs = np.float_(sizes) / num_chains\n (hist,garbage) = np.histogram(counts.values(),bins=sizes)\n idxs = hist > 0\n \n... | [
"0.62747514",
"0.61388403",
"0.6041006",
"0.5977068",
"0.5822721",
"0.58037317",
"0.5766557",
"0.5721363",
"0.5721363",
"0.5721363",
"0.5663317",
"0.5646493",
"0.5640953",
"0.5637996",
"0.56258035",
"0.5622705",
"0.56148934",
"0.55990183",
"0.5596233",
"0.5590827",
"0.5587536... | 0.6481207 | 0 |
Calculates the DNA strand base statistics over a sequence. | def strand_stats(sequence, alphabet, start):
# assure the characters are upper case
alphabet = alphabet.upper()
# assure the characters are upper case
# get the sequence length
seq_len, seq = len(sequence), sequence.upper()
# get the middle position of the sequence
half_gen = (seq_len // 2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bases_stats(sequence, alphabet, start):\n seq = sequence.upper()\n seq_len = len(seq)\n half_seq = seq_len // 2\n ter = start + half_seq\n # as a circular genome\n if ter > seq_len:\n ter = ter - seq_len + 1\n counts = defaultdict(int)\n for base in alphabet:\n total =... | [
"0.6844656",
"0.5866069",
"0.5852457",
"0.5767654",
"0.5659145",
"0.56240505",
"0.5556784",
"0.54912585",
"0.54409754",
"0.5419822",
"0.5405742",
"0.5402327",
"0.53218985",
"0.52998936",
"0.528539",
"0.5226978",
"0.5214499",
"0.51802236",
"0.5163815",
"0.5162196",
"0.51621354... | 0.7544242 | 0 |
Prints the strand statistics. | def print_strand_stats(strand_statistics):
print(' Total\tFor\tRev\tDif')
for base, count in strand_statistics.items():
print(f'{base}: {str(count[0])}\t{str(count[1])}\t{str(count[2])}\t{str(count[3])}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_stats(self, output_type='count'):\n if not self._stats:\n raise TypeError(\"self._stats is not defined. Try running run_parser first!\")\n self._stats.print_spec(output_type)",
"def print_stat(self):\n all_stat = self.get_all_stat()\n for stat_type, stat in all_sta... | [
"0.6812522",
"0.6772878",
"0.66958606",
"0.66482264",
"0.65283674",
"0.65146375",
"0.64881164",
"0.6446352",
"0.64255565",
"0.6423256",
"0.62889",
"0.62166005",
"0.6209804",
"0.6180282",
"0.6165024",
"0.61648023",
"0.61368006",
"0.6129409",
"0.61040974",
"0.6102065",
"0.60754... | 0.74928737 | 0 |
Returns a list of all possible combinations of kmers of length k from a input alphabet. | def get_all_possible_kmers(alphabet, kmin, kmax):
kmers = [''.join(letters) for n in range(kmin, kmax + 1)
for letters in product(alphabet, repeat=n)]
return kmers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_kmers(k):\n\n kmers_list = []\n kmers_tuples = itertools.product('ACGT', repeat=k)\n for kmer in kmers_tuples:\n kmers_list.append(''.join(kmer))\n\n return kmers_list",
"def kmers(sequence, alphabet, k):\n mers = (''.join(c) for c in windowed(k, sequence))\n return [mer fo... | [
"0.7966488",
"0.7883599",
"0.77914125",
"0.7568773",
"0.75586224",
"0.74191636",
"0.7416181",
"0.740234",
"0.73228323",
"0.7060401",
"0.7002437",
"0.69293416",
"0.68837583",
"0.68600106",
"0.6826388",
"0.68097705",
"0.680771",
"0.6743084",
"0.66071045",
"0.65487576",
"0.65257... | 0.81739914 | 0 |
Find clumps of repeated kmers in string. A clump occurs when times or more a kmers appear within a window of size window. A list of (kmer, position, count) tuples is returned. | def get_kmer_clumps(sequence, kmer_list, window, times):
kmer_pos = defaultdict(list)
k = len(kmer_list[0])
clumps = defaultdict(list)
for kmer in kmer_list:
kmer_pos[kmer] = kmer_pos.get(kmer, []) + get_pattern_positions(sequence,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clump_forming_kmers(string, k, l, t):\n clumpFormingKmers = set()\n # Initial counts of k-mers within length l window starting from the first\n # chracter of the string.\n counts = Counter([kmer for i, kmer in enumerate_kmers(string[:l], k)])\n clumpFormingKmers = add_clump_forming_kmers(counts,... | [
"0.7578869",
"0.725475",
"0.7170416",
"0.7065859",
"0.70088464",
"0.6737378",
"0.6601845",
"0.64199483",
"0.62262785",
"0.6064274",
"0.6063467",
"0.5913066",
"0.58647",
"0.58513254",
"0.5823833",
"0.56832606",
"0.5652791",
"0.5648163",
"0.563255",
"0.5630395",
"0.5593445",
... | 0.768465 | 0 |
Function to insert any wild card character in a word or string, generally the string must be a palindrome. | def insert_wild_card(word, num_n=1):
mid = len(word) // 2
# to insert only one wild card character
# with a predefinited condiction
if num_n == 1 and is_palindrome(word) and len(word) % 2 != 0:
return word[:mid] + 'N' + word[mid + 1:], word
# the even words can receive two wild card chars
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EscapeWildcards(string: Text) -> Text:\n precondition.AssertType(string, Text)\n return string.replace(\"%\", r\"\\%\").replace(\"_\", r\"\\_\")",
"def insert_special_char(phrase_words):\n SPECIAL = [\n [\"~\", \"!\", \"#\", \"$\", \"%\", \"^\"],\n [\"&\", \"*\", \"(\", \")\", \"-\", \"=\"... | [
"0.64717144",
"0.63470495",
"0.6299257",
"0.626429",
"0.61380047",
"0.6095588",
"0.59981585",
"0.597494",
"0.5928834",
"0.5911483",
"0.58997667",
"0.58580613",
"0.58496493",
"0.5781776",
"0.57784766",
"0.5746187",
"0.574614",
"0.57364184",
"0.57253385",
"0.5724377",
"0.567421... | 0.64887744 | 0 |
Find number of occurrences of each value in sequence. | def counts(sequence):
# initialize the countainer
count = defaultdict(int)
# iterates through sequence elements
for item in sequence:
# if element not in counts add 0
# else add 1
count[item] = count.get(item, 0) + 1
return dict(count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(seq):\n\treturn sum(1 for x in seq)",
"def count_elements(seq) -> dict:\n hist = {}\n for i in seq:\n hist[i] = hist.get(i, 0) + 1\n return hist",
"def count_elements(seq) -> dict:\n hist = {}\n for i in seq:\n hist[i] = hist.get(i, 0) + 1\n return hist",
"def count(... | [
"0.81605697",
"0.7333692",
"0.7333692",
"0.7317099",
"0.7203902",
"0.71936685",
"0.71691054",
"0.7076678",
"0.7049411",
"0.69177294",
"0.69103754",
"0.6907409",
"0.682325",
"0.6822243",
"0.6801181",
"0.6785441",
"0.67659605",
"0.676138",
"0.67390096",
"0.6727958",
"0.66564286... | 0.7605741 | 1 |
Couns the number of overlapping subsequences of lenght between kmin kmax in a input sequence. | def count_subsequence_in_sliding_window(kmin, kmax, sequence):
if isinstance(sequence, str):
for n in range(kmin, kmax + 1):
for sub in zip(*(deque(itertools.islice(it, i), 0) or
it for i, it in enumerate(itertools.tee(sequence,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_overlapping(seq, subseq):\n \n pos, count = 0, 0\n while True:\n pos = seq.find(subseq, pos)\n if pos < 0:\n break\n pos += 1 \n count += 1\n return count",
"def _get_subsequence_counts(sequences, length, min_support=None):\n # type: (Union[List[s... | [
"0.6897632",
"0.66734475",
"0.66401356",
"0.61437935",
"0.6082373",
"0.60758173",
"0.6067477",
"0.6067079",
"0.60625184",
"0.60437757",
"0.59478396",
"0.591973",
"0.58829165",
"0.5873242",
"0.5867987",
"0.5842749",
"0.5830168",
"0.5733634",
"0.57134503",
"0.5704528",
"0.57030... | 0.72154963 | 0 |
Returns a plot of the genome gc skew | def plot_gc_skew(x, y):
plt.figure(num=None, figsize=(24, 7), dpi=100)
yargmax = y.index(max(y))
plt.axvline(oriCStart + oriOffset, color="r", linestyle='--')
plt.axvline(x[yargmax], color="g", linestyle='--')
plt.plot(x, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_gc_skew(x, y, start, offset):\n plt.figure(num=None, figsize=(24, 7), dpi=100)\n yargmax = y.index(max(y))\n plt.axvline(start + offset, color=\"r\", linestyle='--')\n plt.axvline(x[yargmax], color=\"g\", linestyle='--')\n plt.plot(x, y)\n plt.savefig('Skew_genome.pdf', format='pdf', dpi... | [
"0.70905507",
"0.5991147",
"0.58976996",
"0.5865311",
"0.57162565",
"0.55291164",
"0.55249155",
"0.55096096",
"0.54807127",
"0.54696524",
"0.54455096",
"0.54164976",
"0.5409248",
"0.5373216",
"0.53698695",
"0.535764",
"0.53407437",
"0.5330776",
"0.53299135",
"0.53097653",
"0.... | 0.6686433 | 1 |
When passed a string, representing a nucleotide sequence, treats it as a short inverted repeat, and returns the number of mismatched compared to its reverse complement for half the length of the sequence. | def count_sequence_mismatches(seq):
trans_table = str.maketrans('ACGT', 'TGCA')
half_len = len(seq) // 2
second_half = seq[-half_len:].translate(trans_table)
mismatches = 0
for i in range(half_len):
if seq[i] != second_half[-i - 1]:
mismatches += 1
return mismatches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat_again(s: str) -> int:\n string_dict = dict()\n max_length = 0\n met_repeat = False\n for index, v in enumerate(s):\n if v in string_dict:\n m = index - string_dict[v]\n if m > max_length:\n max_length = m\n met_repeat = True\n str... | [
"0.6090975",
"0.6080663",
"0.6072563",
"0.6008404",
"0.6008404",
"0.6002933",
"0.5976948",
"0.5958161",
"0.5908225",
"0.58983845",
"0.5886952",
"0.5879738",
"0.58791685",
"0.5874548",
"0.5846228",
"0.5821024",
"0.57775706",
"0.5776557",
"0.5747761",
"0.5744451",
"0.5737736",
... | 0.6970629 | 0 |
Function to save the palindrome search result as a csv. | def write_palindromes_to_file(path, csv_name, results):
if not os.path.exists(path):
os.makedirs(path)
df = pd.DataFrame(results, columns=['length',
'start',
'probability',
'mismatches... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome(self):\n vas = []\n file = self.read1()\n print(file[0])\n for line in file:\n line = line.strip()\n string = re.sub(\"[^0-9a-zA-Z]\", \" \", line).split(\" \")\n for s_i in string:\n s_ii = s_i[::-1]\n if s_i... | [
"0.6158536",
"0.5577743",
"0.5539694",
"0.553265",
"0.55125475",
"0.5374812",
"0.5370445",
"0.53692037",
"0.5338849",
"0.53149337",
"0.52733535",
"0.5226261",
"0.5215528",
"0.5195561",
"0.51878613",
"0.5160146",
"0.5150842",
"0.5132658",
"0.5131876",
"0.5128219",
"0.5125109",... | 0.7444958 | 0 |
Function to search through a data set (list of list) if one of the palindromes sequence has insert in it another palindrome. For example, if M is the longer palindrome sequence, if the p start > m start and p end < m end, p is inside m. The output file should be a new data set containing only unique palindrome derived ... | def repeated_palindrome(palindromes_list):
# the list is ordered in the reversed form (long to short)
ordered_palindrome = sorted(palindromes_list)
longest_first = ordered_palindrome[::-1]
# initialize a new list to receive unique plaindromes data
pal_list = [longest_first[0]]
# the longest pali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_palindromes(self, start_file: str, result_file: str) -> list:\n input_words = self.read_file(start_file)\n result_words = []\n stack = ArrayStack()\n\n for word in input_words:\n for letter in word:\n stack.push(letter)\n\n reversed_line = '... | [
"0.69024855",
"0.6746088",
"0.64815366",
"0.6367615",
"0.6211623",
"0.6194972",
"0.61857194",
"0.61326253",
"0.61166674",
"0.6096614",
"0.6090969",
"0.60547453",
"0.60349464",
"0.6011474",
"0.59989303",
"0.59753597",
"0.5967636",
"0.5963775",
"0.5936155",
"0.5925398",
"0.5902... | 0.73361176 | 0 |
This is a function to return start position minus start positions in an ordered data set of identified palindromes. | def check_the_palindromes_starts(palindromes_list):
# to get all the start positions
starts = [(s[1]) for s in palindromes_list]
# all the data sorted
palin = palindromes_list[1:]
sorted(palin)
# the sorted function orders the list for low to high
longest_ordered = sorted(starts, reverse=Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome_itertive(a):\n # TODO make this less crappy\n start = 0 \n end = len(a) - 1\n while start != end:\n # print(end)\n # print('start: ', start, ' a: ', a[start])\n # print('end: ', end, ' a: ', a[end])\n if not a[start] == a[end]:\n return False\n ... | [
"0.6057061",
"0.6030277",
"0.59521663",
"0.59443873",
"0.5820138",
"0.5816679",
"0.5804056",
"0.57669723",
"0.5748433",
"0.57475626",
"0.5710381",
"0.5705939",
"0.5700604",
"0.56801945",
"0.5648704",
"0.56265986",
"0.5622517",
"0.56057376",
"0.5605318",
"0.5587142",
"0.556374... | 0.72034436 | 0 |
Function to clean up all umbigous bases in a sequence. Ambigous bases are bases that are not in the sequence alphabet, ie. 'ACGT' for DNA sequences. | def cleaning_ambiguous_bases(seq):
# compile the regex with all ambiguous bases
pat = re.compile(r'[NRYWXSKM]')
# look for the ambiguous bases and replace by
# nothing
return re.sub(pat, '', seq) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sequence_cleaner(sequence, alphabet):\n seq = sequence.upper()\n sequence = [base for base in seq if base in alphabet]\n return ''.join(sequence)",
"def check_and_clean_sequence(sequence, alphabet):\n if set(sequence).issubset(alphabet):\n return sequence\n else:\n return cleanin... | [
"0.61357856",
"0.60041034",
"0.5838772",
"0.55369747",
"0.5463635",
"0.5433621",
"0.534109",
"0.5335156",
"0.5331861",
"0.5317939",
"0.52726936",
"0.52646846",
"0.5252673",
"0.51944333",
"0.5191811",
"0.51877165",
"0.5157462",
"0.5120989",
"0.5086719",
"0.50287366",
"0.501451... | 0.72724897 | 0 |
Function to check and clean up all umbigous bases in a sequence. Ambigous bases are bases that are not in the sequence alphabet, ie. 'ACGT' for DNA sequences. | def check_and_clean_sequence(sequence, alphabet):
if set(sequence).issubset(alphabet):
return sequence
else:
return cleaning_ambiguous_bases(sequence) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleaning_ambiguous_bases(seq):\n # compile the regex with all ambiguous bases\n pat = re.compile(r'[NRYWXSKM]')\n # look for the ambiguous bases and replace by\n # nothing\n return re.sub(pat, '', seq)",
"def count_umbiguous_bases(sequence):\n sequence = sequence.upper()\n amb = ['N'... | [
"0.6972512",
"0.6083541",
"0.5664274",
"0.55122876",
"0.5495145",
"0.5406091",
"0.5340601",
"0.53405964",
"0.53322184",
"0.5290064",
"0.5243587",
"0.52224714",
"0.51917106",
"0.5164841",
"0.5138689",
"0.50656164",
"0.5061921",
"0.5047701",
"0.5016211",
"0.50158536",
"0.500681... | 0.6441113 | 1 |
Wraps the check fragment in the outer parts of the sql query | def _full_check_sql(self, sql: str) -> str:
return f"SELECT col_name, check_type, check_result FROM ({sql}) AS check_columns" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _valid_filter_query(self):\n if self._output_invalid_imeis:\n valid_filter_sql = sql.SQL('TRUE')\n else:\n valid_filter_sql = sql.SQL('is_valid IS TRUE')\n return valid_filter_sql",
"def test_if_paren_statement():\n r = convert_code(\n \"{if (foo and bar) ... | [
"0.5628021",
"0.5415898",
"0.5397555",
"0.5312858",
"0.5302598",
"0.5286318",
"0.52754784",
"0.5252579",
"0.52508163",
"0.520744",
"0.51931447",
"0.5180745",
"0.51778483",
"0.51662195",
"0.5128626",
"0.5119018",
"0.5098157",
"0.5095183",
"0.5057997",
"0.5057997",
"0.50473386"... | 0.6226931 | 0 |
Checks that the generated sql respects a templated partition clause | def test_sql_check_partition_clause_templating(self, conn_id):
operator = SQLTableCheckOperator(
task_id="test_task",
table="employees",
checks={"row_count_check": {"check_statement": "COUNT(*) = 5"}},
conn_id=conn_id,
partition_clause="employment_year... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _random_sample_for_partitioned_tables(self) -> Query:\n partition_field = self._partition_details[\"partition_field\"]\n col = self.table.__table__.c.get(partition_field.lower())\n col_type = None\n if col is not None:\n col_type = col.type\n if partition_field == ... | [
"0.65572757",
"0.5455361",
"0.5396073",
"0.535287",
"0.5346023",
"0.52282643",
"0.5199034",
"0.51658976",
"0.5140471",
"0.5028549",
"0.49780765",
"0.4906591",
"0.48571414",
"0.47534937",
"0.47362173",
"0.4730835",
"0.4704191",
"0.47004652",
"0.4684612",
"0.46640965",
"0.46412... | 0.73940617 | 0 |
Check if BranchSQLOperator throws an exception for unsupported connection type | def test_unsupported_conn_type(self):
op = BranchSQLOperator(
task_id="make_choice",
conn_id="redis_default",
sql="SELECT count(1) FROM INFORMATION_SCHEMA.TABLES",
follow_task_ids_if_true="branch_1",
follow_task_ids_if_false="branch_2",
dag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_conn(self):\n op = BranchSQLOperator(\n task_id=\"make_choice\",\n conn_id=\"invalid_connection\",\n sql=\"SELECT count(1) FROM INFORMATION_SCHEMA.TABLES\",\n follow_task_ids_if_true=\"branch_1\",\n follow_task_ids_if_false=\"branch_2\"... | [
"0.6958899",
"0.6256558",
"0.6233108",
"0.5780643",
"0.5682214",
"0.56752306",
"0.5596914",
"0.5594159",
"0.5581828",
"0.55458724",
"0.5538639",
"0.55344284",
"0.5532713",
"0.54795086",
"0.5462565",
"0.5447765",
"0.54015386",
"0.5363145",
"0.5348738",
"0.5261789",
"0.52582824... | 0.8031548 | 0 |
Check if BranchSQLOperator throws an exception for invalid connection | def test_invalid_conn(self):
op = BranchSQLOperator(
task_id="make_choice",
conn_id="invalid_connection",
sql="SELECT count(1) FROM INFORMATION_SCHEMA.TABLES",
follow_task_ids_if_true="branch_1",
follow_task_ids_if_false="branch_2",
dag=sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unsupported_conn_type(self):\n op = BranchSQLOperator(\n task_id=\"make_choice\",\n conn_id=\"redis_default\",\n sql=\"SELECT count(1) FROM INFORMATION_SCHEMA.TABLES\",\n follow_task_ids_if_true=\"branch_1\",\n follow_task_ids_if_false=\"branch... | [
"0.7339684",
"0.67935187",
"0.672039",
"0.658468",
"0.63629395",
"0.6320076",
"0.6312238",
"0.6206086",
"0.61220324",
"0.61099696",
"0.60807556",
"0.60751575",
"0.60306495",
"0.60255706",
"0.58591485",
"0.58430076",
"0.57226694",
"0.57224053",
"0.5707363",
"0.56728756",
"0.56... | 0.79077697 | 0 |
Check if BranchSQLOperator works with backend | def test_sql_branch_operator_mysql(self):
branch_op = BranchSQLOperator(
task_id="make_choice",
conn_id="mysql_default",
sql="SELECT 1",
follow_task_ids_if_true="branch_1",
follow_task_ids_if_false="branch_2",
dag=self.dag,
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sql_branch_operator_postgres(self):\n branch_op = BranchSQLOperator(\n task_id=\"make_choice\",\n conn_id=\"postgres_default\",\n sql=\"SELECT 1\",\n follow_task_ids_if_true=\"branch_1\",\n follow_task_ids_if_false=\"branch_2\",\n da... | [
"0.709817",
"0.63938904",
"0.58970475",
"0.58533704",
"0.57342464",
"0.5657157",
"0.56091696",
"0.55608296",
"0.55274713",
"0.5468663",
"0.5457718",
"0.538129",
"0.53299373",
"0.5242461",
"0.5170583",
"0.51125485",
"0.5051785",
"0.5049264",
"0.50373596",
"0.5036543",
"0.49722... | 0.6937743 | 1 |
Check if BranchSQLOperator works with backend | def test_sql_branch_operator_postgres(self):
branch_op = BranchSQLOperator(
task_id="make_choice",
conn_id="postgres_default",
sql="SELECT 1",
follow_task_ids_if_true="branch_1",
follow_task_ids_if_false="branch_2",
dag=self.dag,
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sql_branch_operator_mysql(self):\n branch_op = BranchSQLOperator(\n task_id=\"make_choice\",\n conn_id=\"mysql_default\",\n sql=\"SELECT 1\",\n follow_task_ids_if_true=\"branch_1\",\n follow_task_ids_if_false=\"branch_2\",\n dag=self... | [
"0.6937743",
"0.63938904",
"0.58970475",
"0.58533704",
"0.57342464",
"0.5657157",
"0.56091696",
"0.55608296",
"0.55274713",
"0.5468663",
"0.5457718",
"0.538129",
"0.53299373",
"0.5242461",
"0.5170583",
"0.51125485",
"0.5051785",
"0.5049264",
"0.50373596",
"0.5036543",
"0.4972... | 0.709817 | 0 |
Test SQL Branch with skipping all downstream dependencies | def test_with_skip_in_branch_downstream_dependencies(self, mock_get_db_hook):
branch_op = BranchSQLOperator(
task_id="make_choice",
conn_id="mysql_default",
sql="SELECT 1",
follow_task_ids_if_true="branch_1",
follow_task_ids_if_false="branch_2",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_with_skip_in_branch_downstream_dependencies2(self, mock_get_db_hook):\n branch_op = BranchSQLOperator(\n task_id=\"make_choice\",\n conn_id=\"mysql_default\",\n sql=\"SELECT 1\",\n follow_task_ids_if_true=\"branch_1\",\n follow_task_ids_if_fals... | [
"0.77353257",
"0.6849428",
"0.6762589",
"0.6694354",
"0.6585679",
"0.6435495",
"0.6368142",
"0.6346273",
"0.62660396",
"0.6240822",
"0.6154489",
"0.607924",
"0.59821784",
"0.58053684",
"0.57516813",
"0.57352877",
"0.57304096",
"0.5728055",
"0.5725766",
"0.57254946",
"0.568525... | 0.77809846 | 0 |
Create a connection with a server. Send the data from the client to the server and check if the connection is accepted before accessing it | def create_connection(self):
try:
# Turns the port into an integer.
self.port = int(self.port)
# The privileged port are between 1024 and 60000.
if self.port < 1024 or self.port > 60000:
raise ValueError("The port is not betwee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connectToServer(self):\n self.client = Client(base_url = self.server)\n self.ping()",
"def connect_to_server(self):\n\n try:\n client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n client.connect((self.hostname, self.port))\n return client\n ... | [
"0.73600185",
"0.7100143",
"0.701498",
"0.6990414",
"0.6946399",
"0.69457126",
"0.6896873",
"0.68900764",
"0.6880835",
"0.68647265",
"0.6862838",
"0.6828347",
"0.6762873",
"0.6746322",
"0.674184",
"0.66967577",
"0.66883373",
"0.66488475",
"0.6604633",
"0.6588412",
"0.65870297... | 0.7221236 | 1 |
Get average load stat from /proc/loadavg. | def load_stat():
loadavg = {}
f = open("/proc/loadavg")
con = f.read().split()
f.close()
loadavg['lavg_1'] = con[0]
loadavg['lavg_5'] = con[1]
loadavg['lavg_15'] = con[2]
loadavg['nr'] = con[3]
loadavg['last_pid'] = con[4]
return loadavg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getloadavg():\n global _loadavg_inititialized\n\n if not _loadavg_inititialized:\n cext.init_loadavg_counter()\n _loadavg_inititialized = True\n\n # Drop to 2 decimal points which is what Linux does\n raw_loads = cext.getloadavg()\n return tuple([round(load, 2) for load in raw_load... | [
"0.8758361",
"0.841387",
"0.8378472",
"0.8371394",
"0.8343031",
"0.80248725",
"0.7039417",
"0.6765554",
"0.65243626",
"0.6463336",
"0.64101344",
"0.6311138",
"0.62721884",
"0.6262719",
"0.62597936",
"0.6221697",
"0.6221697",
"0.6221329",
"0.6178771",
"0.6143471",
"0.6116354",... | 0.8684609 | 1 |
Retry Decorator. Realizar un retry de la funcion si esta levanta alguna de las ``exceptions``. Hace tantos retries como ``maxRetries``. | def retry(maxRetries, *exceptions):
def _doDecoration(fn):
def _doRetry(*args, **kwargs):
retries = 0
while retries <= maxRetries:
try:
return fn(*args, **kwargs)
except tuple(exceptions):
retries +=1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retry(func):\n # ... retry MAX_RETRIES times\n # ...\n # make sure you include this for testing:\n # except Exception as exc:\n # print(exc)\n # ...\n # and use wraps to preserve docstring\n #\n @wraps(func)\n def wrapper(*args, **kwargs):\n\n tries = MAX_RETRIES\n ... | [
"0.8104126",
"0.7775",
"0.7661286",
"0.7297725",
"0.72590345",
"0.72263867",
"0.7220899",
"0.7175091",
"0.7168709",
"0.7098994",
"0.7014514",
"0.7011338",
"0.6975068",
"0.69649476",
"0.6956976",
"0.6946955",
"0.6942677",
"0.68957996",
"0.68939567",
"0.68889207",
"0.6867125",
... | 0.83807915 | 0 |
Decorator para funciones con transparencia referncial. Implementa un cache de ``qty`` llamadas para evitar calculos repetidos. | def memo(qty):
def decorator(f):
decoratee = Memo(qty,f)
return functools.wraps(f)(decoratee)
return decorator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addqty(b, name, fn, *args, **kwargs):\n if b is None or brevity < b:\n with _timed_block(name, formatStr='{:45}', printer=printer, verbosity=2):\n qtys[name] = fn(*args, **kwargs)",
"def addqty(b, name, fn, *args, **kwargs):\n if b is None or brevity < b:\n ... | [
"0.559451",
"0.559451",
"0.5573915",
"0.5568411",
"0.5535107",
"0.55242866",
"0.550955",
"0.5381615",
"0.5359697",
"0.5303804",
"0.5300502",
"0.52436477",
"0.5218056",
"0.5205465",
"0.51786435",
"0.5163052",
"0.51593244",
"0.5126326",
"0.5122918",
"0.51178956",
"0.5104016",
... | 0.7298688 | 0 |
read the deCODE file and split into individual files per chrom | def split_decode_file():
# split files by chromosome
header = []
current_chrom = 'chr1'
# file_template = decode_folder + '/{}.deCODE_2019.GRCh38.txt'
file_template = decode_folder + '/{}.deCODE_2019_hg19.txt'
decode_file = decode_folder + '/aau1043_DataS3_hg19_liftOver.bed'
w = open(file_te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(infile_name):\n chr_list = [0]*13 \n for i in range(len(chr_list)):\n chr_list[i] = [] \n infile = open(infile_name)\n for line in infile:\n if line.startswith('SL2.40'):\n info = line.strip().split()\n chr = int(info[0][-2:])\n chr_list[chr]... | [
"0.5818746",
"0.56577337",
"0.5606158",
"0.5569912",
"0.543026",
"0.542189",
"0.5332967",
"0.52981675",
"0.52800643",
"0.5245522",
"0.51938415",
"0.5192011",
"0.51777303",
"0.51236606",
"0.51045394",
"0.5096848",
"0.5091337",
"0.50838816",
"0.50694305",
"0.50682366",
"0.50674... | 0.67987746 | 0 |
Tests registered class types (passable by reference and value). Also tests a moveonly class type. | def test_abstract_value_registered_class(self):
obj = MoveOnlyType(10)
self.assertEqual(
str(Value[MoveOnlyType]),
"<class 'pydrake.common.value.Value[MoveOnlyType]'>")
# This *always* clones `obj`.
value = Value[MoveOnlyType](obj)
self.assertTrue(value.ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_isclassinstance():\n class MockClass:\n pass\n\n # Since Python3, everything is a class, so this means nothing (?)\n assert isclassinstance(0)\n assert isclassinstance(1.0)\n assert isclassinstance(complex(2.0))\n assert isclassinstance('foo')\n assert isclassinstance([])\n ... | [
"0.6440121",
"0.62261176",
"0.6093001",
"0.6060876",
"0.604561",
"0.6029342",
"0.595637",
"0.58810997",
"0.5852991",
"0.58228475",
"0.57530355",
"0.5710559",
"0.5691547",
"0.5682141",
"0.5676183",
"0.56754434",
"0.56320673",
"0.5610011",
"0.55910206",
"0.5559114",
"0.555801",... | 0.63377374 | 1 |
Instantiates GameObjectFactory, the factory that will create all the game objects. | def create_factory() -> pygameng.GameObjectFactory:
from Assets.inventory import images, sounds, assets, game_types
factory = pygameng.GameObjectFactory(pygameng.ClassRegistrar.registry, images, sounds, assets, game_types)
factory.set_layer_manager_asset_name("LayerManager")
return factory | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_game(self):\n game = Game(self.data['gamename'])\n self.game = game\n return game",
"def create(game):\r\n ## Create Garbage\r\n game.garbage = deque([])\r\n\r\n ## Create Stars\r\n game.create_stars()\r\n\r\n ## Create Millenium Falcon\r\n ... | [
"0.5683385",
"0.56730527",
"0.56672084",
"0.564122",
"0.5577839",
"0.55421233",
"0.55357003",
"0.55088884",
"0.5471441",
"0.54373586",
"0.5369217",
"0.53011876",
"0.5292592",
"0.5270018",
"0.5170161",
"0.5158009",
"0.5140437",
"0.51247996",
"0.5097501",
"0.50773364",
"0.50667... | 0.740402 | 0 |
Return a vector of size self.n_voxels. See mode options below. | def get_feature_vector(self, mode="binary"):
voxel_n = np.ravel_multi_index([self.voxel_x, self.voxel_y, self.voxel_z], self.x_y_z)
if mode == "binary":
vector = np.zeros(self.n_voxels)
vector[np.unique(voxel_n)] = 1
vector = vector.reshape(self.x_y_z)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_feature_vector(self, mode=\"binary\"):\n vector = np.zeros(self.n_voxels)\n\n if mode == \"binary\":\n vector[np.unique(self.voxel_n)] = 1\n\n elif mode == \"density\":\n count = np.bincount(self.voxel_n)\n vector[:len(count)] = count\n vecto... | [
"0.717673",
"0.6309085",
"0.628692",
"0.62847066",
"0.6244491",
"0.6162953",
"0.6134086",
"0.60895526",
"0.60499966",
"0.60194033",
"0.6017152",
"0.6012891",
"0.5983854",
"0.59729743",
"0.59357184",
"0.59262997",
"0.5916878",
"0.5905484",
"0.5902124",
"0.588724",
"0.5847988",... | 0.65292823 | 1 |
Get valid, nonempty 26 neighbors of voxel. | def get_voxel_neighbors(self, voxel):
x, y, z = np.unravel_index(voxel, self.x_y_z)
valid_x = []
valid_y = []
valid_z = []
if x - 1 >= 0:
valid_x.append(x - 1)
if y - 1 >= 0:
valid_y.append(y - 1)
if z - 1 >= 0:
valid_z.append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_voxel_neighbors(self, voxel):\n\n x, y, z = np.unravel_index(voxel, self.x_y_z)\n\n valid_x = []\n valid_y = []\n valid_z = []\n if x - 1 >= 0:\n valid_x.append(x - 1)\n if y - 1 >= 0:\n valid_y.append(y - 1)\n if z - 1 >= 0:\n ... | [
"0.687631",
"0.6724855",
"0.67223924",
"0.6670258",
"0.65394425",
"0.6517443",
"0.6467586",
"0.64275324",
"0.64233154",
"0.6421244",
"0.64047986",
"0.6391682",
"0.6388574",
"0.6371847",
"0.63681686",
"0.6354173",
"0.63498",
"0.63498",
"0.63498",
"0.63498",
"0.63398826",
"0.... | 0.6917683 | 0 |
it'll call get_all_data from service module and return all students data | def get_all_data():
return jsonify(service.get_all_data()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_data(self):",
"def get_all_records(self, data: dict, execution_context: dict):",
"def test_get_Student_bulk(self):\n school_ids = self.create_School(2,20)\n url = '/students'\n for i in range(10):\n data = {'first_name': 'Poompatai', 'last_name': 'Puntitpong','age': 20... | [
"0.63158745",
"0.62640435",
"0.62553257",
"0.62480736",
"0.61972684",
"0.61808133",
"0.6172427",
"0.61494964",
"0.6140303",
"0.6039809",
"0.6035919",
"0.60292524",
"0.6018947",
"0.59919596",
"0.59866506",
"0.59833336",
"0.5977811",
"0.59730965",
"0.592698",
"0.58814895",
"0.5... | 0.6492461 | 0 |
Run through new_schm and add any fields not in old_schm to old_schm. | def merge_schemas(self, old_schm, new_schm):
old_schm_cols = [x['name'] for x in old_schm]
for col in new_schm:
if type(col) == dict:
if col['name'] not in old_schm_cols:
old_schm.append(col)
for count, old_col in enumerate(old_schm):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_from(self, src):\n changed = {}\n for name in self.action_fields:\n other_field = getattr(src, name)\n this_field = getattr(self, name)\n if other_field != this_field:\n changed[name] = other_field\n setattr(self, name, other_f... | [
"0.5547992",
"0.53283143",
"0.53074485",
"0.5118632",
"0.49806392",
"0.4959772",
"0.4932249",
"0.49296173",
"0.4907506",
"0.4893577",
"0.48828602",
"0.48637092",
"0.48500943",
"0.48333395",
"0.48257568",
"0.4819643",
"0.4781666",
"0.47804913",
"0.47772083",
"0.4759098",
"0.47... | 0.6495964 | 0 |
Write file at file_name to table in BQ. | def write_to_bq(self,
table_name,
file_name,
append=True,
ignore_unknown_values=False,
bq_schema_autodetect=False):
table_name = table_name.lower().replace("-","_")
self.log.info(f"Writing {table_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_table(table, file_path):\n\n\twith open(file_path, 'w') as file:\n\t\tfile.write(table)",
"def save(file, table):\n pq.write_table(pa.Table.from_pandas(table), file)",
"def write_to_file(self, filename: str) -> None:",
"def write_to(self, fname, **kwargs):\n data = self.to_Table()\n ... | [
"0.6389289",
"0.62776583",
"0.6185979",
"0.6152416",
"0.61514306",
"0.60884386",
"0.6057259",
"0.5896836",
"0.5782033",
"0.5767647",
"0.5767647",
"0.5727883",
"0.5715699",
"0.56989884",
"0.5688516",
"0.5665562",
"0.565316",
"0.5612624",
"0.5582769",
"0.5565674",
"0.55629915",... | 0.6649394 | 0 |
Takes start and end datetimes and chunks the period into ndays size chunks. | def chunk_date_range(self, start_datetime, end_datetime, chunk_size):
self.log.info(f'Chunking period {start_datetime} to {end_datetime} into chunks of {chunk_size} days.')
for n in range(int ((end_datetime - start_datetime).days) + 1):
if n/chunk_size == int(n/chunk_size):
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_periods(start, end):\n\n logging.debug(f'chunking {start} to {end}')\n # convert the strings to datetime objects\n #start = dt.datetime.strptime(''.join(start.rsplit(':', 1)), '%Y-%m-%dT%H:%M:%S-%z')\n start = dt.datetime.strptime(start, '%Y-%m-%dT%H:%M:%S-%z')\n logging.debug(f'start: {st... | [
"0.74561584",
"0.70724005",
"0.6633228",
"0.6588212",
"0.6577086",
"0.65028185",
"0.643334",
"0.6382789",
"0.6378288",
"0.6325229",
"0.6312387",
"0.62938607",
"0.62823457",
"0.62358534",
"0.616273",
"0.6017077",
"0.59950334",
"0.5977496",
"0.5964378",
"0.5950997",
"0.5935242"... | 0.78345835 | 0 |
Returns maximum value from date_column in table_name. | def find_last_entry(self, table_name, date_column):
query = f"SELECT MAX({date_column}) FROM `{self.dataset_id}.{table_name}`"
query_job = self.bq_client.query(query) # API request
rows = query_job.result()
latest_time = [x[0] for x in rows][0]
return latest_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max(self):\n max_value= self.df[self.col_name].max()\n return max_value",
"async def max(self, table_name: str, column: str, conditions_list=None):\n if conditions_list:\n conditions = LemkPgUtils.get_conditions(conditions_list)\n query = f\"\"\"SELECT MAX({column}) FRO... | [
"0.69734967",
"0.68731785",
"0.6581008",
"0.6453102",
"0.6329918",
"0.62211794",
"0.6203115",
"0.6109451",
"0.60852724",
"0.6030926",
"0.592045",
"0.5807638",
"0.57572854",
"0.57227606",
"0.5688055",
"0.5640436",
"0.55683875",
"0.5554176",
"0.5554176",
"0.5554019",
"0.5534208... | 0.7224291 | 0 |
Runs a query in BQ and retunrs the results in a list of rows. | def bq_query(self, query):
query_job = self.bq_client.query(query) # API request
rows = [x for x in query_job.result()]
return rows | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_query(conn, query):\n\tcur = conn.cursor()\n\tcur.execute(query)\n\trows = cur.fetchall()\n\treturn rows",
"def run_query(query):\r\n db = psycopg2.connect('dbname=' + database)\r\n connect = db.cursor()\r\n connect.execute(query)\r\n rows = connect.fetchall()\r\n db.close()\r\n return ... | [
"0.74091065",
"0.73635143",
"0.7329013",
"0.7272752",
"0.71248585",
"0.7106369",
"0.70463365",
"0.70437837",
"0.7036642",
"0.6965512",
"0.69410104",
"0.693591",
"0.68967617",
"0.68664765",
"0.6862096",
"0.68477184",
"0.680308",
"0.68021363",
"0.6753161",
"0.6746222",
"0.67208... | 0.7811319 | 0 |
Runs all keys in a JSON object (dict or list) through the given callback function. | def fix_json_keys(self, obj, callback):
if type(obj) == list:
newlist = []
for item in obj:
newlist.append(self.fix_json_keys(item, callback))
return newlist
elif type(obj) == dict:
newdict = {}
for item in list(obj):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterate(d, fun): # type: (Dict, Callable[[Any, Any], None]) -> None\n for key, value in d.items():\n if isinstance(value, dict):\n DictUtil.iterate(value, fun)\n else:\n fun(key, value)",
"def __call__(self, *args, **kwargs):\n for key, obj i... | [
"0.60165715",
"0.57527566",
"0.55811495",
"0.5573455",
"0.5379951",
"0.5370649",
"0.5307617",
"0.52369964",
"0.5205658",
"0.5186293",
"0.51724434",
"0.5159436",
"0.5126748",
"0.5125651",
"0.5117088",
"0.50605685",
"0.5046835",
"0.5046835",
"0.50238544",
"0.50214005",
"0.50214... | 0.654714 | 0 |
Runs all values in a JSON object (dict or list) through the given callback function. Callback should be passed two | def fix_json_values(self, obj, callback, **kwargs):
if type(obj) == list:
newlist = []
for item in obj:
newlist.append(self.fix_json_values(item, callback, **kwargs))
return newlist
elif type(obj) == dict:
newdict = {}
for item ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_apply(fragment, check_func, func):\n if check_func(fragment):\n return func(fragment)\n elif isinstance(fragment, list):\n output = []\n for val in fragment:\n output.append(json_apply(val, check_func, func))\n return output\n elif isinstance(fragment, dict)... | [
"0.6534004",
"0.59166056",
"0.58235997",
"0.5695522",
"0.5678162",
"0.5629116",
"0.5615373",
"0.56030566",
"0.54738176",
"0.54465544",
"0.54227227",
"0.53541183",
"0.5297419",
"0.5266667",
"0.5264149",
"0.52472883",
"0.52044153",
"0.5186965",
"0.51423436",
"0.5129454",
"0.511... | 0.64443946 | 1 |
Returns a query for copying and replacing a table, applying the given callback to each column name. | def copy_and_replace_keys(self, table, key_callback):
client = self.bq_client
t = client.get_table(table)
cross_joins = []
# begin query generation process
q = f'CREATE OR REPLACE TABLE `{table}` AS (\nSELECT \n'
for field in t.schema:
q += process_field(fie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_new_table(db_old, db_new, table, col_index, new_col_list, ord_users, ord_subs):\n con = lite.connect(db_old)\n with con:\n cur = con.cursor()\n cur.execute(\"SELECT * FROM \" + table)\n tuple_list = cur.fetchall()\n for i in range(0, len(new_col_list)):\n tuple_list[i] ... | [
"0.59699565",
"0.5824967",
"0.5479155",
"0.54488003",
"0.54385924",
"0.54055893",
"0.5390006",
"0.53809685",
"0.5363095",
"0.53458697",
"0.5302262",
"0.52874994",
"0.52289927",
"0.5214595",
"0.5214595",
"0.5214595",
"0.5214595",
"0.5191025",
"0.5183032",
"0.5167538",
"0.51456... | 0.6539468 | 0 |
Send test metric to AWS CloudWatch | def main():
logging.basicConfig(level=logging.DEBUG)
cloud_watch = create_cloud_watch(
'Test Namespace',
asynchronous=False,
buffered=False,
dummy=False,
dimensions={'By intent': 'Test'},
)
cloud_watch.log('awsme-test', {'By source': 'awsme'})
print('Successfu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postToCloudWatch(sServerId, sMetricName, sServerDesc, sStatus):\n import boto3.ec2\n if not hasattr(postToCloudWatch, 'oBoto'):\n postToCloudWatch.oBoto = boto3.client('cloudwatch',\n aws_access_key_id=getConfig('cloudwatch', 'access_id'),\n ... | [
"0.6268691",
"0.62427914",
"0.6162454",
"0.61112636",
"0.60867095",
"0.6058298",
"0.60395",
"0.59895533",
"0.59845847",
"0.5904876",
"0.5773967",
"0.57484984",
"0.569267",
"0.56479716",
"0.5644985",
"0.56444424",
"0.56369525",
"0.56129986",
"0.5581815",
"0.55798525",
"0.55467... | 0.72424513 | 0 |
parses through log files to extract marginal likelihood estimates from executing the variational inference algorithm on a dataset. | def parse_logs(files):
marginal_likelihood = []
for file in files:
handle = open(file,'r')
for line in handle:
if 'Marginal Likelihood' in line:
m = float(line.strip().split('=')[1])
marginal_likelihood.append(m)
break
handle.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_extract(log_info):\n \n #Handle file names, strings and open file-like objects equivalently\n with uber_open_rmode(log_info) as log_info:\n \n headers = []\n footers = []\n i = 0\n \n #for all lines in file/output\n for line in log_info:\n \n... | [
"0.6709856",
"0.6107463",
"0.58700055",
"0.58251566",
"0.55823094",
"0.5506087",
"0.5464955",
"0.54559237",
"0.5388074",
"0.537436",
"0.5313697",
"0.52944803",
"0.52933943",
"0.52919465",
"0.5281008",
"0.5272261",
"0.52709246",
"0.52665913",
"0.52410084",
"0.5238071",
"0.5233... | 0.7288729 | 0 |
Ensure n_fft, n_per_seg and n_overlap make sense. | def _check_nfft(n, n_fft, n_per_seg, n_overlap):
if n_per_seg is None and n_fft > n:
raise ValueError(
(
"If n_per_seg is None n_fft is not allowed to be > "
"n_times. If you want zero-padding, you have to set "
"n_per_seg to relevant length. Got n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _autocheck_dimensions(self):\n # W dimensions check list\n assert len(self.W.shape) == 2, f\"W shape should be (N, N) but is {self.W.shape}.\"\n assert self.W.shape[0] == self.W.shape[1], f\"W shape should be (N, N) but is {self.W.shape}.\"\n\n # Win dimensions check list\n a... | [
"0.5919392",
"0.5857666",
"0.5699962",
"0.5582914",
"0.551394",
"0.54537946",
"0.5436112",
"0.54184246",
"0.5386672",
"0.53664434",
"0.53493524",
"0.5337134",
"0.5311439",
"0.52793556",
"0.5267394",
"0.5254082",
"0.5248522",
"0.52285975",
"0.5204103",
"0.5197914",
"0.51861525... | 0.79668355 | 0 |
compute dev or test accuracy on a certain task | def get_accuracy(model, task, batchmanager, test_set=False):
model.eval()
count, num = 0., 0
batchmanager = batchmanager if isinstance(batchmanager, BatchManager) else batchmanager.batchmanagers[task]
iter = batchmanager.test_iter if test_set else batchmanager.dev_iter
with torch.no_grad():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(eval_ds, model, task):\n\n print('==========EVAL==========')\n # Testing contrastive accuracy\n if task['name'] == 'contrastive_accuracy':\n ds = eval_ds.map(data_utils.pretrain_preprocess)\n ds = ds.batch(128)\n test_contrast_acc = tf.keras.metrics.Accuracy(name='test_co... | [
"0.69914055",
"0.6827569",
"0.6770814",
"0.6744679",
"0.658327",
"0.6576183",
"0.6530896",
"0.6528073",
"0.64344484",
"0.6419894",
"0.6414318",
"0.641199",
"0.63928133",
"0.63615847",
"0.63476807",
"0.634563",
"0.6324",
"0.63181156",
"0.62964886",
"0.6295964",
"0.62817776",
... | 0.7175868 | 0 |
Given Card or View layers, convert the grid layers to a string | def convert_layers_to_string(layers: list) -> str:
string_conversion = ""
for layer in layers:
string_conversion += "\n" + "".join(layer)
return string_conversion | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cat_layer_dict_to_str(layer: dict, rows_per_column: int) -> str:\n\n rpc_str = \"Infinity\" if np.isinf(rows_per_column) else str(rows_per_column)\n layer_str = [\n \"const \" + layer[\"name\"],\n \" = L.gridLayer.tiledMarkers(\",\n \"{ \",\n 'tileURL:\"' + layer[\"directory\"... | [
"0.68149734",
"0.6398493",
"0.6249319",
"0.60937405",
"0.60690725",
"0.58461916",
"0.5807707",
"0.5799735",
"0.5788799",
"0.574172",
"0.5738138",
"0.57306874",
"0.5712747",
"0.5700559",
"0.56804615",
"0.567307",
"0.5638548",
"0.5636529",
"0.56099236",
"0.55986625",
"0.5596996... | 0.71344054 | 0 |
Parse a paper, save it to a local file and return the dblp key of the paper. Parses all properties as specified in `parse_properties.py`. | def get_paper(paper_container):
paper_type = list(paper_container.keys())[0]
dblp_paper = paper_container[paper_type]
dblp_key = dblp_paper["@key"].replace("/", "_")
paper = {"type": paper_type}
for prop in props:
# see if property exists and get the key
key = prop.key
if key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_paper(self, dblpkey, db):\n NS = {'tei': 'http://www.tei-c.org/ns/1.0'}\n try:\n xml=self.get_grobid_xml(dblpkey)\n result= grobid_mapping.tei_to_dict(xml)\n #\n #try:\n mongo_set_dict=dict()\n #print(\"results: {}\".format(result))\n ... | [
"0.5995921",
"0.58947307",
"0.5745195",
"0.5690165",
"0.5009332",
"0.49415568",
"0.4937688",
"0.49098766",
"0.48259768",
"0.48054695",
"0.48006597",
"0.47413546",
"0.47379598",
"0.47188556",
"0.47013918",
"0.46845803",
"0.46781558",
"0.46623516",
"0.46493664",
"0.46405235",
"... | 0.69308305 | 0 |
Parse the author with given id and all their papers and store them in the local database. | def get_autor_with_papers(author_id):
print("getting information from dblp about author {}".format(author_id))
data = get("https://dblp.org/pid/" + author_id + ".xml")["dblpperson"]
author_id = author_id.replace("/", "_")
author = {
"name": data["@name"],
"papers": [get_paper(paper_conta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape_author(self, author_name, min_len=0, max_len=9999):\n search = sc.search_author(author_name)\n author = next(search)\n sc.fill(author, sections=['publications'])\n print(author.keys())\n with open(\n 'loadings\\\\authors_papers\\\\{}.txt'.format(author_name)... | [
"0.61678886",
"0.57925886",
"0.5683686",
"0.5675467",
"0.5641725",
"0.5558396",
"0.5553384",
"0.5525774",
"0.5525136",
"0.54713714",
"0.5426789",
"0.53912705",
"0.5386846",
"0.53686625",
"0.5347512",
"0.53283745",
"0.5324974",
"0.5319414",
"0.52988154",
"0.5288916",
"0.527565... | 0.7115444 | 0 |
Get the paper with the given id from dblp. | def get_paper_by_id(paper_id):
dblp_key = paper_id.replace("/", "_")
if local.paper_exists(dblp_key):
return dblp_key
print("getting information from dblp about paper {}".format(paper_id))
data = get("https://dblp.org/rec/" + paper_id + ".xml")["dblp"]
return get_paper(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_publication_from_id_in_db(new_id: str) -> Union[None, Dict]:\n\n # db_publications = app.data.driver.db[\"publications\"]\n # try:\n # res = db_publications.find({\"id\": new_id}).limit(1).next()\n # except:\n # res = None\n # return res\n\n url = BaseConfig.DATAESR_PUBLICATIONS_... | [
"0.62456495",
"0.60768956",
"0.6007585",
"0.5988748",
"0.59750795",
"0.5948963",
"0.59419364",
"0.5877572",
"0.58755744",
"0.5851668",
"0.5780145",
"0.57121706",
"0.57081234",
"0.56810683",
"0.56097275",
"0.5588593",
"0.5541607",
"0.5515542",
"0.5512216",
"0.5502963",
"0.5487... | 0.8748886 | 0 |
Get venue information based on the venue id. | def get_venue(venue_id):
venue = venue_id.split("_")[1]
# search for exact venue id
print("getting information from dblp about venue {}".format(venue))
data = get("https://dblp.org/search/venue/api?h=1000&q=" + venue + "$")
data = data["result"]["hits"]
if int(data["@total"]) == 0:
dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_venue(venue_id):\n data = get_venue_by_id(venue_id).venue_details\n return render_template('pages/show_venue.html', venue=data)",
"async def lookup_ven(ven_name=None, ven_id=None):\n return {'ven_id': 'ven1234'}",
"def get_venue_and_events(cls, venue_id, db_session):\n logger.debug(\"%... | [
"0.77026415",
"0.7629306",
"0.7103243",
"0.65625393",
"0.652582",
"0.6364141",
"0.63093",
"0.6302329",
"0.629436",
"0.6290347",
"0.62509865",
"0.6245466",
"0.6217084",
"0.6169167",
"0.6144405",
"0.6015178",
"0.5862008",
"0.5855715",
"0.5842037",
"0.57189023",
"0.56969595",
... | 0.7865581 | 0 |
Parse all venues that appear in papers in the local database. | def get_venues():
papers = local.papers().values()
venues = {paper["venue"] for paper in papers if "venue" in paper}
for venue_id in venues:
file_name = local.file_name("venues", venue_id)
if os.path.isfile(file_name):
continue
venue = get_venue(venue_id)
if not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_venues():\n print(\"Fixing publication field\")\n\n # Load our database of venue names and keywords\n with open(resource_filename('fixmendeley', 'venues.json'), 'r') as f:\n venues = json.load(f)\n\n for venue in venues:\n # Build filter pattern for keywords\n ordered_keywo... | [
"0.6436121",
"0.54411566",
"0.5419386",
"0.5414439",
"0.5358596",
"0.53317887",
"0.52881116",
"0.52856827",
"0.51955736",
"0.5189618",
"0.51495665",
"0.5109944",
"0.51090825",
"0.5100515",
"0.5097937",
"0.5094935",
"0.49625772",
"0.48519638",
"0.4790151",
"0.4780734",
"0.4763... | 0.6916864 | 0 |
Writes in os.getenv('HOME') + os.sep + '/powersdata/simplots.xml' These are parameters that are specific to the type of lines, etc. | def xml_saveLineParameters(dparms,basename=None):
fname = ''
if os.name =='nt':
try:
os.mkdir('D:/powersdata')
except:
pass
if basename == None:
fname = 'd:/powersdata/simplots.parms'
else:
fname = basename
else:
if basename == None:
fname = os.getenv('HOME') + '/powersdata/simplots.par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_datafiles(shell,params_info):\n\n parameters_text_items = []\n for key,value in params_info.items():\n shell.write_file(value['path'], value['text'])\n parameters_text_items.append(\"%s:%s\" % (value['type'],value['path']))\n\n # generate the parameters file to feed into the url\n ... | [
"0.57784325",
"0.5466428",
"0.54199535",
"0.5338996",
"0.5319302",
"0.52897364",
"0.52734584",
"0.520129",
"0.5163601",
"0.5156643",
"0.5152206",
"0.5109015",
"0.5105658",
"0.50975186",
"0.5085345",
"0.50773543",
"0.50253874",
"0.4992709",
"0.49893114",
"0.49869478",
"0.49840... | 0.6829257 | 0 |
Collect parameters from self.myLineParmBtns and put them in self.lineParameters self.lineParmBtns.append([lbl,lnStyleOpts,lnClrBtn,markerOpts,markerColorBtn,lnWdOpts]) self.lineParameters.append([i+1, '', self.colors[k],lw,self.markerTypes[j], self.colors[k],mw]) | def handleApplyButton(self,save=1):
#self.faceColor = self.faceColorBtn['bg']
#self.borderColor = self.borderColorBtn['bg']
self.obj.showGrid = self.showGrid
self.obj.gridLineStyle = self.gridLineStyle
#self.obj.borderColor = self.borderColor
#self.obj.faceColor = self.obj.faceColor
self.obj.legend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_params(lw=1.5, universal_color=\"#262626\", fontsize=16):\n rc(\"font\", size=fontsize)\n rc(\"lines\", linewidth=lw, markeredgewidth=lw * 0.5)\n rc(\"patch\", linewidth=lw, edgecolor=\"#FAFAFA\")\n rc(\n \"axes\",\n linewidth=lw,\n edgecolor=universal_color,\n label... | [
"0.57280254",
"0.5546413",
"0.5510684",
"0.5442827",
"0.52763814",
"0.5265816",
"0.52513844",
"0.5206591",
"0.51973724",
"0.5193094",
"0.5166233",
"0.51613885",
"0.5127534",
"0.51055425",
"0.51003975",
"0.5092666",
"0.5092629",
"0.50905925",
"0.50885",
"0.50683045",
"0.505577... | 0.5729337 | 0 |
Create a package with the current pack_operation_ids of the picking that aren't yet in a pack. Used in the barcode scanner UI and the normal interface as well. operation_filter_ids is used by barcode scanner interface to specify a subset of operation to pack | def action_pack(self, cr, uid, picking_ids, operation_filter_ids=None, context=None):
if operation_filter_ids is None:
operation_filter_ids = []
stock_operation_obj = self.pool.get('stock.pack.operation')
package_obj = self.pool.get('stock.quant.package')
stock_move_obj = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_pack_ops(self, quants, forced_qties):\n valid_quants = quants.filtered(lambda quant: quant.qty > 0)\n _Mapping = namedtuple('Mapping', ('product', 'package', 'owner', 'location', 'location_dst_id','move_id'))\n all_products = valid_quants.mapped('product_id') | self.env['product.p... | [
"0.5840583",
"0.55044174",
"0.5431738",
"0.542185",
"0.53571826",
"0.52159303",
"0.51423734",
"0.5080695",
"0.5045913",
"0.499037",
"0.4984317",
"0.49737558",
"0.49271718",
"0.4918655",
"0.49071163",
"0.4905323",
"0.4889021",
"0.48848778",
"0.48737967",
"0.4859566",
"0.477815... | 0.73506504 | 0 |
Search for an operation with given 'domain' in a picking, if it exists increment the qty (+1) otherwise create it | def _search_and_increment(self, cr, uid, picking_id, domain, filter_visible=False, visible_op_ids=False, increment=True, context=None):
if context is None:
context = {}
# if current_package_id is given in the context, we increase the number of items in this package
package_clause = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_id(demand_array, old_iter, new_iter):\r\n #функция для первоначального добавления айдишника\r\n #используется в тех случаях, когда зафиксирована продажа,\r\n #но конкретно такого предмета еще нет в demand\r\n #adding item ID\r\n demand_array.append({\"item_id\": old_iter['item_id']})\r\n ... | [
"0.46932408",
"0.463366",
"0.46036744",
"0.4586839",
"0.4582527",
"0.45816582",
"0.45693213",
"0.45557344",
"0.44739816",
"0.44731164",
"0.44641668",
"0.4427717",
"0.44171816",
"0.44152266",
"0.43981063",
"0.43791568",
"0.43735072",
"0.43704206",
"0.4368647",
"0.43574724",
"0... | 0.6647632 | 0 |
Used by barcode interface to create a new lot and assign it to the operation | def create_and_assign_lot(self, cr, uid, id, name, context=None):
obj = self.browse(cr, uid, id, context)
product_id = obj.product_id.id
val = {'product_id': product_id}
new_lot_id = False
if name:
lots = self.pool.get('stock.production.lot').search(
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_so_pack_operation_lot(self, picking):\n StockProductionLot = self.env['stock.production.lot']\n sale_line_obj = self.env['sale.order.line']\n has_wrong_lots = False\n for del_move in picking.move_lines:\n del_move.move_line_ids.unlink()\n for move in picking.mo... | [
"0.6130646",
"0.59913564",
"0.59538823",
"0.58391386",
"0.57997227",
"0.5788583",
"0.5747826",
"0.5601751",
"0.5560619",
"0.5560485",
"0.554676",
"0.5544482",
"0.55205005",
"0.5441034",
"0.5437646",
"0.5388805",
"0.53761446",
"0.5363241",
"0.53601325",
"0.5335545",
"0.5300332... | 0.6627396 | 0 |
Check ~/.planning.domains exists, and is not a file | def checkExists(pd_dir):
if os.path.isfile(pd_dir):
print("Fatal error: need to store settings in {0}, but there is a file with that name".format(pd_dir))
exit(1)
if not os.path.isdir(pd_dir):
print("""
== Pre-release client for planning.domains ==
This is pre-release soft... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkDNSInstallDir(self):\n try:\n dnsDir = self.getDNSInstallDir()\n except IOError:\n dnsDir = None\n if not dnsDir:\n fatal_error('no valid DNSInstallDir found, please repair in Config program or Configuration GUI')\n pass",
"def server_has_non_... | [
"0.5942702",
"0.5712539",
"0.56750417",
"0.5662834",
"0.5592347",
"0.55438226",
"0.5541979",
"0.5524914",
"0.5514341",
"0.549784",
"0.54763305",
"0.5436257",
"0.5427554",
"0.5411611",
"0.540421",
"0.5377908",
"0.5346322",
"0.53399336",
"0.53397995",
"0.5331371",
"0.5325626",
... | 0.605463 | 0 |
Show an object of type sub that matches the id arg. | def show(sub, arg):
arg = int(arg)
if sub == 'collection':
res = api.get_collection(arg)
elif sub == 'domain':
res = api.get_domain(arg)
elif sub == 'problem':
res = api.get_problem(arg)
elif sub == 'plan':
res = api.get_plan(arg)
else:
print("Error: Unr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info(self, id):",
"def ShowObject(object_id):\n return ShowObjects(object_id)==1",
"def get_object(id):",
"def show(self,id, **kw):\n r = validate_get(id)\n return dict(name=name, namepl=namepl, record=r)",
"def get_object(self, id, **args):\n return self.request(\"{0}/{1}\".for... | [
"0.6170138",
"0.61571515",
"0.6098876",
"0.59050685",
"0.5701581",
"0.5683588",
"0.5617816",
"0.5617816",
"0.5584747",
"0.5561041",
"0.5561041",
"0.5537727",
"0.5529539",
"0.5524066",
"0.55181515",
"0.5504681",
"0.5497895",
"0.5497895",
"0.5497895",
"0.5497895",
"0.5454298",
... | 0.6315935 | 0 |
Average a scalar over the nodes if we are in distributed training. We use this for distributed evaluation. | def average_distributed_scalar(scalar, args):
if args.local_rank == -1:
return scalar
scalar_t = torch.tensor(scalar, dtype=torch.float, device=args.device) / torch.distributed.get_world_size()
torch.distributed.all_reduce(scalar_t, op=torch.distributed.ReduceOp.SUM)
return scalar_t.item() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute(self, node, input_vals):\r\n assert len(input_vals) == 1\r\n if node.const_attr!=None:\r\n return np.array(np.mean(input_vals[0], node.const_attr))\r\n else:\r\n return np.array(np.mean(input_vals[0]))",
"def mean(self):\n return self.sum / self.sum_w... | [
"0.6868551",
"0.66323113",
"0.65663683",
"0.6506279",
"0.6506279",
"0.64611053",
"0.64454865",
"0.6427829",
"0.6404392",
"0.6344673",
"0.63312757",
"0.6280638",
"0.6280638",
"0.6280638",
"0.6280638",
"0.6280638",
"0.6259122",
"0.62401956",
"0.6236642",
"0.62141514",
"0.619560... | 0.7250768 | 0 |
Add special tokens to the tokenizer and the model if they have not already been added. | def add_special_tokens_(model, tokenizer, update_model=True):
orig_num_tokens = len(tokenizer)
num_added_tokens = tokenizer.add_special_tokens(ATTR_TO_SPECIAL_TOKEN) # doesn't add if they are already there
#print("coab::",len(tokenizer.vocab))
if (num_added_tokens > 0 and update_model):
model.en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_special_tokens_(model, tokenizer):\n orig_num_tokens = len(tokenizer.encoder)\n num_added_tokens = tokenizer.add_special_tokens(ATTR_TO_SPECIAL_TOKEN) # doesn't add if they are already there\n if num_added_tokens > 0:\n model.resize_token_embeddings(new_num_tokens=orig_num_tokens + num_adde... | [
"0.7694922",
"0.6634113",
"0.6582269",
"0.64322776",
"0.64064205",
"0.6263845",
"0.5975597",
"0.59564984",
"0.59484524",
"0.5922455",
"0.5899315",
"0.58885926",
"0.5843837",
"0.5829498",
"0.5825403",
"0.57836765",
"0.575896",
"0.5743932",
"0.57355046",
"0.5733764",
"0.5721004... | 0.7371381 | 1 |
Equal comparison Two pilots are defined equal, if and only if their first and last names are equal. | def __eq__(self, other):
return self.last_name == other.last_name and self.first_name == other.first_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other: 'Pair') -> bool:\n return self.names == other.names",
"def equal(self, other):\n return self.slots == other.slots",
"def same_player(self, other):\n return self.name == other.name \\\n and self.color == other.color",
"def is_equal_to(self, another_labyr... | [
"0.6627373",
"0.63435644",
"0.6153186",
"0.6149348",
"0.6088684",
"0.602681",
"0.6011238",
"0.5975594",
"0.5950189",
"0.5947117",
"0.59188914",
"0.58683014",
"0.58377177",
"0.5823649",
"0.58202285",
"0.58163077",
"0.5816294",
"0.5756619",
"0.5748799",
"0.5720211",
"0.5704944"... | 0.6386746 | 1 |
Less comparison by last name and first name | def __lt__(self, other):
return( (self.last_name, self.first_name)
< (other.last_name, other.first_name) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n return self.first_name < other.first_name",
"def __lt__(self, other):\n if self.last_name == other.last_name:\n return self.name < other.name\n return self.last_name < other.last_name",
"def __lt__(self, other):\r\n if self.lastName == other.las... | [
"0.75604546",
"0.742028",
"0.7111031",
"0.7088123",
"0.7088123",
"0.7088123",
"0.7088123",
"0.7088123",
"0.67837274",
"0.6554892",
"0.64998496",
"0.6478273",
"0.64664423",
"0.6444121",
"0.6444121",
"0.6406543",
"0.63803595",
"0.6337073",
"0.63360804",
"0.62972367",
"0.6284565... | 0.7713619 | 0 |
Generate default user name of the form '``first_name``.\ ``last_name``' | def generateUsername(self):
retval= "{0}.{1}".format( self.first_name.split()[0].lower(),
self.last_name.split()[-1].lower() )
return toAscii(retval) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_name(self):\n full_name = f'{self.f_name} {self.l_name}'\n return full_name",
"def get_short_name(self):\n return f\"{self.first_name} {self.last_name[:1]}\" if self.first_name else self.username",
"def get_full_name(self):\n full_name = f'{self.first_name} {self.last_n... | [
"0.78407025",
"0.77698755",
"0.7629761",
"0.7615957",
"0.75311977",
"0.75153714",
"0.73975754",
"0.7373969",
"0.73408616",
"0.73127294",
"0.72625107",
"0.72523916",
"0.7252209",
"0.7217108",
"0.7209429",
"0.71537197",
"0.7150995",
"0.7134499",
"0.7072816",
"0.70415425",
"0.70... | 0.8386236 | 0 |
Gets field from comment. Comment fields are strings of the format '``key`` = ``value``' | def getCommentField(self, key):
if not self.comments:
return None
pattern= re.compile(key + r"\s*=\s*'(.+)'")
match= pattern.search(self.comments)
if not match:
return None
return match.group(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getfield(value, arg):\n #import pdb; pdb.set_trace()\n if hasattr(value, \"fields\"):\n fields = getattr(value, \"fields\")\n if str(arg) in fields:\n return str(fields[str(arg)])",
"def get_field(fieldname):\n m = re.search(\"(^|\\\\n)%s\\\\s(.*?)\\n\" % fieldname, ... | [
"0.60989666",
"0.60174024",
"0.59364283",
"0.5774984",
"0.5718621",
"0.5715055",
"0.57144874",
"0.5686602",
"0.5627017",
"0.56223005",
"0.56118613",
"0.5563498",
"0.55319387",
"0.55255896",
"0.5520792",
"0.5506498",
"0.5476555",
"0.5475833",
"0.5456248",
"0.5456248",
"0.54253... | 0.76645404 | 0 |
Set comment field. Comment fields are strings of the format '``key`` = ``value``' | def setCommentField(self, key, value):
if not key:
raise KeyError()
comment= ""
if value:
comment= "{0}='{1}'".format(key, value)
if not self.comments:
self.comments= comment
return
pattern= re.com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_comment(self, comment):\n self.comment_text = str(comment)",
"def set_comment(self, comment):\n\t\tself.comment_ = comment",
"def comment(self, value: str):\n self._comment = value",
"def comment(self, comment):\n\n self.logger.debug(\"In 'comment' setter.\")\n\n self._com... | [
"0.7819822",
"0.7701546",
"0.75566393",
"0.7124005",
"0.7091031",
"0.7003119",
"0.7003119",
"0.69408345",
"0.69243276",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6875771",
"0.6860937",
"0.67275405",... | 0.79708326 | 0 |
A function to remove beats that fall beyond the the bounds of the phrase | def trim_timings(phrase_length, timings):
extra_hits = np.argwhere(np.cumsum(timings) > int(phrase_length)).ravel()
if len(extra_hits) != 0:
all_to_end = np.min(extra_hits)
del timings[all_to_end:]
return timings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune(self, upper, lower):\n # max_count = sorted([self.counts[key] for key in self.counts.keys()])[::-1][upper]\n max_count = upper\n\n print('Removed all words that occur less than {} times and more than {} times'.format(lower, upper))\n for i, doc in enumerate(self.docs):\n ... | [
"0.60071754",
"0.5904355",
"0.5902717",
"0.58244514",
"0.58123296",
"0.57975394",
"0.5666994",
"0.5652277",
"0.56520176",
"0.56004584",
"0.5580919",
"0.5541433",
"0.55284405",
"0.5460393",
"0.5398652",
"0.53874314",
"0.5385925",
"0.53792715",
"0.5347592",
"0.5344827",
"0.5343... | 0.593318 | 1 |
compute overall precision, recall and FB1 (default values are 0.0) if percent is True, return 100 original decimal value | def calcMetrics(TP, P, T, percent=True):
precision = TP / P if P else 0
recall = TP / T if T else 0
FB1 = 2 * precision * recall / (precision + recall) if precision + recall else 0
if percent:
return 100 * precision, 100 * recall, 100 * FB1
else:
return precision, recall, FB1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_precision(self):\r\n return round(f1_score(self.actual, self.predicted),2)",
"def f1_score(precision, recall):\n if precision + recall == 0:\n return 0\n return 2 * precision * recall / (precision + recall)",
"def get_real_percent(self):\n if not (self.votes and self.score):\n ... | [
"0.70171875",
"0.6893242",
"0.6893009",
"0.68919694",
"0.68863714",
"0.68086755",
"0.6713527",
"0.6683036",
"0.6610096",
"0.65929633",
"0.657033",
"0.6569705",
"0.65341216",
"0.65330094",
"0.648091",
"0.6473839",
"0.6464411",
"0.6462978",
"0.64594454",
"0.6454277",
"0.6442183... | 0.7153003 | 0 |
Split chunk tag into IOB tag and chunk type; return (iob_tag, chunk_type) | def splitTag(chunkTag, oTag = "O", raw = False):
if chunkTag == "O" or chunkTag == oTag:
tag, type_ = "O", None
elif raw:
tag, type_ = "B", chunkTag
else:
try:
# split on first hyphen, allowing hyphen in type
tag, type_ = chunkTag.split('-', 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_tag(chunk_tag):\n if chunk_tag == 'O':\n return ('O', None)\n return chunk_tag.split('-', maxsplit=1)",
"def split_chunk(chunk):\n if not sentinel_d.get(\"repatt2\"):\n patt2 = r\"<(t(?:ag)?)\\s*([^>]*)>([^>]*)</t(?:ag)?>\"\n sentinel_d.update(repatt2=re.compile(patt2, fla... | [
"0.713737",
"0.69007325",
"0.6209524",
"0.60984844",
"0.6082831",
"0.58778906",
"0.57449347",
"0.5672539",
"0.5591809",
"0.55803895",
"0.5574942",
"0.5501076",
"0.547124",
"0.5446082",
"0.5443957",
"0.54422784",
"0.5439464",
"0.5370299",
"0.53504926",
"0.5332012",
"0.53270584... | 0.7466575 | 0 |
Process input in given format and count chunks using the last two columns; return correctChunk, foundGuessed, foundCorrect, correctTags, tokenCounter | def countChunks(args,inputFile):
boundary = "-X-" # sentence boundary
# delimiter = args.delimiter
# raw = args.raw
# oTag = args.oTag
#inputFile=args.inputFile
delimiter = args["delimiter"]
raw = args["raw"]
oTag = args["oTag"]
fileIterator=open(inputFile)
co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_chunks(self) -> int:",
"def mistake_counts(filename, statsfile):\n #The data dat will be used comes from the mistakes_dataframe-function.\n data = mistakes_dataframe(filename, statsfile)[0]\n\n #For all the types of information, a list will be made, for every \n #false positive and negati... | [
"0.577075",
"0.5582318",
"0.5535175",
"0.54834586",
"0.5468226",
"0.53948593",
"0.5361013",
"0.53123224",
"0.53054005",
"0.5288631",
"0.5288206",
"0.5273744",
"0.5239814",
"0.5214098",
"0.5131974",
"0.51176083",
"0.5099485",
"0.509863",
"0.5094825",
"0.50480515",
"0.50278896"... | 0.75956017 | 0 |
Creates index for a dictionary index file is created in form of dictionary object and creates a file by name dictfile.index with contents in following format A=1 B=2000 .... (For eg. en_US.index) | def create_index(self, dictfile):
self.dictionary_file = dictfile
self.index_file = os.path.join(dictfile.split(".")[0] + ".index")
self.fp = codecs.open(self.dictionary_file, "r", encoding="utf-8")
self.op = codecs.open(self.index_file, "w", encoding="utf-8")
# loop untill en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_index(self, filename, tri):\n self.index = {'name': filename, \"bi\": {}}\n if tri:\n self.index[\"tri\"] = {}\n fichero = open(filename, 'r').read()\n fichero = fichero.replace(\";\",\".\")\n fichero = fichero.replace(\"\\n\\n\",\".\")\n fichero = ... | [
"0.7095544",
"0.7029676",
"0.7002316",
"0.67770976",
"0.67745614",
"0.67199093",
"0.66818196",
"0.6662767",
"0.6655858",
"0.6651296",
"0.6531438",
"0.6508011",
"0.6504394",
"0.6454348",
"0.6287616",
"0.62688965",
"0.6261858",
"0.6243503",
"0.6228945",
"0.6199209",
"0.61885613... | 0.8214013 | 0 |
This function reads the index file and loads the content into a dictionary object. If file doesn't exist this will create the index file and then reads it. | def load_index(self, dictfile):
self.index_file = os.path.join(self.path,
dictfile.split(".")[0] + ".index")
try:
self.fp = codecs.open(self.index_file, "r",
encoding="utf-8", errors="ignore")
except IOError:
self.create_index(dictfile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_index(index_file):\n index_dict = {}\n with open(index_file) as f:\n for line in f:\n title, path = line.strip().split()\n index_dict[title] = path\n return index_dict",
"def get_index(self):\n with open(self.index_path, \"r\") as f:\n return json.... | [
"0.79177237",
"0.6884474",
"0.6872445",
"0.68435687",
"0.67888933",
"0.6783612",
"0.6745491",
"0.673843",
"0.66856533",
"0.6683366",
"0.66697305",
"0.6482477",
"0.64072615",
"0.64012605",
"0.6378176",
"0.6347014",
"0.6316539",
"0.6304061",
"0.6221651",
"0.6221545",
"0.6154775... | 0.7745487 | 1 |
Returns a normalized domain on rating.rating to select the records to include in count, avg, ... computation of current model. | def _rating_domain(self):
return ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', self.ids), ('consumed', '=', True), ('website_published', '=', True)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_rating(self):\n queryset = ArticleRating.objects.filter(article_id=self.get_object())\n return queryset.aggregate(Avg('rate')).get(\"rate__avg\")",
"def average_ratings(self):\n return get_average_rate(\n model=Rating,\n article=self.pk\n )",
"d... | [
"0.55893254",
"0.55250335",
"0.54229623",
"0.53542584",
"0.533851",
"0.53040886",
"0.5296353",
"0.5279337",
"0.5270756",
"0.52280354",
"0.5141364",
"0.5106121",
"0.5101962",
"0.5076106",
"0.5063996",
"0.5055503",
"0.50505793",
"0.50104856",
"0.50104856",
"0.4995368",
"0.49942... | 0.6925912 | 0 |
Creates an empty list and then appends a random number to the list 'count' number of times. A CPUheavy operation! | def list_append(count, id, out_list):
for i in range(count):
out_list.append(random.random()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newList(self):\n lst = []\n count = 0\n while count < 52:\n lst.append(randint(1, 1500))\n count += 1\n return lst",
"def create_list(self):\n\n\t\trandom_list = random.sample(range(0, 500), 10)\n\n\t\treturn random_list",
"def populate_empty_list():\n\n ... | [
"0.7182441",
"0.70022523",
"0.6790341",
"0.6682189",
"0.6658717",
"0.6651417",
"0.6616092",
"0.65375924",
"0.64722615",
"0.6330074",
"0.6265442",
"0.62584394",
"0.6244736",
"0.6236094",
"0.6146634",
"0.61383426",
"0.6136133",
"0.61209166",
"0.6118684",
"0.61057687",
"0.602213... | 0.7692458 | 0 |
Get the output of conv layer. | def conv_output(model, layer_name, img):
# this is the placeholder for the input images
input_img = model.input
try:
# this is the placeholder for the conv output
out_conv = model.get_layer(layer_name).output
except:
raise Exception('Not layer named {}!'.format(layer_name))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_output(self, **kwargs):\n with tf.variable_scope(self.layer_scope):\n return self.out",
"def get_output(self, prev_layers=None, **kwargs):\n if prev_layers is None:\n prev_layers = list()\n if self not in prev_layers:\n prev_layers += [self]\n ... | [
"0.74672776",
"0.6889656",
"0.67878616",
"0.6749953",
"0.67351806",
"0.6727751",
"0.6727751",
"0.6727751",
"0.6722555",
"0.6673674",
"0.66717416",
"0.65963495",
"0.6580103",
"0.6580103",
"0.65754825",
"0.65445495",
"0.64597344",
"0.6435824",
"0.63882506",
"0.6363812",
"0.6345... | 0.78071994 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.