query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Test with the default `key` function.
def test_default(self): iterables = [xrange(4), xrange(7), xrange(3, 6)] eq_(sorted(reduce(list.__add__, [list(it) for it in iterables])), list(collate(*iterables)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def func2(key):\n return key in my_test_dict.keys()", "def func4(key):\n return key in list(my_test_dict.keys())", "def _check_key(self, key):\n raise NotImplementedError", "def def_key(x):\n return x", "def match_key(name, func, fallback=None, default=None):\n return key_predicate(name,...
[ "0.7282693", "0.71756196", "0.71305937", "0.7098984", "0.7057804", "0.7001745", "0.6984697", "0.69285727", "0.6883116", "0.68428445", "0.681415", "0.681415", "0.67970467", "0.6711432", "0.6591156", "0.6535495", "0.6524363", "0.65238", "0.64847535", "0.6474364", "0.64628536", ...
0.0
-1
Test using a custom `key` function.
def test_key(self): iterables = [xrange(5, 0, -1), xrange(4, 0, -1)] eq_(list(sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True)), list(collate(*iterables, key=lambda x: -x)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def func2(key):\n return key in my_test_dict.keys()", "def func4(key):\n return key in list(my_test_dict.keys())", "def test_key_predicate(datum):\n return 0 < datum", "def check_key(key, value):\n return lambda event, data: data[key] == value", "def def_key(x):\n return x", "def m...
[ "0.7484835", "0.72601134", "0.7210287", "0.7091431", "0.6978449", "0.69044787", "0.69040096", "0.6876834", "0.66988754", "0.6654753", "0.6654753", "0.6654383", "0.6632204", "0.6570202", "0.6456564", "0.6436678", "0.64096034", "0.6403737", "0.6399561", "0.6399555", "0.63975805...
0.0
-1
Be nice if passed an empty list of iterables.
def test_empty(self): eq_([], list(collate()))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _assert_non_empty(iterable):\n first_elem = six.next(iterable, None)\n assert first_elem is not None, first_elem\n return itertools.chain([first_elem], iterable)", "def safe_iterator(i):\n return i or []", "def non_none(iterable: Iterable[Optional[_T]]) -> Iterable[_T]:\n return (x for x in ...
[ "0.697166", "0.6827782", "0.6481945", "0.640688", "0.640688", "0.636432", "0.6197909", "0.6123634", "0.6121327", "0.6044029", "0.60292834", "0.60119545", "0.5998964", "0.59287125", "0.5925197", "0.5832315", "0.5824543", "0.5822089", "0.5778827", "0.5768213", "0.57573366", "...
0.53930485
83
Work when only 1 iterable is passed.
def test_one(self): eq_([0, 1], list(collate(xrange(2))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterable(arg):\n return isinstance(arg, collections.Iterable) and not isinstance(arg, six.string_types)", "def oneIteration(self):\n\t\traise NotImplementedError", "def _ensure_iterable(x):\n if isinstance(x[0], Iterable):\n if len(x) > 1:\n raise TypeError(\"Either Iterable or vari...
[ "0.66168714", "0.64325726", "0.62727374", "0.6237593", "0.6157956", "0.6146108", "0.60707337", "0.6051359", "0.5916164", "0.588313", "0.5857233", "0.5807984", "0.57936543", "0.5764656", "0.57329", "0.5730603", "0.5715446", "0.5656539", "0.56495816", "0.5647118", "0.56263393",...
0.0
-1
Test the `reverse` kwarg.
def test_reverse(self): iterables = [xrange(4, 0, -1), xrange(7, 0, -1), xrange(3, 6, -1)] eq_(sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True), list(collate(*iterables, reverse=True)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _can_reverse(self):\n return not bool(self._reverse_callback())", "def set_reverse(rev):\n global is_reverse\n is_reverse = rev", "def testSortingReverse(self):\n if self.sortingReverse.lower() in [\"1\", \"yes\", \"true\", \"on\"]:\n self.assertTrue(\n self.co...
[ "0.73392296", "0.68163896", "0.6537939", "0.6523438", "0.63412285", "0.6307833", "0.6299878", "0.6275159", "0.61790586", "0.613202", "0.6116976", "0.60824007", "0.6046022", "0.5983002", "0.5976699", "0.5970638", "0.594553", "0.59288", "0.59192276", "0.58404404", "0.574365", ...
0.0
-1
Return a value corresponding to the specified key in the (possibly nested) dictionary d. If there is no item with that key, return default.
def search(d, key, default=None): stack = [iter(d.items())] while stack: for k, v in stack[-1]: if isinstance(v, dict): stack.append(iter(v.items())) break elif k == key: return v else: stack.pop() return def...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_default(ddict, key, default):\n if ddict is None or key not in ddict or ddict[key] is None:\n return default\n return ddict[key]", "def get(self, k, d=None):\n try:\n return self[k]\n except KeyError:\n return d", "def get_from_dict(d, k):\n try:\n ...
[ "0.7717753", "0.76185805", "0.7615463", "0.7520465", "0.72834295", "0.72716373", "0.7218349", "0.7151886", "0.71330154", "0.71017414", "0.7101235", "0.7039617", "0.70120084", "0.7002762", "0.69949806", "0.6990771", "0.6963007", "0.6906186", "0.690185", "0.68835884", "0.684690...
0.7036676
12
This function get latest block from diffetent APIs and write in json file
def get_info(): with open('explorers.json', 'r') as file: block_expl_info = json.load(file) BLOCK_EXPL_INFO['block_explorers'] = [{'analytics': [None, None]} for i in range(len(block_expl_info))] analytic_thread = threading.Thread(target=get_analytics) analytic_thread.start() print(analytic_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_latest_data():\n try:\n print '\\nRequesting new data.....\\n'\n response = get(\"https://api.myjson.com/bins/2csub\")\n if response.status_code is 200:\n print '\\nSuccess (200) in downloading data\\n'\n current_json = response.json()\n set_backup_d...
[ "0.6503777", "0.6334233", "0.62467307", "0.62189907", "0.61117643", "0.6050079", "0.60054547", "0.58136255", "0.58010566", "0.57338744", "0.5697717", "0.5620307", "0.55549675", "0.5551227", "0.55333763", "0.55333763", "0.55144376", "0.5498901", "0.5490922", "0.5452683", "0.54...
0.5848694
7
benanne lasagne ortho init (faster than qr approach)
def orthogonal(shape): # taken from https://gist.github.com/kastnerkyle/f7464d98fe8ca14f2a1a flat_shape = (shape[0], np.prod(shape[1:])) a = np.random.normal(0.0, 1.0, flat_shape) u, _, v = np.linalg.svd(a, full_matrices=False) q = u if u.shape == flat_shape else v # pick the one with the correct s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orthopyroxene():\n\n rho = 3304.\n\n C = np.zeros((6,6), dtype=float)\n C[0,0] = 236.9; C[0,1] = 79.6; C[0,2] = 63.2; C[0,3] = 0.; C[0,4] = 0.; C[0,5] = 0.\n C[1,0] = C[0,1]; C[1,1] = 180.5; C[1,2] = 56.8; C[1,3] = 0.; C[1,4] = 0.; C[1,5] = 0.\n...
[ "0.64098346", "0.63685274", "0.60832596", "0.6028435", "0.5947269", "0.59407026", "0.579842", "0.5745779", "0.5697982", "0.5618773", "0.5618319", "0.56166106", "0.5591402", "0.55160123", "0.55101013", "0.55034405", "0.54688793", "0.5467705", "0.54606175", "0.54093295", "0.539...
0.5047098
62
Adds a text element to a specified parent.
def appendElement(document, parentEl, elementType, elementText): el = document.createElement(elementType) textEl = document.createTextNode(elementText) el.appendChild(textEl) parentEl.appendChild(el)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def appendXmlTextNode(tag_name, text, parent):\n\tel = xmlTextNode(tag_name, text)\n\tparent.append(el)\n\treturn el", "def newTextChild(self, parent, name, content):\n if parent is None: parent__o = None\n else: parent__o = parent._o\n ret = libxml2mod.xmlNewTextChild(parent__o, self._o, na...
[ "0.7619326", "0.7439826", "0.6652759", "0.64436185", "0.6351779", "0.63348407", "0.6281517", "0.62726134", "0.62400335", "0.6226029", "0.6225046", "0.6085889", "0.60642475", "0.60318387", "0.60238725", "0.60130715", "0.5980843", "0.5944152", "0.59254986", "0.5901929", "0.5814...
0.69940925
2
Returns the text of a child node found by name. Only one such named child is expected.
def getSingleChildTextByName(rootNode, name): try: nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name] if len(nodeList) > 0: return nodeList[0] else: return None except AttributeError: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_child(self, name):\n for n in self.children:\n if n.name == name:\n return n\n\n raise ChildError(\"Can't find child node '{name}'\".format(**locals()))", "def get_child(node, name):\r\n for child in node.childNodes:\r\n if child.localName == name:\r\n ...
[ "0.73368084", "0.727436", "0.709972", "0.69880795", "0.6772942", "0.66547203", "0.6558581", "0.6543391", "0.63135356", "0.6266445", "0.61968386", "0.6183661", "0.6125282", "0.610355", "0.6097007", "0.60358995", "0.6027794", "0.6010082", "0.5985832", "0.5980697", "0.5976921", ...
0.7597116
0
Returns the text of a child node found by name and namespaceURI. Only one such named child is expected.
def getSingleChildTextByNameNS(rootNode, ns, name): try: nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name and e.namespaceURI == ns] if len(nodeList) > 0: return nodeList[0] else: return None except AttributeError: return No...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_child(node, name):\r\n for child in node.childNodes:\r\n if child.localName == name:\r\n return child", "def getSingleChildTextByName(rootNode, name):\n try:\n nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name]\n if len(nodeList) > 0:\...
[ "0.70851547", "0.70435005", "0.6444718", "0.6246965", "0.6225065", "0.61497194", "0.60729676", "0.59668297", "0.5915806", "0.58188534", "0.5817289", "0.58145833", "0.5802411", "0.57501686", "0.5727612", "0.57120925", "0.5695159", "0.5669567", "0.5641456", "0.5641404", "0.5610...
0.7306041
0
Returns a child node found by name. Only one such named child is expected.
def getSingleChildByName(rootNode, name): nodeList = [e for e in rootNode.childNodes if e.localName == name] if len(nodeList) > 0: return nodeList[0] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_child(self, name):\n for n in self.children:\n if n.name == name:\n return n\n\n raise ChildError(\"Can't find child node '{name}'\".format(**locals()))", "def get_child(self, name):\n return next((x for x in self.children if x.name == name), None)", "def ...
[ "0.86502516", "0.8376062", "0.8369748", "0.8116588", "0.8055217", "0.80475324", "0.74776024", "0.72721773", "0.7254135", "0.70476526", "0.7046877", "0.6960973", "0.6834015", "0.68138915", "0.67392963", "0.67390233", "0.6701957", "0.6683626", "0.6664809", "0.6658932", "0.66554...
0.7313616
7
Returns a child node found by name and namespaceURI. Only one such named child is expected.
def getSingleChildByNameNS(rootNode, ns, name): nodeList = [e for e in rootNode.childNodes if e.localName == name and e.namespaceURI == ns] if len(nodeList) > 0: return nodeList[0] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_child(node, name):\r\n for child in node.childNodes:\r\n if child.localName == name:\r\n return child", "def get_child(self, name):\n for n in self.children:\n if n.name == name:\n return n\n\n raise ChildError(\"Can't find child node '{name}'\...
[ "0.7954468", "0.7309337", "0.68384355", "0.6826391", "0.6678914", "0.6557882", "0.65442234", "0.64864975", "0.64746964", "0.63713264", "0.6350687", "0.63305914", "0.6259071", "0.6197164", "0.61778927", "0.6077632", "0.60627794", "0.6056079", "0.602803", "0.5981976", "0.595238...
0.7256824
2
Returns a descendent node found by a list of names forming a path. The path is expected to define a unique node.
def getSingleChildByPath(rootNode, path): parentNode = rootNode for name in path: node = getSingleChildByName(parentNode, name) if node == None: return None else: parentNode = node return node
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_find_by_name( fdt, node_name, starting_node = 0, multi_match=False ):\n\n matching_nodes = []\n matching_node = None\n\n search_active = False\n if starting_node == \"/\" or starting_node == 0:\n search_active = True\n\n for node in fdt.node_iter():\n ...
[ "0.6124487", "0.6115838", "0.593276", "0.5823367", "0.5745633", "0.569657", "0.56698596", "0.5564221", "0.55456084", "0.5510131", "0.5459823", "0.5403007", "0.5365805", "0.5351223", "0.5350362", "0.5321328", "0.52815527", "0.5258361", "0.5242366", "0.51757175", "0.5166429", ...
0.552407
9
Returns a descendent node found by a list of names and namespaceURIs forming a path. The path is expected to define a unique node.
def getSingleChildByPathNS(rootNode, path): parentNode = rootNode for (ns, name) in path: node = getSingleChildByNameNS(parentNode, ns, name) if node == None: return None else: parentNode = node return node
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ParsePath(p_names: Iterable[Text]) -> gnmi_pb2.Path:\n gnmi_elems = []\n for word in p_names:\n word_search = _RE_PATH_COMPONENT.search(word)\n if not word_search: # Invalid path specified.\n raise XpathError('xpath component parse error: %s' % word)\n if word_search.group('key') is not None: ...
[ "0.5617993", "0.5379932", "0.5344396", "0.52256453", "0.5165489", "0.5163145", "0.5140036", "0.49797037", "0.49483255", "0.49193937", "0.4904224", "0.4882593", "0.48682582", "0.48599708", "0.48452106", "0.482554", "0.47848898", "0.4771717", "0.47439066", "0.47428063", "0.4738...
0.5693317
0
Returns all child nodes of a specified name.
def getChildrenByName(rootNode, name): return [e for e in rootNode.childNodes if e.localName == name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def findChildren(self, name):\n\n # Note: this returns a list of all the children of a given\n # name, irrespective of the depth of look-up.\n \n children = []\n \n for child in self.getAllChildren():\n if child.getName() == name:\n children.appen...
[ "0.78755844", "0.76069707", "0.70648605", "0.6875181", "0.686096", "0.68549895", "0.6836145", "0.67805845", "0.6676841", "0.6539384", "0.65334934", "0.65248793", "0.6507252", "0.6486434", "0.6399938", "0.6362787", "0.63362265", "0.6320614", "0.6318085", "0.6318085", "0.629610...
0.79214627
0
Returns all child nodes of a specified name and namespaceURI.
def getChildrenByNameNS(rootNode, ns, name): return [e for e in rootNode.childNodes if e.localName == name and e.namespaceURI == ns]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getChildrenByName(rootNode, name):\n return [e for e in rootNode.childNodes if e.localName == name]", "def getElements(self, name=\"\"):\n\n if not name:\n return self.children\n else:\n elements = []\n for element in self.children:\n if elemen...
[ "0.7223935", "0.6433308", "0.6407375", "0.6367358", "0.63064814", "0.6166133", "0.6032213", "0.59840125", "0.59068906", "0.5855462", "0.5814537", "0.58058417", "0.577752", "0.5765865", "0.5721846", "0.5721846", "0.5707831", "0.5676966", "0.5676966", "0.564972", "0.5647398", ...
0.77882755
0
Returns the value of an attribute specified by local name. The attribute's namespace is ignored.
def getAttributeByLocalName(element, localName): attrs = element.attributes for idx in xrange(attrs.length): attr = attrs.item(idx) if attr.localName == localName: return attr.value return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getattribute(self, name):\n return self.attributes[name]", "def getAttribute(self, name):\n \n return self[self._name][name]", "def get_attr(attributes, name):\n try:\n return attributes.getValue(name)\n except KeyError:\n return None", "def get_attribute_by_name(...
[ "0.70017785", "0.6997067", "0.68574476", "0.68190736", "0.68038845", "0.67893267", "0.6683643", "0.66774267", "0.66566056", "0.6655", "0.66367906", "0.6598971", "0.6485137", "0.6479439", "0.6449892", "0.635203", "0.6340864", "0.62663764", "0.6259211", "0.6237172", "0.6237172"...
0.69933337
2
Process a /results command.
def results(update: Update, context: CallbackContext): #update.effective_message.reply_text(text="here are all new results") if update is not None: context.bot.send_chat_action( chat_id=update.effective_chat.id, action=ChatAction.TYPING) get_latest_result(update, context) if update.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_result(self, results: List[Dict], **info):\n pass", "def process(self, results):\n raise NotImplementedError", "def process_results(self, response, results):\n return results", "def process_results(self, response, results):\n return results", "def process_results(self...
[ "0.6734966", "0.67013997", "0.65604585", "0.65604585", "0.6508539", "0.6383611", "0.63752776", "0.628759", "0.62337244", "0.60858846", "0.60244346", "0.5963668", "0.5954561", "0.5951688", "0.592082", "0.58933157", "0.58777326", "0.5819628", "0.5786597", "0.5752275", "0.573779...
0.55912423
33
Add new node to the Pipeline
def add_node(self, new_node: 'GraphNode'): self.operator.add_node(new_node)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_node(self, node):", "def add_node(self, node):\n self.nodes.append(node)", "def add_node (self, node):\n raise NotImplementedError", "def add_node(self, node):\n self.nodes.add(node)", "def addNode(self, node: Node):\n self.nodes.append(node)", "def add_node(self, node):\n...
[ "0.78037673", "0.75197977", "0.74303645", "0.74014753", "0.7204696", "0.7202427", "0.7178709", "0.7173464", "0.715541", "0.7050441", "0.7048333", "0.70343333", "0.703212", "0.70309037", "0.7029448", "0.7029448", "0.70204383", "0.70176816", "0.7000545", "0.69609106", "0.693755...
0.7537602
1
Replace old_node with new one.
def update_node(self, old_node: 'GraphNode', new_node: 'GraphNode'): self.operator.update_node(old_node, new_node)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_node(old_node: Node, new_node: Node):\n assert old_node.graph is new_node.graph\n graph = old_node.graph\n # save output edges and reconnect them to new node\n for i in range(len(old_node.out_nodes())):\n graph.add_edge(new_node.id, old_node.out_node(i).id, **old_node.out_edge(i))\n ...
[ "0.7680387", "0.7633826", "0.7320932", "0.73136884", "0.7191044", "0.7059257", "0.6879529", "0.6699083", "0.65904534", "0.6554778", "0.6548092", "0.6536816", "0.6461663", "0.64516395", "0.6449112", "0.63957167", "0.63931674", "0.6388096", "0.6375951", "0.6366883", "0.63541114...
0.73606163
2
Replace the subtrees with old and new nodes as subroots
def update_subtree(self, old_subroot: 'GraphNode', new_subroot: 'GraphNode'): self.operator.update_subtree(old_subroot, new_subroot)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_replace(self,node):\r\n self.feature_index = node.feature_index\r\n self.threshold = node.threshold\r\n self.label = node.label\r\n self.left = node.left\r\n self.right = node.right\r\n self.substitute = node.substitute\r\n if node.left is not None and node...
[ "0.7107235", "0.65856475", "0.6365465", "0.63301456", "0.625012", "0.6236693", "0.61715674", "0.61310095", "0.6120327", "0.60683495", "0.6065253", "0.6024953", "0.6012735", "0.5961078", "0.5948224", "0.5947182", "0.59322995", "0.5925321", "0.5905774", "0.5905076", "0.58694637...
0.6714457
1
Delete chosen node redirecting all its parents to the child.
def delete_node(self, node: 'GraphNode'): self.operator.delete_node(node)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self):\n self.parent.delete_node(self)", "def delete_one_child(self, node):\n if node.left != None:\n child = node.left\n else:\n child = node.right\n \n parent = node.parent\n if parent.left == node:\n parent.left = ch...
[ "0.78784764", "0.7650336", "0.715978", "0.71591645", "0.71019995", "0.70694184", "0.70303255", "0.6992636", "0.6982972", "0.696881", "0.6946081", "0.6915932", "0.6914303", "0.6887968", "0.6835174", "0.6793784", "0.67868143", "0.67830443", "0.677916", "0.67647326", "0.6760859"...
0.62219507
71
Delete the subtree with node as subroot.
def delete_subtree(self, subroot: 'GraphNode'): self.operator.delete_subtree(subroot)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_root(self, node):\n current = node\n successor = self.find_successor(current) \n temp_height = current.height\n current.height = successor.height\n successor.height = temp_height\n\n if successor != None:\n self.root = successor\n parent = ...
[ "0.75925773", "0.7480435", "0.7424216", "0.71247655", "0.70918965", "0.70537895", "0.6969854", "0.6895656", "0.68567795", "0.682668", "0.67609817", "0.66893965", "0.66813046", "0.6672785", "0.667115", "0.66323125", "0.6606388", "0.6594874", "0.6567626", "0.6545911", "0.652475...
0.8428926
0
compute the style factor ret
def get_factor_ret(date,date_lag): ret = get_ret(date_lag) cap = get_cap(date) style_factor = get_barra_factor_from_sql(date) data_all = pd.concat([ret,cap,style_factor],axis = 1,join = 'inner') X = pd.DataFrame(data_all.iloc[:,2:]) X = sm.add_constant(X) wls_model = sm.WLS(pd.DataFrame(data...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def css(self):\n return (self.table[0, 0] * self.table[1, 1] - self.table[0, 1] * self.table[1, 0]) / \\\n ((self.table[0, 0] + self.table[0, 1]) * (self.table[1, 0] + self.table[1, 1]))", "def get_style_loss(curr_style,target_style):\n height,width,channels = curr_style.get_shape().as_li...
[ "0.6677056", "0.5938655", "0.5827328", "0.5765011", "0.5739071", "0.56346804", "0.54632366", "0.54539573", "0.53806096", "0.53754634", "0.5356752", "0.5328772", "0.5323262", "0.5297223", "0.5296184", "0.5294494", "0.5294494", "0.5257359", "0.52487844", "0.52442724", "0.523510...
0.0
-1
compute the style factor's ret, use WLS regression
def factor_ret(self): factor_ret_all = pd.DataFrame([]) for i in range(len(self.trade_date) - self.timelog): date = self.trade_date.iloc[i,0] date_lag = self.trade_date.iloc[i + self.timelog,0] factor_ret = get_factor_ret(date,date_lag) factor_ret_all = p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WLS(store):\n calcweighted(store)\n store['regsampler'].update_yvec(store['yvectil'])\n store['regsampler'].update_xmat(store['xmattil'])\n return store['regsampler'].sample()", "def get_factor_ret(date,date_lag):\n ret = get_ret(date_lag)\n cap = get_cap(date)\n style_factor = get_barra...
[ "0.6541837", "0.6528602", "0.6300997", "0.5896583", "0.5835056", "0.58338577", "0.5816256", "0.5798426", "0.5788605", "0.5721435", "0.57168084", "0.5705413", "0.56867045", "0.56772465", "0.5673809", "0.5667356", "0.56673163", "0.56629777", "0.5637043", "0.56341547", "0.560991...
0.0
-1
compute the hs300 and zz500 weekly exposure on style factors
def factor_exposure(self): exp_hs_all = pd.DataFrame([]) exp_zz_all = pd.DataFrame([]) for i in range(len(self.weekly_date)): date = self.weekly_date.iloc[i,0] factor = get_barra_factor_from_sql(date) factor['secID'] = factor.index.tolist() stockli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exposure():\n def r(x):\n return x/6e4\n\n def w(x):\n return int(x*6e4)\n return r, w", "def get_weight(ew1, ew2):\n dw = flu.delta_epiweeks(ew1, ew2)\n yr = 52.2\n hl1, hl2, bw = yr, 1, 4\n a = 0.05\n #b = (np.cos(2 * np.pi * (dw / yr)) + ...
[ "0.61604285", "0.56509274", "0.55025834", "0.53923845", "0.53762066", "0.5370133", "0.5294281", "0.52752477", "0.5265615", "0.520303", "0.5171824", "0.51513815", "0.5132893", "0.5092595", "0.5088409", "0.5087371", "0.50813", "0.5065104", "0.50638103", "0.5060144", "0.50426376...
0.5779782
1
r""" Run black on the current source tree (all ``.py`` files).
def blacken( c, line_length=79, folders=None, check=False, diff=False, find_opts=None ): config = c.config.get("blacken", {}) default_folders = ["."] configured_folders = config.get("folders", default_folders) folders = folders or configured_folders default_find_opts = "" configured_find_op...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blacken(session):\n session.install(DEPS[\"black\"])\n check_black = get_path(\"scripts\", \"blacken_all_files.py\")\n session.run(\"python\", check_black)", "def black(context):\n exec_cmd = \"black --check --diff .\"\n run_cmd(context, exec_cmd)", "def test_black(self):\n chdir(REPO...
[ "0.733671", "0.7141421", "0.6959907", "0.6956898", "0.68009764", "0.6798593", "0.6255054", "0.5877577", "0.5772148", "0.5749536", "0.5534074", "0.54764223", "0.54479384", "0.53870153", "0.5380241", "0.5284122", "0.52231586", "0.5213798", "0.51873237", "0.5178605", "0.5165765"...
0.5832402
8
Run all common formatters/linters for the project.
def all_(c): # TODO: contextmanager config, if we don't already have that c.config.run.echo = True blacken(c) lint(c)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commands_all():\n lint()\n complexity()\n coverage()", "def run(self):\n check_paths = PACKAGES + [\n 'setup.py',\n 'tests',\n 'util',\n ]\n ignore = [\n 'doc/',\n ]\n\n # try to install missing dependencies a...
[ "0.6045163", "0.59757775", "0.5945999", "0.5914624", "0.58727103", "0.5807249", "0.57904285", "0.5688181", "0.5572407", "0.5500889", "0.54245555", "0.5423646", "0.5422726", "0.539087", "0.53885156", "0.5384772", "0.5380067", "0.5378278", "0.5339264", "0.53275114", "0.53085154...
0.5965984
2
Read taxonomy nodes.dmp file into pandas DataFrame
def read_nodes_dmp(fname): df = pd.read_csv(fname, sep="|", header=None, index_col=False, names=['tax_id', 'parent_tax_id', 'rank', 'embl_code', 'division_id', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_node_file(self):\n self.node_df = gt.remove_colons(pd.read_csv(self.node_file, dtype=str))", "def nodes_df_creation(self, path: str) -> pyspark.sql.dataframe.DataFrame:\n try:\n nodes_df = self.spark.read.parquet(path)\n except OSError:\n print('cannot open', ...
[ "0.6789381", "0.6212274", "0.615097", "0.6114801", "0.6108535", "0.5889607", "0.5821102", "0.58102983", "0.57548654", "0.56308955", "0.5610583", "0.56097096", "0.5609186", "0.55935985", "0.5593163", "0.5582398", "0.55768555", "0.55726385", "0.55648285", "0.55583286", "0.55448...
0.78661364
0
Read taxonomy names.dmp file into pandas DataFrame
def read_names_dmp(fname): df = pd.read_csv(fname, sep="|", header=None, index_col=False, names=["tax_id", "name_txt", "unique_name", "name_class"]) return df.assign(name_txt = lambda x: x['name_txt'].str.strip(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_nodes_dmp(fname):\n df = pd.read_csv(fname, sep=\"|\", header=None, index_col=False,\n names=['tax_id', \n 'parent_tax_id',\n 'rank', \n 'embl_code',\n 'division_id', \n ...
[ "0.68054324", "0.5834878", "0.5798597", "0.5793068", "0.57881135", "0.57818484", "0.5780603", "0.5767426", "0.5762671", "0.5683659", "0.5658958", "0.5644294", "0.56357336", "0.557491", "0.55712473", "0.55641025", "0.55571115", "0.5556157", "0.5546592", "0.55335677", "0.550611...
0.7467837
0
args one or more file names containing descriptor code kwargs a dict containing a mapping between descriptor filename extensions and actual paths to the definition files in the future this could be replaced with the preloaded context for the extension but this is easiest for now
def vidl(*args, **kwargs): loadstring = '' #now read the file definitions for file in args: ext = os.path.splitext(file)[1][1:] # get the extension without the dot if ext == 'ddf': loadstring += open(file).read() continue elif ext == 'rdf': continu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_file_args(self):\n spec = {\n 'input': [\n '$[[codeFile]]'\n ]\n }\n parameters = pd.create_parameter_index([\n {\n 'id': 'codeFile',\n 'datatype': 'file',\n 'defaultValue': 'src/helloworld.py...
[ "0.5796783", "0.55400974", "0.5462255", "0.5362446", "0.5343054", "0.5336746", "0.53364706", "0.5328841", "0.5306926", "0.5260287", "0.5257919", "0.5232348", "0.5188024", "0.51780456", "0.51419365", "0.5123478", "0.5110492", "0.50916123", "0.5067574", "0.5067574", "0.50532025...
0.5347166
4
This does the ranking of whether the Patient is a match/possible/No
def categorize_distances(row): category_name = "" try: distance_value = row["dist"] value = float(distance_value) if value == 0.000000: category_name = "Match" elif 0.000001 <= value <= 0.1: category_name = "Possible Match" elif value > 0.1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arsenalResults(dat):\n arsScore = int(dat[0])\n othScore = int(dat[2])\n if arsScore > othScore:\n res = 1\n elif arsScore == othScore:\n res = 2\n else:\n res = 0\n return res", "def recip_rank(recs, truth):\n good = recs['item'].isin(truth.index)\n npz, = np.non...
[ "0.58622277", "0.5766292", "0.5724738", "0.5672559", "0.56332046", "0.5531462", "0.5514099", "0.5505791", "0.55048496", "0.54982716", "0.5472145", "0.54713345", "0.54514253", "0.5431467", "0.5430985", "0.541267", "0.5409298", "0.53975964", "0.53651744", "0.5355841", "0.535556...
0.0
-1
Checks authorization of a rule against the target in this context. This function is not to be called directly. Calling the function with a target that evaluates to None may result in policy bypass. Use 'authorize_on_' calls instead.
def __authorize(context, rule, target=None): target = target or {'tenant': context.tenant} return get_enforcer().authorize( rule, target, context.to_dict(), do_raise=True, exc=trove_exceptions.PolicyNotAuthorized, action=rule)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrap_check_policy(func):\n @functools.wraps(func)\n def wrapped(self, context, target_obj, *args, **kwargs):\n check_policy(context, func.__name__, target_obj)\n return func(self, context, target_obj, *args, **kwargs)\n\n return wrapped", "def authorization_rule(self) -> Optional[pulum...
[ "0.59729636", "0.58791226", "0.57168037", "0.56584775", "0.55937326", "0.5568693", "0.55458856", "0.55406976", "0.5506479", "0.550026", "0.5477174", "0.5477174", "0.5420243", "0.53873324", "0.5317387", "0.5297428", "0.5296398", "0.52627957", "0.52248955", "0.5222644", "0.5208...
0.7202618
0
'To assume as true in the absence of proof to the contrary.' Returns a modified transaction with this value set if the value of the item is not already known. If a value has already been fetched or presumed, this will be a noop. If modified, the presumed value will be available via `get`, and will additionally check yo...
def presume( transaction: VersionedTransaction, table: TableNameOrResource, item_key: ItemKey, item_value: Optional[Item], ) -> VersionedTransaction: if item_value is not None: for key_attr, key_val in item_key.items(): assert item_value[key_attr] == key_val, "Item key must match...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_batch_get_lazy_load():\n t = VersionedTransaction(dict())\n table_a = ItemTable(\"a\")\n table_b = ItemTable(\"b\")\n\n a1_k = dict(id=\"a1\")\n a2_k = dict(id=\"a2\")\n b1_k = dict(id=\"b1\")\n\n a3_k = dict(id=\"a3\")\n\n def triple_get(t: VersionedTransaction) -> VersionedTransa...
[ "0.5932803", "0.5802937", "0.5779788", "0.5756236", "0.5724148", "0.56774515", "0.5541173", "0.55110294", "0.5491138", "0.5489476", "0.53459036", "0.5339431", "0.5324479", "0.52662617", "0.522534", "0.5209724", "0.520189", "0.51962876", "0.5192975", "0.51924634", "0.5159292",...
0.6724734
0
Idempotent definition of key attribute schema for the given table without forcing any IO operations/effects up front. The main reason you might want to do this is if you need to do a `put`, because `put` cannot infer the shape of your key. If the table definition is already present, this is a noop.
def define_table( transaction: VersionedTransaction, table: TableNameOrResource, *key_attributes: str, ) -> VersionedTransaction: assert len(key_attributes) > 0 and len(key_attributes) <= 2 if _table_name(table) in transaction.tables: return transaction return VersionedTransaction( table...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_table_schema(table_desc, table_name, schema):\n table_desc['TableName'] = table_name\n table_desc['AttributeDefinitions'] = [{\n 'AttributeName': item['name'],\n 'AttributeType': DynamoStubber._encode_type(item['type'])\n } for item in schema]\n ...
[ "0.60570586", "0.5902038", "0.5678898", "0.5671591", "0.5581425", "0.55520034", "0.5543876", "0.55083936", "0.53274363", "0.53022087", "0.52965194", "0.5224999", "0.52233547", "0.5223007", "0.5222796", "0.52002573", "0.51673585", "0.5139907", "0.5126423", "0.51261", "0.511605...
0.6186573
0
Given a relpath like drake/pkg/res.txt or external/repo/pkg/res.txt, find the data file and return its path
def find_data(relpath): # Because we are in a py_binary, Bazel's wrapper script sets up our # $PYTHONPATH to have our resources somewhere on a sys.path entry. for one_path in sys.path: possible = os.path.join(one_path, relpath) if os.path.exists(possible): return possible rai...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_path(data_path):\n\treturn os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path", "def get_data_file(f):\n if os.path.isfile(f):\n path = f\n\n else:\n p = pkg_resources.resource_filename('PaSDqc', \"db/{}\".format(f))\n \n if os.path.isfile(p):\n ...
[ "0.71274626", "0.6904814", "0.6769969", "0.6497312", "0.6490332", "0.6470966", "0.64500815", "0.64413446", "0.64217675", "0.6399083", "0.63932604", "0.63386345", "0.6311808", "0.62965494", "0.62960714", "0.6275206", "0.62670004", "0.62568855", "0.62269145", "0.62260854", "0.6...
0.7789457
0
convert kitti points(N, >=3) to voxels. This version calculate everything in one loop. now it takes only 4.2ms(complete point cloud) with jit and 3.2ghz cpu.(don't calculate other features)
def points_to_voxel_plus( points, voxel_size, coors_range, max_points=35, reverse_index=True, max_voxels=20000, ): if not isinstance(voxel_size, np.ndarray): voxel_size = np.array(voxel_size, dtype=points.dtype) if not isinstance(coors_range, np.ndarra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def voxelize(self, points):\n voxels, coors, num_points = [], [], []\n for res in points:\n res_voxels, res_coors, res_num_points = self.pts_voxel_layer(res)\n voxels.append(res_voxels)\n coors.append(res_coors)\n num_points.append(res_num_points)\n ...
[ "0.6589704", "0.65418935", "0.654082", "0.6479842", "0.6015914", "0.6004015", "0.5937598", "0.5853999", "0.58375835", "0.5777515", "0.5760727", "0.5734398", "0.5712557", "0.5698626", "0.56847566", "0.5652651", "0.5626064", "0.56038326", "0.5576575", "0.5576291", "0.5574701", ...
0.50797534
81
Create simple routes and then register api blueprints.
def register_blueprints(app): @app.route('/') def hello(): return '<html><body>{{ cookiecutter.project_name }} - Hello World</body></html>' @app.route('/healthz') def healthz(): {% if cookiecutter.use_sqlalchemy == 'True' %} """ Verify the DB is there. :return: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_routes(api: Api):\n api.add_resource(SignUpApi, '/user/signup/')\n api.add_resource(LoginApi, '/user/login/')\n\n api.add_resource(UsersApi, '/users/')\n\n api.add_resource(CafeteriasCreationAPI, '/createcafeteria/')\n api.add_resource(CreateItemsAPI, '/createcafeteriaitems/')", "def in...
[ "0.80723184", "0.7742963", "0.75816625", "0.750119", "0.7224631", "0.7081037", "0.705355", "0.702835", "0.6989628", "0.69582707", "0.6948669", "0.692166", "0.68536395", "0.6782817", "0.6780066", "0.6779047", "0.6709916", "0.6695856", "0.6689925", "0.66680044", "0.6630894", ...
0.63309956
33
Build a userinput_listener coroutine.
def user_input_listener(state: SharedState):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _listen(self):\n users = fileIO.load_json(\"users.json\")\n print(\"The list of users is: \")\n for i in users:\n print(users[i][\"name\"])\n name = False\n while not name: #Loop until valid user given\n name = input(\"Please enter the user that you woul...
[ "0.60229254", "0.5902512", "0.5665694", "0.5660546", "0.5540109", "0.552596", "0.55182016", "0.5446837", "0.54210794", "0.53281254", "0.53130955", "0.5302447", "0.52767766", "0.52541715", "0.5171928", "0.51666707", "0.5162627", "0.51598024", "0.51451725", "0.5137769", "0.5034...
0.74263144
0
Build a websocket stream coroutine for every symbol.
def candle_producers(state: SharedState, manager: BinanceSocketManager):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def open_websocket_server(sock, filter=None): # pylint: disable=W0622\n ws = await create_websocket_server(sock, filter=filter)\n try:\n yield ws\n finally:\n await ws.close()", "def connect(self):\n self.wss.start()\n while not self.wss.conn.connected.is_set():\n ...
[ "0.5675283", "0.5632832", "0.5602713", "0.5536626", "0.55332685", "0.54705304", "0.5417256", "0.5412137", "0.5374019", "0.5361107", "0.5324008", "0.52814776", "0.5270162", "0.5264434", "0.5173382", "0.5166334", "0.5157106", "0.5140275", "0.51327926", "0.51196957", "0.51107293...
0.4692814
66
Build one coroutine that downloads candle history for each symbol and time interval.
def historical_candle_producer(state: SharedState, client: AsyncClient):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def fetch_history(stock, start, end):\n disable_stdout()\n with timer(logtime(\"ts.get_h_data('%s', autype=None, start='%s', end='%s', drop_factor=False)\" % (stock, start, end))):\n df = await wait_concurrent(event_loop, proc_pool, ts.get_h_data, stock, autype=None, start=start, end=end, drop_f...
[ "0.62406814", "0.6226014", "0.619598", "0.6178408", "0.6124466", "0.6044843", "0.59872854", "0.5895894", "0.5866143", "0.5864519", "0.58620954", "0.58356297", "0.5758476", "0.57579523", "0.5756885", "0.5747019", "0.57367694", "0.5733668", "0.5694192", "0.56894606", "0.5677922...
0.55126107
28
Build a fake websocket stream coroutine for every symbol.
def mock_candle_producers(state: SharedState):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def open_websocket_server(sock, filter=None): # pylint: disable=W0622\n ws = await create_websocket_server(sock, filter=filter)\n try:\n yield ws\n finally:\n await ws.close()", "async def setup_ws_stream_coros(app):\n\n app[\"ws_stream_coro\"] = set()", "def websocket_serv...
[ "0.622791", "0.5865622", "0.58078146", "0.56601346", "0.5592847", "0.5521169", "0.5491376", "0.54190344", "0.54174733", "0.53975993", "0.5363104", "0.5340883", "0.5321347", "0.5300425", "0.52969384", "0.5278497", "0.5272565", "0.52193433", "0.5187779", "0.51829916", "0.516728...
0.0
-1
Build one coroutine that handles all messages and sends them to their corresponding pipelines.
def consumer(state: SharedState):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _dispatch_messages(self):\n while True:\n select_obj = (yield)\n if select_obj == self._message_queue.selobj:\n msg = self._message_queue.get_nowait()\n if msg is not None:\n msg_type = msg.get('type', None)\n if m...
[ "0.6499672", "0.5979923", "0.5959593", "0.5840355", "0.5830399", "0.5809362", "0.57409644", "0.57242227", "0.56772774", "0.5677117", "0.56234056", "0.5620072", "0.55886537", "0.55492806", "0.5539985", "0.5526545", "0.5525597", "0.550391", "0.54963815", "0.54895586", "0.548119...
0.0
-1
Returns a list of selected coroutines.
def build() -> List[asyncio.Task]:
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_coroutines(self, coros):\n return self._loop.run_until_complete(asyncio.gather(*coros, loop=self._loop))", "def select_clients(self, my_round, num_clients=20):\n samples_futures = []\n for cs in self.client_servers:\n samples_future = cs.select_clients.remote(my_round, nu...
[ "0.58138645", "0.57921916", "0.5500767", "0.5427553", "0.52810246", "0.523673", "0.5232737", "0.51655847", "0.50899875", "0.5058168", "0.5043694", "0.5025866", "0.49998668", "0.4987699", "0.49808943", "0.4948969", "0.4917828", "0.48906115", "0.48799387", "0.48627067", "0.4851...
0.45013225
74
Returns length of longest increasing subsequence given an array of numbers.
def longestIncreasingSubsequence(nums): if not nums: return 0 dp = [None] * len(nums) dp[0] = 1 maxans = 1 for i in range(1, len(dp)): maxval = 0 for j in range(0, i): if nums[i] > nums[j]: maxval = max(maxval, dp[j]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_length_of_longest_sub_array(l):\n if len(l) < 1:\n return 0\n\n longest_seen_sequence = 0\n\n this_sequence_length = 1\n\n previous = l[0]\n\n for _, current in enumerate(l):\n\n if current > previous:\n this_sequence_length = this_seq...
[ "0.7756621", "0.7332605", "0.6925975", "0.68926334", "0.6865751", "0.68350095", "0.66415817", "0.6594408", "0.65523106", "0.6539818", "0.65185964", "0.6484091", "0.64561516", "0.64262223", "0.6355707", "0.62699634", "0.6269051", "0.62369823", "0.6226302", "0.6150499", "0.6116...
0.7476641
1
Raise DuplicateAction exception if this intent is a duplicate Concrete actions can override this method and call self.raise_duplicate_action() if they find that this intent should be discarded as (near) duplicate of an already stored action
def check_duplicate(self, state): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testduplicate(self):\n self.assertTrue(AmuletAbility('Control Dragon').duplicate(\n AmuletAbility('Control Dragon')))\n self.assertFalse(AmuletAbility('Control Dragon').duplicate(\n AmuletAbility('Control NPC')))\n self.assertTrue(AmuletAbilit...
[ "0.5758249", "0.5727997", "0.5709236", "0.5676586", "0.55160147", "0.5503697", "0.5438317", "0.5433323", "0.53957826", "0.5377086", "0.5372131", "0.53480536", "0.52793163", "0.5243134", "0.5236685", "0.5235135", "0.523479", "0.52295125", "0.52072746", "0.5196021", "0.51959985...
0.5613794
4
Create an Action from this intent, filling missing data from state
def at(self, state): self.complete_data(state) self.check_duplicate(state) action = entities.Action( action_id=new_id(state), type=self.get_type_name(), data=pmap(self.data), time=state.context.time, randomness=state.context.randomness,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _formulate_action(Action, **kwargs):\n\n return Action(**kwargs)", "def action(self, action_id):\r\n return Action(self, action_id)", "def action(self, action_id):\r\n return Action(self, action_id)", "def from_of_action(cls, of_action):\n return cls()", "def create_action(insta...
[ "0.63214076", "0.6280206", "0.6280206", "0.6092075", "0.60566056", "0.5983633", "0.5972293", "0.59379184", "0.58593243", "0.58537024", "0.5842147", "0.5834748", "0.5764666", "0.5716841", "0.5701877", "0.5692661", "0.5685065", "0.56532115", "0.5642375", "0.56263447", "0.561336...
0.72059274
0
Match the calibSources and sources, and propagate Interesting Flags (e.g. PSF star) to the sources
def propagateCalibFlags(keysToCopy, calibSources, sources, matchRadius=1): if calibSources is None or sources is None: return closest = False # return all matched objects matched = afwTable.matchRaDec(calibSources, sources, matchRadius*afwGeom.arcseconds, closest) # # Becaus...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sources_extraction(image,sextractor_pars):\n\n cat_name, detect_minarea, detect_thresh, analysis_thresh, phot_aperture, satur_level, ZP, gain, pixelScale,seeing,back_type,back_value,back_size,backphoto_type,backphoto_thick,back_filterthresh,checkimage_type,checkimage_name= sextractor_pars\n sp.run('sex %s....
[ "0.56265473", "0.55381423", "0.55253875", "0.5407288", "0.53591067", "0.53485554", "0.53367805", "0.5311908", "0.5266865", "0.52260643", "0.5216051", "0.5157914", "0.5119476", "0.507221", "0.5060244", "0.50464916", "0.5040846", "0.50221545", "0.50190264", "0.5007729", "0.5004...
0.69685996
0
Parse the command line arguments.
def main(): parser = argparse.ArgumentParser() parser.add_argument("host", type=str, nargs="+") parser.add_argument("--user", type=str, default=getpass.getuser()) parser.add_argument("--path", type=str, required=True) parser.add_argument("--keep", type=int, default=3) parser.add_argument("--depl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def parseArguments(self):\n iterator = iter(sys.argv[1:]) # Skip file name\n for argument in iterator:\n if len(argument) < 2 or argument[:2] != '--':\n self.error('syntax error \"{}\"'.format(argument))\n else:\n de...
[ "0.81931424", "0.75572526", "0.7554", "0.7513019", "0.751122", "0.73971534", "0.7371605", "0.73673505", "0.72861725", "0.7245646", "0.72365344", "0.7233457", "0.7223075", "0.7216988", "0.7214747", "0.7208797", "0.72051626", "0.7194125", "0.7173979", "0.71704656", "0.7168313",...
0.0
-1
Checks that the Drakecreated flavor of nlopt.cpp (via a patch file) is consistent with the upstreamgenerated flavor of same (via CMake). If this test fails during an NLopt version pin upgrade, you will need to update patches/gen_enums.patch with the reported differences.
def test_enum_cross_check(self): # Load both input files. # "actual" refers to the the Drake-created flavor (via a patch file). # "expected" refers to the upstream-generated flavor (via CMake). manifest = runfiles.Create() actual_file = manifest.Rlocation( "nlopt_inte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self, expected):\n versions = ['3.0', '4.0', '5.0', '6.0', '7.0', '8.0']\n modes = ['strict', 'normal', 'ignore']\n\n for version in versions:\n for mode in modes:\n assert self.get(app_version=version, compat_mode=mode) == (\n expected['-...
[ "0.56607723", "0.5562484", "0.54389495", "0.5402845", "0.53964126", "0.5389693", "0.53053814", "0.5245198", "0.523824", "0.5220819", "0.5130013", "0.50907856", "0.5084268", "0.507624", "0.50242937", "0.5022775", "0.5013908", "0.5011498", "0.50096434", "0.49897176", "0.4972365...
0.6848094
0
Evaluate the given distribution function in the point(s) (r, ppar, pperp). Use the vector 'v' to specify the parameters of this distribution function.
def Eval(self, r, ppar, pperp, v, gamma=None, p2=None, p=None, xi=None): while False: yield None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _p_v_at_r(self, v, r):\n if hasattr(self, \"_logfQ_interp\"):\n return (\n numpy.exp(\n self._logfQ_interp(\n -_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0\n )\n )\n * v**2.0\n ...
[ "0.66941005", "0.6040724", "0.5935693", "0.5931339", "0.5931324", "0.5880862", "0.5767878", "0.5735554", "0.56684875", "0.5650999", "0.5604907", "0.5558572", "0.5557449", "0.5551832", "0.55289036", "0.55191976", "0.5493359", "0.54931647", "0.54723114", "0.5459315", "0.5458212...
0.6704118
0
Preprocess the input vector to give it a shape appropriate for generating the distribution
def PreprocessInputVector(self, v, n, nparams): l = v.size if l % nparams is not 0: smutil.error("AvalancheDistributionFunction: Input vector has invalid format: length is not a multiple of "+str(nparams)+" (number of parameters in model).") # Number of radial points in interface gr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return normalized", "def normalize(vec):\n return vec / length(vec)", "def get_normalized_vector(vector):\n # WARN: Zero length may cause problems!\n vector_lenght = get_vector_length(vector)\n ...
[ "0.630594", "0.6298658", "0.60276604", "0.6004589", "0.5926612", "0.58883804", "0.5880402", "0.5858213", "0.5854227", "0.58155197", "0.57243234", "0.57066524", "0.5685303", "0.56719977", "0.56702715", "0.56669194", "0.56142706", "0.56082267", "0.5602667", "0.55900484", "0.554...
0.601182
3
Calculate phase cross correlation (pcc) between signal and wavelet foreach signal in seismic For this purpose wavelet is shifted in time and compared to corresponding portion in each signals
def xcorr(seismic_signal, wavelet, **kwargs): # if seismic signal is a trace object, we pack it to a stream if isinstance(seismic_signal, _tr.Trace): sources = _st.Stream([seismic_signal]) else: sources = seismic_signal if not isinstance(sources, _st.Stream): raise TypeError('s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PLV_Coh(X,Y,TW,fs):\n X = X.squeeze()\n ntaps = 2*TW - 1\n dpss = sp.signal.windows.dpss(X.size,TW,ntaps)\n N = int(2**np.ceil(np.log2(X.size)))\n f = np.arange(0,N)*fs/N\n PLV_taps = np.zeros([N,ntaps])\n Coh_taps = np.zeros([N,ntaps])\n Phase_taps = np.zeros([N,ntaps])\n for k in r...
[ "0.6411508", "0.6399294", "0.63741624", "0.63008296", "0.61233366", "0.6064643", "0.605886", "0.6058215", "0.6025654", "0.60073525", "0.59338397", "0.59186095", "0.5901491", "0.58867425", "0.5868824", "0.57322395", "0.56866455", "0.566528", "0.5639549", "0.5631151", "0.562609...
0.0
-1
Calculate phase autocorrelation for each signal in seismic_stream
def acorr(seismic_signal, **kwargs): # if seismic signal is a trace object, we pack it to a stream if isinstance(seismic_signal, _tr.Trace): sources = _st.Stream([seismic_signal]) else: sources = seismic_signal if not isinstance(sources, _st.Stream): raise TypeError('seismic_str...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step_autocorrelation(self):\n\n max_hops = max([len(x) for x in self.steps])\n\n self.acf = np.zeros([len(self.steps), max_hops])\n\n keep = [] # list to hold indices of trajectories with a non-zero amount of hops\n for i in range(len(self.steps)):\n hops = self.steps[i]...
[ "0.6106281", "0.5915008", "0.5743236", "0.56838435", "0.56832486", "0.5655305", "0.56056494", "0.55680525", "0.5545803", "0.55240375", "0.55095017", "0.54883564", "0.54883564", "0.5412182", "0.5382874", "0.5338562", "0.5338562", "0.52966046", "0.5273439", "0.52382296", "0.520...
0.5928678
1
Calculate phase cross correlation (pcc) between signal1 and signal2 For this purpose signal2 is shifted in time and compared to corresponding portion in signal1
def _xcorr_trace(signal1, signal2, **kwargs): kwargs['mode'] = 'pcc' kwargs['lags'] = __default_lags_if_not_set(signal1, signal2, **kwargs) pcc_signal = phasecorr.xcorr(signal1.data, signal2.data, **kwargs) trace = _tr.Trace(data=pcc_signal) __writeheader(trace, signal1, **kwargs) return tra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cphase(h1, h2):\n\n for h in (h1, h2):\n h.assert_ket_space()\n\n field = h1.base_field\n\n d = h1.dim()\n if h2.dim() != d:\n raise HilbertError('spaces must be of the same dimension')\n\n ret = (h1*h2).O.array()\n for (j, a) in enumerate(h1.index_iter()):\n for (k, b) i...
[ "0.66017336", "0.6389433", "0.61255634", "0.6099715", "0.6079657", "0.6045117", "0.59957165", "0.5968298", "0.5967114", "0.59037614", "0.5879406", "0.5871049", "0.5862538", "0.585481", "0.58367324", "0.57887626", "0.57637984", "0.5761343", "0.5755311", "0.5738161", "0.573262"...
0.69613063
0
Calculate phase auto correlation (pac) of signal1 For this purpose a shifted copy in time of signal1 is compared to corresponding portion in signal1
def _acorr_trace(signal1, **kwargs): kwargs['mode'] = 'pac' kwargs['lags'] = __default_lags_if_not_set(signal1, signal1, **kwargs) pac_signal = phasecorr.acorr(signal1.data, **kwargs) trace = _tr.Trace(data=pac_signal) __writeheader(trace, signal1, **kwargs) return trace
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constract(phase, magnitude):\n new_spectrum = magnitude * np.exp(1j * phase)\n\n # reverse the shift and FFT\n f_ishift = np.fft.ifftshift(new_spectrum)\n img_back = np.fft.ifft2(f_ishift)\n \n return np.abs(img_back)", "def test_lag1Cor_Estimation(self):\n P = PSignal.PSignal(np.arange(10...
[ "0.59478575", "0.5942706", "0.58623695", "0.58456415", "0.58392256", "0.5771846", "0.57513154", "0.57069325", "0.5691568", "0.569096", "0.5653918", "0.5615717", "0.55893755", "0.55863965", "0.55757755", "0.5560512", "0.55482876", "0.55477715", "0.55407035", "0.55402577", "0.5...
0.6709351
0
get random proxy from proxypool
def get_random_proxy(): url=requests.get(proxypool_url).text.strip() #logger.info("now url is",url) return url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random(self):\n return random.choice(self.proxies)", "def get_proxy_pool(self,proxy_pool,num):\n\n url='{url}/proxy/?num={num}'.format(url=config.SERVER_URL,num=num)\n\n try:\n res=request.urlopen(url,timeout=5).read()\n res=str(res,encoding='utf8')\n exc...
[ "0.7766926", "0.7258919", "0.72230166", "0.70320004", "0.6830322", "0.67573696", "0.6513024", "0.64002264", "0.63306606", "0.6161731", "0.60935825", "0.6068532", "0.59971714", "0.5855311", "0.584551", "0.58218956", "0.57690114", "0.574567", "0.5730094", "0.5697484", "0.569187...
0.8399079
0
use proxy to crawl page
def crawl(url): while True: try: proxy=get_random_proxy() proxies = {'http': 'http://' + proxy} logger.info(proxies) resp = requests.get(url, proxies=proxies,timeout=3) # 设置代理,抓取每个公司的连接 resp.encoding = resp.apparent_encoding # 可以正确解码 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n if self.is_full():\n return\n for crawler in self.crawlers:\n logger.info(f'crawler {crawler} to get proxy')\n proxies = crawler.run()\n if proxies:\n for proxy in proxies:\n self.redis.add(proxy)\n ...
[ "0.6656336", "0.6540788", "0.6506942", "0.65062267", "0.6483475", "0.6374295", "0.6259475", "0.6233891", "0.6208135", "0.61101043", "0.609967", "0.60954505", "0.6091064", "0.605424", "0.6050282", "0.60383075", "0.6023799", "0.59682155", "0.5963611", "0.59390926", "0.59319854"...
0.69973946
0
main method, entry point
def main(): proxy = get_random_proxy() html = crawl(target_url) company_all_url = html.xpath('//*[@id="quotesearch"]/ul/li/a/@href') code=['none']*len(company_all_url) for i in range(len(company_all_url)): s = str(str(company_all_url[i])) code[i]=s[(len(s) - 13):(len(s) - 5)] sav...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main(...
[ "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006", "0.88615006"...
0.0
-1
Checks if given position is empty ("") in the board.
def _position_is_empty_in_board(position, board): return board[position[0]][position[1]] == "-"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_empty_space(board, position1):\n return board[position1] == \" \"", "def emptyAt(self, position):\n\n #check for any sprites at the position\n for key in self.sprites:\n s = self.sprites[key]\n if s.position == position and s.visible: #not visible means it isn't taking up t...
[ "0.79477996", "0.788795", "0.7743375", "0.7719691", "0.76447976", "0.74391013", "0.74310374", "0.7350126", "0.7295014", "0.71880174", "0.71601164", "0.7151122", "0.7118377", "0.7117768", "0.7107725", "0.71016866", "0.7068392", "0.7039862", "0.6971793", "0.6948898", "0.6942450...
0.89006466
0
Checks if given position is a valid. To consider a position as valid, it must be a twoelements tuple, containing values from 0 to 2.
def _position_is_valid(position): # Make sure that... # position is a tuple # position's length is 2 # every value in the tuple is an int # every int in the tuple is either 0, 1 or 2 # if not, return False if not isinstance(position, tuple) \ or len(position) != 2 \...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_valid_position_tuple(pos):\n try: chrom, start_pos, end_pos, strand = pos\n except (TypeError, ValueError): raise MutantError(\"Didn't get a correct position tuple! %s\"%pos)\n if strand not in SEQ_STRANDS: raise MutantError(\"Invalid strand %s!\"%strand)...
[ "0.76978976", "0.7626505", "0.7124657", "0.70859355", "0.6977404", "0.69307876", "0.685049", "0.6840817", "0.67205507", "0.6672402", "0.66398543", "0.66194904", "0.6600491", "0.6599175", "0.6573275", "0.65055704", "0.6466658", "0.6444392", "0.6436828", "0.63908213", "0.635216...
0.84633476
0
Returns True if all positions in given board are occupied.
def _board_is_full(board): # looks for "-" in every position in the board # returns False if it finds one for row in board: if any(column for column in row if column == "-"): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_board_full(board):\n return not any(0 in val for val in board)", "def _check_occupied(self, col, row):\n if self.board[row - 1][col - 1] == EMPTY:\n return False\n else:\n return True", "def is_board_full(self):\n for position in self.positions:\n ...
[ "0.74002767", "0.7333643", "0.7305194", "0.72547317", "0.7221987", "0.72074044", "0.715917", "0.71400607", "0.7111857", "0.7029353", "0.70200616", "0.6994772", "0.6989892", "0.698797", "0.69771594", "0.69702905", "0.69275504", "0.69254285", "0.689183", "0.68875754", "0.687192...
0.701698
11
Checks if all 3 positions in given combination are occupied by given player.
def _is_winning_combination(board, combination, player): """ ### Code before refactoring into a comprehension list: for a_tuple in combination: # e.g. a_tuple = (0,0) # if board[0][0] != "X" if board[a_tuple[0]][a_tuple[1]] != player: return False """ if any(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_winning_combinations(board, player):\n winning_combinations = (\n ((0, 0), (0, 1), (0, 2)),\n ((1, 0), (1, 1), (1, 2)),\n ((2, 0), (2, 1), (2, 2)),\n ((0, 0), (1, 0), (2, 0)),\n ((0, 1), (1, 1), (2, 1)),\n ((0, 2), (1, 2), (2, 2)),\n ((0, 0), (1, 1), (...
[ "0.7056445", "0.6785087", "0.6513575", "0.6407896", "0.63359", "0.6332282", "0.6314953", "0.62546915", "0.62414443", "0.6239754", "0.6238734", "0.61814517", "0.6174631", "0.6169825", "0.61628115", "0.6144622", "0.61050117", "0.60615724", "0.60549986", "0.6050816", "0.60260415...
0.72803354
0
There are 8 posible combinations (3 horizontals, 3, verticals and 2 diagonals) to win the Tictactoe game. This helper loops through all these combinations and checks if any of them belongs to the given player.
def _check_winning_combinations(board, player): winning_combinations = ( ((0, 0), (0, 1), (0, 2)), ((1, 0), (1, 1), (1, 2)), ((2, 0), (2, 1), (2, 2)), ((0, 0), (1, 0), (2, 0)), ((0, 1), (1, 1), (2, 1)), ((0, 2), (1, 2), (2, 2)), ((0, 0), (1, 1), (2, 2)), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_winning_combination(board, combination, player):\n\n \"\"\"\n ### Code before refactoring into a comprehension list:\n\n for a_tuple in combination:\n\n # e.g. a_tuple = (0,0)\n # if board[0][0] != \"X\"\n if board[a_tuple[0]][a_tuple[1]] != player:\n\n return False...
[ "0.71583956", "0.70575804", "0.7002491", "0.6714407", "0.669649", "0.66591203", "0.66099006", "0.6589296", "0.6558027", "0.6533149", "0.6491051", "0.6489824", "0.644219", "0.6395233", "0.6353411", "0.63451284", "0.6342977", "0.6325276", "0.62973696", "0.6287886", "0.6280949",...
0.76965
0
Creates and returns a new game configuration.
def start_new_game(player1, player2): return { 'player1': "X", 'player2': "O", 'board': [ ["-", "-", "-"], ["-", "-", "-"], ["-", "-", "-"], ], 'next_turn': "X", 'winner': None }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_new_game(game_config):\n _type = game_config[\"game_type\"]\n if _type == \"hex\":\n game = Hex(game_config[\"hex\"], verbose=game_config[\"verbose\"])\n else:\n raise ValueError(\"Game type is not supported\")\n return game", "def create_config(self) -> None:\n pass", ...
[ "0.6866214", "0.6441648", "0.6441648", "0.62015563", "0.6154281", "0.6075715", "0.5959731", "0.59504825", "0.588382", "0.58830607", "0.58786094", "0.58786094", "0.58771557", "0.586809", "0.5866608", "0.57652086", "0.5752994", "0.5737094", "0.5673671", "0.5668067", "0.5663768"...
0.0
-1
Returns the winner player if any, or None otherwise.
def get_winner(game): return game['winner']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner(self):\n # Credit to Dariusz Walczak for inspiration.\n # http://stackoverflow.com/questions/1720421/merge-two-lists-in-python\n moves = [p.possible_moves(p.pieces, self) for p in self.players]\n if False in [mv == [] for mv in moves]:\n return (\"None\")\n ...
[ "0.79259926", "0.7767767", "0.77578986", "0.76471484", "0.76094395", "0.7577104", "0.7522824", "0.74686444", "0.7463236", "0.74358934", "0.7395176", "0.73575616", "0.73575616", "0.7349675", "0.7327973", "0.7324711", "0.7274085", "0.7265994", "0.72104675", "0.71895385", "0.706...
0.70658773
21
Performs a player movement in the game. Must ensure all the pre requisites checks before the actual movement is done. After registering the movement it must check if the game is over.
def move(game, player, position): # Is the board full? Or do we already have a winner? Then game is over. if _board_is_full(game['board']) or game['winner'] != None: raise InvalidMovement('Game is over.') # if the next player is not the one who should make the move if not get_next_turn(game) =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def try_move_player(self):\n player = self.player\n if player.direction == 'U':\n next_position = (player.position[0], player.position[1] - 1)\n elif player.direction == 'D':\n next_position = (player.position[0], player.position[1] + 1)\n elif player.direction == ...
[ "0.69746006", "0.6750943", "0.6730142", "0.66434145", "0.6624069", "0.66014683", "0.6598992", "0.65845567", "0.6582338", "0.6566751", "0.65254796", "0.6504708", "0.6499943", "0.6482451", "0.6433244", "0.64278674", "0.6408127", "0.64079386", "0.639623", "0.6323653", "0.6275745...
0.61105865
32
Returns a string representation of the game board in the current state.
def get_board_as_string(game): str_board = "\n" # every board starts with a blank line row = 0 # used to print the board # creates a board of 5 lines. 3 rows, 2 dashed. for line in range(1, 6): # every odd line if line % 2 != 0: # add a row to the string str_board ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_board_state_pretty(self):\n\n board_state = ''\n for i in range(0, 3):\n board_state += ' | '.join([self.board['{}{}'.format(i, j)] for j in range(0, 3)])\n board_state += '\\n'\n return board_state", "def board_string(self):\n s = \"\"\n for i, v ...
[ "0.8295647", "0.82778364", "0.82208264", "0.8033392", "0.79234034", "0.791434", "0.78864056", "0.7875186", "0.78537625", "0.78222716", "0.7806988", "0.778111", "0.7743911", "0.7685247", "0.7682562", "0.7667545", "0.76609117", "0.7657479", "0.7643367", "0.7634906", "0.7624794"...
0.71689326
49
Returns the player who plays next, or None if the game is already over.
def get_next_turn(game): return game['next_turn']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_next_player(self, player):\r\n return player * -1", "def get_next_player(self, player):\r\n return player * -1", "def get_next_player(current_player: Optional[str]) -> str:\n if current_player == c.X:\n return c.O\n else:\n return c.X", "def next_player(board, prev_p...
[ "0.76222545", "0.76222545", "0.75664425", "0.74821323", "0.73752886", "0.73482656", "0.7283921", "0.72544986", "0.72476065", "0.71792877", "0.7154323", "0.71080816", "0.7093113", "0.7084624", "0.70579547", "0.7050713", "0.70100635", "0.70100635", "0.6991924", "0.6985718", "0....
0.0
-1
Look in the current directory and then each parent until root.
def find_in_parent_dir(fname): p = os.path.abspath(os.path.curdir) while not os.path.exists(os.path.join(p, project_conf_name)): oldp, p = p, os.path.dirname(p) if p == oldp: return None return open(os.path.join(p, project_conf_name), 'r')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _walk_to_root(path):\n if not os.path.exists(path):\n raise IOError('Starting path not found')\n\n if os.path.isfile(path):\n path = os.path.dirname(path)\n\n last_dir = None\n current_dir = os.path.abspath(path)\n while last_dir != current_dir:\n yield current_dir\n ...
[ "0.7434952", "0.71153444", "0.69121534", "0.6693403", "0.65015477", "0.64132035", "0.63960505", "0.6387505", "0.623293", "0.6227715", "0.62218225", "0.6208172", "0.61608905", "0.6140065", "0.6102608", "0.6067385", "0.60380626", "0.6005215", "0.5958163", "0.5939146", "0.593403...
0.5471526
69
Used to extract information about our dataset. It does iterate over all images and return a DataFrame with the data (age, gender and sex) of all files.
def parse_dataset(dataset_path, ext='jpg'): def parse_info_from_file(path): """ Parse information from a single file """ try: filename = os.path.split(path)[1] filename = os.path.splitext(filename)[0] age, gender, race, _ = filename.split('_') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_dataset() -> Tuple[pd.DataFrame, Dict]:\n\n data_dir = Path.cwd()/\"freiburg_grocery_images\"\n labels = [directory.name for directory in data_dir.iterdir()]\n label_map = {label: i for i, label in enumerate(labels)}\n\n all_items = [str(file) for label in labels for file in (data_dir/label...
[ "0.6953958", "0.69098717", "0.68971664", "0.68201923", "0.64545614", "0.6400425", "0.6322264", "0.6270314", "0.61469066", "0.6143167", "0.61304915", "0.6126947", "0.6060151", "0.60446715", "0.60239255", "0.6021422", "0.6001422", "0.5997284", "0.5975618", "0.59695774", "0.5934...
0.592172
22
Parse information from a single file
def parse_info_from_file(path): try: filename = os.path.split(path)[1] filename = os.path.splitext(filename)[0] age, gender, race, _ = filename.split('_') return int(age), dataset_dict['gender_id'][int(gender)], dataset_dict['race_id'][int(race)] except E...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self, infile):\r\n raise NotImplementedError()", "def _parse(self, infile):\n raise NotImplementedError()", "def _parse_file(cls, filepath):\n hdus = sunpy.io.read_file(filepath)\n return cls._parse_hdus(hdus)", "def parse_data(fp):\n pass", "def parse_file(self, file):...
[ "0.7360086", "0.72870433", "0.7046545", "0.7038436", "0.69900817", "0.6958809", "0.684544", "0.6791917", "0.67794955", "0.6685041", "0.66544765", "0.661106", "0.6580625", "0.65276223", "0.65232867", "0.6515129", "0.6504125", "0.6483635", "0.6483133", "0.6455571", "0.6450634",...
0.68785435
6
Used to perform some minor preprocessing on the image before inputting into the network.
def preprocess_image(self, img_path): im = Image.open(img_path) im = im.resize((IM_WIDTH, IM_HEIGHT)) im = np.array(im) / 255.0 return im
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(self, img):\n img_ = image.load_img(img, target_size=(299, 299))\n img_ = image.img_to_array(img_)\n img_ = np.expand_dims(img_, axis=0)\n img_ = preprocess_input(img_)\n return img_", "def _preprocessing(self, input_image):\n if self.resize:\n ...
[ "0.76596355", "0.7428046", "0.7330726", "0.73097295", "0.7233228", "0.72189915", "0.72014105", "0.7197177", "0.7121413", "0.71081626", "0.70633936", "0.70560926", "0.7039367", "0.7033568", "0.7023033", "0.70055234", "0.698125", "0.6977507", "0.69203556", "0.68990195", "0.6893...
0.6308844
100
Used to generate a batch with images when training/testing/validating our Keras model.
def generate_images(self, image_idx, is_training, batch_size=16): # arrays to store our batched data images, ages, races, genders = [], [], [], [] while True: for idx in image_idx: person = self.df.iloc[idx] age = person['age'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_batch(model, batch_size, test_data=False):\n if model == 'cnn':\n as_image = True\n else:\n as_image = False\n\n image = _read_images(test_data=test_data, as_image=as_image)\n label = _read_labels(test_data=test_data)\n\n images_batch, labels_batch = tf.train.batch([image, label],\n ...
[ "0.75774246", "0.74922997", "0.74519485", "0.73910856", "0.7325273", "0.71627367", "0.71103084", "0.7077549", "0.7029831", "0.70131713", "0.70102745", "0.6954216", "0.6947352", "0.6941008", "0.69298536", "0.69187367", "0.69123995", "0.6905738", "0.6889662", "0.6868008", "0.68...
0.72434276
5
Used to build the race branch of our face recognition network. This branch is composed of three Conv > BN > Pool > Dropout blocks, followed by the Dense output layer.
def build_race_branch(self, inputs, num_races): x = self.make_default_hidden_layers(inputs) x = Flatten()(x) x = Dense(128)(x) x = Activation("relu")(x) x = BatchNormalization()(x) x = Dropout(0.5)(x) x = Dense(num_races)(x) x = Activation("softmax", name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_bisenet(inputs, num_classes):\n\n ### The spatial path\n ### The number of feature maps for each convolution is not specified in the paper\n ### It was chosen here to be equal to the number of feature maps of a classification\n ### model at each corresponding stage\n # spatial_net = fl...
[ "0.69784904", "0.6751553", "0.673756", "0.66934335", "0.667088", "0.6633901", "0.6607632", "0.65503025", "0.65443754", "0.65243477", "0.65239656", "0.65187544", "0.6490053", "0.6459417", "0.6453328", "0.6452226", "0.643148", "0.6430326", "0.6419869", "0.6396226", "0.63870144"...
0.612305
60
Used to build the gender branch of our face recognition network. This branch is composed of three Conv > BN > Pool > Dropout blocks, followed by the Dense output layer.
def build_gender_branch(self, inputs, num_genders=2): x = Lambda(lambda c: tf.image.rgb_to_grayscale(c))(inputs) x = self.make_default_hidden_layers(inputs) x = Flatten()(x) x = Dense(128)(x) x = Activation("relu")(x) x = BatchNormalization()(x) x = Dropout(0.5)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_discriminator(self):\n img_shape = (self.img_size[0], self.img_size[1], self.channels)\n\n model = Sequential()\n ###############\n # Conv Stack 1:\n ###############\n model.add(\n Conv2D(128, kernel_size=5, strides=2, input_shape=img_shape, padding=\"...
[ "0.66957885", "0.66077316", "0.63622165", "0.6342879", "0.633063", "0.6302211", "0.6302211", "0.62979877", "0.6269781", "0.62534744", "0.623655", "0.62052697", "0.61675453", "0.61575735", "0.61488783", "0.61291873", "0.61201566", "0.61011446", "0.60958564", "0.6083565", "0.60...
0.7864113
0
Used to build the age branch of our face recognition network. This branch is composed of three Conv > BN > Pool > Dropout blocks, followed by the Dense output layer.
def build_age_branch(self, inputs): x = self.make_default_hidden_layers(inputs) x = Flatten()(x) x = Dense(128)(x) x = Activation("relu")(x) x = BatchNormalization()(x) x = Dropout(0.5)(x) x = Dense(1)(x) x = Activation("linear", name="age_output")(x) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discriminator_block(in_filters, out_filters):\n layers = [ nn.Conv2d(in_filters, out_filters, 4, stride=2, padding=1),\n nn.LeakyReLU(0.01)]\n return layers", "def build_bisenet(inputs, num_classes):\n\n ### The spatial path\n ### The number of feature maps for each...
[ "0.6322069", "0.62509495", "0.6210222", "0.6205929", "0.61850744", "0.6165662", "0.61332285", "0.6119399", "0.6096222", "0.60777825", "0.6053835", "0.60508585", "0.60431457", "0.6030179", "0.60178214", "0.6007941", "0.5995195", "0.5962688", "0.59607214", "0.59575105", "0.5951...
0.7157092
0
Used to assemble our multioutput model CNN.
def assemble_full_model(self, width, height, num_races): input_shape = (height, width, 3) inputs = Input(shape=input_shape) age_branch = self.build_age_branch(inputs) race_branch = self.build_race_branch(inputs, num_races) gender_branch = self.build_gender_branch(inputs) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_model(input_classes,output_classes):\n dimensions = 20\n inputs = []\n embedded_outputs = []\n for i in input_classes:\n input_layer = Input((1,))\n inputs.append(input_layer)\n embedder = Embedding(input_dim=i,output_dim=dimensions,input_length=1,embeddings_constraint=Un...
[ "0.67610925", "0.6492056", "0.6454665", "0.644587", "0.6413437", "0.6320915", "0.62863666", "0.6275258", "0.6252421", "0.6248297", "0.6241189", "0.6237258", "0.6234287", "0.615311", "0.6143814", "0.61404675", "0.6138519", "0.61306256", "0.6123763", "0.6122863", "0.61180544", ...
0.0
-1
Computer perimeter for the rectangle
def perimRect(length, width): return 2 * (length + width)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perimeter(self):", "def perimeter(self):\n\t\treturn 2 * (self.width + self.height)", "def calculateperimeter(self):\r\n return (self.width * 2) + (self.height * 2)", "def perimeter(self):\r\n return (2*self.width) + (2*self.height)", "def perimeter(self):\n return 2 * (self.height...
[ "0.8430252", "0.83806247", "0.83072674", "0.8281285", "0.8204777", "0.81401604", "0.805963", "0.7651174", "0.74341273", "0.7422448", "0.73345184", "0.72595495", "0.721846", "0.7185834", "0.7158701", "0.7130895", "0.7089875", "0.70687634", "0.70687634", "0.6887997", "0.6867396...
0.6235728
87
Compute area for the rectangle
def areaRect(length, width): return length * width
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rect_area(rect):\n return rect[2] * rect[3]", "def area_rect(w, h):\n return w * h", "def _area(bounds):\n return (bounds[0, 1] - bounds[0, 0]) * (bounds[1, 1] - bounds[1, 0])", "def area(self):\n num_rows = self.row_end - self.row_start\n num_cols = self.col_end - self.col_start\n...
[ "0.8253932", "0.8153468", "0.8056531", "0.80223805", "0.79693747", "0.79442996", "0.7873636", "0.7872711", "0.78698665", "0.786057", "0.784172", "0.7819327", "0.7814251", "0.7764691", "0.7752274", "0.77518463", "0.7743629", "0.77320397", "0.77025086", "0.77025086", "0.7702508...
0.77284664
18
Global variables available in all templates
def global_variables(request): data = { 'DEBUG': settings.DEBUG, } return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def global_variables():\n item_catalog_app.jinja_env.globals[\"ALL_CATEGORIES\"] = act.all_categories()\n __logged_in_user__ = act.user(\n pointer=login_session.get(\"user_id\")\n )\n item_catalog_app.jinja_env.globals[\"USER\"] = __logged_in_user__\n g.USER = __logged_in_user__", "def inje...
[ "0.73522717", "0.70804507", "0.6623835", "0.6614453", "0.6387393", "0.6256472", "0.61475796", "0.61302704", "0.6017198", "0.5988722", "0.5954301", "0.5932908", "0.5932745", "0.5928411", "0.59138465", "0.58811116", "0.58521664", "0.58481276", "0.5838821", "0.5833165", "0.57925...
0.6709685
2
raise WinproxyError if result is 0
def fail_on_zero(func_name, result, func, args): if not result: raise WinproxyError(func_name) return args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winhttp_WinHttpFreeProxyResult(jitter):\n ret_ad, args = jitter.func_args_stdcall([\"pProxyResult\"])\n raise RuntimeError('API not implemented')\n jitter.func_ret_stdcall(ret_ad, ret_value)", "def winhttp_WinHttpGetProxyResult(jitter):\n ret_ad, args = jitter.func_args_stdcall([\"hResolver\", \"...
[ "0.68406665", "0.63366336", "0.6020998", "0.6016139", "0.58826256", "0.5877293", "0.5857276", "0.582949", "0.57794017", "0.5773708", "0.57534397", "0.56958175", "0.5652606", "0.5602097", "0.5585624", "0.5577021", "0.55100924", "0.5496161", "0.54908186", "0.5478192", "0.542409...
0.721989
0
Function called when extension is loaded.
def setup(bot): bot.logger.debug( 'Registering extension "Quiz"' ) bot.add_cog(QuizCog(bot))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_load(self):\n pass", "def on_load(self):\n pass", "def init_extensions(self, package, module):\n\n pass", "def on_load(self):", "def on_startup(self) -> None:\n ...", "def on_load(self):\n self.__init__()", "def __init_on_load__(self):", "def test_load(self):\n ...
[ "0.73872864", "0.73872864", "0.7158644", "0.6950948", "0.6821005", "0.6776726", "0.67198926", "0.66803163", "0.66501784", "0.6643111", "0.657011", "0.6525896", "0.6503312", "0.6479751", "0.6448623", "0.64208615", "0.6371902", "0.6362281", "0.63427466", "0.63366205", "0.632070...
0.0
-1
Function called when extension is unloaded.
def teardown(bot): bot.logger.debug( 'Removing extension "Quiz"' ) bot.get_cog('Quiz').save_traking_data() bot.remove_cog(bot.get_cog('Quiz'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unloaded():\n pass", "def on_unload(self):\n pass", "def unload_plugin(self):\n pass", "async def unload(self, ctx, *, extension: str):\r\n self.bot.unload_extension(extension)\r\n await ctx.send(f\":ok_hand: Unloaded module `{extension}`\")", "async def unload(self) -> N...
[ "0.78926325", "0.7739239", "0.7379189", "0.7115593", "0.6993464", "0.68589085", "0.6789264", "0.677395", "0.6731156", "0.66316205", "0.6624827", "0.66196173", "0.6605904", "0.6605904", "0.6562715", "0.6562715", "0.6562715", "0.656185", "0.65453285", "0.6543707", "0.6531165", ...
0.6474187
24
Setup local flowables database with flows that require special handling. Also loads the flowables file. When overriding this function, place the super() call between preload and postload activities.
def _configure_flowables(self, flowables): if flowables is None: flowables = DEFAULT_FLOWABLES # FlowablesDict-- mainly to upsample CAS numbers for matching self._fm = FlowablesDict() self._fm.new_entry('carbon dioxide', '124-38-9') self._fm.new_entry('Water', '7732...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup(cls):\n super().setup()\n cls.db = DBCommunication()", "def _pre_setup(self):\n apps.clear_cache()\n call_command('migrate', interactive=False, verbosity=0)\n call_command('loaddata', 'initial_data', verbosity=0)\n super(DatatableViewTestCase, self)._pre_setup(...
[ "0.6175916", "0.6035001", "0.5991969", "0.5970857", "0.58654773", "0.58605886", "0.5847241", "0.5826606", "0.5805958", "0.57829595", "0.5778072", "0.575451", "0.56998646", "0.56855494", "0.56470186", "0.56340146", "0.5630023", "0.56250453", "0.5624165", "0.5621802", "0.562054...
0.5878006
4
LciaEngine.__getitem__ retrieves a canonical context by more intensively searching for matches from a given context. Adds foreign context's full name as synonym if one is affirmatively found. If one is not found, returns the NullContext. None is returned as None, to represent 'unspecified' (i.e. accept all) as opposed ...
def __getitem__(self, item): if item is None: return None try: return self._cm.__getitem__(item) except KeyError: if isinstance(item, Context): return self._cm.find_matching_context(item) elif isinstance(item, tuple) and len(item) >...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __dis_context__(self, context, word):\n senses = self.vs.get_senses(word, self.ignore_case)\n if self.verbose:\n print(\"Senses of a target word:\")\n print(senses)\n\n if len(senses) == 0: # means we don't know any sense for this word\n return None\n\n ...
[ "0.57803524", "0.52267176", "0.5220787", "0.52120763", "0.5174642", "0.5164446", "0.5149356", "0.5041184", "0.49859065", "0.49716657", "0.49243554", "0.49187955", "0.49112827", "0.4855967", "0.48273122", "0.4817933", "0.47763702", "0.47615644", "0.4757728", "0.47567716", "0.4...
0.6447261
0
This function was created because we don't want TermManagers getting confused about things like misassigned CAS numbers, because they don't have the capacity to store multiple CFs. So we will save the full synonym list for the LciaEngine.
def _flow_terms(flow): return flow.synonyms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_stempool(self):\n tokens = [apply_word_tokenize(x) for x in self.df['name']]\n\n flatten1 = itertools.chain.from_iterable\n flat = list(flatten1(tokens))\n\n stems = [self.stemmer.stem(x) for x in flat]\n\n return set(stems)", "def nsrSynonyms():\r\n # Input file\r\...
[ "0.57324946", "0.5650351", "0.554946", "0.5542705", "0.5465308", "0.54454356", "0.5441436", "0.53831476", "0.5370351", "0.5335252", "0.5318396", "0.5302473", "0.5295376", "0.5264259", "0.52387655", "0.5215229", "0.5215099", "0.5204873", "0.5161386", "0.51540685", "0.513916", ...
0.52873546
13
Harvest biogenic co2 synonyms (not worth correcting for other biogenic substances??)
def _add_to_existing_flowable(self, fb, new_terms): biog = ('124-38-9' in fb) for term in new_terms: self._fm.add_synonym(fb, term) if biog and bool(biogenic.search(term)): self._bio_co2.add_term(term) # ensure that bio term is a biogenic synonym
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nsrSynonyms():\r\n # Input file\r\n synonymsFile = pd.read_csv(args.indir+\"/\"+args.infile2, header=2,\r\n sep=\"\\t\", encoding=\"utf8\")\r\n\r\n # Parse taxonomic names into their elementary components\r\n synonyms = synonymsFile.loc[synonymsFile['language'] == 'Sci...
[ "0.6278373", "0.6064663", "0.6054872", "0.6007341", "0.6002883", "0.59069574", "0.5802612", "0.58015925", "0.57863915", "0.57196033", "0.56676126", "0.5618402", "0.5598366", "0.55523103", "0.5539704", "0.55314595", "0.55285823", "0.5485978", "0.5470576", "0.5457307", "0.54489...
0.0
-1
Here we are not picky about having duplicate quantities
def add_quantity(self, quantity): if quantity.entity_type != 'quantity': raise TypeError('Must be quantity type') if quantity.link not in self._qm: self._qm.add_quantity(quantity) assert quantity.link in self._qm return self._canonical_q(quantity)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_items_quantity_not_duplicates(request):\n all_items_no_duplicates = []\n\n for loop_index, item in enumerate(all_shopping_items(request)):\n item_dict = {\n 'item': item.item,\n 'quantity': item.quantity,\n 'category': item.category.category,\n 'id':...
[ "0.5703828", "0.57010126", "0.5693255", "0.55881643", "0.5587493", "0.5551469", "0.5545252", "0.55120176", "0.54732245", "0.54649097", "0.5460169", "0.5428315", "0.5425589", "0.5398626", "0.53612894", "0.5330958", "0.5326141", "0.5314214", "0.5252058", "0.52479565", "0.523333...
0.0
-1
Absorb second into child of first. Currently does not support remapping entries, so import_cfs(second) needs to be run again. Old factors will be left in so _fq_map still works.
def merge_quantities(self, first, second): dom = self.get_canonical(first) add = self.get_canonical(second) self._qm.merge(dom, add) self.import_cfs(second)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map2(self, f, pt):\n logger.debug('[START] PID[%s] map2 skeleton', PID)\n assert self.__distribution == pt.distribution\n content = SList([None] * self.__content.length())\n for i in range(len(self.__global_index[self.__start_index: self.__start_index +\n ...
[ "0.49451524", "0.48374847", "0.4816826", "0.47681516", "0.47121134", "0.46719477", "0.46434382", "0.4612929", "0.45820156", "0.45763972", "0.4503654", "0.45029733", "0.44901878", "0.44694677", "0.44611233", "0.44572702", "0.4405865", "0.4381707", "0.43751577", "0.43663976", "...
0.41888988
43
For LciaEngines, we use the default behavior of ContextManager which is to first try 'attach', then fallback to 'rename'
def _add_compartments(self, comps): return self._cm.add_compartments(comps)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_context(name, ctx=None):\n if ctx is None:\n ctx = builtins.__xonsh__.ctx\n modctx = xontrib_context(name)\n if modctx is None:\n if not hasattr(update_context, \"bad_imports\"):\n update_context.bad_imports = []\n update_context.bad_imports.append(name)\n ...
[ "0.5382174", "0.52348757", "0.5089552", "0.4976699", "0.4921123", "0.4909736", "0.4871767", "0.48032677", "0.47282645", "0.47134584", "0.46923074", "0.46920326", "0.46766403", "0.46594715", "0.4586809", "0.45746368", "0.456511", "0.45414543", "0.45359203", "0.45268455", "0.45...
0.0
-1
Given a quantity, import its CFs into the local database. Unfortunately this is still going to be slow because every part of the CF still needs to be canonicalized. The only thing that's saved is creating a new Characterization instance.
def import_cfs(self, quantity): try: qq = self._canonical_q(quantity) except KeyError: qq = self.add_quantity(quantity) count = 0 for cf in quantity.factors(): count += 1 # print(cf) try: fb = self._fm[cf.flowab...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_counties():\n\n query = 'INSERT INTO texas_counties(county, region) VALUES(%s,%s)'\n with persistence() as db:\n # create new cursor instance\n cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor)\n\n for council, counties in COUNCIL_DATA.items():\n for...
[ "0.54053676", "0.5345252", "0.5009659", "0.49099687", "0.47605696", "0.4740605", "0.4696015", "0.46920276", "0.46907184", "0.46507764", "0.46204922", "0.46030006", "0.45985758", "0.45907193", "0.45657995", "0.4537645", "0.45328835", "0.45299235", "0.45244938", "0.45229474", "...
0.7534431
0
Assigns the cf to the mapping; does subclassspecific collision checking
def _store_cf(cl, context, new_cf): try: cl.add(new_cf, key=context) except TypeError: print(type(cl)) raise
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collision(self):\n raise NotImplementedError", "def applyMapping(self):\n pass", "def setupCollisions(self):\n\t\tbase.cTrav = CollisionTraverser()\n\t\tself.cHandler = CollisionHandlerEvent()\n\t\t#self.cHandler.setInPattern('%fn-sped-up')\n\t\t\n\t\tcQuad = CollisionPolygon(Point3(0, 0, 0),...
[ "0.5515978", "0.53430635", "0.52271914", "0.522315", "0.5207508", "0.519834", "0.5172758", "0.5147812", "0.5145852", "0.51225555", "0.5114735", "0.50724304", "0.50228596", "0.50203246", "0.49639764", "0.49526194", "0.4949708", "0.4940785", "0.49291757", "0.49172798", "0.49058...
0.46996704
46
Adds ability to filter by origin note this is exclusive to the ability to filter by quantity
def flowables(self, search=None, origin=None, new=False, **kwargs): if origin is None: _iter = super(LciaEngine, self).flowables(search=search, **kwargs) else: if search is None: _iter = self._fb_by_origin[origin] else: _iter = (str(x) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_restriction_filters(self):\n self.restriction_filters[\"pk__exact\"] = self.request.user.pk", "def filter(self, *args, **kwargs):", "def _custom_filter(self, query):\r\n return query", "def filter_disputes_notes_grid(self, column_name, filter_item):\n self.grid_filter_with_textbo...
[ "0.59470046", "0.56179065", "0.5568572", "0.55291736", "0.55232686", "0.550949", "0.5477399", "0.5416927", "0.53570306", "0.5337462", "0.5325544", "0.524886", "0.52306837", "0.52302957", "0.5215678", "0.52031213", "0.5201506", "0.51735073", "0.51728815", "0.51467144", "0.5142...
0.0
-1
We assume that all biogenic CO2 flows will be detected via add_flow, and will have their names set to something
def _quell_co2(self, flowable, context): if self._quell_biogenic is False: return False if flowable in self._bio_co2: if context.is_subcompartment(self._cm['from air']): return True if context.is_subcompartment(self._cm['Emissions']): r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _dup_pipeline_name_cfg(self):", "def _configure_flowables(self, flowables):\n if flowables is None:\n flowables = DEFAULT_FLOWABLES\n\n # FlowablesDict-- mainly to upsample CAS numbers for matching\n self._fm = FlowablesDict()\n\n self._fm.new_entry('carbon dioxide', '1...
[ "0.58474296", "0.569925", "0.56435513", "0.53014785", "0.52610934", "0.5227977", "0.5182955", "0.5182175", "0.5170833", "0.5162001", "0.5134495", "0.51231927", "0.5099633", "0.50600487", "0.50040334", "0.5002867", "0.49885595", "0.4968262", "0.49279296", "0.49234572", "0.4919...
0.0
-1
detach lookup for cleanness. canonical everything
def _factors_for_flowable(self, fb, qq, cx, **kwargs): self._check_factors(qq) try: cl = self._qlookup(qq, fb) except NoFQEntry: return if cx is None: for v in cl.cfs(): yield v else: for v in cl.find(cx, **kwargs): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applyDemapping(self):\n pass", "def cleanup():", "def revise():", "def cleanup(self):", "def cleanup(self):", "def cleanup(self):", "def clean(_context):", "def clean(c):", "def horde_cleanup(self):", "def _clean_up(self):", "def cleanup(self):\n for residue in self.debumper.b...
[ "0.6569446", "0.58934015", "0.5845248", "0.57096654", "0.57096654", "0.57096654", "0.56681806", "0.5656693", "0.565422", "0.56260526", "0.5572836", "0.5460176", "0.54530233", "0.54232705", "0.5409617", "0.540709", "0.5392803", "0.5388027", "0.53739077", "0.5367186", "0.536718...
0.0
-1
Here we deal with water contexts specified as flowables by creating children this is generalizeable (vs for CO2)
def factors_for_flowable(self, flowable, quantity=None, context=None, **kwargs): try: fb = self._fm[flowable] except KeyError: return ''' # this does not do anything helpful if fb == self._fm['Water']: try: context = self._cm['flow-%s'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def child_case():\n result = ObjectContainer()\n\n flow1 = Flow(\"flow1\")\n result.flow1 = flow1\n\n with flow1.add_container(\"container1\") as container1:\n result.container1 = container1\n with container1.add_task(\"task1\") as task1:\n result.task1 = task1\n with co...
[ "0.605448", "0.5835285", "0.57355165", "0.57282794", "0.56974614", "0.5680976", "0.56371605", "0.5522915", "0.54681087", "0.5428466", "0.54168093", "0.5416636", "0.5369338", "0.5354371", "0.53340364", "0.5281433", "0.5277179", "0.52718735", "0.52553463", "0.5245438", "0.52121...
0.5138674
27
This function can sum any objects which have __add___
def custom_sum(*args): return functools.reduce(lambda x, y: x + y, args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __add__(self, other):\r\n return self.add(other)", "def __add__(self, other):\n pass", "def __add__(self, other):\n pass", "def __add__(self, other):\n return self.add(other)", "def add(obj):", "def __add__(self, other):\n \"*** YOUR CODE HERE ***\"", "def __add__...
[ "0.7702068", "0.75945014", "0.75945014", "0.7573851", "0.75017023", "0.7357567", "0.72784346", "0.72784346", "0.7203079", "0.7149354", "0.7149354", "0.7116317", "0.7116317", "0.7116317", "0.7116317", "0.7116317", "0.7116317", "0.7116317", "0.70699376", "0.7068136", "0.7054115...
0.65717214
84
Test a model on an example
def infer(self, example, model): asp_input = model + '\n\n' + example + '\n\n' + inference_program_ec ctl = clingo.Control() ctl.add("base", [], asp_input) ctl.ground([("base", [])], context=self) ctl.solve(on_model=self.show_model)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_model():\n pass", "def test_example(self):\n self.assertEqual(self.example.get_example(), True)", "def testModel( self, classTest, classPred):", "def test_model_found(arguments):\n ...", "def testGetReigsteredModel(self):\n from soc.models.student import Student\n model = mo...
[ "0.77361155", "0.74117136", "0.7402094", "0.7367298", "0.6964708", "0.6916549", "0.68771887", "0.68725353", "0.6861734", "0.6753478", "0.6733257", "0.6683285", "0.66675687", "0.66135466", "0.6555324", "0.65510744", "0.6531237", "0.6518147", "0.6501927", "0.65007454", "0.64869...
0.0
-1