query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Test suite including all test suites
def test_suite(): testSuite = unittest.TestSuite() testSuite.addTest(test_spec("test_cmd_parser")) return testSuite
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suite():\n test_suite = unittest.TestSuite()\n test_suite.addTest(unittest.makeSuite(globalOptimizerTest))\n test_suite.addTest(unittest.makeSuite(recursiveStepTest))\n return test_suite", "def main():\n # add all new test suites per test module here\n suite_date = test_date.suite()\n su...
[ "0.79815567", "0.79566133", "0.79299814", "0.7830009", "0.78079045", "0.77646685", "0.7761804", "0.7670637", "0.7668768", "0.7660842", "0.7646167", "0.7619189", "0.7598848", "0.7583602", "0.75772774", "0.7562298", "0.75592405", "0.752341", "0.75119865", "0.75030947", "0.74757...
0.72484934
39
_operator()_ Used as callback to handle events that have been subscribed to
def __call__(self, event, payload): logging.debug("Received Event: %s" % event) logging.debug("Payload: %s" % payload) # start debug event if event == "MergeAccountant:StartDebug": logging.getLogger().setLevel(logging.DEBUG) return # stop debug event if event == "MergeAccountant:EndDebug": logging.getLogger().setLevel(logging.INFO) return # enable event if event == "MergeAccountant:Enable": self.enabled = True return # disable event if event == "MergeAccountant:Disable": self.enabled = False return # a job has finished if event == "JobSuccess": try: self.jobSuccess(payload) except Exception, ex: msg = "Unexpected error when handling a " msg += "JobSuccess event: " + str(ex) msg += traceback.format_exc() logging.error(msg) return # a job has failed if event == "GeneralJobFailure": try: self.jobFailed(payload) except Exception, msg: logging.error("Unexpected error when handling a " + \ "GeneralFailure event: " + str(msg)) return # wrong event logging.debug("Unexpected event %s, ignored" % event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe(observer):", "def subscribe(observer):", "def observe(self, event_pattern, priority, callback):\n pass # pragma: no cover", "def __call__(self, trigger, type, event):", "def subscribe(self, event_handler):\n pass # pragma: no cover", "def events(self):", "def doEvent(self,...
[ "0.65357095", "0.65357095", "0.65028983", "0.6397221", "0.62587845", "0.62279207", "0.6155505", "0.61392504", "0.61106503", "0.6109636", "0.60489565", "0.5954443", "0.5939382", "0.5924449", "0.58737683", "0.58658725", "0.5865626", "0.58425915", "0.5839737", "0.58376145", "0.5...
0.0
-1
_jobSuccess_ A job has finished successfully. Non merge jobs are ignored. If it is complete success, all input files are marked as 'merged' and the output file as 'merged'. JobSuccess for partial merge are not implemented yet!. When it
def jobSuccess(self, jobReport): jobName = None try: #// Invoke job report handler with jobReport location and flag to enable/disable merge job report handling handler = ReportHandler(jobReport, int(self.args['MaxInputAccessFailures']), enableMergeHandling=self.enabled) jobName = handler() logging.info('this is jobname'+ str(jobName)) except Exception, ex: msg = "Failed to handle job report from job:\n" msg += "%s\n" % jobReport msg += str(ex) msg += "\n" msg += traceback.format_exc() logging.error(msg) #// Failed to read job report if jobName is None: return # files can be cleaned up now logging.info("trigger cleanup for: %s" % jobName) try: self.trigger.setFlag("cleanup", jobName, "MergeAccountant") except (ProdAgentException, ProdException): logging.error("trying to continue processing success event") return #// END jobSuccess
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_job_success(self, job):\n super().handle_job_success(job)\n\n self._handle_job_status(job, \"finished\")", "def jobFailed(self, jobName):\n\n # ignore non merge jobs\n if jobName.find('mergejob') == -1:\n logging.info(\"Ignoring job %s, since it is not a merge jo...
[ "0.65560216", "0.6231087", "0.61976314", "0.61811936", "0.6096661", "0.60207766", "0.58854157", "0.5847686", "0.5811745", "0.5810917", "0.57712907", "0.572245", "0.5717534", "0.5705085", "0.5678648", "0.56590325", "0.5635989", "0.5614332", "0.5596668", "0.55745363", "0.556087...
0.67897856
0
_jobFailed_ A job has failed. Non merge jobs are ignored. Since it is a general failure, the error handler has tried to submit the job a number of times and it always failed. Mark then all input files as 'unmerged' (which will increment their failures counter) and the output file as 'failed'. If limit of failures in input files is reached, they are tagged as 'invalid'
def jobFailed(self, jobName): # ignore non merge jobs if jobName.find('mergejob') == -1: logging.info("Ignoring job %s, since it is not a merge job" \ % jobName) # Add cleanup flag for non merge jobs too logging.info("trigger cleanup for: %s" % jobName) try: self.trigger.setFlag("cleanup", jobName, "MergeAccountant") except (ProdAgentException, ProdException): logging.error("trying to continue processing failure event") return # files can be cleaned up now logging.info("trigger cleanup for: %s" % jobName) try: self.trigger.setFlag("cleanup", jobName, "MergeAccountant") except (ProdAgentException, ProdException): logging.error("trying to continue processing failure event") # verify enable condition if not self.enabled: return # open a DB connection database = MergeSensorDB() # start a transaction database.startTransaction() # get job information try: jobInfo = database.getJobInfo(jobName) # cannot get it! except Exception, msg: logging.error("Cannot process Failure event for job %s: %s" \ % (jobName, msg)) database.closeDatabaseConnection() return # check that job exists if jobInfo is None: logging.error("Job %s does not exist." % jobName) database.closeDatabaseConnection() return # check status if jobInfo['status'] != 'undermerge': logging.error("Cannot process Failure event for job %s: %s" \ % (jobName, "the job is not currently running")) database.closeDatabaseConnection() return # get dataset id datasetId = database.getDatasetId(jobInfo['datasetName']) # mark all input files as 'unmerged' (or 'invalid') unFinishedFiles = [] for fileName in jobInfo['inputFiles']: # update status newStatus = database.updateInputFile(\ datasetId, fileName, \ status = "unmerged", \ maxAttempts = int(self.args['MaxInputAccessFailures'])) # add invalid files to list of non finished files if newStatus == 'invalid': unFinishedFiles.append(fileName) # mark output file as 'failed' database.updateOutputFile(datasetId, jobName=jobName, status='failed') # commit changes database.commit() # notify the PM about the unrecoverable files if len(unFinishedFiles) > 0: File.merged(unFinishedFiles, True) # log message logging.info("Job %s failed, file information updated." % jobName) # close connection database.closeDatabaseConnection()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fail(self):\n self.cleanup()\n self.runner.report_job_fail(self.id)", "def handle_job_error(self, job):\n super().handle_job_error(job)\n\n self._handle_job_status(job, \"failed\")", "def runjob(job):\n inputfiles = glob.glob(job['InputFile'])\n logecho(' %s file/...
[ "0.64195037", "0.6388101", "0.6150792", "0.6027144", "0.60192287", "0.60131675", "0.5950463", "0.59497935", "0.5936166", "0.59313744", "0.5911836", "0.5835701", "0.5786333", "0.5782995", "0.5782858", "0.57241905", "0.57127255", "0.5671086", "0.56666774", "0.56585604", "0.5630...
0.7485483
0
_startComponent_ Fire up the two main threads
def startComponent(self): # create message service instance self.ms = MessageService() # register self.ms.registerAs("MergeAccountant") # subscribe to messages self.ms.subscribeTo("MergeAccountant:StartDebug") self.ms.subscribeTo("MergeAccountant:EndDebug") self.ms.subscribeTo("MergeAccountant:Enable") self.ms.subscribeTo("MergeAccountant:Disable") self.ms.subscribeTo("JobSuccess") self.ms.subscribeTo("GeneralJobFailure") self.ms.subscribeTo("MergeAccountant:SetJobCleanupFlag") # set trigger access for cleanup self.trigger = Trigger(self.ms) # set message service instance for PM interaction File.ms = self.ms # wait for messages while True: # get message messageType, payload = self.ms.get() self.ms.commit() # create session object Session.set_database(dbConfig) Session.connect() # start transaction Session.start_transaction() # process it self.__call__(messageType, payload) self.ms.commit() # commit and close session Session.commit_all() Session.close_all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def startComponent(self):\n self.ms = MessageService()\n self.ms.registerAs(\"TaskRegisterComponent\")\n \n self.ms.subscribeTo(\"CRAB_Cmd_Mgr:NewTask\")\n self.ms.subscribeTo(\"TaskRegisterComponent:StartDebug\")\n self.ms.subscribeTo(\"TaskRegisterComponent:EndDebug\")\n...
[ "0.7069816", "0.65574837", "0.65574837", "0.6347645", "0.6330432", "0.6329626", "0.6314845", "0.62738216", "0.6261208", "0.62377006", "0.6209128", "0.6199045", "0.61689764", "0.61576235", "0.6155671", "0.61154896", "0.61113256", "0.6080329", "0.60750294", "0.60603696", "0.605...
0.6306281
7
_getVersionInfo_ return version information
def getVersionInfo(cls): return __version__ + "\n"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version_info(self):\n return self._jadeRpc('get_version_info')", "def get_version_info() -> Tuple[Text, Text]:", "def version_info(self):\n\n return __version_info__", "def info(self):\n version_str = self.version\n return Utils.version_str2tuple(version_str)", "def vers...
[ "0.80382955", "0.7959786", "0.78665364", "0.772043", "0.76289654", "0.7546513", "0.7518231", "0.7508608", "0.74194604", "0.72860444", "0.72014874", "0.7074777", "0.7063996", "0.7035926", "0.7033924", "0.699559", "0.6988741", "0.69872457", "0.69825757", "0.69360656", "0.693177...
0.80043864
1
Make sure that the marks are correctly set
def test_marks(data, request): current_marks = get_pytest_marks_on_item(request._pyfuncitem) assert len(current_marks) == 1 if data == 1: assert current_marks[0].name == "fast" elif data == 2: assert current_marks[0].name == "slow" else: raise AssertionError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check4(self, x, y, mark, d = 0):", "def check3(self, x, y, mark, d = 0):", "def assign_mark(entry: StudentEntry):\n pass", "def test_correct_init_multiple_markers(self):\n subject = self._get_test_subject(markers=MULTIPLE_MARKERS)\n\n self.assertEqual(len(subject.signal_map), len(MULTIPL...
[ "0.6549789", "0.64396226", "0.6256343", "0.5967002", "0.59457564", "0.58952796", "0.58587354", "0.5848375", "0.58305866", "0.58305866", "0.5808072", "0.57763886", "0.5767603", "0.5664824", "0.5655856", "0.5617224", "0.5596353", "0.55772895", "0.55504787", "0.55380124", "0.552...
0.5462163
23
Given string like "test_odm_pcb (tests.wedge100.test_eeprom.EepromTest)" convert to a python test format to use it directly
def format_into_test_path(self, testitem): test_string = testitem.split("(") test_path = test_string[1].split(")")[0] """ Test item has different path with different python version example: on 3.8 set_psu_cmd (tests.fuji.test_psu.Psu1Test) on 3.11 set_psu_cmd (tests.fuji.test_psu.Psu1Test.set_psu_cmd) """ if test_path.split(".")[-1].strip() != test_string[0].strip(): test_path = test_path + "." + test_string[0] return test_path.strip()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split(test_name):\n recipe, simple_test_name = test_name.split('.', 1)\n return recipe, simple_test_name", "def test_string():", "def test_parse_string(self):\n bb = parse(antlr4.InputStream(test_file))\n\n assert bb._var == {\"alpha\": 0.3423}\n\n expected = {\"name\": \"fock\", \"o...
[ "0.5940089", "0.5811446", "0.5723814", "0.5717782", "0.5511057", "0.5496379", "0.54187816", "0.54119813", "0.52977437", "0.5285956", "0.52357966", "0.52247846", "0.51995105", "0.5177037", "0.51671624", "0.5032216", "0.50164425", "0.500829", "0.50076115", "0.50026107", "0.5000...
0.57777196
2
Returns a set of test names that are formatted to a single test like 'tests.wedge100.test_eeprom.EepromTest.test_odm_pcb'
def get_all_platform_tests(self): for testitem in self.get_tests(self.discover_tests()): if not testitem: continue prefix = "tests." + self.platform + "." self.formatted_tests_set.append( prefix + self.format_into_test_path(testitem) ) if self.denylist: try: with open(self.denylist, "r") as f: denylist = f.read().splitlines() except FileNotFoundError: denylist = [] self.formatted_tests_set = [ t for t in self.formatted_tests_set if t not in denylist ] return self.formatted_tests_set
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_name(self):\r\n parts = []\r\n if self.test.__module__ != '__main__':\r\n parts.append(self.test.__module__)\r\n if hasattr(self.test, 'im_class'):\r\n parts.append(self.test.im_class.__name__)\r\n parts.append(self.test.__name__)\r\n return '.'.joi...
[ "0.7208352", "0.6553833", "0.65289885", "0.6420306", "0.6344564", "0.62654716", "0.62462103", "0.62398034", "0.6210148", "0.6169689", "0.60774684", "0.60527426", "0.5981892", "0.5960162", "0.59601563", "0.59381056", "0.58674467", "0.5789974", "0.5787742", "0.5770073", "0.5759...
0.5076667
73
Tests that trigger from outside BMC need Hostname information to BMC and userver
def set_external(args): if args.host: os.environ["TEST_HOSTNAME"] = args.host # If user gave a hostname, determine oob name from it and set it. if "." in args.host: index = args.host.index(".") os.environ["TEST_BMC_HOSTNAME"] = ( args.host[:index] + "-oob" + args.host[index:] ) if args.bmc_host: os.environ["TEST_BMC_HOSTNAME"] = args.bmc_host
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_host(self):\n pass", "def test_perform_host_action(self):\n pass", "def test_get_host_access(self):\n pass", "def test(cls, hostname):\n pass", "def test_hostname_value(self):\n \n hostname = get_hostname()\n \n # Check to make sure the h...
[ "0.72601837", "0.6868456", "0.6761789", "0.6384901", "0.63416314", "0.6243301", "0.6243301", "0.6148776", "0.6148776", "0.6120381", "0.6119962", "0.6033267", "0.60227525", "0.6017332", "0.60004425", "0.5981932", "0.5963929", "0.5948897", "0.5937301", "0.5936245", "0.5922357",...
0.6309198
5
Optional arguments for firmware upgrade test
def set_fw_args(args): os.environ["TEST_FW_OPT_ARGS"] = args.firmware_opt_args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_upgrade_with_auto_upgrade_latest_engine_enabled():", "def null_upgrade_step(setup_tool):\n pass", "def test_patch_hyperflex_server_firmware_version(self):\n pass", "def test_update_hyperflex_server_firmware_version(self):\n pass", "def check_arguments(self):\n ## only four ...
[ "0.6306604", "0.6163344", "0.583488", "0.5804764", "0.57716423", "0.57552814", "0.57459766", "0.5694769", "0.5651118", "0.5639809", "0.55904186", "0.557991", "0.55499375", "0.5547003", "0.5539552", "0.55363226", "0.5525847", "0.55074257", "0.5484567", "0.5458392", "0.5432542"...
0.6882471
0
Extracts the value between marker and index
def extract(self): # type: () -> str if self.end(): return self._src[self._marker :] else: return self._src[self._marker : self._idx]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, position):\n return self.numbers[position[0]][position[1]]", "def __getitem__(self, index):\n return self.data[index[0] - 1][index[1] - 1]", "def get_value_at_index(self, index, cc):\n tl = cc.dsget(self.title)\n return (tl[index], None)", "def marker_at_position(sel...
[ "0.63515353", "0.63282895", "0.625605", "0.62464094", "0.62333435", "0.6199576", "0.6177496", "0.6158412", "0.6130857", "0.6084534", "0.606006", "0.6025226", "0.6003024", "0.6003024", "0.5981887", "0.59495384", "0.5900323", "0.58751357", "0.5841193", "0.58206975", "0.5820006"...
0.6038684
11
Increments the parser if the end of the input has not been reached. Returns whether or not it was able to advance.
def inc(self): # type: () -> bool try: self._idx, self._current = next(self._chars) return True except StopIteration: self._idx = len(self._src) self._current = TOMLChar("\0") return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def done_parsing(self):\n # STUDENT\n return (self.input_buffer_len() == 1 ) and (self.stack_len()==1) \n # END STUDENT", "def _is_at_end(self):\n return self._peek().token_type == scanner.TokenType.EOF", "def has_next(self):\n try:\n self.next()\n ...
[ "0.693617", "0.69233114", "0.69094247", "0.6850217", "0.6331117", "0.6285765", "0.620027", "0.61610067", "0.61490417", "0.6147039", "0.6147039", "0.6147039", "0.6147039", "0.6117384", "0.6101283", "0.6094416", "0.60582894", "0.60258627", "0.60254914", "0.6012133", "0.60018945...
0.64029455
4
Increments the parser by n characters if the end of the input has not been reached.
def inc_n(self, n): # type: (int) -> bool for _ in range(n): if not self.inc(): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __advance(self, n=1):\r\n for i in range(n):\r\n if self.__tokenizer.has_more_tokens():\r\n self.__tokenizer.advance()\r\n continue\r\n return False\r\n return True", "def cmd_n(self,s):\n length = 0\n node = self.start\n ...
[ "0.6357484", "0.5569419", "0.55248344", "0.5505389", "0.5498772", "0.5482731", "0.54729337", "0.54318476", "0.5427386", "0.5418166", "0.5390718", "0.5387553", "0.53819525", "0.5361975", "0.5354554", "0.5300933", "0.52418137", "0.5228473", "0.52153623", "0.5198761", "0.5185116...
0.0
-1
Returns True if the parser has reached the end of the input.
def end(self): # type: () -> bool return self._idx >= len(self._src) or self._current == "\0"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_at_end(self):\n return self._peek().token_type == scanner.TokenType.EOF", "def is_eof(self) -> bool:\n ...", "def end_of_input():\n return at_end.bind(lambda end:\n Parser(lambda chunk, last: ParserResult.from_error(\"Not end of input\"))\n if no...
[ "0.8109592", "0.75955963", "0.7418105", "0.7389045", "0.7385828", "0.73675007", "0.733003", "0.7321836", "0.7321836", "0.7321836", "0.7321836", "0.71485347", "0.7051112", "0.7041451", "0.70217884", "0.70157605", "0.69563675", "0.695557", "0.69082236", "0.6880412", "0.6842493"...
0.70420015
13
Sets the marker to the index's current position
def mark(self): # type: () -> None self._marker = self._idx
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_pos(self, position, marker):\n i, j = self.board[position]\n self.grid[i][j] = marker", "def __setitem__(self, index, value):\n self.position[index] = value", "def set_mark( self, mark, index ):\n\n try:\n int(self.__grid[index-1])\n\n if mark.lower() ...
[ "0.7185202", "0.66934663", "0.6468027", "0.64015055", "0.63248855", "0.6277485", "0.6270743", "0.6233759", "0.6233759", "0.6202351", "0.61644644", "0.6080283", "0.60600364", "0.6030192", "0.60263723", "0.602531", "0.6000895", "0.5999829", "0.59920174", "0.5950956", "0.5903941...
0.7850461
0
Merges the given Item with the last one currently in the given Container if both are whitespace items. Returns True if the items were merged.
def _merge_ws(self, item, container): # type: (Item, Container) -> bool: last = container.last_item() if not last: return False if not isinstance(item, Whitespace) or not isinstance(last, Whitespace): return False start = self._idx - (len(last.s) + len(item.s)) container.body[-1] = ( container.body[-1][0], Whitespace(self._src[start : self._idx]), ) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_be_merged(prev, cur):\n\n WHITESPACE = (' ', '\\t')\n if not cur.mergeable or not prev.mergeable:\n return False\n # offset is char offset, not byte, so length is the char length!\n elif cur.offset != (prev.offset + prev.length):\n r...
[ "0.5630323", "0.562426", "0.51364464", "0.5081948", "0.5043025", "0.48954043", "0.48792508", "0.4865082", "0.48528847", "0.48474756", "0.48178267", "0.48116726", "0.47968078", "0.4795999", "0.478459", "0.47503677", "0.47446725", "0.47313824", "0.47310415", "0.47016767", "0.46...
0.75566405
0
Creates a generic "parse error" at the current position.
def parse_error(self, kind=ParseError, args=None): # type: () -> None line, col = self._to_linecol(self._idx) if args: return kind(line, col, *args) else: return kind(line, col)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _error(self, token, msg):\n self._interpreter.parse_error(token, msg)\n return ParseError()", "def error(self, message, token=None):\n raise ParseException(\n message,\n self.filename,\n line=self._line,\n line_number=self._line_number,...
[ "0.7336168", "0.7223053", "0.6826519", "0.6767211", "0.65252376", "0.64913183", "0.6489117", "0.64567614", "0.6366437", "0.6286208", "0.6225419", "0.6205159", "0.61615443", "0.60905075", "0.60646534", "0.60110784", "0.6001469", "0.59982574", "0.5976438", "0.59754544", "0.5968...
0.64861685
7
Returns whether a key is strictly a child of another key. AoT siblings are not considered children of one another.
def _is_child(self, parent, child): # type: (str, str) -> bool return child != parent and child.startswith(parent + ".")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_child_exists(self, key):\n return True if _Node.__find_key_in_level(self, key) else False", "def __contains__(self, key):\n\n if type(key) != self.type:\n return False\n\n first_char = key[:1]\n others = key[1:]\n\n if first_char not in self.children:\n ...
[ "0.7154145", "0.6607566", "0.6557412", "0.64785355", "0.642279", "0.62678003", "0.6224301", "0.61702096", "0.61305875", "0.60911614", "0.6060285", "0.6012716", "0.5971186", "0.59556484", "0.59540933", "0.5942657", "0.594154", "0.59342253", "0.59315073", "0.59144604", "0.59130...
0.64586204
4
Attempts to parse the next item and returns it, along with its key if the item is valuelike.
def _parse_item(self): # type: () -> Optional[Tuple[Optional[Key], Item]] self.mark() saved_idx = self._save_idx() while True: c = self._current if c == "\n": # Found a newline; Return all whitespace found up to this point. self.inc() return (None, Whitespace(self.extract())) elif c in " \t\r": # Skip whitespace. if not self.inc(): return (None, Whitespace(self.extract())) elif c == "#": # Found a comment, parse it indent = self.extract() cws, comment, trail = self._parse_comment_trail() return (None, Comment(Trivia(indent, cws, comment, trail))) elif c == "[": # Found a table, delegate to the calling function. return else: # Begining of a KV pair. # Return to beginning of whitespace so it gets included # as indentation for the KV about to be parsed. self._restore_idx(*saved_idx) key, value = self._parse_key_value(True) return key, value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getNextKey(self, item):\n return (2, item)", "def getitem(value, key):\n try:\n return value[key]\n except Exception:\n return \"\"", "def p_value_key(protItem):\n return protItem[-1]", "def p_value_key(protItem):\n return protItem[-1]", "def get_next(item: str, after:...
[ "0.6376964", "0.6067354", "0.5974745", "0.5974745", "0.59615964", "0.5913587", "0.5901849", "0.589939", "0.5882357", "0.5807142", "0.57675356", "0.5747622", "0.56723076", "0.5654322", "0.5633313", "0.56198114", "0.5533659", "0.5505485", "0.5488771", "0.54648966", "0.5464157",...
0.7419916
0
Returns (comment_ws, comment, trail) If there is no comment, comment_ws and comment will simply be empty.
def _parse_comment_trail(self): # type: () -> Tuple[str, str, str] if self.end(): return "", "", "" comment = "" comment_ws = "" self.mark() while True: c = self._current if c == "\n": break elif c == "#": comment_ws = self.extract() self.mark() self.inc() # Skip # # The comment itself while not self.end() and not self._current.is_nl() and self.inc(): pass comment = self.extract() self.mark() break elif c in " \t\r,": self.inc() else: break if self.end(): break while self._current.is_spaces() and self.inc(): pass trail = "" if self._idx != self._marker or self._current.is_ws(): trail = self.extract() return comment_ws, comment, trail
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_from_comment(self, comment):\n comment = re.sub(r'\\s+', ' ', comment.strip().strip(\"/*\").strip())\n if len(comment) == 0:\n return set(), set()\n domain_terms, code_elements = self.extract_from_sentence(comment)\n return domain_terms, code_elements", "def get...
[ "0.5537778", "0.55255157", "0.55058956", "0.54286265", "0.53183115", "0.53128594", "0.5308172", "0.5303508", "0.53024226", "0.52887475", "0.52451444", "0.52160954", "0.5189738", "0.51862514", "0.51771724", "0.5174911", "0.5149944", "0.51467705", "0.51425964", "0.5140602", "0....
0.7539042
0
Parses a Key at the current position; WS before the key must be exhausted first at the callsite.
def _parse_key(self): # type: () -> Key if self._current in "\"'": return self._parse_quoted_key() else: return self._parse_bare_key()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_bare_key(self): # type: () -> Key\n self.mark()\n while self._current.is_bare_key_char() and self.inc():\n pass\n\n key = self.extract()\n\n return Key(key, sep=\"\")", "def _parse_quoted_key(self): # type: () -> Key\n quote_style = self._current\n ...
[ "0.63221157", "0.6206109", "0.6151237", "0.5712115", "0.5649564", "0.53943276", "0.53714085", "0.5363242", "0.5210409", "0.51909065", "0.5114601", "0.50023776", "0.4978723", "0.49580935", "0.49418062", "0.4941112", "0.49383867", "0.49335584", "0.4920512", "0.49124452", "0.490...
0.68402857
0
Parses a key enclosed in either single or double quotes.
def _parse_quoted_key(self): # type: () -> Key quote_style = self._current key_type = None for t in KeyType: if t.value == quote_style: key_type = t break if key_type is None: raise RuntimeError("Should not have entered _parse_quoted_key()") self.inc() self.mark() while self._current != quote_style and self.inc(): pass key = self.extract() self.inc() return Key(key, key_type, "")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_key(self): # type: () -> Key\n if self._current in \"\\\"'\":\n return self._parse_quoted_key()\n else:\n return self._parse_bare_key()", "def test__parse_key_unquoted(value, position, expected_output, expected_position):\n state = ParserState(value)\n state....
[ "0.7441108", "0.6559555", "0.64326805", "0.6145812", "0.6115858", "0.60998946", "0.6094155", "0.5979537", "0.5926579", "0.5861342", "0.58433485", "0.58369255", "0.5756874", "0.5747807", "0.57185864", "0.57078075", "0.5646424", "0.56063914", "0.560016", "0.55992305", "0.558389...
0.6559366
2
Parses a bare key.
def _parse_bare_key(self): # type: () -> Key self.mark() while self._current.is_bare_key_char() and self.inc(): pass key = self.extract() return Key(key, sep="")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_key(self): # type: () -> Key\n if self._current in \"\\\"'\":\n return self._parse_quoted_key()\n else:\n return self._parse_bare_key()", "def parse_key(raw_key):\n raw_key_bytes = raw_key.encode('ascii')\n try:\n validate_cmek(raw_key)\n key_type = KeyType...
[ "0.76626766", "0.6655824", "0.6617215", "0.6501489", "0.6450143", "0.6249241", "0.6145767", "0.5899227", "0.5899173", "0.5889372", "0.5886852", "0.58818334", "0.5807456", "0.58011734", "0.5785233", "0.5777432", "0.57585365", "0.57519037", "0.5722677", "0.5717174", "0.57077587...
0.810298
0
Attempts to parse a value at the current position.
def _parse_value(self): # type: () -> Item self.mark() trivia = Trivia() c = self._current if c == '"': return self._parse_basic_string() elif c == "'": return self._parse_literal_string() elif c == "t" and self._src[self._idx :].startswith("true"): # Boolean: true self.inc_n(4) return Bool(True, trivia) elif c == "f" and self._src[self._idx :].startswith("false"): # Boolean: true self.inc_n(5) return Bool(False, trivia) elif c == "[": # Array elems = [] # type: List[Item] self.inc() while self._current != "]": self.mark() while self._current.is_ws() or self._current == ",": self.inc() if self._idx != self._marker: elems.append(Whitespace(self.extract())) if self._current == "]": break if self._current == "#": cws, comment, trail = self._parse_comment_trail() next_ = Comment(Trivia("", cws, comment, trail)) else: next_ = self._parse_value() elems.append(next_) self.inc() res = Array(elems, trivia) if res.is_homogeneous(): return res raise self.parse_error(MixedArrayTypesError) elif c == "{": # Inline table elems = Container() self.inc() while self._current != "}": if self._current.is_ws() or self._current == ",": self.inc() continue key, val = self._parse_key_value(False) elems.append(key, val) self.inc() return InlineTable(elems, trivia) elif c in string.digits + "+" + "-": # Integer, Float, Date, Time or DateTime while self._current not in " \t\n\r#,]}" and self.inc(): pass raw = self.extract() item = self._parse_number(raw, trivia) if item: return item try: res = parse_rfc3339(raw) except ValueError: res = None if res is None: raise self.parse_error(InvalidNumberOrDateError) if isinstance(res, datetime.datetime): return DateTime(res, trivia, raw) elif isinstance(res, datetime.time): return Time(res, trivia, raw) elif isinstance(res, datetime.date): return Date(res, trivia, raw) else: raise self.parse_error(InvalidNumberOrDateError) else: raise self.parse_error(UnexpectedCharError, (c))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self, value):\n raise NotImplementedError(\"Please implement the Class\")", "def parse_value(cls, value):\n return value", "def parse_value(cls, value):\n return value", "def parse_value(cls, value):\n raise NotImplementedError(\"subclass must implement parse_value()\")"...
[ "0.67975473", "0.6596191", "0.6596191", "0.65703046", "0.61353844", "0.60871327", "0.60674334", "0.6023864", "0.59837496", "0.5958098", "0.5956337", "0.59420466", "0.5825742", "0.57203496", "0.5710543", "0.5646205", "0.5597949", "0.5590369", "0.55894625", "0.5586219", "0.5578...
0.6330559
4
Parses a table element.
def _parse_table(self): # type: (Optional[str]) -> Tuple[Key, Item] indent = self.extract() self.inc() # Skip opening bracket is_aot = False if self._current == "[": if not self.inc(): raise self.parse_error(UnexpectedEofError) is_aot = True # Key self.mark() while self._current != "]" and self.inc(): pass name = self.extract() key = Key(name, sep="") self.inc() # Skip closing bracket if is_aot: # TODO: Verify close bracket self.inc() cws, comment, trail = self._parse_comment_trail() result = Null() values = Container() while not self.end(): item = self._parse_item() if item: _key, item = item if not self._merge_ws(item, values): values.append(_key, item) else: if self._current == "[": _, name_next = self._peek_table() if self._is_child(name, name_next): key_next, table_next = self._parse_table() key_next = Key(key_next.key[len(name + ".") :]) values.append(key_next, table_next) # Picking up any sibling while not self.end(): _, name_next = self._peek_table() if not self._is_child(name, name_next): break key_next, table_next = self._parse_table() key_next = Key(key_next.key[len(name + ".") :]) values.append(key_next, table_next) else: table = Table( values, Trivia(indent, cws, comment, trail), is_aot ) result = table if is_aot and ( not self._aot_stack or name != self._aot_stack[-1] ): result = self._parse_aot(table, name) break else: raise self.parse_error( InternalParserError, ("_parse_item() returned None on a non-bracket character."), ) if isinstance(result, Null): result = Table(values, Trivia(indent, cws, comment, trail), is_aot) return key, result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_table(table):\n rows = table.find_all('tr')\n if not rows:\n raise ValueError(\"No rows for table\")\n pages = []\n table_tag = \"<table>\"\n tbl_headers = get_tbl_headers(rows)\n table_tag += \"<tr>\"\n for header in tbl_headers.keys():\n table_tag += conf.ADD_TH_TAG(h...
[ "0.6638918", "0.65049", "0.640189", "0.6186907", "0.61552876", "0.5986234", "0.59336215", "0.5882514", "0.5852241", "0.5727533", "0.5713803", "0.57028484", "0.56890404", "0.5629742", "0.5603507", "0.55797344", "0.5575111", "0.55562884", "0.55540824", "0.5548597", "0.5501241",...
0.6397043
3
Peeks ahead nonintrusively by cloning then restoring the initial state of the parser. Returns the name of the table about to be parsed, as well as whether it is part of an AoT.
def _peek_table(self): # type: () -> Tuple[bool, str] # Save initial state idx = self._save_idx() marker = self._marker if self._current != "[": raise self.parse_error( InternalParserError, ("_peek_table() entered on non-bracket character") ) # AoT self.inc() is_aot = False if self._current == "[": self.inc() is_aot = True self.mark() while self._current != "]" and self.inc(): table_name = self.extract() # Restore initial state self._restore_idx(*idx) self._marker = marker return is_aot, table_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_aot(self, first, name_first): # type: (Item, str) -> Item\n payload = [first]\n self._aot_stack.append(name_first)\n while not self.end():\n is_aot_next, name_next = self._peek_table()\n if is_aot_next and name_next == name_first:\n _, table = s...
[ "0.5321881", "0.5258151", "0.5246666", "0.51772755", "0.5133962", "0.4889261", "0.47756714", "0.4769611", "0.4711629", "0.46457544", "0.45855626", "0.45844787", "0.45794702", "0.4570339", "0.4569376", "0.456038", "0.45316866", "0.45240548", "0.4521015", "0.45061612", "0.44987...
0.7672022
0
Parses all siblings of the provided table first and bundles them into an AoT.
def _parse_aot(self, first, name_first): # type: (Item, str) -> Item payload = [first] self._aot_stack.append(name_first) while not self.end(): is_aot_next, name_next = self._peek_table() if is_aot_next and name_next == name_first: _, table = self._parse_table() payload.append(table) else: break self._aot_stack.pop() return AoT(payload)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_table_to_xmltree_sub(node):\n # Split text into Token nodes\n # NOTE: very basic token splitting here... (to run through CoreNLP?)\n if node.text is not None:\n for tok in re.split(r'\\s+', node.text):\n node.append(et.Element('token', attrib={'word':tok}))\n \n # Recursively append children\...
[ "0.5702697", "0.56278515", "0.55263174", "0.5384425", "0.5336966", "0.52965224", "0.52801716", "0.5213338", "0.51913345", "0.5113082", "0.5075567", "0.5038085", "0.50110316", "0.49885792", "0.49777687", "0.49660102", "0.49603015", "0.49517924", "0.4944479", "0.49234688", "0.4...
0.5284191
6
Wait on an IPython AsyncResult, printing progress to stdout. Based on wait_interactive() in IPython and the output of Joblib in verbose mode.parallel This will work best when using a loadbalanced view with a smallish chunksize.
def wait_progress(ar, interval=5, timeout=-1): if timeout is None: timeout = -1 N = len(ar) tic = time.time() print "\nRunning %i tasks:" % N sys.stdout.flush() last = 0 while not ar.ready() and (timeout < 0 or time.time() - tic <= timeout): ar.wait(interval) progress, elapsed = ar.progress, ar.elapsed if progress > last: last = progress remaining = elapsed * (float(N) / progress - 1.) print ' Done %4i out of %4i | elapsed: %s remaining: %s' % ( progress, N, short_format_time(elapsed), short_format_time(remaining)) sys.stdout.flush() if ar.ready(): try: speedup = round(100.0 * ar.serial_time / ar.wall_time) print "\nParallel speedup: %i%%" % speedup # For some reason ar.serial_time occasionally throws this exception. # We choose to ignore it and just not display the speedup factor. except TypeError: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_progress(self):\n pass", "def wait_progress(self):\n pass", "def waitOutput( self, verbose=False ):\n log = info if verbose else debug\n output = ''\n while self.waiting:\n data = self.monitor()\n output += data\n log( data )\n ...
[ "0.59242386", "0.59242386", "0.58943117", "0.567091", "0.5660828", "0.5650391", "0.5599117", "0.5516994", "0.55079556", "0.5468367", "0.54247904", "0.5390598", "0.53793055", "0.530005", "0.5276069", "0.525269", "0.525216", "0.5234912", "0.52020633", "0.5197482", "0.5197482", ...
0.5838231
3
Creates and saves a User with the given email and password.
def create_user(self, email, password=None): if not email: raise ValueError('Users must have an email address') user = self.model( email=self.normalize_email(email), ) user.set_password(password) user.save(using=self._db) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user", "def...
[ "0.8417866", "0.84094507", "0.8398238", "0.83918047", "0.83918047", "0.83918047", "0.8383299", "0.8381542", "0.83808947", "0.8380314", "0.8379753", "0.83765846", "0.83742833", "0.83648807", "0.83648807", "0.83648807", "0.8361933", "0.8361933", "0.8348754", "0.8347133", "0.834...
0.79938453
84
Creates and saves a superuser with the given email and password.
def create_superuser(self, email, password): user = self.create_user(email, password=password) user.is_admin = True user.save(using=self._db) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createsuperuser():\n\n email = prompt('User E-Mail')\n email_confirm = prompt('Confirm E-Mail')\n\n if not email == email_confirm:\n sys.exit('\\nCould not create user: E-Mail did not match')\n\n if not EMAIL_REGEX.match(email):\n sys.exit('\\nCould not create user: Invalid E-Mail add...
[ "0.83345544", "0.82813346", "0.8258201", "0.8249415", "0.8248188", "0.8223905", "0.82129776", "0.8210377", "0.8180428", "0.8175924", "0.8174477", "0.8159496", "0.81555283", "0.8152179", "0.8147241", "0.8146682", "0.81466043", "0.81466043", "0.81466043", "0.81454295", "0.81319...
0.80541736
37
Get a name for the user. Use this whenever you show the user in the UI.
def displayname(self): return self.email
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_name(self) -> str:\n return pulumi.get(self, \"user_name\")", "def name(self) -> str:\n return self.user.name", "def getUserName(self):\n user = User.by_id(self.user_id)\n return user.name", "def user_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"us...
[ "0.85959435", "0.846185", "0.83146304", "0.8313038", "0.8228794", "0.8220969", "0.8218388", "0.81126636", "0.8054196", "0.8036822", "0.8036822", "0.8036822", "0.80256647", "0.79910946", "0.79809284", "0.7884007", "0.78487474", "0.7847428", "0.78015506", "0.78015506", "0.77903...
0.0
-1
Is the user a member of staff?
def is_staff(self): return self.is_admin
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def is_staff(ctx):\n member = ctx.message.author\n vipRole = discord.utils.get(member.guild.roles, name=ROLE_VIP)\n staffRole = discord.utils.get(member.guild.roles, name=ROLE_STAFF)\n return vipRole in member.roles or staffRole in member.roles", "def is_staff(self):\n # Simplest possibl...
[ "0.8091983", "0.79417914", "0.79417914", "0.79417914", "0.78373754", "0.7725267", "0.7695455", "0.7543704", "0.7538521", "0.74671674", "0.74179083", "0.740949", "0.740872", "0.7405209", "0.7117188", "0.7050242", "0.7050242", "0.7018241", "0.694894", "0.68767804", "0.685789", ...
0.76052535
8
Is the user a superuser?
def is_superuser(self): return self.is_admin
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSuper(self):\n user = self.getSession()\n return self.pipe.auth.isSuper(user)", "def is_superuser():\n if sys.version > \"2.7\":\n for uid in os.getresuid():\n if uid == 0:\n return True\n else:\n if os.getuid() == 0 or os.getegid() == 0:\n ...
[ "0.8203781", "0.8123163", "0.7936285", "0.77750057", "0.76693565", "0.7637397", "0.757354", "0.7337289", "0.7219452", "0.713708", "0.70978487", "0.7031901", "0.69242924", "0.69207996", "0.6917187", "0.6854157", "0.68328345", "0.68302256", "0.6777356", "0.6768828", "0.6747381"...
0.80404836
2
Normalize and then split tags on commas and spaces. Empty tags are removed.
def split_commaseparated_tags(cls, commaseparatedtags): if commaseparatedtags.strip() == '': return [] else: return [ cls.normalize_tag(tagstring) for tagstring in list([_f for _f in re.split(r'[,\s]', commaseparatedtags) if _f])]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitTags(user_input):\n \n elements = []\n if ',' in user_input:\n elements = user_input.split(',')\n elif ' ' in user_input:\n elements = user_input.split(' ')\n else:\n elements.append(user_input)\n\n tags = []\n for element in elements:\n element = element.s...
[ "0.68961847", "0.6774083", "0.67034566", "0.65602213", "0.63447934", "0.62999445", "0.6269208", "0.62582284", "0.6224067", "0.61772186", "0.6168551", "0.6133678", "0.6001191", "0.5954021", "0.592172", "0.59052056", "0.5873035", "0.5848221", "0.5820034", "0.58127075", "0.57512...
0.6720322
2
Clean a sender address by using a predefined map
def clean_sender(sender): if sender in _sender_map: return _sender_map[sender] return ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_recipient(recipient):\n if recipient in _recipient_map:\n return _recipient_map[recipient]\n return ''", "def _cleanupAddress(self, address):\n clean = []\n \n # This is sort of a desultory effort but I'm not convinced \n # that these cleanups will actually resu...
[ "0.6415194", "0.63102794", "0.6073433", "0.5693001", "0.5599912", "0.5535422", "0.5509846", "0.5509394", "0.5472849", "0.5472058", "0.5465454", "0.5461169", "0.5429801", "0.54245687", "0.53459334", "0.53453904", "0.53189844", "0.52752376", "0.52727574", "0.52652967", "0.52621...
0.6980281
0
Clean a recipient address by using a predefined map
def clean_recipient(recipient): if recipient in _recipient_map: return _recipient_map[recipient] return ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _cleanupAddress(self, address):\n clean = []\n \n # This is sort of a desultory effort but I'm not convinced \n # that these cleanups will actually result in cleaner searches\n for word in address.split(None):\n lower = word.lower()\n \n # Som...
[ "0.6710551", "0.6352095", "0.6117725", "0.6082749", "0.59901404", "0.5843147", "0.5725053", "0.56326616", "0.5629568", "0.56150633", "0.56043804", "0.5557785", "0.55360675", "0.5443463", "0.54358226", "0.5432276", "0.5409129", "0.5401632", "0.53814", "0.53644365", "0.5340619"...
0.7065244
0
Examine the text to see if we need to use full MIME parsing or not.
def use_full_parser(text): end_of_header_match = _end_of_simple_header_pattern.search(text) return end_of_header_match is not None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasRawText(self, text):\n r = re.compile(r'<(p|blockquote|div|form|table|ul|ol|dl|pre|h\\d)[^>]*?>.*</\\1>',\n re.S).sub('', text.strip()).strip()\n r = re.compile(r'<(hr|br)[^>]*?/>').sub('', r)\n return '' != r", "def is_text(content):\n if b\"\\0\" in content:...
[ "0.6001141", "0.5973282", "0.5906038", "0.5895969", "0.5820583", "0.5703178", "0.5675198", "0.5666455", "0.5633167", "0.55806506", "0.55011463", "0.5480535", "0.5429232", "0.53972876", "0.5385626", "0.5375632", "0.53742987", "0.53600854", "0.53416246", "0.5340039", "0.5295856...
0.57026833
6
Some dumps of hotmail messages introduce weird line breaks into header content, making them impossible to parse. This function will fix this content.
def fix_broken_hotmail_headers(text): end_of_header_match = _end_of_simple_header_pattern.search(text) temp_header_text = text[:end_of_header_match.end()].strip() lines = temp_header_text.splitlines()[1:] # first line is not a header... fixed_header_lines = reduce(_merge_broken_header_lines, lines, []) return_text = os.linesep.join(fixed_header_lines) + text[end_of_header_match.end():] return return_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_broken_yahoo_headers(text):\n end_of_header_match = _end_of_multipart_header_pattern.search(text)\n temp_header_text = text[:end_of_header_match.end()].strip()\n lines = temp_header_text.splitlines()\n fixed_header_lines = reduce(_merge_broken_header_lines, lines, [])\n return_text = os.line...
[ "0.6554932", "0.6418198", "0.64063436", "0.6094776", "0.60202503", "0.5935732", "0.58566016", "0.58263063", "0.57753146", "0.57245463", "0.56043744", "0.5570992", "0.55153716", "0.55127054", "0.5502749", "0.54770464", "0.5456795", "0.5437268", "0.53645223", "0.5352466", "0.53...
0.73432523
0
Some dumps of yahoo messages introduce weird line breaks into header content, making them impossible to parse. This function will fix this content.
def fix_broken_yahoo_headers(text): end_of_header_match = _end_of_multipart_header_pattern.search(text) temp_header_text = text[:end_of_header_match.end()].strip() lines = temp_header_text.splitlines() fixed_header_lines = reduce(_merge_broken_header_lines, lines, []) return_text = os.linesep.join(fixed_header_lines) + '\r\n\r\n' + text[end_of_header_match.end():] return return_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_broken_hotmail_headers(text):\n end_of_header_match = _end_of_simple_header_pattern.search(text)\n temp_header_text = text[:end_of_header_match.end()].strip()\n lines = temp_header_text.splitlines()[1:] # first line is not a header...\n fixed_header_lines = reduce(_merge_broken_header_lines, l...
[ "0.64710176", "0.6009694", "0.5937977", "0.5803022", "0.57353634", "0.5620867", "0.5585157", "0.55775535", "0.55016285", "0.5496441", "0.54666466", "0.54155815", "0.53363466", "0.52728117", "0.52605987", "0.52031696", "0.5202499", "0.51547736", "0.5134256", "0.5130388", "0.51...
0.7440384
0
Returns a single message object from a list of text content and attachments in a MIME message, after filtering out unwanted content. Also handles nested content like forwarded messages.
def get_nested_payload(mime_message): return_message = EmailMessage() return_message.subject = mime_message.get('Subject') return_message.sender = clean_sender(mime_message.get('From')) return_message.recipient = clean_recipient(mime_message.get('To')) return_message.date = parse(mime_message.get('Date')) for sub_message in mime_message.walk(): content_type = sub_message.get_content_type() disposition = sub_message.get('Content-Disposition') if content_type == 'text/plain' and disposition is None: x = unicode(sub_message.get_payload()) return_message.append_body(x) elif content_type in _ignored_content_types and disposition is None: pass # throw away contents we don't want else: return_message.add_attachment(sub_message.get_payload(), content_type=content_type, filename=disposition) return return_message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_content(content):\n attachments = []\n body = None\n html = None\n\n for part in content.walk():\n if part.get('Content-Disposition') is not None:\n decoded_data = decode_attachment(part)\n\n attachment = parse_attachment(part)\n if attachment:\n att...
[ "0.6099892", "0.6005864", "0.59787667", "0.59406656", "0.5869029", "0.5850756", "0.5808466", "0.57489055", "0.5714828", "0.5676952", "0.5646985", "0.5642732", "0.56374663", "0.56352216", "0.5632284", "0.56273305", "0.56104976", "0.5606248", "0.55780625", "0.55734146", "0.5572...
0.6649057
0
Coerce an unknown date to the given timezone, then to UTC
def normalize_to_utc(date, timezone): local_tz = pytz.timezone(timezone) new_date = date.replace(tzinfo = local_tz) utc_tz = pytz.timezone('UTC') new_date = new_date.astimezone(utc_tz) return new_date
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toutc(dateobj, timezone):\n fmtdate = parser.parse(dateobj) # string to datetime object\n user_tz = pytz.timezone(timezone) # getting user's timezone\n localize_date_with_tz = user_tz.localize(fmtdate) #adding user's timezone to datetime object\n utcdate = pytz.utc.normalize(localize_date_with_tz) ...
[ "0.75894195", "0.7289164", "0.7209024", "0.6907422", "0.6864215", "0.6698652", "0.6688846", "0.6686423", "0.6653843", "0.6593803", "0.6576157", "0.6573529", "0.6562767", "0.6553227", "0.65446633", "0.6526314", "0.64945215", "0.64906996", "0.6474339", "0.64524305", "0.6386153"...
0.76795125
0
Processing function used to reassemble corrected MIME header lines back into a block of text at the beginning of an email message.
def _merge_broken_header_lines(accumulator, item): cleaned_item = item.strip() for header in _header_list: if item.startswith(header): accumulator.append(cleaned_item) return accumulator try: accumulator[len(accumulator)-1] = accumulator[len(accumulator)-1] + ' ' + cleaned_item except IndexError: # edge case where the first line doesn't start with a header accumulator.append(cleaned_item) return accumulator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_broken_hotmail_headers(text):\n end_of_header_match = _end_of_simple_header_pattern.search(text)\n temp_header_text = text[:end_of_header_match.end()].strip()\n lines = temp_header_text.splitlines()[1:] # first line is not a header...\n fixed_header_lines = reduce(_merge_broken_header_lines, l...
[ "0.66956985", "0.65403616", "0.620646", "0.6043575", "0.59951806", "0.5961931", "0.5931331", "0.5886571", "0.5792057", "0.5707722", "0.56881887", "0.5639475", "0.56263655", "0.561612", "0.5583248", "0.5579559", "0.55687916", "0.5543469", "0.5506505", "0.5480917", "0.54660165"...
0.5239302
38
Used by JVM for java.lang.String and hence by some popular java memcached clients as default such as
def JAVA_NATIVE(key): h = 0 l = len(key) for (idx,c) in enumerate(key): h += ord(c)*31**(l-(idx+1)) return _signed_int32(h)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_cache_key_adapter(obj):\n return obj", "def store_string(self, string: str) -> None:", "def stringable(self):\n return True", "def __init__(self) -> None:\n str.__init__(self)", "def test_str(self):\n dummy = DummyCryptographicObject()\n str(dummy)", "def intern(...
[ "0.6431343", "0.58831644", "0.5787502", "0.57085586", "0.5668089", "0.56542784", "0.55438024", "0.5541255", "0.5535427", "0.5526042", "0.5480257", "0.54440296", "0.54340893", "0.5433637", "0.5404673", "0.5362585", "0.5343884", "0.5343884", "0.5334441", "0.5314773", "0.5311111...
0.0
-1
MD5based hashing algorithm used in consistent hashing scheme to compensate for servers added/removed from memcached pool.
def KETAMA(key): d = hashlib.md5(key).digest() c = _signed_int32 h = c((ord(d[3])&0xff) << 24) | c((ord(d[2]) & 0xff) << 16) | \ c((ord(d[1]) & 0xff) << 8) | c(ord(d[0]) & 0xff) return h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MD5(self) -> _n_0_t_3[_n_0_t_9]:", "def pool_hash(path_list):\n return pool_process(md5_tuple, path_list, 'MD5 hashing')", "def calc_md5(string):\n\treturn md5(string).hexdigest()", "def __hash_md5__(self, text):\n key = hashlib.md5()\n key.update(text.encode('utf-8'))\n return ke...
[ "0.7700844", "0.7656716", "0.7500732", "0.74877924", "0.7479576", "0.7474418", "0.725043", "0.7211859", "0.7142206", "0.71216583", "0.7043272", "0.7021252", "0.6984938", "0.69776475", "0.6957162", "0.6938334", "0.69136685", "0.69106406", "0.69105786", "0.6903468", "0.6874061"...
0.0
-1
Auslesen aller Konversationen aus der Datenbank
def find_all(self): result = [] cursor = self._cnx.cursor() command = "SELECT id, konversation, nachricht_id, teilnehmer, herkunfts_id, ziel_id, inhalt FROM konversationen" cursor.execute(command) tuples = cursor.fetchall() for (id, konversation, nachricht_id, teilnehmer, herkunfts_id, ziel_id, inhalt) in tuples: konversation = Konversation() konversation.set_id(id) konversation.set_konversation(konversation) konversation.set_nachricht_id(nachricht_id) konversation.set_teilnehmer(teilnehmer) konversation.set_herkunfts_id(herkunfts_id) konversation.set_ziel_id(ziel_id) konversation.set_inhalt(inhalt) result.append(konversation) self._cnx.commit() cursor.close() return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_typing_block(self):\n\t # open the database using the masterpassword\n typing_text = 'Send({})\\n'.format(self.masterpassword)\n\n # add in exit - this is achieved using CTRL + q\n typing_text += 'Sleep(15677)\\n'\n typing_text += \"SendKeepActive('KeePass')\\n\"\n ty...
[ "0.57340914", "0.56032443", "0.5596878", "0.55474406", "0.5542437", "0.5542437", "0.5542437", "0.5542437", "0.5542437", "0.55125624", "0.55125624", "0.55125624", "0.5512051", "0.5425027", "0.54236233", "0.54012054", "0.5378505", "0.5372138", "0.5365111", "0.5340748", "0.53144...
0.6025704
0
Test hiding the library.
def test_privatize_library(self): g = Game() g.add_player(uuid4(), 'p1') g.add_player(uuid4(), 'p2') gs = g gs.library.set_content(cm.get_cards( ['Circus', 'Circus', 'Circus', 'Circus Maximus', 'Circus', 'Circus', 'Ludus Magna', 'Ludus Magna', 'Statue', 'Coliseum', ])) gs_private = g.privatized_game_state_copy('p1') self.assertFalse(gs_private.library.contains('Circus')) self.assertEqual(gs_private.library, Zone([Card(-1)]*len(gs_private.library), name='library'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_module(self):\n pass", "def __test__():\n#-------------------------------------------------------------------------------\n import pylib.tester as tester\n return 0", "def importlib_only(fxn):\n return unittest.skipIf(using___import__, \"importlib-specific test\")(fxn)", "def test_pl...
[ "0.6566218", "0.6470722", "0.63644457", "0.6197142", "0.6101666", "0.6054569", "0.59973603", "0.5936304", "0.5921999", "0.5883885", "0.5871062", "0.5861786", "0.5840665", "0.5811318", "0.57991433", "0.57575244", "0.5749411", "0.5728871", "0.5727159", "0.56983817", "0.5689791"...
0.6069717
5
Test hiding opponents' hands.
def test_privatize_hands(self): g = Game() g.add_player(uuid4(), 'p0') g.add_player(uuid4(), 'p1') gs = g p0, p1 = gs.players latrine, insula, jack, road = cm.get_cards(['Latrine', 'Insula', 'Jack', 'Road']) p0.hand.set_content([latrine, insula]) p1.hand.set_content([jack, road]) gs_private = g.privatized_game_state_copy('p0') p0, p1 = gs_private.players self.assertIn(jack, p1.hand) self.assertIn(Card(-1), p1.hand) self.assertNotIn(road, p1.hand) self.assertIn(latrine, p0.hand) self.assertIn(insula, p0.hand) self.assertEqual(len(p0.hand), 2) self.assertEqual(len(p1.hand), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_play_no_gain(self):\n self.card = self.g[\"Festival\"].remove()\n self.plr.piles[Piles.HAND].set(\"Duchy\")\n self.plr.add_card(self.card, Piles.HAND)\n self.plr.favors.set(2)\n self.plr.test_input = [\"No\"]\n self.plr.play_card(self.card)\n self.assertEqu...
[ "0.66469085", "0.66251075", "0.661568", "0.6462299", "0.63435477", "0.625224", "0.6242946", "0.62145275", "0.61973673", "0.6194856", "0.61828953", "0.6082449", "0.60560155", "0.6051513", "0.59985155", "0.5985109", "0.5983806", "0.5977845", "0.5970393", "0.5968302", "0.5965452...
0.69971275
0
Test hiding all vaults.
def test_privatize_vaults(self): g = Game() g.add_player(uuid4(), 'p0') g.add_player(uuid4(), 'p1') gs = g p0, p1 = gs.players latrine, insula, statue, road = cm.get_cards(['Latrine', 'Insula', 'Statue', 'Road']) p0.vault.set_content([latrine, insula]) p1.vault.set_content([statue, road]) gs_private = g.privatized_game_state_copy('p1') p0, p1 = gs_private.players self.assertEqual(p0.vault, Zone([Card(-1)]*2, name='vault')) self.assertEqual(p1.vault, Zone([Card(-1)]*2, name='vault'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_yggdrasil_vaults(self):\n pass", "def test_get_asgard_vaults(self):\n pass", "def test_vault_get_all_vault_items(self):\n pass", "def test_vault_get_all_vault_sections(self):\n pass", "def test_auth_private_unowned(self):\n self.do_visible(False, 'pattieblack...
[ "0.73062766", "0.6963295", "0.6804855", "0.64582133", "0.63372976", "0.6049422", "0.59896415", "0.59509873", "0.5787047", "0.57756597", "0.5770837", "0.57636744", "0.57540184", "0.5746007", "0.5736347", "0.5734542", "0.5626461", "0.5625377", "0.5586302", "0.55808043", "0.5574...
0.6935641
2
Test hiding the card revealed with the fountain.
def test_privatize_fountain_card(self): g = Game() g.add_player(uuid4(), 'p0') g.add_player(uuid4(), 'p1') gs = g p0, p1 = gs.players latrine, insula, statue, road = cm.get_cards(['Latrine', 'Insula', 'Statue', 'Road']) p0.fountain_card = latrine gs_private = g.privatized_game_state_copy('p1') p0, p1 = gs_private.players self.assertEqual(p0.fountain_card, Card(-1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_play_no_gain(self):\n self.card = self.g[\"Festival\"].remove()\n self.plr.piles[Piles.HAND].set(\"Duchy\")\n self.plr.add_card(self.card, Piles.HAND)\n self.plr.favors.set(2)\n self.plr.test_input = [\"No\"]\n self.plr.play_card(self.card)\n self.assertEqu...
[ "0.6782351", "0.67602885", "0.6536577", "0.639235", "0.63622284", "0.6298589", "0.62585497", "0.6215377", "0.6096858", "0.60356593", "0.603329", "0.6007592", "0.592438", "0.5918852", "0.5918852", "0.58873326", "0.5886941", "0.5881228", "0.587296", "0.57984495", "0.5798309", ...
0.6018047
11
Returns False for out of range inputs.
def test_invalid_inputs(self): f = gtrutils.check_petition_combos self.assertFalse( f(-1, 1, [], False, False)) self.assertFalse( f( 0, 1, [], False, False)) self.assertFalse( f( 1, 0, [], False, False)) self.assertFalse( f( 1, 1, [-1], False, False)) self.assertFalse( f( 1,-1, [], False, False)) self.assertFalse( f( 1, 1, [1], False, False)) # n_off_role can never be 1 self.assertFalse( f( 1, 1, [1], True, False)) # n_off_role can never be 1 self.assertFalse( f( 1, 1, [1], False, True)) # n_off_role can never be 1 self.assertFalse( f( 1, 1, [1], True, True)) # n_off_role can never be 1 self.assertFalse( f( 1, 1, [1,3], True, True)) # n_off_role can never be 1 self.assertFalse( f( 3, 0, [2,3,3], False, True)) # n_off_role can never be 1 self.assertFalse( f( 3, 0, [2,3,3], True, False)) # n_off_role can never be 1 self.assertFalse( f( 2, 0, [2,3,3], False, True)) # n_off_role can never be 1 self.assertFalse( f( 2, 0, [2,3,3], True, False)) # n_off_role can never be 1 self.assertFalse( f( 5, 1, [6,6], True, False)) # n_off_role can never be 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isRangeValid(self) -> bool:\n ...", "def acceptsArgument(self):\n range = self.validateRange(self.range)\n return not(not(range[1]))", "def in_range(x, y):\n if (x < 0 or x > width or y < 0 or y > length):\n return False\n else:\n return True", "def _inside_op_range(s...
[ "0.76130134", "0.74046963", "0.73377717", "0.72116476", "0.7005175", "0.69723386", "0.68953574", "0.6872818", "0.68704146", "0.6861065", "0.68098015", "0.66929597", "0.66748506", "0.6673904", "0.66729593", "0.66561925", "0.66364926", "0.6613519", "0.66080934", "0.6600456", "0...
0.0
-1
Test with no petitions allowed.
def test_no_petitions(self): f = gtrutils.check_petition_combos self.assertTrue( f( 0, 0, [ 0], False, False)) self.assertFalse( f( 1, 0, [], False, False)) self.assertFalse( f( 1, 1, [2], False, False)) self.assertFalse( f( 1, 1, [3], False, False)) self.assertFalse( f( 1, 1, [4], False, False)) self.assertTrue( f( 1, 1, [], False, False)) self.assertFalse( f( 1, 2, [], False, False)) self.assertFalse( f( 1, 3, [], False, False)) self.assertFalse( f( 2, 1, [], False, False)) self.assertTrue( f( 2, 2, [], False, False)) self.assertFalse( f( 2, 3, [], False, False)) self.assertFalse( f( 3, 1, [], False, False)) self.assertFalse( f( 3, 2, [], False, False)) self.assertTrue( f( 3, 3, [], False, False)) self.assertTrue( f(13,13, [], False, False)) self.assertFalse( f( 1, 1, [0,0,0,3], False, False)) self.assertFalse( f( 2, 1, [0,0,0,3], False, False)) self.assertFalse( f( 3, 1, [0,0,0,3], False, False))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testNoSpecialties(self):\n self.failUnlessEqual(self.person.getSpecialties(), [])", "def not_test_without_user(self):\n # TODO", "def test_tally_no_candidates(self):\n self.init_elect_types()\n\n userA = models.User(\n name = \"UserA\",\n email = \"userA@eL...
[ "0.64601696", "0.63709843", "0.62266237", "0.6206515", "0.5949884", "0.5946186", "0.5936945", "0.5928463", "0.59168476", "0.5914561", "0.59085196", "0.58991575", "0.58986336", "0.5888519", "0.5865907", "0.58641195", "0.58631915", "0.58543706", "0.5849753", "0.58493304", "0.58...
0.551846
99
Test with only threecard petitions allowed.
def test_only_three_card_petitions(self): f = gtrutils.check_petition_combos self.assertTrue( f( 0, 0, [0], False, True)) self.assertFalse( f( 1, 0, [0], False, True)) self.assertTrue( f( 1, 1, [0], False, True)) self.assertTrue( f( 1, 0, [3], False, True)) self.assertTrue( f( 1, 3, [0], False, True)) self.assertFalse( f( 1, 1, [2], False, True)) self.assertFalse( f( 1, 1, [3], False, True)) self.assertFalse( f( 1, 1, [4], False, True)) self.assertTrue( f( 2, 2, [0], False, True)) self.assertTrue( f( 2, 1, [3], False, True)) self.assertTrue( f( 2, 3, [3], False, True)) self.assertTrue( f( 2, 6, [0], False, True)) self.assertTrue( f( 2, 0, [6], False, True)) self.assertFalse( f( 2, 4, [3], False, True)) self.assertFalse( f( 3, 1, [], False, True)) self.assertFalse( f( 3, 2, [], False, True)) self.assertFalse( f( 3, 0, [3], False, True)) self.assertFalse( f( 3, 0, [6], False, True)) self.assertTrue( f( 3, 3, [], False, True)) self.assertTrue( f( 3, 2, [3], False, True)) self.assertTrue( f( 3, 3, [6], False, True)) self.assertTrue( f( 3, 1, [6], False, True)) self.assertTrue( f( 3, 0, [9], False, True)) self.assertTrue( f(13,13, [], False, True)) self.assertTrue( f(13,39, [], False, True)) self.assertTrue( f(13, 0, [39], False, True)) self.assertTrue( f(13,15, [24], False, True)) self.assertTrue( f(13,15, [], False, True)) self.assertTrue( f(13,12, [3], False, True)) self.assertFalse( f(13,14, [], False, True)) self.assertFalse( f( 6, 1, [3,6,9], False, True)) self.assertTrue( f( 7, 1, [3,6,9], False, True)) self.assertFalse( f( 8, 1, [3,6,9], False, True))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_two_and_three_card_petitions(self):\n f = gtrutils.check_petition_combos\n\n self.assertTrue( f( 0, 0, [], True, True))\n\n self.assertFalse( f( 1, 0, [], True, True))\n self.assertFalse( f( 1, 0, [1], True, True))\n self.assertTrue( f( 1, 0, [2], True, True))\n ...
[ "0.6810119", "0.6473808", "0.645677", "0.62938344", "0.62752783", "0.62059915", "0.6155211", "0.6148065", "0.60892385", "0.59840876", "0.596696", "0.5963209", "0.59501404", "0.5799793", "0.5697761", "0.5672481", "0.566434", "0.561755", "0.56103486", "0.5594359", "0.5582937", ...
0.7429536
0
Test with only twocard petitions
def test_only_two_card_petitions(self): f = gtrutils.check_petition_combos self.assertTrue( f( 0, 0, [0], True, False)) self.assertFalse( f( 1, 0, [], True, False)) self.assertFalse( f( 1, 0, [1], True, False)) self.assertTrue( f( 1, 0, [2], True, False)) self.assertFalse( f( 1, 0, [3], True, False)) self.assertFalse( f( 1, 0, [4], True, False)) self.assertTrue( f( 1, 1, [], True, False)) self.assertFalse( f( 1, 1, [2], True, False)) self.assertFalse( f( 2, 0, [2], True, False)) self.assertFalse( f( 2, 0, [3], True, False)) self.assertTrue( f( 2, 0, [4], True, False)) self.assertFalse( f( 2, 0, [5], True, False)) self.assertTrue( f( 2, 1, [2], True, False)) self.assertFalse( f( 2, 1, [3], True, False)) self.assertFalse( f( 2, 1, [4], True, False)) self.assertTrue( f(13, 26, [], True, False)) self.assertTrue( f(13, 0, [26], True, False)) self.assertTrue( f(13, 14, [12], True, False)) self.assertTrue( f(13, 13, [10], True, False)) self.assertFalse( f(13, 15, [11], True, False)) self.assertFalse( f( 6, 1, [2,4,6], True, False)) self.assertTrue( f( 7, 1, [2,4,6], True, False)) self.assertFalse( f( 8, 1, [2,4,6], True, False))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testBeliefs1sk(self):", "def test_when_opponent_all_Ds(self):\n self.responses_test([C, C, C, C], [D, D, D, D], [D, D, D], random_seed=5)", "def test_three_arms_two_winners(self):\n self._test_three_arms_two_winners()", "def test_theft_and_stealing(self):", "def test_when_opponent_all_Ds(...
[ "0.6394057", "0.63925785", "0.63051224", "0.62454295", "0.62086844", "0.61224383", "0.60351664", "0.6014525", "0.599899", "0.5914783", "0.5904088", "0.58920974", "0.5878094", "0.5875978", "0.58667856", "0.5842628", "0.5808113", "0.5807632", "0.5807632", "0.5807632", "0.576396...
0.59637266
9
Test with two and threecard petitions
def test_two_and_three_card_petitions(self): f = gtrutils.check_petition_combos self.assertTrue( f( 0, 0, [], True, True)) self.assertFalse( f( 1, 0, [], True, True)) self.assertFalse( f( 1, 0, [1], True, True)) self.assertTrue( f( 1, 0, [2], True, True)) self.assertTrue( f( 1, 0, [3], True, True)) self.assertFalse( f( 1, 0, [4], True, True)) self.assertTrue( f( 1, 1, [], True, True)) self.assertTrue( f( 1, 2, [], True, True)) self.assertTrue( f( 1, 3, [], True, True)) self.assertFalse( f( 1, 4, [], True, True)) self.assertFalse( f( 1, 1, [2], True, True)) self.assertFalse( f( 1, 1, [3], True, True)) self.assertFalse( f( 1, 2, [2], True, True)) self.assertFalse( f( 1, 3, [2], True, True)) self.assertFalse( f( 1, 3, [3], True, True)) self.assertTrue( f( 2, 1, [2], True, True)) self.assertTrue( f( 2, 1, [3], True, True)) self.assertTrue( f( 2, 0, [4], True, True)) self.assertTrue( f( 2, 0, [5], True, True)) self.assertTrue( f( 2, 0, [6], True, True)) self.assertTrue( f( 2, 4, [], True, True)) self.assertTrue( f( 2, 5, [], True, True)) self.assertTrue( f( 2, 6, [], True, True)) self.assertTrue( f(13, 26, [], True, True)) self.assertTrue( f(13, 39, [], True, True)) self.assertTrue( f(13, 0, [26], True, True)) self.assertTrue( f(13, 14, [12], True, True)) self.assertTrue( f(13, 13, [10], True, True)) self.assertTrue( f(13, 15, [11], True, True)) self.assertFalse( f(13, 40, [], True, True)) self.assertFalse( f(13, 11, [3], True, True)) self.assertFalse( f(4, 1, [2,3,6], True, True)) self.assertTrue( f(5, 1, [2,3,6], True, True)) self.assertTrue( f(6, 1, [2,3,6], True, True)) self.assertFalse( f(7, 1, [2,3,6], True, True))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_only_three_card_petitions(self):\n f = gtrutils.check_petition_combos\n\n self.assertTrue( f( 0, 0, [0], False, True))\n\n self.assertFalse( f( 1, 0, [0], False, True))\n self.assertTrue( f( 1, 1, [0], False, True))\n self.assertTrue( f( 1, 0, [3], False, True))\n ...
[ "0.7009317", "0.6996275", "0.65862507", "0.6539536", "0.65000474", "0.64990026", "0.64953685", "0.6476889", "0.64768463", "0.6467368", "0.6336645", "0.6292399", "0.6257715", "0.62031925", "0.61506057", "0.6122968", "0.60999656", "0.6068418", "0.6024874", "0.6014065", "0.60111...
0.7173055
0
Test limit at beginning of game.
def test_initial_limit(self): g = test_setup.simple_two_player() p1, p2 = g.players self.assertEqual(g._clientele_limit(p1), 2) self.assertEqual(g._clientele_limit(p2), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _safe_limit_check(self):\n if self.rem == 40:\n self.time_start = time.time()\n elif time.time() - self.time_start >= 11:\n self.rem = 40\n self.time_start = time.time()\n elif self.rem <= 0:\n t = 11 - (time.time() - self.time_start)\n\n ...
[ "0.6717742", "0.65904355", "0.64534426", "0.64433163", "0.643638", "0.6354526", "0.6331702", "0.6220812", "0.6176772", "0.61617315", "0.6129828", "0.60590106", "0.6015792", "0.5951251", "0.5916098", "0.5896707", "0.58848923", "0.5870503", "0.5835869", "0.5821406", "0.58180004...
0.7055831
0
Test limit with some completed buildings.
def test_limit_with_influence(self): g = test_setup.simple_two_player() p1, p2 = g.players p1.influence = ['Stone'] p2.influence = ['Rubble'] self.assertEqual(g._clientele_limit(p1), 5) self.assertEqual(g._clientele_limit(p2), 3) p1.influence = ['Wood'] p2.influence = ['Marble'] self.assertEqual(g._clientele_limit(p1), 3) self.assertEqual(g._clientele_limit(p2), 5) p1.influence = ['Brick'] p2.influence = ['Concrete'] self.assertEqual(g._clientele_limit(p1), 4) self.assertEqual(g._clientele_limit(p2), 4) p1.influence = ['Brick', 'Concrete', 'Marble'] p2.influence = ['Concrete', 'Stone', 'Rubble', 'Rubble', 'Rubble'] self.assertEqual(g._clientele_limit(p1), 9) self.assertEqual(g._clientele_limit(p2), 10)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_communities_created_limit(self):\n self.login_as(\"ben\")\n for i in range(settings.QUIZZZ_CREATED_COMMUNITIES_LIMIT):\n response = self.client.post(self.url, {\"name\": f\"test-group-{i}\"})\n self.assertEqual(response.status_code, status.HTTP_201_CREATED)\n res...
[ "0.6331062", "0.6307083", "0.6275143", "0.62501746", "0.62440616", "0.62208784", "0.6138763", "0.613732", "0.6108998", "0.61038834", "0.60081613", "0.58726895", "0.58467835", "0.58440167", "0.58301693", "0.5813597", "0.5789836", "0.5772815", "0.5768534", "0.5768062", "0.57310...
0.0
-1
Test limit with completed Insula.
def test_limit_with_insula(self): d = TestDeck() g = test_setup.simple_two_player() p1, p2 = g.players self.assertEqual(g._clientele_limit(p1), 2) p1.buildings.append(Building(d.insula, 'Rubble', complete=True)) self.assertEqual(g._clientele_limit(p1), 4) p1.influence = ['Stone'] self.assertEqual(g._clientele_limit(p1), 7)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_identify_limit(limit, all, expected):\n assert identify_limit(limit, all) == expected", "def test_get_remain_limit(self):\n finder = FinderInsidePro(self.test_key)\n limit = finder.get_remain_limit()\n assert isinstance(limit, int)\n assert limit > 0", "def test_limit(se...
[ "0.70281196", "0.6930952", "0.6867976", "0.63591504", "0.6339935", "0.63310546", "0.63143235", "0.63078123", "0.62953484", "0.62816274", "0.62538594", "0.62326956", "0.61941534", "0.61918557", "0.6187162", "0.61759824", "0.61723286", "0.61669195", "0.6164165", "0.6162524", "0...
0.62189835
12
Test limit with completed Aqueduct.
def test_limit_with_aqueduct(self): d = TestDeck() g = test_setup.simple_two_player() p1, p2 = g.players self.assertEqual(g._clientele_limit(p1), 2) p1.buildings.append(Building(d.aqueduct, 'Concrete', complete=True)) self.assertEqual(g._clientele_limit(p1), 4) p1.influence = ['Stone'] self.assertEqual(g._clientele_limit(p1), 10)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_environmental_impact_compliance():\n emissions = 12000\n legal_limit = 300\n assert emissions < legal_limit", "def test_get_remain_limit(self):\n finder = FinderInsidePro(self.test_key)\n limit = finder.get_remain_limit()\n assert isinstance(limit, int)\n assert limi...
[ "0.6602689", "0.65843254", "0.65533227", "0.63588923", "0.63528883", "0.6254358", "0.6215978", "0.6180673", "0.61653847", "0.61470395", "0.6145852", "0.6117478", "0.61015135", "0.6094627", "0.6062201", "0.5976109", "0.59308255", "0.59041405", "0.5900028", "0.5873644", "0.5867...
0.7109697
0
Test limit with completed Aqueduct.
def test_limit_with_insula_and_aqueduct(self): d = TestDeck() g = test_setup.simple_two_player() p1, p2 = g.players self.assertEqual(g._clientele_limit(p1), 2) p1.buildings.append(Building(d.aqueduct, 'Concrete', complete=True)) p1.buildings.append(Building(d.insula, 'Rubble', complete=True)) self.assertEqual(g._clientele_limit(p1), 8) p1.influence = ['Stone'] self.assertEqual(g._clientele_limit(p1), 14)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_limit_with_aqueduct(self):\n d = TestDeck()\n\n g = test_setup.simple_two_player()\n\n p1, p2 = g.players\n\n self.assertEqual(g._clientele_limit(p1), 2)\n\n p1.buildings.append(Building(d.aqueduct, 'Concrete', complete=True))\n\n self.assertEqual(g._clientele_lim...
[ "0.7108374", "0.6605307", "0.6584849", "0.655564", "0.6354267", "0.62519914", "0.6215818", "0.6181438", "0.61679924", "0.61482066", "0.61449", "0.6115197", "0.6100592", "0.60953647", "0.60620195", "0.5975527", "0.5931888", "0.59042233", "0.5899593", "0.5873513", "0.58678395",...
0.63586307
4
fetch from local json post the first tweet in the list then record that the tweet was tweeted
def tweet(self): self.__refresh_local_tweets() if not self.tweets: return tweet_obj = self.tweets[0] # upload picture media_id = self.__upload_media(tweet_obj["img"]) # tweet with text, and image if not media_id: return self.__post_status(tweet_obj["text"], media_id) self.tweets.remove(tweet_obj) self.tweeted.append(tweet_obj) self.__update_local_tweets()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_posts(username):\r\n\r\n # Authenticate to Twitter\r\n auth = tweepy.OAuthHandler(twitter_credentials.CONSUMER_KEY, twitter_credentials.CONSUMER_SECRET)\r\n auth.set_access_token(twitter_credentials.ACCESS_TOKEN, twitter_credentials.ACCESS_TOKEN_SECRET)\r\n\r\n api = tweepy.API(auth)\r\n\r\n ...
[ "0.6760458", "0.6652912", "0.65520895", "0.63962245", "0.6344638", "0.634384", "0.633406", "0.6325491", "0.632352", "0.62919587", "0.624689", "0.62440544", "0.6242781", "0.6195591", "0.61683637", "0.6155086", "0.6136341", "0.6133877", "0.6104071", "0.6096447", "0.60790527", ...
0.5840768
48
fetch latest tweets saved from json
def __refresh_local_tweets(self): f_tweets = open(f'{TWEETS}', 'r') f_tweeted = open(f'{TWEETED}', 'r') try: self.tweets = json.load(f_tweets) self.tweeted = json.load(f_tweeted) finally: f_tweets.close() f_tweeted.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tweets(self):\r\n now = datetime.datetime.now()\r\n tweet_json = self.api.get_tweets(self.last, now)\r\n self.last = now\r\n return [Tweet(x) for x in tweet_json]", "def get_posts(username):\r\n\r\n # Authenticate to Twitter\r\n auth = tweepy.OAuthHandler(twitter_credent...
[ "0.7257259", "0.7204354", "0.71714604", "0.69285256", "0.6901832", "0.68701154", "0.6827814", "0.6807941", "0.67518646", "0.6662134", "0.665305", "0.66091895", "0.65875465", "0.65313274", "0.64886", "0.6487753", "0.64813256", "0.64548606", "0.6451675", "0.6448758", "0.64238",...
0.6033949
59
record the modified tweet/tweeted structures on disk
def __update_local_tweets(self): f_tweets = open(f'{TWEETS}', 'w') f_tweeted = open(f'{TWEETED}', 'w') try: f_tweets.write(json.dumps(self.tweets, sort_keys=True, indent=4)) f_tweeted.write(json.dumps(self.tweeted, sort_keys=True, indent=4)) finally: f_tweets.close() f_tweeted.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, tid, tmsg, tent, fp_rel=REL_PATH):\n # TODO\n # work out if saved previously and give better response\n \n\n # save to file system/rest api? where?\n # save to filesystem\n # TODO what day is this? localtime?\n fn = dt.fn_current_day(ext='json')\n\n ...
[ "0.6658211", "0.6079574", "0.6022582", "0.5911571", "0.58289623", "0.57782304", "0.57550776", "0.57268596", "0.5723704", "0.5721074", "0.57111156", "0.56885713", "0.5671371", "0.5641506", "0.56221664", "0.5615904", "0.5552578", "0.5543077", "0.55106515", "0.55028576", "0.5494...
0.7087227
0
post the tweet with a media and text
def __post_status(self, text, media_id): params = { "status": text, "media_ids": ",".join(map(str, [media_id])) } response = self.session.post(STATUS_UPDATE_URL, data=params) res_err(response, "POSTING THE TWEET AFTER MEDIA UPLOAD") logging.info(f'posted {text}')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_tweet(media_id, quote, movie_name):\n\n tweet = '{} - {}'.format(quote, movie_name)\n request_data = {\n 'status': tweet,\n 'media_ids': media_id\n }\n\n requests.post(url=constants.POST_TWEET_URL, data=request_data, auth=oauth)", "def post_to_tweets(data, url):\n\n print(\"...
[ "0.7451198", "0.7257137", "0.70719504", "0.701658", "0.6817208", "0.6798214", "0.67413294", "0.6739724", "0.67385334", "0.67385334", "0.67385334", "0.6715136", "0.6670937", "0.66504085", "0.6643696", "0.6608908", "0.6608185", "0.65740305", "0.6516414", "0.64698046", "0.635794...
0.6901592
4
Route for getting tweets by hashtag.
def get_tweets_by_hashtag_route(hashtag): response, code = get_tweets_by_hashtag( hashtag, request.args.get('limit', 30)) return jsonify(response), code
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getByHashtags(hashtag):\n\n # set page_limits. The default is 1 \n pages_limit = request.args.get('pages_limit') or 1\n pages_limit = int(pages_limit)\n\n raw_response = get_response(tw_api, 'search/tweets', { 'q': '#' + hashtag, 'count': 100 }, pages_limit)\n list_response = convert_resp2list(r...
[ "0.70752335", "0.66526765", "0.66291153", "0.66205215", "0.6536219", "0.6486589", "0.63549507", "0.6294649", "0.5997771", "0.5885162", "0.5859275", "0.56409836", "0.561119", "0.55870056", "0.5549043", "0.55390894", "0.5523961", "0.54777485", "0.54763746", "0.54185194", "0.538...
0.8222778
0
Route for getting tweets by a user.
def get_tweets_by_user_route(username): response, code = get_tweets_by_user( username, request.args.get('limit', 30)) return jsonify(response), code
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_user_tweets(username):\n userdata = query_db('select * from user where username = ?',\n [username], one=True)\n if userdata is None:\n abort(404)\n else:\n user_details = {\"username\": userdata['username'],\"user_id\":userdata['user_id']}\n\n followed = False\n if requ...
[ "0.7213664", "0.684018", "0.6731007", "0.67143995", "0.6648292", "0.65042245", "0.63557523", "0.6336596", "0.62716496", "0.624116", "0.6206272", "0.61798954", "0.61040026", "0.6077563", "0.6045129", "0.6031549", "0.60101897", "0.6005784", "0.6003022", "0.5988208", "0.5985817"...
0.81342083
0
Retrieve a new eagle eye auth key and subdomain information
def _get_eagleeye_session(carson_api, building_id): url = C_API_URI + C_EEN_SESSION_ENDPOINT.format(building_id) session = carson_api.authenticated_query(url) return session.get('sessionId'), session.get('activeBrandSubdomain')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_auth():\n config = configparser.RawConfigParser()\n config.read(\"speech.cfg\")\n apikey = config.get('auth', 'apikey')\n return (\"apikey\", apikey)", "def api_key(request):\r\n user_acct = request.user\r\n return _api_response(request, {\r\n 'api_key': user_acct.api_key,\r\n ...
[ "0.61862534", "0.6072772", "0.59618855", "0.58222324", "0.57261264", "0.5712428", "0.57017297", "0.5646959", "0.56169933", "0.55943763", "0.5513818", "0.5508162", "0.5504784", "0.5502838", "0.54992354", "0.5479007", "0.54416525", "0.5434418", "0.5419267", "0.5413086", "0.5412...
0.55181515
10
List of contact information
def contact_info(self): return [ { 'contact_info': c.get('contactInfo'), 'type': c.get('type'), 'primary': c.get('primary'), 'verified': c.get('verified'), } for c in self.entity_payload.get('contactInfo')]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_contact(self):\n contacts = \"\".join(str(contact) for contact in self.contact_list)\n print(contacts)", "def list_contacts(self):\n return self.contacts", "def list_contact(name):\n db = get_db()\n name = hashlib.sha256(name).hexdigest()\n \n if name in db:\n ...
[ "0.78861237", "0.76341623", "0.758478", "0.75249934", "0.75059426", "0.7496882", "0.7042957", "0.70327526", "0.7013183", "0.7013183", "0.7013183", "0.69496447", "0.69449735", "0.69267607", "0.69231725", "0.6869843", "0.6860492", "0.6860492", "0.6857307", "0.6849241", "0.68165...
0.7561425
3
Create a formatted recommnedation URI based on user id.
def resolve_worker_evaluation_url(request, user): return request.build_absolute_uri(reverse('hirer:evaluate', args=[user.id]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_user_link(user):\n return '[@{0}](https://github.com/{0})'.format(user)", "def create_qr_uri(user: User) -> dict:\n otp_secret = pyotp.random_base32()\n qr_uri = pyotp.totp.TOTP(otp_secret).provisioning_uri(\n name=user.username, issuer_name=f\"{APPNAME} ({MAIN_VERSION_NAME})\"\n ...
[ "0.5987479", "0.5844432", "0.57443655", "0.5638544", "0.5572798", "0.54887694", "0.5328215", "0.531546", "0.5313541", "0.5249727", "0.5235717", "0.5221336", "0.5174196", "0.51600695", "0.51578987", "0.5155158", "0.5142916", "0.5137194", "0.5137102", "0.510324", "0.50865287", ...
0.46228266
86
Create a formatted mail message to sent to worker user. This method pass the user and evaluation_link to be processed by txt template alerts/subscription_message.txt
def alert_subscription_message(request, user): message = loader.get_template( 'alerts/subscription_message.txt').render( {'user': user, 'evaluation_link': resolve_worker_evaluation_url(request, user)}) return message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_created_email(self):\n if settings.NOTIFY_NEW_REG:\n to = settings.NOTIFY_NEW_REG\n message = \"\"\"\\\nGreetings,<br><br>\n\nA new vehicle registration has been submitted by %s.<br><br>\n\nGo here to view or edit the request: <br>\n<a href=\"%s\">%s</a>\n<br><br>\nSincerely,<...
[ "0.6634772", "0.63277805", "0.6235654", "0.6227511", "0.61810446", "0.61754483", "0.6124126", "0.6124126", "0.6104047", "0.60752434", "0.6052107", "0.59274155", "0.5924757", "0.590727", "0.58884096", "0.5875973", "0.5858161", "0.58423764", "0.58318377", "0.58315945", "0.58279...
0.777387
0
Create a formatted email message to sent to worker user template alerts/new_service_notification.txt
def alert_new_service_notification(hirer, worker, service): domain = Site.objects.get_current().domain url = "http://" + domain + "/worker/" message = loader.get_template( 'alerts/new_service_notification.txt').render( {'worker': worker, 'hirer': hirer, 'service': service, 'url':url}) return message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_created_email(self):\n if settings.NOTIFY_NEW_REG:\n to = settings.NOTIFY_NEW_REG\n message = \"\"\"\\\nGreetings,<br><br>\n\nA new vehicle registration has been submitted by %s.<br><br>\n\nGo here to view or edit the request: <br>\n<a href=\"%s\">%s</a>\n<br><br>\nSincerely,<...
[ "0.7332573", "0.7300195", "0.70396394", "0.65700346", "0.6381602", "0.63333446", "0.6274574", "0.62374425", "0.61783296", "0.61655205", "0.6151091", "0.61510384", "0.6135396", "0.6120886", "0.61056536", "0.60524446", "0.6039856", "0.6035018", "0.6004501", "0.5985513", "0.5972...
0.74509716
0
Create a formatted email message to sent to worker user template alerts/service_notification.txt
def alert_service_notification(user, service): message = loader.get_template( 'alerts/service_notification.txt').render( {'user': user, 'service': service}) return message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alert_new_service_notification(hirer, worker, service):\n\n domain = Site.objects.get_current().domain\n url = \"http://\" + domain + \"/worker/\"\n\n message = loader.get_template(\n 'alerts/new_service_notification.txt').render(\n {'worker': worker, 'hirer': hirer, 'service': service, ...
[ "0.7191147", "0.6990005", "0.69212645", "0.65836084", "0.64851093", "0.6402051", "0.6330503", "0.6326159", "0.62814146", "0.6238903", "0.62185687", "0.6207358", "0.6139531", "0.60843295", "0.60813093", "0.60735154", "0.6054305", "0.60353315", "0.6029179", "0.60170865", "0.598...
0.74859136
0
Create a formatted email message to the worker when a hirer makes an evaluation template alerts/worker_evaluated.txt
def alert_worker_evaluated(hirer,worker): message = loader.get_template( 'alerts/worker_evaluated.txt').render( {'worker': worker, 'hirer': hirer}) return message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_created_email(self):\n if settings.NOTIFY_NEW_REG:\n to = settings.NOTIFY_NEW_REG\n message = \"\"\"\\\nGreetings,<br><br>\n\nA new vehicle registration has been submitted by %s.<br><br>\n\nGo here to view or edit the request: <br>\n<a href=\"%s\">%s</a>\n<br><br>\nSincerely,<...
[ "0.6600645", "0.6544189", "0.63650763", "0.63307947", "0.6069563", "0.60685426", "0.6014015", "0.5973316", "0.59537005", "0.5941229", "0.58852065", "0.5875624", "0.58755213", "0.58395034", "0.582515", "0.5794151", "0.57777476", "0.5777449", "0.5768729", "0.57670987", "0.57439...
0.79926217
0
Decorator to force workers to complete their profiles. This decorator will redirect workers with incomplete profiles to the detailed profile subscription view.
def documents_required(function=None): def _dec(view_func): def _view(request, *args, **kwargs): _user = request.user if _user.is_authenticated() and _user.is_worker() and\ (not _user.is_application_form_filled): return redirect('/profissional/subscription/', permanent=True) else: return view_func(request, *args, **kwargs) _view.__name__ = view_func.__name__ _view.__dict__ = view_func.__dict__ _view.__doc__ = view_func.__doc__ return _view if function is None: print("Funciont is none") return _dec else: print("There is some value for function") return _dec(function)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setProfileJobs(self,profile=False):\n self.__profileJobs = profile", "def complete(request, backend, *args, **kwargs):\n return do_complete(request.social_strategy, _do_login, user=None,\n redirect_name='home', *args, **kwargs)", "def profile():\n if g.user:\n return r...
[ "0.51761717", "0.48839507", "0.486394", "0.48614234", "0.48394087", "0.48157418", "0.4814398", "0.48082665", "0.4771799", "0.4770562", "0.47591376", "0.47403374", "0.4720351", "0.46573168", "0.46533135", "0.45912194", "0.4588692", "0.4584498", "0.45765498", "0.45561683", "0.4...
0.0
-1
Return the guessed language of POSTed text.
def POST(self, text): lang = guess_language(text) return {'language': lang}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_language(self, text):\n try:\n post_lang = detect(text)\n except:\n post_lang = 'N/A'\n return post_lang", "def guess_language(text): # pragma: no cover\n try:\n from guess_language import guessLanguage\n return Language.fromguessit(guessLangua...
[ "0.84711045", "0.7443068", "0.72882843", "0.7189894", "0.7099894", "0.7063926", "0.69427687", "0.67506385", "0.6746426", "0.6721064", "0.670669", "0.66078335", "0.6576339", "0.6564039", "0.65360004", "0.65185875", "0.6517528", "0.6502088", "0.64020914", "0.63992137", "0.63880...
0.7704462
1
Generates a sha1 checksum for a given string
def get_checksum(str): hash_object = hashlib.sha1(b'%s' % str) hex_dig = hash_object.hexdigest() return hex_dig
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sha1(s: str) -> str:\n return hashlib.sha1(s.encode()).hexdigest()", "def sha1(self, s):\n\t\tself.sha1_calls += 1\n\t\treturn int(hashlib.sha1(s).hexdigest(), 16)", "def SHA1(self) -> _n_0_t_3[_n_0_t_9]:", "def checksum_from_sha1(value):\n # More constrained regex at lexer level\n CHECKSUM_RE =...
[ "0.7719917", "0.75582397", "0.727031", "0.71468693", "0.7109886", "0.7050218", "0.704167", "0.7008932", "0.6944196", "0.6943862", "0.69164616", "0.6908371", "0.69008803", "0.6843064", "0.67979276", "0.67816305", "0.6755393", "0.67546755", "0.67312115", "0.6660172", "0.663221"...
0.79029137
0
Appends .svg to a checksum
def get_filename(checksum): return '%s.svg' % checksum
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _append_svg(self, svg, before_prompt=False):\n self._append_custom(self._insert_svg, svg, before_prompt)", "def __merger_svg(self):\n pass", "def save_svg(xml_string, checksum=None):\n if checksum is None:\n checksum = get_checksum(xml_string) # Get checksum of this file\n e...
[ "0.6322185", "0.6220869", "0.6096771", "0.6001254", "0.58138853", "0.57505566", "0.5744236", "0.57401705", "0.56943905", "0.5545867", "0.5537553", "0.5533253", "0.5466105", "0.5450053", "0.5445687", "0.54211104", "0.5349227", "0.53329223", "0.532195", "0.5315566", "0.5292804"...
0.6853433
0
Check if this file has been created before if so, just return the S3 URL. Returns None otherwise
def is_duplicate_checksum(checksum): s3 = boto3.client('s3') response = s3.list_objects_v2( Bucket=BUCKET, EncodingType='url', Prefix=checksum ) if response['KeyCount'] > 0 and len(response['Contents']) > 0: return 'https://s3.amazonaws.com/%s/%s' % (BUCKET, response['Contents'][0]['Key']) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_datafile_url(self):\n try:\n return self.datafile.url\n except ValueError:\n if core.utils.is_absolute_url(self.source):\n if self.source.startswith('s3://'):\n return None # file is in the UPLOAD_BUCKET\n return self.sou...
[ "0.6728675", "0.6340867", "0.6091045", "0.6061678", "0.6043561", "0.60391515", "0.6009251", "0.59960645", "0.5973066", "0.5970535", "0.5962591", "0.5951693", "0.59505904", "0.59455204", "0.59345853", "0.5928199", "0.59084433", "0.5899881", "0.5891643", "0.5853361", "0.5844663...
0.6010111
6
Uploads the SVG file to S3, and returns the URL of the object
def upload_svg(filename, xml_string): s3 = boto3.client('s3') response = s3.put_object( ACL='public-read', Body=xml_string, Bucket=BUCKET, Key=filename, StorageClass='REDUCED_REDUNDANCY', ) return 'https://s3.amazonaws.com/%s/%s' % (BUCKET, filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload(file_path, aws_path, access_key, secret_key) -> None:\n # bucket = \"dev-com-courtlistener-storage\"\n bucket = \"seals.free.law\"\n client = boto3.client(\n \"s3\",\n aws_access_key_id=access_key,\n aws_secret_access_key=secret_key,\n )\n transfer = S3Transfer(client...
[ "0.65627086", "0.6511997", "0.64451045", "0.63643384", "0.61173415", "0.6040773", "0.6031718", "0.60039645", "0.5967601", "0.5940069", "0.5857561", "0.58238834", "0.5796205", "0.574195", "0.57342345", "0.57331437", "0.5722847", "0.57148886", "0.57147944", "0.5705097", "0.5654...
0.7696398
0
Saves an XML string as a unique (checksummed) file in S3 And returns the URL of the file Checks for duplicates along the way using sha1 to find collisions
def save_svg(xml_string, checksum=None): if checksum is None: checksum = get_checksum(xml_string) # Get checksum of this file existing_url = is_duplicate_checksum(checksum) # Make sure it's unique if existing_url is not None: # We've generated this file before. logger.info('Duplicate detected for %s' % checksum) return existing_url # If dupe_check has a value, it's a URL to an existing (duplicate) file. # Usually, we've already checked for a duplicate - the above logic is just for cases # where we need to generate the checksum on the backend filename = get_filename(checksum) url = upload_svg(filename, xml_string) return url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_duplicate_checksum(checksum):\n s3 = boto3.client('s3')\n response = s3.list_objects_v2(\n Bucket=BUCKET,\n EncodingType='url',\n Prefix=checksum\n )\n\n if response['KeyCount'] > 0 and len(response['Contents']) > 0:\n return 'https://s3.amazonaws.com/%s/%s' % (BUCKET...
[ "0.6614705", "0.62321055", "0.5942641", "0.5849977", "0.5737562", "0.5682555", "0.567223", "0.5630804", "0.5596855", "0.5581484", "0.5557663", "0.547344", "0.5443973", "0.5370834", "0.5353757", "0.531475", "0.52927846", "0.52644974", "0.5246912", "0.52463406", "0.5242865", ...
0.6733674
0
Create the translations model for the shared model 'model'. 'related_name' is the related name for the reverse FK from the translations model. 'meta' is a (optional) dictionary of attributes for the translations model's inner Meta class. 'fields' is a dictionary of fields to put on the translations model.
def create_translations_model(model, related_name, meta, **fields): if not meta: meta = {} unique = [('language_code', 'master')] meta['unique_together'] = list(meta.get('unique_together', [])) + unique # Create inner Meta class Meta = type('Meta', (object,), meta) name = '%sTranslation' % model.__name__ attrs = {} attrs.update(fields) attrs['Meta'] = Meta attrs['__module__'] = model.__module__ attrs['language_code'] = models.CharField(max_length=15, db_index=True) # null=True is so we can prevent cascade deletion attrs['master'] = models.ForeignKey(model, related_name=related_name, editable=False, null=True) # Create and return the new model return ModelBase(name, (BaseTranslationModel,), attrs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_translations_model(shared_model, related_name, meta, **fields):\n if not meta:\n meta = {}\n\n if shared_model._meta.abstract:\n # This can't be done, because `master = ForeignKey(shared_model)` would fail.\n raise TypeError(\"Can't create TranslatedFieldsModel for abstract cl...
[ "0.7985823", "0.5591691", "0.49817428", "0.4975373", "0.4800113", "0.47464964", "0.4744232", "0.47395378", "0.47331527", "0.46989104", "0.46264884", "0.46264884", "0.459076", "0.45905438", "0.45603356", "0.4508293", "0.44997284", "0.44252264", "0.44179207", "0.4414165", "0.43...
0.822475
0
Contribute translations options to the inner Meta class and set the descriptors. This get's called from TranslateableModelBase.__new__
def contribute_translations(cls, rel): opts = cls._meta opts.translations_accessor = rel.get_accessor_name() opts.translations_model = rel.model opts.translations_cache = '%s_cache' % rel.get_accessor_name() trans_opts = opts.translations_model._meta # Set descriptors for field in trans_opts.fields: if field.name == 'pk': continue if field.name == 'master': continue if field.name == opts.translations_model._meta.pk.name: continue if field.name == 'language_code': attr = LanguageCodeAttribute(opts) else: attr = TranslatedAttribute(opts, field.name) setattr(cls, field.name, attr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_translations_model(model, related_name, meta, **fields):\n if not meta:\n meta = {}\n unique = [('language_code', 'master')]\n meta['unique_together'] = list(meta.get('unique_together', [])) + unique\n # Create inner Meta class \n Meta = type('Meta', (object,), meta)\n name = '%...
[ "0.6093402", "0.5498365", "0.5405703", "0.5377071", "0.5377071", "0.52954173", "0.5262987", "0.5173471", "0.5130741", "0.51139444", "0.5081222", "0.5053549", "0.50521266", "0.5046423", "0.50335914", "0.50004405", "0.4973911", "0.4968481", "0.49118015", "0.49080524", "0.486693...
0.73294145
0
When this instance is saved, also save the (cached) translation
def save_translations(cls, instance, **kwargs): opts = cls._meta if hasattr(instance, opts.translations_cache): trans = getattr(instance, opts.translations_cache) if not trans.master_id: trans.master = instance trans.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, *args, **kwargs):\n\n ret = super(Translation, self).save(*args, **kwargs)\n\n # Does cache invalidation\n cache_key = Translation.objects.make_cache_key(type(self), self.object_id, self.language)\n cache.set(cache_key, self)\n\n return ret", "def save(self, *arg...
[ "0.81048036", "0.6967799", "0.66896576", "0.64093536", "0.6083553", "0.60599184", "0.6016258", "0.59257364", "0.5915563", "0.59141093", "0.59141093", "0.59141093", "0.59141093", "0.59141093", "0.59109294", "0.589746", "0.5893489", "0.5889759", "0.58738244", "0.58508587", "0.5...
0.7327054
1
Add various entries to a cube dictionary and sort by socket index
def normalize(district, purpose, cube_dictionary_list): for gui_index, cube_dictionary in enumerate(cube_dictionary_list): cube_dictionary["district"] = district cube_dictionary["purpose"] = purpose cube_dictionary["gui_index"] = gui_index # Dictionary is given in a natural gui display order. Remember it. return sorted(cube_dictionary_list, key=lambda item: item["socket"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_vertex_to_clusters(clusters,vertex):\n for key in clusters:\n clusters[key].append(vertex)", "def make_neighbor_db(data):\n acted_with = {}\n for i, j, _ in data:\n # the setdefault method lets us avoid checking for ourselves whether an\n # actor is aclready in the dictionar...
[ "0.52169806", "0.5209674", "0.5192503", "0.5059949", "0.50562185", "0.50340647", "0.503215", "0.49723428", "0.4956823", "0.4896037", "0.48916155", "0.48439723", "0.48249584", "0.48159158", "0.48155957", "0.47965276", "0.4795622", "0.47880176", "0.47797826", "0.47521746", "0.4...
0.58312446
0
Performs the right division 'dst / src', and moves 'result_in' to 'dst' to either retrieve the division or the modulo
def perform_divide(c, dst, src, result_in8, result_in16): # We're likely going to need to save some temporary variables # No 'push' or 'pop' are used because 'ah /= 3', for instance, destroys 'al' # 'al' itself can be pushed to the stack, but a temporary variable can hold tmps = TmpVariables(c) # In division, the dividend is divided by the divisor to get a quotient # dividend \ divisor # quotient large_divide = max(dst.size, src.size) > 8 if large_divide: # 16-bits mode, so we use 'ax' as the dividend dividend = 'ax' # The second factor cannot be an inmediate value # Neither AX/DX or variants, because those are used # Neither 8 bits, because 16 bits mode is required if src.code[0] in 'ad' or src.size != 16 or src.value is not None: # Either we use a register, which we would need to save/restore, # or we use directly a memory variable, which is just easier divisor = tmps.create_tmp('divisor', size=16) else: divisor = src.code # If the destination is DH or DL, we need to save the opposite part # If the destination is not DX, we need to save the whole register if dst[0] == 'd': if dst[-1] == 'h': tmps.save('dl') elif dst[-1] == 'l': tmps.save('dh') elif dst[-1] != 'x': tmps.save('dx') else: tmps.save('dx') # If the destination is AH or AL, we need to save the opposite part # If the destination is not AX, we need to save the whole register if dst[0] == 'a': if dst[-1] == 'h': tmps.save('al') elif dst[-1] == 'l': tmps.save('ah') elif dst[-1] != 'x': tmps.save('ax') else: tmps.save('ax') # Load the dividend and divisor into their correct location helperassign(c, [dividend, divisor], [dst, src]) # Perform the division c.add_code([ f'xor dx, dx', f'div {divisor}' ]) # Move the result from wherever it is helperassign(c, dst, result_in16) else: # 8-bits mode, so we use 'al' as the dividend dividend = 'al' # The second factor cannot be an inmediate value # Neither AX/AH because those are used # Neither 16 bits, because 8 bits mode is required if src.code[0] in 'a' or src.size != 8 or src.value is not None: # Either we use a register, which we would need to save/restore, # or we use directly a memory variable, which is just easier divisor = tmps.create_tmp('divisor', size=8) else: divisor = src.code # If the destination is AH or AL, we need to save the opposite part # If the destination is not AX, we need to save the whole register if dst[0] == 'a': if dst[-1] == 'h': tmps.save('al') elif dst[-1] == 'l': tmps.save('ah') elif dst[-1] != 'x': tmps.save('ax') else: tmps.save('ax') # Load the dividend and divisor into their correct location helperassign(c, [dividend, divisor], [dst, src]) # Perform the division c.add_code([ f'xor ah, ah', f'div {divisor}' ]) # Move the result from wherever it is helperassign(c, dst, result_in8) # Restore the used registers tmps.restore_all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def int_div_inplace(a, b):", "def true_div_inplace(a, b):", "def divup(a, b):\n return (a + b - 1) // b", "def divide(lhs, rhs):\n return _make.divide(lhs, rhs)", "def div(self, source, destination):\n value = bytearray()\n\n dividend = destination\n divider = source\n\n i...
[ "0.6179031", "0.6050849", "0.59951925", "0.5947101", "0.5941931", "0.5891567", "0.58224696", "0.5819864", "0.5762812", "0.57600236", "0.57048416", "0.5681911", "0.5675549", "0.5665095", "0.5660404", "0.5639097", "0.56374323", "0.5618714", "0.56052095", "0.55648005", "0.556480...
0.7103163
0
Given the scale of WGUPS shipping, 1000 is a reasonable backing array size
def __init__(self): self.size = 1000 self.mapArray = [None] * self.size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.size = 1000000\n self.mp = [[]] * self.size", "def scale_in(self, count):\n pass", "def limit_size(self, catalog):\n if len(catalog)<=self.limit:\n return catalog\n mem = {}\n for instance in catalog:\n if (instance['vCp...
[ "0.56507504", "0.5521999", "0.5457273", "0.5385491", "0.537851", "0.5337603", "0.5316058", "0.5289358", "0.5258439", "0.52287763", "0.52238894", "0.5206532", "0.51933736", "0.5175065", "0.5167415", "0.5160229", "0.514245", "0.509487", "0.50677186", "0.5030789", "0.50188196", ...
0.53057754
7
Hypothese on the third feature
def compute_determinant(matrix): det = np.linalg.det(matrix) #if det == 0.: # The det = 0 could be related to the third feature # det = np.linalg.det(matrix[:2, :2]) if det == 0.: # Singular covariance matrix, should not be taken into account det = np.nan if np.isclose(det, 0): det = np.abs(det) return det
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hypotenuse(a, b):\r\n return (a**2 + b**2)**0.5", "def hypotenuse():\n print(math.sqrt(5**2 +3**2))", "def hypotenuse():\n print(math.sqrt(5*5 + 3*3))", "def hyp(a,b):\n c=sqrt((a*a)+(b*b))\n return c", "def hypothenuse(x, y):\n return sqrt(x**2 + y**2)", "def hypotenuse(x,y):\n xx =...
[ "0.6345466", "0.6224685", "0.62164116", "0.6141258", "0.5938721", "0.57951844", "0.5715218", "0.5696992", "0.56795216", "0.56696415", "0.5644957", "0.5635818", "0.561018", "0.56082743", "0.5606991", "0.56034803", "0.5592059", "0.55717176", "0.55676854", "0.55559623", "0.55502...
0.0
-1
Method to compute the KullbackLeibler Divergence between two Gaussians PARAMETERS
def compute_kl(mu1, mu2, sigma1, sigma2): k = len(mu1) try: term1 = np.trace(np.matmul(np.linalg.inv(sigma2), sigma1)) term2 = np.matmul(np.matmul((mu2 - mu1).T, np.linalg.inv(sigma2)), (mu2 - mu1)) det_sigma1 = compute_determinant(sigma1) det_sigma2 = compute_determinant(sigma2) # term3 = np.log(np.linalg.det(sigma2)/np.linalg.det(sigma1)) term3 = np.log(det_sigma2) term4 = np.log(det_sigma1) kl = (term1 + term2 - k + term3 - term4)/2. return kl except np.linalg.LinAlgError: return np.nan
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_KL_divergence(self):\n KL_loss_W = Vil.get_KL_divergence_Samples(self.mu_weight, Vil.softplus(self.rho_weight), self.weight, self.prior)\n KL_loss_b = 0\n if self.bias is not None:\n KL_loss_b = Vil.get_KL_divergence_Samples(self.mu_bias, Vil.softplus(self.rho_bias), self.bi...
[ "0.64265364", "0.6414014", "0.64129555", "0.6334975", "0.63160306", "0.6193587", "0.61617297", "0.61293685", "0.61277765", "0.6109303", "0.6043571", "0.603763", "0.60138285", "0.59585667", "0.59533715", "0.5900521", "0.5898689", "0.58980924", "0.5893038", "0.58471286", "0.584...
0.5683974
38
Convert real world points with Doppler to rangeDoppler coordinates PARAMETERS
def convert_to_rd_points(data, world_camera): distances = np.sqrt((data[:, 0] - world_camera[0])**2 + \ (data[:, 1] - world_camera[1])**2) dopplers = data[:, 2] rd_points = [(distances[i], dopplers[i]) for i in range(data.shape[0])] return rd_points
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_points(self, divisions=100):", "def build_coord(norm, d, pts):\n # Compute the origin as the mean point of the points, and this point has to be on the plane\n \n n = len(pts) \n x_total = 0\n y_total = 0\n z_total = 0\n \n for i in range(n):\n x_total += pts[i][0]\n y...
[ "0.6075092", "0.5820298", "0.57956177", "0.5740052", "0.5732382", "0.5556223", "0.55544716", "0.55006737", "0.5466339", "0.54140425", "0.5391508", "0.53908247", "0.53622574", "0.53531116", "0.53329784", "0.5326264", "0.5315539", "0.528949", "0.52882594", "0.5276278", "0.52513...
0.56694
5
Visualise and record DoADoppler point clouds
def visualise_doa(doa_points, doa_labels, path, centroids=None): if isinstance(centroids, np.ndarray) and len(centroids.shape) == 1: centroids = centroids.reshape(1, -1) n_clusters = np.unique(doa_labels).shape[0] fig = plt.figure() ax = fig.add_subplot(111, projection='3d') colors = cycle('bgrcmykbgrcmykbgrcmykbgrcmyk') colors = cycle(['b', 'g', 'r', 'c', 'm', 'y', 'blueviolet', 'brown', 'burlywood', 'khaki', 'indigo', 'peru', 'pink', 'rosybrown', 'teal', 'seagreen']) for k, col in zip(range(n_clusters), colors): indexes = doa_labels == k ax.scatter(doa_points[indexes, 0], doa_points[indexes, 1], doa_points[indexes, 2], 'ro', c=col) if isinstance(centroids, np.ndarray): ax.scatter(centroids[:, 0], centroids[:, 1], centroids[:, 2], 'ro', c='black') ax.set_xlabel('x (m)') ax.set_ylabel('y (m)') ax.set_zlabel('Doppler-Velocity (m/s)') ax.set_title('3D representation of the DoA points with centroid') plt.savefig(path) plt.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish_point_cloud(self):\n all_points = [np.zeros((0, 2), np.float32)]\n all_keys = []\n for key in range(len(self.keyframes)):\n pose = self.keyframes[key].pose\n transf_points = self.keyframes[key].transf_points\n all_points.append(transf_points)\n ...
[ "0.6512084", "0.6371263", "0.6321242", "0.6314276", "0.6305938", "0.6247466", "0.6047218", "0.60251385", "0.5953147", "0.59473276", "0.5941391", "0.592496", "0.59040606", "0.5794781", "0.5758018", "0.5744503", "0.57257426", "0.570993", "0.5699411", "0.5648155", "0.5635541", ...
0.5327644
56
Visualise and record rangeDoppler matrices with projected points PARAMETERS
def visualise_points_on_rd(rd_matrix, path, points, range_res, doppler_res): rd_img = SignalVisualizer(rd_matrix).get_image for point in points: range_coord = (point[0] / range_res).astype(int) doppler_coord = (point[1] / doppler_res).astype(int) if point[1] < 0: doppler_coord += int(rd_matrix.shape[1]/2 - 1) else: doppler_coord += int(rd_matrix.shape[1]/2) rd_img[range_coord*4:(range_coord*4+4), doppler_coord*4:(doppler_coord*4+4)] = [0., 0., 0.] plt.imsave(path, rd_img) plt.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_pin_position_range():\n #Create a sample goniometer\n g = TopazInHouseGoniometer()\n\n #Initialize the leg limits\n g.relative_sample_position = column([0.0, 0.0, 0.0])\n g.getplatepos(0.0, 0.0, 0.0)\n g.calculate_leg_xy_limits(visualize=True)\n\n# if True:\n# pylab.show()\n#...
[ "0.59820175", "0.5681855", "0.5632588", "0.55993336", "0.5567278", "0.5558949", "0.55241627", "0.552349", "0.552066", "0.5517947", "0.5500038", "0.54207855", "0.5374178", "0.5372016", "0.5361266", "0.5345306", "0.534296", "0.5339282", "0.5336971", "0.5336114", "0.53311783", ...
0.6764529
0
Generate random RGB colors for a given seed
def get_random_rgb(seed): random.seed(seed) r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) return [r, g, b]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_color_gen():\n r = randint(0, 255)\n g = randint(0, 255)\n b = randint(0, 255)\n return [r, g, b]", "def random_color():\n colormode(255)\n return randint(0, 255), randint(0, 255), randint(0, 255)", "def _genRandomColor():\n b = random.randint(0, 255)\n g = random.randint(0, ...
[ "0.814636", "0.7701456", "0.76977193", "0.74837154", "0.746802", "0.737749", "0.73708177", "0.7207782", "0.7160151", "0.7154133", "0.7105417", "0.70931727", "0.70826614", "0.7022558", "0.7013978", "0.69533306", "0.6892857", "0.68925637", "0.6831503", "0.6779909", "0.67476416"...
0.84251815
0
Get a binary mask with threshold on probabilities
def threshold_mask(mask, threshold=0.5): mask[np.where(mask >= threshold)] = 1. mask[np.where(mask < threshold)] = 0. return mask
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_predict(probs, threshold = 0.5):\n return (probs >= threshold) * np.ones(len(probs))", "def pred_from_prob(a,threshold):\n bin_preds = np.zeros((np.size(a,0),))\n bin_preds[np.where(a[:,1]>threshold)]=1.0\n return bin_preds", "def _np_get_mask(prob_map, prob_thresh=0.5):\n mask = ...
[ "0.77609915", "0.732614", "0.7293136", "0.6731647", "0.6590931", "0.65737176", "0.65595347", "0.6532869", "0.65259445", "0.6520092", "0.6501832", "0.64822376", "0.6414383", "0.6395488", "0.6340759", "0.63036704", "0.6302406", "0.62916476", "0.6282469", "0.62416035", "0.624160...
0.70543975
3
Method to compute the coefficients of the straight line between two points
def compute_line_coefs(point_a, point_b): b_coef = -1 if (point_b[0] - point_a[0]) == 0: a_coef = 0 else: a_coef = (point_b[1] - point_a[1]) / (point_b[0] - point_a[0]) c_coef = point_b[1] - a_coef*point_b[0] return np.array([a_coef, b_coef, c_coef])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_linear_coef(p1, p2):\n slope = (p1[1] - p2[1]) / (p1[0] - p2[0])\n intercept = p1[1] - slope * p1[0]\n return slope, intercept", "def generate_line(point_1, point_2):\r\n A = point_1.y - point_2.y\r\n B = point_2.x - point_1.x\r\n C = point_1.y * B + point_1.x * A\r\n ret...
[ "0.7252494", "0.7058825", "0.70182276", "0.69539297", "0.68374145", "0.6692208", "0.66759145", "0.66448915", "0.6642555", "0.6631278", "0.660639", "0.65882164", "0.6564653", "0.65506494", "0.64859647", "0.64820635", "0.643047", "0.6408767", "0.63719994", "0.6311349", "0.62959...
0.80344635
0
Method to compute the orthogonal projection of a point on a straight line Let's define (D) the straight line which coeff are given as parameters
def compute_orthogonal_proj(line_coefs, point_coordinates): a = line_coefs[0] c = line_coefs[2] # Compute c_prime by replacing with the coordinates of the point c_prime = a*point_coordinates[1] + point_coordinates[0] x_proj = (c_prime-a*c)/((a**2)+1) y_proj = (a*c_prime+c)/((a**2)+1) return np.array([x_proj, y_proj])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_projection_of_pt_on_line(point, line_point1, line_point2):\n projection = Point(-1, -1)\n projection.x = point.x\n if (line_point2.x - line_point1.x) != 0:\n projection.y = (projection.x - line_point1.x) * (line_point2.y - line_point1.y) / \\\n (line_point2.x - line_po...
[ "0.6800761", "0.64928424", "0.63452107", "0.6339828", "0.60856456", "0.6082376", "0.6082376", "0.59750146", "0.59033185", "0.5879611", "0.58655274", "0.5820088", "0.58171314", "0.5814186", "0.5794391", "0.5717215", "0.56910175", "0.56728375", "0.5667023", "0.5649503", "0.5608...
0.7622919
0
Run a sha1 of the file and return the result
def calchash(filename): sha = hashlib.sha1() with open(filename, 'rb') as f: sha.update(f.read()) return sha
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetFileSha1(file_path):\n return base64.b64encode(GetFileHashes(file_path, do_sha1=True)['sha1'])", "def _calc_sha1(path):\n calc = hashlib.sha1()\n with open(path, 'r') as f:\n calc.update(f.read())\n return calc.hexdigest()", "def sha1(fname):\n fh = open(fname, 'rb')\n sha1 = hashlib.sha1...
[ "0.7758882", "0.7735032", "0.76928216", "0.75606763", "0.7542691", "0.73954326", "0.7363118", "0.71328443", "0.7127811", "0.71266234", "0.7059906", "0.705759", "0.7057296", "0.70450103", "0.70450103", "0.6978939", "0.6903451", "0.69028926", "0.6887849", "0.6887431", "0.682743...
0.7463678
5
Checks to see if the destination exists If a source file is passed in, run a checksum
def checkfile(filename, source=None): if source: # Let's check some sums if os.path.exists(filename) and os.path.exists(source): src_sha = calchash(source) dest_sha = calchash(filename) if DRYRUN: print("{src} hash {src_sha}. {dest} hash {dest_sha}".format(src=source, dest=filename, src_sha=src_sha.hexdigest(), dest_sha=dest_sha.hexdigest())) return src_sha.digest() == dest_sha.digest() else: return os.path.exists(filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checksum_compare(source_file, dest_file):\n\n con_ssh = ControllerClient.get_active_controller()\n\n LOG.info(\"Compare checksums on source file and destination file\")\n cmd = \"getfattr -m . -d {}\"\n\n exitcode, source_sha = con_ssh.exec_cmd(cmd.format(source_file))\n LOG.info(\"Raw source fi...
[ "0.7140068", "0.6845625", "0.6302969", "0.6295187", "0.61806387", "0.61280686", "0.60687417", "0.59943986", "0.59558606", "0.5897827", "0.5882352", "0.58686715", "0.5864275", "0.58456916", "0.58347523", "0.58037543", "0.57591784", "0.5748481", "0.57282805", "0.57282805", "0.5...
0.7357597
0
Establish a connection with the labview server. If the labview program is ever stopped and restarted (as it should be when not taking data, to avoid wearing out the shutter), this should be called to reestablish the connection.
def connect(self): self.sock = s.socket(s.AF_INET,s.SOCK_STREAM) self.sock.connect((self.remote_host, self.remote_port))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self):\n self.class_logger.info(\"Performing connection to TRex server via HLT API\")\n self.check_res(self.hltapi.connect(device=self.host, port_list=self.ports, reset=True, break_locks=True))", "def connect_to_server(self):\n\n server=os.popen('hostname').read()\n if 'ep...
[ "0.6657257", "0.66268283", "0.6589886", "0.65059596", "0.64859515", "0.6469739", "0.64388025", "0.6428868", "0.63881606", "0.6269265", "0.6240393", "0.6225351", "0.6219129", "0.6197346", "0.6195343", "0.6181658", "0.61551857", "0.6146872", "0.6136307", "0.60901004", "0.607203...
0.0
-1
Takes a shot on the CCD. Returns a 2tuple ``(wl, ccd)``.
def get_spectrum(self): self.sock.send('Q') self.sock.send(str(100 * self.center_wl)) response = self.sock.recv(7) if not response: raise InstrumentError( 'No response from Labview client, try reconnecting') datalen = int(response) data = '' while datalen > 0: # read data in chunks dt = self.sock.recv(datalen) data += dt datalen -= len(dt) data = data.split("\n")[:-1] for i in range(len(data)): data[i] = data[i].split("\t") data = n.array(data,dtype=float) wl = data[0] ccd = data[1:] return wl,ccd #self.sock.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_shoot(data: bytes) -> Tuple[bytes, str]:\n length = struct.unpack('H', data[:2])[0]\n name = data[2:length+2]\n direction = struct.unpack('fff', data[length+2:length+2+12])\n return data[2+length:], f'Shot {name.decode()} in direction: {direction}'", "def wcsshift(x0, y0, hd1, hd2):\n w...
[ "0.5148957", "0.49647325", "0.48577526", "0.48168695", "0.47914028", "0.4786531", "0.4775281", "0.47224483", "0.47096628", "0.46394467", "0.46250522", "0.46067777", "0.4606352", "0.45833904", "0.4575049", "0.45720398", "0.4562999", "0.4545978", "0.45373318", "0.4482143", "0.4...
0.0
-1
String representation of this class
def __repr__(self): return f"<Airport(id={str(self.id)}, name={self.name})>"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toString(self):\n\n sMembers = '';\n for sAttr in self.getDataAttributes():\n oValue = getattr(self, sAttr);\n sMembers += ', %s=%s' % (sAttr, oValue);\n\n oClass = type(self);\n if sMembers == '':\n return '<%s>' % (oClass.__name__);\n return...
[ "0.8405431", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.83985007", "0.8396452", "0.8396452", "0.8396452", "0.8396452", "0.8396452", "0.83616906", "0...
0.0
-1