query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Consume the streamed responses until there are no more.
def consume_all(self, max_loops=None): curr_loop = 0 if max_loops is None: max_loops = float('inf') while curr_loop < max_loops: curr_loop += 1 try: self.consume_next() except StopIteration: break
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ReceiveStreamedEvents(self, request, context):\n print 'got ReceiveStreamedEvents request'\n while 1:\n if ShutDown.stop:\n break\n yield self.get_next_event()", "def run(self) -> None:\n\n # Track the last timestamp we see. When we fetch_stream() ag...
[ "0.67627555", "0.66493285", "0.65866256", "0.64904374", "0.63416284", "0.63416284", "0.63320816", "0.6224936", "0.6160845", "0.61538947", "0.61309123", "0.60998666", "0.60958767", "0.6089914", "0.602663", "0.60244423", "0.5999156", "0.5978938", "0.5977096", "0.5976404", "0.59...
0.0
-1
Helper for validation methods.
def _raise_if(predicate, *args): if predicate: raise InvalidChunk(*args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate():", "def __validate():\n # TODO: implement", "def _validate(self):\n pass", "def validate(self):", "def validate(self):", "def __validate__(self):", "def __validate(self):\n pass", "def validate(self):\n ...", "def check_validity(self):", "def validate(ob):",...
[ "0.8222522", "0.8042264", "0.78539884", "0.7784185", "0.7784185", "0.75735545", "0.7555545", "0.75300395", "0.75175196", "0.7459588", "0.74407196", "0.7387297", "0.7387297", "0.7387297", "0.7387297", "0.7387297", "0.7387297", "0.7387297", "0.7387297", "0.7351893", "0.727022",...
0.0
-1
Produce gridded field plots of regimes, plotting MEAN and MAX fields only.
def plot_gridded(ini_dict, md_list, short_name, filesuffix='', title='', verbose=1): contour_levels = adaqcode.aq_indices.DAQI_LEVELS.get(short_name, None) ini_dict['levels_list'] = contour_levels for md in md_list: #Develop aggregated md cube = md.extract(short_name=shor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _plot_group_fields(ax, xss, field, **kw):\n #check for an xmax keyword\n if('xmax' in kw):\n xmax = kw['xmax']\n else:\n xmax = False\n #plot the fields, keeping handles and finding max of all\n fields_list = [xs.fields[field] for xs in xss]\n for i in range(len(fields_list)):\n...
[ "0.611477", "0.6102327", "0.591604", "0.58786225", "0.583914", "0.5818713", "0.5709947", "0.5696284", "0.56764764", "0.5647464", "0.56137687", "0.56037486", "0.5603121", "0.5597776", "0.5560565", "0.5557221", "0.5551405", "0.55269533", "0.55249816", "0.55095065", "0.55004513"...
0.0
-1
Toplevel plotting routine to incorporate all possible types of regime specific plotting.
def regime_plotting(inifilename=None, verbose=1): print('Beginning at ', datetime.datetime.now()) #Read ini file ini_dict = adaqcode.inifile.get_inidict( inifilename=inifilename, defaultfilename='adaqscripts/aq_plot_regimes.ini') #Ensure models_list is setup if not already given in in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def builtin_plot(self, **kwargs):\n self.gp.plot(**kwargs)\n return", "def plot_global(type):\n click.echo(click.style(\n \"Generating Plot....\", fg='cyan', bold='true'))\n plot_time_series.TimeSeriesPloTs.plot_global(type)\n click.echo(click.style(\n \"Done....\", fg='green', bold=...
[ "0.7028155", "0.69380605", "0.6713669", "0.6648349", "0.6640619", "0.6638443", "0.6557937", "0.6537343", "0.6513881", "0.6505749", "0.6471406", "0.6449923", "0.64455175", "0.6404636", "0.6396561", "0.63633186", "0.6305545", "0.62955946", "0.62955946", "0.62758654", "0.6261723...
0.6413665
13
Return the capacity of the link that tp_ofid is on.
def get_link_capacity(self, src_port_ofid, dst_port_ofid): src_node_id = src_port_ofid.rsplit(":", 1)[-2] for neighbor in self.neighbors[src_node_id]: if neighbor["dst_port"] == dst_port_ofid: return neighbor["bps_capacity"] # Link not found raise KeyError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_capacity():\n fs.get_capacity()", "def Capacity(self) -> int:", "def getCapacity(self):\n\n return self._dfa._capacity", "def capacity(self):\n return self._cap", "def get_capacity_param(self):\n intr = self.get_interaction()\n return intr.get_capacity(None, None, None, None,...
[ "0.6554091", "0.6332799", "0.6309355", "0.6215011", "0.61785585", "0.6164421", "0.60826606", "0.60619515", "0.6057466", "0.6057466", "0.6057466", "0.6057466", "0.6056847", "0.6049901", "0.6034765", "0.60161144", "0.59946734", "0.59814006", "0.5973901", "0.5961227", "0.5903538...
0.7761142
0
Return all nodes in the network
def get_node_ids(self): return self.node_ids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNodes(self):\n return self.__allNodes", "def get_all_nodes(self):\n return self._get_all_nodes()", "def all_nodes(self):\n nodes = []\n for layer in self.layers:\n nodes += layer.nodes\n return nodes", "def get_all_nodes(self):\n # NOTE: return copy...
[ "0.8247986", "0.8242274", "0.8113676", "0.8104979", "0.7826658", "0.7803574", "0.7803508", "0.7803005", "0.77714455", "0.77469605", "0.76678354", "0.7628621", "0.7616412", "0.76123136", "0.7595596", "0.75938034", "0.7593681", "0.7553161", "0.7541189", "0.7539073", "0.7539073"...
0.6610832
86
Return all edges in the network.
def get_all_edges(self): ans = [] for node_id in self.neighbors: for edge_to_neighbor in self.neighbors[node_id]: ans.append(edge_to_neighbor) return ans
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edges(self):\n return self.__generate_edges()", "def edges(self):\n return self.__generate_edges()", "def edges(self):\n return self.__generate_edges()", "def edges(self):\n return self.generate_edges()", "def edges(self):\n return self.graph.edges", "def edges(self...
[ "0.81871164", "0.81871164", "0.81871164", "0.8181812", "0.80812013", "0.8064314", "0.7845059", "0.78269714", "0.78269714", "0.78269714", "0.78269714", "0.78269714", "0.78269714", "0.7755025", "0.7750934", "0.77017057", "0.76950264", "0.7680285", "0.76666814", "0.7649937", "0....
0.7920656
6
Return all neighbor entries/outgoing edges from node_id
def get_neighbors(self, node_id): return self.neighbors[node_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def neighbors(self, node_id):\n node_id = _get_vertex_obj(self.graph, node_id)\n neighors = self.graph.vertex(node_id).out_neighbors()\n return [\n _get_node_id(self.graph, n) for n in neighors\n ]", "def edges(self, node):\n nID = self.n2ID[node]\n return [(s...
[ "0.7633168", "0.7256833", "0.69981307", "0.6936573", "0.68811303", "0.68784815", "0.6823754", "0.6782679", "0.6781637", "0.6762141", "0.6747605", "0.67075604", "0.67031693", "0.6702216", "0.6670769", "0.6641744", "0.66277415", "0.6607706", "0.66022193", "0.65648645", "0.65638...
0.72472596
2
Add an edge/link in the topology between two nodes (1 edge for each direction)
def add_link(self, src_node_id, dst_node_id, src_port, dst_port, capacity=10000000): # Get function name fname = sys._getframe().f_code.co_name # Do not add the link if the nodes are not in the topology if src_node_id not in self.nodes or dst_node_id not in self.nodes: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(self, vertex1, vertex2):\n\n vertex1.add_outgoing_node(vertex2)\n vertex2.add_incoming_node(vertex1)", "def add_edge(self,node1,node2):\n # add nodes if not already in graph\n if node1 not in self.nodes():\n self.add_node(node1)\n if node2 not in self.no...
[ "0.78282404", "0.76579326", "0.75549924", "0.7542781", "0.75203115", "0.7520227", "0.737233", "0.7299674", "0.72904104", "0.7273545", "0.72243893", "0.7223685", "0.7185693", "0.71600395", "0.71443963", "0.70664114", "0.69873816", "0.6983436", "0.69761634", "0.6974766", "0.695...
0.0
-1
Adjust a reserved link bandwidth by value bps.
def add_link_reservation(self, node_id, tp_ofid, value): try: # Look for the port port = None for edge in self.neighbors[node_id]: if edge["src_port"] == tp_ofid: port = edge break # Stop if the port is dow...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_link_reservation(self, tp_ofid, value):\n\n try:\n # Get the node_id that the port is on\n node_id = tp_ofid.rsplit(\":\", 1)[-2]\n\n # Look for the port\n port = None\n for edge in self.neighbors[node_id]:\n if edge[\"src_port\"]...
[ "0.64046305", "0.611136", "0.5871874", "0.5852293", "0.57230866", "0.57218266", "0.5703435", "0.57025605", "0.5698364", "0.5678939", "0.5646187", "0.5641", "0.56002516", "0.55978924", "0.55819315", "0.5550268", "0.5505545", "0.5464052", "0.5417048", "0.5378025", "0.53441006",...
0.60160214
2
Adjust a reserved link bandwidth by value bps.
def set_link_reservation(self, tp_ofid, value): try: # Get the node_id that the port is on node_id = tp_ofid.rsplit(":", 1)[-2] # Look for the port port = None for edge in self.neighbors[node_id]: if edge["src_port"] == tp_ofid: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_link_capacity(self, path, bw):\n\n # PART 1, TASK 3.4 add bw to edges", "def add_link_reservation(self, node_id, tp_ofid, value):\n\n try:\n # Look for the port\n port = None\n for edge in self.neighbors[node_id]:\n if edge[\"src_port\"] == t...
[ "0.61118245", "0.60168004", "0.58715844", "0.5852447", "0.57242996", "0.57220125", "0.5703579", "0.5702154", "0.5698886", "0.5678886", "0.56471074", "0.5643329", "0.5599899", "0.55982184", "0.5582539", "0.5551441", "0.55049795", "0.5464619", "0.5417648", "0.5377427", "0.53443...
0.6404733
0
Return a list of OpenVSwitch node ids in this Topology.
def get_switch_ids(self): switch_ids = [] for node_id in self.nodes: if isinstance(self.nodes[node_id], OVSNode): switch_ids.append(node_id) return switch_ids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_ids(self):\n return [self.node_id]", "def get_node_ids(self):\n \n return self.node_ids", "def all_node_ids(self):\n return [i for i in range(0, self.n_inputs + self.n_hidden + self.n_outputs)]", "def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n ...
[ "0.7999517", "0.7927706", "0.7313502", "0.7179201", "0.69924164", "0.69775486", "0.69099134", "0.6908216", "0.68880624", "0.6844725", "0.68219465", "0.68216735", "0.6820734", "0.67531025", "0.6720736", "0.66904956", "0.6629367", "0.6593734", "0.6553961", "0.6481646", "0.64808...
0.78524137
2
Return a list of Edge/Fog node id's in this Topology
def get_host_ids(self): host_ids = [] for node_id in self.nodes: if (isinstance(self.nodes[node_id], HostNode)): host_ids.append(node_id) return host_ids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_edge_ids(self):\n node_ids = self.node_ids\n return [(node_ids[0], node_ids[1])]", "def node_ids(self):\n return [self.node_id]", "def get_node_ids(self):\n \n return self.node_ids", "def get_edge_ids(self):\n edge_ids = []\n \n for node_id in s...
[ "0.80246747", "0.80021924", "0.776323", "0.7640247", "0.75365937", "0.7336693", "0.726671", "0.7169679", "0.702738", "0.69416404", "0.6934128", "0.6929972", "0.68517333", "0.67951334", "0.67895263", "0.6690179", "0.668437", "0.6664594", "0.6642702", "0.6632913", "0.6613287", ...
0.72585964
7
Return a list of EdgeNode id's in this Topology
def get_edge_ids(self): edge_ids = [] for node_id in self.nodes: if (isinstance(self.nodes[node_id], EdgeNode)): edge_ids.append(node_id) return edge_ids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_edge_ids(self):\n node_ids = self.node_ids\n return [(node_ids[0], node_ids[1])]", "def node_ids(self):\n return [self.node_id]", "def get_node_ids(self):\n \n return self.node_ids", "def all_node_ids(self):\n return [i for i in range(0, self.n_inputs + self....
[ "0.8417553", "0.7780123", "0.7595157", "0.7044697", "0.70229703", "0.702295", "0.70166737", "0.6988524", "0.69479936", "0.6896795", "0.6852807", "0.68157274", "0.6791412", "0.6770623", "0.6764456", "0.6745589", "0.6739532", "0.67375714", "0.67306167", "0.66955346", "0.6693982...
0.8353254
1
Return a list of FogNode id's in this Topology
def get_fog_ids(self): fog_ids = [] for node_id in self.nodes: if (isinstance(self.nodes[node_id], FogNode)): fog_ids.append(node_id) return fog_ids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_ids(self):\n return [self.node_id]", "def get_node_ids(self):\n \n return self.node_ids", "def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n if not nodes:\n nodes = self.nodes\n if isinstance(nodes[0], integer_types):\n ...
[ "0.7718199", "0.75891614", "0.707182", "0.70489115", "0.7045605", "0.6933897", "0.6912419", "0.6898886", "0.6818077", "0.671521", "0.6713926", "0.6675852", "0.66475016", "0.66136235", "0.65971607", "0.65971607", "0.6568176", "0.65103084", "0.6461194", "0.6459157", "0.64580387...
0.7993218
0
Add a queue to the OVSNode object. Does not add a queue to a physical switch. The queue input should just be the json sent to the controller.
def add_queue(self, queue): queue_id = queue["ovsdb:queues"][0]["queue-id"] self.queue_dict[queue_id] = queue
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_queue(self, queue):\n with self.mutex:\n self.queues.append(queue)", "def enqueue(queue, item):\n new_node = Node(item, None)\n if empty_queue(queue):\n queue.front = new_node\n queue.back = new_node\n else:\n queue.back.next = new_node\n queue.back ...
[ "0.699978", "0.6716818", "0.65438", "0.65087456", "0.64866793", "0.6472381", "0.6423053", "0.63540053", "0.63540053", "0.62116456", "0.6189609", "0.61521506", "0.61341804", "0.6133515", "0.6109886", "0.61030436", "0.61030436", "0.61030436", "0.60970837", "0.60970837", "0.6097...
0.7638089
0
Remove a queue from the OVSNode object. Does not remove a queue from a physical switch.
def del_queue(self, queue_id): del self.queue_dict[queue_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_queue(self, queue) -> None:\r\n self.receive_queues.remove(queue)", "def remove_queue(self, queue):\n with self.mutex:\n self.queues.remove(queue)", "def deQueue(self):\n\t\tif self.isEmpty():\n\t\t\tprint(\"Queue already empty: Queue Empty\")\n\t\t\texit(1)\n\t\tprint(\"Deq...
[ "0.73949075", "0.7126362", "0.6574585", "0.65712065", "0.6396596", "0.6378849", "0.6377577", "0.6337017", "0.6212335", "0.6211877", "0.618047", "0.6144785", "0.61073905", "0.60976845", "0.60388345", "0.6032203", "0.6030154", "0.6012632", "0.59610015", "0.59492713", "0.5937360...
0.6300589
8
Add a qos to the OVSNode object. Updates qos if it already exists. Does not add a qos to a physical switch. The qos input should just be the json sent to the controller.
def add_qos(self, qos): qos_id = qos["ovsdb:qos-entries"][0]["qos-id"] self.qos_dict[qos_id] = qos
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_qos(tenant_id, qos_name, qos_desc):\n LOG.debug(\"add_qos() called\")\n session = db.get_session()\n try:\n qos = (session.query(network_models_v2.QoS).\n filter_by(tenant_id=tenant_id).\n filter_by(qos_name=qos_name).one())\n raise c_exc.QosNameAlreadyExi...
[ "0.675133", "0.6740849", "0.6509288", "0.63825524", "0.6261487", "0.623508", "0.61480707", "0.6146155", "0.6125985", "0.60934", "0.5971305", "0.5832702", "0.5652961", "0.56214666", "0.55383885", "0.55369544", "0.55208385", "0.5508991", "0.5416964", "0.5408776", "0.52939504", ...
0.8248631
0
Remove a qos from the OVSNode object. Does not remove a qos from a physical switch.
def del_qos(self, qos_id): del self.qos_dict[qos_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_qos(tenant_id, qos_id):\n session = db.get_session()\n try:\n qos = (session.query(network_models_v2.QoS).\n filter_by(tenant_id=tenant_id).\n filter_by(qos_id=qos_id).one())\n session.delete(qos)\n session.flush()\n return qos\n except ex...
[ "0.7492389", "0.66317993", "0.65376616", "0.613438", "0.6096178", "0.5843171", "0.57433033", "0.57280266", "0.565263", "0.5633237", "0.55685246", "0.54654384", "0.54583687", "0.5413236", "0.5384401", "0.5379288", "0.5373369", "0.5344602", "0.52841705", "0.5275169", "0.5238269...
0.74182165
1
Set the port data of a node. Add/Remove a QoS to it beforehand.
def set_port_data(self, port_ofid, qos): # qos_id = qos["ovsdb:qos-entries"][0]["qos-id"] self.port_dict[port_ofid] = qos
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_port(self, data):\n self.port = get_optional_value(data, self.PORT, None)\n if self.port:\n self.port = \":\" + str(self.port)\n else:\n self.port = \"\"", "def set_in_data(self, data: NodeData, port: Port):\n self.inputs[port.index] = copy(data)\n ...
[ "0.67488563", "0.66739744", "0.6240939", "0.62166893", "0.5869487", "0.58545256", "0.5842943", "0.5787363", "0.5717762", "0.5713686", "0.5713686", "0.5690743", "0.5690426", "0.56870556", "0.5679274", "0.5679274", "0.56715566", "0.56647885", "0.5629037", "0.5599139", "0.558414...
0.7049002
0
Remove a QoS from a port on the OVSNode object. Does not remove a qos from a physical switch port.
def del_port_qos(self, port_ofid): del self.port_dict[port_ofid]["termination-point"][0]["ovsdb:qos-entry"] # del self.port_dict[port_ofid]["ovsdb:port-external-ids"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_qos(tenant_id, qos_id):\n session = db.get_session()\n try:\n qos = (session.query(network_models_v2.QoS).\n filter_by(tenant_id=tenant_id).\n filter_by(qos_id=qos_id).one())\n session.delete(qos)\n session.flush()\n return qos\n except ex...
[ "0.6073217", "0.5983327", "0.5815346", "0.56779134", "0.55692255", "0.5565197", "0.54546815", "0.5450063", "0.5372083", "0.5365305", "0.53215384", "0.5122388", "0.5097211", "0.5077547", "0.50117797", "0.5011468", "0.49515623", "0.49181432", "0.48132536", "0.48091388", "0.4789...
0.7311583
0
Return the queuenumber of the queue which is on the specified qos. Throw KeyError for nonexistant qos_id or queue_id.
def get_queue_num(self, qos_id, queue_id): q_num = None queues = self.qos_dict[qos_id]["ovsdb:qos-entries"][0]["queue-list"] # Go through all queues for queue in queues: cur_queue_id = queue["queue-ref"].split("'")[-2] # If we have a match, get the q_num and bre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qos(self, qos_id):\n aname = \"cinder_v%s.get_qos\" % self.version\n with atomic.ActionTimer(self, aname):\n return self._get_client().qos_specs.get(qos_id)", "def get_qos(self, qos_id):\n return self._unify_qos(self._impl.get_qos(qos_id))", "def search_queue_number(self...
[ "0.66933286", "0.6456661", "0.6404476", "0.62828374", "0.6201854", "0.6167598", "0.6123524", "0.61234075", "0.60170996", "0.5987462", "0.5904443", "0.5872696", "0.58259076", "0.58259076", "0.58259076", "0.58225393", "0.58024627", "0.57807124", "0.5712098", "0.55508906", "0.55...
0.8528866
0
If current window is not open anymore, ensure to have a valid one selected.
def _ensure_valid_window(session): try: session.window_handle except webdriver.NoSuchWindowException: session.window_handle = session.handles[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _handle_popup_open(self):\n log.debug(\"Handling popup open\")\n self.current_selected = self.listbox.get_focus()[1]", "def __window_getSelection(self):\n return None", "def activeWindow(self):\n raise RuntimeError('Not implemented')\n \n return None ...
[ "0.6643104", "0.65358114", "0.62136686", "0.6166602", "0.61252916", "0.6113035", "0.60954267", "0.6088451", "0.6025493", "0.600874", "0.5997454", "0.5980767", "0.5965386", "0.59619033", "0.59610575", "0.5932412", "0.58595824", "0.58078897", "0.5784558", "0.5779727", "0.576519...
0.61354476
4
Dismisses any open user prompts in windows.
def _dismiss_user_prompts(session): current_window = session.window_handle for window in _windows(session): session.window_handle = window try: session.alert.dismiss() except webdriver.NoSuchAlertException: pass session.window_handle = current_window
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_launcher(self):\n self.misc.go_to_win(self.misc.bufwinnr(self.name))\n if self.misc.bufname() == self.name:\n vim.command('bd')\n self.misc.go_to_win(self.misc.bufwinnr(self.curr_buf.number))\n if self.nohidden_set:\n vim.command(\"set nohidde...
[ "0.6640128", "0.65973043", "0.6501951", "0.6496951", "0.63111687", "0.6168662", "0.6166496", "0.6155943", "0.61541855", "0.6115891", "0.60888875", "0.60834306", "0.60509425", "0.6042105", "0.6036628", "0.6024034", "0.6024034", "0.6023815", "0.60197735", "0.5955441", "0.595205...
0.77716744
0
Closes superfluous windows opened by the test without ending the session implicitly by closing the last window.
def _restore_windows(session): current_window = session.window_handle for window in _windows(session, exclude=[current_window]): session.window_handle = window if len(session.window_handles) > 1: session.close() session.window_handle = current_window
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\r\n t1 = time.time()\r\n self.driver.close()\r\n self.my_print(\"{0} Closed current window, Spend {1} seconds\".format(success, time.time() - t1))", "def close_window() -> None:\n global _window\n\n if _window is None:\n return\n\n _window.close()\n _windo...
[ "0.70893556", "0.6985419", "0.6844001", "0.68161947", "0.6801015", "0.67555696", "0.6706753", "0.66400015", "0.65985036", "0.65967566", "0.6549405", "0.6519287", "0.6494511", "0.64939183", "0.6481835", "0.64684445", "0.6450102", "0.64454997", "0.6437897", "0.6434593", "0.6434...
0.6911804
2
If the current browsing context selected by WebDriver is a `` or an ``, switch it back to the toplevel browsing context.
def _switch_to_top_level_browsing_context(session): session.switch_frame(None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def switch_to_default(self):\n self.base_driver.switch_to.default_content()", "def i_go_back(self):\n if not world.using_selenium:\n assert False, (\"this step needs to be implemented for the \"\n + \"django test client\")\n world.browser.back()", "def switch_to_frame_...
[ "0.58153147", "0.5623497", "0.5574684", "0.5559198", "0.5539013", "0.5519285", "0.54529727", "0.53206336", "0.53082204", "0.52926224", "0.5244077", "0.52141947", "0.5180062", "0.5123678", "0.5098424", "0.5080767", "0.50088096", "0.49289653", "0.4915355", "0.48766986", "0.4849...
0.7291539
0
Set of window handles, filtered by an `exclude` list if provided.
def _windows(session, exclude=None): if exclude is None: exclude = [] wins = [w for w in session.handles if w not in exclude] return set(wins)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter(self, contains, ignore_hidden=True, ignore_smaller=(480, 800)):\n if type(contains) == str:\n contains = [contains]\n\n dct = {hwnd: window for hwnd, window in self.windows.items() if window.find(contains)}\n if ignore_hidden:\n dct = {hwnd: window for hwnd, wi...
[ "0.6869567", "0.5888472", "0.58635926", "0.57578135", "0.573252", "0.5632768", "0.5533731", "0.55274135", "0.5482475", "0.5399696", "0.5340132", "0.52620625", "0.52454895", "0.5245142", "0.52206814", "0.51517177", "0.5098032", "0.5060605", "0.5053272", "0.50375456", "0.503629...
0.8272605
0
Create an `iframe` element in the current browsing context and insert it into the document. Return an element reference.
def create_frame(session): def create_frame(): append = """ var frame = document.createElement('iframe'); document.body.appendChild(frame); return frame; """ response = session.execute_script(append) return create_frame
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iframe(src, width=400, height=300):\n return TAG.iframe(_src=src, _width=width, _height=height)", "def as_iframe(self, html_data):\n\n srcdoc = html_data.replace('\"', \"'\")\n return ('<iframe id=\"{div_id}\", srcdoc=\"{srcdoc}\" style=\"width: {width}; '\n 'height: {heig...
[ "0.6174784", "0.55865693", "0.54760414", "0.5332886", "0.51973313", "0.5196938", "0.51477903", "0.48718172", "0.48631668", "0.48425317", "0.48268217", "0.47691065", "0.47580108", "0.47167465", "0.47058505", "0.46702343", "0.45552185", "0.45123303", "0.4505555", "0.44861558", ...
0.6257008
0
Open new window and return the window handle.
def create_window(session): def create_window(): windows_before = session.handles name = session.execute_script("window.open()") assert len(session.handles) == len(windows_before) + 1 new_windows = list(set(session.handles) - set(windows_before)) return new_windows.pop() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_new_window(event):\n url = event.GetURL()\n webbrowser.open(url)", "def _open_window(self):\r\n\t\t# Creating the window\r\n\t\tself._window = Window(self, Locations.RESTAL)", "def open_new_window(self, selector):\n current_window = self.driver.current_window_handle\n ele...
[ "0.69135225", "0.6894578", "0.67950994", "0.67186034", "0.66880804", "0.6459025", "0.6384433", "0.6371975", "0.63716286", "0.63049585", "0.6247003", "0.61046994", "0.608595", "0.60641366", "0.6063295", "0.60611963", "0.60415345", "0.6027003", "0.5991303", "0.59858763", "0.595...
0.6855852
2
Upgrade a repository in place.
def upgraderepo( ui, repo, run=False, optimize=None, backup=True, manifest=None, changelog=None, filelogs=None, ): if optimize is None: optimize = {} repo = repo.unfiltered() revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS) specentries = ( (upgrade_engin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upgrade_db(self):\n repo = Repository(meta.metadata, meta.Session)\n\n if len(self.args) > 1:\n repo.upgrade(self.args[1])\n else:\n repo.upgrade()", "def update_from_repo():\n\treturn", "def upgrade(repo, package, editable):\n if repo.upgrade(package, editable...
[ "0.7149958", "0.691143", "0.68245393", "0.60859185", "0.6031843", "0.59491736", "0.5927844", "0.5927132", "0.59253454", "0.59129244", "0.5888372", "0.5848155", "0.5830943", "0.5814992", "0.57757306", "0.570952", "0.56553763", "0.56553763", "0.5622135", "0.5615035", "0.5530544...
0.0
-1
Upgrades a share to use sharesafe mechanism
def upgrade_share_to_safe( ui, hgvfs, storevfs, current_requirements, mismatch_config, mismatch_warn, ): wlock = None store_requirements = localrepo._readrequires(storevfs, False) original_crequirements = current_requirements.copy() # after upgrade, store requires will be shared,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_nas_share(self):\n pass", "def ensure_share(self, context, share, share_server=None):\n pass", "def ensure_share(self, context, share, share_server=None):\r\n LOG.debug(\"Ensure share.\")", "def test_update_nas_share_by_nas(self):\n pass", "def modify_share(self,...
[ "0.6845057", "0.67203784", "0.6711169", "0.6557974", "0.64306986", "0.6332817", "0.6282094", "0.61291856", "0.5973632", "0.59096307", "0.58651215", "0.58249974", "0.58247286", "0.5690291", "0.56780624", "0.56755394", "0.5666705", "0.5627112", "0.5567672", "0.5542713", "0.5532...
0.6667364
3
Downgrades a share which use sharesafe to not use it
def downgrade_share_to_non_safe( ui, hgvfs, sharedvfs, current_requirements, mismatch_config, mismatch_warn, ): wlock = None source_requirements = localrepo._readrequires(sharedvfs, True) original_crequirements = current_requirements.copy() # we cannot be 100% sure on which requi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upgrade_share_to_safe(\n ui,\n hgvfs,\n storevfs,\n current_requirements,\n mismatch_config,\n mismatch_warn,\n):\n wlock = None\n store_requirements = localrepo._readrequires(storevfs, False)\n original_crequirements = current_requirements.copy()\n # after upgrade, store requires...
[ "0.6136717", "0.60942453", "0.5921612", "0.5819336", "0.5804598", "0.57667804", "0.5730506", "0.5587024", "0.55807817", "0.55419433", "0.5486107", "0.54153746", "0.53993505", "0.5386615", "0.53716373", "0.5360348", "0.5339382", "0.5251872", "0.5182905", "0.5155481", "0.515402...
0.67952925
0
Freezer is based on top of the pkg module. Return True since the `pkg` module should always exist. This avoids the overhead of loading all modules.
def __virtual__(): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _package_available(package_name: str) -> bool:\n try:\n return find_spec(package_name) is not None\n except ModuleNotFoundError:\n return False", "def is_pkg(cls, path):\n return exists(join(path, '__init__.py'))", "def is_package(self, fullname):\n return hasattr(self.__g...
[ "0.72167784", "0.7054037", "0.67946243", "0.67609817", "0.67345065", "0.6663047", "0.66244084", "0.66183674", "0.6577075", "0.6577075", "0.6500366", "0.64847684", "0.6473244", "0.64359987", "0.64204097", "0.64127177", "0.641208", "0.6371272", "0.63555104", "0.6305438", "0.626...
0.0
-1
Return the path where we will store the states.
def _states_path(): return os.path.join(__opts__["cachedir"], "freezer")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _state_data_path(self) -> Path:\n return Path(self._state_dir, 'state')", "def _state_dir(self) -> Path:\n assert self._project_root is not None\n return Path(self._project_root, '.cache/bacloud')", "def store_path(self):\n return path.join(env.store_home, self._store_path)", ...
[ "0.8130128", "0.74008346", "0.70137334", "0.69225276", "0.69225276", "0.6753384", "0.6694371", "0.66362345", "0.6522849", "0.6502435", "0.647101", "0.64176416", "0.6388808", "0.63761514", "0.634791", "0.6343165", "0.6338234", "0.6337287", "0.63310677", "0.63310677", "0.632196...
0.6853956
5
Return the full path for the packages and repository freezer files.
def _paths(name=None): name = "freezer" if not name else name states_path = _states_path() return ( os.path.join(states_path, "{}-pkgs.yml".format(name)), os.path.join(states_path, "{}-reps.yml".format(name)), )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def package_dir(self):\r\n return \".\"", "def get_package_dir():\n return Path(__file__).parent", "def GetPackageDirectory():\n return os.path.dirname(__file__)", "def get_pack_path():\r\n return get_package_path().replace(\"\\\\\", \"/\").replace(\"src\", \"\")", "def get_package_path():\n ...
[ "0.7146569", "0.68887824", "0.6863531", "0.68391216", "0.67521113", "0.6483317", "0.6479278", "0.6454551", "0.63976353", "0.63864076", "0.63839537", "0.6382218", "0.6355614", "0.6326879", "0.62890786", "0.62197596", "0.62076443", "0.6198006", "0.61681855", "0.6160469", "0.615...
0.58967614
34
Return True if there is already a frozen state. A frozen state is merely a list of packages (including the version) in a specific time. This information can be used to compare with the current list of packages, and revert the installation of some extra packages that are in the system. name Name of the frozen state. Opt...
def status(name=None): name = "freezer" if not name else name return all(os.path.isfile(i) for i in _paths(name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def we_are_frozen():\r\n\treturn hasattr(sys, \"frozen\")", "def is_frozen():\r\n return hasattr(sys, 'frozen') and sys.frozen", "def is_frozen(self, type_name):\n return self._symtab[type_name].is_frozen()", "def frozen_project():\n return hasattr(sys, \"frozen\")", "def freeze(name=None, force=F...
[ "0.68721086", "0.6851596", "0.68231916", "0.6491958", "0.63796014", "0.6135377", "0.6115065", "0.5805816", "0.5657362", "0.5609856", "0.5582771", "0.55413973", "0.54397535", "0.53899515", "0.5386102", "0.53778887", "0.53278416", "0.53246194", "0.53165835", "0.52400833", "0.52...
0.5422256
13
Return the list of frozen states.
def list_(): ret = [] states_path = _states_path() if not os.path.isdir(states_path): return ret for state in os.listdir(states_path): if state.endswith(("-pkgs.yml", "-reps.yml")): # Remove the suffix - both files start with the freezer # name ret.ap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_list(self) -> Sequence[TState]:\n pass", "def get_list_of_states(self):\n return self.states", "def getstate(self):\n return [elem.getstate() for elem in self]", "def initial_states(self):\n return list(self.iter_initial_states())", "def all_states(self):\n retu...
[ "0.69866335", "0.6971545", "0.6748766", "0.66988707", "0.66819704", "0.6678218", "0.66705126", "0.66479045", "0.6599758", "0.6587541", "0.6573471", "0.6547036", "0.65039486", "0.6479427", "0.6453777", "0.63992965", "0.63978416", "0.6305674", "0.626267", "0.6252373", "0.623590...
0.63569236
17
Save the list of package and repos in a freeze file. As this module is build on top of the pkg module, the user can send extra attributes to the underlying pkg module via kwargs. This function will call ``pkg.list_pkgs`` and ``pkg.list_repos``, and any additional arguments will be passed through to those functions. nam...
def freeze(name=None, force=False, **kwargs): states_path = _states_path() try: if not os.path.exists(states_path): os.makedirs(states_path) except OSError as e: msg = "Error when trying to create the freezer storage %s: %s" log.error(msg, states_path, e) raise C...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore(name=None, clean=False, **kwargs):\n if not status(name):\n raise CommandExecutionError(\"Frozen state not found.\")\n\n frozen_pkgs = {}\n frozen_repos = {}\n for fname, content in zip(_paths(name), (frozen_pkgs, frozen_repos)):\n with fopen(fname) as fp:\n content...
[ "0.61378956", "0.5859899", "0.5553727", "0.5517044", "0.5368273", "0.5356391", "0.5287984", "0.52467597", "0.5167484", "0.5165636", "0.51454926", "0.50794226", "0.50436324", "0.5004659", "0.4979779", "0.49662858", "0.49491364", "0.49177143", "0.49048695", "0.48790634", "0.487...
0.7397437
0
Add missing repositories and update the ret dict
def _add_missing_repositories(frozen_repos, ret, **kwargs): repos = __salt__["pkg.list_repos"](**kwargs) missing_repos = set(frozen_repos) - set(repos) for repo in missing_repos: try: # In Python 2 we cannot do advance destructuring, so we # need to create a temporary diction...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_repos(self):\n for repo in self.json_repos['repos']:\n title = str(repo[\"title\"])\n repo_url = str(repo['repo'])\n self.repos[title] = repo_url", "def prepare_repositories(self):\n if 'packages' not in self.image:\n return\n\n if self.i...
[ "0.6011542", "0.6000943", "0.59702677", "0.59536284", "0.57572675", "0.5679424", "0.5480698", "0.54709816", "0.54696035", "0.5465429", "0.5418876", "0.5358285", "0.5336003", "0.5319714", "0.5300553", "0.52956134", "0.52946633", "0.52800137", "0.5257892", "0.52492833", "0.5244...
0.73283684
0
Remove extra repositories and update the ret dict
def _remove_extra_repositories(frozen_repos, ret, **kwargs): repos = __salt__["pkg.list_repos"](**kwargs) extra_repos = set(repos) - set(frozen_repos) for repo in extra_repos: try: __salt__["pkg.del_repo"](repo, **kwargs) ret["repos"]["remove"].append(repo) log.in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_repo(self, url, multiple=False):\n json_data = loads(self.get_from_net(url)) #TODO add code to detect error messages in JSON from API\n if not multiple: json_data = [json_data]\n repo_dets = []\n for i in json_data:\n dets = {\n 'full_name': i['ful...
[ "0.63768286", "0.6205617", "0.6049083", "0.601234", "0.60121554", "0.59163606", "0.5872671", "0.5815441", "0.57877725", "0.57659966", "0.56418854", "0.5562782", "0.5551324", "0.55462074", "0.5538305", "0.5520755", "0.5516609", "0.549151", "0.54913694", "0.53865844", "0.537592...
0.6732441
0
Add missing packages and update the ret dict
def _add_missing_packages(frozen_pkgs, ret, **kwargs): # NOTE: we can remove the `for` using `pkgs`. This will improve # performance, but I want to have a more detalied report of what # packages are installed or failed. pkgs = __salt__["pkg.list_pkgs"](**kwargs) missing_pkgs = set(frozen_pkgs) - set...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_missing(base_pkg, missing, file_deps, use_test_depends=False):\n rospack = rospkg.RosPack()\n for launch_file in file_deps.keys():\n pkg = rospkg.get_package_name(os.path.dirname(os.path.abspath(launch_file)))\n\n if pkg is None: #cannot determine package\n print(\"ERRO...
[ "0.63271356", "0.62929744", "0.6243237", "0.6235455", "0.60803497", "0.60435265", "0.59839565", "0.59402096", "0.5894886", "0.5889566", "0.585334", "0.58395016", "0.58032274", "0.57730275", "0.57447606", "0.5739964", "0.57197624", "0.57119703", "0.56428427", "0.5610361", "0.5...
0.7601584
0
Remove extra packages and update the ret dict
def _remove_extra_packages(frozen_pkgs, ret, **kwargs): pkgs = __salt__["pkg.list_pkgs"](**kwargs) extra_pkgs = set(pkgs) - set(frozen_pkgs) for pkg in extra_pkgs: try: __salt__["pkg.remove"](name=pkg, **kwargs) ret["pkgs"]["remove"].append(pkg) log.info("Removed ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_packages(self, packages):", "def get_package_extras(provider_package_id: str) -> dict[str, list[str]]:\n if provider_package_id == \"providers\":\n return {}\n extras_dict: dict[str, list[str]] = {\n module: [get_pip_package_name(module)]\n for module in ALL_DEPENDENCIES[pro...
[ "0.6884728", "0.6164183", "0.60443765", "0.59631884", "0.59131014", "0.5821271", "0.58056074", "0.5762834", "0.57213247", "0.5667933", "0.56448823", "0.55830485", "0.5582136", "0.5575238", "0.5559194", "0.5512853", "0.55096483", "0.5499099", "0.5496219", "0.54939055", "0.5487...
0.7281054
0
Make sure that the system contains the packages and repos from a frozen state. Read the list of packages and repositories from the freeze file, and compare it with the current list of packages and repos. If there is any difference, all the missing packages are repos will be installed, and all the extra packages and rep...
def restore(name=None, clean=False, **kwargs): if not status(name): raise CommandExecutionError("Frozen state not found.") frozen_pkgs = {} frozen_repos = {} for fname, content in zip(_paths(name), (frozen_pkgs, frozen_repos)): with fopen(fname) as fp: content.update(json.lo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def freeze(name=None, force=False, **kwargs):\n states_path = _states_path()\n\n try:\n if not os.path.exists(states_path):\n os.makedirs(states_path)\n except OSError as e:\n msg = \"Error when trying to create the freezer storage %s: %s\"\n log.error(msg, states_path, e)\...
[ "0.6693031", "0.55354106", "0.5459218", "0.53684884", "0.52549475", "0.5132709", "0.5117423", "0.5094458", "0.4987855", "0.4985477", "0.49605286", "0.49180958", "0.4916067", "0.49073735", "0.490322", "0.49010733", "0.48840627", "0.48726887", "0.4865071", "0.4854589", "0.48454...
0.7274024
0
Display the difference between two frozen states. The results are shown as as a dictionary with keys for packages and repositories. Each key may contain a changes dictionary showing items that differ between the two frozen states. Items shown in the "old" changes but not the "new" were removed. Items in "new" but not "...
def compare(old, new): ret = {} if not (status(old) and status(new)): raise CommandExecutionError("Frozen state not found.") for ofile, nfile in zip(_paths(old), _paths(new)): with fopen(ofile, "r") as ofp: old_dict = json.load(ofp) with fopen(nfile, "r") as nfp: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diff(self, old, new):\n added = {}\n removed = {}\n updated = {}\n new_keys = set(new.keys())\n old_keys = set(old.keys())\n for key in new_keys.difference(old_keys):\n self.stack.append(key)\n if self.stack not in self.EXCLUDE_PATHS:\n ...
[ "0.6445065", "0.63510185", "0.62291247", "0.61684805", "0.60867995", "0.6075472", "0.6043765", "0.5956082", "0.5903646", "0.5833109", "0.5818187", "0.5767265", "0.5758895", "0.5721016", "0.5704464", "0.56633997", "0.5603045", "0.5588445", "0.5552404", "0.55448395", "0.5528738...
0.73044235
0
Parses indices. If the input is a list or tuple, this function has no effect. The input can also be a string, which is either a comma separated list of numbers 'a, b, c', or a dash separated range 'a c'. Space in the string will be ignored.
def parse_indices(obj, min_val=None, max_val=None): if obj is None or obj == "": indices = [] elif isinstance(obj, int): indices = [obj] elif isinstance(obj, (list, tuple, np.ndarray)): indices = list(obj) elif isinstance(obj, str): indices = [] splits = obj.repla...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ParseIndex(self, text):\n taxonStart = 0\n taxonStop = len(self.alignment) - 1\n columnStart = 0\n columnStop = self.alignment.get_alignment_length() - 1\n if (',' not in text):\n self.AlertMessage('Invalid index format. (taxa or columns missing)', 'high')\n ...
[ "0.700616", "0.67060786", "0.657264", "0.6481597", "0.6438154", "0.63995856", "0.622149", "0.6210855", "0.62036157", "0.60486674", "0.6009811", "0.56968063", "0.5622881", "0.5620511", "0.56019014", "0.5565559", "0.55575943", "0.549187", "0.5483714", "0.5469936", "0.5424265", ...
0.6356329
6
Interpolates two sets of latent codes linearly.
def interpolate(src_codes, dst_codes, step=5): if not (src_codes.ndim >= 2 and src_codes.shape == dst_codes.shape): raise ValueError( f"Shapes of source codes and target codes should both be " f"[num, *code_shape], but {src_codes.shape} and " f"{dst_codes.shape} are recei...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linear_interpolate(src_code, dst_code, step=5):\n assert (len(src_code.shape) == 2 and len(dst_code.shape) == 2 and\n src_code.shape[0] == 1 and dst_code.shape[0] == 1 and\n src_code.shape[1] == dst_code.shape[1])\n\n linspace = np.linspace(0.0, 1.0, step)[:, np.newaxis].astype(np.f...
[ "0.62725574", "0.6111674", "0.60768944", "0.60146874", "0.5994274", "0.5972352", "0.5939591", "0.5883201", "0.5856789", "0.5837395", "0.5833687", "0.58239853", "0.5815338", "0.58129686", "0.57570577", "0.5739954", "0.57292", "0.5709187", "0.5701638", "0.5627414", "0.56159806"...
0.6663595
0
Mixes styles from style codes to those of content codes. Each style code or content code consists of `num_layers` codes, each of which is typically fed into a particular layer of the generator. This function mixes styles by partially replacing the codes of `content_codes` from some certain layers with those of `style_c...
def mix_style( style_codes, content_codes, num_layers=1, mix_layers=None, is_style_layerwise=True, is_content_layerwise=True, ): if not is_style_layerwise: style_codes = style_codes[:, np.newaxis] style_codes = np.tile( style_codes, [num_layers if axis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def style_transfer(content_image, style_image,\n content_layer_ids, style_layer_ids,\n weight_content=1.5, weight_style=10.0,\n weight_denoise=0.3,\n num_iterations=120, step_size=10.0):\n\n # Create an instance of the VGG16-model. This is ...
[ "0.5546307", "0.5322151", "0.5304092", "0.52960813", "0.5194528", "0.5082745", "0.49479872", "0.48794138", "0.48556757", "0.4852009", "0.47630924", "0.4735377", "0.4601009", "0.45873055", "0.45219663", "0.45044163", "0.44962087", "0.44862875", "0.44846854", "0.44637838", "0.4...
0.84206253
0
Gets layerwise strength for manipulation.
def get_layerwise_manipulation_strength(num_layers, truncation_psi, truncation_layers): strength = [1.0 for _ in range(num_layers)] pdb.set_trace() if truncation_layers > 0: for layer_idx in range(0, truncation_layers): strength[layer_idx] = truncation_psi return strength
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strength(self) -> float:\n ...", "def getStrength(self):\n return self.st", "def strength(self) -> int:\n return self._strength", "def get_strength(self):\n return 10 - self.get_agility()", "def strength(self):\n return self._characterStrength", "def getPersonStreng...
[ "0.7637712", "0.75455815", "0.7303854", "0.7146308", "0.6993009", "0.6847768", "0.66764456", "0.6671681", "0.65083355", "0.6465695", "0.6432412", "0.6431157", "0.6431157", "0.6380653", "0.6380653", "0.63509285", "0.6347956", "0.6305505", "0.6294251", "0.6259037", "0.6241275",...
0.7233131
3
Parses boundary list. Sometimes, a text file containing a list of boundaries will significantly simplify image manipulation with a large amount of boundaries. This function is used to parse boundary information from such list file. Basically, each item in the list should be with format
def parse_boundary_list(boundary_list_path): if not os.path.isfile(boundary_list_path): raise ValueError(f"Boundary list `boundary_list_path` does not exist!") pdb.set_trace() boundaries = {} with open(boundary_list_path, "r") as f: for line in f: if line[: len("DISABLE")] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bbox(meta_data: List) -> List:\n\n x = [v for v in meta_data[0].split(\" \") if v][0]\n y = [v for v in meta_data[1].split(\" \") if v][0]\n w = [v for v in meta_data[2].split(\" \") if v][0]\n h = meta_data[3].replace(\")\", \"\").strip(\" \")\n\n return [x, y, w, h]", "def read_bounding_...
[ "0.6213156", "0.6167396", "0.6040958", "0.5963082", "0.5890223", "0.5804764", "0.5769279", "0.56760764", "0.56570864", "0.56555957", "0.5593112", "0.5554073", "0.5542578", "0.5527665", "0.5524644", "0.5523039", "0.5522045", "0.5506655", "0.54766965", "0.5425461", "0.54130983"...
0.7501823
0
(Optional) allocate torch tensors that could potentially be used in in the train_step() or evaluation_step() functions. If the load_to_gpu() function is called then those tensors will be moved to the gpu device.
def allocate_tensors(self): self.tensors = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cuda(self):\n if torch.cuda.is_available():\n self.automata = self.automata.cuda()\n self.inv_automata = self.inv_automata.cuda()\n self.action = self.action.cuda()\n self.inv_action = self.inv_action.cuda()", "def _place_cached_acts_data(inp_data: torch.Ten...
[ "0.573606", "0.5722874", "0.5655872", "0.5533152", "0.5515631", "0.5467257", "0.5454712", "0.5453343", "0.5453343", "0.5433174", "0.54190475", "0.54162455", "0.5402546", "0.5393747", "0.53816223", "0.5370867", "0.53450185", "0.5337499", "0.5332042", "0.5314197", "0.5313799", ...
0.6671218
0
Make html page of days detection queue
def detect_report(day, json_conf): rpt = mk_css() rpt += "<h1>Detection Report for " + STATION_ID + " on " + day + "</h1>"; data_dir = "/mnt/ams2/SD/proc2/" + day + "/data/" image_dir = "/mnt/ams2/SD/proc2/" + day + "/images/" video_dir = "/mnt/ams2/SD/proc2/" + day + "/hd_save/" meteor_files = glo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writeHTMLbody(appurl, numberOfCompletedFiles, stoppedState, componentList, dayStart, dayEnd):\n html = u'''\\\n<html>\n <head></head>\n <body>\n <p>Kære Operatør</p>\n <p>\n Her en rapport over hvordan det er gået med opsamling af YouSee\n TV i det seneste døgn. Informationerne i denn...
[ "0.6014922", "0.5980289", "0.5916077", "0.5734094", "0.5610235", "0.5561521", "0.55389494", "0.55242777", "0.5508221", "0.54680556", "0.54221916", "0.5414351", "0.54111207", "0.539427", "0.5379795", "0.5355775", "0.53470993", "0.534335", "0.53360784", "0.5315552", "0.5308816"...
0.49489394
76
get datatitanic feature engineering result
def get_titanic_fea(dataset): dataset['Name_length'] = dataset['Name'].apply(len) # Mapping Sex 不在map定义的 就是NaN dataset['Sex'] = dataset['Sex'].map({'female': 0, 'male': 1}).astype(int) dataset['Has_Cabin'] = dataset['Cabin'].apply(lambda x: 0 if type(x) == float else 1) dataset['FamilySize'] = dat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feature_engineering(data):\n ft, nt, pruefung, training, version, vt, zt = get_testposition(data[\"Testposition\"])\n HA, Self, HA_nt, HA_vt, HA_zt = get_HA(data[\"HA\"])\n wochentag, ist_schulzeit = get_datetime_fields()\n sex_m, sex_w = get_sex(data[\"Sex\"])\n jahredabei = get_jahre_dabei(dat...
[ "0.66658264", "0.6181846", "0.61572766", "0.6148501", "0.60842323", "0.60698855", "0.6047452", "0.60049474", "0.59855366", "0.59295857", "0.59173936", "0.589615", "0.5892659", "0.58738184", "0.5871625", "0.5870629", "0.58673483", "0.5862045", "0.58589894", "0.5845185", "0.581...
0.559091
38
Updates settings in TopView and triggers a redraw.
def update_settings(self): settings = { "reference": self, "draw_tangents": self.cbDrawTangents.isChecked(), } if self.cbShowSolarAngle.isChecked(): settings["show_solar_angle"] = self.cbSolarAngleType.currentText(), self.cbSolarBody.currentText() else...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateSettingsUI(self):\n\n pass", "def update(self):\n self.active = False\n self.top.update(self.rgb,self.cmyk,self.hsv)\n self.bot.update(self.rgb,self.cmyk,self.hsv)\n self.active = True", "def UpdateUI(self):\n # colors & font\n self.SetBackgroundColour...
[ "0.6638624", "0.6337346", "0.61559534", "0.6116857", "0.60962045", "0.60954", "0.6090623", "0.6031026", "0.60115486", "0.59824395", "0.5955727", "0.59068084", "0.59050995", "0.5873285", "0.58553267", "0.58553267", "0.5830154", "0.5823889", "0.5820076", "0.58084303", "0.580387...
0.6364625
1
Computes Tangent points of limb sounders aboard the aircraft
def compute_tangent_lines(self, bmap, wp_vertices, wp_heights): x, y = list(zip(*wp_vertices)) wp_lons, wp_lats = bmap(x, y, inverse=True) if bmap.projection == "cyl": # hack for wraparound wp_lons = normalize_longitude(wp_lons, -180, 180) fine_lines = [bmap.gcpoints2( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buildTangents( points , averaged=True, isClosing=False):\n tangents = numpy.zeros( (len(points),2) )\n i=1\n tangents[:-i] += points[i:] - points[:-i] # i <- p_i+1 - p_i \n tangents[i:] += points[i:] - points[:-i] # i <- p_i - p_i-1\n if isClosing:\n tangents[0] += tangents[0] - tangents...
[ "0.6392705", "0.63793325", "0.5986296", "0.5917323", "0.57991946", "0.5788517", "0.5762938", "0.57296056", "0.5694058", "0.56526256", "0.5648896", "0.56463647", "0.56098217", "0.56055284", "0.5594248", "0.5535556", "0.5519586", "0.5510969", "0.5496143", "0.54937667", "0.54800...
0.585564
4
Computes coloured overlay over the flight path that indicates the danger of looking into the sun with a limb sounder aboard the aircraft.
def compute_solar_lines(self, bmap, wp_vertices, wp_heights, wp_times, solartype): # calculate distances and times body, difftype = solartype times = [datetime_to_jsec(_wp_time) for _wp_time in wp_times] x, y = list(zip(*wp_vertices)) wp_lons, wp_lats = bmap(x, y, inverse=True) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_tfl_lights(image: np.ndarray):\n kernel = np.array(\n [[0, 0, 0],\n [0, 0, 0],\n [0, 1, 0],\n [1, 3, 1],\n [0, 1, 0]])\n\n kernel = kernel - kernel.mean()\n\n red_image = image.copy()\n red_image = red_image[:, :, 0]\n _, red_image = cv2.threshold(red_...
[ "0.5856036", "0.577144", "0.55132717", "0.55071807", "0.5418471", "0.5381328", "0.537577", "0.5362233", "0.5343238", "0.5297552", "0.5258092", "0.5255616", "0.5250201", "0.52456754", "0.52210706", "0.52202874", "0.5201753", "0.52011275", "0.51957077", "0.5158769", "0.515049",...
0.0
-1
Computes coordinates of tangent points given coordinates of flight path.
def tangent_point_coordinates(self, lon_lin, lat_lin, flight_alt=14, cut_height=12): med_lon = np.median(lon_lin) lon_lin = normalize_longitude(lon_lin, med_lon - 180, med_lon + 180) lins = list(zip(lon_lin[0:-1], lon_lin[1:], lat_lin[0:-1], lat_lin[1:])) lins = [(x0 * np.cos(np.deg2rad(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tangent(self, p):\n p = array(p, float)\n v = (p - self.o)\n v /= norm(v)\n b = self.o + ((cross(v, self.N) - v) / 3)*self.r\n mb = _mirror_(self.o, p, b) \n mbb = mb - b\n return mbb/norm(mbb)", "def to_tangent(self, vector, base_point):\n tangent_vec ...
[ "0.64119583", "0.62860763", "0.62766653", "0.6097216", "0.60910517", "0.6090201", "0.6041448", "0.6013547", "0.59927946", "0.5969202", "0.5915505", "0.59119284", "0.58881056", "0.5871481", "0.5823385", "0.5801728", "0.57816553", "0.57736695", "0.57451314", "0.5734588", "0.570...
0.6730327
0
Computes coordinates of tangent points given coordinates of flight path.
def direction_coordinates(self, gc_lines): lins = [(_line[0][mid], _line[0][mid + 1], _line[1][mid], _line[1][mid + 1]) for _line, mid in zip(gc_lines, [len(_line[0]) // 2 for _line in gc_lines]) if len(_line[0]) > 2] lens = [np.hypot(_line[0][0] - _line[0][-1], _line[0][...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tangent_point_coordinates(self, lon_lin, lat_lin, flight_alt=14, cut_height=12):\n med_lon = np.median(lon_lin)\n lon_lin = normalize_longitude(lon_lin, med_lon - 180, med_lon + 180)\n lins = list(zip(lon_lin[0:-1], lon_lin[1:], lat_lin[0:-1], lat_lin[1:]))\n lins = [(x0 * np.cos(np...
[ "0.6730327", "0.64119583", "0.62860763", "0.62766653", "0.6097216", "0.60910517", "0.6090201", "0.6041448", "0.6013547", "0.59927946", "0.5969202", "0.5915505", "0.59119284", "0.58881056", "0.5871481", "0.5823385", "0.5801728", "0.57816553", "0.57736695", "0.57451314", "0.573...
0.5026742
92
Calculates the angular distance between given directions under the condition that the sun is above the horizon.
def calc_view_rating(obs_azi, obs_ele, sol_azi, sol_ele, height, difftype): delta_azi = obs_azi - sol_azi delta_ele = obs_ele - sol_ele if "horizon" in difftype: thresh = -np.rad2deg(np.arccos(EARTH_RADIUS / (height + EARTH_RADIUS))) - 3 if sol_ele < thresh: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wind_bearing(self) -> float:\r\n return self._first_timeserie[\"data\"][\"instant\"][\"details\"][\r\n \"wind_from_direction\"\r\n ]", "def manhatam_distance(self) -> int:\n return abs(self.north) + abs(self.east)", "def distance_between_wheels():", "def calc_wdir(u,v):\n ...
[ "0.6064235", "0.5968686", "0.59022677", "0.5732977", "0.57161665", "0.56307954", "0.5567947", "0.5544834", "0.5523047", "0.5511551", "0.5506899", "0.5485641", "0.54762894", "0.5461327", "0.53818095", "0.5378092", "0.5377965", "0.53136206", "0.5282288", "0.526286", "0.5260875"...
0.0
-1
This method returns the currently active IOManager instance, or creates a new one if none exists
def IOManager(): global _iom_instance global _iom_shutdown if _iom_instance: return _iom_instance if _iom_shutdown or _iom_shutdown is None: raise Exception("Should not call IOManager after shutdown") _iom_instance = _IOManager() _IOManager.set_signal_handlers([signal.SIGINT, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ioserver(self) -> _IOManager:\n return self._iomanager", "def new_manager() -> SyncManager:\n return Manager()", "def GetManager(self):\r\n\r\n return self.manager", "def get_instance(cls):\n global FW_MANAGER_API\n if not FW_MANAGER_API:\n FW_MANAGER_API = cls()...
[ "0.7698565", "0.6525439", "0.6344778", "0.6328575", "0.63087434", "0.6188434", "0.61720836", "0.6109373", "0.5934774", "0.5931367", "0.5905049", "0.5869388", "0.58146125", "0.56089675", "0.5588589", "0.5574307", "0.5538294", "0.5504296", "0.54978806", "0.54878485", "0.5487848...
0.66689914
1
This method clears the IOManager instance currently active, if any
def clear_IOM(): global _iom_instance if _iom_instance: _iom_instance.stop() if threading.current_thread() != _iom_instance: _iom_instance.join() _iom_instance = None _IOManager.restore_signal_handlers()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n # Orphan all objects\n for obj in self.uow:\n state(obj).session = None\n self.uow.clear()\n self.imap.clear()", "def reset(self):\n self.destroy()\n self.open()", "def close(self):\n self._available = False\n self._io_manage...
[ "0.67583764", "0.6700083", "0.66260433", "0.6534188", "0.64129114", "0.6411327", "0.6398604", "0.6225837", "0.6192987", "0.61438346", "0.61311615", "0.6116497", "0.61151767", "0.6108931", "0.6102664", "0.6092479", "0.60895723", "0.6066649", "0.60661376", "0.6043499", "0.60384...
0.7886593
0
This handler will stop the IOManager on interpreter exit. It will set the shutdown flag to True and run clear_IOM.
def __atexit_handler(): global _iom_shutdown _iom_shutdown = True clear_IOM()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shutdown_manager(self):\n # pylint: disable=E1101\n self.shutdown() # type: ignore\n # pylint: enable=E1101", "def exit_handler(self):\n self.logger.debug(\n \"Starting script shutdown in the class \" +\n self.__class__.__name__\n )\n\n # Clean...
[ "0.6671942", "0.6663697", "0.6621949", "0.6565478", "0.6563746", "0.6546713", "0.65447253", "0.6509654", "0.6466096", "0.6458403", "0.64495385", "0.64292604", "0.64199954", "0.6417803", "0.6410902", "0.6401739", "0.6390104", "0.638613", "0.63592774", "0.63264143", "0.63257796...
0.8109695
0
This method can be registered as a signal handler and will terminate the IOManager thread on the signal and call the original signal handler.
def signal_handler(cls, signum, frame): global _iom_instance # Find name of signal signame = str(signum) for key in signal.__dict__.keys(): if key.startswith("SIG") and getattr(signal, key) == signum: signame = key break try: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signal_handler(signum, frame):\n main.CLOSE = True", "def _signal_handler(*_: typing.Any) -> None:\n shutdown_event.set()", "def signal(self):\n self.mainloop().signal()", "def sigint_handler(signal, frame):\n rclpy.shutdown()\n if prev_sigint_handler is not None:\n prev_sigint_...
[ "0.7207195", "0.7170434", "0.7115355", "0.7054465", "0.7031309", "0.70231557", "0.70108473", "0.6952786", "0.6932358", "0.6926428", "0.68975925", "0.6876757", "0.68614537", "0.6856073", "0.68490416", "0.6838871", "0.6832425", "0.6823985", "0.68018293", "0.6773629", "0.6724269...
0.7621493
0
This method is called whenever a IOManager is instantiated. It sets the signal_handler to be the handler for a set of signals to stop the thread when they arrive.
def set_signal_handlers(cls, signals): for sig in signals: try: original_handler = signal.getsignal(sig) if original_handler == cls.signal_handler: continue signal.signal(sig, cls.signal_handler) cls.__signal_handler...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_signal_handler(self) -> None:\r\n loop = asyncio.get_running_loop()\r\n # get interupt signals supported by user's OS.\r\n signals = [getattr(signal, s) for s in (\r\n 'SIGBREAK', 'SIGINT', 'SIGTERM', 'SIGHUP') if hasattr(signal, s)]\r\n for s in signals:\r\n ...
[ "0.6817427", "0.6538489", "0.64577276", "0.61924624", "0.61902976", "0.6181113", "0.6163753", "0.6090798", "0.6042454", "0.597119", "0.59546494", "0.5951743", "0.59432435", "0.5930009", "0.5922619", "0.5829607", "0.5799968", "0.5792957", "0.5750904", "0.574089", "0.57047683",...
0.5322302
49
This method is called when a IOManager thread ends to restore the original behavior.
def restore_signal_handlers(cls): signals = cls.__signal_handlers.keys() for sig in signals: try: signal.signal(sig, cls.__signal_handlers[sig]) except Exception as e: pass cls.__signal_handlers = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_reset_after_execution(self):\n pass", "def async_reset(self) -> None:", "def sync_end(self):", "def afterWork(self):\n pass", "def end(self):\n #self.manipulator_restore()\n #self.header_text_restore()\n #self.cursor_modal_restore()\n pass", "def on_cleanup(...
[ "0.6445182", "0.637332", "0.62031007", "0.6166421", "0.6166274", "0.61425656", "0.6142068", "0.6139438", "0.61386204", "0.613159", "0.6103942", "0.60389787", "0.60346854", "0.6015365", "0.6005893", "0.6002341", "0.5995557", "0.59931254", "0.59931254", "0.5992719", "0.5987215"...
0.0
-1
Stop the IOManager thread when the object is deleted.
def __del__(self): self.stop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __del__(self):\n if self.running:\n self.stop()", "def __del__(self):\n self.shutdown()", "def stop(self):\n self._Thread__stop()", "def __del__(self):\n self.motorStop()\n GPIO.cleanup()", "def __del__(self):\n self.disconnect()", "def lock_delete(s...
[ "0.7355407", "0.6769922", "0.663857", "0.6621683", "0.66111404", "0.65707177", "0.6567212", "0.65458006", "0.65412396", "0.6519639", "0.6516644", "0.6500565", "0.64998776", "0.6485494", "0.6417872", "0.6413109", "0.6394764", "0.6394764", "0.63827056", "0.63687885", "0.6367023...
0.73901945
3
Set up the IOManager thread and start it.
def __init__(self): super(_IOManager, self).__init__() self.__poll = iopoll.IOPoll() self.__et = self.__poll.set_edge_triggered(True) self.__wrappers = {} self.__disconnected_wrappers = [] self.__running = True self.__wrapper_lock = threading.RLock() sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _start_io_event_loop(self):\r\n self._event_loop_started = threading.Lock()\r\n self._event_loop_started.acquire()\r\n threading.Thread(None, self._io_event_loop_thread).start()\r\n self._event_loop_started.acquire()", "def start(self):\n\n # ioloop.install()\n threa...
[ "0.74360424", "0.71200305", "0.70094883", "0.6825649", "0.67651063", "0.66524005", "0.66524005", "0.6649809", "0.6606698", "0.65546614", "0.6520184", "0.6413288", "0.6413288", "0.6407481", "0.6396625", "0.6396582", "0.6340354", "0.6314484", "0.6298781", "0.62838554", "0.62762...
0.7044002
2
This method will be called when the thread starts. It wraps the _run method to make it possible to profile the IOManager.
def run(self): if not self.__class__.profile is None: import cProfile cminstance = self cProfile.runctx('self._run()', globals(), locals(), self.__class__.profile) else: self._run()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n self.started()", "def __run(self):\n sys.settrace(self.globaltrace) # set self.globaltrace before thread start\n self.__run_backup()\n self.run = self.__run_backup", "def startup_run(self):\n raise NotImplementedError # implement in subclass", "def _start...
[ "0.6828915", "0.680916", "0.6805878", "0.66512567", "0.6584526", "0.6556901", "0.65331644", "0.65176994", "0.65038", "0.6494421", "0.64460075", "0.64399743", "0.6406046", "0.64020944", "0.64020944", "0.63957137", "0.63918793", "0.63672525", "0.6362143", "0.6357723", "0.634809...
0.64420706
11
This method is the main thread of the IOManager. It polls all active IOWrappers and calls their read and write handlers when data can be read or written. It will also try to connect any unconnected IOWrappers that have been registered.
def _run(self): global _iom_instance self.__logger.info("IOManager started") timeout = 0 while self.__running: # Poll for events if self.__et: self.__poll_et() else: self.__poll_lt() # Perform IOWrapper chec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n\n super(_IOManager, self).__init__()\n self.__poll = iopoll.IOPoll()\n self.__et = self.__poll.set_edge_triggered(True)\n self.__wrappers = {}\n self.__disconnected_wrappers = []\n self.__running = True\n\n self.__wrapper_lock = threading.RLock...
[ "0.72020644", "0.6404343", "0.6323055", "0.613848", "0.5930006", "0.5890055", "0.57467985", "0.5727425", "0.56816876", "0.5658827", "0.5594921", "0.55433446", "0.5537435", "0.5534609", "0.5534609", "0.55324864", "0.55123097", "0.5511399", "0.5455873", "0.54299587", "0.5427040...
0.7329676
0
After polling and updating of the ready lists has completed the function iterates over the file descriptors ready for reading and writing. The _handle_read and _handle_write of each file descriptor wrapper will be called roundrobin in a loop, for as long as the current tick lasts. If the file descriptors become nonread...
def __perform_io_et(self, max_time): # Perform IO on ready file descriptors start = time.time() while time.time() < start + max_time: if not self.__read_list and not self.__write_list: break # Handle file descriptors ready for reading read_fds...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _poll(self):\n if self.selector.get_map(): # Pray it doesn't block\n # We can block as long as we want if theres no tasks to process till we're done\n # We want our currently ready files\n if not self._tasks or self._queue:\n if self._timers:\n ...
[ "0.59377813", "0.59214854", "0.55150586", "0.5487273", "0.53215456", "0.5306082", "0.5305153", "0.52936137", "0.5274444", "0.5273521", "0.5254349", "0.5227428", "0.52225745", "0.521662", "0.5181105", "0.5173039", "0.51649815", "0.5164472", "0.5151223", "0.5100448", "0.5085929...
0.6719054
0
This method checks if the fd is the wakeup pipe, and if so, reads the data from that pipe.
def __check_wakeup(self, fd, num): if fd == self.__wakeup_read: if num == 1: # Was woken up, count savings. self.__last_tick_end # if the time the poll would have ended if it was # not awoken by the wakeup pipe. self.__saved_time += sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self):\n if self.alive:\n with self._register_poll():\n with _unblock_read(self._proc):\n return self._yield_ready_read()\n else:\n raise ProcessIsDeadError('Can not read. The process is already dead.')", "def handle_fd_wakeup(self, f...
[ "0.6059474", "0.5925316", "0.584181", "0.57787955", "0.5770543", "0.5589297", "0.5565441", "0.5561058", "0.55366427", "0.5456041", "0.5398647", "0.5317475", "0.5312273", "0.5296096", "0.52547514", "0.5235931", "0.5193808", "0.5187531", "0.51835066", "0.5122953", "0.50859684",...
0.6730117
0
This method calls the handle_loop function of each wrapper, once every true tick. This should be at the frequency of the ticker, about 10 times per second.
def __handle_loop(self): with self.__wrapper_lock: for wrapper in self.__wrappers.values(): self.__wrap_function(wrapper, "_handle_loop")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _handle_loop(self):\n pass", "def loop(self):\n pass", "def tick(self):\n for method in self.on_ticker:\n getattr(self, method)()", "def loop(self):\n while True:\n delay_until_next = self.tick()\n if not delay_until_next:\n brea...
[ "0.64973104", "0.64548576", "0.64116734", "0.63547313", "0.6350633", "0.62593937", "0.6253672", "0.6138138", "0.6093034", "0.60708076", "0.6063108", "0.6000306", "0.5996489", "0.5970046", "0.5959777", "0.595509", "0.5947199", "0.58936435", "0.58918947", "0.5885203", "0.587622...
0.73193914
0
This method calls a function on the wrapper in a try/except block. This is to make sure the IOManager will keep on running even when exceptions occur in one of the wrappers. This will prevent from the complete system to collapse when one IOWrapper fails.
def __wrap_function(self, wrapper, funcname): try: function = getattr(wrapper, funcname) return function() except Exception as err: self.__handle_exception(wrapper, funcname, err) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __handle_exception(self, wrapper, method, exception):\n # First print the normal exception output\n #traceback.print_exc()\n\n self.__logger.critical(\"Exception raised in %s in IOWrapper %s. \" \\\n \"Removing IOWrapper from IOManager. The \" \\\n ...
[ "0.69837755", "0.6610055", "0.6577397", "0.63594145", "0.6054665", "0.60317206", "0.58830297", "0.58719325", "0.5851649", "0.57956946", "0.5773262", "0.574262", "0.57129633", "0.57051915", "0.5691588", "0.5672247", "0.5664732", "0.56170017", "0.55975455", "0.5587568", "0.5570...
0.5509951
23
This method calls a function on the wrapper in a try/except block. This is to make sure the IOManager will keep on running even when exceptions occur in one of the wrappers. This will prevent from the complete system to collapse when one IOWrapper fails. The difference with this function and __wrap_function is that thi...
def __wrap_function_io(self, wrapper, funcname): try: function = getattr(wrapper, funcname) return function() except IOWrapperEnd: # Expected exception when no more data can be read or written if self.__et: # poll_et needs this to update ready list ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __handle_exception(self, wrapper, method, exception):\n # First print the normal exception output\n #traceback.print_exc()\n\n self.__logger.critical(\"Exception raised in %s in IOWrapper %s. \" \\\n \"Removing IOWrapper from IOManager. The \" \\\n ...
[ "0.7079343", "0.6734453", "0.5904045", "0.5741803", "0.573452", "0.5708396", "0.5700704", "0.5695424", "0.5689182", "0.56592643", "0.5600514", "0.5544569", "0.55219084", "0.5493219", "0.5482397", "0.54791456", "0.5455687", "0.5441942", "0.54216826", "0.53943896", "0.5390842",...
0.6724944
2
This method is called whenever an exception has occured in any of the wrappers functions. It outputs the message and removes the wrapper from the IOManager.
def __handle_exception(self, wrapper, method, exception): # First print the normal exception output #traceback.print_exc() self.__logger.critical("Exception raised in %s in IOWrapper %s. " \ "Removing IOWrapper from IOManager. The " \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_expt(self):\r\n self._perform_on_error_handling()", "def __cleanup(self):\n wrappers = copy.copy(self.__wrappers)\n\n num = len(wrappers)\n for fd in wrappers:\n wrappers[fd].close()\n\n self.__wrappers = {}\n self.__disconnected_wrappers = []\n ...
[ "0.5796533", "0.5781985", "0.57516783", "0.57218486", "0.56933635", "0.5625278", "0.5609338", "0.5575694", "0.5547018", "0.554088", "0.55381966", "0.552271", "0.552271", "0.55152225", "0.5510325", "0.5500664", "0.54709405", "0.542822", "0.54094625", "0.54007", "0.5381929", ...
0.7543375
0
Helper method for the main thread. Attempt to connect unconnected wrappers
def __attempt_wrappers(self): with self.__wrapper_lock: sock_list = self.__disconnected_wrappers for wrapper in sock_list: if not self.__wrap_function(wrapper, "connected"): self.__wrap_function(wrapper, "_handle_attempt")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.try_to_connect()", "def reconnect(self):\n raise NotImplementedError()", "def reconnect(self):\n\t\t# TODO: Make sure the remote devices are actually found?\n\t\tself.setup()\n\t\tself.patch()", "def reconnecting(self) -> bool:", "def connect_thread():\n return f...
[ "0.64431804", "0.62675923", "0.62119734", "0.6136976", "0.60975665", "0.6084777", "0.60635346", "0.60544574", "0.59910864", "0.59895176", "0.5947471", "0.5933719", "0.5890628", "0.5878055", "0.5876207", "0.5851456", "0.58358234", "0.58204126", "0.57915825", "0.57911247", "0.5...
0.6719007
0
Check if there are any registered IOWrappers, and if not, stop running after 30 seconds. Also stop if the parent thread ended to make sure the interpreter does not keep running just for the IOManager.
def __check_stop(self): if not self.__parent_thread.is_alive(): global _iom_shutdown self.__logger.info("Parent thread ended. Stopping IOManager.") _iom_shutdown = True self.__running = False if not self.__wrappers and not self.__disconnected_wrappers and...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run(self):\n global _iom_instance\n self.__logger.info(\"IOManager started\")\n timeout = 0\n while self.__running:\n # Poll for events\n if self.__et:\n self.__poll_et()\n else:\n self.__poll_lt()\n\n # Perf...
[ "0.6366383", "0.57110745", "0.5528167", "0.54710895", "0.5455402", "0.54529166", "0.5441537", "0.5420318", "0.54132575", "0.5391293", "0.53664964", "0.53484637", "0.5341384", "0.53394556", "0.5324404", "0.5323673", "0.529864", "0.5285029", "0.5271595", "0.5261558", "0.5254184...
0.78956103
0
This method will close all open file descriptor wrappers, and clean up the lists of the IOManager.
def __cleanup(self): wrappers = copy.copy(self.__wrappers) num = len(wrappers) for fd in wrappers: wrappers[fd].close() self.__wrappers = {} self.__disconnected_wrappers = [] self.__logger.info("Closed %d IOWrappers" % num) os.close(self.__wakeup_rea...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __del__(self):\n for handle in self._filehandles:\n handle.close()", "def _close(self):\n for fd in self._fds:\n try:\n os.close(fd)\n except:\n pass", "def close(self):\n for m in self._mappers:\n m.close()\n ...
[ "0.7514108", "0.7498143", "0.732576", "0.72181565", "0.7003081", "0.6941212", "0.69345033", "0.6913506", "0.689964", "0.68566614", "0.68230253", "0.67590755", "0.67090476", "0.66836107", "0.6683077", "0.66567516", "0.66393477", "0.663894", "0.66197586", "0.6617457", "0.649656...
0.8179671
0
Return the file descriptor wrapper object belonging to the specified file descriptor
def __find_wrapper(self, fd): with self.__wrapper_lock: if fd in self.__wrappers: return self.__wrappers[fd] with self.__poll_lock: if self.__poll.is_known(fd): self.__logger.warning("Cannot find wrapper object belonging to " \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_descriptor(self):\n return self._file_descriptor", "def get_fd(self, target):\n return target.fileno() if 'fileno' in dir(target) else target", "def as_file_descriptor(fd_or_fname: Union[str, io.IOBase], mode: str = 'r') -> io.IOBase:\n if type(fd_or_fname) is str:\n return sys...
[ "0.7286407", "0.71450967", "0.6965853", "0.6604872", "0.66034746", "0.6305489", "0.62961644", "0.62359", "0.6224803", "0.60508865", "0.60166526", "0.59716743", "0.594537", "0.59389013", "0.59326965", "0.5919888", "0.5863128", "0.5839114", "0.58325076", "0.57683665", "0.575988...
0.618339
9
This method validates the wrapper to be an instance of the IOWrapper base class, making sure it implements the required methods. It will raise an exception if the wrapper is invalid.
def __validate_wrapper(self, wrapper): if not isinstance(wrapper, IOWrapper): raise Exception("Only subclasses of IOWrapper should be registered in the IOManager")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __handle_exception(self, wrapper, method, exception):\n # First print the normal exception output\n #traceback.print_exc()\n\n self.__logger.critical(\"Exception raised in %s in IOWrapper %s. \" \\\n \"Removing IOWrapper from IOManager. The \" \\\n ...
[ "0.5546093", "0.54604685", "0.5411889", "0.5309438", "0.5097935", "0.5074125", "0.50426716", "0.5028937", "0.5028663", "0.50056034", "0.5000518", "0.49766174", "0.49689043", "0.49568233", "0.49489707", "0.49489707", "0.4896973", "0.48923403", "0.48844403", "0.4847181", "0.482...
0.8688556
0
This method wakes up the current call to poll by writing a zero byte to the wakeup pipe. This will wake the poller and increase the speed at which the lock is released.
def __wakeup(self): os.write(self.__wakeup_write, "\x00")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wake_up(self):\r\n self._write.send('1')", "def wake_up(self):\n self._write.send(b'1')", "def wakeup(self):\n self.waker.notify()", "def wake(self):\n self.timeout_set(0) # Reset timeout counter\n self.write(255) # Wake\n\n if self._firmware >= 264:\n ...
[ "0.6200318", "0.61424816", "0.60313165", "0.592887", "0.58623546", "0.57935506", "0.5555034", "0.5547922", "0.54821897", "0.54446363", "0.53919256", "0.5354077", "0.5333378", "0.5275664", "0.5257908", "0.52261096", "0.5193175", "0.5160611", "0.511783", "0.5045297", "0.5030981...
0.5534405
8
Register a connected file descriptor wrapper
def register(self, wrapper): self.__validate_wrapper(wrapper) fd = self.__wrap_function(wrapper, "fileno") if not type(fd) is type(0): self.__logger.error("Cannot register IOWrapper with file descriptor %s" % repr(fd)) return False with self.__wrapper_lock: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register(self, fd):\n if fd not in self._fds:\n self._fds.append(fd)", "def add_descriptor(self, descriptor):", "def attach_filedescriptor(self, filedesc):\n self._filedescriptor = filedesc", "async def register(self, fd: FileDescriptor, events: EPOLL,\n cb:...
[ "0.64342827", "0.62055624", "0.6110365", "0.6007258", "0.5854498", "0.5718946", "0.56768453", "0.5648945", "0.5648945", "0.5624154", "0.56074166", "0.55798113", "0.5561913", "0.55372834", "0.5466594", "0.5397645", "0.53729844", "0.5352667", "0.53021127", "0.52466935", "0.5202...
0.73034364
0
Register a disconnected file descriptor wrapper that needs its _attempt method to be called at a regular interval.
def register_unconnected(self, wrapper): self.__validate_wrapper(wrapper) with self.__wrapper_lock: self.__logger.debug("Registering disconnected IOWrapper") self.__disconnected_wrappers.append(wrapper) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register(self, wrapper):\n self.__validate_wrapper(wrapper)\n fd = self.__wrap_function(wrapper, \"fileno\")\n if not type(fd) is type(0):\n self.__logger.error(\"Cannot register IOWrapper with file descriptor %s\" % repr(fd))\n return False\n with self.__wrapp...
[ "0.59026706", "0.55204797", "0.5341881", "0.5245475", "0.52327204", "0.52327204", "0.5181297", "0.51777464", "0.50116295", "0.5001589", "0.49905667", "0.48477736", "0.48344794", "0.4818529", "0.48130843", "0.4807283", "0.48045424", "0.4798308", "0.4786231", "0.4742031", "0.47...
0.56404316
1
Unregister a file descriptor wrapper, usually because it has been disconnected or closed.
def unregister(self, wrapper): self.__validate_wrapper(wrapper) found = False fd = self.__wrap_function(wrapper, "fileno") if not type(fd) is type(0): self.__logger.error("Cannot unregister IOWrapper with file descriptor %s" % repr(fd)) return False with ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unregister(self, fd):\n self.poller.unregister(fd)", "def unregister(self, fd):\n self.poller.unregister(fd)", "def unregister(self, fd):\n if fd in self._fds:\n self._fds.remove(fd)", "def remove_descriptor(self, fileno):\n self.listeners[READ].pop(fileno, None)\n ...
[ "0.72940564", "0.72940564", "0.70253867", "0.66749716", "0.6640618", "0.64988714", "0.6204748", "0.6200317", "0.6153142", "0.6145244", "0.6072479", "0.6006315", "0.5988268", "0.59799767", "0.5932645", "0.5908495", "0.58961105", "0.5864231", "0.5809946", "0.57125515", "0.56913...
0.79327255
0
Unregister an unconnected file descriptor wrapper, usually because it has succesfully opened/connected or because it is no longer needed.
def unregister_unconnected(self, wrapper): self.__validate_wrapper(wrapper) with self.__wrapper_lock: if wrapper in self.__disconnected_wrappers: self.__disconnected_wrappers.remove(wrapper) return True else: self.__logger.warning("...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unregister(self, wrapper):\n self.__validate_wrapper(wrapper)\n found = False\n fd = self.__wrap_function(wrapper, \"fileno\")\n if not type(fd) is type(0):\n self.__logger.error(\"Cannot unregister IOWrapper with file descriptor %s\" % repr(fd))\n return False...
[ "0.7516931", "0.6932183", "0.6932183", "0.6672085", "0.6633065", "0.6464714", "0.6444078", "0.6234741", "0.61665344", "0.61642176", "0.6150731", "0.6091415", "0.6089481", "0.601867", "0.60160476", "0.5773837", "0.5757351", "0.5747841", "0.5737379", "0.57177335", "0.5711948", ...
0.73670936
1
Marks the file descriptor as writable in the poller
def set_writable(self, wrapper, writable): self.__validate_wrapper(wrapper) fd = self.__wrap_function(wrapper, "fileno") if type(fd) is type(0): self.__wakeup() with self.__poll_lock: try: self.__poll.modify(fd, True, writable, True) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writable(name):", "def writable(self):\n ...", "def writable(path):", "def set_data_writable(self):\n pass", "def writable(self):\n return True", "def make_writeable(filename):\n if sys.platform.startswith('java'):\n # On Jython there is no os.access()\n ...
[ "0.6926017", "0.68552274", "0.65640175", "0.628673", "0.6203078", "0.61750156", "0.61536247", "0.6150798", "0.6146159", "0.60953534", "0.6092632", "0.6038486", "0.5971263", "0.59446305", "0.58429897", "0.5816304", "0.56790227", "0.56523734", "0.5646463", "0.5605246", "0.56032...
0.7544291
0
Stop the IOManager. This will set the running flag to false, which should terminate the IOManager thread in a short timespan.
def stop(self): self.__running = False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop(self):\n self._run = False\n self.IA.stop()", "def stop(self):\n self._running = False", "def stop(self):\n self._running = False", "def stop(self) -> None:\n self._running = False", "def stop(self):\n with self._lock:\n self._running.clear()\n ...
[ "0.7407258", "0.73312134", "0.73312134", "0.7321287", "0.72551525", "0.7187192", "0.7187192", "0.7187192", "0.7187192", "0.7187192", "0.71809447", "0.713626", "0.713626", "0.711165", "0.70648855", "0.70051324", "0.7004732", "0.6987879", "0.6959247", "0.6959247", "0.6959247", ...
0.7348014
1
This method should close the file descriptor.
def close(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\r\n self._fd.close()", "def _close(self):\n self.fh.close()", "def close(self):\n os.close(self.fd)", "def close(self):\n os.close(self.fdWrite)", "def close(self):\n os.close(self.fdWrite)", "def close(self):\n os.close(self.fdWrite)", "def _c...
[ "0.7605753", "0.7402619", "0.73371327", "0.7204997", "0.7204997", "0.7204997", "0.7158271", "0.710828", "0.69746006", "0.692794", "0.6922735", "0.68033993", "0.6779868", "0.67775816", "0.67525387", "0.67400956", "0.6723742", "0.6723742", "0.6723742", "0.6723742", "0.6723742",...
0.64909166
89
This method should return the file descriptor associated with the wrapper, to be registered in the IO Poll object.
def fileno(self): return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __find_wrapper(self, fd):\n with self.__wrapper_lock:\n if fd in self.__wrappers:\n return self.__wrappers[fd]\n with self.__poll_lock:\n if self.__poll.is_known(fd):\n self.__logger.warning(\"Cannot find wrapper object belonging to ...
[ "0.6799083", "0.6625334", "0.64499575", "0.6371323", "0.6279051", "0.61178285", "0.6040341", "0.5963289", "0.5941422", "0.5915336", "0.5891764", "0.588181", "0.5879061", "0.58350354", "0.5829187", "0.58112043", "0.5807162", "0.5807162", "0.5807162", "0.5786799", "0.5746828", ...
0.50989753
60
This method should return True when the wrapper has an open file descriptor, and False when it's not connected.
def connected(self): return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_open(self):\n return self._socket is not None", "def is_open(self):\n\t\treturn self.conn.open", "def is_open(self):\n return self.stream.is_open()", "def can_open_stream(self):\n return True", "def is_open(self) -> bool:\n return self._connection is not None", "def is_...
[ "0.7882163", "0.7750182", "0.7552568", "0.754683", "0.75396127", "0.7478334", "0.7461147", "0.72868925", "0.72610456", "0.72236586", "0.7161832", "0.71361506", "0.7039435", "0.70343107", "0.69845927", "0.6971223", "0.6915318", "0.6902555", "0.6877083", "0.6875769", "0.6862824...
0.62585795
86
This method will be called whenever the file descriptor is readable.
def _handle_read(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_read(self):\n pass", "def on_readable(self):\n data = self.read(2048)\n if len(data) == 0:\n self.mark_down()\n if self.response is None:\n return\n else:\n self.response.on_connection_down(self)\n retur...
[ "0.73387545", "0.69494987", "0.6500824", "0.6464955", "0.63102823", "0.6290031", "0.62537575", "0.6229785", "0.61987466", "0.6165211", "0.6161047", "0.61076564", "0.60857755", "0.6050972", "0.60345066", "0.6018789", "0.6007374", "0.59776145", "0.5973924", "0.59695303", "0.596...
0.708658
1
This method will be called whenever the file descriptor is writable and has been set to be writable using the set_writable method of the IOManager.
def _handle_write(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writable(self):\n ...", "def set_data_writable(self):\n pass", "def writable(self):\n return True", "def set_writable(self, wrapper, writable):\n self.__validate_wrapper(wrapper)\n fd = self.__wrap_function(wrapper, \"fileno\")\n if type(fd) is type(0):\n ...
[ "0.7668859", "0.72399795", "0.70585614", "0.7040901", "0.69973457", "0.67973596", "0.66718215", "0.65625733", "0.65552163", "0.6530584", "0.6411131", "0.6370776", "0.62651396", "0.6228186", "0.6159805", "0.61561954", "0.61448884", "0.6143178", "0.6137905", "0.6137905", "0.605...
0.6958797
5
This method will be called when the connected method returns true, and the class has registered itself using the register method in the IOManager.
def _handle_loop(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected(self):\n pass", "def connected(self):\n pass", "def connected(self):\n _abstract()", "def connected(self):\n _abstract()", "def __connected(self):\n self.connected()\n if self.__callbacks.get(\"connected\"):\n cb = self.__callbacks[\"connecte...
[ "0.72842795", "0.72842795", "0.7219887", "0.7219887", "0.7126593", "0.71082824", "0.7094123", "0.70091665", "0.6758902", "0.67402714", "0.66984755", "0.66984755", "0.66984755", "0.66984755", "0.66984755", "0.66984755", "0.66984755", "0.66984755", "0.6633296", "0.6611846", "0....
0.0
-1
This method will be called at regular intervals when the wrapper has registered itself using the register_unconnected method of the IOManager and the connected method returns False.
def _handle_attempt(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_unconnected(self, wrapper):\n self.__validate_wrapper(wrapper)\n with self.__wrapper_lock:\n self.__logger.debug(\"Registering disconnected IOWrapper\")\n self.__disconnected_wrappers.append(wrapper)\n return True", "def unregister_unconnected(self, wra...
[ "0.74780333", "0.6770592", "0.64593047", "0.61647743", "0.6147918", "0.60868263", "0.60868263", "0.60763484", "0.5996702", "0.5958507", "0.5948301", "0.5932912", "0.59111786", "0.5881842", "0.58815527", "0.5847823", "0.5843601", "0.5843601", "0.58434093", "0.58274114", "0.581...
0.0
-1
Computes the accuracy over the k top predictions for the specified values of k
def accuracy(output, target, topk=(1,)): with torch.no_grad(): maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() correct = pred.eq(target.view(1, -1).expand_as(pred)) res = [] for k in topk: c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)", "def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua...
[ "0.8330957", "0.8284237", "0.82376367", "0.8229314", "0.8219836", "0.81859726", "0.8184298", "0.8174704", "0.8170969", "0.8169349", "0.81659627", "0.81640005", "0.8163328", "0.8161707", "0.8161707", "0.8161707", "0.8161707", "0.8161707", "0.8161707", "0.8161707", "0.8161707",...
0.78468007
98
render the potentially vulnerable code block
def render_block(data): snippet = data[2] title = data[0]['name'] description = data[0]['description'] block_type = data[0]['type'] # change the panel outline for # warnings and detections block_border = 'yellow' if block_type == 'warning' else 'red1' code_snippet = Syntax( snippet, SYNTAX, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unrendered(self) -> str:", "def block_code(self, code, lang=None):\n code = code.rstrip('\\n')\n return [\"<code>\"] + code", "def renderHTTP(self, ctx):\n return 'Keep trying. You are almost there.'", "def code():", "def DoMaliciousThings():\r\n\tprint(\"You are infected\")", "...
[ "0.6015911", "0.5981022", "0.59464854", "0.5932595", "0.58442914", "0.58003086", "0.56476384", "0.5602891", "0.5592425", "0.5590407", "0.55835813", "0.55495167", "0.5475325", "0.54703414", "0.5453699", "0.54517597", "0.5439034", "0.5437036", "0.5432236", "0.5416334", "0.54013...
0.5786832
6
render the blocks that make up the audit report
def render_report(blocks): for block in blocks: render_block( ( block[0], # signature block[1], # line number block[2], # line ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_block(data):\n\tsnippet = data[2] \n\ttitle = data[0]['name']\n\tdescription = data[0]['description']\n\tblock_type = data[0]['type']\n\t\n\n\t# change the panel outline for\n\t# warnings and detections\n\tblock_border = 'yellow' if block_type == 'warning' else 'red1'\n\n\tcode_snippet = Syntax(\n\t\t\t...
[ "0.62289196", "0.5903791", "0.5720958", "0.5665011", "0.5582263", "0.5578783", "0.5555787", "0.5538801", "0.55341536", "0.5489891", "0.54667926", "0.54592144", "0.5451408", "0.5437162", "0.54213434", "0.54210407", "0.54027796", "0.5376064", "0.53752387", "0.5314603", "0.53117...
0.7140696
0
Send a message to all contributors of the given campaign.
def message_contributors(request, campaign_id, form_class=messageforms.ComposeForm, template_name='messages/compose.html', success_url=None): campaign = get_object_or_404(Campaign.visible_objects, pk=campaign_id, artist__user_profile__user=request.user, is_approved=True) form = form_class() if request.me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_mass_messages(self, recipient_list, sender, message=\"\", subject=\"\"):\n try:\n for s in recipient_list:\n self.send_message(to=s, sender=sender, message=message, subject=subject)\n except TypeError:\n return -1\n return 1", "def send(self):\n ...
[ "0.59895015", "0.5723126", "0.55414027", "0.5496166", "0.54702157", "0.5385357", "0.5354316", "0.53353274", "0.5331929", "0.53257227", "0.5290182", "0.52430385", "0.52145374", "0.52112824", "0.51320004", "0.5124197", "0.5091597", "0.50726116", "0.50437075", "0.5014694", "0.50...
0.64192283
0
Show campaign summaries of logged in artist under the given category.
def list_artist_campaigns(request, category): # Sanity check if category not in ('unsubmitted', 'pending-approval', 'approved-upcoming', 'active', 'expired'): raise Http404 artist = request.user.get_profile().artist category = category.replace('-', '_') # DRY: Call template tag for the...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def view(request, category):\r\n return render(request, 'categories/view.html', {\r\n 'title': category.name,\r\n 'category': category,\r\n 'articles': Article.objects.select_related('author','author__profile','category').filter(category=category, status=Article.PUBLISHED),\r\n })", "d...
[ "0.57856625", "0.5675397", "0.56653684", "0.55892456", "0.5370637", "0.5199555", "0.51664764", "0.51587814", "0.50789976", "0.50553215", "0.5020364", "0.5019221", "0.49870524", "0.49827644", "0.49658126", "0.49644506", "0.4948786", "0.49370286", "0.49153695", "0.48407295", "0...
0.7150761
0
Process free campaign registration.
def contribute(request, campaign_id, template='campaign/campaign_contribution_form.html'): campaign = get_object_or_404(Campaign.objects.active(), pk=campaign_id) if not campaign.is_free: # Disable direct credit card based contribution request.user.message_set.create(message=_('That payment ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_freeform(self):\n try:\n safe_execute_command(self._prepare_freeform_reg_cmd(),\n self.freeform_log_file_path, self.freeform_error_file_path)\n except SafeExecuteCommandError as err:\n raise RegistrationError('Freeform registration fa...
[ "0.5581644", "0.5504613", "0.54512143", "0.5345784", "0.5285115", "0.5249719", "0.5249719", "0.5229771", "0.5177037", "0.5137388", "0.50815356", "0.50800085", "0.50467014", "0.50437224", "0.5027567", "0.5015311", "0.5009956", "0.50032485", "0.49973428", "0.4996586", "0.496805...
0.5190933
8
Process a PayPal or Google Checkout based contribution.
def contribute_by_payment_mode(request, campaign_id, payment_mode, template='campaign/campaign_contribution_form_%s.html'): campaign = get_object_or_404(Campaign.objects.active(), pk=campaign_id) payment_option = campaign.artist.get_merchant_account(payment_mode) if not payment_option: raise Htt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paypal_notification(request, payment_mode='paypal'):\r\n try:\r\n data = request.POST\r\n _log.debug(\"PayPal IPN data: %s\", repr(data))\r\n\r\n if not paypal.verify_ipn_request(request):\r\n return HttpResponse()\r\n\r\n if data.get('payment_status', None) != \"Compl...
[ "0.6142225", "0.58493024", "0.58211684", "0.5619037", "0.5387988", "0.53015286", "0.52222437", "0.5161513", "0.5132129", "0.51251936", "0.5114004", "0.5054638", "0.50287324", "0.5019555", "0.50136614", "0.49825796", "0.49805087", "0.4972348", "0.49634263", "0.49543017", "0.49...
0.58965725
1