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 |
|---|---|---|---|---|---|---|
Returns the mediant (n1+n2)/(d1+d2) of the two fractions, represented as a 2tuple (n,d). frac1 and frac2 are given as 2tuples (n,d) | def mediant(frac1, frac2):
# print "%s m %s = %s" % (frac1, frac2, (frac1[0]+frac2[0], frac1[1]+frac2[1])
return (frac1[0]+frac2[0], frac1[1]+frac2[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify_fraction(a, b):\n c = gcd(a, b)\n return a // c, b // c",
"def diff_frac(data_1, data_2):\n\n frac_1 = np.sum(data_1) / len(data_1)\n frac_2 = np.sum(data_2) / len(data_2)\n\n return frac_1 - frac_2",
"def fraction_to_proper_fraction(rational):\n assert isinstance(rational, Fract... | [
"0.62101525",
"0.5934107",
"0.58908975",
"0.58583033",
"0.57450724",
"0.57265115",
"0.57136464",
"0.56596386",
"0.5658014",
"0.56181496",
"0.5612167",
"0.5595354",
"0.55772436",
"0.5576887",
"0.55666596",
"0.5561884",
"0.5558363",
"0.5557005",
"0.5555802",
"0.5551015",
"0.554... | 0.80688035 | 0 |
Return True if frac1 is greater than frac2. | def compare_fracs(frac1, frac2):
return frac1[0]*frac2[1] > frac2[0]*frac1[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gt__(self, frac):\n\n if isinstance(frac,Fraction):\n if (self.numerator ==0 and self.denominator==0) or (frac.numerator ==0 and frac.denominator==0):\n return self.inf_size > frac.inf_size\n if self.inf_size!=0 or frac.inf_size!= 0:\n return self.in... | [
"0.7365881",
"0.7272041",
"0.7179911",
"0.7146161",
"0.70425826",
"0.7039962",
"0.70348424",
"0.7027964",
"0.6976749",
"0.6785346",
"0.6748767",
"0.6638374",
"0.662061",
"0.6575495",
"0.6486706",
"0.6460307",
"0.64515734",
"0.64330274",
"0.6383279",
"0.63759863",
"0.63638836"... | 0.75417024 | 0 |
returns the existing fraction immediately to the left of this one | def get_left_frac(self):
if self.parent == None:
# if this is the root node
return (0,1)
elif self.is_left_child:
# if the left side, run up the tree until we find a right child
return self.parent.get_left_frac()
else:
# if right child, just return the fraction above it
return self.parent.frac | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __pos__( self ):\r\n\t\treturn fraction( self )",
"def inverse( self ):\r\n\t\treturn fraction( self.denominator, self.numerator )",
"def reduce(self):\n import math\n g = math.gcd(self.num, self.den)\n return Fraction(self.num//g, self.den//g)",
"def numerator(self):\n return... | [
"0.6986293",
"0.6574903",
"0.6369118",
"0.6360639",
"0.63306767",
"0.63286066",
"0.6244909",
"0.62005043",
"0.618055",
"0.61376506",
"0.60833395",
"0.6046018",
"0.60386914",
"0.6024639",
"0.6022832",
"0.5980461",
"0.5970324",
"0.5944058",
"0.59315735",
"0.5909025",
"0.5904262... | 0.7014593 | 0 |
returns the fraction immediately to the right of this one | def get_right_frac(self):
if self.parent == None:
# if this is the root node
return (1,0)
elif self.is_left_child:
# if the left side, just return the fraction above it
return self.parent.frac
else:
# if right child, run up the tree til we find a left child
return self.parent.get_right_frac() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __pos__( self ):\r\n\t\treturn fraction( self )",
"def denominator(self):\n return 1",
"def fractionPassing(self):\n return self.cut.entries / self.entries",
"def reciprocal(self):\n return Rational(self.denominator, self.numerator)",
"def inverse( self ):\r\n\t\treturn fraction( self.... | [
"0.7226107",
"0.69381106",
"0.69352823",
"0.69166285",
"0.6860141",
"0.68463516",
"0.6796122",
"0.6757292",
"0.661353",
"0.6584862",
"0.6569921",
"0.6569921",
"0.6495624",
"0.6387157",
"0.6384618",
"0.63573",
"0.6352741",
"0.6351452",
"0.6347366",
"0.63327",
"0.6324134",
"0... | 0.70297647 | 1 |
Populates self.left, self.right with the proper child nodes. If max_denom is given, the children also generate their nodes until the maximum denominator is reached. While in max_denom mode, all created nodes will be <1, otherwise the tree blows up to infinity. If max_depth is given, it will generate that many layers of... | def gen_children(self, max_denom=None, max_depth=None, current_depth=0):
left_child_frac = mediant(self.frac, self.get_left_frac() )
right_child_frac = mediant(self.frac, self.get_right_frac())
# print "%s generating children %s and %s" % (self.frac, left_child_frac, right_child_frac)
if max_denom != None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_tree(self, max_depth = None):\n\n if max_depth is None:\n max_depth = self.tree.max_depth\n else:\n max_depth -= 1\n if max_depth == 0:\n return\n self.generate_children()\n if self.tree.remove:\n os.unlink(self.sou... | [
"0.665115",
"0.5866646",
"0.5856637",
"0.57829106",
"0.56562775",
"0.5619012",
"0.54160964",
"0.5317201",
"0.5247463",
"0.518805",
"0.5149137",
"0.51216483",
"0.51197636",
"0.49725723",
"0.49714312",
"0.4908645",
"0.4853916",
"0.48523086",
"0.48383847",
"0.48062086",
"0.48059... | 0.79430693 | 0 |
Can be called recursively. Will return a list, sorted L2G, of the 2tuple fractions below in the tree. If max_depth and current_depth given, will return the row of the tree at a certain depth. Depth is indexed from 0; ie the 1/1 node has depth 0. Otherwise, will return the entire tree with no divisions. External calls s... | def get_tree_below(self, max_depth=None, current_depth=0):
tree_list = []
if max_depth == None:
# if we are not returning a row.
if self.left_child != None:
# if this is not the base of the tree
tree_list = self.left_child.get_tree_below()
tree_list.append(self.frac)
tree_list = tree_list + se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _new_depth(self, node, curr_depth):\n right = curr_depth\n left = curr_depth\n if node._rkid:\n right = self._new_depth(node._rkid, curr_depth + 1)\n if node._lkid:\n left = self._new_depth(node._lkid, curr_depth + 1)\n if right > left:\n retu... | [
"0.5385036",
"0.53593683",
"0.52864254",
"0.52792823",
"0.5208625",
"0.51871115",
"0.5185997",
"0.5131725",
"0.5105242",
"0.50936437",
"0.5092283",
"0.50806874",
"0.50686944",
"0.5068055",
"0.5050487",
"0.5041063",
"0.5021816",
"0.5019684",
"0.5018557",
"0.5002453",
"0.498524... | 0.7730652 | 0 |
Returns the node furthest down the tree to the left. This one if it doesn't have a left child. | def get_leftmost_child(self):
if self.left_child == None:
return self
else:
return self.left_child.get_leftmost_child() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_left_node(self):\n\t\tif self.left_child == None:\n\t\t\t# if we are at the end of a branch\n\t\t\tlowest_right_parent = self.get_lowest_right_parent()\n\t\t\tif lowest_right_parent.parent == None:\n\t\t\t\t# if this was called from left edge of the tree\n\t\t\t\t# the lowest right parent is the 1/1 node\n... | [
"0.78348905",
"0.7655214",
"0.76067376",
"0.7596791",
"0.7550032",
"0.7471591",
"0.73937553",
"0.7313952",
"0.72924364",
"0.72379893",
"0.7209601",
"0.7154187",
"0.71160156",
"0.7078668",
"0.70374316",
"0.70040953",
"0.70040953",
"0.7002512",
"0.69932324",
"0.69902736",
"0.69... | 0.80510676 | 0 |
Returns the node furthest down the tree to the right. This one if it doesn't have a right child. | def get_rightmost_child(self):
if self.right_child == None:
return self
else:
return self.right_child.get_rightmost_child() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_right_node(self):\n\t\tif self.right_child == None:\n\t\t\t# if we are at the end of a branch\n\t\t\tlowest_left_parent = self.get_lowest_left_parent()\n\t\t\tif lowest_left_parent.parent == None:\n\t\t\t\t# if this was called from right edge of the tree\n\t\t\t\t# the lowest left parent is the 1/1 node\n\... | [
"0.796525",
"0.75402415",
"0.7468751",
"0.74566835",
"0.73042727",
"0.7213994",
"0.71809685",
"0.7162541",
"0.7078963",
"0.70587814",
"0.7023619",
"0.69773936",
"0.692357",
"0.6920898",
"0.6904356",
"0.6904356",
"0.68679136",
"0.6867284",
"0.6864408",
"0.6818495",
"0.68105125... | 0.81017864 | 0 |
returns the lowest parent up the tree from herethat is a right child. | def get_lowest_right_parent(self):
if self.parent == None:
# if we reached the top of the tree
# just return this node bc the 1/1 node is technically a child of both the 1/0 and 0/1 nodes
return self
elif not self.parent.is_left_child:
# the parent is a right child
return self.parent
else:
# the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_left_parent(self):\n\t\tif self.parent == None:\n\t\t\t# if we reached the top of the tree\n\t\t\t# just return this node bc the 1/1 node is technically a child of both the 1/0 and 0/1 nodes\n\t\t\treturn self\n\t\telif not self.parent.is_left_child:\n\t\t\t# the parent is a right child\n\t\t\tretur... | [
"0.8165508",
"0.7484334",
"0.7232219",
"0.72201324",
"0.7219222",
"0.7097782",
"0.706845",
"0.70569",
"0.7031903",
"0.6971588",
"0.6931417",
"0.6929054",
"0.6923967",
"0.69074976",
"0.6900387",
"0.6890993",
"0.6888747",
"0.6853589",
"0.68239844",
"0.67936134",
"0.6713629",
... | 0.879376 | 0 |
returns the lowest parent up the tree from herethat is a right child. | def get_lowest_left_parent(self):
if self.parent == None:
# if we reached the top of the tree
# just return this node bc the 1/1 node is technically a child of both the 1/0 and 0/1 nodes
return self
elif not self.parent.is_left_child:
# the parent is a right child
return self.parent.get_lowest_left_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_right_parent(self):\n\t\tif self.parent == None:\n\t\t\t# if we reached the top of the tree\n\t\t\t# just return this node bc the 1/1 node is technically a child of both the 1/0 and 0/1 nodes\n\t\t\treturn self\n\t\telif not self.parent.is_left_child:\n\t\t\t# the parent is a right child\n\t\t\tretu... | [
"0.879376",
"0.7484334",
"0.7232219",
"0.72201324",
"0.7219222",
"0.7097782",
"0.706845",
"0.70569",
"0.7031903",
"0.6971588",
"0.6931417",
"0.6929054",
"0.6923967",
"0.69074976",
"0.6900387",
"0.6890993",
"0.6888747",
"0.6853589",
"0.68239844",
"0.67936134",
"0.6713629",
"... | 0.8165508 | 1 |
Search through the tree and return the SBNode with the target fraction. | def search_tree(self, tgt_frac):
if self.frac == tgt_frac:
return self
elif compare_fracs(self.frac, tgt_frac):
# tgt is less than self and to left
return self.left_child.search_tree(tgt_frac)
else:
# tgt is greater than self and to right
return self.right_child.search_tree(tgt_frac) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(self):\n best_qsa_star_add = -99999\n best_node = None\n for a, c in self.children.items():\n qsa = c.wins / c.visits\n if c.visits_amaf == 0:\n qsa_tilde = 0\n else:\n qsa_tilde = c.wins_amaf / c.visits_amaf\n ... | [
"0.5656099",
"0.55765146",
"0.55034596",
"0.5352702",
"0.5343666",
"0.53300196",
"0.52742344",
"0.5213806",
"0.5170091",
"0.51638526",
"0.51331604",
"0.5125105",
"0.51183134",
"0.5118209",
"0.5068344",
"0.50424486",
"0.50326693",
"0.50320405",
"0.50314623",
"0.5024199",
"0.50... | 0.7159926 | 0 |
Print results of PCA analysis to command line. | def printPCAresults(pc_ana, param_list, print_components=False):
print(f'explained variance ratio '
f'({pc_ana.components_.shape[0]} components): '
f'{sum(pc_ana.explained_variance_ratio_):2.2f} '
f'({pc_ana.explained_variance_ratio_.round(2)})')
if print_components:
for j,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runPCA(data, reducedDimensions, showScree):\n print(\"-->Running PCA.\")\n latent = gp.pca(data['features'], reducedDimensions, showScree, savePlots)\n plot(latent, data['colours'], reducedDimensions, \"Iris Dataset\", \"PCA\")",
"def pca():\n pca = PCA()\n\n data = pca.fit_transform([[22,23,2... | [
"0.6608524",
"0.63565147",
"0.6017152",
"0.6001357",
"0.58680606",
"0.5785082",
"0.5773136",
"0.5744654",
"0.5728827",
"0.5686987",
"0.5664689",
"0.56456596",
"0.5635779",
"0.5624087",
"0.56012213",
"0.5596487",
"0.5595612",
"0.55919385",
"0.5590758",
"0.55323523",
"0.5470266... | 0.67139107 | 0 |
Update annotation and image. | def update_annot(ind):
# update text annotation
pos = sc.get_offsets()[ind["ind"][0]]
annot.xy = pos
idxlist = []
for element in PC:
idxlist.append(np.allclose(element, pos))
idx = idxlist.index(True)
annotation_string = f'{idx + 1}\n'
if displ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_image(self, image):\n raise NotImplementedError()",
"def update_image(self):\n self.image = Image.fromarray(self.img)",
"def write_annotation(self, ann_file, img_path, new_img_name):\n if self.type == \"imagenet\":\n label = self.in_annotations[img_path]\n ... | [
"0.7223096",
"0.67385095",
"0.65887845",
"0.6427451",
"0.64269096",
"0.63743126",
"0.63287795",
"0.6328405",
"0.63069886",
"0.63019645",
"0.62771714",
"0.6265501",
"0.6256589",
"0.6237346",
"0.6206293",
"0.61357236",
"0.6047715",
"0.6038806",
"0.60358",
"0.6002621",
"0.598172... | 0.7386941 | 0 |
Call this method to check if runner is in shutdown mode. | def is_in_shutdown(self):
return self._in_shutdown | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutting_down(self):\n return self._shutdown.is_set()",
"def check_main_stop(notifier):\n pass",
"def initiate_shutdown(self) -> None:",
"def shutdown(self):\r\n self._update('shutdown')\r\n self.supervisord.options.mood = SupervisorStates.SHUTDOWN\r\n return True",
"def ... | [
"0.7437572",
"0.6536957",
"0.6488601",
"0.64296126",
"0.6410239",
"0.6397543",
"0.63587606",
"0.63571006",
"0.63571006",
"0.63571006",
"0.6332087",
"0.6332087",
"0.6316774",
"0.626796",
"0.6259934",
"0.62512004",
"0.62483555",
"0.622814",
"0.62151444",
"0.62003744",
"0.619627... | 0.71672535 | 1 |
Submit connection observer to background execution. Returns Future that could be used to await for connection_observer done. | def submit(self, connection_observer):
assert connection_observer.life_status.start_time > 0.0 # connection-observer lifetime should already been
self._add_connection_observer(connection_observer=connection_observer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_connect(self):\n loop = asyncio.get_event_loop()\n task = loop.create_task(self.connect())\n loop.run_until_complete(task)",
"def connect(self):\n self.conn.add_listener(self.handle_connection_change)\n self.conn.start_async()",
"async def _async_on_connect():\n ... | [
"0.5857671",
"0.56647265",
"0.56131005",
"0.5611528",
"0.55837786",
"0.5582157",
"0.54861045",
"0.54837835",
"0.5407324",
"0.54024726",
"0.5363167",
"0.5361956",
"0.5330528",
"0.52729976",
"0.52215517",
"0.5154078",
"0.5144362",
"0.5119566",
"0.5107343",
"0.5095302",
"0.50916... | 0.63165396 | 0 |
Feeds connection_observer with data to let it become done. This is a place where runner is a glue between words of connection and connectionobserver. Should be called from backgroundprocessing of connection observer. Left only for backward compatibility. | def feed(self, connection_observer):
pass # pylint: disable=unnecessary-pass
# For backward compatibility only | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _runner_loop(self):\n while not self._stop_loop_runner.is_set():\n with self._connection_observer_lock:\n if self._copy_of_connections_observers != self._connections_observers:\n self._copy_of_connections_observers = copy_list(self._connections_observers, dee... | [
"0.68458927",
"0.62021434",
"0.61665285",
"0.60803646",
"0.5961914",
"0.5954607",
"0.59324074",
"0.58269244",
"0.5813925",
"0.58135957",
"0.58135957",
"0.580633",
"0.5800871",
"0.57929605",
"0.57856214",
"0.5737841",
"0.57358813",
"0.5700238",
"0.5689247",
"0.56702626",
"0.56... | 0.77465856 | 0 |
Add connection observer to the runner. | def _add_connection_observer(self, connection_observer):
with self._connection_observer_lock:
if connection_observer not in self._connections_observers:
moler_connection = connection_observer.connection
moler_connection.subscribe_connection_observer(connection_observe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self):\n self.conn.add_listener(self.handle_connection_change)\n self.conn.start_async()",
"def feed(self, connection_observer):\n pass # pylint: disable=unnecessary-pass\n # For backward compatibility only",
"def connected(self):\n manager = self.manager()\n ... | [
"0.6652319",
"0.6634749",
"0.6357493",
"0.6296808",
"0.62870336",
"0.6249382",
"0.62253284",
"0.619049",
"0.6146856",
"0.61381954",
"0.61206764",
"0.6047478",
"0.6041911",
"0.60389286",
"0.60389286",
"0.60245043",
"0.60162157",
"0.5997827",
"0.59874004",
"0.59874004",
"0.5938... | 0.7385649 | 0 |
Wait for not started connection observer (command or event) is done. | def _wait_for_not_started_connection_observer_is_done(self, connection_observer):
# Have to wait till connection_observer is done with terminaing timeout.
eol_remain_time = connection_observer.life_status.terminating_timeout
start_time = time.time()
while not connection_observer.done() a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wait_ready(self):\n command = self._recv_from_client()\n while command != \"READY\":\n command = self._client.recv_from_client()",
"def wait_for_connection(no_wait):\n\n while not no_wait and not handler.is_client_attached():\n time.sleep(0.1) # spinlock",
"async def wa... | [
"0.6908525",
"0.6747412",
"0.6716177",
"0.6633412",
"0.65618926",
"0.6443611",
"0.6427281",
"0.6427281",
"0.6427281",
"0.6427281",
"0.64223105",
"0.6414303",
"0.63679636",
"0.63404787",
"0.62514836",
"0.6183887",
"0.61603725",
"0.61309344",
"0.61298865",
"0.6106968",
"0.61069... | 0.8095583 | 0 |
Call on_inactivity on connection_observer if needed. | def _check_last_feed_connection_observers(self):
current_time = time.time()
for connection_observer in self._copy_of_connections_observers:
life_status = connection_observer.life_status
if (life_status.inactivity_timeout > 0.0) and (life_status.last_feed_time is not None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_enter(self):\n\n Clock.schedule_once(partial(check_connection.is_alive,\n self.ids[\"ico_connection\"]\n )\n )\n self.check_connection = Clock.schedule_interval(partial(check_connection.is_alive,\n ... | [
"0.64713466",
"0.6371828",
"0.5915407",
"0.5905554",
"0.58560777",
"0.58488846",
"0.58475876",
"0.5762941",
"0.5762161",
"0.5735699",
"0.5579951",
"0.55780596",
"0.55497235",
"0.55436623",
"0.5540052",
"0.55236906",
"0.5475399",
"0.5463221",
"0.54446304",
"0.54095566",
"0.539... | 0.66244066 | 0 |
Check list of ConnectionObservers if any timeout. | def _check_timeout_connection_observers(self):
for connection_observer in self._copy_of_connections_observers:
start_time = connection_observer.life_status.start_time
current_time = time.time()
run_duration = current_time - start_time
timeout = connection_observer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_last_feed_connection_observers(self):\n current_time = time.time()\n for connection_observer in self._copy_of_connections_observers:\n life_status = connection_observer.life_status\n if (life_status.inactivity_timeout > 0.0) and (life_status.last_feed_time is not None... | [
"0.720017",
"0.60273504",
"0.5892644",
"0.58705306",
"0.5864277",
"0.5846206",
"0.58225244",
"0.58115554",
"0.5797517",
"0.5743379",
"0.57153195",
"0.56690484",
"0.5665623",
"0.5610668",
"0.56082106",
"0.55857295",
"0.5578086",
"0.55780697",
"0.553308",
"0.54411095",
"0.54365... | 0.78741795 | 0 |
Prepare ConnectionObserver (command or event) for timeout. | def _prepare_for_time_out(self, connection_observer, timeout):
passed = time.time() - connection_observer.life_status.start_time
self._timeout_observer(connection_observer=connection_observer,
timeout=timeout, passed_time=passed,
runner_logge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_timeout_connection_observers(self):\n for connection_observer in self._copy_of_connections_observers:\n start_time = connection_observer.life_status.start_time\n current_time = time.time()\n run_duration = current_time - start_time\n timeout = connectio... | [
"0.62128496",
"0.611689",
"0.60697615",
"0.5706707",
"0.54417396",
"0.54395616",
"0.53547174",
"0.533949",
"0.5256496",
"0.5228185",
"0.52027476",
"0.51956594",
"0.51771903",
"0.51439977",
"0.5131876",
"0.51315176",
"0.51151115",
"0.5111697",
"0.5094155",
"0.50818205",
"0.508... | 0.70860237 | 0 |
Remove unnecessary ConnectionObservers from list to proceed. | def _remove_unnecessary_connection_observers(self):
for connection_observer in self._copy_of_connections_observers:
if connection_observer.done():
self._to_remove_connection_observers.append(connection_observer)
_, msg = RunnerSingleThread._its_remaining_time(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self):\n self.removeObservers()",
"def cleanup(self):\n self.removeObservers()",
"def cleanup(self):\n\t\tself.removeObservers()\n\t\tself.active = False",
"def cleanup(self):\r\n #self.removeObservers()\r\n pass",
"def _cleanup(self, server: Any) -> None: # noqa: F821\n ... | [
"0.73731667",
"0.7266392",
"0.7062582",
"0.7014867",
"0.6624878",
"0.6520376",
"0.6510573",
"0.6391279",
"0.6221481",
"0.61856866",
"0.616328",
"0.6141174",
"0.61400443",
"0.6113766",
"0.61032987",
"0.6094096",
"0.60722625",
"0.6015473",
"0.6015473",
"0.60107964",
"0.60098463... | 0.84189975 | 0 |
Srart command if connection_observer is an instance of a command. If an instance of event then do nothing. | def _start_command(self, connection_observer):
if connection_observer.is_command():
connection_observer.send_command() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_command(self, command):\r\n if self.visprotocol is not None:\r\n _LOGGER.info(\"client process_command called {0} type is {1}\".format(command, type(self.visprotocol))) \r\n self.visprotocol.process_command(command)\r\n else:\r\n _LOGGER.error(\"[Visonic... | [
"0.5808302",
"0.5749298",
"0.5739811",
"0.572681",
"0.54549485",
"0.53268474",
"0.5285533",
"0.5209355",
"0.51952237",
"0.5170219",
"0.5147668",
"0.5114667",
"0.51124805",
"0.50656945",
"0.50455505",
"0.5018172",
"0.5008057",
"0.49998525",
"0.49858227",
"0.49823084",
"0.49651... | 0.683487 | 0 |
method to set queryset for retrieving objects for user's company only. | def get_queryset(self):
qs = super().get_queryset()
qs.filter(company=self.request.user.company)
return qs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return self.request.user.setting_set.get().companies",
"def get_queryset(self):\n return self.request.user.setting_set.get().companies",
"def get_queryset(self):\n return self.request.user.setting_set.get().companies",
"def get_queryset(self):\n return se... | [
"0.74833214",
"0.74833214",
"0.74833214",
"0.74833214",
"0.7096127",
"0.6695653",
"0.6640594",
"0.6633222",
"0.6544434",
"0.6500737",
"0.6420627",
"0.6395806",
"0.6321692",
"0.62992424",
"0.62633705",
"0.61954886",
"0.6175595",
"0.6160776",
"0.6148539",
"0.6130602",
"0.611168... | 0.83381206 | 0 |
Gets a queryset with specified filters from request.GET overrides django.views.generic.list.MultipleObjectMixin.get_queryset | def get_queryset(self):
qs = super().get_queryset() # get company specific queryset
filters = dict(self.request.GET.lists()) # dictionary of lists
# pull out order_by and order
order_by = filters.pop("order_by", None)
order = filters.pop("order", None)
# Ordering by... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_get_list(self, request=None, **kwargs):\n filters = None\n\n if hasattr(request, 'GET'):\n filters = request.GET\n\n applicable_filters = self.build_filters(filters=filters)\n applicable_filters.update(kwargs)\n\n try:\n return self.get_object_list(r... | [
"0.76005995",
"0.74862903",
"0.74671745",
"0.73489726",
"0.7338303",
"0.7274823",
"0.72584987",
"0.7209284",
"0.7193955",
"0.7184572",
"0.7105138",
"0.70795804",
"0.7065119",
"0.7065119",
"0.7050204",
"0.7050204",
"0.70427555",
"0.70153874",
"0.69784844",
"0.69669074",
"0.695... | 0.76752055 | 0 |
Will fill inplace the export data structure with nested headers and their respective text | def get_data(export, headers, section):
for unit in section:
# We use a temporary variable so as to not update it for all
# iteration
temp_header = headers + [unit.title]
# Get the text
text = unit.text
# NOTE: this is probably dirty, could use classes in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_dict(data: list, output_path: str, title: str) -> None:\n output = []\n for row in data:\n heading = get_heading(row)\n output.append(f'# {heading}')\n output.append('')\n for _, header in utils.srg_export.data.COLUMN_MAPPINGS.items():\n output.append(f'## {h... | [
"0.6079765",
"0.5885699",
"0.58411974",
"0.57001233",
"0.5619722",
"0.5597703",
"0.5558174",
"0.55084187",
"0.54957384",
"0.5491653",
"0.5460945",
"0.5460104",
"0.5441996",
"0.54364884",
"0.5418627",
"0.5417288",
"0.5392408",
"0.5381344",
"0.53796035",
"0.53658533",
"0.536546... | 0.62805873 | 0 |
Returns a list of variables to train. | def _get_variables_to_train():
if FLAGS.trainable_scopes is None:
return tf.trainable_variables()
else:
scopes = [scope.strip() for scope in FLAGS.trainable_scopes.split(',')]
variables_to_train = []
for scope in scopes:
variables = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope)
var... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_variables_to_train(self):\n if self.trainable_scopes is None:\n return tf.trainable_variables()\n else:\n scopes = [scope.strip() for scope in self.trainable_scopes.split(',')]\n \n variables_to_train = []\n for scope in scopes:\n variables ... | [
"0.78420085",
"0.77309436",
"0.77309436",
"0.7696798",
"0.76793075",
"0.7623573",
"0.75650865",
"0.7555172",
"0.75006074",
"0.7315166",
"0.7200911",
"0.7186752",
"0.7165649",
"0.7107194",
"0.70173025",
"0.6995667",
"0.69873655",
"0.6917468",
"0.6909653",
"0.69072306",
"0.6886... | 0.77719444 | 1 |
Instantiate a CalcInterface object. | def __init__(self, proj=None, model=None, run=None, ens_mem=None, var=None,
date_range=None, region=None, intvl_in=None, intvl_out=None,
dtype_in_time=None, dtype_in_vert=None, dtype_out_time=None,
dtype_out_vert=None, level=None, time_offset=None):
if run not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classFactory(iface): # pylint: disable=invalid-name\n #\n from .indicadores_geosaude import IndicadoresGeosaude\n return IndicadoresGeosaude(iface)",
"def createStandardInputObjFromCalcObjs(self, calcObjs):\n\t\treturn self._stdInpFromCalcObjs(self, calcObjs)",
"def __init__(self, calcGrad, calcC... | [
"0.55461043",
"0.54615575",
"0.5398776",
"0.53714937",
"0.53408873",
"0.52831453",
"0.5282024",
"0.5174737",
"0.5168434",
"0.5158829",
"0.51377535",
"0.5136189",
"0.5122206",
"0.50964415",
"0.5093284",
"0.5087388",
"0.50600004",
"0.5042441",
"0.5030675",
"0.5029526",
"0.50092... | 0.57148844 | 0 |
Create string of the data directory to store a tar file. | def _dir_tar_out(self):
ens_label = utils.io.ens_label(self.ens_mem)
return os.path.join(self.proj.tar_direc_out, self.proj.name,
self.model.name, self.run.name,
ens_label) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmp_data_directory(tmp_path_factory):\n return str(tmp_path_factory.mktemp(\"datathon-mlapp-starter\"))",
"def get_data_dir() -> str:\n os.makedirs(DEFAULT_OUTPUT_DIR, exist_ok=True)\n return DEFAULT_OUTPUT_DIR",
"def datadir():\n return '../data/'",
"def _create_data_directory(self):\n ... | [
"0.668783",
"0.66433996",
"0.65262216",
"0.64303285",
"0.6403059",
"0.6379541",
"0.63335735",
"0.6287801",
"0.6276481",
"0.6238254",
"0.62279934",
"0.62135416",
"0.6202375",
"0.6194497",
"0.6191514",
"0.618291",
"0.6157835",
"0.6141365",
"0.6122145",
"0.6097494",
"0.6095356",... | 0.6959594 | 0 |
Add model grid attributes to a dataset | def _add_grid_attributes(self, ds):
for name_int, names_ext in self._grid_attrs.items():
ds_coord_name = set(names_ext).intersection(set(ds.coords) |
set(ds.data_vars))
model_attr = getattr(self.model, name_int, None)
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepopulate(self, model, exclude=[]):\n for col in model.columns():\n if col not in exclude and hasattr(self, col):\n setattr(getattr(self, col), 'data', getattr(model, col))",
"def attribute(self, data, model, model_name):",
"def _write_attributes_(self):\n #Open th... | [
"0.6093668",
"0.60661185",
"0.59482807",
"0.5856596",
"0.5852455",
"0.5736706",
"0.57010055",
"0.5676482",
"0.55973953",
"0.5530213",
"0.5523712",
"0.5513159",
"0.5505337",
"0.5502275",
"0.54875046",
"0.5467387",
"0.5464971",
"0.54523236",
"0.5370031",
"0.53413594",
"0.533947... | 0.7780318 | 0 |
Get pressure or pressure thickness array for data on pcoords. | def _get_pressure_from_p_coords(self, ps, name='p'):
if np.any(self.pressure):
pressure = self.pressure
else:
pressure = self.model.level
if name == 'p':
return pressure
if name == 'dp':
return utils.vertcoord.dp_from_p(pressure, ps)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pshape(self):\n try:\n return plist([x.pshape() for x in self], root=self.__root__)\n except Exception:\n return plist([len(self)], root=self.__root__)",
"def pressure(x, kind=\"geopotential\"):\n\n p = table(x, kind)[2]\n return p",
"def _get_pdi(cls, data, windows):\n\t\twindow = cl... | [
"0.55917585",
"0.5577419",
"0.5542342",
"0.53993183",
"0.5391667",
"0.5391056",
"0.5374878",
"0.5368606",
"0.5305264",
"0.5304141",
"0.5295931",
"0.5269179",
"0.5235801",
"0.52351403",
"0.5233223",
"0.5221241",
"0.5218153",
"0.51947767",
"0.51916176",
"0.51729184",
"0.5156414... | 0.5965626 | 0 |
Get the data for a single variable over the desired date range. | def _get_input_data(self, var, start_date, end_date):
logging.info(self._print_verbose("Getting input data:", var))
# Pass numerical constants as is.
if isinstance(var, (float, int)):
return var
# aospy.Var objects remain.
# Pressure handled specially due to complicat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_data(data=pd.DataFrame(), date_initial=\"2005-01-01\", date_final=\"2019-12-31\"):\n data = data[data.index >= date_initial]\n data = data[data.index <= date_final]\n return data",
"def get_records_date(start_date, end_date):\n start = minus_one(start_date)\n temp = pd.read_sql_query(_q... | [
"0.64027274",
"0.60679734",
"0.60579973",
"0.6029412",
"0.6007587",
"0.59154254",
"0.5905602",
"0.58029187",
"0.57601243",
"0.57441825",
"0.5735495",
"0.570289",
"0.5694353",
"0.5680198",
"0.5679844",
"0.5646513",
"0.5644005",
"0.5620897",
"0.56159776",
"0.561455",
"0.5593017... | 0.6285674 | 1 |
Perform the specified time reduction on a local timeseries. | def _time_reduce(self, arr, reduction):
if self.dtype_in_time == 'av':
return arr
reductions = {
'None': lambda xarr: xarr,
'ts': lambda xarr: xarr,
'av': lambda xarr: xarr.mean(internal_names.YEAR_STR),
'std': lambda xarr: xarr.std(internal_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_all_time_reductions(self, full_ts, monthly_ts, eddy_ts):\n logging.info(self._print_verbose(\"Applying desired time-\"\n \"reduction methods.\"))\n # Determine which are regional, eddy, time-mean.\n reduc_specs = [r.split('.') for r in self.dt... | [
"0.5988665",
"0.51748985",
"0.5174669",
"0.51686645",
"0.51683694",
"0.5122315",
"0.5104745",
"0.50596696",
"0.50596696",
"0.5038005",
"0.50319225",
"0.5011385",
"0.49402636",
"0.49358612",
"0.49357003",
"0.49233362",
"0.491421",
"0.48677415",
"0.48568976",
"0.4825794",
"0.48... | 0.6599274 | 0 |
Perform a calculation for all regions. | def region_calcs(self, arr, func):
# Get pressure values for data output on hybrid vertical coordinates.
bool_pfull = (self.def_vert and self.dtype_in_vert ==
internal_names.ETA_STR and self.dtype_out_vert is False)
if bool_pfull:
pfull = self._full_to_yearly_ts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_calculate_all(self, **kwargs):\n _return = False\n\n # Calculate all Allocations, skipping the top node in the tree.\n for _node in self.tree.all_nodes()[1:]:\n if _node.identifier != 0:\n self.do_calculate(_node.identifier, **kwargs)\n\n return _return"... | [
"0.6194143",
"0.5827072",
"0.5770518",
"0.56490785",
"0.5578175",
"0.5562212",
"0.55582315",
"0.5550116",
"0.5517527",
"0.5458629",
"0.5393012",
"0.5392545",
"0.5353598",
"0.5342892",
"0.5308947",
"0.52641714",
"0.5259804",
"0.523855",
"0.52160764",
"0.5192724",
"0.5178875",
... | 0.6156202 | 1 |
Apply all requested time reductions to the data. | def _apply_all_time_reductions(self, full_ts, monthly_ts, eddy_ts):
logging.info(self._print_verbose("Applying desired time-"
"reduction methods."))
# Determine which are regional, eddy, time-mean.
reduc_specs = [r.split('.') for r in self.dtype_out_time]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _time_reduce(self, arr, reduction):\n if self.dtype_in_time == 'av':\n return arr\n reductions = {\n 'None': lambda xarr: xarr,\n 'ts': lambda xarr: xarr,\n 'av': lambda xarr: xarr.mean(internal_names.YEAR_STR),\n 'std': lambda xarr: xarr.std... | [
"0.6698724",
"0.58304536",
"0.5740768",
"0.57148784",
"0.5643352",
"0.55625993",
"0.55606973",
"0.54921097",
"0.5462226",
"0.5439169",
"0.53766143",
"0.5346602",
"0.5320928",
"0.5296981",
"0.5267185",
"0.52655417",
"0.5249101",
"0.5232051",
"0.5216631",
"0.51879865",
"0.51837... | 0.75268835 | 0 |
Create full, monthlymean, and eddy timeseries of data. | def _make_full_mean_eddy_ts(self, data):
bool_monthly = (['monthly_from' in self.dtype_in_time] +
['time-mean' in dout for dout in self.dtype_out_time])
bool_eddy = ['eddy' in dout for dout in self.dtype_out_time]
if not all(bool_monthly):
full, full_dt = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_full_ts(self, data, monthly_mean=False, zonal_asym=False):\n # Get results at each desired timestep and spatial point.\n # Here we need to provide file read-in dates (NOT xarray dates)\n full_ts, dt = self._compute(data, monthly_mean=monthly_mean)\n if zonal_asym:\n ... | [
"0.6448815",
"0.6376945",
"0.62100995",
"0.6183168",
"0.6156314",
"0.60932374",
"0.58807534",
"0.5847974",
"0.58189225",
"0.57914835",
"0.5777638",
"0.57754767",
"0.57584393",
"0.56558776",
"0.5642424",
"0.5631541",
"0.5627859",
"0.5620441",
"0.5610955",
"0.55953705",
"0.5576... | 0.74621826 | 0 |
Save the data to netcdf files in direc_out. | def _save_files(self, data, dtype_out_time):
path = self.path_out[dtype_out_time]
if not os.path.isdir(self.dir_out):
os.makedirs(self.dir_out)
if 'reg' in dtype_out_time:
try:
reg_data = xr.open_dataset(path)
except (EOFError, RuntimeError, IO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_netcdf(self, outfile):",
"def save_to_disk(self, filename='ens_state.nc'):\n self.to_netcdf(filename)",
"def save_to_netcdf(img, filename):\n filename = os.path.join(datadir, filename + '.nc')\n print('Saving: ' + filename)\n img.to_netcdf(filename)",
"def output_netcdf(forecast,proj_d... | [
"0.7944753",
"0.70882285",
"0.69628674",
"0.6949173",
"0.6941277",
"0.6930326",
"0.683638",
"0.68314844",
"0.6766005",
"0.67641866",
"0.6610118",
"0.6586224",
"0.65797985",
"0.6492392",
"0.64117795",
"0.6389692",
"0.6355074",
"0.6350296",
"0.63153183",
"0.62991965",
"0.627094... | 0.77034247 | 1 |
Add the data to the tar file in tar_out_direc. | def _write_to_tar(self, dtype_out_time):
# When submitted in parallel and the directory does not exist yet
# multiple processes may try to create a new directory; this leads
# to an OSError for all processes that tried to make the
# directory, but were later than the first.
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tar_dir(output_path, source_dir):\n with tarfile.open(output_path, \"w:gz\") as tar:\n tar.add(source_dir, arcname=os.path.basename(source_dir))",
"def _outside_tar(self):\r\n outside_tar = self.unsafe_common_dir / \"unsafe_file.tar.gz\"\r\n with tarfile.open(outside_tar, \"w:gz\") as... | [
"0.6786602",
"0.6693681",
"0.6670188",
"0.6648034",
"0.64866704",
"0.6451304",
"0.6295874",
"0.61914855",
"0.61045814",
"0.6101494",
"0.6056289",
"0.60557306",
"0.604684",
"0.6011332",
"0.5993754",
"0.59463626",
"0.58494645",
"0.583224",
"0.5801141",
"0.577348",
"0.5759886",
... | 0.70681113 | 0 |
Append the data of the given dtype_out to the data_out attr. | def _update_data_out(self, data, dtype):
try:
self.data_out.update({dtype: data})
except AttributeError:
self.data_out = {dtype: data} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast(self, dtype):\n self.dtype = np.dtype(dtype)\n self.preprocess = False\n self.set_data(self.data)",
"def setRxDataOut(self, rx_data_out):\n self.rx_data_out = rx_data_out",
"def _save_files(self, data, dtype_out_time):\n path = self.path_out[dtype_out_time]\n ... | [
"0.557317",
"0.5526732",
"0.55255765",
"0.54921657",
"0.54495966",
"0.53745854",
"0.5360902",
"0.526652",
"0.5238675",
"0.52305984",
"0.51603323",
"0.5156865",
"0.5149443",
"0.5124915",
"0.50758576",
"0.50730234",
"0.50729704",
"0.50701445",
"0.5064776",
"0.50359225",
"0.5",
... | 0.7611866 | 0 |
Subset the data array to the specified time/level/lat/lon, etc. | def _get_data_subset(self, data, region=False, time=False,
vert=False, lat=False, lon=False):
if region:
raise NotImplementedError
if np.any(time):
data = data[time]
if 'monthly_from_' in self.dtype_in_time:
data = np.mean(data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subset_by_time(self):\n\n this_satellite_dict = satellite_io.subset_by_time(\n satellite_dict=copy.deepcopy(SATELLITE_DICT_ALL_EXAMPLES),\n desired_times_unix_sec=DESIRED_TIMES_UNIX_SEC\n )[0]\n\n self.assertTrue(compare_satellite_dicts(\n this_satelli... | [
"0.61725897",
"0.60649836",
"0.5830782",
"0.5813046",
"0.56072766",
"0.55780876",
"0.5566176",
"0.55291396",
"0.5466052",
"0.54169613",
"0.5414688",
"0.5406871",
"0.5399697",
"0.53718024",
"0.5317835",
"0.5213868",
"0.5211027",
"0.51781565",
"0.5149405",
"0.5148659",
"0.51393... | 0.659993 | 0 |
Add metadata attributes to Dataset or DataArray | def _add_metadata_as_attrs(data, units, description, dtype_out_vert):
if isinstance(data, xr.DataArray):
return _add_metadata_as_attrs_da(data, units, description,
dtype_out_vert)
else:
for name, arr in data.data_vars.items():
_add_metadata_as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_metadata(ds, metadata):\n\n ds.attrs.update(metadata)\n\n return ds",
"def add_metadata(self, metadata: dict) -> None:",
"def set_metadata(self, data):\r\n pass",
"def _add_metadata_as_attrs_da(data, units, description, dtype_out_vert):\n if dtype_out_vert == 'vert_int':\n ... | [
"0.7955883",
"0.7114015",
"0.70907336",
"0.70366824",
"0.6820789",
"0.66713685",
"0.6642246",
"0.6585722",
"0.6585722",
"0.65347093",
"0.64802325",
"0.6474943",
"0.6464878",
"0.6454285",
"0.6454285",
"0.64433736",
"0.63965815",
"0.63449633",
"0.6330062",
"0.62801987",
"0.6280... | 0.80313355 | 0 |
Find the .whl file in the dist folder. | def _find_wheel(ctx):
wheel = ctx.path.ant_glob("dist/*-" + VERSION + "-*.whl")
if not len(wheel) == 1:
ctx.fatal("No wheel found (or version mismatch)")
else:
wheel = wheel[0]
Logs.info("Wheel %s", wheel)
return wheel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_wheel():\n wheels = sorted(DIST.glob(\"*.whl\"))\n if not wheels:\n subprocess.check_call([\"pyproject-build\", \".\", \"--wheel\", \"--no-isolation\"], cwd=ROOT)\n wheels = sorted(DIST.glob(\"*.whl\"))\n return wheels[-1]",
"def upload_wheels():\n build()\n sh(\"%s -m twi... | [
"0.60192287",
"0.58031386",
"0.535494",
"0.5350329",
"0.5279466",
"0.5263522",
"0.523158",
"0.5209095",
"0.5129796",
"0.5092573",
"0.50611657",
"0.50155604",
"0.5009956",
"0.49787986",
"0.49689916",
"0.49234095",
"0.49003977",
"0.49003977",
"0.48994312",
"0.48742357",
"0.4785... | 0.7416635 | 0 |
Add an Inline Auth Helper to a Pluggable Auth Service. | def addInlineAuthHelper(dispatcher, id, title=None, REQUEST=None):
iah = InlineAuthHelper(id, title)
dispatcher._setObject(iah.getId(), iah)
if REQUEST is not None:
REQUEST['RESPONSE'].redirect('%s/manage_workspace'
'?manage_tabs_message='
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_virtual_authenticator(self, config):\n pass",
"def manage_addBlowfishExtendedCookieAuthHelper(self, id, title='',\n RESPONSE=None, **kw):\n\n self = self.this()\n\n o = BlowfishExtendedCookieAuthHelper(id, title, **kw)\n self._setObject(o.getId(), o)\... | [
"0.5557414",
"0.55137914",
"0.53382605",
"0.53051865",
"0.5261152",
"0.50570595",
"0.5031519",
"0.5024108",
"0.50065255",
"0.50065255",
"0.4975993",
"0.49440524",
"0.4900964",
"0.48620814",
"0.48328233",
"0.48326203",
"0.48200023",
"0.48074985",
"0.48062065",
"0.47664997",
"0... | 0.74920344 | 0 |
Extract credentials from cookie or 'request'. | def extractCredentials(self, request):
creds = {}
# Look in the request for the names coming from the login form
login = request.get('__ac_name', '')
password = request.get('__ac_password', '')
if login:
creds['login'] = login
creds['password'] = passwor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractCredentials(self, request):\n\n cookie = request.cookies.get('.ASPXAUTH')\n creds = {}\n creds['cookie'] = cookie\n creds['plugin'] = self.getId()\n\n return creds",
"def extractCredentials( self, request ):\n #log( 'extractCredentials')\n\n creds = {}\... | [
"0.7835554",
"0.7634402",
"0.7204632",
"0.65182984",
"0.6486379",
"0.6455087",
"0.61710817",
"0.61479807",
"0.611163",
"0.60100037",
"0.594791",
"0.5943985",
"0.5915417",
"0.5796954",
"0.5777253",
"0.5771008",
"0.57167053",
"0.57153827",
"0.5690814",
"0.5690609",
"0.56588995"... | 0.779748 | 1 |
Get an example list_cluster call (For mocking) | def list_cluster_response():
return {
"clusters": [
EXAMPLE_NAME
]
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cluster_list(self):\n return self.__cluster_list",
"def test_get_hyperflex_cluster_list(self):\n pass",
"def test_list_cluster_network(self):\n pass",
"def cluster_list():\n request_debug(r, logger)\n json_body = r.get_json(force=True, silent=True) or {}\n result = cluster_... | [
"0.7539311",
"0.7504863",
"0.7477707",
"0.7102973",
"0.69092697",
"0.6877012",
"0.6751242",
"0.6587598",
"0.65839416",
"0.65274453",
"0.6473518",
"0.64674175",
"0.64640313",
"0.6455506",
"0.6433894",
"0.6427904",
"0.63871676",
"0.6361137",
"0.63391733",
"0.63274634",
"0.63141... | 0.7792407 | 0 |
Get an example describe_cluster call during creation | def describe_cluster_creating_response():
return {
"cluster": {
"status": "CREATING",
"name": EXAMPLE_NAME,
"certificateAuthority": {},
"roleArn": "arn:aws:iam::111222333444/eksRole",
"resourcesVpcConfig": {
"subnetIds": [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_cluster_response():\n return {\n \"clusters\": [\n EXAMPLE_NAME\n ]\n }",
"def launch_example_cluster_cmd(*args, **kwargs):\n return launch_example_cluster(*args, **kwargs)",
"def describe_cluster_response():\n return {\n \"cluster\": {\n \"status... | [
"0.69354606",
"0.680464",
"0.6495944",
"0.64750975",
"0.6322822",
"0.6270452",
"0.62655216",
"0.62579936",
"0.62399894",
"0.6176743",
"0.6172865",
"0.615929",
"0.6146113",
"0.61262864",
"0.61135745",
"0.6100122",
"0.60850996",
"0.60792947",
"0.60370797",
"0.5967636",
"0.59601... | 0.7227927 | 0 |
Get an example describe_cluster call during deletion | def describe_cluster_deleting_response():
return {
"cluster": {
"status": "DELETING",
"endpoint": "https://endpoint.amazonaws.com",
"name": EXAMPLE_NAME,
"certificateAuthority": {
"data": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpWR1Z6ZEdsdVp5QkV... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_cluster(self):",
"def Run(self, args):\n cluster_ref = args.CONCEPTS.cluster.Parse()\n items = [command_util.ClusterMessage(name=cluster_ref.vmwareClustersId)]\n\n if not args.validate_only:\n command_util.ConfirmationPrompt('cluster', items, 'deleted')\n\n client = apis.ClustersClien... | [
"0.75909144",
"0.68696296",
"0.6740679",
"0.6721878",
"0.66755325",
"0.6675259",
"0.6641943",
"0.66240346",
"0.6619215",
"0.6527228",
"0.6468657",
"0.6459234",
"0.64044845",
"0.6308383",
"0.61893874",
"0.61806893",
"0.6159998",
"0.61259925",
"0.6114047",
"0.607198",
"0.606095... | 0.75442225 | 1 |
Return a string representing a presigned url | def presigned_url():
return 'https://presignedurl.test.com' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(self, url):\n return self.presigned_url(url)",
"def presigned_url(self, url, expiration=3600, force_download=False):\n force_download = \"?force_download=1\" if force_download else \"\"\n public_url = Path(self.config.get(\"public_url\", \"\"))\n resource_url = public_url / ur... | [
"0.82590914",
"0.778759",
"0.72649896",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7126",
"0.7020326",
"0.6789058",
"0.67851526",
"0.67817545",
"0.6... | 0.83870244 | 0 |
The exception decorator adds an exception method to the decorated input_fn that catches any exception raised by the function. If an exception is caught, it the output from sys.exc_info() is stored in a .exception member. If not exception is caught, input_fn.exception will be None. Call input_fn.exception after a callin... | def exception(input_fn, *args, **kwargs):
if hasattr(input_fn, "exception"):
raise AttributeError("Cannot decorate input_fn because it already has and 'exception' attribute")
def new(*args, **kwargs):
from sys import exc_info
try :
new.exception = None
ret = inpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_function(self, fn):\n\n @functools.wraps(fn)\n def wrapper(*args):\n fname = fn.__name__\n if len(args) > len(self._insigs):\n raise TypeError(\n (\"{}() takes {} positional arguments but {} were \" \"given\").format(\n ... | [
"0.6175209",
"0.61053234",
"0.60425055",
"0.6041987",
"0.5936048",
"0.5906888",
"0.5871319",
"0.5841565",
"0.58280474",
"0.58030313",
"0.57741934",
"0.57514983",
"0.57445973",
"0.56957304",
"0.5662573",
"0.56570697",
"0.5612495",
"0.5603439",
"0.55952275",
"0.5540759",
"0.553... | 0.81485933 | 0 |
Encrypts some data (aligns to 64 bytes, if needed). | def encryptData(self, key, iv, data, align = True):
if((len(data) % self.align) != 0 and align):
return AES.new(key, AES.MODE_CBC, iv).encrypt(data + ("\x00" * (self.align - (len(data) % self.align))))
else:
return AES.new(key, AES.MODE_CBC, iv).encrypt(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encrypt(data):\n cipher = AES.new(bytes(_AES_KEY), AES.MODE_CBC, bytes(_AES_IV))\n\n # Pad to 16 bytes for AES CBC\n for i in range(16 - (len(data) % 16)):\n data += b'\\0'\n\n return cipher.encrypt(data)",
"def Encrypt(self, data):\n\n if len(data) % 16 != 0:\n data += ... | [
"0.7885185",
"0.7712841",
"0.7654952",
"0.7337602",
"0.7299068",
"0.7281445",
"0.71950537",
"0.7059179",
"0.7026982",
"0.69452465",
"0.68957233",
"0.684373",
"0.6826722",
"0.67560023",
"0.6729065",
"0.6721459",
"0.66718626",
"0.6671148",
"0.66647303",
"0.66416234",
"0.6613740... | 0.77255154 | 1 |
Return the current font. | def font(self):
return self.m_font | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def GetFont(self):\r\n\r\n return self._font",
"def GetFont(self):\r\n\r\n return self._font",
"def GetFont(self):\r\n\r\n return self... | [
"0.8364022",
"0.8364022",
"0.8364022",
"0.83319396",
"0.83319396",
"0.83319396",
"0.7937106",
"0.784561",
"0.78324264",
"0.78324264",
"0.75864154",
"0.75253946",
"0.74566376",
"0.73828804",
"0.7366602",
"0.728598",
"0.7264327",
"0.72018814",
"0.71568465",
"0.71465045",
"0.708... | 0.85015863 | 0 |
Return the lowlevel gd font. | def _font(self):
return self.m_gdfont | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font(self):\n\treturn self.m_font",
"def font(self):\n\treturn self.m_font",
"def get_font(self, option):\n return get_font(option=option)",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"... | [
"0.7086381",
"0.7086381",
"0.6938595",
"0.69367456",
"0.69367456",
"0.69367456",
"0.6928394",
"0.6858252",
"0.6838323",
"0.67379063",
"0.6708655",
"0.66984797",
"0.663425",
"0.663425",
"0.663425",
"0.6609488",
"0.6609394",
"0.65845054",
"0.65330255",
"0.65114707",
"0.64931756... | 0.80946225 | 0 |
Construct a new truetype font. The `font' parameter specifies the file name of a truetype font, and `pointsize' specifies the point size to use. | def __init__(self, font, pointsize):
self.m_font = font
self.m_pointsize = pointsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(font_name, point):\n return pygame.font.SysFont(font_name, int(point))",
"def truetype(font=None, size=10, index=0, encoding=\"\",\r\n layout_engine=None):\r\n if not freetype_installed:\r\n raise NotImplementedError(\"freetype-py is not installed or the libfreetype.dll/dy... | [
"0.65943176",
"0.6507712",
"0.6302644",
"0.6169613",
"0.60154456",
"0.5916379",
"0.58347595",
"0.5834142",
"0.5751763",
"0.55977577",
"0.55713534",
"0.55640525",
"0.5546145",
"0.5519924",
"0.55184734",
"0.54587924",
"0.54574084",
"0.54460585",
"0.5384534",
"0.53706086",
"0.53... | 0.6511013 | 1 |
Return the current font. | def font(self):
return self.m_font | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def GetFont(self):\r\n\r\n return self._font",
"def GetFont(self):\r\n\r\n return self._font",
"def GetFont(self):\r\n\r\n return self... | [
"0.8364022",
"0.8364022",
"0.8364022",
"0.83319396",
"0.83319396",
"0.83319396",
"0.7937106",
"0.784561",
"0.78324264",
"0.78324264",
"0.75864154",
"0.75253946",
"0.74566376",
"0.73828804",
"0.7366602",
"0.728598",
"0.7264327",
"0.72018814",
"0.71568465",
"0.71465045",
"0.708... | 0.85015863 | 1 |
Set the current font. | def set_font(self, font):
self.m_font = font | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_font_family(self, font):\n self.parent.setCurrentFont(font)",
"def set_font(self, font: str):\n self.font = font",
"def SetFont(self, font):\r\n \r\n self._font = font",
"def SetFont(self, font):\r\n\r\n self._font = font",
"def set_font(self, font):\n\ttry:\n\t ... | [
"0.86504996",
"0.85895497",
"0.85511273",
"0.8487338",
"0.82593066",
"0.81806946",
"0.8180615",
"0.80901104",
"0.78574944",
"0.7839135",
"0.783008",
"0.77893543",
"0.7788783",
"0.777804",
"0.77533484",
"0.77471095",
"0.7734195",
"0.77050644",
"0.76914483",
"0.76196116",
"0.76... | 0.8616047 | 1 |
Return the current point size. | def pointsize(self):
return self.m_pointsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self) -> Point:\n\t\treturn self._size",
"def getPointSize(self):\n l = [point.size for point in self.points]\n if l.count(l[0]) == len(l):\n return l[0]\n else:\n raise ValueError(\"The sizes of the points must be the same otherwise it makes no sense.\")",
"... | [
"0.8636495",
"0.82199454",
"0.75747615",
"0.74275225",
"0.7424574",
"0.7419275",
"0.73445594",
"0.73120743",
"0.7296886",
"0.7276074",
"0.72740424",
"0.7266581",
"0.7259557",
"0.7255099",
"0.7255099",
"0.72550595",
"0.72550595",
"0.72550595",
"0.7226226",
"0.7226226",
"0.7221... | 0.90453184 | 0 |
Set the current point size. | def set_pointsize(self, pointsize):
self.m_pointsize = pointsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_point_size(self, pointSize):\n self.pointSize = pointSize",
"def setPointSize(self, size):\n for point in self.points:\n point.size = size",
"def set_point_size(self, point_size=0.0):\r\n for b in self.buf:\r\n b.unib[8] = point_size",
"def set_size(self, size):\n ... | [
"0.8869498",
"0.8786114",
"0.8302565",
"0.7436967",
"0.7383736",
"0.7337534",
"0.7333951",
"0.7167893",
"0.7167893",
"0.7124836",
"0.70554525",
"0.6935905",
"0.68554765",
"0.68554765",
"0.68554765",
"0.68554765",
"0.670467",
"0.66977566",
"0.66885006",
"0.66778666",
"0.666099... | 0.88312125 | 1 |
Traverse `graph` with BFS starting from `source`, up to `size` nodes. Return an iterator of subgraph nodes (including source node). | def _bfs_nodes(cls, graph, source, size, **kwargs):
if size < 1:
return iter(())
return itertools.chain(
(source,),
itertools.islice((v for u, v in nx.bfs_edges(graph, source)), size-1)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pfs_nodes(cls, graph, source, size, priority):\n if size < 1:\n return iter(())\n\n # use min-heap to implement (max) priority queue\n # use insertion order to break priority tie\n queue = []\n counter = itertools.count()\n push = lambda priority, node: hea... | [
"0.697801",
"0.61683583",
"0.6095612",
"0.5985303",
"0.5921379",
"0.588585",
"0.58339345",
"0.5821681",
"0.56726986",
"0.5672395",
"0.56356573",
"0.5611731",
"0.5600283",
"0.55612266",
"0.5560045",
"0.5480478",
"0.54231256",
"0.5411031",
"0.54024166",
"0.53965765",
"0.5389880... | 0.7747768 | 0 |
Priorityfirst traversal of `graph` starting from `source` node, returning up to `size` nodes iterable. Node priority is determined by `priority(node)` callable. Nodes with higher priority value are traversed before nodes with lower priority. | def _pfs_nodes(cls, graph, source, size, priority):
if size < 1:
return iter(())
# use min-heap to implement (max) priority queue
# use insertion order to break priority tie
queue = []
counter = itertools.count()
push = lambda priority, node: heappush(queue, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bfs_nodes(cls, graph, source, size, **kwargs):\n if size < 1:\n return iter(())\n\n return itertools.chain(\n (source,),\n itertools.islice((v for u, v in nx.bfs_edges(graph, source)), size-1)\n )",
"def traverse_breadth_first(self, src: int = 0, graph: ... | [
"0.6303713",
"0.53427094",
"0.51598406",
"0.5158019",
"0.513834",
"0.51348895",
"0.5099508",
"0.5099216",
"0.5047503",
"0.49562794",
"0.48239127",
"0.4789225",
"0.47295532",
"0.47219703",
"0.47005248",
"0.46776277",
"0.46731353",
"0.4671026",
"0.46589205",
"0.4648572",
"0.461... | 0.74001116 | 0 |
Traverse `bqm` graph using multistart graph search `method`, until `size` variables are selected. Each subgraph is seeded from `ordered_priority` ordered dictionary. | def _iterative_graph_search(cls, bqm, sample, ordered_priority, visited, size, method):
graph = bqm.to_networkx_graph()
graph.remove_nodes_from(visited)
variables = set()
order = iter(ordered_priority)
while len(variables) < size and len(graph):
# find the next untr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_node(self, priority_q, query, debug=False):\n popped = priority_q.pop(0)\n node = list(popped.keys())[0]\n node_label = node.split('.') \n if node[0] == \"C\": \n if debug:\n logging.info(f\"L{len(node_label) - 2} found bucket {node}\") \n ... | [
"0.53520167",
"0.5279833",
"0.522712",
"0.5184884",
"0.5166358",
"0.513863",
"0.5096856",
"0.5012815",
"0.49687812",
"0.49585232",
"0.4911081",
"0.48797333",
"0.48594335",
"0.4851185",
"0.4849475",
"0.48467082",
"0.48397836",
"0.48288202",
"0.4805648",
"0.4793294",
"0.4779177... | 0.695425 | 0 |
Show back button only if we were already on gites website | def backButtonAvailable(self):
referer = self.request.get('HTTP_REFERER')
if not referer:
return False
portalUrl = getToolByName(self.context, 'portal_url')()
if referer and referer.startswith(portalUrl):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def back_button(self):\r\n self.update_settings()\r\n self.is_action = True\r\n if self.back_call is not None:\r\n self.back_call()",
"def go_back(self):\n self.hide()",
"def go_back(self):\n self.hide()",
"def back(self):\n self.log_info(f\"Browser.back: ... | [
"0.66009057",
"0.65096796",
"0.65096796",
"0.6471661",
"0.6471332",
"0.64020437",
"0.6306402",
"0.62755764",
"0.6258319",
"0.6226828",
"0.6185653",
"0.61637855",
"0.61317366",
"0.61177963",
"0.60919166",
"0.6067055",
"0.6042377",
"0.6030426",
"0.5962144",
"0.58853775",
"0.588... | 0.7582404 | 0 |
This function predicts the label for a trained onevsall classifier. The labels are in the range 1..K, where K = all_theta.shape[0]. | def predict_one_vs_all(all_theta, X):
m = X.shape[0]
num_labels = all_theta.shape[0]
X_add = np.append(np.ones((m,1)), X, axis=1)
# compute the class probability for each class on each training instance
h = sigmoid(np.dot(X_add, all_theta.T))
p = np.argmax(h, axis=1)
# because ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_one_vs_all(all_theta, X):\n m = X.shape[0]\n num_labels = all_theta.shape[0]\n\n # You need to return the following variables correctly\n p = np.zeros((m, 1))\n\n # Add ones to the X data matrix\n X = np.hstack((np.ones((m, 1)), X))\n\n # ====================== YOUR CODE HERE =====... | [
"0.7766958",
"0.73554176",
"0.72547424",
"0.71412677",
"0.71165025",
"0.6996137",
"0.69605386",
"0.6868233",
"0.685735",
"0.6855751",
"0.6845887",
"0.6840902",
"0.6798085",
"0.678235",
"0.67749465",
"0.67749465",
"0.67486465",
"0.6730217",
"0.6724619",
"0.66748214",
"0.667482... | 0.8260868 | 0 |
Goes through the output queue, and calculates and answer based on RPN. This is achieved by using a stack to store the results, and checking each item in output queue. | def RPN(self):
stack = Stack()
while not self.output_queue.is_empty():
item = self.output_queue.pop()
if isinstance(item, numbers.Number):
stack.push(item)
elif isinstance(item, Function):
stack.push(item.execute(stack.pop()))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\r\n eq = input(\"Input an equation: \")\r\n splitList = (mysplit(eq))\r\n operandsList = []\r\n #This loop takes in the split list and adds to a list without operators\r\n for operand in splitList:\r\n if operand == '+' or operand == '-' or operand == '*' or operand == '/':\r\n ... | [
"0.6068715",
"0.5985844",
"0.5882993",
"0.5708964",
"0.5642679",
"0.561505",
"0.56025106",
"0.5601041",
"0.5527031",
"0.5418403",
"0.5372319",
"0.5371151",
"0.53369904",
"0.52827096",
"0.52697396",
"0.52394825",
"0.5237868",
"0.5236513",
"0.52331185",
"0.5231739",
"0.5179411"... | 0.7618425 | 0 |
Takes in an "normal" input queue, and converts it to RPN. The RPN output is pushed to the output queue in the right order. | def shunting_yard(self, input_queue):
operator_stack = Stack()
for item in input_queue:
if isinstance(item, numbers.Number):
self.output_queue.push(item)
elif isinstance(item, Function):
operator_stack.push(item)
elif item == '(':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RPN(self):\n stack = Stack()\n while not self.output_queue.is_empty():\n item = self.output_queue.pop()\n\n if isinstance(item, numbers.Number):\n stack.push(item)\n\n elif isinstance(item, Function):\n stack.push(item.execute(stack.p... | [
"0.69277567",
"0.5724403",
"0.5680305",
"0.5612169",
"0.55673456",
"0.54916817",
"0.54428995",
"0.5430331",
"0.5354963",
"0.5272707",
"0.525648",
"0.52467066",
"0.517748",
"0.5164673",
"0.51554155",
"0.5152124",
"0.51476604",
"0.51356125",
"0.51281035",
"0.5121775",
"0.511103... | 0.6383998 | 1 |
Get a PDU buffer of the given size cast to the correct type | def get_clns_buffer (self, size, pdu_type):
if sys.version_info >= (3, 0):
buf = bytearray(size)
hdr = pdu.PDU_PDU_TYPES[pdu_type].from_buffer(buf)
else:
buf = create_string_buffer(size)
hdr = util.cast_as(buf, pdu.PDU_PDU_TYPES[pdu_type])
hdr.llc_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_buffer(self) -> bytearray:\n packet = bytearray()\n packet.extend(\n struct.pack(\n \"!ccccHH\",\n \"D\".encode(\"ascii\"),\n \"L\".encode(\"ascii\"),\n \"E\".encode(\"ascii\"),\n \"P\".encode(\"ascii\"),\n ... | [
"0.6299509",
"0.62020695",
"0.6165722",
"0.585175",
"0.5818612",
"0.5739499",
"0.5722811",
"0.56874335",
"0.5664632",
"0.5662061",
"0.56257224",
"0.56121916",
"0.5598169",
"0.55793726",
"0.55635995",
"0.55509305",
"0.5521163",
"0.54932046",
"0.5467055",
"0.5446987",
"0.543480... | 0.6536022 | 0 |
This method is called by AdjDB if DIS election information has changed | def dis_election_info_changed(self, lindex):
lxlink = self.lxlink[lindex]
if lxlink:
lxlink.dis_election_info_changed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self.haveDistrict = len(self.districts()) > 0",
"def district_check(self):\n\t\t\n\t\tplaces_2_fetch=list(ons_week.stored_names.values())+ons_week.extra_places\n\t\tself.edition=None\n\t\tfor place in places_2_fetch:\n\t\t\t_filters=self.district_filter(place)\n\t\t\tif _filters:\n\t\t... | [
"0.55303323",
"0.542889",
"0.5330749",
"0.53204805",
"0.5200429",
"0.51930946",
"0.5169944",
"0.516099",
"0.5150847",
"0.51451606",
"0.5138021",
"0.5088016",
"0.5068397",
"0.504758",
"0.50452393",
"0.5004574",
"0.50022286",
"0.49970877",
"0.4994714",
"0.4983401",
"0.4978172",... | 0.6338383 | 0 |
Fill an SNP packet with SNP entries | def fill_snp_packet (self, ssnflags, tlvview):
snpstruct = tlv.SNPEntryStruct
sz = snpstruct.size
availb = len(tlvview) - 2
avail = availb // sz
while avail > 0 and ssnflags:
tavailb = min(255, availb)
tlvview[0] = tlvwrb(tlv.TLV_SNP_ENTRIES)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _capture_snp(self):\n # Get the forward position\n self._forward_position = self._sequence.find('[')\n # Get the reverse position\n self._reverse_position = len(self._sequence) - self._sequence.find(']')\n # Get the SNP\n self._snp = self._sequence[self._forward_... | [
"0.5446104",
"0.53793764",
"0.53116316",
"0.5188341",
"0.5188341",
"0.5178828",
"0.51245576",
"0.51135856",
"0.506556",
"0.49394774",
"0.49370044",
"0.49324453",
"0.49284285",
"0.48855937",
"0.48824796",
"0.4859781",
"0.48385096",
"0.482571",
"0.48249093",
"0.48228484",
"0.48... | 0.7410464 | 0 |
Fetch chunks and yield in order. Chunks are downloaded with concurrency as configured in `async_queue` | def for_each_chunk(blob: Blob, chunk_size: int=default_chunk_size, async_queue: Optional[AsyncQueue]=None):
reader = Reader(blob, chunk_size=chunk_size)
if async_queue is not None:
for chunk_number in reader._unfetched_chunks:
async_queue.put(reader._fetch_chunk, chunk_number)
for ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_each_chunk_async(blob: Blob, async_set: AsyncSet, chunk_size: int=default_chunk_size):\n reader = Reader(blob, chunk_size)\n\n def fetch_chunk(chunk_number):\n data = reader._fetch_chunk(chunk_number)\n return chunk_number, data\n\n for chunk_number in range(reader.number_of_chunks):... | [
"0.7039756",
"0.65459436",
"0.62428933",
"0.6091742",
"0.60693383",
"0.6043477",
"0.60399",
"0.603614",
"0.6003629",
"0.599732",
"0.59915036",
"0.5966428",
"0.5956915",
"0.5922741",
"0.5853379",
"0.58391833",
"0.5839072",
"0.58271337",
"0.5776846",
"0.5762124",
"0.57584995",
... | 0.7003836 | 1 |
Fetch chunks with concurrency as configured in `async_set`, yielding results as soon as available. Results may be returned in any order. | def for_each_chunk_async(blob: Blob, async_set: AsyncSet, chunk_size: int=default_chunk_size):
reader = Reader(blob, chunk_size)
def fetch_chunk(chunk_number):
data = reader._fetch_chunk(chunk_number)
return chunk_number, data
for chunk_number in range(reader.number_of_chunks):
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_all(self, urls):\n async with ClientSession() as session:\n tasks = []\n for url in urls:\n task = asyncio.create_task(self.fetch(session, url))\n tasks.append(task)\n results = await asyncio.gather(*tasks)\n return re... | [
"0.66831255",
"0.64402056",
"0.63998175",
"0.6395605",
"0.61951405",
"0.6106072",
"0.5962315",
"0.5895014",
"0.5870512",
"0.58378106",
"0.5837633",
"0.57841134",
"0.57645226",
"0.5702948",
"0.56887645",
"0.56626827",
"0.56352234",
"0.56112266",
"0.5609669",
"0.55819654",
"0.5... | 0.75537604 | 0 |
Syntactic sugar for timethis with default logger at DEBUG level | def debugtime(message = None, level = logging.DEBUG, store = lambda _:_):
return timethis(message, lambda *args: logging.log(level, *args), store) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug_logger(name='test'):\n return LogAdapter(DebugLogger(), name)",
"def logger(self):\n pass",
"def debug ( self , message , *args , **kwargs ) :\n return self.logger.debug ( message , *args , **kwargs )",
"def logger_initiate():\n logger.setLevel(logging.DEBUG)\n return log... | [
"0.64855564",
"0.6156266",
"0.6101502",
"0.6100334",
"0.6082833",
"0.60534525",
"0.60445464",
"0.5964673",
"0.593482",
"0.5923773",
"0.58918554",
"0.58901954",
"0.5874944",
"0.58692116",
"0.5829989",
"0.5771339",
"0.5764214",
"0.5760625",
"0.57563484",
"0.57418877",
"0.573770... | 0.75985086 | 0 |
Returns only the alerts that have a closure label | def get_closure_alerts(alert_list):
out = []
for alert in alert_list:
if alert[2] == "Park Closure":
out.append(alert)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_all_alert():\n warning = []\n \n all_alerts = db.get_table_content(\"Alert\")\n for alert in all_alerts:\n ticker = Ticker.Ticker(alert[0], True)\n \n if ticker.is_valid and ticker.last_price > 0:\n if alert[1] == \"up\":\n if ticker.last_price >... | [
"0.5146252",
"0.49078953",
"0.4843155",
"0.48385358",
"0.4751838",
"0.47516876",
"0.47288427",
"0.4712131",
"0.4680923",
"0.46440727",
"0.46357977",
"0.46296796",
"0.46294236",
"0.46020463",
"0.45657477",
"0.4553938",
"0.4550098",
"0.4546892",
"0.45239007",
"0.45100582",
"0.4... | 0.673873 | 0 |
Creates the dictionary of required info for the map marker given a park id. If there is no closure alert for the park, it assumes the park is open. | def get_waypoint_info(park_id, DB, max_alerts_displayed=3):
info = {}
# (code, name, lon, lat, url)
park_info = DB.get_park_info(park_id)
# [(code, title, alert_type, description), (...), ...]
alert_info = DB.get_alert_info(park_id)
if park_info is None:
logging.error("Park ID: %s i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_marker_param(self, marker):\n params = {}\n if marker:\n params[self.MARKER] = marker\n return params",
"def _get_goal_info(self, last_info):\n start_ID = 4\n end_ID = start_ID + self.num_parts\n places = {}\n for ID in range(start_ID, end_ID... | [
"0.5516939",
"0.5484209",
"0.5084606",
"0.5053326",
"0.5027071",
"0.4971269",
"0.4958931",
"0.4953794",
"0.49500203",
"0.49257556",
"0.48262146",
"0.4823674",
"0.47392023",
"0.47389412",
"0.4737305",
"0.47296727",
"0.47292727",
"0.4706636",
"0.46876857",
"0.4654955",
"0.46485... | 0.6238994 | 0 |
returns True if the caps are RAW | def is_raw(caps):
rep = caps.to_string()
valid = ["video/x-raw", "audio/x-raw", "text/plain", "text/x-pango-markup"]
for val in valid:
if rep.startswith(val):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_raw(self):\n return not self.has_structure",
"def IsRegular(info):\n return (info.external_attr >> 28) == 010",
"def is_worthless(self):\n self.normalize()\n return self.all_details['normalized'] in WORTHLESS_UA_TYPES",
"def is_raw(self) -> bool:\n return len(self.segments... | [
"0.5681612",
"0.56376565",
"0.56115663",
"0.55799925",
"0.55633974",
"0.5548804",
"0.5468991",
"0.5462032",
"0.5429142",
"0.5349694",
"0.5348325",
"0.53240716",
"0.53076625",
"0.53020465",
"0.52818954",
"0.5262257",
"0.5241407",
"0.5236117",
"0.5233745",
"0.5208863",
"0.51933... | 0.7767293 | 0 |
Returns the list of demuxers, decoders and parsers available, sorted by rank | def _getSortedFactoryList(self):
def myfilter(fact):
if fact.get_rank() < 64 :
return False
klass = fact.get_klass()
if not ("Demuxer" in klass or "Decoder" in klass or "Parse" in klass):
return False
return True
reg = gst.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPUsers(self):\n model = self.tvPUsers.get_model()\n result = []\n model.foreach(lambda model, path, iter, data:\n result.append(model.get(iter, 0)[0]), None)\n result.sort()\n return result",
"def prioritized_viewers():\n\n viewers = [ep.load() fo... | [
"0.5803798",
"0.56278354",
"0.5614147",
"0.553916",
"0.54727554",
"0.54135334",
"0.52898943",
"0.5285935",
"0.5066761",
"0.5046462",
"0.50107205",
"0.4980161",
"0.49614632",
"0.49613678",
"0.4952624",
"0.49493778",
"0.49484605",
"0.49353278",
"0.49073923",
"0.49002057",
"0.48... | 0.57236826 | 1 |
Returns a list of factories (sorted by rank) which can take caps as input. Returns empty list if none are compatible | def _findCompatibleFactory(self, caps):
self.debug("caps:%s" % caps.to_string())
res = []
for factory in self._factories:
for template in factory.get_static_pad_templates():
if template.direction == gst.PAD_SINK:
intersect = caps.intersect(template... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getSortedFactoryList(self):\n def myfilter(fact):\n if fact.get_rank() < 64 :\n return False\n klass = fact.get_klass()\n if not (\"Demuxer\" in klass or \"Decoder\" in klass or \"Parse\" in klass):\n return False\n return True\n... | [
"0.71993726",
"0.5707209",
"0.540283",
"0.5378691",
"0.5331204",
"0.5251546",
"0.52479005",
"0.51990193",
"0.5153327",
"0.51474243",
"0.5144368",
"0.5135094",
"0.51296175",
"0.51014024",
"0.5099869",
"0.5071028",
"0.50625104",
"0.5040018",
"0.5008479",
"0.49882582",
"0.498816... | 0.68841034 | 1 |
Tries to link one of the factories' element to the given pad. Returns the element that was successfully linked to the pad. | def _tryToLink1(self, source, pad, factories):
self.debug("source:%s, pad:%s , factories:%r" % (source.get_name(),
pad.get_name(),
factories))
result = None
for factory in factories:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _closePadLink(self, element, pad, caps):\n self.debug(\"element:%s, pad:%s, caps:%s\" % (element.get_name(),\n pad.get_name(),\n caps.to_string()))\n if caps.is_empty():\n self.log(\"u... | [
"0.503194",
"0.49497634",
"0.47379994",
"0.46080324",
"0.4555549",
"0.45181164",
"0.44388047",
"0.44343936",
"0.4425721",
"0.4418763",
"0.4364893",
"0.43579903",
"0.43553662",
"0.4336896",
"0.43215272",
"0.43126917",
"0.42910552",
"0.42624408",
"0.42379418",
"0.42214766",
"0.... | 0.67851293 | 0 |
Ghost the given pad of element. Remove nonused elements. | def _wrapUp(self, element, pad):
if self._srcpad:
return
self._markValidElements(element)
self._removeUnusedElements(self.typefind)
self.log("ghosting pad %s" % pad.get_name())
self._srcpad = gst.GhostPad("src", pad)
self._srcpad.set_active(True)
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_padding(im, pad):\n\n return im[pad:-pad, pad:-pad]",
"def _removeUnusedElements(self, element):\n self.log(\"element:%r\" % element)\n for pad in element.src_pads():\n if pad.is_linked():\n peer = pad.get_peer().get_parent()\n self._removeUnus... | [
"0.60958475",
"0.5913197",
"0.5780126",
"0.57168174",
"0.5607434",
"0.5409166",
"0.5402955",
"0.53921175",
"0.5367817",
"0.5362773",
"0.5360787",
"0.53020066",
"0.52960426",
"0.5293717",
"0.5272031",
"0.5266434",
"0.52592355",
"0.52355856",
"0.5184225",
"0.51815903",
"0.51798... | 0.6121266 | 0 |
Mark this element and upstreams as valid | def _markValidElements(self, element):
self.log("element:%s" % element.get_name())
if element == self.typefind:
return
self._validelements.append(element)
# find upstream element
pad = list(element.sink_pads())[0]
parent = pad.get_peer().get_parent()
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setValid(self):\n self.valid = True",
"def valid(self):\n pass",
"def SetValid(self, valid):\r\n\r\n self._valid = valid",
"def SetValid(self, valid):\r\n\r\n self._valid = valid",
"def valid(self, target):",
"def valid(self) -> bool:\n pass",
"def valid(self) -> ... | [
"0.66019636",
"0.62431264",
"0.6062435",
"0.6062435",
"0.5959112",
"0.5954582",
"0.59216887",
"0.5829217",
"0.5820905",
"0.5796385",
"0.57952785",
"0.5787865",
"0.5753835",
"0.5753835",
"0.5690036",
"0.5673884",
"0.5673884",
"0.5673884",
"0.5671159",
"0.5644206",
"0.56414044"... | 0.67863214 | 0 |
Remove unused elements connected to srcpad(s) of element | def _removeUnusedElements(self, element):
self.log("element:%r" % element)
for pad in element.src_pads():
if pad.is_linked():
peer = pad.get_peer().get_parent()
self._removeUnusedElements(peer)
if not peer in self._validelements:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_discarded(self):\n while self.shrink_target.has_discards:\n discarded = []\n\n for ex in self.shrink_target.examples:\n if ex.discarded and (not discarded or ex.start >= discarded[-1][-1]):\n discarded.append((ex.start, ex.end))\n\n ... | [
"0.6208477",
"0.60841775",
"0.5987278",
"0.5718551",
"0.5528435",
"0.5527522",
"0.5503612",
"0.54967445",
"0.54903656",
"0.5440708",
"0.5410119",
"0.54018587",
"0.53677535",
"0.5367388",
"0.53665525",
"0.5362788",
"0.5347237",
"0.5332786",
"0.53268355",
"0.5318066",
"0.531519... | 0.75238466 | 0 |
Test correct formatting of the footer string | def test_format_emperor_html_footer_string(self):
self.maxDiff = 5000
# footer for a jackknifed pcoa plot without biplots
out_string = format_emperor_html_footer_string(False, True)
self.assertItemsEqual(out_string.split('\n'),
EXPECTED_FOOTER_A.split('\n')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_report_footer(self):",
"def WriteFooter(self):\n self.WriteText('}')",
"def email_footer():\n footer = \"\"\n\n return footer",
"def footer():\n\treturn \"\"\"<footer><table width=\"100%\"><th>Weather Icons by <a href=\"https://github.com/erikflowers/weather-icons\">Erik Flowers</a></th>\... | [
"0.6916973",
"0.6706198",
"0.65470004",
"0.6467227",
"0.6396218",
"0.6396218",
"0.6322183",
"0.6317668",
"0.630486",
"0.62373716",
"0.6228748",
"0.6082782",
"0.6076292",
"0.6027462",
"0.5991507",
"0.5988088",
"0.5987023",
"0.5986638",
"0.5892697",
"0.5833384",
"0.58297634",
... | 0.75619566 | 0 |
Sent by a client when the user entered a new message. The _message is sent to all people in the room. | def message(message):
room = session.get('room')
print('%s : message : %s' % (session, message['message']))
emit('_message', {'user_name': session.get('name'), 'message' : message['message']}, room=room, include_self=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_message(self, message):\n #print(f\"This message was sent: {message}\") # Writes to the console window (server side)\n self.write_message(f\"This message was sent: {message}\") # Writes message to sender",
"def on_message(self, message):\n print \"Client %s received a message : %s\" %... | [
"0.75515765",
"0.7389769",
"0.73630506",
"0.7308458",
"0.7274646",
"0.7151676",
"0.71495336",
"0.71244293",
"0.70860195",
"0.70378906",
"0.6993945",
"0.68838733",
"0.68355983",
"0.68355983",
"0.68355983",
"0.68079144",
"0.6807457",
"0.6795922",
"0.67576134",
"0.6731406",
"0.6... | 0.76300406 | 0 |
Returns true or false based on wheter or not a show ID is valid | def validate_id(show_id: int,
database_connection: mysql.connector.connect) -> bool:
try:
show_id = int(show_id)
except ValueError:
return False
try:
cursor = database_connection.cursor()
query = "SELECT showid from ww_shows where showid = %s;"
cursor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_exists(show_id: int,\n database_connection: mysql.connector.connect) -> bool:\n return validate_id(show_id, database_connection)",
"def is_id_valid(id_code: str) -> bool:\n if is_valid_gender_number(int(id_code[0:1])):\n if is_valid_year_number(int(id_code[1:3])):\n if... | [
"0.6806671",
"0.6270524",
"0.62053543",
"0.6015456",
"0.5900047",
"0.5893857",
"0.5874957",
"0.5871361",
"0.5863451",
"0.5851223",
"0.57663053",
"0.5741871",
"0.5730465",
"0.5723474",
"0.5673921",
"0.56678677",
"0.5666891",
"0.5639787",
"0.56023496",
"0.5581077",
"0.5566015",... | 0.76452476 | 0 |
Returns a show's ID based on the show's year, month and day | def convert_date_to_id(show_year: int,
show_month: int,
show_day: int,
database_connection: mysql.connector.connect) -> int:
show_date = None
try:
show_date = datetime.datetime(year=show_year,
mont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getShowId(show, conn):\n cur = conn.cursor()\n cur.execute(\"SELECT id_show FROM show WHERE name=?\", (show,))\n id_show = cur.fetchone()[0]\n return id_show",
"def identifier(self):\n return self.slug + str(self.year())",
"def search_show_id(self, series, year=None):\n # make the... | [
"0.63307565",
"0.62844926",
"0.59220475",
"0.5455561",
"0.54395676",
"0.539838",
"0.5384833",
"0.53265357",
"0.52978224",
"0.5228968",
"0.52228785",
"0.5200436",
"0.5122689",
"0.5111875",
"0.5071342",
"0.50661474",
"0.5059235",
"0.5027292",
"0.49998707",
"0.497275",
"0.494356... | 0.74980223 | 0 |
Returns a show's date based on the show's ID | def convert_id_to_date(show_id: int,
database_connection: mysql.connector.connect
) -> datetime.datetime:
try:
cursor = database_connection.cursor()
query = "SELECT showdate FROM ww_shows WHERE showid = %s;"
cursor.execute(query, (show_id,))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date_from_id(date_id):\n return Date.query.filter_by(id=date_id).first()",
"def get(self, show_id):\r\n show = Shows.query.filter_by(ShowID=show_id).first_or_404()\r\n content = jsonify({\r\n \"shows\": [{\r\n \"date\": get_iso_format(show.ShowDate),\r\n ... | [
"0.61641234",
"0.603501",
"0.5778164",
"0.5685854",
"0.5669825",
"0.5654186",
"0.5623275",
"0.5566595",
"0.553927",
"0.55132943",
"0.5504347",
"0.5438018",
"0.54188645",
"0.54028845",
"0.54028845",
"0.54028845",
"0.54028845",
"0.53803724",
"0.52745485",
"0.52659804",
"0.52588... | 0.65703845 | 0 |
Returns true or false based on whether or not a show ID exists | def id_exists(show_id: int,
database_connection: mysql.connector.connect) -> bool:
return validate_id(show_id, database_connection) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_id(show_id: int,\n database_connection: mysql.connector.connect) -> bool:\n try:\n show_id = int(show_id)\n except ValueError:\n return False\n\n try:\n cursor = database_connection.cursor()\n query = \"SELECT showid from ww_shows where showid = %s;\... | [
"0.67525923",
"0.62630546",
"0.62593603",
"0.61877805",
"0.61274064",
"0.6115206",
"0.6102666",
"0.5976109",
"0.5963691",
"0.595145",
"0.59385914",
"0.59335345",
"0.5849504",
"0.58397585",
"0.5820755",
"0.58057904",
"0.57720315",
"0.57560587",
"0.5727696",
"0.57051325",
"0.56... | 0.7385383 | 0 |
Returns true or false based on whether or not a show exists for the requested year, month and day | def date_exists(show_year: int,
show_month: int,
show_day: int,
database_connection: mysql.connector.connect) -> bool:
show_date = None
try:
show_date = datetime.datetime(show_year, show_month, show_day)
except ValueError as err:
raise ValueErr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_exists(self, date):\n for record in self.records:\n if self.date_str == record[\"date\"]:\n return True\n return False",
"def is_in_advent() -> bool:\n # Run the code from the 1st to the 24th\n return datetime.now(EST).day in range(1, 25) and datetime.now(... | [
"0.60448545",
"0.5855372",
"0.5646979",
"0.56412184",
"0.5618332",
"0.5570403",
"0.55611014",
"0.5494139",
"0.53984886",
"0.53625304",
"0.5299045",
"0.52949613",
"0.5285001",
"0.523645",
"0.5209728",
"0.51797956",
"0.51647764",
"0.5139528",
"0.5135483",
"0.51350844",
"0.51290... | 0.7940867 | 0 |
outputs automaton to a file | def output(self, out):
res = "# File: " + out + "\n# NFA\n# Q_ - the set of states\n"
for q in self.states:
res += q + ' '
res = res[0:-1]
res += "\n# Sigma_ the alphabet\n"
for a in self.alphabet:
res += a + ' '
res = res[0:-1]
res += '\... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_sequence(self):\n\n staves = self.get_sequence()\n\n with open(self.output_file, 'w') as out_file:\n\n print()\n out_file.write('')\n for num, staff in enumerate(staves):\n #out_file.write(('Sequence staff # ' + str(num) + '\\n' + staff + '\\n... | [
"0.6571705",
"0.63586414",
"0.6302915",
"0.62937003",
"0.6239766",
"0.62379503",
"0.62351996",
"0.6158247",
"0.61540806",
"0.61510086",
"0.61367595",
"0.61271656",
"0.6108666",
"0.6108193",
"0.60962945",
"0.6069241",
"0.6062584",
"0.6049",
"0.6020087",
"0.6017663",
"0.600498"... | 0.6979519 | 0 |
private function, adds prefix to each state of automaton | def _add_state(self, prefix):
for i in range(len(self.states)):
self.states[i] = prefix + self.states[i]
self.q_0 = prefix + self.q_0
for i in range(len(self.final)):
self.final[i] = prefix + self.final[i]
keys = list(self.transition.keys())
for key in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_prefix(prefix = \"Peptides\"):\n var_list = gen_cell_lines_states_replicates()\n prefix = prefix\n res_list = []\n for i in var_list:\n unit_str = prefix + \" \"\n unit_str += i\n res_list.append(unit_str)\n return res_list",
"def add_prefix(self, state_dict, prefix):\... | [
"0.7056793",
"0.69126916",
"0.62347484",
"0.62095976",
"0.61847854",
"0.6168341",
"0.61563754",
"0.6150717",
"0.6126691",
"0.60915726",
"0.6062005",
"0.6011941",
"0.59447503",
"0.5837729",
"0.5836263",
"0.5826232",
"0.5809354",
"0.5775668",
"0.57756335",
"0.57562876",
"0.5732... | 0.7660045 | 0 |
adds epsilon transitions from new state and from final states to start state | def add_epsilon_transitions(self, state):
self.states.append(state)
self.transition[state + ', .'] = [self.q_0]
for s in self.final:
self.transition[s + ', .'] = [self.q_0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeEpsilonTransition(self, currentStates):\n nextStates = self.makeTransition(currentStates, '$', True)\n #if epsilon transition did not occur or it started an infitine loop\n if not nextStates or nextStates == currentStates:\n return currentStates #end recursion\n else:... | [
"0.68393135",
"0.65938413",
"0.64521855",
"0.6450548",
"0.63267624",
"0.6233461",
"0.62020105",
"0.61552405",
"0.60778964",
"0.6039172",
"0.600596",
"0.5991411",
"0.59820724",
"0.597354",
"0.5958634",
"0.5930484",
"0.592039",
"0.5908626",
"0.5803106",
"0.5798349",
"0.5791438"... | 0.8106117 | 0 |
concatenation of two top automatons | def concat(self):
nfa2 = self.aut_stack.pop()
nfa1 = self.aut_stack.pop()
nfa1_star = nfa1.transform('X')
nfa2_star = nfa2.transform('Y')
nfa_concat = Automaton()
nfa_concat.final = nfa2_star.final
nfa_concat.q_0 = nfa1_star.q_0
nfa_concat.states = list(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_two_calls(self) -> None:",
"def union(self):\n nfa2 = self.aut_stack.pop()\n nfa1 = self.aut_stack.pop()\n\n nfa1_star = nfa1.transform('X')\n nfa2_star = nfa2.transform('Y')\n\n nfa_union = Automaton()\n nfa_union.states = list(set(nfa1_star.states).union(nfa2... | [
"0.6010168",
"0.5590357",
"0.53088385",
"0.51978385",
"0.51666653",
"0.51333827",
"0.5098099",
"0.50811666",
"0.5070868",
"0.5070868",
"0.5062796",
"0.50482255",
"0.50468844",
"0.50343424",
"0.50241405",
"0.5002939",
"0.50017685",
"0.49519634",
"0.49431038",
"0.49408138",
"0.... | 0.5941984 | 1 |
union of two top automatons in the stack | def union(self):
nfa2 = self.aut_stack.pop()
nfa1 = self.aut_stack.pop()
nfa1_star = nfa1.transform('X')
nfa2_star = nfa2.transform('Y')
nfa_union = Automaton()
nfa_union.states = list(set(nfa1_star.states).union(nfa2_star.states))
nfa_union.states.append('S')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def union(stack):\n assertArity(stack, 2)\n rhs, lhs = stack.pop(), stack.pop()\n assertType(lhs, Set)\n assertType(rhs, Set)\n return Set(lhs | rhs)",
"def union(self, *args):\n return self.phy2abs.union(*args)",
"def union(first, second):\n # Put your code here.",
"def union(self, ... | [
"0.6618299",
"0.646862",
"0.6269154",
"0.6163646",
"0.61239934",
"0.6003781",
"0.5924754",
"0.58439076",
"0.58394533",
"0.5780357",
"0.5768155",
"0.5723707",
"0.5701208",
"0.5686139",
"0.56796765",
"0.5636822",
"0.56243503",
"0.56036437",
"0.5600259",
"0.5587218",
"0.5572553"... | 0.73748773 | 0 |
converts stack to nfa | def stack2nfa(stack):
for op in stack.operations:
if op == '=push':
stack.push()
if op == '=star':
stack.star()
if op == '=concat':
stack.concat()
if op == '=union':
stack.union()
if op == '=print':
return stack... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_nfa_from_postfix(regex: str):\n\n nfa_stack = []\n\n for char in regex:\n if char == '.':\n # to concat two nfas, add an epsilon arrow from every accepting state\n # of the first to the start state of the second and turn all accepting states\n # of the first... | [
"0.57262903",
"0.5415393",
"0.5326861",
"0.5321518",
"0.5242631",
"0.51943195",
"0.5160745",
"0.5048725",
"0.5032095",
"0.49959958",
"0.49540788",
"0.49480787",
"0.4946257",
"0.4938141",
"0.49019092",
"0.48895568",
"0.48797578",
"0.48735604",
"0.48648134",
"0.48560274",
"0.48... | 0.8418595 | 0 |
~30x faster than hankel_weights_ascii | def hankel_weights(order=0):
if order == 0:
return N.frombuffer(b'\x8fC\xa7\xfbr\xaa\xfa9{\xd9\x8cj+y\x0c\xbd\xfb\xad\x9eC\xf8\xfb)=\xa3Ng\x98\xb6\x82\x1f\xbd\xc2\x9a\x84Y\xff\xc4.=\x92"\xfc\x1f\x8f\xde\x1d\xbd)p\xe2\x83i\xf2/=\xdbF\xa8W\xedI\x18\xbd+2\xef\xb8Ij0=\x18\xb0\x10x\xbdi\x11\xbd/\x8a\xee\x14\xbf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_weighted_hash(cls, word):\n\n hash_value = 0\n for char in word:\n hash_value += cls.alpha_lookup[char.lower()]\n return hash_value",
"def calc_weight(str,dict):\n for i,c in enumerate(str):\n dict[c] += 10**(len(str)-(i+1))",
"def elementary_weight_str(t... | [
"0.5841104",
"0.5627546",
"0.56087494",
"0.5506234",
"0.5505255",
"0.5500743",
"0.5451423",
"0.5432521",
"0.54016435",
"0.5336379",
"0.53301096",
"0.53196824",
"0.5318167",
"0.53105646",
"0.527878",
"0.5275149",
"0.52684206",
"0.52534753",
"0.52520436",
"0.5230744",
"0.522517... | 0.7021357 | 0 |
~30x faster than hankel_points_ascii | def hankel_points():
return N.frombuffer(b'`\rC\x94r\x199=\xb5\x8dn\xc17\xbd;=1h34\x0f\xa8>=\x02\x02X7\xb9\xf0@=\x9cb\xeb\x18\xd2\xb8B=\x92-\xdb\xd3\xe2\xb0D=\xa1H\xcd\xe3\xf6\xddF=\xba\x02\xfa\x97\xa1EI=\xc9\\!\\\x0c\xeeK=\x04^\x1b\x82\x06\xdeN=\x82=;Z\x8b\x0eQ=\x8b\x11l\x1f\xc7\xd9R=\\\x8e\xc3.O\xd5T=[\xc2\\\xe5... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_points_expansion(self):\n tot_points = 0\n if 'capi' in args.exp:\n be = ['_'] * 8\n be += self.b[ 0: 5]\n be += ['_'] * 2\n be += self.b[ 5:10]\n be += ['_'] * 2\n be += self.b[10:15]\n be += ['_'] * 2\n ... | [
"0.6047821",
"0.5564484",
"0.5453595",
"0.54502755",
"0.5411063",
"0.53716034",
"0.53273135",
"0.51558906",
"0.5144419",
"0.50915307",
"0.5058742",
"0.50469184",
"0.5027793",
"0.50248283",
"0.50232935",
"0.50198644",
"0.5017458",
"0.50110656",
"0.5005989",
"0.49963257",
"0.49... | 0.73444813 | 0 |
0th/1storder Hankeltransform of f. F_n(k) = int_0^oo r f(r) J_n(kr) dr, n=0,1 Note that Anderson's implementation includes the r factor in input function (i.e. g(r) = r f(r)), but this is not the case for this procedure. | def hankelTransform(f, k, order=0):
# Get [cached] points and weights
if order in hankelTransform.__dict__:
p, w = hankelTransform.__dict__[order]
else:
p = hankel_points()
w = hankel_weights(order=order)
hankelTransform.__dict__[order] = p, w
# Anderson's implementatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fisher_z_transform(r):\r\n if abs(r) == 1: # fisher z transform is undefined, have to return nan\r\n return nan\r\n return .5 * log((1. + r) / (1. - r))",
"def f(y):\n \n\n k = 1.0\n return y*(1-y)",
"def _f(X, g, n):\n if n == 3:\n n = 3.001 # for numerical stabil... | [
"0.64156175",
"0.62107056",
"0.61803037",
"0.6101504",
"0.60944474",
"0.60662603",
"0.60073453",
"0.597241",
"0.5946434",
"0.5942573",
"0.5939346",
"0.593745",
"0.5881655",
"0.58690447",
"0.58384955",
"0.5835517",
"0.5816677",
"0.5767257",
"0.57494926",
"0.5738316",
"0.573499... | 0.67184377 | 0 |
Return a SymPy object representing the mole fraction as a function of site fractions. | def mole_fraction(phase, active_comps, species):
result = S.Zero
site_ratio_normalization = S.Zero
# Calculate normalization factor
for idx, sublattice in enumerate(phase.constituents):
active = set(sublattice).intersection(set(active_comps))
if 'VA' in active:
site_ratio_nor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moleFraction(self, s): \n if type(s) == types.StringType:\n kk = self._contents.speciesIndex(s)\n else:\n kk = s\n x = self.moleFractions()\n return x[kk]",
"def __init__ (self,numerator,denominator=1):\n self.debug = False\n if (self.debug): pri... | [
"0.5262331",
"0.52277535",
"0.5183561",
"0.5163303",
"0.51579064",
"0.49737516",
"0.49443674",
"0.48803365",
"0.48623955",
"0.48332852",
"0.48077378",
"0.4806169",
"0.48024052",
"0.47912028",
"0.47703204",
"0.4750244",
"0.47342396",
"0.47308242",
"0.47271502",
"0.47234315",
"... | 0.55855596 | 0 |
Generate `n` points of `d` dimension | def generate(self, n, d):
self.n = n
self.d = d
self.X = np.random.rand(n, d)
self.Y = np.random.choice([0, 1], size=n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_point_cloud(n:int, d:int = 2, seed=1234) -> np.ndarray:\n initial_seed = np.random.get_state()\n np.random.seed(seed)\n points = np.random.rand(n, d)\n np.random.set_state(initial_seed)\n return points",
"def create_random_points(n):\n\n\treturn [(random.randint(0,n),random.randint(0,... | [
"0.7702441",
"0.6789765",
"0.6712974",
"0.66599315",
"0.65611076",
"0.6416333",
"0.6307879",
"0.6275656",
"0.62721384",
"0.6263218",
"0.6248472",
"0.6243516",
"0.6242459",
"0.6237172",
"0.6169062",
"0.6159954",
"0.6099011",
"0.6078545",
"0.6072246",
"0.6034091",
"0.59908116",... | 0.73754287 | 1 |
Get the AssetKey associated with this InputDefinition for the given | def get_asset_key(self, context: "InputContext") -> Optional[AssetKey]:
if callable(self._asset_key):
return self._asset_key(context)
else:
return self.hardcoded_asset_key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"key\")",
"def key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"key\")",
"def key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"key\")",
"def key(self) -> pulumi.Input[str]:\n return pulumi.get(sel... | [
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6646105",
"0.6354836",
"0.6335745",
"0.6335745",
"0.63294554",
"0.63294554",
"0.6288275",
"0.6288275",
... | 0.739318 | 0 |
Create an input mapping to an input of a child node. In a GraphDefinition, you can use this helper function to construct | def mapping_to(
self, node_name: str, input_name: str, fan_in_index: Optional[int] = None
) -> "InputMapping":
check.str_param(node_name, "node_name")
check.str_param(input_name, "input_name")
check.opt_int_param(fan_in_index, "fan_in_index")
return InputMapping(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_graph_from_input(self, input_node):\n raise NotImplementedError",
"def map_from_parent_nid(self, layer_id, parent_nids, remap_local=...):\n ...",
"def map_input_and_node(cls, onnx_model: onnx.ModelProto):\n\n input2node: Dict[str, List] = dict()\n for node in onnx_model.graph.... | [
"0.6538408",
"0.635551",
"0.6255453",
"0.59544104",
"0.5894463",
"0.58544743",
"0.5850743",
"0.5818974",
"0.57496595",
"0.5615324",
"0.5543781",
"0.5497266",
"0.5463415",
"0.5447868",
"0.54466885",
"0.5313355",
"0.5294535",
"0.52467805",
"0.5215256",
"0.52111",
"0.51674205",
... | 0.70850724 | 0 |
Return a new InputDefinition that merges this ones properties with those inferred from type signature. | def combine_with_inferred(self, inferred: InferredInputProps) -> "InputDefinition":
check.invariant(
self.name == inferred.name,
f"InferredInputProps name {inferred.name} did not align with InputDefinition name"
f" {self.name}",
)
dagster_type = self._dagster... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from_base(cls, _input: Optional[Union[Input, Dict]]) -> Optional[\"InternalInput\"]:\n if _input is None:\n return None\n if isinstance(_input, InternalInput):\n return _input\n if isinstance(_input, Input):\n # do force cast directly as there is no new fi... | [
"0.5935494",
"0.5238198",
"0.5198502",
"0.5185639",
"0.51366514",
"0.5023624",
"0.5011453",
"0.50001436",
"0.4978054",
"0.49546343",
"0.4936571",
"0.49176475",
"0.4890198",
"0.48576808",
"0.48501834",
"0.4840561",
"0.48357502",
"0.48231715",
"0.4815088",
"0.48061097",
"0.4803... | 0.7089827 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.