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
Sample a batch of environment rollouts.
def sample_batch(models, env_constructor, device, config): # Initialize envs. envs = [SubProcessWrapper(env_constructor) for _ in range(config["SAMPLE_PARALLEL_ENVS"])] player_ids = list(models.keys()) # EpisodeData for in-progress episodes. # ep_datas[i][p_id] references the EpisodeData for play...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_rollouts(self, policy, batch_size=None, num_episodes=None,\n render=False):\n assert batch_size or num_episodes\n\n episodes = []\n env_need_reset = True\n episode_i = 0\n steps = 0\n while True:\n if env_need_reset:\n if batch_size and steps >= batch_s...
[ "0.6516522", "0.59469414", "0.58380026", "0.5784115", "0.5737071", "0.5736166", "0.5663401", "0.5652385", "0.54480004", "0.5421653", "0.5413528", "0.5351798", "0.5346711", "0.52808744", "0.52584416", "0.52503365", "0.52500457", "0.5222135", "0.52005", "0.518044", "0.51592726"...
0.56392044
8
Initializes a request to be sent to OBS.
def __init__(self, _id: Generator[str, None, None], data: dict, obs: OBS) -> None: self.id: Generator[str, None, None] = _id self.data: dict = data self.obs: OBS = obs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_initialization(self) -> global___Snippet.StreamingRequestInitialization:", "def request_initialization(self) -> global___Snippet.StreamingRequestInitialization:", "def request_initialization(self) -> global___Snippet.SimpleRequestInitialization:", "def request_initialization(self) -> global___Sni...
[ "0.685322", "0.685322", "0.669071", "0.669071", "0.669071", "0.669071", "0.66258395", "0.6607381", "0.64253324", "0.62924165", "0.6255951", "0.6251031", "0.6192649", "0.6179652", "0.61713386", "0.6120564", "0.61139685", "0.6105661", "0.6087456", "0.6045154", "0.6024741", "0...
0.0
-1
Returns a list of formatted messages to send to OBS.
def format(self) -> list[dict]: #type: ignore msgs: list = [] mtype: str = self.data["type"] #Requests from obs-websockets version 4.8.0 #Configurable Interactions if mtype == "showSource": msg: dict = {"message-id": next(self.id)} msg["reques...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_message(self):\n\t\tmessage = \"\"\n\t\tlength = len(self.object_list)\n\t\tfor i in range(length - 1):\n\t\t\to = self.object_list[i]\n\t\t\tmessage += self.index_letter_string(i) + o.display_name(True) + \", \"\n\t\tlast_object = self.object_list[length - 1]\n\t\tmessage += self.index_letter_string(leng...
[ "0.65863127", "0.6530261", "0.6438402", "0.6406806", "0.63439816", "0.63024664", "0.62537295", "0.61052835", "0.6044819", "0.59388864", "0.5895649", "0.5718684", "0.5644828", "0.56388956", "0.56388956", "0.56383955", "0.5618301", "0.55736536", "0.55598074", "0.5554202", "0.55...
0.500685
87
Initializes a response to handle a message from OBS.
def __init__(self, data: dict, obs: OBS) -> None: self.data: dict = data self.obs: OBS = obs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle(self) -> None:\r\n\r\n if self.data.get(\"message-id\") != None:\r\n if self.data[\"status\"] == \"error\":\r\n print(self.data[\"error\"])\r\n return\r\n else:\r\n requestData = self.obs.pendingResponses.pop(self.data[\"message-i...
[ "0.6307403", "0.61879915", "0.61478025", "0.61191314", "0.5998926", "0.59968907", "0.59647006", "0.5892805", "0.5841872", "0.579581", "0.57954675", "0.57868123", "0.57337445", "0.5706767", "0.5691417", "0.5691417", "0.5648714", "0.5639251", "0.5633114", "0.5633114", "0.561409...
0.0
-1
Updates the state of the OBS container according to the response.
def handle(self) -> None: if self.data.get("message-id") != None: if self.data["status"] == "error": print(self.data["error"]) return else: requestData = self.obs.pendingResponses.pop(self.data["message-id"]) reques...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_response(self, response):\r\n self.stri.update_response(response)", "def update_response(self, response):\r\n self.stri.update_response(response)", "def update_state(self, slate_documents, responses):", "def UpdateFromResponse(self, response):\n for key in self.status:\n ...
[ "0.66328907", "0.66328907", "0.6365583", "0.6323352", "0.62054694", "0.5852313", "0.5707392", "0.565545", "0.56158465", "0.56016433", "0.5578041", "0.55435324", "0.5526519", "0.55161214", "0.5515251", "0.5485049", "0.54347223", "0.54051816", "0.5404983", "0.5404624", "0.53896...
0.0
-1
Only do something if this object has a search_document property and an index_components() method.
def on_save(sender, **kwargs): obj = kwargs["instance"] if ( not hasattr(obj, "search_document") or not hasattr(obj, "index_components") or not callable(obj.index_components) ): return transaction.on_commit(make_updater(kwargs["instance"]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_search_document(self, index='_all'):\n raise NotImplementedError(\n \"{} does not implement 'get_search_document'.\".format(self.__class__.__name__)\n )", "def supports_book_search(self):\n return False", "def _do_search_action(self, index, action, force=False):\n ...
[ "0.66740507", "0.6086673", "0.6014173", "0.59897864", "0.58953184", "0.5854505", "0.58025813", "0.57932407", "0.5785991", "0.5781423", "0.5732713", "0.56731194", "0.5663661", "0.56631273", "0.56279314", "0.5615476", "0.55995417", "0.55688345", "0.5557545", "0.55552804", "0.55...
0.6202369
1
Updates the search index for an object. Assumes it has a search_document attribute and an index_components()
def make_updater(instance): components = instance.index_components() pk = instance.pk def on_commit(): search_vectors = [] for text, weight in components: search_vectors.append( SearchVector(Value(text, output_field=TextField()), weight=weight) ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_index(self, document):\n\t\tix = self.get_index()\n\n\t\twith ix.searcher():\n\t\t\twriter = AsyncWriter(ix)\n\t\t\twriter.delete_by_term(self.id, document[self.id])\n\t\t\twriter.add_document(**document)\n\t\t\twriter.commit(optimize=True)", "def update_document(obj):\n index = obj.get_index_name(...
[ "0.71704626", "0.6848658", "0.6616188", "0.65059805", "0.63653237", "0.63453496", "0.634416", "0.6302417", "0.6235462", "0.6203117", "0.6128573", "0.61170757", "0.60977256", "0.6055189", "0.6028021", "0.5986587", "0.59665364", "0.59641314", "0.5958063", "0.5940997", "0.592000...
0.6918292
1
group vluns in libs by rounded cvss score and report all
def group_vulns_in_libs_by_cvss(self, df_dependencies): cvss_numeric = pandas.to_numeric(df_dependencies['CVSS']) bin0 = bin1 = bin2 = bin3 = bin4 = bin5 = bin6 = bin7 = bin8 = bin9 = bin10 = 0 for row in cvss_numeric: value = round(row, 0) if value < 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_cvss_score_and_vector_severities(apps, _):\n cvss_systems = [\n \"cvssv2\",\n \"cvssv3\",\n \"cvssv3.1\",\n ]\n\n cvss_vector_systems = [\n \"cvssv2_vector\",\n \"cvssv3_vector\",\n \"cvssv3.1_vector\",\n ]\n\n all_cvss_systems = cvss_systems + cvs...
[ "0.5470115", "0.54475075", "0.53560334", "0.5241141", "0.52371013", "0.5234901", "0.5210737", "0.51736027", "0.5165898", "0.5158116", "0.5143539", "0.51215786", "0.510381", "0.50826854", "0.50627923", "0.50498676", "0.5042613", "0.503236", "0.50254", "0.5015093", "0.5014526",...
0.6109658
0
Count entries by columnname
def group_by_columnanme(self, dataframe, column_name): df = pandas.DataFrame({'Count': dataframe.groupby([column_name]).size()}).reset_index() return df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_entries(df, col_name='lang'):\n\n # Initialize an empty dictionary: cols_count\n cols_count = {}\n \n # Extract column from DataFrame: col\n col = df[col_name]\n\n # Iterate over the column in DataFrame\n for entry in col:\n\n # If entry is in cols_count, add 1\n if ent...
[ "0.7858759", "0.7828455", "0.7743403", "0.7352662", "0.6984403", "0.691869", "0.6903616", "0.6770115", "0.6694787", "0.66542095", "0.6488362", "0.64713675", "0.6461202", "0.6431488", "0.64141375", "0.6414034", "0.6400081", "0.6375286", "0.63674825", "0.63674825", "0.63674825"...
0.63895893
17
Count findings based on tag associated
def count_by_tag(self, dataframe, tags): if tags and not dataframe['tags'].empty: data_to_return = [] counter = 0 for tag in tags: for datafield in dataframe['tags']: if tag in datafield: counter += 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_count(self, tag: Text) -> int:\r\n sub_tags = tag.split(\"+\")\r\n return len([e for e in self.elements if all(t in e.tags for t in sub_tags)])", "def pos_tag_counts(doc):\n tags = []\n for token in doc:\n tags.append(token.pos_)\n frequency = dict(Counter(tags).most_common(...
[ "0.67256415", "0.6657197", "0.66489214", "0.6582122", "0.6580195", "0.64372814", "0.6407761", "0.63473797", "0.63320565", "0.63153505", "0.6284836", "0.6276899", "0.6252535", "0.6238871", "0.6220066", "0.6181116", "0.61404437", "0.6114114", "0.61076623", "0.60928756", "0.6057...
0.67084455
1
Group Data by Severity and count findings.
def group_by_severity(self, dataframe): blocker = dataframe[(dataframe['severity'] == 'BLOCKER')]['delta'].count() critical = dataframe[(dataframe['severity'] == 'CRITICAL')]['delta'].count() major = dataframe[(dataframe['severity'] == 'MAJOR')]['delta'].count() minor = dataframe[(da...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_grouping(self):\n group_container, film_container, plank_container = [[] for a in range(self.tot_conditions)], \\\n [[] for a in range(self.tot_conditions)], \\\n [[] for a in range(s...
[ "0.6221499", "0.6004024", "0.5713319", "0.56625205", "0.55638", "0.55037814", "0.54887646", "0.5456852", "0.5438692", "0.5416134", "0.53570604", "0.53044593", "0.5290189", "0.5248686", "0.5247813", "0.5245111", "0.5245111", "0.52328354", "0.5223807", "0.52144516", "0.52034396...
0.6730897
0
Perform analysis of collected data
def group_by_days_open(self, data): excel_adaptor = ExcelAdaptor() bins = numpy.arange(0, 750, 125) labels = [125, 250, 375, 500, 625] data['delta'] = pandas.to_numeric(data['delta']) return excel_adaptor.create_pivot_analysis(data, 'delta', 'labels', bins, labels, 'Tage Off...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataStats(self):\n print (\"Performing statistical analysis of the data\")\n # stuff to do", "def analyse(self, data=None):\n pass", "def analyse(self):\n pass", "def analyze(data):\n ## Do welch periodogram here\n pass", "def Analyze(self, data):\n self._Ad...
[ "0.7715692", "0.7516815", "0.74466145", "0.7446264", "0.71001583", "0.7076552", "0.7073888", "0.6830436", "0.6803028", "0.6729046", "0.66151905", "0.6603184", "0.6536165", "0.64877903", "0.64850986", "0.64317435", "0.63817", "0.6376414", "0.6330861", "0.6317275", "0.6305871",...
0.0
-1
Generate Report of OWASP DependencyChecker Data
def generate_dependency_checker_report(self, df): lineitem_list = [] for index, dat in df.iterrows(): if 'message' in dat: msg = dat['message'] str_msg = str(msg) if str_msg.startswith("Filename:"): lineitem = [] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_report():\n\n # Fetch the top 3 most viewed articles and number of views and print them\n articles_query = get_articles_query()\n popular_articles = execute_query(articles_query)\n print_top_articles(popular_articles)\n\n # Fetch the most popular authors and print them\n authors_quer...
[ "0.6349714", "0.6115491", "0.6089617", "0.60730565", "0.5983427", "0.58648086", "0.5862421", "0.5851142", "0.5844404", "0.5793625", "0.5771352", "0.5768434", "0.5756283", "0.57550555", "0.563971", "0.5591594", "0.55902934", "0.55511624", "0.5532146", "0.55305606", "0.5529665"...
0.6661429
0
Analyses dataframe based on project list and filters for CWE column
def analyse_by_applications(self, dataframe, applicationslist, cwe_filter): result = [] for app in applicationslist: df_analysis = dataframe[(dataframe['project'] == app)] counts = 0 counts += len(df_analysis[(df_analysis['CWE'].isin(cwe_filter))].index) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def healthcare_filter(df_all): \n #get requested assets under healthcare tag \n df_filtered = pandas.DataFrame(columns=['osm_id','asset','geometry']) #create df for saving data\n for row in range(len(df_all.index)): \n if 'healthcare' in df_all[\"asset\"][row]: #check if healthcare key ...
[ "0.60948294", "0.54548633", "0.54526734", "0.54413414", "0.5439022", "0.53998333", "0.53511494", "0.5345424", "0.5326692", "0.53213", "0.5316692", "0.52784705", "0.523554", "0.5214889", "0.5200827", "0.51885015", "0.5170738", "0.51610965", "0.5160015", "0.51404864", "0.513783...
0.598965
1
Main Routine to perform all analysis with
def analyse(self, df_analysis, df_dependencies, tags): data = df_analysis[df_analysis.delta.notnull()] df_age = self.group_by_days_open(data) df_sev = self.group_by_severity(data) # Add Count(Vulns) by Owasp Controls df_owasp = self.count_by_tag(df_analysis, tags) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_all(self):\n\n self.run_mash() ###Run MASH analysis\n self.filter_query() ###Filter fasta sequences out based on p value\n self.build_index(self.filtered_out_path) ###Build index for off-target analysis\n os.remove(self.filtered_out_path) ###Clean up intermediate fasta file\n ...
[ "0.74853045", "0.742947", "0.7351557", "0.7310844", "0.72842807", "0.7275961", "0.7265989", "0.71876854", "0.71395785", "0.70843226", "0.7028306", "0.6994845", "0.69630873", "0.6918516", "0.687861", "0.68648106", "0.6836755", "0.68028307", "0.68008864", "0.6793005", "0.676501...
0.0
-1
Initialize the redirector service.
def __init__(self, consul_host_port, redir_to_https=False, redir_to_ip=False, log_disable=False, poll_interval=5.0, bind_port=8080, check_id='service:vault', key_path=None, cert_path=None): self.active_node_ip_port = None self.last_poll_time = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, requestor, client_id, redirect_uri=None):\n self._requestor = requestor\n self.client_id = client_id\n self.redirect_uri = redirect_uri", "def initialize(self):\n self.login()", "def __init__(self, auto_redirect=True):\n self.redirect = auto_redirect\n ...
[ "0.58872813", "0.5705055", "0.5653513", "0.5589158", "0.5589158", "0.5589158", "0.55823886", "0.55203754", "0.55014133", "0.5453068", "0.5420782", "0.53252023", "0.53183275", "0.53034985", "0.53034985", "0.53034985", "0.53034985", "0.53034985", "0.5300782", "0.52785456", "0.5...
0.5608237
3
If we have paths to a TLS certificate and key, check that we're ready
def get_tls_factory(self): if not access(self.cert_path, R_OK): raise RuntimeError('Error: cert file at %s is not ' 'readable' % self.cert_path) if not access(self.key_path, R_OK): raise RuntimeError('Error: key file at %s is not ' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_privatekey_valid(self):\n key = load_privatekey(FILETYPE_PEM, client_key_pem)\n cert = load_certificate(FILETYPE_PEM, client_cert_pem)\n context = Context(SSLv23_METHOD)\n context.use_privatekey(key)\n context.use_certificate(cert)\n assert None is context.c...
[ "0.6499415", "0.6312758", "0.6302942", "0.6282047", "0.62025607", "0.6180923", "0.6171225", "0.6110366", "0.5958099", "0.59206104", "0.5909794", "0.5901246", "0.5897176", "0.58793414", "0.58764917", "0.5832142", "0.5826128", "0.5790147", "0.57800645", "0.5775141", "0.5746711"...
0.54756963
37
setup signal handlers for logging enable/disable Note that this doesn't work on Windows.
def setup_signal_handlers(self): signal.signal(signal.SIGUSR1, self.handle_logging_signal) signal.signal(signal.SIGUSR2, self.handle_logging_signal)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_signal_handlers():\n # type: () -> None\n for signum in [signal.SIGINT, signal.SIGTERM]:\n signal.signal(signum, log_and_exit_handler)\n\n signal.signal(signal.SIGUSR1, dump_thread_handler)", "def init_signal_handler():\n signal.signal(signal.SIGUSR1, sig_handler)\n signal.signal(...
[ "0.7772562", "0.73069805", "0.70535564", "0.69866353", "0.6862096", "0.6861376", "0.64042336", "0.63918316", "0.63752675", "0.621561", "0.61876076", "0.60945964", "0.6074691", "0.60609514", "0.5999939", "0.59959495", "0.5987227", "0.59856313", "0.5965386", "0.5942906", "0.589...
0.81305313
0
Handle a signal sent to this process (SIGUSR1 or SIGUSR2) to enable or disable logging.
def handle_logging_signal(self, signum, frame): if signum == signal.SIGUSR1: logger.warning('Logging enabled via signal; send SIGUSR2 to PID ' '%d to disable logging', getpid()) self.log_enabled = True elif signum == signal.SIGUSR2: logger.w...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_signal_handlers(self):\n signal.signal(signal.SIGUSR1, self.handle_logging_signal)\n signal.signal(signal.SIGUSR2, self.handle_logging_signal)", "def set_signal(self):\n eprint(\"Signal caught, ending log...\")\n self.log_sig = True", "def init_signal_handler():\n signa...
[ "0.7424925", "0.6531359", "0.60466653", "0.60098785", "0.57099855", "0.5659611", "0.5627149", "0.5599337", "0.55690354", "0.5476252", "0.5459919", "0.5393123", "0.53718174", "0.5364912", "0.5362066", "0.5353693", "0.5314653", "0.5218517", "0.5217412", "0.5206121", "0.5176048"...
0.8433533
0
GET the Consul URL for the 'vault' service health check, parse the JSON
def get_active_node(self): url = 'http://%s/v1/health/service/vault' % self.consul_host_port # parse the health check results and find the one that's passing if self.log_enabled: logger.debug('Polling active node from: %s', url) r = requests.get(url) # return the curr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def healthcheck(self):\n url = urljoin(self.url, \"/.well-known/healthcheck.json\")\n r = requests.get(url)\n return r.json()", "def test_simple_health_check(self):\n response = self.client.open(\n '/awadallah/VaultsManager/1.0.0/health',\n method='GET')\n ...
[ "0.66680086", "0.64634347", "0.63958126", "0.61298597", "0.610365", "0.60786", "0.5995004", "0.5983581", "0.59696084", "0.59464586", "0.5921893", "0.5909836", "0.59078926", "0.5889489", "0.57978845", "0.57828724", "0.5711383", "0.57027406", "0.5672408", "0.5661904", "0.564784...
0.0
-1
Method to run the Twisted reactor; mock point for testing
def run_reactor(self): self.reactor.run()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n\n if reactor.running:\n return\n\n self._thread = threading.Thread(target=reactor.run, args=(False,))\n self._thread.daemon = True\n self._thread.start()", "def run(self):\n\n if reactor.running:\n misc.formatted_print('RosBridgeWebSockCom...
[ "0.7778394", "0.74967456", "0.7319666", "0.7220562", "0.7220562", "0.7008422", "0.7003522", "0.6994657", "0.66136485", "0.6601231", "0.6545518", "0.6543385", "0.64206713", "0.63929015", "0.6370003", "0.635786", "0.627061", "0.61581725", "0.613168", "0.61298543", "0.60738724",...
0.8518277
0
Setup TCP listener for the Site; helper method for testing
def listentcp(self, site): logger.warning('Setting TCP listener on port %d for HTTP requests', self.bind_port) self.reactor.listenTCP(self.bind_port, site)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_for_run(self):\n self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n self.server.bind((self.ip_address, self.port))\n self.server.listen(100)", "def _startListening(self, port=None):\n i...
[ "0.70610344", "0.67669165", "0.6753614", "0.669443", "0.65610534", "0.65455735", "0.6543585", "0.6519221", "0.6474275", "0.6452438", "0.6423061", "0.64223975", "0.639628", "0.638766", "0.6324891", "0.6289175", "0.626186", "0.62408364", "0.6237316", "0.6210429", "0.6184662", ...
0.7318118
0
Setup TLS listener for the Site; helper method for testing
def listentls(self, site): logger.warning('Setting TCP TLS listener on port %d for HTTPS requests', self.bind_port) self.reactor.listenSSL(self.bind_port, site, self.tls_factory)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _config_tls(self):\n pass", "def test_tls_in_tls_tunnel(self) -> None:\n self.start_destination_server()\n self.start_proxy_server()\n\n sock = socket.create_connection(\n (self.proxy_server.host, self.proxy_server.port)\n )\n with self.client_context.wrap...
[ "0.7026453", "0.6474438", "0.6472922", "0.6274493", "0.62616086", "0.6183114", "0.61796516", "0.61622256", "0.61182225", "0.6105451", "0.60914046", "0.60610014", "0.606056", "0.6055678", "0.59946406", "0.59886986", "0.59402734", "0.5873588", "0.581147", "0.57844216", "0.57763...
0.74420154
0
Setup the LoopingCall to poll Consul every ``self.poll_interval``; helper for testing.
def add_update_loop(self): l = LoopingCall(self.update_active_node) l.clock = self.reactor logger.warning('Setting Consul poll interval to %s seconds', self.poll_interval) l.start(self.poll_interval)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polling_call(self) -> global___Snippet.ClientCall:", "def setup_poll(self):\n while True:\n try:\n self.do_polling()\n time.sleep(0.01)\n except KeyboardInterrupt:\n print(self.get_stream())\n exit()", "def _start_poll...
[ "0.64300156", "0.6119329", "0.6094615", "0.58870393", "0.5854085", "0.5847177", "0.5814883", "0.5669755", "0.56681806", "0.56652987", "0.56584185", "0.5645527", "0.5624671", "0.56083053", "0.559879", "0.55794555", "0.55784315", "0.5574817", "0.556912", "0.5552644", "0.5544401...
0.7342474
0
setup the site, start listening on port, setup the looping call to
def run(self): # get the active node before we start anything... self.active_node_ip_port = self.get_active_node() if self.active_node_ip_port is None: logger.critical("ERROR: Could not get active vault node from " "Consul. Exiting.") raise Sys...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n log.debug(\"start web server running\")\n webDir = self.config.webDir\n self.root.putChild(\"images\", static.File(webDir+\"/images\"))\n self.root.putChild(\"css\", static.File(webDir+\"/css\")) \n self.root.putChild(\"scripts\", static.File(w...
[ "0.72846186", "0.7238455", "0.6964677", "0.6964677", "0.686212", "0.67896116", "0.67560655", "0.674393", "0.672427", "0.6691133", "0.6642251", "0.664133", "0.66080475", "0.6559788", "0.65560853", "0.6506846", "0.6506031", "0.64883065", "0.64726406", "0.64354897", "0.64280635"...
0.59107053
91
This should never be called; it's simply required to implement the
def getChildWithDefault(self, name, request): return resource.ErrorPage(NOT_FOUND, "No Such Resource", "No Such Resource")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self):\n raise NotImplementedError", "def __call__(self):\n raise NotImplementedError()", "def __call__(self):\r\n raise NotImplementedError('override me')", "def __call__(self) -> None:", "def __call__(self):\n\t\treturn", "def __call__(self):\n pass", "def __c...
[ "0.78682625", "0.771158", "0.7696754", "0.7624288", "0.7534245", "0.7481967", "0.7481967", "0.743059", "0.7084661", "0.7017043", "0.6961426", "0.6961426", "0.69497", "0.69305223", "0.69083184", "0.69083184", "0.69083184", "0.69083184", "0.68199265", "0.68048245", "0.6791688",...
0.0
-1
python 3+ needs a binary response; create one
def make_response(self, s): if sys.version_info[0] < 3: return s return s.encode('utf-8') # nocoverage - unreachable under py2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bytes2response(data, level=3,\n method=None, url=\"http://example.com\", req_headers=None, req_files=None,\n req_data=None, req_auth=None, req_json=None\n ):\n # These imports can be moved outside to gain slight performance improvement\n # they are ...
[ "0.6456993", "0.6221034", "0.6101108", "0.60980344", "0.6045693", "0.59918797", "0.59856886", "0.59291124", "0.5786804", "0.5780398", "0.5764244", "0.5759735", "0.5759337", "0.5749703", "0.57455724", "0.57413113", "0.5741175", "0.5727549", "0.5659588", "0.56577563", "0.563172...
0.57673514
10
Generate and return a healthcheck response.
def healthcheck(self, request): statuscode = OK msg = self.make_response('OK') if self.redirector.active_node_ip_port is None: statuscode = SERVICE_UNAVAILABLE msg = self.make_response('No Active Vault') request.setResponseCode(statuscode, message=msg) req...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_health_check(self):\n return util.create_response(output=\"OK\")", "def healthcheck():\n return make_response(jsonify(status=200, message='Healthy'), status.HTTP_200_OK)", "def health_check():\n # TODO: implement any other checking logic.\n return '', 200", "def _healthcheck():\n ...
[ "0.802485", "0.77074367", "0.7512624", "0.7500844", "0.7327958", "0.7084402", "0.705349", "0.69670343", "0.6913111", "0.68223006", "0.6725334", "0.67168075", "0.6697383", "0.6569488", "0.6566781", "0.6561923", "0.64547014", "0.6334859", "0.6329124", "0.63058436", "0.6282877",...
0.58168834
48
Render the response to the given request. This simply gets the current active vault node from ``self.redirector`` (our instance of
def render(self, request): path = request.uri # python3 will get a byte string here if not isinstance(path, str): # nocoverage - py3 only path = path.decode('utf-8') # find the original Twisted server header twisted_server = request.responseHeaders.getRawHeaders( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, request):\n return render(request, self.template, self.context)", "def render(self, request):\r\n response = LoudWSGIResponse(\r\n self._reactor, self._threadpool, self._application, request)\r\n response.start()\r\n return NOT_DONE_YET", "def render(self, r...
[ "0.6560809", "0.6359053", "0.6336096", "0.6310626", "0.6300567", "0.6269164", "0.61724883", "0.61724883", "0.61724883", "0.61724883", "0.61724883", "0.6134169", "0.6116021", "0.5992712", "0.5980887", "0.58995026", "0.58071774", "0.5804967", "0.5791897", "0.57851684", "0.57508...
0.7892752
0
Return num_items many items of seq, spread evenly. If seq is shorter than num_items, include all items. Otherwise, include first and last items and spread evenly in between. (If num_items is 1, only include first item.)
def select_evenly_spread(seq, num_items): if len(seq) <= num_items: return seq if num_items == 1: return [seq[0]] step_size = (len(seq) - 1) / float(num_items - 1) float_indices = [i * step_size for i in range(num_items)] return [seq[int(round(index))] for index in float_indices]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def takespread(sequence, num):\n length = float(len(sequence))\n for i in range(num):\n yield sequence[int(np.ceil(i * length / num))]", "def takespread(sequence, num):\n length = float(len(sequence))\n for i in range(num):\n yield sequence[int(ceil(i * length / num))]", "def chunk(si...
[ "0.6699766", "0.66776925", "0.64731294", "0.6373739", "0.6299112", "0.6218917", "0.61767405", "0.6134805", "0.6121701", "0.6070096", "0.6070043", "0.6037862", "0.59886056", "0.59750354", "0.59304655", "0.5926504", "0.59138757", "0.5903377", "0.59028697", "0.5899408", "0.58725...
0.71883833
0
Dump records into a etree.
def dumps_etree(records, xslt_filename=None, prefix=None): E = ElementMaker(namespace=MARC21_NS, nsmap={prefix: MARC21_NS}) def dump_record(record): """Dump a single record.""" rec = E.record() leader = record.get('leader') if leader: rec.append(E.leader(leader)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumps(records, xslt_filename=None, **kwargs):\n root = dumps_etree(records=records, xslt_filename=xslt_filename)\n return etree.tostring(\n root,\n pretty_print=True,\n xml_declaration=True,\n encoding='UTF-8',\n **kwargs\n )", "def dumps_etree(pid, record, **kwarg...
[ "0.69029105", "0.63929474", "0.56852293", "0.55213356", "0.5477097", "0.5326399", "0.5287852", "0.5261604", "0.5207058", "0.51850164", "0.51611996", "0.51485854", "0.5118779", "0.5108804", "0.50956446", "0.5054487", "0.5044759", "0.50340503", "0.50274277", "0.49789754", "0.49...
0.7121784
0
Dump a single record.
def dump_record(record): rec = E.record() leader = record.get('leader') if leader: rec.append(E.leader(leader)) if isinstance(record, GroupableOrderedDict): items = record.iteritems(with_order=False, repeated=True) else: items = iteritems(rec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emit(self, record):\n\n print(record.__dict__)", "def save_record(record):\n record. save_details()", "def makePickle(self, record):\n return self.format(record) + \"\\n\"", "def record(self):\n # TODO: record the data", "def dump(self) -> None:\n ...", "def serialize(self)...
[ "0.6242049", "0.6222805", "0.6132557", "0.612427", "0.6115146", "0.60970974", "0.6094088", "0.5977179", "0.59287816", "0.59142005", "0.57409346", "0.57253456", "0.5718467", "0.57092816", "0.57047963", "0.56437147", "0.5635687", "0.56231046", "0.56150806", "0.5597934", "0.5593...
0.5833669
10
Dump records into a MarcXML file.
def dumps(records, xslt_filename=None, **kwargs): root = dumps_etree(records=records, xslt_filename=xslt_filename) return etree.tostring( root, pretty_print=True, xml_declaration=True, encoding='UTF-8', **kwargs )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumps_etree(records, xslt_filename=None, prefix=None):\n E = ElementMaker(namespace=MARC21_NS, nsmap={prefix: MARC21_NS})\n\n def dump_record(record):\n \"\"\"Dump a single record.\"\"\"\n rec = E.record()\n\n leader = record.get('leader')\n if leader:\n rec.append(...
[ "0.63906", "0.6186403", "0.5400288", "0.53913724", "0.5287706", "0.52607244", "0.5199263", "0.5194999", "0.5178158", "0.5165629", "0.50882804", "0.50425106", "0.50006974", "0.486957", "0.48627663", "0.48580542", "0.48235115", "0.4818354", "0.4817395", "0.481157", "0.4808279",...
0.5589955
2
Get the path to the .env file and load it.
def load_env(): project_dir = abspath(join(dirname(__file__), '../..', '..', '..')) dotenv.read_dotenv(join(project_dir, 'nijanthan/practise/base_pro/.env'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_env(env_path=''):\n if not env_path:\n env_path = Path.home() / '.pincidents'\n load_dotenv(dotenv_path=env_path)", "def load_config(env_file_path: str) -> None:\n if os.path.isfile(env_file_path):\n load_dotenv(dotenv_path=env_file_path)\n else:\n logger.info(f\".env fi...
[ "0.78547215", "0.7557182", "0.73901635", "0.721461", "0.7143697", "0.69619185", "0.69241214", "0.6902178", "0.68390185", "0.68265843", "0.6611378", "0.65993965", "0.65926677", "0.65620166", "0.65477896", "0.63888115", "0.6374202", "0.63433176", "0.6342294", "0.63167065", "0.6...
0.7732894
1
Creates mapping key = word, value = row index
def _create_dictionary(self, document): words = self._normalize_words(document.words) unique_words = frozenset(words) return dict((word, idx) for idx, word in enumerate(unique_words))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_index(text: Iterable) -> Dict[str, List[Tuple[int, int]]]:\n index = defaultdict(list)\n for line_no, line in enumerate(text, 1):\n for match in WORD_RE.finditer(line):\n word = match.group()\n column_no = match.start() + 1\n location = (line_no, column_no)\n...
[ "0.7159948", "0.6949987", "0.66246754", "0.66195613", "0.6606184", "0.6294764", "0.62644446", "0.61882865", "0.61626875", "0.6162056", "0.6147786", "0.6146079", "0.6131257", "0.61265624", "0.6122289", "0.6063121", "0.60443723", "0.60232854", "0.59934974", "0.596981", "0.59339...
0.57246023
36
Computes TF metrics for each sentence (column) in the given matrix.
def _compute_term_frequency(self, matrix, smooth=0.4): assert 0.0 <= smooth < 1.0 max_word_frequencies = numpy.max(matrix, axis=0) rows, cols = matrix.shape for row in range(rows): for col in range(cols): max_word_frequency = max_word_frequencies[col] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tfidfTransform(matrix):\n matrix_float = numpy.zeros(matrix.shape)\n document_Total = len(matrix)\n rows, cols = matrix.shape\n for row in xrange(0, rows): # For each document\n wordTotal = reduce(lambda x, y: x + y, matrix[row])\n for col in xrange(0, cols): # For each term\n ...
[ "0.60472375", "0.5998401", "0.5973252", "0.59692657", "0.589974", "0.5786748", "0.5782038", "0.5769449", "0.57081085", "0.5629882", "0.55642563", "0.5558503", "0.5544128", "0.55242777", "0.5487957", "0.54660946", "0.5455768", "0.5450541", "0.53934824", "0.5379008", "0.5349152...
0.5123305
38
(W,H) = nmf(V, Winit, Hinit, tol, timelimit, maxiter)
def nmf(V, Winit, Hinit, tol, timelimit, maxiter): W = Winit; H = Hinit; initt = time(); gradW = dot(W, dot(H, H.T)) - dot(V, H.T) gradH = dot(dot(W.T, W), H) - dot(W.T, V) initgrad = norm(r_[gradW, gradH.T]) tolW = max(0.001, tol) * initgrad tolH = tolW for i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def NMF(X,r):\n nmf_mdl = nmf.NMF(X,num_bases=r)\n nmf_mdl.initialization()\n nmf_mdl.factorize()\n return nmf_mdl.W,nmf_mdl.H,np.dot(nmf_mdl.W,nmf_mdl.H)", "def test_hmf_init(self):\n spec = np.random.random((20, 100))\n invvar = np.random.random((20, 100))\n hmf = HMF(spec, invvar)\n ...
[ "0.6112802", "0.60931575", "0.5728019", "0.56031424", "0.55949867", "0.55810726", "0.5515399", "0.55091494", "0.5394185", "0.5364246", "0.5362784", "0.5339164", "0.5308675", "0.5297075", "0.52824354", "0.52717924", "0.52717847", "0.52690816", "0.5243116", "0.5242015", "0.5231...
0.81835836
0
Outputs a 2D matrix of modular multiplication in Zn
def times_table(n): return [[(i * j) % n for i in range(n)] for j in range(n)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _z2matmul(self, left, right):\n prod = np.mod(np.dot(left, right), 2)\n return prod", "def matrixMultiplication(self, n, id, context):\n\n print(\"id: {}\".format(id))\n # Create one matrix\n f = 1\n m1 = []\n for x in range(n):\n row = []\n ...
[ "0.68996847", "0.63369983", "0.62360066", "0.614778", "0.6139831", "0.61245316", "0.60973686", "0.6054237", "0.601557", "0.5962045", "0.5907254", "0.5882478", "0.5859488", "0.5854544", "0.58375496", "0.5802503", "0.57747495", "0.576629", "0.57641774", "0.5759685", "0.5757113"...
0.0
-1
Outputs a 2D matrix of modular addition in Zn
def plus_table(n): return [[(i + j) % n for i in range(n)] for j in range(n)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix_add():", "def add_matrices(m1, m2):\n\t\n\t\n\treturn [[a+b for a, b in izip(m1, m2)] for m1, m2 in izip(m1, m2)]", "def add_matrices(m1, m2): \n output = []\n \n for index in range(len(m1)):\n row_1 = m1[index]\n row_2 = m2[index]\n new_row = []\n for index2 ...
[ "0.6809368", "0.5947889", "0.5828537", "0.5741617", "0.5741421", "0.56778955", "0.5655315", "0.56499636", "0.5641074", "0.5639486", "0.56214535", "0.56210726", "0.5598829", "0.5592749", "0.5589371", "0.55851173", "0.55637825", "0.5523123", "0.5510404", "0.5494969", "0.5478293...
0.5318169
33
Computes x^y in z_n
def zn_pow(x, y, n): if y < 0: y = abs(y) x = inverse_in_zn(x, n) product = 1 for i in range(y): product = (product * x) % n vprint("{}^{}={}".format(x, i, product)) return product
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def power(x, y):\n return x^y", "def f(x, i_x, y, i_y, z, i_z, length):\r\n s_x = x(i_x, length)\r\n s_y = y(i_y, length)\r\n s_z = z(i_z, length)\r\n sol = ''\r\n i=0\r\n while len(sol)<length:\r\n sol += xor(xor(mult(s_x[i],s_y[i]) , mult(s_y[i], s_z[i])),s_z[i])\r\n i+=1\r\n...
[ "0.66730636", "0.6635001", "0.6572842", "0.6569926", "0.63914114", "0.63569474", "0.63238096", "0.6276317", "0.6223808", "0.6194685", "0.6188878", "0.6178684", "0.61747915", "0.61637163", "0.6114781", "0.6096214", "0.6078316", "0.60657305", "0.6062788", "0.60532427", "0.60515...
0.75251645
0
Generates Z_n = {x | 0 < x < n and gcd(x, n) = 1}. This structure is the sort of group used for "textbook RSA"
def zn_star(n): return [x for x in range(1, n) if coprime(x, n)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zzx_mod_gcd(f, g, **flags):\n if not (f or g):\n return [], [], []\n elif not f:\n return g, [], [1]\n elif not g:\n return f, [1], []\n\n n = zzx_degree(f)\n m = zzx_degree(g)\n\n cf = zzx_content(f)\n cg = zzx_content(g)\n\n gcd = igcd(cf, cg)\n\n f = [ c // gc...
[ "0.63748896", "0.63698", "0.62174314", "0.60367006", "0.6008271", "0.59705156", "0.59385264", "0.59185094", "0.5916367", "0.5895515", "0.58827764", "0.586639", "0.5847179", "0.58172923", "0.57936674", "0.57864976", "0.5722669", "0.5683913", "0.5671629", "0.56647587", "0.56600...
0.61808234
3
Produces the cyclic subgroup generated by the element g in Zn.
def elts_generated_by_g_in_zn(g, n): product = 1 elts_generated = [] g = g % n # Ensure that g is a representative element for i in range(n): vprint("$${}*{} = {} \equiv {}$$".format( product, g, product*g, (product*g) % n)) product = (product * g) % n elts_generated....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cyclic_subgroup(a):\n G = []\n t = a\n while True:\n G.append(t)\n t = a+t\n if t == a:\n break\n return G", "def cyclic_subgroups(C):\n ps = C.points()\n Gs = []\n \n for i in ps:\n P = Elliptic_Point(i[0],i[1],C)\n Gs.append(cyclic_subgr...
[ "0.72780496", "0.71233326", "0.63908875", "0.62647253", "0.62647253", "0.6255603", "0.60240215", "0.57137513", "0.54768765", "0.54702216", "0.5463425", "0.54543304", "0.5452055", "0.54111314", "0.5383891", "0.5365543", "0.53105134", "0.5281393", "0.5260145", "0.52543074", "0....
0.0
-1
Checks if g is a generator of z_n
def is_generator_in_zn(g, n): elts_generated = elts_generated_by_g_in_zn(g, n) vprint("g:{}, elts:{}\n".format(g, elts_generated)) return all([i in elts_generated for i in zn_star(n)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_generator(p, g):\n if(not (1 <= g <= (p - 1))): # g must be an element in Z_{p}^{*}\n return False\n \n q = (p - 1) // 2 # Since p = 2q + 1\n if(pow(g, 2, p) == 1):\n return False\n elif(pow(g, q, p) == 1):\n return False\n ...
[ "0.7949682", "0.70262194", "0.6968087", "0.62968594", "0.6117654", "0.57494915", "0.5652518", "0.5647986", "0.56283367", "0.56008095", "0.55592644", "0.55405307", "0.54814005", "0.54731536", "0.5467142", "0.5421483", "0.5421247", "0.5407625", "0.5404735", "0.53993076", "0.536...
0.7681654
1
Returns a list containing the generator(s) of z_n
def generators(n): return [g for g in zn_star(n) if is_generator_in_zn(g, n)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parition_generator(n):\n # generator\n k = np.zeros(n, dtype=np.dtype(int))\n Z = np.zeros(n, dtype=np.dtype(int))\n h = [float(n)]\n yield(Z)\n while next_partition(Z, k, h) is not None:\n yield(Z)", "def _generators_for_H(self):\n if self.level() in [1, 2]:\n retu...
[ "0.67002165", "0.63764656", "0.62214935", "0.60862786", "0.60487634", "0.60005474", "0.5977176", "0.5936845", "0.592394", "0.588313", "0.5868543", "0.5853401", "0.58512384", "0.58411086", "0.58137316", "0.5801812", "0.5782896", "0.5781784", "0.57633716", "0.5753569", "0.57496...
0.8108819
0
Computes a | b Finds q, r such that 0 <= r < q a = bq + r
def division_algo(a, b): return a / b, a % b
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def within(p, q, r):\r\n return p <= q <= r or r <= q <= p", "def _heuristic(a, b):\n return (b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2", "def lqr(a, b, q, r):\n a, b, q, r = map(np.atleast_2d, (a, b, q, r))\n p = scipy.linalg.solve_continuous_are(a, b, q, r)\n\n # LQR gain\n k = np.linalg.s...
[ "0.63561344", "0.6302599", "0.628819", "0.62867814", "0.62752557", "0.6238031", "0.6194553", "0.6194516", "0.6176849", "0.6092765", "0.5993498", "0.59408194", "0.5920558", "0.58626187", "0.58285016", "0.5796347", "0.57915044", "0.576501", "0.5761697", "0.57412153", "0.5727595...
0.0
-1
Find the values which satisfy Bezout's identity for a and b, i.e. finds X, Y, d such that aX + bY = d, where d = gcd(a, b)
def extended_euclidean(a, b): vprint("a: {}, b: {}".format(a, b)) assert(a >= b) if a == b: x = 1 y = 0 d = a vprint("Base case: a == b") vprint("x: {}, y: {}, d: {}".format(x, y, d)) return x, y, d q, r = division_algo(a, b) vprint(" a = q * b + r") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extendedGcd(a, b):\n x0 = 1\n x1 = 0\n y0 = 0\n y1 = 1\n\n while b != 0:\n p = a // b\n z = a % b\n a = b\n b = z\n\n w = x1\n x1 = x0 - p * x1\n x0 = w\n \n v = y1\n y1 = y0 - p * y1\n y0 = v\n print(\"returns: gcd,...
[ "0.68385243", "0.6651178", "0.66141975", "0.6609516", "0.65556455", "0.65132046", "0.6482014", "0.64708185", "0.6469052", "0.6451727", "0.6451727", "0.6451727", "0.6443934", "0.64220333", "0.6405892", "0.6404742", "0.6369613", "0.6367694", "0.6327167", "0.6283818", "0.6280122...
0.0
-1
Test if n is prime, with witness a. Output True if n is prime, False otherwise
def is_prime_by_fermat_test(n, a): output = zn_pow(a, n-1, n) # a^{n-1}, mod n if output == 1: vprint("prime") return True vprint("composite") return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_prime(a):\n return all(a % i for i in xrange(2, a))", "def isprime(n):\r\n\treturn is_prime(n)", "def isprime(n):\n\treturn is_prime(n)", "def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False", "def is_prime(n):\n return mr_prime(n)", "def if_prime(cls, ...
[ "0.7837422", "0.77885544", "0.7740405", "0.76765877", "0.7637204", "0.75215995", "0.75006753", "0.74756145", "0.7446736", "0.74348235", "0.7434485", "0.7431155", "0.74153996", "0.7403929", "0.7353826", "0.73335487", "0.731264", "0.73082674", "0.73048615", "0.7267132", "0.7265...
0.70814806
55
Find inverse of g in z_n
def inverse_in_zn(g, n): assert(n >= g) x, y, d = extended_euclidean(n, g) if y < 0: return y + n return y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inverse_gc(g):\n i = g\n j = 1\n while j<N:\n i = i ^ (g >> j)\n j = j + 1\n return i", "def _invert(G):\n return Surreal.from_value(1 / G._n)", "def inverse_fisher_z_transform(z):\r\n return ((e ** (2 * z)) - 1.) / ((e ** (2 * z)) + 1.)", "def inv(z: int) -> int:\n ...
[ "0.75171715", "0.67687446", "0.6758636", "0.6735445", "0.6680595", "0.6458415", "0.64496434", "0.63375884", "0.63053936", "0.6281091", "0.62721896", "0.62156457", "0.6212842", "0.61471933", "0.6141524", "0.6140245", "0.61159855", "0.6105521", "0.61054134", "0.60821134", "0.60...
0.8124559
0
Finds dlog(h) baseg in Z_n, i.e. given generator g, finds x such that g^x = h in Z_n
def dlog(g, h, n): elts_generated = elts_generated_by_g_in_zn(g, n) # If this assert fails, then g wasn't actually a generator assert(h in elts_generated) return elts_generated.index(h)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def g_d(self, z):\n a = self.g(z)\n return a * (1 - a)", "def g(i):\n return int(np.log2(gc(i)^gc(i+1)))", "def G(k):\n return k^(k>>1)", "def g(z):\n return 1. / (1. + np.exp(-z))", "def generation(x, g):\n return int(x/g)", "def d(i):\n if i==0:\n return 0\n elif ...
[ "0.67295223", "0.66372913", "0.61786944", "0.61676687", "0.60204524", "0.6011649", "0.60047656", "0.6002928", "0.59030944", "0.5895163", "0.58863825", "0.58171076", "0.581507", "0.5794808", "0.5784611", "0.5769089", "0.57558495", "0.57503766", "0.5745927", "0.5738804", "0.565...
0.77870095
0
Converts i to its binary string representation
def int2bin(i): if i == 0: return "0" s = '' while i: if i & 1 == 1: s = "1" + s else: s = "0" + s i /= 2 return s
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intToBin(i):\n # devide in two parts (bytes)\n i1 = i % 256\n i2 = int( i/256)\n # make string (little endian)\n return chr(i1) + chr(i2)", "def bin_str(i):\n out = ''\n for j in range(N-1,-1,-1):\n if (i>>j) & 1 == 1:\n out += '1'\n else:\n out += '0'...
[ "0.7506868", "0.7330302", "0.7313609", "0.69675094", "0.68550926", "0.67596966", "0.6709922", "0.66618997", "0.64344794", "0.63535184", "0.6154925", "0.61517626", "0.6132392", "0.611826", "0.6111625", "0.6084419", "0.6080857", "0.60784036", "0.5990371", "0.5986936", "0.598170...
0.7067672
3
Speedily computes a^x (mod n)
def fast_exp(a, x, n): x_2 = int2bin(x) vprint("{} = [{}]_2".format(str(x), x_2)) powers = [a % n] vprint("{}^(2^0) = {}^1 = {} \\equiv {}".format(a, a, a, (a % n))) i = 1 while i < len(x_2): # This (hilariously ugly) print statement prints the # intermediary operations in a form...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fast_power(a, n, m): # (a ^ n) % m\n result = 1\n value = a\n power = n\n while power > 0:\n if power % 2 == 1:\n result = result * value\n result %= m\n value = value * value\n value %= m\n power = power//2\n return result", "def fast_expo(a, ...
[ "0.79421157", "0.7464723", "0.73651356", "0.7330644", "0.73195386", "0.7313797", "0.72905034", "0.7276198", "0.7246754", "0.7216778", "0.72006136", "0.71849555", "0.71495146", "0.70580775", "0.70481366", "0.7007317", "0.6999108", "0.69729644", "0.6950965", "0.69267964", "0.69...
0.7604963
1
Update and return an existing `Alumno` instance, given the validated data.
def update(self, instance, validated_data): instance.edad_min = validated_data.get('edad_min', instance.edad_min) instance.edad_max = validated_data.get('edad_max', instance.edad_max) instance.complejo_id = validated_data.get('complejo_id', instance.complejo_id) instance.turno_id = valid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, instance, validated_data):\n for attr, value in list(validated_data.items()):\n if attr == 'authority':\n instance.authority = value\n else:\n setattr(instance, attr, value)\n instance.save()\n return instance", "def update...
[ "0.5845844", "0.5769151", "0.57466364", "0.5688297", "0.56788665", "0.5669592", "0.5633918", "0.5633918", "0.5615619", "0.55975354", "0.55958843", "0.55896044", "0.5553421", "0.55398446", "0.5533651", "0.5492649", "0.54891443", "0.5474566", "0.5474315", "0.54662853", "0.54543...
0.6467178
0
Returns a list of the file's full filespaths from the passed directory.
def get_files_in_dir(dir: str): file_list = [f"{dir}/{file}" for file in listdir(dir) if isfile(join(dir, file))] return file_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_filepaths(self, directory):\n folder_paths = [os.path.join(directory, folder) for folder in os.listdir(directory) if not folder.startswith('.')]\n filepaths = [[os.path.join(cur_folder, cur_file) for cur_file in os.listdir(cur_folder)] for cur_folder in folder_paths]\n return filepath...
[ "0.82656676", "0.8022355", "0.80130976", "0.7965983", "0.7958262", "0.79399973", "0.7929841", "0.7923375", "0.78915095", "0.78915095", "0.78915095", "0.7870893", "0.77364165", "0.76328206", "0.76297075", "0.76133543", "0.7523412", "0.7522805", "0.74846363", "0.74801105", "0.7...
0.7711428
13
Loads a .pkl file.
def load_pkl_file(p): pkl_file = open(p, 'rb') obj = pickle.load(pkl_file) pkl_file.close() return obj
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pkl_file(path):\n with open(path, 'rb') as pkl_file:\n return pickle.load(pkl_file)", "def load_pkl(file_name):\n with open(file_name) as fp:\n data = pkl.load(fp)\n return data", "def load_pkl(path):\r\n f = open(path, 'rb')\r\n try:\r\n rval = cPickle.load(f)\r\n ...
[ "0.80848205", "0.80261904", "0.7606655", "0.74007636", "0.7380519", "0.7297209", "0.72097653", "0.7130443", "0.699941", "0.69030744", "0.6784717", "0.66750306", "0.6643464", "0.6591345", "0.65817916", "0.6562977", "0.6518841", "0.65133154", "0.65023845", "0.64697045", "0.6465...
0.8053456
1
Saves train and test DataFrames.
def save_train_test(train_df, test_df, save_path: str, save_as_dict: bool=True): if save_as_dict: data = { 'train_df': train_df, 'test_df': test_df } save_pkl_file(data, save_path) else: # Remove the extension so we can add 'train' or 'test' to the save_pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __save_datasets(self):\n self.train.to_csv('{}/{}/{}'.format(path_to_train_set, img_format, 'train.csv'))\n self.valid.to_csv('{}/{}/{}'.format(path_to_valid_set, img_format, 'valid.csv'))\n self.test.to_csv('{}/{}/{}'.format(path_to_test_set, img_format, 'test.csv'))", "def download_tra...
[ "0.74632454", "0.72168815", "0.68651634", "0.6844151", "0.684323", "0.6843225", "0.671058", "0.6538746", "0.6511335", "0.64811313", "0.64115703", "0.63099635", "0.6287524", "0.62760574", "0.6226931", "0.618777", "0.6178389", "0.6170827", "0.61698985", "0.6161954", "0.6153325"...
0.75162804
0
Generate a training set and test set from data
def train_test_split(features, outcomes, percent_train, limited_size=-1): if len(features) != len(outcomes): raise IndexError('the number of feautre instances and outcome instances do not match') if percent_train >= 100 or percent_train <= 0: raise ValueError('percent must be between 0 and 100')...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_train_test(self):\n x, y = self.read_data()\n x_train, y_train, x_test, y_test = self.sample_data(x, y)\n self.train = (x_train, y_train)\n self.test = (x_test, y_test)", "def get_training_and_testing_sets(data, Y):\r\n data = pd.concat([data, Y], axis=1)\r\n x,y=da...
[ "0.7984581", "0.7837024", "0.7367375", "0.73139334", "0.72865283", "0.7285406", "0.7207996", "0.71946037", "0.71236736", "0.7105508", "0.7062874", "0.7050452", "0.70330983", "0.70330036", "0.69531333", "0.69360524", "0.692125", "0.68574643", "0.6853784", "0.6832601", "0.67617...
0.0
-1
Generate a training set and test set from data
def generate_optimal_pipeline(features, outcomes, output_dir, memory=None): if(features.shape[0] * features.shape[1] > (50000 * 250)): config_dict = 'TPOT light' else: config_dict = None pipeline_optimizer = TPOTRegressor(generations=GENERATIONS, population_size=POPULATION_SIZE, verbosity=g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_train_test(self):\n x, y = self.read_data()\n x_train, y_train, x_test, y_test = self.sample_data(x, y)\n self.train = (x_train, y_train)\n self.test = (x_test, y_test)", "def get_training_and_testing_sets(data, Y):\r\n data = pd.concat([data, Y], axis=1)\r\n x,y=da...
[ "0.7985538", "0.78372854", "0.736821", "0.73148525", "0.72858316", "0.7285773", "0.7208365", "0.7195767", "0.7123206", "0.7106801", "0.7062899", "0.7049372", "0.7033258", "0.70329034", "0.69533086", "0.6935356", "0.69219756", "0.6859359", "0.6853718", "0.68311256", "0.6761479...
0.0
-1
Look over spacecraft files and make a histogram of (solid angle [sr] time interval [sec]) on MET vs. Zenith angle vs. Cos(Inclination)
def make_livetime_histogram(aHtgLt, nRegion, pathFileScAll, metStart, metStop, aFileToI, aCoordsPix_array, aAreaPix_array, origin_time=0, metExStart=0, metExStop=0): fmwStart = ConvertMetToFMW(metStart) fmwStop = ConvertMetToFMW(metStop) print '==========================================' print 'Going to...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculation_time_analysis():\n\tfrom . import spectra as sp\n\tp_dict = {'Bfield':700,'rb85frac':1,'Btheta':88*np.pi/180,'Bphi':0*np.pi/180,'lcell':75e-3,'T':84,'Dline':'D2','Elem':'Cs'}\n\tchiL,chiR,chiZ = sp.calc_chi([-3500],p_dict)\n\t\n\tfor angle in [0, np.pi/32, np.pi/16, np.pi/8, np.pi/4, np.pi/2]:\n\t\...
[ "0.5840523", "0.5802977", "0.57698035", "0.5718962", "0.5679438", "0.5674738", "0.5654353", "0.5648745", "0.5530748", "0.55119634", "0.55090517", "0.544853", "0.54482937", "0.5443324", "0.54364717", "0.5420338", "0.54029834", "0.53914154", "0.5384595", "0.5371579", "0.5368214...
0.6619343
0
Clips gradients computed during backpropagation to avoid explosion of gradients.
def clip_gradient(self, grad_clip): for group in self.optimizer.param_groups: for param in group['params']: if param.grad is not None: param.grad.data.clamp_(-grad_clip, grad_clip)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backward(self, inputs, gradients, **kwargs):\n grad_relu = inputs > 0\n return gradients * grad_relu", "def clip_gradients(gradients, clip):\n if T.gt(clip, 0):\n gradients = [T.clip(g, -clip, clip) for g in gradients]\n return gradients", "def backward(self, gradient):\n ...
[ "0.65478826", "0.65217435", "0.6488792", "0.6488792", "0.6420124", "0.63564134", "0.6298884", "0.6239288", "0.6235655", "0.6235655", "0.62341547", "0.6193107", "0.6191413", "0.6174061", "0.6174061", "0.6159354", "0.61551833", "0.6153523", "0.61124265", "0.61026716", "0.610064...
0.60037535
26
Assuming there is a single avatar Action is in form env.step(actionId)
def test_history_SinglePlayer_HasHistory(test_name): env = build_test_env( test_name, "tests/gdy/test_step_SinglePlayer_SingleActionType.yaml" ) obs, reward, done, info = env.step(1) expected_history = [{ 'PlayerId': 1, 'ActionName': 'move', 'Tick': 0, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _step(self, action):\n \n obs, reward, done, info = self.env.step(action)\n\n \n advice=self.generateAdvice()[1]\n\n obs = {\n \"image\": obs,\n \"advice\": advice\n }\n\n\n \n\n\n\n return obs, reward, done, info", "def perform_st...
[ "0.6879284", "0.62631834", "0.6221962", "0.6168562", "0.61083734", "0.60759073", "0.6034386", "0.5922812", "0.5875414", "0.5871011", "0.5848797", "0.5848324", "0.58217794", "0.58200806", "0.574704", "0.57444763", "0.5730321", "0.57280064", "0.57254195", "0.57155097", "0.57009...
0.0
-1
Assuming there is a single avatar Action is in form env.step(actionId)
def test_history_SinglePlayer_NoHistory(test_name): env = build_test_env( test_name, "tests/gdy/test_step_SinglePlayer_SingleActionType.yaml", enable_history=False ) obs, reward, done, info = env.step(1) assert 'History' not in info sample = env.action_space.sample() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _step(self, action):\n \n obs, reward, done, info = self.env.step(action)\n\n \n advice=self.generateAdvice()[1]\n\n obs = {\n \"image\": obs,\n \"advice\": advice\n }\n\n\n \n\n\n\n return obs, reward, done, info", "def perform_st...
[ "0.6879888", "0.6264497", "0.6223056", "0.6168731", "0.6109203", "0.6076852", "0.6032723", "0.5923812", "0.5877399", "0.5872794", "0.5849838", "0.5849252", "0.58221585", "0.5820863", "0.5747994", "0.57450235", "0.5731134", "0.57284456", "0.5726483", "0.57167464", "0.5702504",...
0.0
-1
There is no avatar Player performing multiple actions in a single step env.step([ [x1, y1, actionId1], [x2, y2, actionId2] ])
def test_history_SinglePlayer_MultipleAction(test_name): env = build_test_env( test_name, "tests/gdy/test_step_SinglePlayer_SelectSource_SingleActionType_MultipleAction.yaml" ) obs, reward, done, info = env.step([ [2, 3, 1], [1, 4, 3], ]) expected_history = [ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self,action):\n observation, reward, done, info = self.env.step(action)\n if info[\"health\"] <= 0 or info[\"enemy_health\"] <= 0:\n self.player_hp = 120\n self.enemy_hp = 120\n reward = 0\n else:\n self.player_hp = info['health']\n ...
[ "0.6572526", "0.6459972", "0.64552194", "0.6449714", "0.6434788", "0.64279014", "0.64060885", "0.6402929", "0.63347393", "0.6286504", "0.6276009", "0.62723917", "0.622544", "0.62236977", "0.6215904", "0.6177647", "0.6166431", "0.61575204", "0.61478454", "0.61081797", "0.61075...
0.0
-1
There is an avatar Multiple players env.step([ [actionId_player1], [actionId_player2] ])
def test_history_MultiplePlayer_History(test_name): env = build_test_env( test_name, "tests/gdy/test_step_MultiPlayer_SingleActionType.yaml" ) obs, reward, done, info = env.step([ 1, 3, ]) expected_history = [ {'PlayerId': 1, 'ActionName': 'move', 'Tick': 0,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self, action):\n self.game.play_single_turn([action])\n next_obs = self.get_state()\n reward = self.game.player_1.score - self.game.turn_count\n done = self.game.check_for_end_of_game() or self.game.turn_count > 25\n\n if done:\n if self.game.player_1.score > ...
[ "0.61099774", "0.597763", "0.59705085", "0.593915", "0.58626133", "0.5805523", "0.56825304", "0.56517285", "0.5641856", "0.56401896", "0.563502", "0.56247324", "0.56229705", "0.56197584", "0.55769986", "0.55767983", "0.55717695", "0.5540885", "0.5540204", "0.553557", "0.54902...
0.0
-1
There no avatar, multiple players env.step([ [ player 1 multiple actions [x1, y1, action_type, actionId1], [x2, y2, action_type, actionId2] ], [ player 2 multiple actions [x1, y1, action_type, actionId1], ], ])
def test_history_MultiplePlayer_MultipleAction_History(test_name): env = build_test_env( test_name, "tests/gdy/test_step_MultiPlayer_SelectSource_MultipleActionType_MultipleAction.yaml" ) obs, reward, done, info = env.step([ [ [1, 3, 0, 1], [3, 4, 1, 3], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self,action):\n observation, reward, done, info = self.env.step(action)\n if info[\"health\"] <= 0 or info[\"enemy_health\"] <= 0:\n self.player_hp = 120\n self.enemy_hp = 120\n reward = 0\n else:\n self.player_hp = info['health']\n ...
[ "0.6771211", "0.6563184", "0.6512123", "0.6502924", "0.63414675", "0.6318815", "0.62837267", "0.6269722", "0.6246364", "0.62127644", "0.6204405", "0.6197293", "0.61846834", "0.61688", "0.6157189", "0.6128305", "0.61026144", "0.6097804", "0.6087183", "0.60775745", "0.60597694"...
0.56935376
56
Returns an empty source sequence. 1 xs = empty() Returns a source sequence with no items.
def empty() -> AsyncObservable: return Empty()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty() -> ObservableBase:\n from ..operators.observable.empty import empty\n return empty()", "def emptyGenerator():\n return\n yield", "def empty(self):", "def empty():\n return CAT([], 0, 0, active=False)", "def empty(self):\n return [cell for cell in self.compact i...
[ "0.7190336", "0.6586385", "0.6339112", "0.62491333", "0.61783946", "0.61632603", "0.6109439", "0.5943606", "0.5919759", "0.58963215", "0.5843404", "0.5801935", "0.5801185", "0.5760105", "0.57408905", "0.5725397", "0.5718578", "0.57175076", "0.5712515", "0.57118976", "0.568722...
0.65011406
2
Signal handler for controlling manage
def handler(signum, frame): m.signal()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def management_signal_notified(self, signal):\n # allow mgmt signal counting\n super().management_signal_notified(signal)\n # make it known that it was notified\n self._management_notified = True", "def signal(self):\n pass", "def test_allows_mgmt_signal_handler_override(self...
[ "0.6495568", "0.62869585", "0.60036194", "0.5998795", "0.5967664", "0.59662455", "0.5890098", "0.5718116", "0.5702595", "0.56896913", "0.5667243", "0.56670564", "0.56377053", "0.55687994", "0.5566352", "0.5566352", "0.5560538", "0.55468893", "0.5545095", "0.5533499", "0.55291...
0.51896775
67
Sets the performance data of the connection
def preformance(self, perf): self.perf = perf
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_data(self):\n for attribute in [\"flow_rate\"]:\n self._data[attribute] = self._connection.measure", "def set_performance(self, performance):\n weight, max_payload, max_endurance, max_dimension, build_time = performance\n self.weight = {'value': weight, 'unit': 'N'}\n ...
[ "0.65992594", "0.5902569", "0.5862756", "0.5830329", "0.57924294", "0.57833534", "0.57557845", "0.5734162", "0.56692535", "0.5660908", "0.565647", "0.56558716", "0.56558716", "0.56389415", "0.56088275", "0.5608227", "0.5593765", "0.5593765", "0.5570513", "0.55661803", "0.5554...
0.0
-1
Setup an nonblocking IPv4 stream socket. Reusing the socket if available, and listening for BACKLOG number of connections.
def init(self, HOST, PORT, BACKLOG): s = socket(AF_INET, SOCK_STREAM) s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) #s.setblocking(0) s.bind((HOST, PORT)) s.listen(BACKLOG) # Add socket to list of available inputs self.server = s self.inputs.append(s) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_for_run(self):\n self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n self.server.bind((self.ip_address, self.port))\n self.server.listen(100)", "def initialize_socket(self):\n try:\n ...
[ "0.6098318", "0.6078186", "0.60704386", "0.59955555", "0.5970364", "0.5955056", "0.59149724", "0.59033114", "0.58959544", "0.58484787", "0.5810466", "0.57604283", "0.5742364", "0.57147354", "0.5676988", "0.56547594", "0.56545484", "0.562925", "0.5628846", "0.5623654", "0.5597...
0.60635066
3
Run Manage Select sockets, create new connections, and send/recv data.
def run(self): while self.inputs: readable, writeable, exceptions = select(self.inputs, self.outputs, self.inputs) for s in readable: if s is self.server and self.acc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n while True:\n # Get the list sockets which are ready to be read through select\n all_connections = list(self.connection_dict.values()) + self.new_connections\n read_sockets, _, _ = select.select(all_connections, [], [])\n\n for sock in read_socket...
[ "0.7065427", "0.6981465", "0.6548176", "0.6485487", "0.6466612", "0.6442823", "0.63081646", "0.63043135", "0.6303645", "0.6295815", "0.62055284", "0.61597306", "0.6147114", "0.6142933", "0.61378807", "0.61182433", "0.6065653", "0.6053135", "0.60521066", "0.6041287", "0.594735...
0.6180113
11
Parse incoming data for socket s
def parse(self, data, s): fn = s.fileno() perf = re.compile("<xml><perf>(\d+)</perf></xml>") numbers = re.compile("<xml>(?:<number>(\d+)</number>)+</xml>") if not self.accepting: self.mq[fn].put_nowait("die\n") self.inputs.remove(s) else: sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(data: bytes, port: int, origin: helpers.ConnectionType):\n # Ignore packets from master server... game server is more interesting\n if port == helpers.MASTER_PORT:\n return\n # Iteratively parse packet data until nothing is left to parse\n reads = 0\n while len(data) >= 2:\n ...
[ "0.68106925", "0.6662685", "0.6619296", "0.66118187", "0.66085845", "0.65729916", "0.6566147", "0.6561392", "0.65554523", "0.6542034", "0.65204155", "0.65103513", "0.64792174", "0.64737993", "0.64652234", "0.6451255", "0.6406737", "0.6398697", "0.6397721", "0.63719755", "0.63...
0.7151742
0
Accept an incoming socket connection
def accept(self, s): conn, addr = s.accept() conn.setblocking(0) self.conns[conn] = Connection(conn, addr) self.inputs.append(conn) self.log("New connection from: %s", addr) self.mq[conn.fileno()] = Queue()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AcceptSocket(self) -> Socket:", "def accept_connection(self):\n # if not settings.USE_SOCKETS:\n # return\n self.dbg(\"sockets_event\",\n \"Blocking on accept_connection for {}\",\n [self.data_name])\n # now keep talking with the client\n self....
[ "0.8224586", "0.81074625", "0.7585465", "0.75491565", "0.7494398", "0.74706304", "0.7337153", "0.72807235", "0.7280459", "0.7264571", "0.7237035", "0.7221729", "0.7203442", "0.71945244", "0.714089", "0.69014674", "0.68742543", "0.683105", "0.68192405", "0.6808297", "0.6806378...
0.6965163
15
Send messages from socket queue to socket.
def send(self, s): try: next_msg = self.mq[s.fileno()].get_nowait() except QueueEmpty: #print >>sys.stderr, 'output queue for', s.getpeername(), 'is empty' # No messages waiting so stop checking for writability. self.outputs.remove(s) except Socket...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _send(self):\n while self.socket is not None:\n try:\n data = self._get_data_from_send_queue()\n if self.socket is not None:\n header = self._create_data_header(data)\n with self.socket_lock:\n self.soc...
[ "0.7570823", "0.7434461", "0.7400673", "0.736733", "0.7216632", "0.7153784", "0.7150297", "0.6992216", "0.69611615", "0.692399", "0.6897112", "0.6851757", "0.6817943", "0.68100935", "0.6747445", "0.6745317", "0.672771", "0.6702367", "0.66685253", "0.66651344", "0.6663716", ...
0.74609864
1
Close the socket 's' remove it from message queues remove it from inputs and outputs list
def remove(self, s): if s in self.outputs: self.outputs.remove(s) self.inputs.remove(s) del self.conns[s] s.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\n if self.pending_messages:\n print(\"?? closing client socket with unsent messages. message list follows. \")\n for message in self.pending_messages:\n print(\"*** \", message)\n self.socket_.shutdown(socket.SHUT_RDWR)\n self.socket_.close...
[ "0.6987036", "0.6689519", "0.6636837", "0.660379", "0.6540728", "0.6522226", "0.6471989", "0.6421278", "0.6414562", "0.64129907", "0.64037186", "0.63122636", "0.62923497", "0.62892485", "0.62617534", "0.62568074", "0.62358254", "0.62116987", "0.620988", "0.6200299", "0.619964...
0.65682644
4
Signal handling for Manage object Reads in rest of data from clients, sends 'kill' message to all clients and exits
def signal(self): self.log("Server shutting down.") self.accepting = False for s in self.inputs: if s is self.server: self.inputs.remove(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remote_kill():", "def handler(self):\n\t\tself.exitClient()", "def kill(self):\n\t\t\n\t\tif not self.proc:\n\t\t\tself.logf.error('Received kill request, but I am not aware of any quake2 server running!')\n\t\t\treturn\n\t\t\n\t\tif self.proc.poll():\n\t\t\tself.logf.error('Received kill request, but the ...
[ "0.63532007", "0.6216608", "0.5885992", "0.58741534", "0.58577865", "0.5848533", "0.5847207", "0.5839106", "0.58010256", "0.58010256", "0.57763827", "0.57727134", "0.5766851", "0.57256085", "0.57066345", "0.5705488", "0.5705338", "0.5680359", "0.5674788", "0.5658976", "0.5643...
0.55191106
30
Takes a route function and applies pretty_errors to it, ensuring that if the function fails when called it will throw an appropriate exception.
def make_route(*route_args, **route_kwargs): def config_pretty_errors(fn): """ :param fn: func :return: func <pretty_errors> """ fn.route_args = route_args fn.route_kwargs = route_kwargs return pretty_errors(fn) return config_pretty_errors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def catch_errors(f):\n\n @functools.wraps(f)\n def func(*args, **kwargs):\n try:\n return f(*args, **kwargs)\n except HorizonError as exception:\n print_failure(f\"{str.upper(f.__name__)} request failed to successfully execute. {exception.status_code if exception else None...
[ "0.646833", "0.6162938", "0.60064167", "0.59349936", "0.5697101", "0.5608123", "0.56056154", "0.558898", "0.5550731", "0.5529519", "0.5516675", "0.5480708", "0.54793113", "0.5434496", "0.5430767", "0.5355389", "0.533879", "0.53027284", "0.528631", "0.52726746", "0.5265935", ...
0.65817827
0
Registers a route using Flask's route() method. Depends on make_route() to set attributes, so calling function nests this function after make_route().
def register(app, fn): @functools.wraps(fn) def config_route(**kwargs): """ :param kwargs: str, id of existing entry :return: dict or exception """ return fn(app.config, **kwargs) app.route(*fn.route_args, **fn.route_kwargs)(config_route)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_route(self, route, app):\n assert route not in self.routes\n self.routes[route] = app", "def add_route(self, route: Route, routing_url: str, methods: typing.Iterable[str] = (\"GET\",)):\n # Create an endpoint name for the route.\n route.routing_url = routing_url\n route.me...
[ "0.79209733", "0.7192723", "0.71093345", "0.71085656", "0.6970921", "0.6878834", "0.6854651", "0.6851344", "0.68498003", "0.6847353", "0.682385", "0.68175274", "0.6793829", "0.67623925", "0.6709542", "0.66622424", "0.66376895", "0.6614897", "0.6593398", "0.6571527", "0.655145...
0.6497629
22
Checks config of route, returning the route if authorization passes and returning an exception if not.
def requires_admin(original_route): @functools.wraps(original_route) def wrapper(config, *args, **kwargs): if "Authorization" not in request.headers: raise MissingAuthorization() auth_header_value = request.headers["Authorization"] if not auth_header_value.startswith("Bearer ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_authorized(f):\n @functools.wraps(f)\n def wrapper(self, addr, request):\n if not self.sessions[addr].get(\"authorized\"):\n return Header.ERROR, Error.FORBIDDEN_REQUEST\n else:\n return f(self, addr, request)\n\n return wrapper", ...
[ "0.5924331", "0.5677408", "0.5673498", "0.5611696", "0.5605074", "0.54552543", "0.54456705", "0.5437622", "0.5402217", "0.5393605", "0.5388714", "0.5376963", "0.5369662", "0.53387743", "0.53348774", "0.53269184", "0.5319198", "0.53161675", "0.52916414", "0.5267928", "0.525631...
0.6329581
0
Agregar las criticas al final de un archivo
def appendReviewsInfile(file_path): # Para crear el archivo head = ['@relation criticas\n\n@attribute calificacion numeric\n@attribute critica string\n\n@data\n\n'] with open(file_path, "a") as myfile: writer = csv.writer(myfile) writer.writerow(head) for review in getAllReviews():...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _write_crit(crit_name, crit_contents, fobj):\n\n part = crit_contents['name']\n ammo_count = crit_contents['ammo_count'] or '-'\n flags = crit_contents['flags'] or '-'\n\n val_str = \" {crit_name:<12} {{ {part} {ammo_count} {flags} }}\\n\".format(\n crit_name=crit_name, part=part, ammo_co...
[ "0.59496677", "0.53732085", "0.53669095", "0.5254458", "0.51725936", "0.5153413", "0.5128358", "0.5076442", "0.5021931", "0.5009339", "0.4959675", "0.4952517", "0.4886669", "0.48234826", "0.47843346", "0.47599125", "0.4717787", "0.4690944", "0.46858728", "0.46683598", "0.4653...
0.4268887
87
Initialize the window and display its contents to the screen.
def initializeUI(self): self.setGeometry(100, 100, 300, 200) self.setWindowTitle('Event Handling Example') self.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _prep_window(self, parent=None):\n self.toolkit.app.initialize()\n if not self.initialized:\n self.setup(parent)\n self.resize_to_initial()\n self.update_minimum_size()\n self.update_maximum_size()", "def initialise_window(self):\n self.imageLa...
[ "0.7569187", "0.7542983", "0.75038004", "0.7413473", "0.7342436", "0.7308346", "0.7170552", "0.714782", "0.7107684", "0.71004796", "0.7086097", "0.7072577", "0.70708853", "0.7068425", "0.7060813", "0.7034016", "0.7013022", "0.69861555", "0.6979213", "0.6977984", "0.6947726", ...
0.7143477
8
Checks that both of the passwords match
def clean_password(self): password1 = self.cleaned_data.get('password1') password2 = self.cleaned_data.get('password2') if password1 and password2 and password1 != password2: raise forms.ValidationError('Passwords do not match') return password2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_passwords_match(self, password1, password2):\n return password1 == password2", "def check_password(password1: str, password2: str) -> bool:\n if password1 == password2:\n return True\n else:\n raise ValueError('Пароли не совпадают')", "def PasswordMatch(self, *args):\n ...
[ "0.83009994", "0.8058815", "0.7718188", "0.7482169", "0.74734956", "0.74406075", "0.74128413", "0.73900324", "0.737099", "0.7363211", "0.7333755", "0.73232675", "0.73163605", "0.7280678", "0.7273862", "0.727366", "0.727366", "0.72511595", "0.72487503", "0.7244461", "0.7194329...
0.7429908
6
Save data, mostly the password, in a hashed form
def save(self, commit=True): user = super(UserCreationForm, self).save(commit=False) user.set_password(self.cleaned_data['password1']) user.save() # Making user profile and assigning to CPCESU # CPCESU #group = Organization.objects.get(name='Colorado Plateau') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_user(username, data):\n\n hashed_username = base64.b64encode(Cryptography.hash(username).digest()).decode()\n\n file = open(getcwd() + Database.__DB_FILENAME, 'a')\n iv, ciphered_data = Cryptography.cipher(Cryptography.get_passphrase(), data)\n file.write(hashed_username + ':' ...
[ "0.72408736", "0.71299857", "0.67459494", "0.67451376", "0.6704457", "0.6700729", "0.6690764", "0.65380937", "0.6532989", "0.65213966", "0.651148", "0.6487244", "0.6473089", "0.64305174", "0.64227515", "0.6398669", "0.6353623", "0.63221234", "0.6308102", "0.6291499", "0.62854...
0.0
-1
Sets the initial password
def clean_password(self): return self.initial['password']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setpassword(self, pwd):\n pass", "def set_password(self, password):\n self.__init__(password=password)", "def set_password(self, password):\n self.password = password", "def _set_password(self, password):\n self._password = generate_password_hash(password)", "def passwor...
[ "0.7829949", "0.7584354", "0.7387299", "0.7378411", "0.73474324", "0.7336049", "0.73340523", "0.72898114", "0.72839683", "0.7275202", "0.7224501", "0.7217348", "0.7217348", "0.71376014", "0.71363944", "0.71319175", "0.71319175", "0.70857656", "0.70481783", "0.70444065", "0.70...
0.642688
66
Row echelon form of self
def echelon(self): new_value = [self.matrix[i] + [self.result[i]] for i in range(len(self.matrix))] # Loop through each row for i, current in enumerate(new_value): # Check if it's a potential pivot if i < len(new_value) - 1: # Elimate all in the same co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row(self):\n\t\treturn self.__row", "def rows(self):\r\n raise NotImplementedError", "def to_row_echelon(self):\n return self._to_row_echelon(fully_reduce = False)", "def row(self) -> TableRow:\n raise NotImplementedError", "def get_rows(self):\n raise NotImplementedError('S...
[ "0.70609975", "0.65889734", "0.65858597", "0.6565646", "0.65521294", "0.65164995", "0.65140456", "0.6405884", "0.64036775", "0.6367222", "0.63488394", "0.6321696", "0.6264376", "0.6230606", "0.6143434", "0.61398244", "0.61308104", "0.6130064", "0.61283", "0.611047", "0.606063...
0.601407
25
Row echelon form of self
def echelon_with_steps(self): new_value = [self.matrix[i] + [self.result[i]] for i in range(len(self.matrix))] # Loop through each row print("Step begin here") for i, current in enumerate(new_value): # Check if it's a potential pivot if i < len(new_value) - 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row(self):\n\t\treturn self.__row", "def rows(self):\r\n raise NotImplementedError", "def to_row_echelon(self):\n return self._to_row_echelon(fully_reduce = False)", "def row(self) -> TableRow:\n raise NotImplementedError", "def get_rows(self):\n raise NotImplementedError('S...
[ "0.7062499", "0.658987", "0.6585491", "0.6567438", "0.6553125", "0.65173584", "0.6515596", "0.64076334", "0.64039314", "0.63662446", "0.63499534", "0.63227886", "0.62642574", "0.62316895", "0.6144202", "0.61409897", "0.61311567", "0.6127701", "0.61099464", "0.60616374", "0.60...
0.6129754
17
Return a row echelon form of block matrix
def echelon(aug_matrix: list) -> list: new_value = aug_matrix[:] # Loop through each row for i, current in enumerate(new_value): # Check if it's a potential pivot if i < len(new_value) - 1: # Elimate all in the same column beside the pivot for j in range(i + 1, len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block(B):\n return np.array(np.bmat(B))", "def gen_matrix(e):\n\tif e < 1:\n\t\treturn None\n\tm_list = [[[1, 2], [3, 0]]]\n\t_b = m_list[0]\n\tfor n in xrange(1, e):\n\t\tm = m_list[n - 1]\n\t\tm_list.append(\n\t\t\t[\n\t\t\t\t[4 * i + _b[0][0] for i in m[0]] + [4 * i + _b[0][1] for i in m[0]],\n\t\t\t\t...
[ "0.64906496", "0.6387295", "0.6329327", "0.6276677", "0.62498295", "0.6249121", "0.6209815", "0.6167374", "0.6164449", "0.6115715", "0.6108402", "0.6098269", "0.6071696", "0.59854084", "0.5969197", "0.5939759", "0.5937983", "0.5906043", "0.58834684", "0.58352166", "0.5830121"...
0.57090706
27
Return a row echelon form of block matrix
def echelon_with_steps(aug_matrix: list) -> list: new_value = aug_matrix[:] # Loop through each row print("Steps begins here") for i, current in enumerate(new_value): # Check if it's a potential pivot if i < len(new_value) - 1: # Elimate all in the same column beside the p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block(B):\n return np.array(np.bmat(B))", "def gen_matrix(e):\n\tif e < 1:\n\t\treturn None\n\tm_list = [[[1, 2], [3, 0]]]\n\t_b = m_list[0]\n\tfor n in xrange(1, e):\n\t\tm = m_list[n - 1]\n\t\tm_list.append(\n\t\t\t[\n\t\t\t\t[4 * i + _b[0][0] for i in m[0]] + [4 * i + _b[0][1] for i in m[0]],\n\t\t\t\t...
[ "0.64906496", "0.6387295", "0.6329327", "0.6276677", "0.62498295", "0.6249121", "0.6209815", "0.6167374", "0.6164449", "0.6115715", "0.6108402", "0.6098269", "0.59854084", "0.5969197", "0.5939759", "0.5937983", "0.5906043", "0.58834684", "0.58352166", "0.5830121", "0.5806784"...
0.6071696
12
Time an array with an int
def times(coef: int, array: list) -> list: return [(item * coef) for item in array]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_TimeArray_init_int64():\r\n time = ts.TimeArray(np.int64(1))\r\n npt.assert_equal(time.__repr__(), '1.0 s')\r\n\r\n pass", "def test_TimeArray_convert_unit():", "def getTimes():", "def getTimes():", "def getTimes():", "def arr_time(self, arr_time):\n\n self._arr_time = arr_time",...
[ "0.6477466", "0.6037651", "0.5831548", "0.5831548", "0.5831548", "0.58124846", "0.5811097", "0.5769816", "0.5768962", "0.5764548", "0.5730512", "0.5714224", "0.5708823", "0.5633007", "0.561181", "0.56110406", "0.5590648", "0.55521584", "0.5529344", "0.54940295", "0.5471841", ...
0.58714753
2
Reduce an array by another one
def minus(lhs: list, rhs: list) -> list: return [lhs[i] - rhs[i] for i in range(len(lhs))]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce(self, array, index):\n\n return 0", "def relay_array_reduce(c, fn, array, shape):\n assert fn.is_constant(Primitive)\n assert shape.is_constant(tuple)\n fn = fn.value\n tshp = shape.value\n ary = c.ref(array)\n if fn == P.scalar_add:\n ashp = ashape(array)\n if l...
[ "0.6348511", "0.6150579", "0.6016236", "0.5968705", "0.5848071", "0.58358955", "0.58271974", "0.5824475", "0.5751819", "0.56967777", "0.5687287", "0.55605084", "0.55590504", "0.552838", "0.5520212", "0.5507012", "0.5501756", "0.54810095", "0.5471388", "0.5470944", "0.54626155...
0.0
-1
Will tell the user what is the level of markup available in a uniformized way. Takes as argument the level, being full / rich / basic / none To avoid making page looking strange, we will put that only on textarea where it is supposed to be the most useful
def info(level): if level == 'basic': string = _("Basic markup") text = _("Only basic text tags are available in this input field.") elif level == 'rich': string = _("Rich markup") text = _("Rich and basic text tags are available in this input field.") elif level == 'fu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_to_display(level):\n if level == \"html\":\n return html_answers, html_text\n elif level == \"css\":\n return css_answers, css_text\n elif level == \"python\":\n return python_answers, python_text", "def readability(target_text):\n\n nb1 = total_words(target_text)\n n...
[ "0.6541411", "0.59189075", "0.588361", "0.5685282", "0.5556694", "0.5506273", "0.5398678", "0.537253", "0.5259121", "0.5254447", "0.522227", "0.51589924", "0.50934595", "0.50596815", "0.5027844", "0.50271535", "0.5017934", "0.50091934", "0.5007883", "0.500059", "0.50002885", ...
0.6965915
0
r""" Converts special markup characters in the input text to real HTML
def basic(text): lines = text.split("\n") result = [] for line in lines: result.append(_inline(line)) return "\n".join(result)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def txt_to_html(in_str):\n replace_list = {\n \">\": \"&gt;\",\n \"<\": \"&lt;\",\n \"\\n\": \"<br/>\",\n }\n for i in replace_list:\n in_str = re.sub(i, replace_list[i], in_str)\n return in_str", "def convertHTML(self, text):\n return text.replace('&#39;', \"'\")",...
[ "0.762879", "0.74244183", "0.7385181", "0.71260995", "0.70367193", "0.7033456", "0.6993729", "0.69431865", "0.6933242", "0.69150764", "0.69091547", "0.6881", "0.6881", "0.6840589", "0.68315023", "0.68019253", "0.6780413", "0.676863", "0.6766401", "0.67561406", "0.6736872", ...
0.0
-1
r""" Converts special markup characters in the input text to real HTML This function does the same markup as basic(), plus
def rich(text): return full(text, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def txt_to_html(in_str):\n replace_list = {\n \">\": \"&gt;\",\n \"<\": \"&lt;\",\n \"\\n\": \"<br/>\",\n }\n for i in replace_list:\n in_str = re.sub(i, replace_list[i], in_str)\n return in_str", "def encode_tags(self, text):\n text = re.sub(self.patterns['html_ope...
[ "0.7166274", "0.7025396", "0.69370985", "0.69116396", "0.68682986", "0.68594396", "0.68148464", "0.6807054", "0.67854005", "0.67552936", "0.6742589", "0.6722713", "0.6722713", "0.6673737", "0.66299605", "0.6624588", "0.6606426", "0.660245", "0.6575476", "0.651976", "0.6509007...
0.0
-1
r""" Converts special markup characters in the input text to real HTML This function does the same markup as rich(), plus it converts headings to ... >>> full('= A =') 'A' >>> full('== A ==') 'A' >>> full('=== A ===') 'A' >>> full('==== A ====') 'A' >>> full('= A =\n=== B ===') 'A\nB' >>> full('= A =\n\nintro\n\n== B =...
def full(text, allow_headings=True): lines = text.split("\n") result = [] printer = False # used to be global var in PHP # we use a stack (last in, first out) to track the current # context (paragraph, lists) so we can correctly close tags context_stack = [] quoted_text = False verbat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self, text, apply_spammer_limits=False):\n if False:\n regex = re.compile(\"&(?!nbsp;)\");\n body = regex.sub( \"&amp;\", text )\n regex = re.compile(\"<(/?)([a-zA-Z]+?)( .*?)?/?>\")\n return regex.sub( htmltag_replace, body )\n return \"\"", "...
[ "0.6172186", "0.6085963", "0.6070014", "0.6061101", "0.6056567", "0.6047235", "0.6022591", "0.6011758", "0.5911472", "0.57859755", "0.5771857", "0.57694525", "0.5719388", "0.57174504", "0.56998706", "0.5692087", "0.5658594", "0.56158036", "0.56086636", "0.56026626", "0.559274...
0.5312917
61
r""" Convert whatever content that can contain markup to a valid text output It wont touch what seems to be valid in text already, or what cannot be converted in a very satisfactory way. This function should be minimal, just to avoid weird things, not to do very fancy things.
def textoutput(text): lines = text.split("\n") result = [] protocols = "https?|ftp|sftp|file|afs|nfs" savane_tags = "verbatim|nomarkup" for line in lines: # Handle named hyperlink. line = re.sub( # find the opening brace '[' '\[' # followed by th...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reformat_text(self, text):\n xml = BeautifulSoup(text)\n self.remove_header_and_footer(xml)\n self.process_superscripts(xml)\n self.remove_footnotes(xml)\n text = xml.get_text() # Strip XML tags.\n text = self.join_hyphenated_words(text)\n text = self.remove_lin...
[ "0.68793434", "0.6470074", "0.64084923", "0.6402816", "0.63169515", "0.62916267", "0.62815624", "0.626851", "0.62062097", "0.6139577", "0.612412", "0.6121925", "0.61189353", "0.61099166", "0.6086353", "0.607869", "0.60347635", "0.602285", "0.60196966", "0.6014832", "0.6008078...
0.0
-1
Internal function for recognizing and formatting special markup characters in the input line to real HTML This function is a helper for utils_full_markup() and should not be used otherwise.
def _full_markup(line, allow_headings, context_stack, quoted_text): ############################################################# # context formatting # # the code below marks up recognized special characters, # by starting a new context (e.g. headings and lists) ###############################...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_html(self, text):\n def fixup(m):\n text = m.group(0)\n if text[:2] == \"&#\":\n # character reference\n try:\n if text[:3] == \"&#x\":\n return unichr(int(text[3:-1], 16))\n else:\n return ...
[ "0.624009", "0.61456203", "0.61188686", "0.6041081", "0.6004094", "0.5927767", "0.59231144", "0.5908411", "0.5897724", "0.58639586", "0.57926077", "0.57418895", "0.5695616", "0.5692075", "0.5687767", "0.56841373", "0.567872", "0.567524", "0.5637707", "0.5631721", "0.56164014"...
0.6084477
3
Internal function for recognizing and formatting headings This function is a helper for _full_markup() and should not be used otherwise.
def _headings(line, context_stack, start_paragraph): matches = re.search( # find one to four '=' signs at the start of a line '^(={1,4})' # followed by exactly one space + ' ' # followed by any character + '(.+)' # followed by exactly one space + ' ' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _HandleHeading(self, input_line, match, output_stream):\n match = match.strip()\n\n # Count the equals on the left side.\n leftequalcount = 0\n for char in match:\n if char != \"=\":\n break\n leftequalcount += 1\n\n # Count the equals on the right side.\n rightequalcount = 0...
[ "0.68117684", "0.6703448", "0.6686388", "0.6641036", "0.6569948", "0.65361214", "0.6381924", "0.63551927", "0.6309079", "0.63004845", "0.6290214", "0.6246954", "0.6241416", "0.62322277", "0.6224916", "0.619095", "0.610838", "0.6089141", "0.60846764", "0.6083716", "0.6078289",...
0.7195238
0
Internal function for recognizing and formatting lists This function is a helper for _full_markup() and should not be used otherwise.
def _lists(line, context_stack, start_paragraph): matches = re.search('^\s?([*0]+) (.+)$', line) if matches is not None: # determine the list level currently in use current_list_level = 0 for context in context_stack: if context == '</ul>' or context == '</ol>': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handleList(self, _): # pylint: disable=invalid-name", "def setup_list(self) -> None:\n style = self.current_line.next_line.line_parts[0].style.copy()\n\n if self.list_style is None:\n self.list_style = {}\n elif isinstance(self.list_style, str):\n self.list_style =...
[ "0.625572", "0.6235757", "0.6144444", "0.6115993", "0.61062497", "0.6073675", "0.5992033", "0.5986289", "0.59715676", "0.5956412", "0.59061575", "0.58841556", "0.5840704", "0.5832542", "0.57787555", "0.5772048", "0.57643884", "0.5758637", "0.5734864", "0.5729983", "0.57268584...
0.6597641
0
Internal function for recognizing and formatting inline tags and links This function is a helper for _full_markup() and should not be used otherwise.
def _inline(line): if len(line) == 0: return '' # Regexp of protocols supported in hyperlinks (should be protocols that # we can expect web browsers to support) protocols = "https?|ftp|sftp|file|afs|nfs" # Prepare usual links: prefix every "www." with "http://" # unless there is a // ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_links(self, text):\r\n MAX_LINK_TEXT_SENTINEL = 3000 # markdown2 issue 24\r\n\r\n # `anchor_allowed_pos` is used to support img links inside\r\n # anchors, but not anchors inside anchors. An anchor's start\r\n # pos must be `>= anchor_allowed_pos`.\r\n anchor_allowed_pos...
[ "0.57991374", "0.5778433", "0.56992257", "0.5589757", "0.5430655", "0.5376251", "0.5374833", "0.53722954", "0.53425616", "0.5325182", "0.53235716", "0.52952796", "0.5279214", "0.52436084", "0.51851094", "0.51743567", "0.51424706", "0.51421195", "0.5134545", "0.51161426", "0.5...
0.64185977
0
Get the current password
def get_password(self): return self.__password
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_password(self) -> str:\n return pulumi.get(self, \"current_password\")", "def getPassword(self):\n\t\treturn self.Password", "def _get_password(self):\r\n return self._password", "def _get_password(self):\n return self._password", "def GetPassword(self):\n return sel...
[ "0.89230293", "0.86624825", "0.86599106", "0.8658316", "0.849225", "0.8470791", "0.84300846", "0.8415174", "0.83287334", "0.8275838", "0.8275838", "0.8275838", "0.8260763", "0.8248222", "0.82091284", "0.81729376", "0.8151032", "0.8151032", "0.8151032", "0.8151032", "0.8083733...
0.8503764
4
Creates a new password
def new_password(self): # create new password return password_generator.create_password() # have password reset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_password():\n new_pass = generate_password()\n entry_pass.delete(0, END)\n entry_pass.insert(0, new_pass)", "def create_password(self):\r\n alphabet = string.ascii_letters + string.digits\r\n password = ''.join(secrets.choice(alphabet) for i in range(30))\r\n\r\n QtWidgets.Q...
[ "0.7812141", "0.73570216", "0.7317928", "0.70469546", "0.70222723", "0.70207393", "0.7015751", "0.7004244", "0.6982175", "0.69231737", "0.68888825", "0.68539685", "0.6784342", "0.67792207", "0.67678064", "0.67359525", "0.6710755", "0.6703852", "0.6692514", "0.66761273", "0.66...
0.77939874
1
Handles a new email event
def handle_new_email(self): email = self.__email_handler.get_most_recent_email() message = self.__email_handler.get_email_body(email['id']) sender = self.__email_handler.get_email_sender(email['id']) if 'COMMAND' in message: if 'test' in message: print(f'{se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def handle_email(self, email):\n\t\tif 'logdir' in self.log_settings:\n\t\t\tfilename = 'email_%s_%s.eml' % (datetime.datetime.utcnow().isoformat(), str(uuid.uuid4()))\n\t\t\twith open(str(Path(self.log_settings['logdir'], 'emails', filename).resolve()), 'wb') as f:\n\t\t\t\tf.write(email.email.as_bytes())\n...
[ "0.69614106", "0.641426", "0.63397574", "0.62871844", "0.62519395", "0.61346054", "0.60729545", "0.6032336", "0.60047245", "0.59550864", "0.5944151", "0.5934481", "0.5925262", "0.59202504", "0.5915834", "0.59125566", "0.5903289", "0.58379304", "0.58089226", "0.57496667", "0.5...
0.77442443
0