query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
calculates highest update ID of all the updates we receive from getUpdates. | def get_last_update_id(updates):
update_ids = []
for update in updates["result"]:
update_ids.append(int(update["update_id"]))
return max(update_ids) | [
"def _calc_autoid(self):\n maxid = 0\n for i in self.items:\n maxid = max(maxid, i['id'])\n self._autoid = maxid + 1",
"def _find_newest_update_by_location(updates: Iterable) -> Iterable:\n d = defaultdict(list)\n for update in updates:\n d[update[\"location\"]].append... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
for data in projection axe.projection find and mask the overlaps (more 1/2 the axe.projection range) X, Y either the coordinates in axe.projection or longitudes latitudes Z the data operation one of 'pcorlor', 'pcolormesh', 'countour', 'countourf' if source_projection is a geodetic CRS data is in geodetic coordinates a... | def z_masked_overlap(axe, X, Y, Z, source_projection=None):
if not hasattr(axe, 'projection'):
return Z
if not isinstance(axe.projection, ccrs.Projection):
return Z
if len(X.shape) != 2 or len(Y.shape) != 2:
return Z
if (source_projection is not None and
isinstance(... | [
"def XPLMMapProject(projection,\n latitude, longitude,\n outX, outY):\n pass",
"def projection_data(self, filter_name=None):\n #PCA Data does not have projection_mask, just return all\n return self;",
"def xy_projections(image,center,d):\n from numpy impor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ingest a packet and put the flow object into the context of the flow that the packet belongs to. | def ingest_packet(self, pkt, pkt_receive_timestamp):
#*** Packet length on the wire:
self.packet_length = len(pkt)
#*** Read into dpkt:
eth = dpkt.ethernet.Ethernet(pkt)
eth_src = _mac_addr(eth.src)
eth_dst = _mac_addr(eth.dst)
eth_type = eth.type
#*** We ... | [
"def ingest_packet(self, dpid, in_port, packet, timestamp):\n #*** Instantiate an instance of Packet class:\n self.packet = self.Packet()\n pkt = self.packet\n\n #*** DPID of the switch that sent the Packet-In message:\n pkt.dpid = dpid\n #*** Port packet was received on:\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the size of the largest packet in the flow (in either direction) | def max_packet_size(self):
return max(self.fcip_doc['packet_lengths']) | [
"def max_packet_size(self):\n max_packet_size = 0\n db_data = {'flow_hash': self.packet.flow_hash,\n 'timestamp': {'$gte': datetime.datetime.now() - \\\n self.flow_time_limit}}\n packet_cursor = self.packet_ins.find(db_data).sort('time... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the size of the smallest packet in the flow (in either direction) | def min_packet_size(self):
return min(self.fcip_doc['packet_lengths']) | [
"def get_size(pkt: Packet) -> int:\n return len(pkt)",
"def min_pkt_size(self):\n return 64",
"def minimum_size(self):\n # Size in arcsec\n size = self.seeing.minimum_size()\n try:\n # Try using `intrinsic` as an object\n size = max(self.intrinsic.minimum_siz... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the size of the average interpacket time interval in the flow (assessed per direction in flow). . | def avg_interpacket_interval(self):
avg_c2s = 0
avg_s2c = 0
count_c2s = 0
count_s2c = 0
prev_c2s_idx = 0
prev_s2c_idx = 0
for idx, direction in enumerate(self.fcip_doc['packet_directions']):
if direction == 'c2s':
count_c2s += 1
... | [
"def __cal_avg_init_wnd_size(self):\n \n wnd_size_sum = 0\n num = 0\n for pcap_packet in self.pcap_container.pcap_packets:\n if (pcap_packet.top_layer >= 3 and pcap_packet.tcp.flag_syn == 1):\n num += 1\n wnd_size_sum += pcap_packet.tcp.window_siz... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the size of the largest interpacket time interval in the flow (assessed per direction in flow). . | def max_interpacket_interval(self):
max_c2s = 0
max_s2c = 0
count_c2s = 0
count_s2c = 0
prev_c2s_idx = 0
prev_s2c_idx = 0
for idx, direction in enumerate(self.fcip_doc['packet_directions']):
if direction == 'c2s':
count_c2s += 1
... | [
"def max_packet_size(self):\n max_packet_size = 0\n db_data = {'flow_hash': self.packet.flow_hash,\n 'timestamp': {'$gte': datetime.datetime.now() - \\\n self.flow_time_limit}}\n packet_cursor = self.packet_ins.find(db_data).sort('time... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the size of the smallest interpacket time interval in the flow (assessed per direction in flow) . | def min_interpacket_interval(self):
min_c2s = 0
min_s2c = 0
count_c2s = 0
count_s2c = 0
prev_c2s_idx = 0
prev_s2c_idx = 0
for idx, direction in enumerate(self.fcip_doc['packet_directions']):
if direction == 'c2s':
count_c2s += 1
... | [
"def min_packet_size(self):\n return min(self.fcip_doc['packet_lengths'])",
"def get_size(pkt: Packet) -> int:\n return len(pkt)",
"def get_stepsize(traj, min_points=200):\n n = traj.n_frames\n if n <= min_points:\n return 1\n else:\n return n // min_points",
"def minContigLen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the suppressed attribute in the flow database object to the current packet count so that future suppressions of the same flow can be backed off to prevent overwhelming the controller | def set_suppress_flow(self):
self.suppressed = self.packet_count
self.fcip.update_one({'hash': self.fcip_hash},
{'$set': {'suppressed': self.suppressed},}) | [
"def record_suppression(self, dpid, suppress_type, result, standdown=0):\n #*** Instantiate a new instance of FlowMod class:\n flow_mod_record = self.FlowMod(self.flow_mods, self.packet.flow_hash,\n dpid, suppress_type, standdown)\n if not standdown:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP FIN flag set? | def tcp_fin(self):
return self.tcp_flags & dpkt.tcp.TH_FIN != 0 | [
"def tcp_fin(self):\n return self.tp_flags & dpkt.tcp.TH_FIN != 0",
"def is_eof_packet(self):\n return self.data[0] == 0xfe",
"def tcp_ack(self):\n return self.tcp_flags & dpkt.tcp.TH_ACK != 0",
"def EndOfPacket(self) -> bool:",
"def tcp_ack(self):\n return self.tp_flags ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP SYN flag set? | def tcp_syn(self):
return self.tcp_flags & dpkt.tcp.TH_SYN != 0 | [
"def tcp_syn(self):\n return self.tp_flags & dpkt.tcp.TH_SYN != 0",
"def _is_tcp_syn(tcp_flags):\n if tcp_flags == 2:\n return 1\n else:\n return 0",
"def _is_tcp_synack(tcp_flags):\n if tcp_flags == 0x12:\n return 1\n else:\n return 0",
"def tcp_psh(self):\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP RST flag set? | def tcp_rst(self):
return self.tcp_flags & dpkt.tcp.TH_RST != 0 | [
"def tcp_rst(self):\n return self.tp_flags & dpkt.tcp.TH_RST != 0",
"def tcp_ack(self):\n return self.tcp_flags & dpkt.tcp.TH_ACK != 0",
"def tcp_ack(self):\n return self.tp_flags & dpkt.tcp.TH_ACK != 0",
"def tcp_urg(self):\n return self.tcp_flags & dpkt.tcp.TH_URG != 0",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP PSH flag set? | def tcp_psh(self):
return self.tcp_flags & dpkt.tcp.TH_PUSH != 0 | [
"def tcp_psh(self):\n return self.tp_flags & dpkt.tcp.TH_PUSH != 0",
"def _is_tcp_synack(tcp_flags):\n if tcp_flags == 0x12:\n return 1\n else:\n return 0",
"def has_packet(self) -> bool:\r\n\r\n if self._packet_queue:\r\n return True\r\n\r\n return False"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP ACK flag set? | def tcp_ack(self):
return self.tcp_flags & dpkt.tcp.TH_ACK != 0 | [
"def tcp_ack(self):\n return self.tp_flags & dpkt.tcp.TH_ACK != 0",
"def ack(self):\n return (self.status == self.STATUS_ACK)",
"def is_dhcp_ack_packet(self):\n return self._get_dhcp_message_type() == 5",
"def is_ack(self) -> bool:\n return self.code == COAP_CODE_ACK",
"def i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP URG flag set? | def tcp_urg(self):
return self.tcp_flags & dpkt.tcp.TH_URG != 0 | [
"def tcp_urg(self):\n return self.tp_flags & dpkt.tcp.TH_URG != 0",
"def tcp_ack(self):\n return self.tcp_flags & dpkt.tcp.TH_ACK != 0",
"def tcp_ack(self):\n return self.tp_flags & dpkt.tcp.TH_ACK != 0",
"def _is_tcp_synack(tcp_flags):\n if tcp_flags == 0x12:\n return 1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP ECE flag set? | def tcp_ece(self):
return self.tcp_flags & dpkt.tcp.TH_ECE != 0 | [
"def tcp_ece(self):\n return self.tp_flags & dpkt.tcp.TH_ECE != 0",
"def tcp_fin(self):\n return self.tp_flags & dpkt.tcp.TH_FIN != 0",
"def tcp_ack(self):\n return self.tp_flags & dpkt.tcp.TH_ACK != 0",
"def tcp_ack(self):\n return self.tcp_flags & dpkt.tcp.TH_ACK != 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does the current packet have the TCP CWR flag set? | def tcp_cwr(self):
return self.tcp_flags & dpkt.tcp.TH_CWR != 0 | [
"def tcp_cwr(self):\n return self.tp_flags & dpkt.tcp.TH_CWR != 0",
"def tcp_urg(self):\n return self.tp_flags & dpkt.tcp.TH_URG != 0",
"def tcp_urg(self):\n return self.tcp_flags & dpkt.tcp.TH_URG != 0",
"def tcp_ack(self):\n return self.tcp_flags & dpkt.tcp.TH_ACK != 0",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Passed a TCP flags object (hex) and return 1 if it contains a TCP SYN and no other flags | def _is_tcp_syn(tcp_flags):
if tcp_flags == 2:
return 1
else:
return 0 | [
"def _is_tcp_synack(tcp_flags):\n if tcp_flags == 0x12:\n return 1\n else:\n return 0",
"def tcp_flags(flag):\n flagreturn = ''\n if flag == dpkt.tcp.TH_FIN:\n flagreturn = \"FIN\"\n elif flag == dpkt.tcp.TH_SYN:\n flagreturn = \"SYN\"\n elif f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Passed a TCP flags object (hex) and return 1 if it contains TCP SYN + ACK flags and no other flags | def _is_tcp_synack(tcp_flags):
if tcp_flags == 0x12:
return 1
else:
return 0 | [
"def _is_tcp_syn(tcp_flags):\n if tcp_flags == 2:\n return 1\n else:\n return 0",
"def tcp_flags(flag):\n flagreturn = ''\n if flag == dpkt.tcp.TH_FIN:\n flagreturn = \"FIN\"\n elif flag == dpkt.tcp.TH_SYN:\n flagreturn = \"SYN\"\n elif flag ==... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a predictable hash for the 5tuple which is the same not matter which direction the traffic is travelling | def _hash_5tuple(ip_A, ip_B, tp_src, tp_dst, proto):
if ip_A > ip_B:
direction = 1
elif ip_B > ip_A:
direction = 2
elif tp_src > tp_dst:
direction = 1
elif tp_dst > tp_src:
direction = 2
else:
direction = 1
hash_5t = hashlib.md5()
if direction == 1:
... | [
"def hash_function(input_tuple):\n return hash(input_tuple)",
"def hash_flow(flow_5_tuple):\n ip_A = flow_5_tuple[0]\n ip_B = flow_5_tuple[1]\n tp_src = flow_5_tuple[2]\n tp_dst = flow_5_tuple[3]\n proto = flow_5_tuple[4]\n if proto == 6:\n #*** Is a TCP flow:\n if ip_A > ip_B:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert a MAC address to a readable/printable string | def _mac_addr(address):
return ':'.join('%02x' % ord(b) for b in address) | [
"def mac_ntoa(mac):\n return '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(map(ord, list(mac)))",
"def get_mac_string():\n mac_int = getnode()\n mac_str = ':'.join((\"%012x\" % mac_int)[i:i + 2] for i in range(0, 12, 2))\n return mac_str",
"def _format_mac(mac_address):\n return format_mac(mac_address).... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Action partial update test | def test_partial_update(self):
action = ActionFactory.create(id=22)
data = {
'name': 'Ação para Melhorar',
'institution': 'Vamos Ajudar',
}
self.assertNotEqual(action.name, data['name'])
self.assertNotEqual(action.institution, data['institution'])
... | [
"def test_cases_partial_update(self):\n pass",
"def test_client_partial_update(self):\n pass",
"def test_partial_update_website(self):\n pass",
"def test_partial_update_web_app(self):\n pass",
"def test_partial_update_list(self):\n pass",
"def test_partial_update_bill(se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializing the board and current player. | def __init__(self):
self.board = [
BS, BS, BS, BS,
BS, BS, BS,
BS, BS, BS, BS,
EM, EM, EM,
WS, WS, WS, WS,
WS, WS, WS,
WS, WS, WS, WS
]
self.curr_player = WHITE_PLAYER | [
"def setup(self):\n self.set_players()\n self.board = Board()",
"def initBoard(self):\n pass",
"def _init_main_boards(self):\n for y in range(1, 5):\n # black's board\n for x in range(5, 9):\n self.board[y][x][4] = 0\n\n # neutral board... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculating all the possible single moves. | def calc_single_moves(self):
single_soldier_moves = [(i, j) for (i, j) in SOLDIER_SINGLE_MOVES[self.curr_player]
if self.board[i][:1] == SOLDIER_COLOR[self.curr_player]
and self.board[j] == EM]
single_officer_moves = [(i, j) for (i, j) in O... | [
"def get_possible_moves(self):\n\t\tcapture_moves = self.get_possible_capture_moves()\n\t\tif capture_moves: return capture_moves\n\t\telse: return self.get_possible_positional_moves()",
"def gen_moves(self):\n res = []\n for i in range(BOARD_SIZE):\n for j in range(BOARD_SIZE):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculating all the possible capture moves, but only the first step. | def calc_capture_moves(self):
capture_soldier_moves = [(i, j, k) for (i, j, k) in SOLDIER_CAPTURE_MOVES[self.curr_player]
if self.board[i][:1] == SOLDIER_COLOR[self.curr_player]
and self.board[j][:1] in OPPONENT_COLORS[self.curr_player]
... | [
"def get_possible_capture_moves(self):\n\t\treturn reduce((lambda moves, piece: moves + piece.get_possible_capture_moves()), self.searcher.get_pieces_in_play(), [])",
"def get_possible_moves(self):\n\t\tcapture_moves = self.get_possible_capture_moves()\n\t\tif capture_moves: return capture_moves\n\t\telse: return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a capture move, return all long capture moves following this one. We do recursive DFS. We also don't replicate the board, but use the same self.board to avoid replication time. | def find_following_moves(self, capture_move, move_privilege):
# Temporarily changing the board, simulating the move and checking if there are more to follow.
floating_piece = self.board[capture_move[1]]
self.board[capture_move[1]] = EM
self.board[capture_move[2]] = self.board[capture_mov... | [
"def dfsl(board, depth_limit):\n # base cases\n if all(not piece.alive for piece in board.black_pieces):\n # goal! start building a path\n return []\n\n elif depth_limit == 0:\n # no path found to goal with this depth limit\n return None\n\n # recursive case: try all possible... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests static method is_heap if it can correctly verify if a list of elements preserves the heap property. | def test_static_is_heap(self):
good = [4, 4, 8, 9, 4, 12, 9, 11, 13]
bad = [1,2,3,114,5,6,7,8,9,10]
self.assertTrue(Heap.is_heap(good), 'should hold the heap property')
self.assertFalse(Heap.is_heap(bad), 'should not hold the heap property') | [
"def a_heap():\n # 产生一个100个元素的列表,列表元素的值范围在1000内\n li = [random.randrange(1000) for _ in range(100)]\n assert heapq.nlargest(1, li)[0] == max(li)\n assert heapq.nsmallest(1, li)[0] == min(li)\n\n # heapy的排序底层是调用了heapify方法,使一个序列变为堆排序的结果\n # 此时可以通过heappop方法取出最小值\n heapq.heapify(li)\n assert min... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the removal of a key from the middle of the heap. | def test_remove(self):
data = [4, 4, 8, 9, 4, 12, 9, 11, 13]
h = Heap(data)
h.remove(2)
self.assertTrue(Heap.is_heap(data), 'should preserve heap property')
self.assertNotIn(8, h.data, 'the value corresponding to the index was removed') | [
"def delete(self,key):\r\n\r\n break_out = 0 #For loop breaking and adt node location purposes\r\n not_fst = 0\r\n remove = self._make_hash(key)\r\n if self.speedups[remove] == key:\r\n self.speedups[remove] = None\r\n\r\n runner = self.headptr\r\n prev = None\r\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if extracting min and adding a new value at the same time works. | def test_extract_min_and_insert(self):
data = [4, 5, 8, 9, 6, 12, 9, 11, 13]
h = Heap(data)
min_value = h.extract_min_and_insert(2)
self.assertEqual(min_value, 4, 'should return the min value')
expected = [2, 5, 8, 9, 6, 12, 9, 11, 13]
self.assertEqual(h.data, expected, ... | [
"def min(x):\n pass",
"def _min_in_bounds(self, min):\n if min <= self.valmin:\n if not self.closedmin:\n return self.val[0]\n min = self.valmin\n\n if min > self.val[1]:\n min = self.val[1]\n return self._stepped_value(min)",
"def byValue(mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the loop body graph with a subgraph (for body or condition functions) | def update_body_graph(body_graph: Graph, subgraph_proto: dict,
body_parameter_names: list, body_results: list):
# create a map from a node name in original model to a name in a loop body graph assuming
# that names in the original model are unique
# initially, the map contains names fo... | [
"def add_loops(self):\n self._add_edges((x, x) for x in self.vertices)",
"def update_graph(self):\r\n for element in self.neighbours:\r\n element.neighbours.append(self)\r\n print('Graph update successful')",
"def inner_loops(node):\n\n return FindInnerLoops().visit(node)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check to see if we should apply thresholding to preprocess the image | def preprocess(img):
#if "thresh" in args["preprocess"]:
image = cv2.threshold(img, 0, 255,
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
"""
make a check to see if median blurring should be done to remove
noise
"""
#if "blur" in args["preprocess"]:
#image = cv2.medianBlur(gray, 3)
return image | [
"def global_threshold(img, threshold_method):\n pass",
"def _applyPreprocessing(self, image):\n if self.params['preprocessing']['detectCircle'] == 'true':\n image = self.extractCircle(image)\n\n if self.params['preprocessing']['edgeDetection']['enabled'] == 'true':\n grey = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
various right embeding of video | def test_embed_ok(self):
self.go200('minus_upload')
self.formfile('minus_upload', 'file', AUDIO_FILE)
self.fv('minus_upload', 'id_embed_video', YOUTUBE_URL)
self.submit200()
self.notfind("Невірний")
self.show()
self.find("youtube_video")
self.find("<objec... | [
"def processVideo():\n pass",
"def test_video_embed(self):\n with patched_client() as jwclient:\n # No matter how videos are searched, return two with ID: 34\n jwclient.videos.list.return_value = self.LIST_RESPONSE_WITH_MEDIA\n\n # Try to embed a video\n r = s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
plus should be attached to minus.user not to moderator | def test_moderator_uploads_plusrecord(self):
self.go200('minus_plus_upload_user',[self.user.id])
self.formfile('minus_plus_upload', 'file', AUDIO_FILE)
self.submit200()
self.logout('auth_logout')
self.login('u', 'p', url='auth_login', formid='id_login')
self.go200('minus_... | [
"def on_plus(self):",
"def plus_minus(self, plus_minus):\n\n self._plus_minus = plus_minus",
"def isUMinus(self):\n return _libsbml.ASTNode_isUMinus(self)",
"def test_user_can_add_inactive(self):\n self.assertTrue(self.asset.user_can_add(self.user1))\n self.user1.is_active = False ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for peers_get | def test_peers_get(self):
pass | [
"def test_get_peers(self):\n pass",
"def test_peers_peerid_get(self):\n pass",
"def test_list_peers(self):\n pass",
"def test_players_account_id_peers_get(self):\n pass",
"def test_get_peer_details(self):\n pass",
"def test_peers_post(self):\n pass",
"def test_m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for peers_peerid_delete | def test_peers_peerid_delete(self):
pass | [
"def test_peers_peerid_get(self):\n pass",
"def test_peers_peerid_post(self):\n pass",
"def test_bgp_peer_remove(self, m_client):\n # Set up arguments\n address = '1.2.3.4'\n\n # Call method under test\n bgp_peer_remove(address, 4)\n\n # Assert\n m_client.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for peers_peerid_get | def test_peers_peerid_get(self):
pass | [
"def test_players_account_id_peers_get(self):\n pass",
"def test_get_peer_details(self):\n pass",
"def test_peers_get(self):\n pass",
"def test_peers_peerid_post(self):\n pass",
"def test_get_peers(self):\n pass",
"def test_peers_peerid_delete(self):\n pass",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for peers_peerid_post | def test_peers_peerid_post(self):
pass | [
"def test_peers_post(self):\n pass",
"def test_peers_peerid_get(self):\n pass",
"def test_peers_peerid_delete(self):\n pass",
"def test_post_party(self):\n pass",
"def test_peers_get(self):\n pass",
"def test_get_peer_details(self):\n pass",
"def test_duplicate_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for peers_post | def test_peers_post(self):
pass | [
"def test_peers_peerid_post(self):\n pass",
"def test_post_party(self):\n pass",
"def test_post_chain(self):\n pass",
"def test_post_users_post(self):\n pass",
"def test_peers_get(self):\n pass",
"def test_meme_post(self):\n pass",
"def test_post_user_post(self)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for volumes_get | def test_volumes_get(self):
pass | [
"def test_aws_service_api_volume_get(self):\n pass",
"def test_aws_service_api_volumes_get(self):\n pass",
"def test_openstack_rest_volumes_get(self):\n pass",
"def test_get_volume(self):\n volume = Volume(self.client, 1)\n self.assertEqual(volume._populated, False)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for volumes_post | def test_volumes_post(self):
pass | [
"def test_aws_service_api_volumes_post(self):\n pass",
"def test_volumes_get(self):\n pass",
"def test_volumes_volname_start_post(self):\n pass",
"def test_volumes_volname_stop_post(self):\n pass",
"def test_v1vm_addvolume(self):\n pass",
"def test_01_create_volume(self)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for volumes_volname_start_post | def test_volumes_volname_start_post(self):
pass | [
"def test_volumes_volname_stop_post(self):\n pass",
"def test_volumes_post(self):\n pass",
"def test_aws_service_api_volumes_post(self):\n pass",
"def test_v1vm_addvolume(self):\n pass",
"def test_v1vmi_addvolume(self):\n pass",
"def test_pvcvolume_attach(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for volumes_volname_stop_post | def test_volumes_volname_stop_post(self):
pass | [
"def test_volumes_volname_start_post(self):\n pass",
"def test_volumes_post(self):\n pass",
"def test_v1_stop(self):\n pass",
"def test_v1vm_removevolume(self):\n pass",
"def test_v1vmi_removevolume(self):\n pass",
"def test_v1alpha3vm_removevolume(self):\n pass",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all valid pairs of tape in rect form given a list of OpenCV contours. Using the angles and center coordinates associated with each of the contours, possible pairs of tape are identified. However, there is no verification done to ensure that contours are valid pieces of tape, as the function assumes that they are va... | def get_pair_rects(contours):
rect_pairs = []
for index, cnt in enumerate(contours):
# Rotated rect - ( center (x,y), (width, height), angle of rotation )
rect = cv2.minAreaRect(cnt)
center_x, center_y = rect[0]
rect_angle = -round(rect[2], 2)
if rect_angle > 45.0:
... | [
"def bound_shapes(contours):\r\n\r\n contours_poly = [None]*len(contours)\r\n boundRect = [None]*len(contours)\r\n centers = [None]*len(contours)\r\n radius = [None]*len(contours)\r\n for i, c in enumerate(contours):\r\n contours_poly[i] = cv2.approxPolyDP(c, 3, True)\r\n boundRect[i] =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all of the pair centers given a list of pairs of rotated rectangles. The function iterates through a list of pairs of rotated rectangles, storing the center of each pair in a list to be returned by the function, in which the indexes between a pair and its center match up. If the rect_pairs list is empty, an empty ... | def find_pair_centers(rect_pairs):
centers = []
for rect1, rect2 in rect_pairs:
center = midpoint(rect1[0], rect2[0])
centers.append(center)
return centers | [
"def get_pair_rects(contours):\n\n rect_pairs = []\n for index, cnt in enumerate(contours):\n # Rotated rect - ( center (x,y), (width, height), angle of rotation )\n rect = cv2.minAreaRect(cnt)\n center_x, center_y = rect[0]\n rect_angle = -round(rect[2], 2)\n\n if rect_angl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the center of the rectangle pair closest to the center of the frame. Iterates through the rotated rectangle pairs, finding the rect pair that is closest to the center of the frame and then returning the center point of that rect pair or None if the rect_pairs list is empty. This function, however, does not detect ... | def closest_center(rect_pairs):
centers = find_pair_centers(rect_pairs)
min_dist = min_center = None
for center in centers:
dist = distance(center, FRAME_CENTER)
if min_dist is None or dist < min_dist:
min_dist = dist
min_center = center
return min_center | [
"def find_pair_centers(rect_pairs):\n\n centers = []\n for rect1, rect2 in rect_pairs:\n center = midpoint(rect1[0], rect2[0])\n centers.append(center)\n\n return centers",
"def get_center(rect):\n return rect.width / 2, rect.height / 2",
"def get_rect_center(rect):\n x, y, w, h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the angle between cX and the center of the frame. | def horizontal_angle(cX):
return atan(((FRAME_CENTER[0] + .5) - cX) / FOCAL_LENGTH) | [
"def central_angle(x: float, y:float) -> float:\n\n\t# Hack\n\tif (y == 0) & (x < 0):\n\t\treturn -90\n\n\tif (y == 0) & (x > 0):\n\t\treturn 90\n\n\tif (y == 0) & (x == 0):\n\t\treturn 0\n\n\t# Vertices\n\tvc_a = (x, y) # shot loation\n\tvc_b = (0,0) # origin\n\tvc_c = (0, y) # reference point (0, y)\n\n\tside_a =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the midpoint between point1 and point2. | def midpoint(point1, point2):
x, y = (int((point1[0] + point2[0]) / 2), int((point1[1] + point2[1]) / 2))
return (x, y) | [
"def midpoint(p1, p2):\n mx = (p1.x + p2.x) / 2\n my = (p1.y + p2.y) / 2\n return Point(mx, my)",
"def mid_point(a: Point, b: Point) -> Point:\n return Point((a.x + b.x) / 2, (a.y + b.y) / 2)",
"def getMidpoint(p1, p2):\r\n return(((p1[0] + p2[0]) / 2), ((p1[1] + p2[1]) / 2))",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the tape using the VideoCapture object in this script and display it. Fetches a frame from the CAP object in this script and finds the horizontal angle between the center of the frame and the tape pair closest to the center of the frame. It prints the horizontal angle and draws various information on the frame bef... | def find_tape():
_, frame = CAP.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(hsv, color_lower, color_upper)
_, contours, _ = cv2.findContours(mask, cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)
# Find all valid pair rects, and reutrn if non... | [
"def display_homographied_plan(h, source):\n # TODO\n\n cap=cv2.VideoCapture(source)\n # Reading our first frame\n ret1,frame1= cap.read()\n cv2.imshow('window',frame1)\n\n frame2 = cv2.perspectiveTransform(frame1, h)\n cv2.imshow('homography',frame2)\n\n\n while True:\n if cv2.waitKe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes 3 arguments and creates an incremental list of characters. | def creatCharList(start, end, increment):
start = int(start)
end = int(end)
increment = int(increment)
characters = []
i = start
for i in range(start, end, increment):
print(f"Loop: {i}.")
characters.append(chr(i))
print("Characters:\n{}".format(characters)... | [
"def gen_chars(length, character):\n return ''.join([character for i in range(length)])",
"def auto_generate_one_letter_list(self, start_char):\n character_list = []\n first_char = start_char\n counter = 1\n while counter <= 26:\n character_list.append(first_char)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds the divisors of x Assumes that x is a positive integer Returns a tuple containing the divisors of x | def finddiv(x):
div = (1, x)
for i in range(2, x//2+1):
if x%i==0:
div+=(i,)
return div | [
"def divisors(x):\n x = abs(x)\n result = []\n upper_bound = int(math.sqrt(x))\n for i in range(1, upper_bound + 1):\n if x % i == 0:\n if x / i == i:\n result.append(i)\n else:\n result.append(i)\n result.append(x//i)\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for MesoscopePreprocess.get_default_tau method. | def test_get_default_tau(self):
subject_detail = {'genotype': [{'allele': 'Cdh23', 'zygosity': 1},
{'allele': 'Ai95-G6f', 'zygosity': 1},
{'allele': 'Camk2a-tTa', 'zygosity': 1}]}
with mock.patch.object(self.task.one.alyx, 're... | [
"def testDefaultEta(self):\n t = Task()\n self.assertEqual(self.now_utctime, t.eta)",
"def test_change_default_dt_static(self):\n ct.set_defaults('control', default_dt=0)\n assert ct.tf(1, 1).dt is None\n assert ct.ss([], [], [], 1).dt is None",
"def test_infer_no_history(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for MesoscopeFOV.get_provenance method. | def test_get_provenance(self):
filename = 'mpciMeanImage.mlapdv_estimate.npy'
provenance = MesoscopeFOV.get_provenance(filename)
self.assertEqual('ESTIMATE', provenance.name)
filename = 'mpciROIs.brainLocation_ccf_2017.npy'
provenance = MesoscopeFOV.get_provenance(filename)
... | [
"def provenance(self):\n return self._provenance",
"def get_provenance(self, element):\n return element.get(\"Provenance\")",
"def test_provenance_extras():\n target = DummyTarget()\n provenance = target.provenance()\n assert \"qcsubmit\" in provenance\n assert \"openforcefield\" in pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for find_triangle function. | def test_find_triangle(self):
points = np.array([[2.435, -3.37], [2.435, -1.82], [2.635, -2.], [2.535, -1.7]])
connectivity_list = np.array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]], dtype=np.intp)
point = np.array([2.6, -1.9])
self.assertEqual(1, find_triangle(point, points, connecti... | [
"def test_find_triangle(self):\n more_factors_than = [1, 4, 5, 10, 15]\n test_hopeful_output = [3, 28, 28, 120, 120]\n test_output = []\n\n for input in more_factors_than:\n test_output.append(find_triangle(input))\n self.assertEqual(test_output, test_hopeful_output)",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for surface_normal function. | def test_surface_normal(self):
vertices = np.array([[0, 1, 0], [0, 0, 0], [1, 0, 0]])
expected = np.array([0, 0, 1])
np.testing.assert_almost_equal(surface_normal(vertices), expected)
# Test against multiple triangles
vertices = np.r_[vertices[np.newaxis, :, :], [[[0, 0, 0], [0,... | [
"def test_normal_always_up(self):\n z_of_normals = []\n for i in range(100):\n neighborhood, pc = create_point_cloud_in_plane_and_neighborhood()\n z_of_normals += list(EigenValueVectorizeFeatureExtractor().extract(pc, neighborhood, None, None, None)[5])\n np.testing.assert... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for _nearest_neighbour_1d function. | def test_nearest_neighbour_1d(self):
x = np.array([2., 1., 4., 5., 3.])
x_new = np.array([-3, 0, 1.2, 3, 3, 2.5, 4.7, 6])
val, ind = _nearest_neighbour_1d(x, x_new)
np.testing.assert_array_equal(val, [1., 1., 1., 3., 3., 2., 5., 5.])
np.testing.assert_array_equal(ind, [1, 1, 1, 4... | [
"def test_nearest_neighbour_pix(self):\n targets = [Target(0, 1127.0000, 796.0000, 13320, 111, 120, 828903, 1)]\n pnr = nearest_neighbour_pix(targets, 1128.0, 795.0, 0.0)\n self.assertEqual(pnr, -999)\n\n pnr = nearest_neighbour_pix(targets, 1128.0, 795.0, -1.0)\n self.assertEqual... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test MesoscopeFOV.register_fov method. Note this doesn't actually hit Alyx. Also this doesn't test stack creation. | def test_register_fov(self):
task = MesoscopeFOV(self.session_path, device_collection='raw_imaging_data', one=self.one)
mlapdv = {'topLeft': [2317.2, -1599.8, -535.5], 'topRight': [2862.7, -1625.2, -748.7],
'bottomLeft': [2317.3, -2181.4, -466.3], 'bottomRight': [2862.7, -2206.9, -679.... | [
"def test_invalid_fov(self):\n try:\n dummy_camera = Camera(\n None,\n None,\n None,\n \"no valid fov\",\n [\"still not\"])\n\n self.assertTrue(True)\n\n except Exception:\n self.assertTrue(Fals... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Draws the optimal route/path AFTER the algorithm has found it | def draw_best_route(final_route):
shape('turtle')
fillcolor('purple')
pencolor('purple')
pensize(4)
speed(1)
# Finds the start position of the node in the graphical grid
start_pos_x = (final_route[0].x) * 30
start_pos_y = (final_route[0].y - 1) * -30
penup()
# Sets the start posi... | [
"def create_path(self): # weights, path_data, show_path=True):\n\n # control variables\n max_distance_to_pf = np.linalg.norm(np.subtract(\n self.pf, np.sum([self.p0, self.d2*self.l2/2], axis=0)))\n current_position_index = [0, int(len(self.lines_list)/2)] # X, Y\n final_posi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Part of the A algorithm. Sets the parent of the node and calculates the g, h and ffunction | def attach_and_eval(node, parent, goal):
node.set_parent(parent)
node.g = parent.g + node.get_arc_cost()
node.heuristic(goal)
node.f = node.g + node.h | [
"def zig1(self, A):\n B = A.parent\n if node is parent.left:\n C, y, z = A.left, A.right, B.right\n\n A.left = C\n if C is not None:\n C.parent = A\n A.right, B.parent = B, A\n B.left = y\n if y is not None:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a Trainer object. training_sampler Sampler that samples training dataset. validation_sampler Sampler that samples validation dataset. Can be None. executor Graph executor to run the network. optimizer The optimizer to use for training. network_output The node name of the network prediction (value or classificat... | def __init__(self,
training_sampler: Sampler,
validation_sampler: Optional[Sampler],
executor: GraphExecutor,
optimizer: Optimizer,
network_output: Optional[str] = None):
self.train_set = training_sampler
self.test_set ... | [
"def train(self, trainer, training_set, save_classifier=..., **kwargs):\n ...",
"def trainNetwork(self):\n global nd, nt\n \n if (nd.trainingData is None):\n sys.stderr.write(\" ERROR: Must load training data!\")\n return\n \n nt = network_train... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs train and test set alternately for a given number of epochs. epochs Number of epochs to run the loop for. events A list of events to use in training/testing. Instances of RunnerEvent invoke the runner events, instances of OptimizerEvent and SamplerEvent are also invoked in the optimizer and sampler objects. collec... | def run_loop(self, epochs,
events: List[TrainingEvent] = None,
collect_all_times: bool = False) -> TrainingStatistics:
# Create statistics object
stats = TrainingStatistics(self.train_set.batch_size,
(0 if self.test_set is None else
... | [
"def loop(self, epochs, train_loader, val_loader, test_loader):\n\n self.all_epoch = epochs\n self._resume()\n\n for ep in range(self.cur_epoch, epochs + 1):\n self.cur_epoch = ep\n\n # conduct training, validation and test\n self.train_loss = self.train(train_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute and return summary statistics from data. | def summarize(self, data):
return self.summary(data).flatten() | [
"def _summary_stats(data):\n \n stats = {'min':[],'max':[], 'mean':[]}\n \n for scan in range(len(data)):\n stats['min'].append(\n (scan, min(data[scan][1]))\n )\n stats['max'].append(\n (scan, max(data[scan][... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a DirectiveError suitable for being thrown as an exception. Call "raise self.directive_error(level, message)" from within a directive implementation to return one single system message at level `level`, which automatically gets the directive block and the line number added. Preferably use the `debug`, `info`, `w... | def directive_error(self, level, message):
return DirectiveError(level, message) | [
"def error(self, msg):\n if self.current_line and self.current_file:\n msg = '{}\\nError in {} line {}'.format(\n msg, self.current_file, self.current_line)\n return self.DirectiveError(msg)",
"def get_libvirtError(self):\n\n return libvirt.libvirtError",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Append self.options['name'] to node['names'] if it exists. Also normalize the name string and register it as explicit target. | def add_name(self, node):
if 'name' in self.options:
name = nodes.fully_normalize_name(self.options.pop('name'))
if 'name' in node:
del(node['name'])
node['names'].append(name)
self.state.document.note_explicit_target(node, node) | [
"def add(self, name):\n\n # no need to add first_name while adding full_name\n name_list = name.strip().split()[1:]\n name_list.append(name)\n for item in set(name_list):\n node = self.root\n # check for every char in word, i.e. check whether is it in trie\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define & return a directive class generated from `directive_fn`. `directive_fn` uses the oldstyle, functional interface. | def convert_directive_function(directive_fn):
class FunctionalDirective(Directive):
option_spec = getattr(directive_fn, 'options', None)
has_content = getattr(directive_fn, 'content', False)
_argument_spec = getattr(directive_fn, 'arguments', (0, 0, False))
required_arguments, opti... | [
"def directive(func):\n func.cfg_is_directive = True\n return func",
"def create_directive_from_renderer(renderer_cls):\n\n class _RenderingDirective(SphinxDirective):\n required_arguments = 1 # path to openapi spec\n final_argument_whitespace = True # path may conta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Filter recipes by user's available time to cook | def filter_by_time(df, user):
time = user.time_to_cook.replace('cooking_time_less_than_', '')
return df.loc[df.minutes <= int(time)] | [
"def filter_by_date(items, start_time, end_time=None):\n start_time = parser.parse(start_time + \"UTC\").timestamp()\n if end_time:\n end_time = parser.parse(end_time + \"UTC\").timestamp()\n else:\n end_time = time.time()\n\n filtered_items = []\n for item in items:\n if 'time' ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get list of unique tags in dataset (this is slow) | def get_unique_tags(df):
tags = []
for index, row in df.iterrows():
tags = list(set(tags + ast.literal_eval(row.tags)))
pdb.set_trace() | [
"def get_unique_tag_elements(tags: Iterable[str]) -> List[str]:\n tags_split = [b.split(\"-\") for b in tags]\n tags_split_flat = chain.from_iterable(tags_split)\n return list(set(tags_split_flat))",
"def dataset_tags(connection):\n assert connection\n query = \"\"\"select * from tags()\"\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
goes through all the reservation records that are due today and sends and email. An email should be sent by invoking a task to a worker pool | def notify(self):
Reservation = self.db_con.table_data['reservations']
Restaurant = self.db_con.table_data['restaurants']
data = self.db_con.session.query(Reservation, Restaurant).\
filter(Reservation.restaurant_id == Restaurant._id).\
filter(Reservation.date == datetime.... | [
"def recs():\n click.echo(\"Emailing recommendations to destination...\")\n dio_dir: DioDir = DioDir()\n sched: ScheduleABC = DefaultSchedule()\n today: datetime.date = datetime.datetime.now().date()\n res: Optional[List[Person]] = get_recs(dio_dir, sched, today)\n next_day: datetime.date = sched.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Process text using the same text processing procedure as was used in the DTM/TFIDF models, and recreate the length column with the cleaned text strings. This results in a more accurate length metric. | def process_length_in_place(flora_data_frame, tokenized_stop_words):
before_process_length = flora_data_frame.text.apply(len)
# Applying the same text processing used in the DTM/TFIDF models
flora_data_frame.text = process_text_tokenize_detokenize(flora_data_frame.text, tokenized_stop_words)
# Remove ... | [
"def TextCalcWidth(Text) -> int:\n pass",
"def make_sentence_lengths(self, text):\n print(\"The whole original string is:\\n\",self.text)\n print(\"\")\n \n pw = \"$\"\n LoW = self.text.split()\n count = 0\n zin = []\n\n total_num_words_text = len(LoW)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Request the status of a message with the provided id and return a response dictionary. Returns a dictionary that contains a 'delivery' key with the status value string or contains 'errorCode' and 'message' on error. | def check_status(self, message_id):
values = {'token': self._token, 'reference': message_id}
return self._request(self.CHECK_STATUS_URL, values) | [
"def get_status(message_id):\n pass",
"def get_status(id):\n task = run_flask_request.AsyncResult(id)\n if task.state == states.PENDING:\n abort(404)\n\n if task.state == states.RECEIVED or task.state == states.STARTED:\n return '', 202, {'Location': url_for('tasks.get_status', id=id)}\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a frame as a byte string of TIFF image data (or None). The byte string can be displayed with image(None, data=Camera.frame()). | def frame(self):
try:
AppHelper.runConsoleEventLoop(installInterrupt=True)
return str(self._delegate.frame.representations()[0].TIFFRepresentation().bytes())
except:
return None | [
"def frame_to_png(frame):\n val, image = cv2.imencode('.png', frame)\n return ''.join(struct.pack('B', byte[0]) for byte in image)",
"def convert_frame(self, frame):\n return (b'--frame\\r\\nContent-Type: image/jpeg\\r\\n\\r\\n' + frame + b'\\r\\n\\r\\n')",
"def get_frame(self):\n success, i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decorator which checks the user is a prof before executing a view Redirect to the index page if not | def login_prof(func):
@wraps(func, assigned=available_attrs(func))
def wrapper(request, *args, **kwargs):
try:
request.user.prof
except ObjectDoesNotExist:
return redirect('gradapp:dashboard_student')
res = func(request, *args, **kwargs)
return res
ret... | [
"def medical_pro_only(view):\n def as_view(request, *args, **kwargs):\n if request.user.is_authenticated:\n if request.profile_type != 'medical_pro':\n return redirect(reverse('users:detail',\n kwargs={'username': request.user.username}))\n return view(r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decorator which checks the user is a student before executing a view Redirect to the index page if not | def login_student(func):
@wraps(func, assigned=available_attrs(func))
def wrapper(request, *args, **kwargs):
try:
request.user.student
except ObjectDoesNotExist:
return redirect('gradapp:list_assignmentypes_running')
res = func(request, *args, **kwargs)
re... | [
"def validate_student(func):\n\n @functools.wraps(func)\n def f(*args, **kwds):\n if \"isTeacher\" not in flask.session:\n return flask.redirect(\"/\")\n if flask.session[\"isTeacher\"] == 1:\n return flask.redirect(\"/teachers/\")\n return func(*args, **kwds)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluate the assignment (pk=assignment_pk) and makes your evaluation a superevaluation. Assignment seen as eval__ | def supereval_assignment(request, assignment_pk, i):
assignment = Assignment.objects.get(id=assignment_pk)
evalassignment = Evalassignment.objects.filter(assignment=assignment,
is_supereval=True).first()
redirect_url = ('/detail_assignmentype/%s/#assignment... | [
"def eval_evalassignment(request, pk, pts):\n student = request.user.student\n evalassignment = Evalassignment.objects.\\\n filter(pk=pk, assignment__student=student).first()\n if evalassignment:\n evalassignment.grade_evaluation = pts\n evalassignment.save()\n redirect_item = '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluate the assignment evaluation (Evalassignment(pk=pk)). evalassignment.grade_evaluation = pts (1, 0, +1) | def eval_evalassignment(request, pk, pts):
student = request.user.student
evalassignment = Evalassignment.objects.\
filter(pk=pk, assignment__student=student).first()
if evalassignment:
evalassignment.grade_evaluation = pts
evalassignment.save()
redirect_item = '#assignment%s... | [
"def evaluate(self):\n args = {\"name\": self.name }\n args = urlencode(args, \"utf-8\")\n page = urlopen('http://137.194.211.71:5000/' +\n 'evaluate?' + args)\n print(\"Grade :=>> \" + page.read().decode('ascii').strip())",
"def evaluation(self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an assignmentype or modify it (with new student list). | def create_assignmentype(request, assignmentype_id=None):
prof = request.user.prof
context = {}
if assignmentype_id:
assignmentype = Assignmentype.objects.get(id=assignmentype_id)
message = 'Reset your assignment. You can upload a new student list, '\
'but be aware that it will r... | [
"def create_assignmentype_students(request):\n existing_students = request.session.get('existing_students', False)\n new_students = request.session.get('new_students', False)\n assignmentype_pk = request.session.get('assignmentype_pk', False)\n if assignmentype_pk:\n tasks.create_assignment(assig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert a question for an assignmentype (pk=pk). The user enters in a form a question to be created (cd=1) or a question to be deleted (cd=1) | def insert_question_assignmentype(request, pk, cd):
prof = request.user.prof
assignmentype = Assignmentype.objects.filter(id=pk, prof=prof).first()
cd = int(cd)
if cd == 1:
classForm = AddQuestionForm
info = 'Add'
elif cd == -1:
classForm = RemoveQuestionForm
info = '... | [
"def insert_question(self, id):\n cursor = self.conn.cursor()\n cursor.execute(f\"insert into {self.site} values (?)\", (id, ))\n self.conn.commit()\n cursor.close()",
"def create_question(self, question_form):\n return # osid.assessment.Question",
"def save_question(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Modify assignmentype fields, except student list. | def modify_assignmentype(request, pk):
prof = request.user.prof
assignmentype = Assignmentype.objects.filter(id=pk, prof=prof).first()
if assignmentype:
if request.method == 'POST':
form = LightAssignmentypeForm(request.POST, instance=assignmentype)
if form.is_valid():
... | [
"def update_or_set_grade(student, assignment, cur):\n #TODO\n pass",
"def assessment_types(self, assessment_types: List[str]):\n\n self._assessment_types = assessment_types",
"def update_assignment(self,assign):\r\n if assign.assign_id not in self.__assignments:\r\n print(\"This assig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete assignmentype with id=pk and redirect to list of running assignmentype if type_list=='1', and to list of archived assignmentype if type_list=='0' | def delete_assignmentype(request, pk, type_list):
prof = request.user.prof
assignmentype = Assignmentype.objects.filter(id=pk, prof=prof).first()
if assignmentype:
assignmentype.delete()
if type_list == '1':
return redirect('gradapp:list_assignmentypes_running')
elif type... | [
"def delete_actividad(request, pk):\n try:\n actividad = Actividades.objects.get(pk=pk)\n except:\n return HttpResponseRedirect('/us/tipo/')\n tipo_us = actividad.tipoUS\n actividad.delete()\n\n return HttpResponseRedirect('/us/tipo/' + str(tipo_us.id))",
"def remove_data(request, dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When creating an assignment, shows students that will be associated to (existing students and new students). If validated, new students are created and new+existing students are associated to the assignment. | def validate_assignmentype_students(request):
existing_students = request.session.get('existing_students', False)
new_students = request.session.get('new_students', False)
assignmentype_pk = request.session.get('assignmentype_pk', False)
if assignmentype_pk:
assignmentype = Assignmentype.objects... | [
"def create_assignmentype_students(request):\n existing_students = request.session.get('existing_students', False)\n new_students = request.session.get('new_students', False)\n assignmentype_pk = request.session.get('assignmentype_pk', False)\n if assignmentype_pk:\n tasks.create_assignment(assig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
After validate_assignmentype_students, create new students and associate new+existing students to an assignmentype.assignment. | def create_assignmentype_students(request):
existing_students = request.session.get('existing_students', False)
new_students = request.session.get('new_students', False)
assignmentype_pk = request.session.get('assignmentype_pk', False)
if assignmentype_pk:
tasks.create_assignment(assignmentype_p... | [
"def create_assignmentype(request, assignmentype_id=None):\n prof = request.user.prof\n context = {}\n if assignmentype_id:\n assignmentype = Assignmentype.objects.get(id=assignmentype_id)\n message = 'Reset your assignment. You can upload a new student list, '\\\n 'but be aware th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List all running (archived=False) assignmentype | def list_assignmentypes_running(request):
prof = request.user.prof
context = {'type_assignmentype': 'running', 'prof': prof}
context['list_assignmentypes'] = Assignmentype.objects.\
filter(archived=False, prof=prof).order_by('deadline_submission')
return render(request, 'gradapp/list_assignmenty... | [
"def list_assignmentypes_archived(request):\n prof = request.user.prof\n context = {'type_assignmentype': 'archived', 'prof': prof}\n context['list_assignmentypes'] = Assignmentype.objects.\\\n filter(archived=True, prof=prof)\n return render(request, 'gradapp/list_assignmentype.html',\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List all archived assignmentype | def list_assignmentypes_archived(request):
prof = request.user.prof
context = {'type_assignmentype': 'archived', 'prof': prof}
context['list_assignmentypes'] = Assignmentype.objects.\
filter(archived=True, prof=prof)
return render(request, 'gradapp/list_assignmentype.html',
con... | [
"def list_all_assignments(self):\r\n assign_list=[]\r\n for assign in self.__assignments.values():\r\n assign_list.append(assign)\r\n return assign_list",
"def get_assignment_queryset(self):\n # assignment_queryset = self.period.assignments.all().order_by('publishing_time')\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dashboard of an assignmentype (id=pk) | def detail_assignmentype(request, pk):
prof = request.user.prof
context = {'prof': prof}
assignmentype = Assignmentype.objects.filter(pk=pk, prof=prof).first()
assignments = assignmentype.assignment_set.\
annotate(std=StdDev('evalassignment__grade_assignment'),
mean=Avg('evalass... | [
"def assignment_detail(request, course_slug, assignment_id):\r\n course = get_object_or_404(Course, slug=course_slug)\r\n assignment = get_object_or_404(Assignment, pk=assignment_id)\r\n student_submissions = Submission.objects.filter(assignment=assignment, student=request.user)\r\n is_student = False\r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set up coefficients of an assignmentype (id=pk) | def coeff_assignmentype(request, pk):
prof = request.user.prof
context = {'prof': prof}
assignmentype = Assignmentype.objects.filter(pk=pk, prof=prof).first()
if assignmentype:
nb_questions = assignmentype.nb_questions
if request.method == 'POST':
form = CoeffForm(request.POS... | [
"def update_coeff(self, **kwargs: float) -> None:\n for rule_name, coeff in kwargs.items():\n if rule_name not in self.rules:\n raise ValueError(f\"Behavioral rule {rule_name} does not exist\")\n else:\n self.rules[getattr(self, rule_name)] = coeff",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
csv to html conversion. | def csv_to_html():
logging.info("Converting csv to html..")
df = pd.read_csv(gTAF_config.execution_summary_csv_file)
df.to_html(gTAF_config.html_report_file)
htmTable = df.to_html() | [
"def csv_to_html(filepath):\r\n df = pd.read_csv(filepath, index_col=0)\r\n html = df.to_html()\r\n return html",
"def csv_to_html(text):\n \n html = ''\n \n html += get_preamble()\n \n if not text.strip():\n html += get_empty()\n \n else:\n keys, groups = _read_csv(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the name of the transformed feature from original name. | def _transformed_name(key: Text) -> Text:
return key + "_xf" | [
"def generate_file_name(old_file_name: str) -> str:\r\n return old_file_name.split(\".\")[0] + '_features' + '.npy'",
"def transformed_name(key: Text) -> Text:\n return key + \"_xf\"",
"def FeatureNameToConstantName(feature_name):\n # type: (str) -> str\n return ('k' + ''.join(word[0].upper() + word[1:]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize a new Hex game, and return it | def get_new_game(game_config):
_type = game_config["game_type"]
if _type == "hex":
game = Hex(game_config["hex"], verbose=game_config["verbose"])
else:
raise ValueError("Game type is not supported")
return game | [
"def init_new_game(self):\n self.game = get_new_game(self.game_config)",
"def __init__(self):\r\n self._game_state = 'UNFINISHED'\r\n self._player_turn = 'blue'\r\n self._blue_gen_square = 'e9'\r\n self._red_gen_square = 'e2'\r\n\r\n # create empty game board (columns a-i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to read auth models go to auth_db. | def db_for_read(self, model, **hints):
if self.isAdminApp(model):
return 'auth_db'
return None | [
"def importDbModels():\n from .users import User",
"def _load_db(self):\n for type_ in self._types:\n try:\n type_.table(self._metadata)\n except InvalidRequestError:\n pass\n # Reflect metadata so auto-mapping works\n self._metadata.refl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allow relations if a model in the auth app is involved. | def allow_relation(self, obj1, obj2, **hints):
if self.isAdminApp(obj1) or self.isAdminApp(obj2):
return True
return None | [
"def allow_relation(self, obj1, obj2, **hints):\n if obj1._meta.app_label in self.auth_apps or \\\n obj2._meta.app_label in self.auth_apps:\n return True\n return None",
"def allow_relation(self, obj1, obj2, **hints):\n if self.is_managed_app(obj1._meta.app_label) \\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find files changed in certain revisions. The function passes `revish` directly to `git diff`, so `revish` can have a variety of forms; see `git diff help` for details. Files in the diff that are matched by `ignore_rules` are excluded. | def files_changed(revish: Text,
ignore_rules: Optional[Sequence[Text]] = None,
include_uncommitted: bool = False,
include_new: bool = False
) -> Tuple[List[Text], List[Text]]:
files = repo_files_changed(revish,
in... | [
"def changes(self, files=[], rev=None, change=None, text=False,\n reverse=False, ignore_all_space=False, ignore_space_change=False,\n ignore_blank_lines=False, context=None, subrepos=False,\n include=None, exclude=None): \n return diffparser.parse(self.diff(file... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a two dimensional n (rows) x m (columns) board filled with zeros 4 x 5 board 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 x 2 board 0 0 0 0 0 0 >>> create_board(4, 5) [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] >>> create_board(3, 2) [[0, 0], [0, 0], [0, 0]] | def create_board(n, m):
if n == 0 or m == 0:
raise IndexError("dimensions cannot both be zero")
if n < 0 or m < 0:
raise IndexError("dimensions cannot be negative")
board = []
rows = [0] * m
for i in range(n):
board.append(rows)
return board | [
"def init_board(n):\n board = [['' for col in range(n)] for row in range(n)]\n return board",
"def create_board(N):\n board = [[0 for x in range(N)] for y in range(N)] \n return board",
"def make_board():\n board = []\n (BOARD_ROW, BOARD_COLUMN) = (5, 5)\n for column in range(1, BOARD_COLUM... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A special invert function that will return 1/x, except in the case that we pass in x = 0, in which case we return 1 | def invert(x):
try:
return 1 / x
except ZeroDivisionError as e:
print(e)
return 1 | [
"def invert(x):\n result = 1/x # Raises a ZeroDivisionError if x is 0\n print('Never printed if x is 0')\n return result",
"def invert0(x):\n return 0 if x > 0 else 1",
"def opposite(x):\n return -1*x",
"def negate(x):\n return x ^ 1",
"def invert(x, out=None, **kwargs):\n return _unar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save a boxplot of given data. Boxplot display the minimum and the maximum, quartiles 1, 2 and 3 and percentiles 2th and 98th. Also the mean is displayed as a curve. | def save_box_plot(data, fname="box_plot.pdf", axis_labels=None,
plot_title=None, plot_suptitle="None"):
figure()
transpose = lambda l: [[l[j][i] for j in range(len(l))] for i in range(len(l[0]))]
tr_data = transpose(data)
# boxplot
boxplot(tr_data)
# plot the mean as a curve
avg = l... | [
"def boxplot(values):\n percentiles = percentile(values, [0, 25, 50, 75, 100])\n result = {'min_val': percentiles[0],\n 'q1_val': percentiles[1],\n 'mean_val': percentiles[2],\n 'q3_val': percentiles[3],\n 'max_val': percentiles[4]}\n return result",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save an errorplot based on given data. Errorplot display the average value plus/minus the standard deviation for each point. | def save_error_plot(data, fname="error_plot.pdf", axis_labels=None,
plot_title=None, plot_suptitle=None):
from math import sqrt
figure()
transpose = lambda l: [[l[j][i] for j in range(len(l))] for i in range(len(l[0]))]
avg = lambda l: sum(l)/len(l)
st_dev = lambda (values, mean): sqrt( su... | [
"def error():\n\n # Make data set using errors\n dataset_a = DataSet(oscillating,error_y=oscillating_error,plot='error_bar',label='Data and error')\n dataset_a.set_error(interval=5,width=1,cap=2)\n dataset_b = DataSet(oscillating,plot='error_shade',error_y=oscillating_error,order=0,colour='lightgrey',la... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a MPG video showing multiple scatter plots. | def anim_scatter_plot(points_list, values,
fname="anim_scatter.mpg", fps=2, *args, **kwargs):
print "Genrating temp images"
for idx, pts in enumerate(points_list):
print "\tPlot %i of %i" % (idx, len(points_list))
scatter_plot(pts, values, "_tmp_%i.png" % idx, *args, **kwargs)
print "Cr... | [
"def create_video(all_obj_locs, fps=30):\n i = 0\n print(len(all_obj_locs[::STEP]))\n for f in all_obj_locs[::STEP]:\n plt.figure(figsize=(SIZE * 2, SIZE), dpi=80)\n plt.ylim([-LANE_LENGTH / 4 + 25, LANE_LENGTH / 4 + 75])\n plt.xlim([-50, LANE_LENGTH + 50])\n x_s = [p[1] for p i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute the linear decay rate of quantity x at time t. x(t) = x0 (1alpha) x0 t / T if t T | def linear_decay(x0, alpha, T, t):
if t <= T:
return x0 - (1 - alpha) * x0 * t / T
else:
return alpha * x0 | [
"def exponential_decay(x, a, t):\n return 1 + a * np.exp(-x / t)",
"def get_rate(self, t):\n return self.l_0 + \\\n self.alpha * sum(np.exp([self.beta * -1.0 * (t - s)\n for s in self.prev_excitations\n if s <= t]))",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a feed_dict with the learning rate filled in. | def feed_dict(self):
return {self.lr_tensor: self.lr()} | [
"def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This function uses patterns to test wether or not a temporal annotation is of a known absolute format | def is_absolute_timexe(string):
patterns = [
'(\d+)', # just digits
'(\d+/\d+/\d+)',
'(\d+/\d+)',
'(\d+-\d+-\d+)',
'(\d+-\d+)',
'^\d{1,2}\/\d{1,2}\/\d{4}$', # matches dates of the form XX/XX/YYYY where XX can be 1 or 2 digits long and YYYY is always 4 digits long.
... | [
"def test_mixed_annotations():\n a = dict(foo=[1, 'a', Datetime(1969,4,28,11,47)])\n sa = to_synapse_annotations(a)\n # print sa\n a2 = from_synapse_annotations(sa)\n # print a2\n assert a2['foo'][0] == '1'\n assert a2['foo'][1] == 'a'\n assert a2['foo'][2].find('1969') > -1",
"def is_time... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this function filters absolute timexes using the patterns above | def filter_absolute_timexes():
timexes = pd.read_excel('../TimeDatasets/i2b2 Data/i2b2_timexe_annotations.xlsx')
timexes = timexes[timexes['type'].isin(['DATE', 'TIME'])]
print('DATE AND TIME')
print(timexes)
absolute_timexes = timexes[ [is_absolute_timexe(string) for string in timexes['ann_text... | [
"def filter_lower_datetime(time, list_time):\n return [t for t in list_time if t <= time]",
"def _xh_filter_ts(commands, start_time, end_time):\n for cmd in commands:\n if start_time <= cmd[\"ts\"] < end_time:\n yield cmd",
"def time_filter_html(time):\n return time_filter(time)",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if two trees are structurally identical | def is_identical(self, tree1, tree2):
if not tree1 and not tree2:
return True
elif tree1 and tree2:
return (tree1.root == tree2.root and self.is_identical(tree1.left,tree2.left) and self.is_identical(tree1.right, tree2.right))
else:
return False | [
"def do_trees_have_same_structure(a, b):\n return jax.tree_structure(a) == jax.tree_structure(b)",
"def _exact_compare(tree1, tree2):\n attrs = ['name', 'length', 'support']\n for n1, n2 in zip(tree1.postorder(), tree2.postorder()):\n for attr in attrs:\n if getattr(n1, attr, None) != g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |