query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Compute the sign of the `root` that yield the smallest weighted cut in `tree_adj` given the already revealed `nodes_sign`. | def flep(tree_adj, nodes_sign, edge_weight, root, return_fullcut_info=False):
# start = clock()
assert isinstance(tree_adj, dict)
if not (isinstance(nodes_sign, tuple) and len(nodes_sign) == 2):
nodes_sign = (nodes_sign, nodes_sign)
if root in nodes_sign[0]:
cutp, cutn = (MAX_WEIGHT, 0) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_node_sign(tree_adj, node, nodes_status, nodes_sign, hinge_lines,\n edge_weight):\n q = deque()\n status = defaultdict(lambda: (False, 0))\n q.append(node)\n status[node] = (True, 0)\n connect_nodes = {}\n min_connect, min_connect_distance = None, 2e9\n while q:... | [
"0.60380954",
"0.58173275",
"0.56156844",
"0.56066066",
"0.5505414",
"0.5458044",
"0.52484727",
"0.52415603",
"0.52331084",
"0.52293885",
"0.5228589",
"0.5197665",
"0.5183578",
"0.51605326",
"0.51593035",
"0.51516813",
"0.5068861",
"0.5022855",
"0.50157493",
"0.50155133",
"0.... | 0.6511304 | 0 |
Get the edges of the hinge tree rooted at `root`. | def get_hinge_tree(root, tree_adj, hinge_nodes):
queue = deque((root, ))
discovered = defaultdict(lambda: False)
discovered[root] = True
sub_adj = {root: set()}
while queue:
v = queue.popleft()
if v in hinge_nodes:
continue
for u in tree_adj[v]:
if not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_edges(self):\n return [tuple(edge) for edge in self._tree.tree_grid[1:3, :].T]",
"def generate_edgelist(ast_root):\n edges = []\n\n def walk_tree_and_add_edges(node):\n for child in node.children:\n edges.append([node.identifier, child.identifier])\n walk_tree_an... | [
"0.65350896",
"0.6380477",
"0.6236031",
"0.6185158",
"0.6100252",
"0.60605776",
"0.60532624",
"0.6031872",
"0.6026344",
"0.60224915",
"0.60098165",
"0.60098165",
"0.60098165",
"0.60098165",
"0.60098165",
"0.60098165",
"0.5993045",
"0.5953177",
"0.5929027",
"0.59179825",
"0.58... | 0.6439717 | 1 |
Propagate the sign of hinge_node to the closest node in the hinge tree. Returns all the node in `node_predictions` whose sign was predicted by this hinge node. | def propagate_hinge(tree_adj, hinge_node, hinge_sign, node_predictions, edge_weight):
discovered, predicted = defaultdict(lambda: False), set()
dst_from_that_hinge = {hinge_node: 0}
discovered[hinge_node] = True
queue = deque([hinge_node, ])
while queue:
v = queue.popleft()
current_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_hinge_nodes(tree_adj, edge_weight, nodes_sign, node_to_predict,\n with_distances=False, with_visited=False):\n stack = []\n # the fields are: discovered, distance_from_root, incident_hinge_line, marked\n status = defaultdict(lambda: [False, float(MAX_WEIGHT), 0, False])\n s... | [
"0.7134438",
"0.6737355",
"0.58424485",
"0.5277435",
"0.49557328",
"0.4929456",
"0.49170706",
"0.486149",
"0.47995198",
"0.4798005",
"0.47674358",
"0.47608614",
"0.47346276",
"0.46701452",
"0.46646553",
"0.46337318",
"0.46312234",
"0.46161234",
"0.4597922",
"0.45949376",
"0.4... | 0.8085963 | 0 |
Remove personality types words given in text from list of tokenized words | def remove_ptype_words(self):
new_words = []
# new_words = ""
for word in self.words:
#after making words to lower letters
new_word = re.sub(r'\b(istj|istp|isfj|isfp|infj|infp|intj|intp|estp|estj|esfp|esfj|enfp|enfj|entp|entj)', '', word)
if new_word != '':
new_words.append(new... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filterWords(text):\n words = text.split()\n out = []\n for w in words:\n w = normalizeOrRemoveWord(w)\n if w != None:\n out.append(w)\n return out",
"def remove_unused_words(text_list, vocab):\n vocabset = set(vocab)\n for i in range(0, len(text_list)):\n tok... | [
"0.7609409",
"0.75687563",
"0.7470731",
"0.72247905",
"0.7206743",
"0.71561325",
"0.7130392",
"0.7122282",
"0.7087075",
"0.7075506",
"0.7055075",
"0.70487016",
"0.7048034",
"0.70478773",
"0.70322025",
"0.7027062",
"0.69901526",
"0.697843",
"0.6960401",
"0.6938746",
"0.6935899... | 0.7178716 | 5 |
Lemmatize verbs in list of tokenized words | def lemmatize_verbs(self):
lemmas = []
# lemmas = ""
for word in self.words:
lemma = wn.lemmatize(word, pos='v')
lemmas.append(lemma)
# lemmas += f"{lemma} "
self.words = lemmas
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatization(tokenized_word_list):\n porter=nltk.stem.PorterStemmer()\n filtered_tokens = [porter.stem(word) for word in tokenized_word_list]\n return filtered_tokens",
"def lemmatisation(tokens):\n pos_tag = nltk.pos_tag(tokens)\n lemmatiser = nltk.WordNetLemmatizer()\n wornet_tags = {\"J... | [
"0.8030228",
"0.7929821",
"0.78893256",
"0.78252596",
"0.7756634",
"0.7741538",
"0.7741538",
"0.7741538",
"0.7741538",
"0.7741538",
"0.7741538",
"0.77332175",
"0.77103",
"0.7703726",
"0.7699928",
"0.76371783",
"0.7631672",
"0.75700194",
"0.7544735",
"0.7536392",
"0.75226045",... | 0.79704237 | 1 |
Return True if the user's account is from a priviledged domain. | def IsPriviledgedDomainUser(email):
if email and '@' in email:
_, user_domain = email.split('@', 1)
return user_domain in settings.priviledged_user_domains
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_privileged_user(email):\n if local_config.AuthConfig().get('all_users_privileged'):\n return True\n\n privileged_user_emails = (db_config.get_value('privileged_users') or\n '').splitlines()\n return any(\n utils.emails_equal(email, privileged_user_email)\n for pri... | [
"0.63530934",
"0.6297092",
"0.62180763",
"0.61976665",
"0.6153836",
"0.615255",
"0.58828485",
"0.5874819",
"0.5859209",
"0.5850652",
"0.5830579",
"0.5830579",
"0.5816409",
"0.5808903",
"0.5808533",
"0.5804732",
"0.57832104",
"0.5780676",
"0.57508516",
"0.57218134",
"0.5715271... | 0.76116556 | 0 |
Returns the value to which the specified key is mapped, or 1 if this map contains no mapping for the key | def get(self, key: int) -> int:
idx = key % 1000
if not self.map[idx]:
return -1
else:
curr = self.map[idx]
while curr:
if curr.key == key:
return curr.val
curr = curr.next
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key: int) -> int:\n if key not in self.map:\n return -1\n return self.map[key]",
"def get(self, key: int) -> int:\n if key in self.hashmap.keys():return self.hashmap[key]\n else:return -1",
"def get(self, key: int) -> int:\n sh = key % 37\n if ... | [
"0.8002072",
"0.7907979",
"0.76276183",
"0.7563081",
"0.7554108",
"0.752721",
"0.75236875",
"0.7371581",
"0.72921616",
"0.72912604",
"0.7219647",
"0.72144943",
"0.71786934",
"0.7174939",
"0.71607196",
"0.69786674",
"0.69259864",
"0.67828715",
"0.6754241",
"0.6731898",
"0.6610... | 0.74908173 | 7 |
Class constructor. Instantiates a new ``DeviceRequestException`` object with the provided parameters. | def __init__(self, msg: str) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, error_msg):\n super(SdkException, self).__init__()\n self.error_msg = error_msg",
"def __init__(self, code, reason):\n super(RequestError, self).__init__(code, reason)",
"def __init__(self, status_code, sdk_error):\n super(ServiceResponseException, self).__init__(... | [
"0.5803186",
"0.57217526",
"0.5709015",
"0.5543319",
"0.55284464",
"0.52882785",
"0.52495176",
"0.52209544",
"0.5206861",
"0.5201629",
"0.5142849",
"0.5119837",
"0.5097363",
"0.50917476",
"0.50868946",
"0.50698847",
"0.50603795",
"0.5054095",
"0.50455505",
"0.50335705",
"0.50... | 0.0 | -1 |
Construct a node that stores the specified value. prev and next references are optional on construction and default to None if nothing else is specified | def __init__(self, value, prev=None, next=None):
self.prev = prev # the node before this one — defaults to None
self.value = value # the value to store
self.next = next # the node after this one — defaults to None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, value, next_node=None):\n self.value = value # element at the node\n self.next_node = next_node # reference to next node",
"def __init__(self, value, next=None):\n self.value = value\n self.next = next",
"def __init__(self, value, next=None):\n self.value... | [
"0.73599726",
"0.7201069",
"0.71057945",
"0.710285",
"0.70844734",
"0.6709122",
"0.66811043",
"0.666139",
"0.6589233",
"0.6539927",
"0.65295476",
"0.6526624",
"0.64724946",
"0.6423439",
"0.63919574",
"0.63919574",
"0.6387749",
"0.63873935",
"0.63873935",
"0.637498",
"0.635869... | 0.85737437 | 0 |
Returns a string representation of this DoublyLinkedList | def __repr__(self):
if self.size == 0:
return "DLL=[]"
str_repr = "DLL=["
current_node = self.head
while current_node is not None:
str_repr += f"{current_node} -> "
current_node = current_node.next
str_repr = f"{str_repr[:-4]}]"
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n s = \"\"\n current = self.__head\n while current:\n s += str(current.data) + \"\\n\"\n current = current.next_node\n return s[:-1]",
"def __str__(self):\n string = \"\"\n cur_node = self.head\n while cur_node is not None:... | [
"0.8245704",
"0.81759214",
"0.8072831",
"0.8020273",
"0.7998722",
"0.79295236",
"0.79042274",
"0.7739197",
"0.7682769",
"0.7680147",
"0.76750654",
"0.76048154",
"0.7598787",
"0.7597622",
"0.75905746",
"0.75905746",
"0.75885516",
"0.7574767",
"0.7558033",
"0.7550062",
"0.75490... | 0.71998256 | 35 |
Wraps the given value in a ListNode and inserts it as the new head of the list. Don't forget to handle the old head node's previous pointer accordingly. | def add_to_head(self, value):
new_node = ListNode(value)
if self.size == 0:
self.head = new_node
self.tail = new_node
else:
new_node.next = self.head
self.head.prev = new_node
new_node.next = self.head
self.head = new_node... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAtHead(self, val):\n new_node = ListNode(val)\n new_node.next = self.head\n self.head = new_node\n self.length += 1",
"def addAtHead(self, val):\n node = ListNode(val)\n if self.head == None:\n self.head = node\n else:\n node.next = se... | [
"0.7515542",
"0.74239516",
"0.7190123",
"0.7158426",
"0.7061008",
"0.70294493",
"0.6970894",
"0.68880725",
"0.68419516",
"0.67599696",
"0.67299294",
"0.67298996",
"0.6727644",
"0.66970205",
"0.66927296",
"0.6691734",
"0.66664726",
"0.66664726",
"0.66185343",
"0.66128457",
"0.... | 0.7749629 | 0 |
Wraps the given value in a ListNode and inserts it as the new tail of the list. Don't forget to handle the old tail node's next pointer accordingly. | def add_to_tail(self, value):
new_node = ListNode(value)
if self.size == 0: # if list is empty
self.head = self.tail = new_node # make new_node both head and tail
else:
self.tail.next = new_node # place new_node after tail
new_node.prev = self.tail # pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAtTail(self, val):\n curr = self.head\n while curr.next:\n curr = curr.next\n new_node = ListNode(val)\n curr.next = new_node\n self.length += 1",
"def addAtTail(self, val):\n node = ListNode(val)\n if self.head == None:\n self.head = ... | [
"0.795366",
"0.7787602",
"0.7488099",
"0.73066425",
"0.7301531",
"0.72027487",
"0.7166401",
"0.71181184",
"0.7091644",
"0.7058869",
"0.7002252",
"0.6995476",
"0.6971394",
"0.6942306",
"0.6942306",
"0.6876243",
"0.6858508",
"0.6785757",
"0.67506313",
"0.67359084",
"0.6731195",... | 0.78356844 | 1 |
Removes the List's current tail node, making the current tail's previous node the new tail of the List. Returns the value of the removed Node. | def remove_from_tail(self):
if self.size == 0: # if list is empty
return None # nothing to remove; return out
tail_to_remove = self.tail # copy value of current tail before deletion (for return)
tail_to_remove.prev = tail_to_remove.next = None # remove any ties to list
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_last(self):\n # return None if no Node to remove\n if self.tail is None:\n return None\n # save the tail\n removed = self.tail\n # set the new tail\n if self.tail != self.head:\n if self.tail.skip_back is None:\n self.tail = ... | [
"0.8073003",
"0.7691993",
"0.7682898",
"0.7649329",
"0.7625997",
"0.7569338",
"0.7505117",
"0.7456315",
"0.74213463",
"0.7277503",
"0.71283627",
"0.709815",
"0.70919055",
"0.70697725",
"0.7012255",
"0.6973596",
"0.6968318",
"0.69624215",
"0.6894814",
"0.6893733",
"0.68922377"... | 0.80111617 | 1 |
Removes the input node from its current spot in the List and inserts it as the new head node of the List. | def move_to_front(self, node):
if self.size == 0: # no items in list
return # nothing to move; return out
if self.head is node: # if node is head already
return # nothing to move, node is at beginning; return out
if self.tail is node: # if node is tail
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_linked_list(input_list):\n\t\ttry:\n\t\t\thead = Node(input_list.pop(0)) #remove the first list item and return as its head\n\n\t\t\twhile (len(input_list)>0):\n\t\t\t\tcurrent_node = head\n\t\t\t\twhile current_node.next:\n\t\t\t\t\tcurrent_node = current_node.next\n\t\t\t\tcurrent_node.next = Node(inp... | [
"0.699391",
"0.69814193",
"0.6884986",
"0.6856627",
"0.6829033",
"0.6725257",
"0.66008973",
"0.65924186",
"0.6571658",
"0.6519314",
"0.65168566",
"0.6482488",
"0.6479803",
"0.64417773",
"0.6418317",
"0.64144427",
"0.638319",
"0.6372999",
"0.631416",
"0.6288066",
"0.62879497",... | 0.6505445 | 11 |
Removes the input node from its current spot in the List and inserts it as the new tail node of the List. | def move_to_end(self, node):
if self.size == 0: # no items in list
return # there is no such node
if node is self.tail: # node is already at end as it is the tail
return # node does not need to be moved
if node is not self.head:
# node must be in the mi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_back(self, item):\n new_node = Node(item) # first create a node\n # if the list is empty, make it head\n if self.head is None:\n self.head = new_node\n else:\n # else, travel till the end \n temp_node = self.head\n while temp_node.ne... | [
"0.6751531",
"0.65330744",
"0.6455957",
"0.64297324",
"0.63831943",
"0.63621294",
"0.6360353",
"0.6302879",
"0.6256736",
"0.6143983",
"0.6120773",
"0.6098733",
"0.60908645",
"0.60882473",
"0.6087474",
"0.60345596",
"0.60271823",
"0.6011966",
"0.6008051",
"0.6007572",
"0.59813... | 0.6368737 | 5 |
Finds and returns the maximum value of all the nodes in the List. | def get_max(self):
max_value = self.head.value
current_node = self.head
# while current_node.next is not None: # when current_node = current.tail, this will not iterate
while current_node.next is not None: # when current_node = current.tail, this will not iterate
current_no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max(self):\n return max(self.nodes, key=int)",
"def find_max(list):\n return find_value_at(list, 0)",
"def max(self):\n no = self.root\n if no:\n no = self.__search_node_max_esq(no)\n if no:\n return no.valor\n return None",
"def fi... | [
"0.8191074",
"0.76349306",
"0.74023765",
"0.7374936",
"0.7374748",
"0.7215606",
"0.71712154",
"0.7167307",
"0.7113489",
"0.70883113",
"0.7053359",
"0.7034993",
"0.7021691",
"0.69815075",
"0.69487154",
"0.6938005",
"0.69217247",
"0.6909923",
"0.6898844",
"0.6849697",
"0.682310... | 0.7679494 | 1 |
Instances of a class which mixes in L{FancyEqMixin} but which defines no comparison attributes compare by identity. | def test_identity(self):
class Empty(util.FancyEqMixin):
pass
self.assertFalse(Empty() == Empty())
self.assertTrue(Empty() != Empty())
empty = Empty()
self.assertTrue(empty == empty)
self.assertFalse(empty != empty) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neq__(self, other): \n return not self == other",
"def complete_comparisons(cls):\n assert cls.__lt__ is not object.__lt__, \"{0} must define < and ideally ==\".format(cls.__name__)\n if cls.__eq__ is object.__eq__:\n cls.__eq__ = lambda self, other: not (cls.__lt__(self, other) ... | [
"0.68128383",
"0.6553233",
"0.6434358",
"0.63941896",
"0.63873625",
"0.63811046",
"0.63771963",
"0.63696903",
"0.63482636",
"0.63344187",
"0.6327503",
"0.6325841",
"0.6320512",
"0.6305288",
"0.6292751",
"0.6251479",
"0.6250307",
"0.62420076",
"0.6239211",
"0.6237525",
"0.6231... | 0.65408975 | 2 |
Instances of a class which mixes in L{FancyEqMixin} should compare equal if all of their attributes compare equal. They should not compare equal if any of their attributes do not compare equal. | def test_equality(self):
self.assertTrue(Record(1, 2) == Record(1, 2))
self.assertFalse(Record(1, 2) == Record(1, 3))
self.assertFalse(Record(1, 2) == Record(2, 2))
self.assertFalse(Record(1, 2) == Record(3, 4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return np.all([\n self.__getattribute__(name) == other.__getattribute__(name)\n for name in self._fields\n ])",
"def __eq__(self, other):\n\t\treturn all((getattr(self, attr, None) == getattr(other, attr, None) for attr in self.attrs))",
"def __eq_... | [
"0.6926736",
"0.6895417",
"0.66664636",
"0.666526",
"0.66455245",
"0.662681",
"0.6613257",
"0.6603822",
"0.6558252",
"0.654533",
"0.6521178",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075606",
"0.65075... | 0.0 | -1 |
Unequality between instances of a particular L{record} should be defined as the negation of equality. | def test_unequality(self):
self.assertFalse(Record(1, 2) != Record(1, 2))
self.assertTrue(Record(1, 2) != Record(1, 3))
self.assertTrue(Record(1, 2) != Record(2, 2))
self.assertTrue(Record(1, 2) != Record(3, 4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equality(self):\n self.assertTrue(Record(1, 2) == Record(1, 2))\n self.assertFalse(Record(1, 2) == Record(1, 3))\n self.assertFalse(Record(1, 2) == Record(2, 2))\n self.assertFalse(Record(1, 2) == Record(3, 4))",
"def test_differentClassesInequality(self):\n self.asser... | [
"0.7754087",
"0.72114074",
"0.7166497",
"0.71314144",
"0.711448",
"0.6921058",
"0.6916062",
"0.67009145",
"0.6680914",
"0.6618862",
"0.6589952",
"0.65768164",
"0.65729654",
"0.6566163",
"0.6540872",
"0.653521",
"0.65116584",
"0.648716",
"0.64791775",
"0.64765286",
"0.6430965"... | 0.8289913 | 0 |
Instances of different classes which mix in L{FancyEqMixin} should not compare equal. | def test_differentClassesEquality(self):
self.assertFalse(Record(1, 2) == DifferentRecord(1, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neq__(self, other): \n return not self == other",
"def __ne__(self, other):\n return super().__eq__(other)",
"def __ne__(self, other):\n return super().__eq__(self)",
"def __eq__(self, other):\n return super().__ne__(other)",
"def __ne__(self, other):\n r... | [
"0.78159",
"0.74686706",
"0.74470246",
"0.74408126",
"0.7418714",
"0.7381456",
"0.737931",
"0.73782563",
"0.7376529",
"0.73459125",
"0.7328298",
"0.7324103",
"0.7324103",
"0.7324103",
"0.7317778",
"0.73096704",
"0.72948253",
"0.7281444",
"0.72805995",
"0.72805995",
"0.7265742... | 0.0 | -1 |
Instances of different classes which mix in L{FancyEqMixin} should compare unequal. | def test_differentClassesInequality(self):
self.assertTrue(Record(1, 2) != DifferentRecord(1, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neq__(self, other): \n return not self == other",
"def __eq__(self, other):\n return super().__ne__(other)",
"def __ne__(self, other):\n return super().__eq__(other)",
"def __ne__(self, other):\n return super().__eq__(self)",
"def __eq__(self, other):\n retur... | [
"0.75969505",
"0.73383665",
"0.7300953",
"0.7280761",
"0.7273663",
"0.7237311",
"0.7227009",
"0.71945935",
"0.71929634",
"0.7170359",
"0.7166687",
"0.7166687",
"0.7166687",
"0.7159782",
"0.71538544",
"0.7138677",
"0.71302897",
"0.7128446",
"0.71237576",
"0.71180415",
"0.71180... | 0.73821676 | 1 |
An instance of a class which derives from a class which mixes in L{FancyEqMixin} should compare equal to an instance of the base class if and only if all of their attributes compare equal. | def test_inheritedClassesEquality(self):
self.assertTrue(Record(1, 2) == DerivedRecord(1, 2))
self.assertFalse(Record(1, 2) == DerivedRecord(1, 3))
self.assertFalse(Record(1, 2) == DerivedRecord(2, 2))
self.assertFalse(Record(1, 2) == DerivedRecord(3, 4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inheritedClassesInequality(self):\n self.assertFalse(Record(1, 2) != DerivedRecord(1, 2))\n self.assertTrue(Record(1, 2) != DerivedRecord(1, 3))\n self.assertTrue(Record(1, 2) != DerivedRecord(2, 2))\n self.assertTrue(Record(1, 2) != DerivedRecord(3, 4))",
"def __eq__(self, o... | [
"0.73055047",
"0.6815091",
"0.6725804",
"0.6710778",
"0.67021215",
"0.67021215",
"0.67021215",
"0.67021215",
"0.66213435",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
"0.65785974",
... | 0.7442145 | 0 |
An instance of a class which derives from a class which mixes in L{FancyEqMixin} should compare unequal to an instance of the base class if any of their attributes compare unequal. | def test_inheritedClassesInequality(self):
self.assertFalse(Record(1, 2) != DerivedRecord(1, 2))
self.assertTrue(Record(1, 2) != DerivedRecord(1, 3))
self.assertTrue(Record(1, 2) != DerivedRecord(2, 2))
self.assertTrue(Record(1, 2) != DerivedRecord(3, 4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inheritedClassesEquality(self):\n self.assertTrue(Record(1, 2) == DerivedRecord(1, 2))\n self.assertFalse(Record(1, 2) == DerivedRecord(1, 3))\n self.assertFalse(Record(1, 2) == DerivedRecord(2, 2))\n self.assertFalse(Record(1, 2) == DerivedRecord(3, 4))",
"def __neq__(self, ... | [
"0.7356038",
"0.700089",
"0.67805654",
"0.6763612",
"0.6709476",
"0.6689046",
"0.66677636",
"0.66457164",
"0.6633749",
"0.6583676",
"0.6555667",
"0.6537525",
"0.6537525",
"0.6537525",
"0.6537525",
"0.6521894",
"0.6478246",
"0.6469855",
"0.6469855",
"0.6469855",
"0.6467118",
... | 0.7679615 | 0 |
Lazy get/create of SerializeableDbDictCollection. | def getcreate_serializedbdictcollection(self, flag_createifmissing):
attributename = 'automatic_SerializeableDbDictCollection'
if (not hasattr(self,attributename)):
if (flag_createifmissing):
# create new one (and config it to autocreate serializable fields on request)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.db = collections.defaultdict(dict)",
"def _get_collection(self) -> Any:\n return self.anki.Collection(self.db_location, log=True)",
"def getcreate_serializedbdict_forfield(self, serialized_dict_fieldname):\n sdictcollection = self.getcreate_serializedbdictcollect... | [
"0.6319729",
"0.6121937",
"0.60835916",
"0.58804506",
"0.57958335",
"0.5757507",
"0.56434363",
"0.5593368",
"0.55382925",
"0.551713",
"0.549941",
"0.54920036",
"0.5474999",
"0.54703194",
"0.5452886",
"0.5451142",
"0.5450955",
"0.5450024",
"0.54326767",
"0.5385962",
"0.5382986... | 0.76161957 | 0 |
return the unique elements in a list | def unique_elements_lists(list_in):
return list(dict.fromkeys(list_in)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _unique(li):\n return list(set(li))",
"def unique_list(inlist):\n return set(inlist)",
"def unique(li):\r\n seen = set()\r\n seen_add = seen.add\r\n return [x for x in li if not (x in seen or seen_add(x))]",
"def unique(lis):\n seen = set()\n ret = []\n for elm in lis:\n if... | [
"0.85259205",
"0.8360654",
"0.8286365",
"0.81805784",
"0.81652266",
"0.7975524",
"0.79450583",
"0.7942193",
"0.7941763",
"0.7920785",
"0.791547",
"0.78999156",
"0.7831818",
"0.7779906",
"0.76344943",
"0.7613137",
"0.76124513",
"0.75830996",
"0.7580081",
"0.75387216",
"0.75211... | 0.75088805 | 23 |
Returns whether a tensor is a sparse tensor. | def is_sparse(tensor):
return isinstance(tensor, sparse_tensor.SparseTensor) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sparse(A):\n if isinstance(A, torch.Tensor):\n return A.layout == torch.sparse_coo\n raise TypeError(\"expected Tensor but got %s\" % (type(A).__name__))",
"def is_sparse(x: Any, backend=None) -> bool:\r\n module = get_module(backend)\r\n return module.is_sparse(x)",
"def isspsparse(v... | [
"0.80707175",
"0.7401373",
"0.7263636",
"0.68127817",
"0.6662162",
"0.6615621",
"0.6555875",
"0.6460289",
"0.64170605",
"0.62785006",
"0.62588364",
"0.6156034",
"0.6126516",
"0.6117841",
"0.6044898",
"0.60012466",
"0.59892374",
"0.58526593",
"0.58424604",
"0.5824965",
"0.5791... | 0.9019931 | 0 |
Converts a sparse tensor into a dense tensor and returns it. | def to_dense(tensor):
if is_sparse(tensor):
return sparse_ops.sparse_tensor_to_dense(tensor)
else:
return tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_to_dense(self, tensor: tf.Tensor, output_shape: tf.TensorShape) -> tf.Tensor:\n return tf.scatter_nd(self.observations_index, tensor, output_shape)",
"def dense_to_sparse(self, tensor: tf.Tensor) -> tf.Tensor:\n tensor_shape = tensor.shape\n expand_dims = len(tensor_shape) == 3\n\... | [
"0.77537674",
"0.75783604",
"0.7495346",
"0.7187648",
"0.7165059",
"0.6454642",
"0.64454424",
"0.64441395",
"0.6280887",
"0.62771934",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671",
"0.6273671"... | 0.8281811 | 0 |
Repeats the elements of a tensor along an axis, like `np.repeat`. If `x` has shape `(s1, s2, s3)` and `axis` is `1`, the output will have shape `(s1, s2 rep, s3)`. | def repeat_elements(x, rep, axis):
x_shape = x.get_shape().as_list()
if x_shape[axis] is None:
raise ValueError('Axis ' + str(axis) + ' of input tensor '
'should have a defined dimension, but is None. '
'Full tensor shape: ' + str(tuple(x_shape)) + '. '
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat(x, repeats, axis=None):\r\n return RepeatOp(axis=axis)(x, repeats)",
"def th_repeat(a, repeats, axis=0):\r\n assert len(a.size()) == 1\r\n return th_flatten(torch.transpose(a.repeat(repeats, 1), 0, 1))",
"def repeat_2D_tensor(tensor, k):\n if len(tensor.size()) > 2:\n raise ValueE... | [
"0.80037993",
"0.74887466",
"0.70882505",
"0.7073389",
"0.7044031",
"0.6817529",
"0.67096704",
"0.664271",
"0.6595274",
"0.65667784",
"0.6545866",
"0.64834327",
"0.64760953",
"0.64378166",
"0.6420571",
"0.6265722",
"0.62020355",
"0.6198244",
"0.6192323",
"0.61534244",
"0.6122... | 0.83238393 | 0 |
So a check for has_max_children should go first. At this point if True there is a left and a right. Now if the item is actually a number then finding the target becomes easy. I guess it depends on how its all set up. If its set up in alphabetical order where "a" < "b" == True then we can find the target easily by going... | def contains(self, target):
current = self
while True:
if current.value == target:
return True # Here is base case we are working towards.
elif target < current.value:
if current.left is not None:
current = current.left # this... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_left_most_has_right_child():\n from bbst import Bst\n return Bst([1, 5, 3, 10, 8, 6, 20, 7])",
"def max_child(self, index):\n # left and right child\n left = self._data[(index*2)+1] if (index*2)+1 < len(self) else None\n right = self._data[(index*2)+2] if (index*2)+2 < len(se... | [
"0.6149039",
"0.58563113",
"0.5697393",
"0.56893945",
"0.56746817",
"0.5662397",
"0.56575876",
"0.55683625",
"0.5533951",
"0.5520568",
"0.54744565",
"0.54439235",
"0.540539",
"0.5360846",
"0.53508466",
"0.5346468",
"0.5343605",
"0.53415495",
"0.53324884",
"0.53134257",
"0.531... | 0.5445325 | 11 |
No input Output will be the max either a value or None if tree is empty. | def get_max(self):
current = self
while current.hasRight(): # This is the belief that the max has to be to the right. If you can't go right either in the begining or any more
# if current has a right this line will be set and will keep going from line 129 to 130 until there are no more rig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_maximum_value(self):\n if self.root: \n self.max_val = self.root.value\n else:\n return 'No tree found'\n def inner(root):\n if root.left:\n inner(root.left)\n\n if root.right:\n inner(root.right)\n\n if self.max_val < root.value:\n self.max_val = roo... | [
"0.82669544",
"0.8254846",
"0.81775665",
"0.79240143",
"0.7880571",
"0.7770813",
"0.7495327",
"0.74036235",
"0.7279871",
"0.72643125",
"0.72096175",
"0.7208831",
"0.7188424",
"0.71773493",
"0.7128972",
"0.7126618",
"0.7076047",
"0.7032376",
"0.70166457",
"0.6938572",
"0.69314... | 0.66144097 | 30 |
Obtains current remote schema URL for a particular descriptor. | def get_remote_schema(self, descriptor):
return self._schemas[descriptor]['remote'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_schema_url(self):\n return self.NAME_TYPE_SCHEMAS.get(self.name_type, None)",
"def get_local_schema(self, descriptor):\n return self._schemas[descriptor]['local']",
"def get_url(self):\n return self.db_url",
"def getQualifiedURL(uri = None):\n schema, stdport = ('http', '80')\... | [
"0.6633675",
"0.65734804",
"0.5889959",
"0.5738448",
"0.5717764",
"0.5690382",
"0.56323653",
"0.54965645",
"0.5472219",
"0.5432388",
"0.54311013",
"0.54270416",
"0.54258853",
"0.54123926",
"0.5403416",
"0.5391813",
"0.5358039",
"0.53416306",
"0.53086895",
"0.5308647",
"0.5302... | 0.79740465 | 0 |
Test instantiation with invalid data. | def test_invalid_data_construction(self):
with self.assertRaises(Exception):
LongDecimalEuler(term=-1)
with self.assertRaises(Exception):
LongDecimalEuler(term="aaa")
with self.assertRaises(Exception):
LongDecimalEuler(nodec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_constructor_invalid():\n with pytest.raises(TypeError, match='missing 1 required positional argument'):\n PseudoPotentialData() # pylint: disable=no-value-for-parameter",
"def test_invalid_instantiation(invalid_instance):\n with pytest.raises(ValueError):\n invalid_instance()",
"d... | [
"0.81213725",
"0.76400506",
"0.7603412",
"0.7316727",
"0.7312854",
"0.72701615",
"0.72641975",
"0.7262138",
"0.72463465",
"0.72282493",
"0.71846575",
"0.7140925",
"0.714044",
"0.71171963",
"0.7102141",
"0.7073066",
"0.704396",
"0.7020163",
"0.7010761",
"0.69903606",
"0.698966... | 0.7582369 | 3 |
Basic test of the PyTorch conv3d Node on Glow. | def test_convTranpose2d(self, _, module, inputs, filters, bias=None):
utils.compare_tracing_methods(
module, inputs, filters, fusible_ops={"aten::_convolution"}
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_x3d_head():\n x3d_head = X3DHead(in_channels=432, num_classes=4, fc1_bias=False)\n x3d_head.init_weights()\n\n assert x3d_head.num_classes == 4\n assert x3d_head.dropout_ratio == 0.5\n assert x3d_head.in_channels == 432\n assert x3d_head.init_std == 0.01\n\n assert isinstance(x3d_head... | [
"0.6198485",
"0.6198485",
"0.6041405",
"0.6010433",
"0.5822204",
"0.5797777",
"0.576961",
"0.5693406",
"0.5691574",
"0.56747746",
"0.5674137",
"0.5637991",
"0.56330955",
"0.55875623",
"0.5530903",
"0.5518026",
"0.5505835",
"0.54151446",
"0.5405355",
"0.54030335",
"0.53872454"... | 0.0 | -1 |
Symmetrically normalize adjacency matrix. | def process_adj(adj, model_name):
if model_name == 'Cheby':
laplacian = sp.eye(adj.shape[0]) - normalize_adj(adj - sp.eye(adj.shape[0]))
# TODO(chamii): compare with
# adj)
largest_eigval, _ = eigsh(laplacian, 1, which='LM')
laplacian_norm = (2. / largest_eigval[0]) * laplacian - sp.eye(adj.shape[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_adj(adj):\n\n rowsum = np.array(adj.sum(1))\n d_inv_sqrt = np.power(rowsum, -0.5).flatten()\n d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.\n d_mat_inv_sqrt = np.diag(d_inv_sqrt)\n return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt)",
"def normalize_adj(adj):\n adj = sp.coo_mat... | [
"0.7884367",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76974994",
"0.76909643",
"0.75937736",
"0.7565492",
"0.7335031",
"0.7303798",
"0.72680664",
"0.68839365",
"0.68612736",
"0.68591523",
"0.6830935",
"... | 0.0 | -1 |
returns datum as a List (QUOTE datum) | def text_of_quotation(exp):
return cadr(exp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(self, data):\n\n temp = []\n for item in data:\n if len(item) > 2:\n i = 0\n while i < len(item):\n temp.append(item[i:min(i+2, len(item))])\n i += 2\n else:\n temp.append(item)\n ... | [
"0.63809043",
"0.6354738",
"0.61296904",
"0.6108132",
"0.6075185",
"0.6065557",
"0.6064056",
"0.5983993",
"0.5907554",
"0.5901674",
"0.5890175",
"0.5888486",
"0.58877826",
"0.5887253",
"0.58418417",
"0.58365417",
"0.5831775",
"0.5811988",
"0.5779311",
"0.5771279",
"0.5770686"... | 0.0 | -1 |
Calculates the Gmean (Geometric mean) score between y_true and y_pred. Higher is better (Best = +1), Range = [0, +1] | def g_mean_score(self, y_true=None, y_pred=None, labels=None, average="macro", decimal=None, **kwargs):
y_true, y_pred, binary, representor, decimal = self.get_processed_data(y_true, y_pred, decimal)
matrix, imap, imap_count = cu.calculate_confusion_matrix(y_true, y_pred, labels, normalize=None)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def g_mean_score(y, y_pred):\n\n cm = confusion_matrix(y, y_pred)\n if cm.shape != (2, 2):\n raise ValueError('The ground truth values and the predictions may contain at most 2 values (classes).')\n\n tn = cm[0, 0]\n fn = cm[1, 0]\n tp = cm[1, 1]\n fp = cm[0, 1]\n\n se = tp/float(tp + f... | [
"0.8117465",
"0.76316136",
"0.6909695",
"0.6909695",
"0.68969995",
"0.6861574",
"0.6855192",
"0.68412095",
"0.6814519",
"0.6799021",
"0.67640907",
"0.6755286",
"0.67446375",
"0.674057",
"0.67405224",
"0.6729725",
"0.6720606",
"0.6704577",
"0.6703467",
"0.6682835",
"0.66735095... | 0.7476104 | 2 |
Create Donor class for data and methods for individual donor. | def __init__(self, name, donation=None):
self.name = name.strip()
if donation is None:
self.donations = []
else:
self.donations = list(donations) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, donors=None):\n if donors is None:\n self.donor_info = {}\n else:\n for donor in donors:\n self.donor_info.update({donor.name: donor})",
"def __init__(self, donor_name, donation):\n if isinstance(donor_name, str):\n self._ful... | [
"0.7083028",
"0.6853679",
"0.6548653",
"0.6510359",
"0.6508466",
"0.6329183",
"0.6275936",
"0.6271978",
"0.61312747",
"0.6004974",
"0.5982692",
"0.591139",
"0.582798",
"0.57680005",
"0.5728862",
"0.5689964",
"0.55786735",
"0.5549692",
"0.5518835",
"0.54841137",
"0.54712325",
... | 0.6021735 | 9 |
Average donation is total donations divided by the number of donations. | def avg_donation(self):
return self.tot_donations / self.num_donations | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_donation(self):\n return self.total_donations()/self.num_donations() if self.donations else 0",
"def avg_donation(self):\n return self._total_donation / self.num_of_donations",
"def donation_avg(donor_list, donor):\n return sum(donor_list[donor]) // len(donor_list[donor])",
"def ... | [
"0.8750945",
"0.8710993",
"0.83598036",
"0.8223379",
"0.81161815",
"0.6977119",
"0.6892846",
"0.6592177",
"0.6592177",
"0.64212304",
"0.6382908",
"0.63692343",
"0.63019806",
"0.62876695",
"0.61911476",
"0.6181856",
"0.61506426",
"0.61424124",
"0.6137102",
"0.6126139",
"0.6099... | 0.87955564 | 1 |
Symmetrically normalize adjacency matrix. | def normalize_adj(adj):
adj = sp.coo_matrix(adj)
rowsum = np.array(adj.sum(1))
d_inv_sqrt = np.power(rowsum, -0.5).flatten()
d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.
d_mat_inv_sqrt = sp.diags(d_inv_sqrt)
return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt).tocoo() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_adj(adj):\n\n rowsum = np.array(adj.sum(1))\n d_inv_sqrt = np.power(rowsum, -0.5).flatten()\n d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.\n d_mat_inv_sqrt = np.diag(d_inv_sqrt)\n return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt)",
"def normalize_adj(adj):\r\n adj = sp.coo_m... | [
"0.788518",
"0.7691616",
"0.759434",
"0.7566608",
"0.7335597",
"0.730491",
"0.72684425",
"0.688461",
"0.68616927",
"0.686005",
"0.6832041",
"0.682895",
"0.6750887",
"0.6750057",
"0.67278",
"0.66282207",
"0.6616473",
"0.64879745",
"0.6486613",
"0.63610464",
"0.63610464",
"0.... | 0.7698141 | 9 |
Convert sparse matrix to tuple representation. | def sparse_to_tuple(sparse_mx):
def to_tuple(mx):
if not sp.isspmatrix_coo(mx):
mx = mx.tocoo()
coords = np.vstack((mx.row, mx.col)).transpose()
values = mx.data
shape = mx.shape
return coords, values, shape
if isinstance(sparse_mx, list):
for i in ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_to_tuple(sparse_mx):\n def to_tuple(mx):\n if not sp.isspmatrix_coo(mx):\n mx = mx.tocoo()\n coords = np.vstack((mx.row, mx.col)).transpose()\n values = mx.data\n shape = mx.shape\n return coords, values, shape",
"def sparse_to_tuple(sparse_mx):\r\n ... | [
"0.85870504",
"0.82527",
"0.82527",
"0.8091624",
"0.7986327",
"0.602773",
"0.59843755",
"0.5971062",
"0.59706587",
"0.59447116",
"0.59443593",
"0.5910293",
"0.5910293",
"0.5910293",
"0.5910293",
"0.5910293",
"0.58940256",
"0.58499134",
"0.5845008",
"0.577404",
"0.5689886",
... | 0.82655305 | 6 |
Returns the head of the Q or throws a QueueEmpty | def head(self):
if self.isquiet():
raise QueueEmpty()
qcurr = self.base + "." + str(self.curr)
assert os.path.exists(qcurr)
qt = open(qcurr, "r")
data = qt.read()
qt.close()
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\r\n if self.is_empty():\r\n raise Empty(\"Queue is empty\")\r\n return self._head._element",
"def first(self):\n\t\tif self.is_empty():\n\t\t\traise Empty('Queue is empty')\n\t\treturn self._head._element",
"def peek(self):\n if self.isEmpty(): \n raise Excepti... | [
"0.7923368",
"0.78764904",
"0.78669983",
"0.7800613",
"0.77737886",
"0.7679711",
"0.7663496",
"0.7645859",
"0.753773",
"0.7479664",
"0.7384338",
"0.7362938",
"0.7333714",
"0.7289088",
"0.7278225",
"0.72757244",
"0.7154849",
"0.7138417",
"0.71183276",
"0.70965713",
"0.70891225... | 0.71598333 | 16 |
If there is a next workitem, promotes it to the head of the Q and returns it. Throws QueueNoNext if the Q is empty before the promotion. Throws QueueEmpty if the Q is empty after the promotion. | def next(self):
if self.isquiet():
raise QueueNoNext()
# Delete old item
qcurr = self.base + "." + str(self.curr)
os.unlink(qcurr)
# Next item
self.curr += 1
self._setcurr(self.curr)
return self.head() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _next(self):\n if self._queue_lock.acquire(False):\n raise AssertionError('Expected _queue_lock to be held here')\n\n queue_ids = list(self._queues.keys())\n if not queue_ids:\n raise StopIteration()\n\n # Find the queue whose head item has the lowest priority ... | [
"0.6467348",
"0.635734",
"0.6188191",
"0.61486584",
"0.6064015",
"0.5960086",
"0.5898226",
"0.5837122",
"0.58277684",
"0.5817459",
"0.578595",
"0.5781129",
"0.5777612",
"0.5775094",
"0.5765389",
"0.5750364",
"0.5742091",
"0.5735595",
"0.57277",
"0.57258403",
"0.5724639",
"0... | 0.621936 | 2 |
Add a given variable/variables at the given indices. If any indices are omitted or Falsey, return all data for the missing dimensions. | def load_data(self, var, start=False, end=False, stride=False, node=False, nele=False, layer=False, level=False):
if self._debug:
print('start: {}, end: {}, stride: {}, node: {}, nele: {}, layer: {}, level: {}'.format(start, end, stride, node, nele, layer, level))
# Check if we've got iter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addVars(self, *indexes, **kwargs):\n ...",
"def assignment_by_sum(x, values, indices, axis=0):\n x_new = copy(x)\n values = array(values)\n use_vectorization = hasattr(indices, \"__len__\") and len(indices) < ndim(x)\n if _is_boolean(indices):\n x_new[indices] += values\n ret... | [
"0.588174",
"0.5748312",
"0.56887764",
"0.5541592",
"0.532477",
"0.5275708",
"0.5272247",
"0.51244736",
"0.5117789",
"0.5052568",
"0.50283647",
"0.4994558",
"0.495853",
"0.49242246",
"0.48868543",
"0.48839685",
"0.48709086",
"0.48707464",
"0.48439464",
"0.48312747",
"0.482107... | 0.0 | -1 |
Find the index of the closest node to the supplied position (x, y). Set `cartesian' to True for cartesian coordinates (defaults to spherical). | def closest_node(self, where, cartesian=False, threshold=None, vincenty=False, haversine=False):
if not vincenty or not haversine:
if cartesian:
x, y = self.grid.x, self.grid.y
else:
x, y = self.grid.lon, self.grid.lat
dist = np.sqrt((x - wher... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest(self, x, y):\n if self.direction == 'horizontal':\n p_pts = np.array([\n self.ax.transData.transform((p, 0))[0] for p in self.positions\n ])\n dist = abs(p_pts - x)\n else:\n p_pts = np.array([\n self.ax.transDa... | [
"0.6468099",
"0.63392854",
"0.6245035",
"0.6210202",
"0.6172821",
"0.59789723",
"0.5959503",
"0.5911771",
"0.5731957",
"0.5726857",
"0.56959206",
"0.5672177",
"0.5663832",
"0.5658853",
"0.5654847",
"0.5642785",
"0.5621622",
"0.56084514",
"0.55915296",
"0.5580149",
"0.5578685"... | 0.67675006 | 0 |
The state transition function The action is an integer from 0 to 8, converted into one of nine different actions as described in the convertActionToVelocity function. The velocity is updated first, then the new position is calculated. If the trajectory intersects a track boundary, then the car is sent back to a random ... | def transitionState(self, state, action):
x, y = state
dV_x, dV_y = self.convertActionToVelocity(action)
# Updating velocities with probability 1-no_action_prob
# if the update does not result in both velocities equal to 0
r = random.uniform(0, 1)
if r > self.no_action_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\n new_speed = self._state + action\n new_speed[np.where(new_speed < 0)] = 0\n for car_idx in range(self.num_cars):\n # almost instantaneous\n traci.vehicle.slowDown(self.controllable[car_idx], new_speed[car_idx], 1)\n traci.simulationStep()\... | [
"0.6848148",
"0.6483251",
"0.6460811",
"0.6439687",
"0.63673866",
"0.636132",
"0.6355704",
"0.63357455",
"0.6330187",
"0.6315936",
"0.6315936",
"0.629775",
"0.6239372",
"0.6229056",
"0.62119085",
"0.6198604",
"0.6185552",
"0.61843884",
"0.6176187",
"0.61695313",
"0.61439",
... | 0.78467125 | 0 |
Function that returns True if the line segment 'p1q1' and 'p2q2' intersect. | def doIntersect(self, p1, q1, p2, q2):
# Find the 4 orientations required for
# the general and special cases
o1 = self.orientation(p1, q1, p2)
o2 = self.orientation(p1, q1, q2)
o3 = self.orientation(p2, q2, p1)
o4 = self.orientation(p2, q2, q1)
# General case
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersect_segment(self, p1, p2):\n p1 = base.getvector(p1)\n if len(p1) == 2:\n p1 = np.r_[p1, 1]\n p2 = base.getvector(p2)\n if len(p2) == 2:\n p2 = np.r_[p2, 1]\n \n\n z1 = self.line * p1\n z2 = self.line * p2\n\n if np.sign(z1) !=... | [
"0.78153306",
"0.75366807",
"0.74173826",
"0.74093777",
"0.73372614",
"0.73336077",
"0.7283651",
"0.7081966",
"0.707857",
"0.70425403",
"0.702909",
"0.70087206",
"0.6929714",
"0.69180727",
"0.6898419",
"0.6852868",
"0.68210685",
"0.67998624",
"0.6798945",
"0.6771915",
"0.6768... | 0.7941821 | 0 |
Convert all string to lowercase letters, and replaces spaces with '_' char | def mix_string (str):
return str.replace(' ', '_').lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lower_replace(value):\n return value.lower().replace(\" \",\"_\")",
"def sanitize(string):\n retval = string.lower()\n retval = re.sub(r\"[^\\w\\s]\", '', retval)\n retval = re.sub(r\"\\s+\", '_', retval)\n return retval",
"def underscore(string):\n # NOTE(retr0h): Taken from jpvanhal/inf... | [
"0.7754718",
"0.7556234",
"0.7519772",
"0.7389597",
"0.7366774",
"0.7366774",
"0.728275",
"0.7262716",
"0.72506166",
"0.72419626",
"0.723379",
"0.7225429",
"0.72144556",
"0.7196569",
"0.71884257",
"0.7184193",
"0.71709204",
"0.71439636",
"0.7118882",
"0.70988643",
"0.709532",... | 0.79720896 | 0 |
Returns the length of the data set. | def obs_length(self):
return self.lc.time[-1] - self.lc.time[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\r\n if self.is_superset:\r\n length = 0\r\n for ds in self.data:\r\n length += len(ds)\r\n return length\r\n else:\r\n return len(self.data)",
"def data_count(self):\n return(len(self.data))",
"def size(self) -> ... | [
"0.83938617",
"0.8206444",
"0.8204359",
"0.81794214",
"0.81794214",
"0.81794214",
"0.8163545",
"0.8163545",
"0.8163545",
"0.8163545",
"0.815379",
"0.8150156",
"0.81189954",
"0.811755",
"0.8069563",
"0.79593843",
"0.79593843",
"0.7942892",
"0.7942857",
"0.79280853",
"0.7889535... | 0.0 | -1 |
Returns a folded light curve. Signature equivalent to lightkurve.LightCurve.fold. | def fold(self, period, t0=None, transit_midpoint=None):
return self.lc.fold(period, t0, transit_midpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lightcurve(self):\n return NGCLightCurve(self['corotid'])",
"def lofted_car(self):\n return LoftedSolid(profiles=self.chamfered_curve,\n mesh_deflection=1e-4)",
"def foldcurve(_band, _period):\n # Set epoch to first date observed\n _epoch = _band[0][0]\n # I... | [
"0.6475792",
"0.5845715",
"0.5207177",
"0.5197757",
"0.50833356",
"0.50737745",
"0.50251245",
"0.49671057",
"0.49563763",
"0.4930438",
"0.49248856",
"0.4881326",
"0.4871287",
"0.48676234",
"0.4861727",
"0.48406097",
"0.4822176",
"0.48220855",
"0.48162645",
"0.4804254",
"0.479... | 0.49613076 | 8 |
Plots the light curve. If a result is already computed, it also plots the resulting model | def plot_lc(self, show=False, result = None, **kwargs):
for i in ['color', 'ylabel', 'normalize']:
try:
del kwargs[i]
except KeyError:
pass
ax: Axes = self.lc.scatter()
model = result if result is not None and len(result) >0 else self.res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_lightcurve(self):\n\n time_array = self.exp_start_times\n\n fig = plt.figure()\n\n if self.transmission_spectroscopy:\n lc_model = self.generate_lightcurves(time_array,\n self.planet.calcTransitDepth())\n plt.ylabel... | [
"0.7002171",
"0.6955156",
"0.6937426",
"0.6801317",
"0.6467292",
"0.64019245",
"0.6398893",
"0.63595045",
"0.6289188",
"0.62866306",
"0.6282411",
"0.62724376",
"0.6262875",
"0.6261419",
"0.6221988",
"0.6221639",
"0.620612",
"0.6200242",
"0.6186521",
"0.6186521",
"0.6186521",
... | 0.6161957 | 23 |
Turn off email notifications for replies to this comment. | def unsubscribe(self, email, id):
self.db.commit([
'UPDATE comments SET',
' notification=0',
'WHERE email=%s AND (id=%s OR parent=%s);'], (email, id, id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_receive_no_mail(self):\n self.__mail = False",
"def send_all_notes_off(self, ch=None):\n self.send_control_change(ALL_NOTES_OFF, 0, ch=ch)",
"def suppress_notifications(self) -> Iterator[None]:\n old = self.set_notifications_enabled(False)\n yield\n self.set_notificat... | [
"0.6442021",
"0.5933037",
"0.5742021",
"0.55164504",
"0.55039537",
"0.54175514",
"0.53476405",
"0.52276963",
"0.52276963",
"0.522494",
"0.51838",
"0.5175598",
"0.5170775",
"0.5162136",
"0.5052024",
"0.50397307",
"0.49801522",
"0.49743384",
"0.4917473",
"0.4896619",
"0.4879046... | 0.5785742 | 2 |
Loads the raw resource file and yields chunks of the specified size in bytes. | def generate_chunk(self, filename):
# open resource file in binary
with open(filename, 'rb') as resource:
# instantiate chunk start byte and trailing line string
p = 0
overlap = ''
while p <= self.file_size:
try:
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partial_reader(filename, chunk_size):\n try:\n file = open(filename, 'rb')\n while True:\n chunk = file.read(chunk_size)\n if not chunk:\n return\n yield chunk\n except IOError as e:\n logger.error(\"... | [
"0.7236397",
"0.6883338",
"0.6774075",
"0.6741574",
"0.67284155",
"0.6721304",
"0.6670949",
"0.66698337",
"0.65777737",
"0.6555259",
"0.6555259",
"0.65491897",
"0.6548192",
"0.65204406",
"0.65183353",
"0.6517779",
"0.6504328",
"0.65040284",
"0.65040284",
"0.65040284",
"0.6504... | 0.5872825 | 47 |
Initialize a data node with data. | def __init__(self, data):
super(DataNode, self).__init__()
# the current data
self._data = data
# the set of children
self._children = set() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data, node):\n self.data = data\n self.node = node",
"def __init__(self, data, node):\n self.data = data\n self.node = node # This is the data structure which holds the data for this node, e.g. lat, lon, etc.",
"def __init__(self, data, next_node=None):\n s... | [
"0.8172431",
"0.7910768",
"0.76385134",
"0.76385134",
"0.7619343",
"0.74057317",
"0.7325825",
"0.7239916",
"0.7229517",
"0.7216096",
"0.72139573",
"0.7137145",
"0.7105465",
"0.70861906",
"0.70344925",
"0.7012536",
"0.7000159",
"0.7000159",
"0.69925267",
"0.69907486",
"0.69907... | 0.75863 | 5 |
Get a copy of the children set. | def get_children(self):
return self._children.copy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_children(self):\n return set()",
"def children(self):\n if self._children is None:\n return set()\n else:\n return self._children",
"def get_all_children(self):\n all_children = set()\n for parent in self.children:\n all_children.add(... | [
"0.7837752",
"0.7660914",
"0.6962233",
"0.6889824",
"0.6842986",
"0.68395025",
"0.68395025",
"0.68395025",
"0.68264645",
"0.6775751",
"0.6772774",
"0.67698216",
"0.67658794",
"0.6764111",
"0.6722807",
"0.6679414",
"0.6668333",
"0.65882194",
"0.6569122",
"0.6550819",
"0.651726... | 0.78740597 | 0 |
Calculates distance between 2 coordinates using haversine formula | def haversine(lon1, lat1, lon2, lat2):
directionDict = {'North':[0,90],'East':[90,180],'South':[180,270],'West':[270,360]}
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(gps1, gps2):\n return haversine(gps1.lng, gps1.lat, gps2.lng, gps2.lat)",
"def calc_distance_haversine(coord1, coord2):\n lat1, lon1 = coord1\n lat2, lon2 = coord2\n # approximate radius of earth in km\n R = 6373.0\n\n lat1 = radians(lat1)\n lon1 = radians(lon1)\n lat2 = radi... | [
"0.8378517",
"0.81214994",
"0.8091685",
"0.7832897",
"0.78270817",
"0.7822563",
"0.7816787",
"0.7789298",
"0.7769136",
"0.7758472",
"0.77521557",
"0.77416694",
"0.77401596",
"0.7726485",
"0.7725695",
"0.77216035",
"0.7705671",
"0.7702377",
"0.7682817",
"0.76774013",
"0.766427... | 0.76960224 | 18 |
A variant of the linear learning rate schedule | def schedule_variant(epoch):
def _linear_annealing(epoch):
t = epoch / args.epochs
lr_ratio = 0.01
if t <= 0.5:
factor = 1.0
elif t <= 0.9:
factor = 1.0 - (1.0 - lr_ratio) * (t - 0.5) / 0.4
else:
factor = lr_ratio
return args.lr_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_schedule(epoch,lr):\r\n learning_rate = lr\r\n if epoch > 10:\r\n learning_rate *= 0.1\r\n if epoch > 20:\r\n learning_rate *= 0.1\r\n if epoch > 50:\r\n learning_rate *= 0.01\r\n\r\n # tf.summary.scalar('learning rate', data=learning_rate, step=epoch)\r\n return learning_rate",
"def learni... | [
"0.77933246",
"0.7463568",
"0.743309",
"0.742269",
"0.7411571",
"0.7410122",
"0.7399396",
"0.73932403",
"0.73774207",
"0.7370963",
"0.73501396",
"0.73501396",
"0.73482597",
"0.73482597",
"0.73482597",
"0.73482597",
"0.7342712",
"0.7336268",
"0.73338616",
"0.73021954",
"0.7282... | 0.6717915 | 49 |
Method that returns all comments of post ordered by date(ascending) | def get_all_comments_ascending(self):
try:
return self.comments.order_by('commented_date')
except(ValueError, IntegrityError, OperationalError):
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments(self):\n return self.get_queryset().filter(content_type__model='comment').order_by('-comments__createdAt')",
"def commentList(post):\n comments = Comment.objects.all().filter(post=post).order_by('-published')\n remote_comments = RemoteComment.objects.all().filter(post=post).order_by('pu... | [
"0.75819373",
"0.7529279",
"0.7259563",
"0.6936415",
"0.69288814",
"0.6881793",
"0.6785298",
"0.6731985",
"0.67015445",
"0.6519404",
"0.6426429",
"0.6373082",
"0.63627994",
"0.63614",
"0.6352466",
"0.63089436",
"0.63089436",
"0.62961787",
"0.62914735",
"0.62545377",
"0.622920... | 0.8264858 | 0 |
Add a point which adds or subtracts traffic | def add_junction(ccTremb):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addPoint(self, *args, **kwargs):\n ...",
"def addPoint(self, point):\n self.points.append(point)",
"def add(self, point):\n self.points.append(point)",
"def __iadd__(self, point):\n self.points.append(point)\n return self",
"def add_point(self, pt):\n self.poin... | [
"0.7178056",
"0.6981729",
"0.697757",
"0.6947909",
"0.6945716",
"0.68888795",
"0.68846154",
"0.6837304",
"0.67697453",
"0.67691517",
"0.67691517",
"0.67691517",
"0.67621046",
"0.6743948",
"0.6725008",
"0.6719686",
"0.6664964",
"0.6621888",
"0.6538063",
"0.65311104",
"0.652155... | 0.0 | -1 |
Return a list of available models. | def get_models():
from lmfit.models import lmfit_models
models = lmfit_models
if 'Expression' in models:
del models['Expression']
if 'Gaussian-2D' in models:
del models['Gaussian-2D']
filenames = set()
models_path = pkg_resources.resource_filename('nexpy.api.frills',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def availablemodels(self):\n return self.__models.keys()",
"def get_available_models():\n modelpath = os.path.join(os.path.dirname(__file__), \"train\", \"model\")\n models = sorted(item.name.replace(\".py\", \"\").replace(\"_\", \"-\")\n for item in os.scandir(modelpa... | [
"0.83207375",
"0.80826354",
"0.79793006",
"0.7913763",
"0.78320515",
"0.78320515",
"0.78320515",
"0.78320515",
"0.7767933",
"0.7588042",
"0.758471",
"0.75452733",
"0.754326",
"0.752727",
"0.74392354",
"0.7436941",
"0.74053097",
"0.73848546",
"0.7353479",
"0.7337276",
"0.72614... | 0.69892395 | 31 |
Initalize name and age attibutes. | def __init__(self, name, age):
self.name = name
self.age = age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, first_name, last_name, age):\n self.first_name = first_name\n self.last_name = last_name\n self.age = age",
"def __init__(self, first_name, last_name, age):\n self.first_name = first_name\n self.last_name = last_name\n self.age = age",
"def __init__(... | [
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.7472384",
"0.736729",
"0.7351724",
"0.7351724",
"0.7351724",
"0.7351724",
"0.72921795",
"0.7189177",
"0.7124933",
"0.711583",
"0.6997387",
"0.6881059",
"0.686831... | 0.75609356 | 2 |
Adds .rewards dictionary to ._cumulative_rewards dictionary. Typically called near the end of a step() method | def _accumulate_rewards(self) -> None:
for agent, reward in self.rewards.items():
self._cumulative_rewards[agent] += reward | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cumulative_rewards(rewards, # rewards at each step\r\n gamma=0.99 # discount for reward\r\n ):\r\n cumulative_rewards = []\r\n prev = 0\r\n\r\n for r in reversed(rewards):\r\n prev = r + gamma * prev\r\n cumulative_rewards.appe... | [
"0.66877925",
"0.65150195",
"0.63543874",
"0.6171038",
"0.6131765",
"0.59833705",
"0.59729856",
"0.59728116",
"0.5945876",
"0.5941239",
"0.5938777",
"0.5859438",
"0.5845564",
"0.5828542",
"0.58256334",
"0.5801388",
"0.57860106",
"0.5721941",
"0.5721941",
"0.57204807",
"0.5710... | 0.8241642 | 0 |
Returns observation, cumulative reward, terminated, truncated, info for the current agent (specified by self.agent_selection). | def last(
self, observe: bool = True
) -> tuple[ObsType | None, float, bool, bool, dict[AgentID, dict[str, Any]]]:
agent = self.agent_selection
assert agent
observation = self.observe(agent) if observe else None
return (
observation,
self._cumulative_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_observation(self , reward = False):\n\t\t# magnetic_ends ****\n\t\topen_magnetic_ends = rnadc.count_magnetic_ends(graph = self._state._graph)\n\t\t# sequence_length difference factor\n\t\tinstance_counter, seq_length = self._state.get_state_counters()\n\t\tseq_length_difference = abs(seq_length - self._sta... | [
"0.6066342",
"0.58572423",
"0.572674",
"0.5680924",
"0.55653965",
"0.55462927",
"0.54915404",
"0.5479996",
"0.5470984",
"0.5380226",
"0.5377741",
"0.5377066",
"0.5372383",
"0.5367619",
"0.53314126",
"0.531771",
"0.5287568",
"0.52366143",
"0.52277625",
"0.52272576",
"0.5227257... | 0.5366415 | 14 |
Moves the left Snatch3r track forward at maximum speed | def left_forward(self):
self.left_motor.run_forever(speed_sp=self.MAX_SPEED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_backward(self):\n self.left_motor.run_forever(speed_sp=-self.MAX_SPEED)",
"def forward_left(self, speed):\n self.pwm_backward.ChangeDutyCycle(0)\n self.pwm_forward.ChangeDutyCycle(speed) \n self.pwm_right.ChangeDutyCycle(0)\n self.pwm_left.ChangeDutyCycle(100)",
"de... | [
"0.68804145",
"0.6766968",
"0.66029763",
"0.65382004",
"0.6491949",
"0.64916617",
"0.6335264",
"0.6314397",
"0.61941",
"0.6185014",
"0.61789197",
"0.61776155",
"0.616607",
"0.61524516",
"0.6108518",
"0.6107015",
"0.60679215",
"0.60029584",
"0.60027933",
"0.5989831",
"0.598815... | 0.714059 | 0 |
Moves the left Snatch3r track backward at maximum speed | def left_backward(self):
self.left_motor.run_forever(speed_sp=-self.MAX_SPEED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_backward(self):\n self.right_motor.run_forever(speed_sp=-self.MAX_SPEED)",
"def backward(self, speed):\n self.controller.reverse(speed)",
"def backward_shimmey(self):\n for x in range(6):\n self.right(primary=-70, counter=-30)\n time.sleep(.5)\n s... | [
"0.6670325",
"0.6528774",
"0.650342",
"0.650342",
"0.63978446",
"0.6393472",
"0.63802224",
"0.6353847",
"0.628464",
"0.62747014",
"0.6223883",
"0.6183431",
"0.61284715",
"0.6123169",
"0.6106527",
"0.6077826",
"0.60769135",
"0.6069814",
"0.6033206",
"0.6030349",
"0.59552073",
... | 0.7142505 | 0 |
>>> queue = ResizingArrayQueue() >>> queue.enqueue('a') >>> queue.enqueue('b') >>> queue.enqueue('c') >>> queue ResizingArrayQueue(['a', 'b', 'c']) >>> queue.capacity 4 | def enqueue(self, i):
if len(self) == self.capacity:
self._resize(self.capacity*2)
if self.tail == self.capacity:
self.tail = 0
self.lst[self.tail] = i
self.tail += 1
self.n += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, size):\n self.queue = collections.deque(maxlen = size)",
"def __init__(self, size):\n self.queue = collections.deque(maxlen=size)",
"def enqueue(self,data): # total: O(n)\n # if pass capacity, double capacity and the array\n while self._size >= self._capacity: #O(... | [
"0.6993432",
"0.69741297",
"0.68684125",
"0.6865613",
"0.6690907",
"0.66519046",
"0.6591576",
"0.65801233",
"0.6565369",
"0.65564317",
"0.64656544",
"0.6449031",
"0.6421977",
"0.6414539",
"0.63977325",
"0.6349502",
"0.63473773",
"0.6325623",
"0.6325235",
"0.6290447",
"0.62844... | 0.6319796 | 19 |
Using the permutation stored in the GroupBy instance, group another array of values and return the location of the first minimum of each group's values. | def argmin(self, values):
return self.aggregate(values, "argmin") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argmin(self, values: pdarray) -> Tuple[groupable, pdarray]:\n k, v = self.aggregate(values, \"argmin\")\n return k, cast(pdarray, v)",
"def min(self, values: pdarray, skipna: bool = True) -> Tuple[groupable, pdarray]:\n if values.dtype == bool:\n raise TypeError(\"min is only ... | [
"0.69315547",
"0.6436416",
"0.63460773",
"0.61645544",
"0.61508465",
"0.61457413",
"0.60260195",
"0.5903984",
"0.5899858",
"0.5884481",
"0.5870008",
"0.58537614",
"0.5794234",
"0.57433397",
"0.5726778",
"0.5689788",
"0.5640447",
"0.56350976",
"0.562677",
"0.5610112",
"0.56016... | 0.6260668 | 3 |
Using the permutation stored in the GroupBy instance, group another array of values and return the number of unique values in each group. | def nunique(self, values):
return self.aggregate(values, "nunique") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution_2(arr):\n total = 0\n for group in arr:\n group_list = []\n for person in group:\n group_list = group_list + person\n group_table = Counter(''.join(group_list))\n for k, v in group_table.items():\n if v == len(group):\n total += 1\... | [
"0.6694003",
"0.6544423",
"0.6516038",
"0.6278004",
"0.6042778",
"0.5976222",
"0.5925271",
"0.5839887",
"0.57857645",
"0.5726247",
"0.571959",
"0.5712345",
"0.5705003",
"0.57005554",
"0.5654896",
"0.55948234",
"0.55775046",
"0.55225563",
"0.5428361",
"0.54021335",
"0.5364717"... | 0.6030383 | 5 |
Initialize the node, appending a new entry to aux_data in the process. | def __init__(self, input_node: WillumpGraphNode, input_name: str, left_input_type: WeldType, output_name: str, join_col_names: List[str],
right_dataframe, aux_data: List[Tuple[int, WeldType]]) -> None:
self.left_input_name = input_name
self._output_name = output_name
self._right... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data: str):\n self.root = Node(data)\n self.node_count = 1\n self.node_of_last_computed_hash = 0",
"def __init__(self, rpc, auxiliary):\n super(AuxiliaryModule, self).__init__(rpc, 'auxiliary', auxiliary)\n self._action = self._info.get('default_action', \"\"... | [
"0.58001876",
"0.5470469",
"0.5460675",
"0.540868",
"0.53352857",
"0.5288485",
"0.52832615",
"0.5265755",
"0.5261563",
"0.5260573",
"0.524959",
"0.5246685",
"0.5234178",
"0.522711",
"0.5222874",
"0.52164316",
"0.5214334",
"0.52069956",
"0.519198",
"0.5179701",
"0.51718295",
... | 0.0 | -1 |
With a suffix of "min" or "minutes", the interval is parsed in minutes. | def test_interval_to_seconds_with_minutes(self):
self.assert_interval_to_seconds(
0, "0min", "0mins", "0minute", "0minutes")
self.assert_interval_to_seconds(
60, "1min", "1mins", "1minute", "1minutes")
self.assert_interval_to_seconds(
3600, "60min", "60mins", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minutes(input=None):\n return get(input).minutes",
"def parse_interval(val):\n re_intv = re.compile(r\"(?P<count>\\d+)(?P<unit>\\w+)\")\n match = re_intv.match(val.strip())\n if not match:\n raise ValueError(\"invalid interval string '%s'\" % val)\n unit = match.group('unit')\n count... | [
"0.7037409",
"0.6139116",
"0.6095989",
"0.59477216",
"0.5934872",
"0.59174246",
"0.58973724",
"0.58434886",
"0.5838393",
"0.5781589",
"0.57582396",
"0.57582396",
"0.57582396",
"0.57582396",
"0.57443696",
"0.5738154",
"0.5738138",
"0.5733011",
"0.569452",
"0.56922257",
"0.5683... | 0.6742453 | 1 |
With a suffix of "h" or "hours", the interval is parsed in hours. | def test_interval_to_seconds_with_hours(self):
self.assert_interval_to_seconds(0, "0h", "0hour", "0hours")
self.assert_interval_to_seconds(3600, "1h", "1hour", "1hours")
self.assert_interval_to_seconds(24 * 3600, "24h", "24hour", "24hours")
self.assert_interval_to_seconds(
12... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hours(input=None):\n return get(input).hours",
"def interval_hours(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"interval_hours\")",
"def from_minutes_and_halves(s):\n s = s.strip()\n half = s.endswith(\"H\")\n s = s.strip(\"H \")\n \n return (int(s) * 60 if s e... | [
"0.67400813",
"0.65030235",
"0.62962854",
"0.6283059",
"0.6155723",
"0.6124772",
"0.59965205",
"0.59143645",
"0.58422655",
"0.5831927",
"0.57765394",
"0.57683414",
"0.5746319",
"0.5652727",
"0.5626688",
"0.5626274",
"0.5617149",
"0.55800486",
"0.55553263",
"0.5552738",
"0.554... | 0.69077224 | 0 |
With a suffix of "mon" or "months", the interval is parsed in months. | def test_interval_to_seconds_with_months(self):
self.assert_interval_to_seconds(0, "0mon", "0month", "0months")
self.assert_interval_to_seconds(2592000, "1mon", "1month", "1months")
self.assert_interval_to_seconds(
12 * 2592000, "12mon", "12month", "12months")
self.assert_int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_interval_months_arg(months_arg):\n months = int(months_arg)\n if months <= 0:\n raise ValueError('Interval value must be a positive number: %d' %\n months)\n return relativedelta.relativedelta(months=months)",
"def interval_months(self) -> pulumi.Input[int]:\n ... | [
"0.69794005",
"0.6895282",
"0.6895282",
"0.6126728",
"0.60785025",
"0.5940183",
"0.5924424",
"0.5883604",
"0.58820176",
"0.58488023",
"0.58415383",
"0.58355105",
"0.58215415",
"0.58067286",
"0.5777452",
"0.5748033",
"0.5748033",
"0.57467586",
"0.57263714",
"0.5710368",
"0.568... | 0.650883 | 3 |
Unix timestamps are accepted as absolute time specifications. | def test_parse_time_unix_timestamp(self):
self.assertEqual(
parse_time("1422748800", None), datetime(2015, 2, 1, 0, 0, 0))
self.assertEqual(parse_time("0", None), datetime(1970, 1, 1, 0, 0, 0))
# The following are treated as unix timestamps, not YYYYMMDD strings.
self.assertE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timestamp():\n natural = timestamp(\"December 15, 2015\")\n assert natural == {\n \"unix\": 1450137600,\n \"natural\": \"December 15, 2015\"\n }\n unix = timestamp(\"1450137600\")\n assert unix == {\n \"unix\": 1450137600,\n \"natural\": \"December 15, 2015\"\n ... | [
"0.6568363",
"0.64676094",
"0.63964117",
"0.62789583",
"0.6265217",
"0.62544745",
"0.6240911",
"0.622704",
"0.6160825",
"0.6132929",
"0.6123738",
"0.6114812",
"0.60862285",
"0.6079087",
"0.60577965",
"0.6041476",
"0.600395",
"0.5978107",
"0.5952521",
"0.5917838",
"0.59091675"... | 0.69407755 | 0 |
Run func every interval seconds. If func has not finished before interval, will run again immediately when the previous iteration finished. | async def _async_repeat(self, func):
while True:
start = time.monotonic()
await func()
timeout = (self.period/1000.) - (time.monotonic()-start)
if timeout > 0:
await asyncio.sleep(timeout) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __set_interval(self, func, sec):\n\n def func_wrapper():\n self.__set_interval(func, sec)\n func()\n\n t = threading.Timer(sec, func_wrapper)\n t.start()\n return t",
"def repeat_every(seconds, fn):\n def wrapper(scheduler):\n try:\n fn()... | [
"0.7132605",
"0.7132258",
"0.69771606",
"0.6975447",
"0.6652803",
"0.65566665",
"0.6453951",
"0.64293045",
"0.637259",
"0.63594073",
"0.6359165",
"0.6342055",
"0.62945026",
"0.6166782",
"0.61098635",
"0.60973805",
"0.60892016",
"0.6034639",
"0.5943972",
"0.5919979",
"0.590021... | 0.6998775 | 2 |
Add the hxladd filter to the end of the chain. | def add_add_filter(source, args, index):
tagspec = _parse_tagspec(args.get('add-tag%02d' % index))
header = args.get('add-header%02d' % index)
value = args.get('add-value%02d' % index, '')
before = (args.get('add-before%02d' % index) == 'on')
values = [(hxl.Column.parse(tagspec, header=header), valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_crds_filter(self, filter):\n if filter not in self.filters:\n self.filters = self.filters + [filter]",
"def hxladd_main(args, stdin=STDIN, stdout=sys.stdout, stderr=sys.stderr):\n\n parser = make_args('Add new columns with constant or computed values to a HXL dataset.')\n parse... | [
"0.5674146",
"0.5450161",
"0.54161954",
"0.53882647",
"0.5341923",
"0.52777165",
"0.5194737",
"0.50652635",
"0.50270283",
"0.49021298",
"0.48996133",
"0.4852402",
"0.48199126",
"0.47835308",
"0.47515863",
"0.4725746",
"0.46435115",
"0.46328098",
"0.4622889",
"0.45699045",
"0.... | 0.4847868 | 12 |
Filter previously recognized words from this window's recognized words this are the same words positionwise. | def new_words_only(base_words, window_words):
new_words = []
if base_words:
for wword in window_words:
dont_include = False
for bword in base_words:
if CharNetRunner._do_words_intersect(wword, bword):
dont_include = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filterPossibleWords(self): \r\n filledInSpaces = []\r\n for i in range(len(self.currentBoard)):\r\n if self.currentBoard[i] != '_':\r\n filledInSpaces.append( (i, self.currentBoard[i]) )\r\n \r\n self.wordList = list(filter(lambda word: self.viableWor... | [
"0.70234567",
"0.6673409",
"0.65990704",
"0.6575512",
"0.64956737",
"0.6322365",
"0.6290354",
"0.6218696",
"0.61996484",
"0.6176571",
"0.61601317",
"0.6129641",
"0.61224663",
"0.6096503",
"0.60807073",
"0.6073102",
"0.5955998",
"0.58935803",
"0.5877056",
"0.58638126",
"0.5843... | 0.6491436 | 5 |
Optionally restricts the returned purchases to a given user, by filtering against a `username` query parameter in the URL. | def get_queryset(self, *args, **kwargs):
queryset_list = ParkingForRent.objects.all()
query = self.request.GET.get("q")
if query:
queryset_list = queryset_list.OrderingFilter(
Q(db_area__icontains=query) | Q(status__icontains=query)
).distinct()
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n username = self.kwargs.get('username', None)\n filters = {}\n if username:\n filters['user__username'] = username\n return super(PhotosListView, self).get_queryset().filter(**filters)",
"def filter_queryset(self, request, queryset, view):\n ... | [
"0.59682834",
"0.59662503",
"0.59339905",
"0.59121907",
"0.59062797",
"0.56636876",
"0.5653978",
"0.5544974",
"0.5541318",
"0.55099636",
"0.5504582",
"0.5494414",
"0.5487761",
"0.5483002",
"0.5471986",
"0.5471543",
"0.5451524",
"0.54157865",
"0.54070425",
"0.53802735",
"0.537... | 0.0 | -1 |
This is the main page for the EBP application | def index(request):
if request.method == 'POST':
form = PatientRecordForm(request.POST)
if form.is_valid():
form.save()
status = simplejson.dumps({'status':'success'})
return HttpResponse(status, mimetype='application/json')
form = PatientRecordForm(auto_id='%s')
return render_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n return render_template(\"index.html\", title=\"Home\", heading=\"Dublin Bus\")",
"def main_page():\n return render_template(\"main_page.html\")",
"def main():\r\n st.sidebar.title(\"MỤC LỤC\")\r\n selection = st.sidebar.radio(\"Go to\", list(PAGES.keys()))\r\n\r\n page = PAGES[se... | [
"0.7146576",
"0.6992902",
"0.69471747",
"0.69064087",
"0.68774116",
"0.6837949",
"0.6729991",
"0.6710734",
"0.6679546",
"0.66456115",
"0.6631698",
"0.662635",
"0.662635",
"0.6622045",
"0.6620401",
"0.66095394",
"0.6584981",
"0.657668",
"0.65752214",
"0.6548664",
"0.65399516",... | 0.0 | -1 |
This view exports all patient records in the database to a csv file. | def export_patient_records(request, app, model):
restart_reasons = [r.reason_id for r in RestartReason.objects.order_by('reason_id')]
header_row = ['Patient ID', 'Vesicant/Irritant?', 'IV Attempts']
header_row += restart_reasons
response = HttpResponse(mimetype='text/csv')
response['Conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(request):\n\n if not request.user.is_authenticated():\n return HttpResponseRedirect('/login/?next=%s' % request.path)\n\n filename = 'export-inscrits%s.csv' % date.today().strftime(\"%y-%m-%d\")\n\n person_list = Person.objects.all()\n\n table = ExportPersonTable(person_list)\n tab... | [
"0.7210922",
"0.700289",
"0.6851801",
"0.6830999",
"0.6803495",
"0.67603964",
"0.67317826",
"0.6704199",
"0.6671088",
"0.6668821",
"0.66361064",
"0.6625432",
"0.6604797",
"0.65415525",
"0.64768344",
"0.6475871",
"0.6445369",
"0.6443853",
"0.6398936",
"0.63887995",
"0.6348947"... | 0.8058624 | 0 |
Generate random string of length=n. | def generate_random_string(self, n, uppercase=False, punctuations=False):
prefix = random.choice(string.ascii_lowercase)
mix = string.ascii_lowercase + string.digits
if uppercase:
mix += string.ascii_uppercase
if punctuations:
mix += string.punctuation
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_rand_str(n):\n return \"\".join(random.choice(string.ascii_letters) for _ in range(n))",
"def randstr(n):\n alphabets = string.digits + string.letters\n return ''.join(random.choice(alphabets) for i in xrange(n))",
"def generate_random_string(N):\n return ''.join(random.choice(string.as... | [
"0.86483145",
"0.8581468",
"0.8542844",
"0.8257327",
"0.8098701",
"0.807988",
"0.79065007",
"0.7890792",
"0.785203",
"0.7787804",
"0.77100617",
"0.7689637",
"0.7676379",
"0.7668683",
"0.76608086",
"0.7650799",
"0.7645829",
"0.76343864",
"0.7628813",
"0.761638",
"0.75866395",
... | 0.75803596 | 22 |
Generate list filled in with random strings. | def generate_random_list_or_string(self):
if self.iteration_deep < self.max_iteration_deep:
self.iteration_deep += 1
value = self.generate_random_list(5)
self.iteration_deep -= 1
else:
value = self.generate_random_value(str)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_string_list(self, n):\n template_str = 'string_'\n string_list = [template_str + str(i) for i in range(n)]\n return string_list",
"def generate_strings(nr_strings, alphabet, length):\n strings = []\n for _ in range(0, nr_strings):\n strings.append(rng_string(alphabe... | [
"0.7400639",
"0.73694855",
"0.7185587",
"0.7178502",
"0.69999796",
"0.69939125",
"0.6979388",
"0.69400686",
"0.69090295",
"0.69053996",
"0.6869956",
"0.6869956",
"0.6869956",
"0.68513846",
"0.6832759",
"0.6790268",
"0.67359257",
"0.6718414",
"0.6687385",
"0.66872764",
"0.6669... | 0.6558872 | 27 |
Generate random payload with possibly restricted data types. | def generate_random_payload(self, restrict_types=None):
if restrict_types:
types = restrict_types
else:
types = (str, int, float, list, dict, bool)
selected_type = random.choice(types)
return self.generate_random_value(selected_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_payload(length=MAX_PAYLOAD_LENGTH):\n payload = \"\"\n for i in range(length):\n payload += random.choice(CHARACTERS)\n return payload",
"def some_payload(size=32, var=0):\n if var:\n size = random.randint(size-var, size+var)\n return ''.join(random.choice(string.ascii... | [
"0.69498396",
"0.6536909",
"0.63344264",
"0.6207788",
"0.6170156",
"0.6010075",
"0.58474576",
"0.58460206",
"0.58064884",
"0.5804888",
"0.568156",
"0.56779945",
"0.55997795",
"0.5552533",
"0.5523869",
"0.5519157",
"0.55029804",
"0.5494486",
"0.5483897",
"0.5471045",
"0.546747... | 0.8258906 | 0 |
Sets the gateway_id of this ApiDownlinkTXInfo. | def gateway_id(self, gateway_id):
self._gateway_id = gateway_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setGateway(self, gateway):\n # type: (str)->None\n\n self._validator.validate_one(\n 'gateway', VALID_OPTS['gateway'], gateway)\n self._ifAttributes['gateway'] = gateway",
"def setGateway(self):\n\t\tself.gatewayip = self.settings.getKeyValue('gatewayip')\n\t\tself.socket.send... | [
"0.6919861",
"0.60536194",
"0.604395",
"0.60017335",
"0.59344053",
"0.5926787",
"0.55722654",
"0.5332749",
"0.5325832",
"0.5280625",
"0.5279205",
"0.52737546",
"0.521756",
"0.5206157",
"0.51509136",
"0.5148105",
"0.5134872",
"0.5122857",
"0.50948477",
"0.50948477",
"0.5079517... | 0.7931258 | 0 |
Sets the gps_epoch_timing_info of this ApiDownlinkTXInfo. | def gps_epoch_timing_info(self, gps_epoch_timing_info):
self._gps_epoch_timing_info = gps_epoch_timing_info | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setepoch(self, value):\n return _coordsys.coordsys_setepoch(self, value)",
"def set_epoch(self, epoch):\n self.epoch = epoch",
"def set_epoch(self, epoch):\r\n pass",
"def upgrade_time_epoch(self, upgrade_time_epoch):\n\n self._upgrade_time_epoch = upgrade_time_epoch",
"def ... | [
"0.5732914",
"0.57127017",
"0.55906236",
"0.5399973",
"0.53581995",
"0.5354772",
"0.5219372",
"0.50478864",
"0.49914047",
"0.49295107",
"0.48875806",
"0.48127365",
"0.4804546",
"0.4775048",
"0.47504318",
"0.4739642",
"0.47354516",
"0.47085053",
"0.469108",
"0.46769345",
"0.46... | 0.8469009 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ApiDownlinkTXInfo):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Piecewise approximate sigmoid as in | def approx_sigmoid(x, n=3):
if n == 5:
cuts = [-5, -2.5, 2.5, 5]
le = [0] + [x <= cut for cut in cuts] + [1]
select = [le[i + 1] - le[i] for i in range(5)]
outputs = [cfix(10 ** -4),
0.02776 * x + 0.145,
0.17 * x + 0.5,
0.02776... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 - (power(e,-x)))",
"def sigmoid(x):\r\n return 1 / (1 + np.exp(-x))",
"def sigmoid(x):\n\treturn 1 / (1 + m.exp(-x))",
"def sigmoid(z):\n return 1 / (1 + e ** -z)",
... | [
"0.8297419",
"0.8297419",
"0.8279786",
"0.82694346",
"0.8248122",
"0.82446915",
"0.82367516",
"0.82317275",
"0.82155514",
"0.82155514",
"0.82155514",
"0.82155514",
"0.82155514",
"0.82155514",
"0.8200153",
"0.81978446",
"0.81973517",
"0.817581",
"0.817581",
"0.816984",
"0.8169... | 0.75954014 | 95 |
ReLU function (maximum of input and zero). | def relu(x):
return (0 < x).if_else(x, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ReLU(self, x):\n self.x = x\n output = np.maximum(0, x)\n return output",
"def ReLU(self, x):\r\n self.x = x\r\n return np.maximum(x, 0)",
"def activation_ReLU(self):\n self.value = max(0, self.value)",
"def relu(X):\n return np.maximum(0, X)",
"def relu(x):\r\n retu... | [
"0.87718457",
"0.85021996",
"0.8275824",
"0.82347953",
"0.82326967",
"0.80922556",
"0.8020506",
"0.78752035",
"0.7717848",
"0.77176964",
"0.7681261",
"0.7585562",
"0.7579859",
"0.7560288",
"0.7509278",
"0.7448967",
"0.74142826",
"0.7400012",
"0.72916",
"0.7225491",
"0.7213747... | 0.6501869 | 54 |
Compute index of maximum element. | def argmax(x):
def op(a, b):
comp = (a[1] > b[1])
return comp.if_else(a[0], b[0]), comp.if_else(a[1], b[1])
return tree_reduce(op, enumerate(x))[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_index(a):\n return a.argmax()",
"def get_max_index(a):\n return a.argmax()",
"def get_max_index(a):\n return a.argmax()",
"def imax(self):\n return self.elem.index(max(self))",
"def max(self):\n max = 0\n a = self.array_form\n for i in xrange(len(a)):\n ... | [
"0.8322118",
"0.8322118",
"0.8322118",
"0.8297905",
"0.78759944",
"0.7831312",
"0.7605612",
"0.7584218",
"0.7570792",
"0.7559726",
"0.7512239",
"0.72421354",
"0.7216627",
"0.72009104",
"0.7186902",
"0.7091226",
"0.706059",
"0.7038191",
"0.703262",
"0.703001",
"0.7014685",
"... | 0.6547924 | 74 |
Construct linear graph from list of layers. | def layers(self, layers):
self._layers = layers
prev = None
for layer in layers:
if not layer.inputs and prev is not None:
layer.inputs = [prev]
prev = layer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_linear_model(x, N, outputs=1):\n with C.layers.default_options(initial_state = 0.1):\n return linear_layer(x, outputs)",
"def __init__(self, weights=[], alphas=[]):\n self._layers = [Layer(w, a) for w, a in zip(weights, alphas)]",
"def create_network(layers):\r\n return NeuronNet... | [
"0.60474527",
"0.60157764",
"0.59577614",
"0.5922712",
"0.5888689",
"0.5882378",
"0.57670313",
"0.57468146",
"0.5709293",
"0.5690243",
"0.5664038",
"0.5629808",
"0.56187624",
"0.5610542",
"0.55311537",
"0.54778516",
"0.5452981",
"0.5437914",
"0.5407891",
"0.5407834",
"0.53705... | 0.49630457 | 95 |
Takes in an action and does it in the environment Returns next state, reward, and if the env is done | def step(self, action):
if action[1] > 0:
throttle = action[1]
brake = 0.0
reverse = False
elif action[1] < 0:
throttle = -action[1]
brake = 0.0
reverse = True
else:
throttle = 0.0
reverse = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\n res = self.reward_table.get(self.curr_state, action)\n\n self.curr_state = res['result']\n\n return res",
"def step(self, action):\n obs = self.gym.get_observations()\n all_actions = self.gym.act(obs)\n all_actions.insert(self.gym.training_agent, action)\n ... | [
"0.79443616",
"0.7808671",
"0.7780876",
"0.77469635",
"0.77188915",
"0.7704215",
"0.7677617",
"0.76512796",
"0.7646551",
"0.76038456",
"0.7579655",
"0.7555507",
"0.75514054",
"0.7544992",
"0.751271",
"0.7510762",
"0.7497757",
"0.7493163",
"0.74923223",
"0.74861497",
"0.741180... | 0.0 | -1 |
Calculate reward for step (assuming no collision) | def _calculate_reward(self):
reward = 0.0 # base reward
if self.calc_lane_invasion:
waypoint = self.world.get_map().get_waypoint(self.vehicle.get_location(), project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
change_al... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_reward(self):\n if self.status():\n return self.current_step/self.ep_length # the reward is proportional to the duration \n else:\n return 0",
"def _compute_reward(self): \n reward = -1\n return reward",
"def _reward(self):\n\n return 1-self.step_count/ sel... | [
"0.81952924",
"0.7955531",
"0.78529656",
"0.77384895",
"0.77119255",
"0.77065194",
"0.7576939",
"0.7566296",
"0.75598776",
"0.755324",
"0.75351113",
"0.7491073",
"0.74761295",
"0.74704194",
"0.7437812",
"0.7437812",
"0.7437812",
"0.7437812",
"0.7437812",
"0.7437812",
"0.74135... | 0.7511983 | 11 |
List of Transitions of batches to tensors batch states, actions, rewards. | def _batch2torch(self, batch, batch_sz=None):
batch = Transition(*zip(*batch))
state_batch = torch.cat(batch.state, 0).float()
# ONLY NON Terminal next states
next_state_batch = [x for x in batch.state_ if x is not None]
next_state_batch = torch.cat(next_state_batch, 0).float()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transitions(self):\n transitions = []\n for row in self.states:\n t_row = []\n for column in self.states:\n t_row.append([row, column])\n transitions.append(t_row)\n return sorted(transitions)",
"def get_step_actions(self):\n ret... | [
"0.60373837",
"0.6035876",
"0.59591216",
"0.5832653",
"0.5773047",
"0.5750845",
"0.56785667",
"0.56773865",
"0.56744826",
"0.5582856",
"0.5561903",
"0.54386777",
"0.536652",
"0.535158",
"0.53441596",
"0.53282326",
"0.53147984",
"0.52974415",
"0.528768",
"0.5279493",
"0.527387... | 0.6422988 | 0 |
Return Tru if this has access else False. | def has_character_access(self, character: EveCharacter) -> Optional[bool]:
owner_corporation = self.structure.owner.corporation
if character.corporation_id == owner_corporation.corporation_id:
return True
if (
owner_corporation.alliance
and owner_corporation.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_ta(self, user, allow_superusers=True):\n return (user.is_superuser and allow_superusers) or len(self.tas.filter(id=user.id)) > 0",
"def test_func(self):\n member_to_view = self.get_object()\n is_self = self.request.user.rfid == member_to_view.rfid\n view_others = self.request.... | [
"0.70299596",
"0.62975913",
"0.62940633",
"0.6240272",
"0.61777246",
"0.61737764",
"0.6110906",
"0.6104301",
"0.6022093",
"0.5994377",
"0.5994087",
"0.5974726",
"0.5968357",
"0.5957992",
"0.5931469",
"0.59304935",
"0.5925713",
"0.58847827",
"0.58722425",
"0.58722425",
"0.5871... | 0.0 | -1 |
Returns the version of an installed pip package. | def get_version_from_pip(package_name):
try:
package_info = subprocess.check_output(['pip', 'show', package_name])
except subprocess.CalledProcessError:
print('ERROR: Package %s has not been installed with pip.' % package_name,
file=sys.stderr)
exit(1)
for line in package_info.split('\n'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version(self):\r\n return self.pip_requirement.installed_version",
"def version_from_pip():\n\n try:\n import pkg_resources # pylint: disable=import-outside-toplevel\n version_string = pkg_resources.get_distribution(\"imagesplit\").version\n if _check_pip_version(version_strin... | [
"0.8061723",
"0.7590231",
"0.75444794",
"0.7524287",
"0.7412558",
"0.7151705",
"0.70828795",
"0.70327353",
"0.702366",
"0.70179385",
"0.69494975",
"0.69481903",
"0.6897285",
"0.68888116",
"0.68674886",
"0.6855834",
"0.6849615",
"0.6849615",
"0.6849615",
"0.6849615",
"0.684961... | 0.84659505 | 0 |
Returns the version of the Cloud SDK that is installed. | def get_cloud_sdk_version():
gcloud_info = subprocess.check_output(['gcloud', 'version'])
for line in gcloud_info.split('\n'):
m = re.match(r'Google Cloud SDK (.+)', line)
if m:
return m.group(1)
print('ERROR: Unable to parse "gcloud version" output: %s' % gcloud_info,
file=sys.stderr)
exi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sdk_version() -> str:\n return definitions.get_sdk_version()",
"def version(self) -> str:\n return utils._auxiliary.get_current_sdk_version()",
"def version(self):\n\n if self.running() is True:\n return APIConsumer.get(\"/version\").content\n else:\n r... | [
"0.7747168",
"0.7563308",
"0.6964963",
"0.6947981",
"0.69341844",
"0.6909471",
"0.6896979",
"0.6867608",
"0.6844083",
"0.6833969",
"0.6831793",
"0.6807727",
"0.67498183",
"0.67498183",
"0.67498183",
"0.6741479",
"0.67219037",
"0.6704942",
"0.66849583",
"0.66758305",
"0.666183... | 0.81744576 | 0 |
Resistance of the TES shunt resistors. Gets or sets the resistance of the TES shunt resistors. Assumes the same shunt resistance for every channel. Units are Ohms. Specified in the pysmurf configuration file as `R_sh`. Returns float Resistance of the TES shunt resistors in Ohms. See Also | def R_sh(self):
return self._R_sh | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_setResistance(self):\n self.read(\":RES?\")",
"def calc_spread_rate(self, FGPathway_object, location, weather_today, supr_dec):\n\n base_sr = weather_today[\"FWI\"] * FGPathway_object.get_surface_fuel(location)\n\n #modify by cell size\n #FWI is in meters/minute\n\n #To... | [
"0.6318244",
"0.57304883",
"0.57296634",
"0.56824136",
"0.5564344",
"0.55062854",
"0.5492521",
"0.5440512",
"0.5427438",
"0.5385388",
"0.5375415",
"0.5342348",
"0.53245705",
"0.53000706",
"0.52947384",
"0.52810884",
"0.52737665",
"0.5268083",
"0.5267711",
"0.5254399",
"0.5243... | 0.0 | -1 |
Current ratio between low to highcurrent modes. Gets or sets the ratio of currents sourced by the cryostat card for the same applied TES bias voltage (from the RTM, at the input to the cryostat card) in high versus lowcurrent cryostat card TES bias relay modes. In typical applications, this ratio is >1, since otherwise... | def high_low_current_ratio(self):
return self._high_low_current_ratio | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_ratio(self):\n return self.current_assets / self.current_liabilities",
"def get_current_rate(self):\n pass",
"def current(self) -> float:\n return self._electric_current",
"def get_measured_current(self):\n status = self.get_status_response()\n current = status[... | [
"0.6195197",
"0.5773408",
"0.5766061",
"0.5761815",
"0.56209284",
"0.5580696",
"0.55429494",
"0.5540704",
"0.5535772",
"0.5533446",
"0.5510715",
"0.5496082",
"0.54872197",
"0.54376376",
"0.5406497",
"0.5401106",
"0.5356859",
"0.5277265",
"0.5263593",
"0.5250575",
"0.5244719",... | 0.7305861 | 0 |
Set the object's owner, based on the incoming request. | def pre_save(self, obj):
obj.owner = self.request.user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner(self, owner):\n self._owner = owner",
"def owner(self, owner):\n self._owner = owner",
"def owner(self, owner):\n self._owner = owner",
"def owner(self, owner):\n self._owner = owner",
"def set_owner(self, owner):\n self.__owner = owner",
"def owner(self, owne... | [
"0.77522546",
"0.77522546",
"0.77522546",
"0.77522546",
"0.77259594",
"0.76241726",
"0.7585329",
"0.7585329",
"0.7585329",
"0.7585329",
"0.74665624",
"0.7376495",
"0.7239318",
"0.70856524",
"0.70856524",
"0.70856524",
"0.693037",
"0.6917968",
"0.68637943",
"0.6718803",
"0.669... | 0.76030654 | 6 |
Checks whether a provided number of days has passed since the user has registered. | def is_joined_days_passed(self, days):
return timezone.now() >= self.user.date_joined + timedelta(days=days) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enough_days(self, cur, username, start_date, end_date):\n cur.execute('SELECT days_free FROM users WHERE username = ?', (username,))\n days_free = cur.fetchone()[0]\n days_between = abs(self.days_difference(start_date, end_date))\n return days_free >= days_between",
"def Daysleftv... | [
"0.7525601",
"0.7008091",
"0.62901556",
"0.62691236",
"0.60377187",
"0.60054314",
"0.6001344",
"0.5909698",
"0.5859116",
"0.58524185",
"0.5815721",
"0.5808451",
"0.5802401",
"0.5789253",
"0.57835424",
"0.57718194",
"0.5751567",
"0.57273835",
"0.572618",
"0.57025343",
"0.56655... | 0.733879 | 1 |
Plot the classification graph This function plots the classification graph showing the ground truth labels and the predicted ones. It also points out oo the missclassifications, and displays several classification metrics to show the model's performance. | def plot_classification(X,
y,
y_true,
y_pred,
metrics=("acc", "sen", "spe"),
fig_size=(12, 5),
fig_show=True,
save_as="figure.pdf",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(self):\n plt.imshow(self.cm, interpolation='nearest', cmap=self.cmap)\n plt.title(self.title)\n plt.colorbar()\n tick_marks = np.arange(len(self.classes))\n plt.xticks(tick_marks, self.classes, rotation=45)\n plt.yticks(tick_marks, self.classes)\n \n ... | [
"0.7271683",
"0.6842304",
"0.6806655",
"0.67334706",
"0.66736966",
"0.6663137",
"0.66581595",
"0.6592424",
"0.6562138",
"0.6552475",
"0.6524335",
"0.6505397",
"0.6451862",
"0.64473957",
"0.6429136",
"0.6376398",
"0.6337301",
"0.6322782",
"0.63144886",
"0.62976277",
"0.6272034... | 0.6984989 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.