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
Merges data from a single transaction. Snapshot is an instance of StatsEngine that contains stats for the single transaction.
def merge(self, snapshot): if not self.__settings: return self.merge_metric_stats(snapshot) self._merge_transaction_events(snapshot) self._merge_synthetics_events(snapshot) self._merge_error_events(snapshot) self._merge_error_traces(snapshot) self._merge_custom_events(snapshot) self._merge_span_events(snapshot) self._merge_sql(snapshot) self._merge_traces(snapshot)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_metric_stats(self, snapshot):\n\n if not self.__settings:\n return\n\n for key, other in six.iteritems(snapshot.__stats_table):\n stats = self.__stats_table.get(key)\n if not stats:\n self.__stats_table[key] = other\n else:\n ...
[ "0.5806089", "0.50894815", "0.5036111", "0.50232536", "0.49642876", "0.4911518", "0.487619", "0.48526537", "0.48363346", "0.48321915", "0.47403112", "0.47268453", "0.46747193", "0.4672916", "0.46666792", "0.4641363", "0.4636667", "0.46207553", "0.46078375", "0.46022642", "0.4...
0.6420531
0
Performs a "rollback" merge after a failed harvest. Snapshot is a copy of the main StatsEngine data that we attempted to harvest, but failed. Not all types of data get merged during a rollback.
def rollback(self, snapshot): if not self.__settings: return _logger.debug('Performing rollback of data into ' 'subsequent harvest period. Metric data and transaction events' 'will be preserved and rolled into next harvest') self.merge_metric_stats(snapshot) self._merge_transaction_events(snapshot, rollback=True) self._merge_synthetics_events(snapshot, rollback=True) self._merge_error_events(snapshot) self._merge_custom_events(snapshot, rollback=True) self._merge_span_events(snapshot, rollback=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollback(self, stage, enodes, exception):", "def test_backup_merge_with_restore(self):\n gen = BlobGenerator(\"ent-backup\", \"ent-backup-\", self.value_size, end=self.num_items)\n self._load_all_buckets(self.master, gen, \"create\", 0)\n self.backup_create()\n self._take_n_backup...
[ "0.6461394", "0.60570455", "0.5918345", "0.5801982", "0.57985705", "0.56479573", "0.5587846", "0.5585826", "0.55499566", "0.55391157", "0.55083054", "0.54737455", "0.54621094", "0.5453677", "0.54407775", "0.5388638", "0.5380963", "0.53626865", "0.53533244", "0.53509045", "0.5...
0.77395844
0
Merges metric data from a snapshot. This is used both when merging data from a single transaction into the main stats engine, and for performing a rollback merge. In either case, the merge is done the exact same way.
def merge_metric_stats(self, snapshot): if not self.__settings: return for key, other in six.iteritems(snapshot.__stats_table): stats = self.__stats_table.get(key) if not stats: self.__stats_table[key] = other else: stats.merge_stats(other)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(self, snapshot):\n\n if not self.__settings:\n return\n\n self.merge_metric_stats(snapshot)\n self._merge_transaction_events(snapshot)\n self._merge_synthetics_events(snapshot)\n self._merge_error_events(snapshot)\n self._merge_error_traces(snapshot)\n...
[ "0.72327065", "0.5681518", "0.5414538", "0.509253", "0.5089406", "0.50668776", "0.50477487", "0.50349045", "0.5023128", "0.50017947", "0.49228266", "0.48627433", "0.47599393", "0.4753302", "0.47469756", "0.47447816", "0.47401235", "0.47382542", "0.47220156", "0.4715443", "0.4...
0.7712152
0
Merges in a set of custom metrics. The metrics should be provide as an iterable where each item is a tuple of the metric name and the accumulated stats for the metric.
def merge_custom_metrics(self, metrics): if not self.__settings: return for name, other in metrics: key = (name, '') stats = self.__stats_table.get(key) if not stats: self.__stats_table[key] = other else: stats.merge_stats(other)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_metrics(self, metrics):\n for i, metric in enumerate(self.config.metrics):\n tf.summary.scalar(metric, metrics[i])", "def aggregate(all_metrics, reducer, suffix):\n # Collect metric separately\n separated_metrics = {} # type: dict[frozenset, list[dict]]\n for el in...
[ "0.67883134", "0.6653943", "0.66358435", "0.65713274", "0.65646595", "0.64966273", "0.64369106", "0.6254954", "0.6035345", "0.6030221", "0.5992154", "0.5904505", "0.58831435", "0.5876968", "0.58738685", "0.586156", "0.58568037", "0.58403516", "0.58366096", "0.5835867", "0.582...
0.8258332
0
Checks if player ready to be rendered on the character sheet
def is_player_ready(self): player = self.base.game_instance['player_ref'] if (player and base.player_states["is_alive"] and base.player_states["is_idle"] and not base.player_states["is_moving"] and not base.player_states["is_running"] and not base.player_states["is_crouch_moving"] and not base.player_states["is_crouching"] and not base.player_states["is_standing"] and not base.player_states["is_jumping"] and not base.player_states["is_h_kicking"] and not base.player_states["is_f_kicking"] and not base.player_states["is_using"] and not base.player_states["is_attacked"] and not base.player_states["is_busy"] and not base.player_states["is_turning"] and not base.player_states["is_mounted"] and not base.player_states["horse_riding"] and not self.base.game_instance["is_player_sitting"] and not player.get_python_tag("is_on_horse") ): return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_ready(self):\n if self.game.has_started():\n return True\n return self.status == self.PLAYER_READY", "def ready(self):\n return self.shader is not None and self.texturesReady()", "def check_ready(self):\r\n print \"Checking ready\"\r\n\t\tif self.game.troug...
[ "0.69993716", "0.6624655", "0.6611897", "0.6352339", "0.6298705", "0.62477887", "0.6227472", "0.6222125", "0.6217452", "0.6090686", "0.607338", "0.6063791", "0.6063283", "0.605453", "0.60500675", "0.6024416", "0.6018847", "0.5996054", "0.5977044", "0.5920064", "0.5918121", ...
0.6954562
1
Run the script at given path catching exceptions. This function should only be used internally by Pyto.
def runScriptAtPath(path): sys.argv = [path] for arg in PytoClasses.Python.shared.args: sys.argv.append(str(arg)) def run() -> None: os.system = PytoClasses.Python.shared.system directory = os.path.expanduser(os.path.dirname(path)) sys.path.insert(0, directory) try: global __script__ spec = importlib.util.spec_from_file_location("__main__", path) __script__ = importlib.util.module_from_spec(spec) spec.loader.exec_module(__script__) PytoClasses.Python.shared.values = [item for item in dir(__script__) if not item.startswith("__")] except SystemExit: print("SystemExit") except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() extracts = traceback.extract_tb(sys.exc_info()[2]) count = len(extracts) lineNumber = -1 fileName = path for i, extract in enumerate(extracts): if extract[0] == fileName: lineNumber = extract[1] break count -= 1 if (type(e) == SyntaxError): # The last word in a `SyntaxError` exception is the line number lineNumber = [int(s) for s in (str(e)[:-1]).split() if s.isdigit()][-1] PytoClasses.Python.shared.errorType = exc_type.__name__ PytoClasses.Python.shared.errorReason = str(e) PytoClasses.EditorViewController.visible.showErrorAtLine(lineNumber) print(traceback.format_exc(limit=-count)) sys.path.remove(directory) PytoClasses.ReviewHelper.shared.launches = PytoClasses.ReviewHelper.shared.launches+1 PytoClasses.ReviewHelper.shared.requestReview() PytoClasses.Python.shared.isScriptRunning = False thread = threading.Thread(target=run, args=()) def loop(): while PytoClasses.Python.shared.isScriptRunning: time.sleep(1) ignoredThreads.append(thread) raise Exception("Stopped script!") def runLoop(): try: loop() except: pass thread.start() runLoop() return __script__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runScript(path=None):\n if path:\n exec(compile(open(path, \"rb\").read(), path, 'exec'))", "def do_exec(self, arg):\n self.run_file(arg['path'])", "def _run_file(file_path, globals_):\n script_name = os.path.basename(file_path)\n\n sys.path = (_PATHS.script_paths(script_name) +\n ...
[ "0.72653073", "0.6912623", "0.68354243", "0.67718136", "0.67703193", "0.65939707", "0.6413898", "0.63070154", "0.61949843", "0.61937946", "0.6164765", "0.6151639", "0.60480416", "0.60265625", "0.60191596", "0.6006073", "0.5994495", "0.59873414", "0.5959248", "0.58620226", "0....
0.7851395
0
Requests input with given prompt.
def input(prompt="Input"): __PyInputHelper__.userInput = None __PyInputHelper__.showAlertWithPrompt(prompt) while (__PyInputHelper__.userInput == None): if (threading.currentThread() in ignoredThreads): return "" continue userInput = __PyInputHelper__.userInput __PyInputHelper__.userInput = None return str(userInput)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input(self, prompt):\r\n return console_input(prompt)", "def get_input(prompt):\n return input(prompt)", "def get_input(prompt):\n return input(prompt)", "def ask_user_input(prompt: str) -> str:\n return input(prompt)", "def ask(self, prompt: str) -> str:\n raise NotImplementedEr...
[ "0.8005862", "0.7744237", "0.7744237", "0.7655172", "0.76528496", "0.75383127", "0.7535779", "0.72016025", "0.7145495", "0.71204597", "0.7108815", "0.70427936", "0.69868904", "0.69493484", "0.69454503", "0.69408095", "0.692065", "0.6888201", "0.6861148", "0.6780953", "0.67475...
0.66135526
31
Prints to the Pyto console, not to the stdout. Works as the builtin `print` function but does not support printing to a custom file. Pyto catches by default the stdout and the stderr, so use the builtin function instead. This function is mainly for internal use.
def print(*objects, sep=None, end=None): if sep is None: sep = ' ' if end is None: end = '\n' array = map(str, objects) __PyOutputHelper__.print(sep.join(array)+end)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printout(*args, **kwargs):\n console_print(sys.stdout, *args, **kwargs)", "def real_print(*args, **kwargs):\n\n kwargs.setdefault('file', real_stdout)\n _python_print_function(*args, **kwargs)", "def escaped_printer(to_write):\n # suppress(anomalous-backslash-in-string)\n to_write = ...
[ "0.7033177", "0.6971747", "0.66082984", "0.6593919", "0.6439161", "0.64060444", "0.6342973", "0.6337713", "0.6297447", "0.625069", "0.625069", "0.625069", "0.625069", "0.625069", "0.625069", "0.6228058", "0.6203651", "0.61796016", "0.6176492", "0.60885143", "0.6076104", "0....
0.0
-1
Expected defaults when no project exists
def test_no_project_defaults(self): ep = exposed.ExposedProject() self.assertIsNone(ep.display) self.assertIsNone(ep.shared) self.assertIsNone(ep.settings) self.assertIsNone(ep.title) self.assertIsNone(ep.id) self.assertIsNone(ep.path()) with self.assertRaises(RuntimeError): ep.title = 'Some Title'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_project(self):\n pass", "def _determine_default_project(project=None):\n if project is None:\n project = _get_gcd_project()\n\n if project is None:\n project = _helpers._determine_default_project(project=project)\n\n return project", "def test_create_project(self):\n ...
[ "0.7302375", "0.69367903", "0.6899856", "0.6899856", "0.6899856", "0.6896533", "0.6896533", "0.6896533", "0.68203735", "0.6759572", "0.6759572", "0.67091924", "0.6589286", "0.65550405", "0.6552097", "0.65425485", "0.6540739", "0.6533683", "0.63593394", "0.6352195", "0.6341002...
0.7610206
0
Should return values from the internal _step object.
def test_step_properties(self, _step: PropertyMock): now = datetime.utcnow() _step.return_value = MagicMock( start_time=now, end_time=now, elapsed_time=0, is_visible=True ) es = exposed.ExposedStep() self.assertEqual(now, es.start_time) self.assertEqual(now, es.end_time) self.assertEqual(0, es.elapsed_time)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSteps():", "def _step(self) -> None:", "def _get_steps(self):\n return self.steps", "def get_steps(self):\n return self.steps", "def step_values(self):\n return self._get_values().copy()", "def _step(self):\n pass", "def step ( self ) :\n return self.__step", "de...
[ "0.7940937", "0.75706524", "0.7514424", "0.7484905", "0.7470057", "0.73012173", "0.7286416", "0.7277636", "0.72470057", "0.713876", "0.7031306", "0.69861174", "0.69578314", "0.69092953", "0.6793182", "0.6793182", "0.6793182", "0.6793182", "0.6725299", "0.6709949", "0.6709949"...
0.0
-1
Should return values from the internal _step object.
def test_step_visibility(self, _step: PropertyMock): _step.return_value = MagicMock(is_visible=True) es = exposed.ExposedStep() self.assertTrue(es.visible) es.visible = False self.assertFalse(es.visible)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSteps():", "def _step(self) -> None:", "def _get_steps(self):\n return self.steps", "def get_steps(self):\n return self.steps", "def step_values(self):\n return self._get_values().copy()", "def _step(self):\n pass", "def step ( self ) :\n return self.__step", "de...
[ "0.7940937", "0.75706524", "0.7514424", "0.7484905", "0.7470057", "0.73012173", "0.7286416", "0.7277636", "0.72470057", "0.713876", "0.7031306", "0.69861174", "0.69578314", "0.69092953", "0.6793182", "0.6793182", "0.6793182", "0.6793182", "0.6725299", "0.6709949", "0.6709949"...
0.0
-1
Should abort stopping and not raise an error when no internal step is available to stop.
def test_step_stop_aborted(self, _step: PropertyMock): _step.return_value = None es = exposed.ExposedStep() es.stop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _gracefully_stop(self):\n pass", "def halt(*_, **kwargs):\n raise ExecutionFinished(\"Reached halt\")", "def stop() -> None:", "def abort() -> NoReturn:\n raise AbortSignal", "def stop(self) -> None:\n ...", "def stop(self) -> None:", "def stop(self) -> None:", "def abort(self...
[ "0.7060672", "0.6969455", "0.6947691", "0.6831138", "0.6816764", "0.6798415", "0.6798415", "0.6757007", "0.6750949", "0.6735412", "0.6730144", "0.66933066", "0.66833615", "0.6682303", "0.6665194", "0.6663481", "0.66407984", "0.6631349", "0.6631349", "0.6631349", "0.6631349", ...
0.7588589
0
Should abort stopping and not raise an error when no internal project is available to stop.
def test_project_stop_aborted(self, get_internal_project: MagicMock): get_internal_project.return_value = None ep = exposed.ExposedProject() ep.stop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stopBuild(reason=\"<no reason given>\"):", "def _gracefully_stop(self):\n pass", "def abort(self):\n try:\n self.acqRunning = False\n except:\n print('Cannot abort properly')", "def stop() -> None:", "def test_stop_project(self):\n support.create_projec...
[ "0.7033246", "0.6999605", "0.68412125", "0.6814739", "0.66516757", "0.6600153", "0.6580697", "0.6565686", "0.6565686", "0.6565686", "0.6565686", "0.65105325", "0.6509005", "0.6509005", "0.6490828", "0.64628285", "0.6435273", "0.6418074", "0.640065", "0.6397539", "0.63974357",...
0.7577744
0
Title should change through exposed project.
def test_change_title(self): test_title = 'Some Title' support.create_project(self, 'igor') cd.project.title = test_title self.assertEqual(cd.project.title, test_title)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title(self) -> str:\n pass", "def get_title():", "def set_title(self, title):\n\t\tpass", "def title(self) -> str:\n raise NotImplementedError", "def title(self, title):\n\n self.container['title'] = title", "def title(self) -> String:\n pass", "def getTitle(self): #$NON-NLS...
[ "0.79620063", "0.79186386", "0.7862367", "0.78303343", "0.77898055", "0.77829283", "0.76941615", "0.76941615", "0.7663939", "0.7562071", "0.7539742", "0.7495875", "0.7455016", "0.7455016", "0.7455016", "0.7455016", "0.7455016", "0.7455016", "0.7455016", "0.7455016", "0.745501...
0.7491403
12
Exposed step should apply defaults without project.
def test_no_step_defaults(self): es = exposed.ExposedStep() self.assertIsNone(es._step)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_Defaults(self):\n self._run(self._test_scenarios, \"Defaults\")", "def setup_default_arguments(self):\n self.add_argument('--clean', action='store_true',\n help='Cleans all generated files.')", "def set_defaults(self):\n self.plastic = False\n self....
[ "0.64410084", "0.63659227", "0.6084587", "0.60367554", "0.60328066", "0.59723306", "0.59047097", "0.5889502", "0.58557147", "0.5821773", "0.57834613", "0.5766115", "0.57598996", "0.57373494", "0.5727727", "0.57167864", "0.5711562", "0.5700834", "0.56967074", "0.567001", "0.56...
0.6023307
5
Should stop the step early and not continue running future steps
def test_stop_step_and_halt(self): support.create_project(self, 'homer') support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.test = 0', 'cd.step.breathe()', 'cd.shared.test = 1', 'cd.step.stop(halt=True)', 'cd.shared.test = 2' ])) support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.test = 3' ])) support.run_command('run') project = cd.project.get_internal_project() step = project.steps[1] self.assertEqual(project.shared.fetch('test'), 1) self.assertNotEqual(-1, step.dom.find('cd-StepStop'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_step(self) -> None:", "def test_step_stop_aborted(self, _step: PropertyMock):\n _step.return_value = None\n es = exposed.ExposedStep()\n es.stop()", "def _step(self) -> None:", "def _step(self):\n pass", "def step(self):\n\n pass", "def test_stop_step_no_halt(sel...
[ "0.7293106", "0.69339883", "0.68969584", "0.68435454", "0.6819655", "0.68091816", "0.6744681", "0.6729426", "0.67282057", "0.6633512", "0.6604878", "0.6572258", "0.65700793", "0.6551742", "0.65375674", "0.6494899", "0.6462652", "0.6412046", "0.6402601", "0.63951445", "0.63924...
0.64876556
16
Should stop the step early and not continue running future steps because the project was halted.
def test_stop_project(self): support.create_project(self, 'homer3') support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.test = 0', 'cd.step.breathe()', 'cd.shared.test = 1', 'cd.project.stop()', 'cd.shared.test = 2' ])) support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.test = 3' ])) support.run_command('run') project = cd.project.get_internal_project() step = project.steps[1] self.assertEqual(project.shared.fetch('test'), 1) self.assertNotEqual(-1, step.dom.find('cd-StepStop'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_stop_step_no_halt(self):\n support.create_project(self, 'homer2')\n support.add_step(self, contents='\\n'.join([\n 'import cauldron as cd',\n 'cd.shared.test = 0',\n 'cd.shared.other = 0',\n 'cd.step.breathe()',\n 'cd.shared.test = 1',\n...
[ "0.71432555", "0.69802755", "0.69084686", "0.68055534", "0.6585818", "0.65606755", "0.6539221", "0.6507136", "0.6481271", "0.64599055", "0.64539194", "0.64235467", "0.64235467", "0.64235467", "0.64235467", "0.64235467", "0.64235467", "0.6410082", "0.63917327", "0.6325879", "0...
0.6601984
4
Should stop the step early but continue running future steps
def test_stop_step_no_halt(self): support.create_project(self, 'homer2') support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.test = 0', 'cd.shared.other = 0', 'cd.step.breathe()', 'cd.shared.test = 1', 'cd.step.stop()', 'cd.shared.test = 2' ])) support.add_step(self, contents='\n'.join([ 'import cauldron as cd', 'cd.shared.other = 1' ])) support.run_command('run') project = cd.project.get_internal_project() step = project.steps[1] self.assertEqual(project.shared.fetch('test'), 1) self.assertEqual(project.shared.fetch('other'), 1) self.assertNotEqual(-1, step.dom.find('cd-StepStop'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_step(self) -> None:", "def _step(self) -> None:", "def step(self):\n\n pass", "def _step(self):\n pass", "def run_one_step(self):\n pass", "def perform_step(self) -> None:\n pass", "def step(self):\n while self.state != STATE_TERMINAL:\n self.step_st...
[ "0.75177705", "0.70118654", "0.6976013", "0.69562066", "0.6870884", "0.6823549", "0.6785878", "0.67788917", "0.6727162", "0.6682127", "0.6655598", "0.6610465", "0.65924037", "0.65851337", "0.65685076", "0.65320814", "0.65093255", "0.64936584", "0.6490016", "0.64489716", "0.64...
0.6420328
26
Should stop the step early and silently
def test_stop_step_silent(self): contents = '\n'.join([ 'import cauldron as cd', 'cd.shared.test = 0', 'cd.step.breathe()', 'cd.shared.test = 1', 'cd.step.stop(silent=True)', 'cd.shared.test = 2' ]) support.create_project(self, 'homeritis') support.add_step(self, contents=contents) support.run_command('run') project = cd.project.get_internal_project() step = project.steps[0] self.assertEqual(project.shared.fetch('test'), 1) self.assertEqual(-1, step.dom.find('cd-StepStop'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_step(self) -> None:", "def test_step_stop_aborted(self, _step: PropertyMock):\n _step.return_value = None\n es = exposed.ExposedStep()\n es.stop()", "def stopTestRun(self):", "def _gracefully_stop(self):\n pass", "def run(self):\n sys.exit(-1)", "def pre_stop...
[ "0.70605266", "0.69810665", "0.69688714", "0.69465715", "0.6923059", "0.69141006", "0.69115365", "0.6902989", "0.6805761", "0.67983", "0.67979056", "0.6749256", "0.6744562", "0.6743129", "0.67402655", "0.6723573", "0.67115927", "0.6710811", "0.67052597", "0.67052597", "0.6702...
0.65623134
32
Should get internal project on the third attempt after one attempt to check before entering the retry and sleep loop and then two iterations through the loop before encountering a nonNone value.
def test_get_internal_project( self, sleep: MagicMock, internal_project: PropertyMock ): project = exposed.ExposedProject() internal_project.side_effect = [None, None, None, 'test'] result = project.get_internal_project() self.assertEqual('test', result) self.assertEqual(2, sleep.call_count)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_retry_run(self):\n pass", "def _retry_occurred(self):", "def retry(times):\n return repeat_with_success_at_least(times, 1)", "def test_get_internal_project_fail(\n self,\n sleep: MagicMock,\n time_time: MagicMock,\n internal_project: PropertyMock...
[ "0.6727273", "0.66801494", "0.61674005", "0.6153633", "0.59194636", "0.5918431", "0.5909713", "0.58628047", "0.5764597", "0.5757618", "0.5737513", "0.5729122", "0.5724581", "0.56619436", "0.5641783", "0.55695194", "0.55670893", "0.555651", "0.5526606", "0.5525379", "0.5483605...
0.5577417
15
Should fail to get internal project and return None after eventually timing out.
def test_get_internal_project_fail( self, sleep: MagicMock, time_time: MagicMock, internal_project: PropertyMock ): project = exposed.ExposedProject() time_time.side_effect = range(20) internal_project.return_value = None result = project.get_internal_project() self.assertIsNone(result) self.assertEqual(10, sleep.call_count)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_internal_project(\n self,\n sleep: MagicMock,\n internal_project: PropertyMock\n ):\n project = exposed.ExposedProject()\n internal_project.side_effect = [None, None, None, 'test']\n result = project.get_internal_project()\n self.assertEq...
[ "0.70699006", "0.68557197", "0.66254395", "0.64616627", "0.63413024", "0.62891513", "0.62088645", "0.61985654", "0.612253", "0.60614514", "0.60256624", "0.6006625", "0.5999078", "0.59616834", "0.5941112", "0.5911068", "0.5911068", "0.59038454", "0.5900037", "0.5870759", "0.58...
0.7359438
0
Should write to the console using a write_source function call on the internal step report's stdout_interceptor.
def test_write_to_console(self, _step: PropertyMock): trials = [2, True, None, 'This is a test', b'hello'] for message in trials: _step_mock = MagicMock() write_source = MagicMock() _step_mock.report.stdout_interceptor.write_source = write_source _step.return_value = _step_mock step = exposed.ExposedStep() step.write_to_console(message) args, kwargs = write_source.call_args self.assertEqual('{}'.format(message), args[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_render_to_console(self, _step: PropertyMock):\n message = ' {{ a }} is not {{ b }}.'\n\n _step_mock = MagicMock()\n write_source = MagicMock()\n _step_mock.report.stdout_interceptor.write_source = write_source\n _step.return_value = _step_mock\n step = exposed.E...
[ "0.7060722", "0.6297328", "0.62191683", "0.6036808", "0.59491473", "0.5853387", "0.58372104", "0.5825977", "0.5810231", "0.5803809", "0.5773342", "0.57336247", "0.5707204", "0.5692095", "0.56633615", "0.5617709", "0.5614963", "0.55947864", "0.55731905", "0.5567739", "0.556441...
0.7509089
0
Should render to the console using a write_source function call on the internal step report's stdout_interceptor.
def test_render_to_console(self, _step: PropertyMock): message = ' {{ a }} is not {{ b }}.' _step_mock = MagicMock() write_source = MagicMock() _step_mock.report.stdout_interceptor.write_source = write_source _step.return_value = _step_mock step = exposed.ExposedStep() step.render_to_console(message, a=7, b='happy') args, kwargs = write_source.call_args self.assertEqual('7 is not happy.', args[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_write_to_console(self, _step: PropertyMock):\n trials = [2, True, None, 'This is a test', b'hello']\n\n for message in trials:\n _step_mock = MagicMock()\n write_source = MagicMock()\n _step_mock.report.stdout_interceptor.write_source = write_source\n ...
[ "0.7027907", "0.6089574", "0.59871966", "0.5953501", "0.5823776", "0.58008", "0.5722767", "0.569426", "0.5688539", "0.5679437", "0.56706893", "0.5645537", "0.5632503", "0.5632419", "0.5579383", "0.55504066", "0.54777354", "0.5475465", "0.547519", "0.5462693", "0.5446832", "...
0.75739104
0
Should raise a ValueError when there is no current step to operate upon by the write function call.
def test_write_to_console_fail(self, _step: PropertyMock): _step.return_value = None step = exposed.ExposedStep() with self.assertRaises(ValueError): step.write_to_console('hello')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _step(self) -> None:", "def step(self):\r\n raise NotImplementedError", "def step(self):\n raise NotImplementedError()", "def step(self):\n raise NotImplementedError()", "def step(self):\n raise NotImplementedError()", "def step(self):\n raise NotImplementedError(\n...
[ "0.60865235", "0.6002841", "0.59607214", "0.59607214", "0.59607214", "0.59400934", "0.5931165", "0.59239656", "0.59183896", "0.5840517", "0.57957006", "0.5792233", "0.57350117", "0.57000464", "0.5628943", "0.5625073", "0.5619831", "0.56141627", "0.5597384", "0.5548896", "0.55...
0.6328565
0
Should render stop display without error
def test_render_stop_display(self, get_formatted_stack_frame: MagicMock): get_formatted_stack_frame.return_value = [ {'filename': 'foo'}, {'filename': 'bar'}, {'filename': os.path.realpath(exposed.__file__)} ] step = MagicMock() exposed.render_stop_display(step, 'FAKE') self.assertEqual(1, step.report.append_body.call_count)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unrendered(self) -> str:", "def _stop(self):\n self.display_end_message()", "def _render(self) -> None:\n pass", "def err_message(self, message):\n self.errors.append(1)\n message = \"<b>\" + message + \"</b>\"\n self.timer_id = GLib.timeout_add_seconds(5, self.error_fa...
[ "0.6397472", "0.63438386", "0.6252806", "0.6063289", "0.6059273", "0.6047525", "0.6009877", "0.5999331", "0.5892407", "0.5892407", "0.5892407", "0.5892407", "0.5892407", "0.5892407", "0.5881014", "0.5866852", "0.5825784", "0.5824481", "0.58154", "0.5803385", "0.57909334", "...
0.0
-1
Should render an empty stack frame when the stack data is invalid.
def test_render_stop_display_error( self, get_formatted_stack_frame: MagicMock, render_template: MagicMock ): get_formatted_stack_frame.return_value = None step = MagicMock() exposed.render_stop_display(step, 'FAKE') self.assertEqual({}, render_template.call_args[1]['frame'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_stack() -> None:\n with raises(GrammarParseError):\n grammar_parser.parse(\"ab}\", lexer_mode=\"VALUE_MODE\")", "def empty(self):\r\n return len(self.stack) == 0", "def show_stack(self) -> None:\n print(\"Show stack: \")\n ok = 1\n for i in reversed(self.ite...
[ "0.6172748", "0.6088951", "0.6082694", "0.6078208", "0.6071998", "0.6070815", "0.604263", "0.6012433", "0.5990902", "0.5990902", "0.5970938", "0.5947907", "0.58997005", "0.58715206", "0.58715206", "0.5864916", "0.58454406", "0.58197826", "0.58059406", "0.5792144", "0.5775396"...
0.61049175
1
Should create an absolute path within the project.
def test_project_path(self): ep = exposed.ExposedProject() project = MagicMock() project.source_directory = os.path.realpath(os.path.dirname(__file__)) ep.load(project) result = ep.path('hello.md') self.assertTrue(result.endswith('{}hello.md'.format(os.sep)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_path(self, filename):\n return os.path.join(self.root_path, filename)", "def project_root() -> Path:\n return PROJECT_ROOT", "def force_absolute(base, path):\n if os.path.abspath(path) and os.path.exists(path):\n return path\n else:\n return path_format(base + path)", "def ...
[ "0.7043294", "0.6796717", "0.679323", "0.676385", "0.67596847", "0.66949475", "0.6657503", "0.6627231", "0.66117865", "0.65952295", "0.65799236", "0.65615535", "0.64732045", "0.6427088", "0.642576", "0.64075583", "0.6396847", "0.6347354", "0.6342947", "0.632171", "0.63044393"...
0.6755603
5
Open the passed file in readbinary mode and write the binary to a string.
def openAndPack(filename): inputfile = open(filename, 'rb') return inputfile.read()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_file_bin_readwrite(self):\n FileWriter(self.binary_path).write_bin(self.binary_string)\n bin_data = FileReader(self.binary_path).read_bin()\n self.assertEqual(bin_data, self.binary_string)", "def get_binary(self, filepath):\n with open(filepath, \"rb\") as f:\n ret...
[ "0.69785064", "0.684996", "0.65437925", "0.6293273", "0.62410367", "0.62361705", "0.61142075", "0.6071782", "0.6044688", "0.5978211", "0.59639037", "0.5924334", "0.5889725", "0.5753386", "0.5673814", "0.5615943", "0.5607474", "0.5558819", "0.55509293", "0.5521247", "0.5515765...
0.5054163
74
Open File to write to and write input binary to the new file
def receiveAndUnpack(binary, filename): inputfile = open(filename, 'wb') inputfile.write(binary)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_to_file(original_path, new_path):\n print(f\"[INFO]: Transform data from binary to text file {new_path}\")\n with open(new_path, mode='wt', encoding='utf-8') as new_file:\n with open(original_path, mode='rb') as original_file:\n for line in original_file:\n ...
[ "0.6816833", "0.6505264", "0.637456", "0.6351842", "0.6127052", "0.6121467", "0.6088371", "0.60827595", "0.60820264", "0.6010023", "0.59770185", "0.59106725", "0.59103024", "0.59103024", "0.5909376", "0.5897663", "0.5867396", "0.5844806", "0.58442897", "0.5841373", "0.5840854...
0.0
-1
Calculates % of alphanumeric characters in string.
def _alnum_percent(line): total = len(line) test_set = set() for letter in string.ascii_letters: test_set.add(letter) test_set.add(' ') # Return a failure (no good characters) if there are no characters if total < 1: return 0 alnum_count = 0 star_count = 0 bar_count = 0 for letter in line: # if letter.isalnum(): if letter in test_set: alnum_count += 1 if letter == '*': star_count += 1 if letter == 'I' or letter == 'i' or letter == 'l' or letter == '|': bar_count += 1 # TODO(searow): properly implement this, but sticking this here for now. if star_count / total > 0.1: return 0 if bar_count / total > 0.5: return 0 return alnum_count / total
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def letter_percent(s):\r\n\r\n alpha = 'abcdefghijklmnopqrstuvwxyz'\r\n s_lower = s.lower()\r\n s_length = 0\r\n letter_count = {} # empty dictionary\r\n keys = letter_count.keys()\r\n\r\n for char in s_lower:\r\n if char in alpha:\r\n s_length = s_length + 1\r\n if ...
[ "0.73372185", "0.6893399", "0.6517647", "0.63861024", "0.61528224", "0.6047942", "0.60439736", "0.5990186", "0.58984005", "0.588371", "0.5831391", "0.58165365", "0.57671547", "0.5763353", "0.57626456", "0.57338387", "0.5726077", "0.5723785", "0.5721825", "0.57174385", "0.5693...
0.75368613
0
Analyzes text lines, in order read from OCR processing. Populates the MailFields object with information gathered from OCR. Uses information from each of the lines to best figure out who is the main addresssee and which box it is trying to reach.
def parse_text_lines(self, text_lines): self.__fields = mail_fields.MailFields() alphanum_threshold = 0.5 # Only evaluate lines that are predominantly alphanumeric for line in text_lines: if _alnum_percent(line) > alphanum_threshold: try: parsed = usaddress.tag(line)[0] except usaddress.RepeatedLabelError as e: # If usaddress gets confused, just throw away the answer as if # we got nothing for now. # TODO(searow): fix this to handle multiple tags and labels. parsed = {} for tag in parsed: self._add_to_fields(tag, parsed[tag]) return self.__fields
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(self) -> None:\n self.parsed = email.message_from_bytes(self.rawmailcontent, policy=email.policy.EmailPolicy()) # type: email.message.EmailMessage\n\n self.subject = self.parsed[\"subject\"]\n\n if self.parsed[\"X-Jicket-Initial-ReplyID\"] is not None and self.parsed[\"X-Jicket-...
[ "0.60554934", "0.58570105", "0.5800822", "0.57903785", "0.5709253", "0.5683452", "0.56657594", "0.5564154", "0.54445773", "0.5323824", "0.52994883", "0.5294524", "0.5293484", "0.5284312", "0.52493984", "0.5248615", "0.5206312", "0.51865774", "0.5184688", "0.5175195", "0.51648...
0.7433099
0
Adds the parsed items to the MailFields object.
def _add_to_fields(self, tag, data): # Addressee data if 'Recipient' == tag: names = data.split() for name in names: self.__fields.addressee_line['all_names'].append(name) # Probable box data # Strip out anything that's not a number since we might get some other # data inside here also. If the box # can be a subnumber (BOX 102-A) then # we'll end up putting everything in the # only. if 'USPSBoxGroupID' == tag or 'USPSBoxGroupType' == tag or \ 'USPSBoxID' == tag or 'USPSBoxType' == tag or \ 'OccupancyType' == tag or 'OccupancyIdentifier' == tag or \ 'SubaddressType' == tag or 'SubaddressIdentifier' == tag: box = re.search('\d+', data) if box is not None: self.__fields.probable_box.append(box.group(0)) # Street data # Discarding street number prefix and suffix for now if 'AddressNumber' == tag: self.__fields.street_line['number'].append(data) if 'StreetName' == tag: self.__fields.street_line['street_name'].append(data) # City data if 'PlaceName' == tag: self.__fields.city_line['city'].append(data) if 'StateName' == tag: self.__fields.city_line['state'].append(data) if 'ZipCode' == tag: self.__fields.city_line['zip_code'].append(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_fields(self, fields):\n for field in fields:\n self.add(field)", "def add_fields(self, fields):\n for label, data in fields.items():\n self[label] = data", "def parse(self):\n\t\tfor part in self.mail.walk():\n\t\t\tself.process_part(part)", "def extract_form_fiel...
[ "0.63991386", "0.6073475", "0.5998139", "0.5921391", "0.58640885", "0.5802949", "0.57639647", "0.5761297", "0.5378668", "0.5297593", "0.52813184", "0.52709", "0.52335626", "0.5191542", "0.5156435", "0.5155164", "0.5128716", "0.50924057", "0.5078077", "0.5077574", "0.5053269",...
0.6065927
2
initial method that store the arguments. of the class Rectangle.
def __init__(self, width, height, x=0, y=0, id=None): if type(width) is not int: raise TypeError("width must be an integer") if width is 0 or width < 0: raise ValueError("width must be > 0") if type(height) is not int: raise TypeError("height must be an integer") if height is 0 or height < 0: raise ValueError("height must be > 0") if type(x) is not int: raise TypeError("x must be an integer") if x < 0: raise ValueError("x must be >= 0") if type(y) is not int: raise TypeError("y must be an integer") if y < 0: raise ValueError("y must be >= 0") self.width = width self.height = height self.x = x self.y = y super().__init__(id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, height, width):\n\n\t\t# _width and _height are internal (private) Rectangle Instance's attributes. This is something\n\t\t# We keep to ourselves to make sure the User can't just update these attrs randomly and also\n\t\t# so that the code has backward compatibility.\n\t\tself._width = None\n\t\...
[ "0.7717153", "0.70783764", "0.7057518", "0.6912608", "0.6878885", "0.6844327", "0.6746747", "0.6710487", "0.66281", "0.6565641", "0.6465655", "0.6464897", "0.6464897", "0.64589643", "0.6448135", "0.6443847", "0.6419465", "0.64143485", "0.6397842", "0.6385662", "0.63642436", ...
0.0
-1
function getter of width. Return the private attribute of width.
def width(self): return self.__width
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_width ( self ):\n return self.width", "def get_width(self):\r\n return self._width", "def get_width(self):\r\n return self._width", "def get_width(self):\r\n return self._width", "def get_width(self):\n return self.width", "def get_width(self):\n return s...
[ "0.8650132", "0.85605687", "0.85605687", "0.85605687", "0.85120815", "0.8511572", "0.84871787", "0.8459629", "0.8459629", "0.8459629", "0.8459629", "0.83854336", "0.8377391", "0.8377391", "0.8377391", "0.8377391", "0.8377391", "0.8377391", "0.8377391", "0.8377391", "0.8377391...
0.8384285
23
function setter of width is modified.
def width(self, width): if type(width) is not int: raise TypeError("width must be an integer") if width is 0 or width < 0: raise ValueError("width must be > 0") self.__width = width
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def set_width(self, width):\n...
[ "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8376353", "0.8339519", "0.83305824", "0.8157303", "0.8157303", "0.8136468", "0.81254727", "0.80290914", "0.8017782", "0.79475737", "0.79475737"...
0.7365873
34
function getter of height. Return the private attribute of height.
def height(self): return self.__height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(self):\n return self[\"height\"]", "def height(self):\n return self[\"height\"]", "def height(self):\n return self.client.call('GET', self.name + 'height')", "def get_height(self):\r\n return self._height", "def get_height(self):\r\n return self._height", "de...
[ "0.8661259", "0.8661259", "0.8615402", "0.8569597", "0.8569597", "0.8569597", "0.85450464", "0.85007274", "0.85007274", "0.85007274", "0.85007274", "0.8489411", "0.8420963", "0.83773327", "0.83516467", "0.83516467", "0.83516467", "0.83516467", "0.83516467", "0.83516467", "0.8...
0.8366778
24
function height of width is modified.
def height(self, height): if type(height) is not int: raise TypeError("height must be an integer") if height is 0 or height < 0: raise ValueError("height must be > 0") self.__height = height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(self) -> int:", "def height(self) -> int:", "def height(self) -> int:", "def height(self):\n\t\tpass", "def setHeight(*args):", "def setHeight(*args):", "def setHeight(*args):", "def setHeight(*args):", "def setHeight(*args):", "def setHeight(*args):", "def setHeight(*args):", "def...
[ "0.7464202", "0.7464202", "0.7464202", "0.7087595", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6872465", "0.6845854", "0.67984444", "0.67984444", "0.678835", "0.6719456", "0.6655328", ...
0.0
-1
function getter of x. Return the private attribute of x.
def x(self): return self.__x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x(self): # same as 'doc' argument of property function\n print(\"getter of x called\")\n return self._x", "def getX(self):\n return self.__x", "def getX(self):\r\n\t\treturn self._x", "def getX(self):\n return self.x", "def x(self):\n return self[\"x\"]", "def X(se...
[ "0.7959929", "0.75061965", "0.73572534", "0.72709286", "0.7234424", "0.72268146", "0.70876133", "0.7002792", "0.69983375", "0.6947473", "0.6877965", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783", "0.6841783...
0.7164953
14
function x of width is modified.
def x(self, x): if type(x) is not int: raise TypeError("x must be an integer") if x < 0: raise ValueError("x must be >= 0") self.__x = x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def width(self) -> int:", "def width(self) -> int:", "def width(self):\n return self.maxx - self.minx", "def width(self):\n return self.x.max() - self.x.min()", "def width(self):\n\t\tpass", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):", "def setWidth(*args):"...
[ "0.6760154", "0.6760154", "0.64897656", "0.6473481", "0.64240944", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6394637", "0.6389916", "0.6348413", "0.6348413", "0.6348413", "0.6348413", ...
0.0
-1
function getter of y. Return the private attribute of y.
def y(self): return self.__y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_y(self):\n return self.__y", "def y ( self ) :\n return self.yvar", "def getY(self):\n return self.__y", "def getY(self):\r\n\t\treturn self._y", "def y(self):\n return (self.__y)", "def y(self):\n return self[\"y\"]", "def Y(self):\n return self.y\n...
[ "0.8211156", "0.8203353", "0.8118901", "0.81069934", "0.809056", "0.80078703", "0.7958397", "0.79568297", "0.7908904", "0.7908904", "0.7864945", "0.7833086", "0.78205884", "0.78205884", "0.78205884", "0.78205884", "0.78205884", "0.78205884", "0.78205884", "0.78205884", "0.782...
0.80254793
13
function y of width is modified.
def y(self, y): if type(y) is not int: raise TypeError("y must be an integer") if y < 0: raise ValueError("y must be >= 0") self.__y = y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y_size(self):\n pass", "def y(self) -> int:", "def y(self):\n pass", "def y(self, x):\n return x", "def wrap_y(self) -> int:\n return self._wrap_y", "def pixelsizey(self) -> ErrorValue:\n return ErrorValue(self._data['YPixel'], self._data.setdefault('YPixelError',0...
[ "0.6572785", "0.63723826", "0.6260383", "0.62368536", "0.6097661", "0.5998206", "0.59495974", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", "0.5924994", ...
0.5659497
48
method that find the area of a rectangle. Return the area of a rectangle.
def area(self): return self.width * self.height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rect_area(rect):\n return rect[2] * rect[3]", "def rectangle_area(base, height):\n return (base * height)", "def rectangle_area(width : number, height : number) ->number:\n area = width*height\n #print(\"The area of rectangle is =\", area, \"sq. units\")\n return area", "def area_rect(w, h...
[ "0.82248306", "0.8159178", "0.8146606", "0.8018593", "0.7922524", "0.78896415", "0.77728826", "0.77609915", "0.76662093", "0.7627938", "0.7534685", "0.74978864", "0.7481451", "0.7436784", "0.73720986", "0.73571813", "0.73135287", "0.72804546", "0.72797346", "0.7272335", "0.72...
0.68457466
74
method that print in screen a rectangle. with the character "".
def display(self): for _jumpline in range(self.y): print(end="\n") for _height in range(self.height): for _space in range(self.x): print(" ", end="") for _width in range(self.width): print("#", end="") print(end="\n")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rectangle(height,width):\n for row in range(height):\n for column in range(width):\n print(CHAR, end = '')\n print()", "def display(self):\n row = (' ' * self.__x) + (Rectangle.print_symbol * self.__width) + '\\n'\n print(('\\n' * self.__y) + (row * self.__height), e...
[ "0.77359396", "0.73379", "0.72519505", "0.7151739", "0.6960012", "0.69556326", "0.6913779", "0.68737376", "0.6843139", "0.68156284", "0.6770897", "0.67551607", "0.6753198", "0.67503697", "0.67081517", "0.6704995", "0.66788816", "0.6676752", "0.6670293", "0.6664551", "0.665134...
0.6455042
42
method that convert Python objects into strings. Return the object in string.
def __str__(self) -> str: return "[Rectangle] ({}) {}/{} - {}/{}".\ format(self.id, self.x, self.y, self.width, self.height)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_(object_):\n return str(object_)", "def objectToString(obj):\n if (hasattr(obj, \"__iter__\")):\n # matrix or vector\n if len(obj) == 0:\n return \"\"\n else:\n if (hasattr(obj[0], \"__iter__\")):\n # matrix\n return matrixToS...
[ "0.82419026", "0.7954741", "0.78152406", "0.773751", "0.7668481", "0.7638423", "0.7572983", "0.73172534", "0.72955215", "0.7287602", "0.72510856", "0.7232165", "0.7204237", "0.71857375", "0.7182068", "0.7144081", "0.7121091", "0.7044212", "0.69868326", "0.6939111", "0.6920688...
0.0
-1
method that update the arguments of each attribute with the argument kwargs.
def update(self, *args, **kwargs): if args: my_list = ['id', 'width', 'height', 'x', 'y'] for i in range(len(args)): setattr(self, my_list[i], args[i]) else: for key, value in kwargs.items(): setattr(self, key, value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateAttrs(self, kwargs):\n for k, v in kwargs.iteritems():\n setattr(self, k, v)", "def update(self, *args, **kwargs):\n if args is not () and args is not None:\n attr_names = [\"id\", \"size\", \"x\", \"y\"]\n for index, attr in enumerate(args):\n ...
[ "0.8080206", "0.76989526", "0.76720726", "0.763494", "0.7632453", "0.7591798", "0.7569203", "0.751074", "0.7499558", "0.7487695", "0.7420642", "0.7385164", "0.7351219", "0.728038", "0.72645634", "0.71921843", "0.71651256", "0.7086656", "0.70693654", "0.7065505", "0.70310396",...
0.74814165
10
method that adding in a dictionary the attributes of the class rectangle. Return the dictionary with the attributes.
def to_dictionary(self): my_dic = { 'id': self.id, 'width': self.width, 'height': self.height, 'x': self.x, 'y': self.y } return my_dic
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rectangledict(self):\n return rectangledict(self.rectangles)", "def to_dictionary(self):\n dictionary = dict(self.__dict__)\n for key in dictionary:\n new_key = key.replace(\"_Rectangle__\", \"\")\n dictionary[new_key] = dictionary.pop(key)\n return dictionary\n ...
[ "0.7408595", "0.72013086", "0.68213564", "0.67093587", "0.6664881", "0.66571337", "0.6597422", "0.6558994", "0.64552194", "0.6355584", "0.6302567", "0.6284163", "0.62188774", "0.61945736", "0.60779554", "0.6066608", "0.60477173", "0.6038226", "0.60199076", "0.60147053", "0.60...
0.56820136
45
Test the clear method works for NTbased systems
def test_clear_windows(self): with mock.patch("hangman.cli.screen.os.system") as mock_system: hangman.cli.screen.Screen.clear() mock_system.assert_called_with("cls")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear():\r\n if name == 'nt':\r\n _ = system('cls')\r\n else:\r\n _ = system('clear')", "def clear(): \n if os.name == \"nt\":\n os.system(\"cls\")\n else:\n os.system(\"clear\")", "def clear():\n if os.name == 'nt': \n os.system('cls') \n else: \n ...
[ "0.7493977", "0.7483117", "0.7462642", "0.7444495", "0.7319081", "0.72657627", "0.7236104", "0.7170008", "0.7141984", "0.69726455", "0.6926334", "0.6926334", "0.6907976", "0.69050306", "0.6864983", "0.6864983", "0.6850608", "0.6749582", "0.67168456", "0.6636215", "0.65972525"...
0.6814909
17
Test the clear method works for posixbased systems
def test_clear_posix(self): with mock.patch("hangman.cli.screen.os.system") as mock_system: hangman.cli.screen.Screen.clear() mock_system.assert_called_with("clear")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear():\n\n # windows \n if os.name == \"nt\": \n _ = os.system(\"cls\") \n # mac and linux\n else: \n _ = os.system(\"clear\")", "def clear(): \n if os.name == \"nt\":\n os.system(\"cls\")\n else:\n os.system(\"clear\")", "def clear():\r\n if name == 'nt...
[ "0.7761506", "0.7746805", "0.7741762", "0.772958", "0.7596242", "0.74570656", "0.7336103", "0.7284548", "0.72207433", "0.72207433", "0.71165365", "0.7097402", "0.7097402", "0.70822984", "0.6909185", "0.68754077", "0.6858489", "0.6781232", "0.6764691", "0.6755633", "0.67161864...
0.79437184
0
Test to see if the gallows method returns the correct image
def test_gallows_within_bounds(self): with mock.patch("hangman.cli.screen.print") as mock_print: for index in range(len(hangman.cli.screen._GALLOWS)): hangman.cli.screen.Screen.gallows(index) mock_print.assert_called_with(hangman.cli.screen._GALLOWS[index])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_image_display(self):\n\n result = self.client.get(\"/select_image\")\n\n self.assertIn(b\"/static/uploads/girl-glowing-skin-blue-eyes.jpg\", result.data)", "def image(self):\n return self.any_image(-1)", "def test_Image():\n assert Image(cur, \"Simple_Linear\").detect_image() == Tr...
[ "0.66298425", "0.6477675", "0.64134514", "0.640309", "0.63916004", "0.6377701", "0.6357215", "0.633534", "0.63193035", "0.63193035", "0.6305505", "0.62537336", "0.6252625", "0.62456065", "0.6232906", "0.6224744", "0.6224744", "0.62182146", "0.6191985", "0.6188353", "0.6181032...
0.0
-1
Test the gallows method handles out of bounds indices
def test_gallows_outside_bounds(self): with mock.patch("hangman.cli.screen.print") as mock_print: for index in [-1, len(hangman.cli.screen._GALLOWS)]: hangman.cli.screen.Screen.gallows(index) mock_print.assert_called_with(hangman.cli.screen._GALLOWS[-1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_out_of_bounds_calls(self):\n with self.assertRaises(IndexError):\n self.gameBoard.getGridItem(101,101)", "def _validate_indexes(self, row, col):\n if min(row, col) < 0 or max(row, col) >= self._n:\n raise IndexError(\n \"Incorrect position (%d, %d) in g...
[ "0.707258", "0.67884666", "0.6612479", "0.6408795", "0.6359397", "0.63439476", "0.6291896", "0.62381816", "0.6209924", "0.62078774", "0.61812973", "0.61478335", "0.6143461", "0.6123273", "0.6093582", "0.6058438", "0.6057654", "0.6057572", "0.6046116", "0.60263014", "0.6016032...
0.6361581
4
Test the get method
def test_get(self): with mock.patch("builtins.input") as mock_input: mock_input.return_value = "foo" self.assertEqual(hangman.cli.screen.Screen.get("Foo?"), "foo")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get(self):\n pass", "def test_get(self):\n return self.doRequest(self.url, method=\"GET\", body=self.input)", "def test_gettem_using_get(self):\n pass", "def test_get2(self):\n pass", "def test_get1(self):\n pass", "def test_listtem_using_get(self):\n pa...
[ "0.91126484", "0.8588359", "0.857955", "0.8355553", "0.82723737", "0.8097538", "0.7919598", "0.7919598", "0.79123116", "0.79123116", "0.7767401", "0.7767401", "0.7659542", "0.7615611", "0.7463382", "0.7394966", "0.7359122", "0.7359122", "0.7332673", "0.73318106", "0.73232585"...
0.0
-1
Test the put method
def test_put(self): with mock.patch("builtins.print") as mock_print: hangman.cli.screen.Screen.put("foo!") mock_print.assert_called_with("\nfoo!")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_kyc_put_request(self):\n pass", "def test_put_method(self):\n self.getPage('/blah', method='PUT')\n self.assertStatus('200 OK')\n self.assertHeader('Content-Type', 'application/json')\n self.assertBody('{\"mystring\": \"blah\"}')", "def test_add_item_at_using_put(sel...
[ "0.8060677", "0.7866297", "0.78294384", "0.7793337", "0.7793337", "0.7779294", "0.7599597", "0.74996424", "0.74829245", "0.7425634", "0.7425499", "0.7411632", "0.7402768", "0.7373352", "0.7357826", "0.73161113", "0.7281676", "0.72784895", "0.72398466", "0.7162743", "0.7127128...
0.0
-1
Test the goodbye method
def test_goodbye(self): with mock.patch("builtins.print") as mock_print: hangman.cli.screen.Screen.goodbye() output = ",".join([str(x) for x in mock_print.call_args_list]) self.assertTrue("Goodbye" in output)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def goodbye(self, args):\n\t\tself.write_line(\"GOODBYE\")\n\t\tself.close();", "async def testgoodbye(self, ctx, *, member = None):\n\n # Check if we're suppressing @here and @everyone mentions\n if self.settings.getServerStat(ctx.message.guild, \"SuppressMentions\"):\n suppress = True\...
[ "0.7509933", "0.6987562", "0.6891158", "0.6829135", "0.68261707", "0.68175083", "0.6816748", "0.6797453", "0.6768984", "0.6768984", "0.6768984", "0.67623085", "0.67623085", "0.67623085", "0.67440975", "0.66107154", "0.658389", "0.6566832", "0.65569544", "0.65374553", "0.65335...
0.7486902
1
Returns the total number of hives in this apiary.
def hives_count(self) -> int: return self.hives.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self) -> float:\n return pulumi.get(self, \"count\")", "def count(self) -> int:\n return pulumi.get(self, \"count\")", "def total_number_of_animals(self):\n animals = self.animal()\n print 'Total number of animals on island: {:4}'.format(\n animals[\"Herbivores\...
[ "0.6977683", "0.6883911", "0.6836276", "0.6753868", "0.6753868", "0.6753868", "0.6739675", "0.67286235", "0.67053115", "0.66854024", "0.6670815", "0.66571957", "0.6634862", "0.6606549", "0.65562564", "0.6529486", "0.6525879", "0.65013546", "0.64641476", "0.64448", "0.64448", ...
0.8205529
0
Performs an arbitrary mapping on the data and returns the result. This is typically an expansion of the data. For instance, the quadratic expansion for data like ( a b ) is ( a b a^2 b^2 ab) ( c d ) ( c d c^2 d^2 cd) ( ... ) ( ... )
def getExpansion(self, data): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map():", "def tuple_map(x):\n return x * 2", "def reflect(data, mapfunc = lambda x:x):\n data2 = np.zeros([tsize, npsi])\n # Copy the original data\n for i in np.arange(ntheta):\n data2[i,:] = data[i,:]\n # Now fill in the remainder\n ...
[ "0.613614", "0.575563", "0.57504135", "0.57287925", "0.5712245", "0.5601982", "0.55600595", "0.55141425", "0.5502613", "0.54546046", "0.54486644", "0.54435486", "0.5433881", "0.54220146", "0.53886235", "0.53791046", "0.5376159", "0.53648996", "0.5351457", "0.53402036", "0.533...
0.0
-1
Convenience method which overrides the call method to call the getExpansion function
def __call__(self, data): return self.getExpansion(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getExpansion(self, data):\n pass", "def expansion_method(self, expansion_method):\n\n self._expansion_method = expansion_method", "def expand(self) -> List[TOKEN]:\n return [self.function, *self.args]", "def get_expansion(block, expansion=None):\n if isinstance(expansion, int):\n ...
[ "0.74891585", "0.5920144", "0.54512185", "0.5370277", "0.53289384", "0.5261651", "0.5257707", "0.5253625", "0.5253625", "0.5253625", "0.5253625", "0.5253625", "0.525186", "0.5245593", "0.51983786", "0.5187937", "0.51806074", "0.51613045", "0.51613045", "0.5146855", "0.5107178...
0.775161
0
Saves a copy of the database into the tmp directory. Modify this code directly if needed, as it hardwires the username, db name and filename.
def mysqldump(): run("mysqldump -u database_user database_name -p > ~/tmp/exported_db.sql")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup():\n backup_shift(os, config.utils.tasks.backup_depth)\n if config.utils.tasks.secret_key is None:\n shutil.copyfile(config.core.database_name, config.core.database_name+'.1')\n else:\n data = get_encrypted_database()\n with open(config.core.database_name+'.1', 'wb') as f:\...
[ "0.6738473", "0.64771056", "0.6374693", "0.6369591", "0.62350726", "0.6213593", "0.6164571", "0.60522014", "0.6035333", "0.60280454", "0.60020876", "0.6000187", "0.59944266", "0.5981501", "0.5978801", "0.5921293", "0.58182704", "0.5779628", "0.5761551", "0.5757", "0.57395315"...
0.63280445
4
To save some output text and time, if you know only one app has changed its database structure, you can run this with the app's name.
def deploy(app_to_migrate=""): mysqldump() # backup database before making changes with cd(code_dir): run("git pull") run(python_add_str + "python manage.py migrate %s" % app_to_migrate) run(python_add_str + "python manage.py createinitialrevisions") # only if using reversion run(python_add_str + "python manage.py collectstatic --noinput") run("../apache2/bin/restart")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def django_sql(appname):\r\n app = wingapi.gApplication\r\n cmdline, dirname, err = _get_base_cmdline()\r\n if err is not None:\r\n title = _(\"Failed to Generate SQL\")\r\n msg = _(\"Could not generate SQL: %s\") % err\r\n app.ShowMessageDialog(title, msg)\r\n return\r\n cmdline += ['sql', appnam...
[ "0.60006577", "0.59486735", "0.59302884", "0.59237796", "0.5841282", "0.5828717", "0.5821404", "0.57724136", "0.5769709", "0.57531637", "0.5702471", "0.5648174", "0.56297046", "0.5620219", "0.5586959", "0.55405587", "0.5521775", "0.55170804", "0.5489317", "0.54577833", "0.544...
0.0
-1
Imports a database from the tmp directory. Use very carefully! (or just to remind yourself how to import mysql data) Modify this code directly if needed, as it hardwires the username, db name and filename.
def mysql_import(): # first make another copy of the db run("mysqldump -u database_user database_name -p > ~/tmp/exported_db_temp.sql") # then import from the backup run("mysql -u database_user -p -D database_name < ~/tmp/exported_db.sql")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_db(import_file):\n import_data(import_file)", "def test_load_database_from_path(tmp_path):\n path = tmp_path / \"test.db\"\n database = load_database(path_or_database=path, fast_logging=False)\n assert isinstance(database, DataBase)\n assert database.path is not None\n assert databas...
[ "0.68345016", "0.64033103", "0.6076044", "0.6069602", "0.60656613", "0.6017671", "0.59419686", "0.59211564", "0.5919211", "0.5879916", "0.57659775", "0.5732443", "0.5716429", "0.5715574", "0.5714675", "0.5714328", "0.568365", "0.56806725", "0.56564546", "0.5650345", "0.564375...
0.7754526
0
Set up an ssh shortcut. Called by setup_ssh_keys. You can call it separately if desired.
def update_ssh_shortcut(output_keyfile, quickname=None): if quickname: with settings(warn_only=True): local("touch $HOME/.ssh/config") local(r"echo '' >> $HOME/.ssh/config") local(r"echo 'Host %s' >> $HOME/.ssh/config" % quickname) local(r"echo '' >> $HOME/.ssh/config") local(r"echo 'Hostname %s' >> $HOME/.ssh/config" % host_name) local(r"echo 'User %s' >> $HOME/.ssh/config" % user) local(r"echo 'IdentityFile ~/.ssh/%s' >> $HOME/.ssh/config" % output_keyfile) local(r"echo 'ServerAliveCountMax 3' >> $HOME/.ssh/config") local(r"echo 'ServerAliveInterval 10' >> $HOME/.ssh/config")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createPuttyShortcuts(folder = \"Putty Connections\"):\n desktop = winshell.desktop()\n cpath = os.path.join(desktop, folder)\n\n if not os.path.exists(cpath):\n os.mkdir(cpath)\n \n for c in getPuttyConnections():\n if c.strip() != \"\":\n path = os.path.join(cpath, c + \".lnk\")\n ...
[ "0.6442464", "0.64414567", "0.6348135", "0.61858404", "0.61858267", "0.6147583", "0.6134668", "0.6058073", "0.59874713", "0.58345175", "0.5792532", "0.5744603", "0.572959", "0.5720658", "0.56933945", "0.56765187", "0.56707656", "0.56636703", "0.55993026", "0.558472", "0.55672...
0.6833319
0
Generate a new SSH key and deliver it to the server. If quickname is provided, also set up an ssh shortcut. Use this to enable passwordless access to webfaction.
def setup_ssh_keys(output_keyfile="id_rsa", ssh_type="rsa", quickname=None): with settings(warn_only=True): local("mkdir -p $HOME/.ssh") with cd("$HOME/.ssh"): local("ssh-keygen -t %s -f %s" % (ssh_type, output_keyfile)) for host in env.hosts: local("scp %s.pub %s:temp_id_key.pub" % (output_keyfile, host)) with settings(warn_only=True): run("mkdir -p $HOME/.ssh") run("cat $HOME/temp_id_key.pub >> ~/.ssh/authorized_keys") run("rm $HOME/temp_id_key.pub") run("chmod 600 $HOME/.ssh/authorized_keys") run("chmod 700 $HOME/.ssh") run("chmod go-w $HOME") if quickname: update_ssh_shortcut(output_keyfile, quickname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_ssh_shortcut(output_keyfile, quickname=None):\n if quickname:\n with settings(warn_only=True):\n local(\"touch $HOME/.ssh/config\")\n local(r\"echo '' >> $HOME/.ssh/config\")\n local(r\"echo 'Host %s' >> $HOME/.ssh/config\" % quickname)\n local(r\"echo '' >> $HO...
[ "0.67290777", "0.635065", "0.6294067", "0.62377936", "0.61897206", "0.5912573", "0.58597594", "0.5857335", "0.5813296", "0.5799843", "0.57982856", "0.5796951", "0.5789643", "0.56701356", "0.56502396", "0.5586603", "0.5574599", "0.5564199", "0.5562149", "0.55100757", "0.549769...
0.69770044
0
Installs pip itself if needed.
def install_pip(): with settings(warn_only=True): run('mkdir $HOME/lib/python2.7') run('easy_install-2.7 pip')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pip_install():\n _require_environment()\n remote(PIP_INSTALL_PREFIX)", "def pipInstall(self):\n\n print \"Does Nothing\"", "def _setup_pip(self, context):\n # We run ensurepip in isolated mode to avoid side effects from\n # environment vars, the current directory and anything else\...
[ "0.7695657", "0.74213576", "0.7209003", "0.7197479", "0.7096822", "0.7030998", "0.69859535", "0.6862794", "0.68612194", "0.6831305", "0.6793315", "0.6789067", "0.6607342", "0.6605917", "0.65682715", "0.65639573", "0.6522661", "0.64693004", "0.64424676", "0.6357721", "0.632134...
0.7709263
0
Creates a new git repo on the server (do not include the .git ending in git_repo_name)
def create_prod_git_repo(git_repo_name): with cd(git_dir): run("git init --bare %s.git && cd %s.git && git config http.receivepack true" % (git_repo_name,git_repo_name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_storer_git_repo():\n # first make teh destination directory\n rel_repo_path = vmcheckerpaths.repository\n abs_repo_path = vmcheckerpaths.abspath(rel_repo_path)\n _mkdir_if_not_exist(abs_repo_path)\n\n # then, if missing, initialize a git repo in it.\n repo_path_git = os.path.join(abs_r...
[ "0.78584546", "0.76648015", "0.7265442", "0.72380567", "0.719079", "0.7102667", "0.709434", "0.7067098", "0.7028291", "0.70168835", "0.6969751", "0.69651526", "0.6953235", "0.69130766", "0.68735963", "0.68264115", "0.67686075", "0.67527515", "0.6737532", "0.6696314", "0.66333...
0.805788
0
Adds the git repo on the server as the local .git repo's origin, and pushes master to it. (do not include the .git ending in git_repo_name)
def add_prod_repo_as_origin_and_push(git_repo_name): local("""echo '[remote "origin"]' >> .git/config""") local(r"echo ' fetch = +refs/heads/*:refs/remotes/origin/*' >> .git/config") local(r"echo ' url = %s:webapps/git/repos/%s.git' >> .git/config" % (env.hosts[0], git_repo_name)) local(r"git push origin master")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(self):\n origin = self.git_repo.remotes.origin\n origin.push()", "def push(ctx):\n dufl_root = ctx.obj['dufl_root']\n git = Git(ctx.obj.get('git', '/usr/bin/git'), dufl_root)\n git.run('push', 'origin', git.working_branch())", "def push():\n branch = git.current_branch().name...
[ "0.74367875", "0.7217327", "0.7001284", "0.68715334", "0.6737078", "0.6531534", "0.65219814", "0.6468138", "0.6464436", "0.6363024", "0.632618", "0.62762666", "0.6264901", "0.62638634", "0.6229483", "0.62241775", "0.61916083", "0.6184975", "0.6179584", "0.61400473", "0.607894...
0.81499577
0
Updates the apache httpd.conf file to point to the new project instead of the default 'myproject'. This is called as part of clone_into_project, or you can call
def update_conf_file(): filepath = remote_dir + "/apache2/conf/httpd.conf" fabric.contrib.files.sed(filepath, 'myproject', project_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_project():\n _require_environment()\n\n # Grants write rights on log dir for the admin group\n log_dir = '%s/log' % _interpolate(VIRTUALENV_DIR)\n if files.exists(log_dir):\n sudo('chmod -R g+w %s' % log_dir)\n\n # Updates from git, issues Django syncdb, South migrate, Collecstatic...
[ "0.6472111", "0.6156051", "0.6123365", "0.5980424", "0.5979637", "0.5878512", "0.57706547", "0.56331587", "0.55369204", "0.5507125", "0.54162174", "0.5402613", "0.53572744", "0.52999634", "0.5277135", "0.52048105", "0.5179632", "0.5174573", "0.5156144", "0.514356", "0.5130455...
0.72978866
0
Clones the git repo into the new webapp, deleting the default myproject project and updating the config file to point to the new project. Also adds a site_settings.py file to the project/project folder.
def clone_into_project(git_repo_name): repo_dir = git_dir + "/%s.git" % git_repo_name with cd(remote_dir): run('rm -rf myproject') run("git clone %s %s" % (repo_dir, project_name)) run("echo 'MY_ENV=\"prod\"' > %s/%s/site_settings.py" % (project_name,project_name)) update_conf_file()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_project():\n _require_environment()\n\n # Grants write rights on log dir for the admin group\n log_dir = '%s/log' % _interpolate(VIRTUALENV_DIR)\n if files.exists(log_dir):\n sudo('chmod -R g+w %s' % log_dir)\n\n # Updates from git, issues Django syncdb, South migrate, Collecstatic...
[ "0.6597053", "0.6376039", "0.6335648", "0.61842006", "0.6173729", "0.6145058", "0.6005152", "0.59648216", "0.595788", "0.59347206", "0.5933034", "0.5923805", "0.59103745", "0.58390486", "0.5812732", "0.57964295", "0.572337", "0.56827134", "0.5680887", "0.5663389", "0.56439286...
0.7331329
0
Adds the "/static" and "/media" directories to the static webapp if needed, and deletes the default index.html. Also adds a project/project/static directory if there isn't one.
def add_dirs_to_static(static_webapp_name): static_dir = '$HOME/webapps/%s' % static_webapp_name with settings(warn_only=True): with cd(static_dir): run("mkdir static && mkdir media") run("rm index.html") run("touch index.html") with cd(code_dir): run("mkdir %s/static" % project_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def include_static_files(app):\n file_path = sphinx_prolog.get_static_path(STATIC_FILE)\n if file_path not in app.config.html_static_path:\n app.config.html_static_path.append(file_path)", "def ensure_static_exists():\n for entry in html_static_path:\n static_path = os.path.join(__repo_doc...
[ "0.70106965", "0.68311924", "0.6625952", "0.63648784", "0.61918205", "0.60434896", "0.5981367", "0.58381754", "0.5810352", "0.57726264", "0.57547545", "0.57248443", "0.56464094", "0.5618542", "0.56139016", "0.5593905", "0.55286866", "0.55245644", "0.5519247", "0.55121106", "0...
0.7912355
0
Installs the necessary thirdparty apps into the local webapp (not globally) using pip. There is probably a better way to do this using a requirements file. Also appends a helpful comment to .bashrc_profile.
def pip_installs(): pip = r'pip-2.7 install --install-option="--install-scripts=$PWD/bin" --install-option="--install-lib=$PWD/lib/python2.7" ' with settings(warn_only=True): run("mkdir $HOME/tmp") with cd(remote_dir): for installation in install_list: run("export TEMP=$HOME/tmp && %s %s" % (pip, installation)) run("echo '#%s' >> $HOME/.bash_profile" % python_add_str)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup(ctx):\r\n ctx.run('pip3 install -r requirements.txt')", "def install_requirements():\n _git_pull()\n _install_requirements()\n _syncdb()\n _migrate()\n _restart_webserver()", "def install_requirements():\n local('. fabric_factory/ve/bin/activate; easy_install pip')\n local('. ...
[ "0.7519722", "0.7148218", "0.7090568", "0.7072766", "0.6987992", "0.6935873", "0.69101477", "0.6883953", "0.68306017", "0.6790433", "0.6782558", "0.67806673", "0.6776519", "0.67606586", "0.6741522", "0.67095673", "0.67082644", "0.6687862", "0.6645893", "0.6642955", "0.6596737...
0.6606969
20
Initialises the database to contain the tables required for DjangoCMS with South. Runs syncdb all and migrate fake.
def initialise_database(): with cd(code_dir): run(python_add_str + "python manage.py syncdb --all") run(python_add_str + "python manage.py migrate --fake")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_database():\n from django.core.management import call_command\n from django import setup\n setup()\n call_command('migrate', verbosity=0, interactive=False)\n call_command('loaddata', data('initial_data.json'), verbosity=0, interactive=False)", "def init_db():\n db = get_db()\n Pag...
[ "0.7663976", "0.75398517", "0.75250465", "0.7471838", "0.7441649", "0.7391628", "0.73528063", "0.72446615", "0.72148156", "0.72110015", "0.71857905", "0.7177211", "0.7132408", "0.7070013", "0.705777", "0.7000869", "0.69667584", "0.69374496", "0.6935844", "0.6935844", "0.68986...
0.8100372
0
Calculate optimal alignment with FengDoolittle algorithm.
def run(self, seq_fasta_fn, subst_matrix_fn, cost_gap_open, clustering):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seq_align(string1,string2,mismatch_penalty,gap_penalty):\n\n # define 2x2 matrix\n matrix = []\n for i in range(len(string1)+1):\n if i == 0:\n matrix.append(list([gap_penalty * x for x in range(len(string2)+1)]))\n else:\n matrix.append(list([gap_penalty * i if x =...
[ "0.6580737", "0.6504036", "0.64750624", "0.6450722", "0.6416593", "0.63871074", "0.6386579", "0.6293225", "0.61991656", "0.6193383", "0.6179944", "0.6168121", "0.61549205", "0.6107183", "0.60953724", "0.60164833", "0.59894025", "0.5960489", "0.5937504", "0.5936695", "0.593435...
0.0
-1
Fast translation, rotation & scale in 2D using np.einsum in case input is not a single point
def fast_TRS_2d(input, transform_matrix, input_is_point=False): if input_is_point: return np.delete(np.dot(transform_matrix, np.insert(input, 2, 1)), 2) else: return np.delete(np.einsum('jk,ik->ij', transform_matrix, np.insert(input, 2, 1, axis=1)), 2, 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transAffine2D( iScale=(1, 1), iTrans=(0, 0), iRot=0, iShear=(0, 0) ): \n iRot = iRot * np.pi / 180\n oMatScale = np.matrix( ((iScale[0],0,0),(0,iScale[1],0),(0,0,1)) )\n oMatTrans = np.matrix( ((1,0,iTrans[0]),(0,1,iTrans[1]),(0,0,1)) )\n oMatRot = np.matrix( ((np.cos(iRot),-np.sin(iRot),0),\\\n...
[ "0.65614295", "0.634234", "0.61342865", "0.61295545", "0.61271703", "0.59918904", "0.5945617", "0.5937629", "0.5931673", "0.59223235", "0.5891538", "0.58714736", "0.5866033", "0.58649784", "0.58559966", "0.5835464", "0.5825817", "0.58026475", "0.5768168", "0.575795", "0.57447...
0.5372871
64
Binary mask from cv2 styled contour (gets filled)
def make_mask(shape, contour): mask = np.zeros(shape, np.int32) cv2.drawContours(mask, [contour], 0, (255), -1) return mask
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_contour_features(mask,selectcell=\"centered\"):\r\n \r\n #binarize image (everything above 0 becomes 1)\r\n mask = np.clip(mask,a_min=0,a_max=1)\r\n\r\n #for contours, dont use RETR_TREE, but RETR_EXTERNAL as we are not interested in internal objects\r\n contours, _ = cv2.findContours(mask, ...
[ "0.7214323", "0.70771843", "0.694643", "0.69156", "0.6753374", "0.6689051", "0.66160184", "0.66025215", "0.65440816", "0.6517318", "0.65129876", "0.64886975", "0.6453866", "0.64246404", "0.64205784", "0.6411343", "0.63934743", "0.6383716", "0.6381961", "0.6374727", "0.6347511...
0.7433139
0
Load saved output from QuPath img import & processing function basically just a stupid wrapper for json.load for now
def load_co_registration_data_from_json(filename: str) -> Dict[str, CoRegistrationData]: with open(filename, "r") as json_file: data = json.load(json_file) co_reg_data = {} for index, data in data.items(): co_reg_data[index] = CoRegistrationData( name=str(data['name']), target_w=int(data['target_w']), target_h=int(data['target_h']), transform_matrix=np.array(data['transform_matrix']), moving_img_name=str(data['moving_img_name']) ) return co_reg_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadjson(path, objectsofinterest, img):\n with open(path) as data_file:\n data = json.load(data_file)\n # print (path)\n pointsBelief = []\n boxes = []\n points_keypoints_3d = []\n points_keypoints_2d = []\n pointsBoxes = []\n poses = []\n centroids = []\n\n translations = ...
[ "0.60999244", "0.60512304", "0.5816437", "0.58107746", "0.5780941", "0.57445073", "0.5644108", "0.5631807", "0.56096995", "0.56022495", "0.55884826", "0.5587083", "0.5582107", "0.5529392", "0.55193985", "0.5491933", "0.54883915", "0.547414", "0.5427283", "0.54183984", "0.5399...
0.0
-1
Save output from QuPath img import & processing function to JSON file
def save_co_registration_data_to_json(datasets: Dict[str, CoRegistrationData], output_file) -> str: to_json_tmp = {} for index, data in datasets.items(): to_json_tmp[index] = { 'name': data.name, 'target_w': data.target_w, 'target_h': data.target_h, 'transform_matrix': data.transform_matrix.tolist(), 'moving_img_name': data.moving_img_name } with open(output_file, "w") as data_file: json.dump(to_json_tmp, data_file, indent=4, sort_keys=True) return json.dumps(to_json_tmp, indent=4, sort_keys=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __make_processing(self, img_name, abspath_dir_img, id_foot):\n data = {}\n data['data'] = ImageInfo.get_date(abspath_dir_img)\n data['total_part'] = TOTAL_PART\n data['nuvens'] = ImageInfo.get_cloud(abspath_dir_img)\n self.__make_tms(abspath_dir_img)\n data['geom'] = s...
[ "0.64531106", "0.64168984", "0.6302975", "0.6163437", "0.6081732", "0.6022132", "0.5954592", "0.59521526", "0.5950262", "0.59386396", "0.5938475", "0.58703864", "0.58624244", "0.5849132", "0.5811577", "0.5798862", "0.579062", "0.5771886", "0.57512766", "0.5739413", "0.5733601...
0.0
-1
Converts either bytes or unicode to `bytes`, using utf8 encoding for text.
def as_bytes(bytes_or_text, encoding='utf-8'): if isinstance(bytes_or_text, _six.text_type): return bytes_or_text.encode(encoding) elif isinstance(bytes_or_text, bytes): return bytes_or_text else: raise TypeError('Expected binary or unicode string, got %r' % (bytes_or_text,))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _to_bytes(value: Union[str, bytes]) -> bytes:\n return value if isinstance(value, bytes) else value.encode(\"utf-8\")", "def ensure_utf8_bytes(v: Union[str, bytes]) -> bytes:\n if isinstance(v, str):\n v = v.encode(\"utf-8\")\n return v", "def force_utf8(text):\n if isinstance(text, bina...
[ "0.78761524", "0.78181183", "0.78134924", "0.77963704", "0.7775173", "0.77212256", "0.7695007", "0.76554793", "0.76551324", "0.76297563", "0.7587289", "0.75190413", "0.74554324", "0.74133134", "0.74104327", "0.74089986", "0.73655003", "0.73444015", "0.72940016", "0.72861797", ...
0.7902959
0
Returns the given argument as a unicode string.
def as_text(bytes_or_text, encoding='utf-8'): if isinstance(bytes_or_text, _six.text_type): return bytes_or_text elif isinstance(bytes_or_text, bytes): return bytes_or_text.decode(encoding) else: raise TypeError( 'Expected binary or unicode string, got %r' % bytes_or_text )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def safe_unicode(arg, *args, **kwargs):\n return arg if isinstance(arg, str) else str(arg, *args, **kwargs)", "def unicode2utf8(arg):\n\n try:\n if isinstance(arg, unicode):\n return arg.encode('utf-8')\n except NameError:\n pass # Python 3\n return arg", "def __str__(self...
[ "0.7720573", "0.7472295", "0.7162145", "0.7126575", "0.6827276", "0.66389793", "0.63655776", "0.63655776", "0.6295255", "0.62470526", "0.62246895", "0.61486644", "0.6147634", "0.6133242", "0.6103886", "0.6103886", "0.6103886", "0.6103886", "0.6103886", "0.6103886", "0.6079908...
0.0
-1
Converts to `str` as `str(value)`, but use `as_str` for `bytes`.
def as_str_any(value): if isinstance(value, bytes): return as_str(value) else: return str(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_string(value):\n if isinstance(value, encodingutils.binary_type):\n return encodingutils.bytes_to_string(value)\n else:\n return encodingutils.text_type(value)", "def convert_to_string(value: Any) -> str:\n if isinstance(value, str):\n return value\n\n if isinstance(value,...
[ "0.8348208", "0.8329601", "0.8227834", "0.81440604", "0.7737775", "0.7444207", "0.74415994", "0.734178", "0.7317427", "0.7214035", "0.7206868", "0.7206296", "0.7203044", "0.72022784", "0.71490884", "0.705423", "0.7025212", "0.70000285", "0.69751537", "0.69738203", "0.6964417"...
0.80614305
4
Returns the file system path representation of a `PathLike` object.
def path_to_str(path): if hasattr(path, '__fspath__'): path = as_str_any(path.__fspath__()) return path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_string(path: pathlib.Path) -> str:\n return path.as_posix()", "def path_serializer(obj: PurePath, **_: Any) -> str:\n return obj.as_posix()", "def as_pathlib(self):\n return Path(self.absolute)", "def _purepath_to_str(\n self, path: Union[Path, PurePath, str]\n ) -> Union[Pa...
[ "0.6641513", "0.64170814", "0.6181322", "0.61145943", "0.5960764", "0.5935031", "0.5927816", "0.5881648", "0.5880042", "0.58208156", "0.5757177", "0.57282186", "0.5713228", "0.5694669", "0.56730723", "0.5647542", "0.56423336", "0.56211954", "0.56108016", "0.5586084", "0.55525...
0.61987334
2
DO NOT EDIT Initialize a node
def __init__(self, value, next_node=None): self.value = value # element at the node self.next_node = next_node # reference to next node
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.node = None\n self.data = None", "def __init__(self):\n self.root = Node('')", "def __init__(self):\n self.root = Node(None)", "def __init__(self):\n self.start = Node('-1')", "def __init__(self):\n self.root = Node(\"\")", "def __init_...
[ "0.76893985", "0.7661167", "0.7623163", "0.7614204", "0.7602438", "0.7602438", "0.7597835", "0.7509312", "0.7497298", "0.74624723", "0.7459934", "0.74241686", "0.74147093", "0.74051684", "0.7398285", "0.7398285", "0.7398285", "0.7396945", "0.7325279", "0.72634804", "0.7246107...
0.6563765
92
DO NOT EDIT Determine if two nodes are equal (same value)
def __eq__(self, other): if other is None: return False if self.value == other.value: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return type(self) == type(other) and self.node is other.node", "def nodes_are_equal(node1, node2):\n\n try:\n return dump_ast(node1).strip() == dump_ast(node2).strip() and \\\n node1.lineno == node2.lineno and \\\n node1.col_offset == node2.co...
[ "0.76085", "0.7590751", "0.7546388", "0.7519825", "0.7519825", "0.7519825", "0.7519825", "0.7519825", "0.74666744", "0.73625326", "0.73597276", "0.73304427", "0.7314779", "0.7209392", "0.7208096", "0.71472955", "0.71115476", "0.710639", "0.710639", "0.7105356", "0.7098044", ...
0.0
-1
DO NOT EDIT String representation of a node
def __repr__(self): return str(self.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_node_str():\n a_left = Node(7, data='pl left')\n a_right = Node(42, data='pl right')\n a = Node(13, data='pl a', left=a_left, right=a_right)\n string_a = str(a)\n expect_string = '13'\n assert string_a == expect_string", "def test_node_str():\n node_a = Node({'name':['list','of','ve...
[ "0.71952814", "0.69486153", "0.6932254", "0.686408", "0.68391114", "0.683295", "0.68214226", "0.68039536", "0.6790645", "0.6687023", "0.6634845", "0.6466171", "0.6461758", "0.64257735", "0.6393528", "0.6344041", "0.63340676", "0.63146573", "0.63079375", "0.6293312", "0.627245...
0.0
-1
DO NOT EDIT Create/initialize an empty linked list
def __init__(self, data=None): self.head = None # Node self.tail = None # Node self.size = 0 # Integer if data: [self.push_back(i) for i in data]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n node = ListNode(0) # dummy\n self.head = node\n self.tail = node\n self.len = 0", "def __init__(self, lst=[]):\n self.__length = 0 # current length of the linked list\n self.__head = None # pointer to the first node in the list\n for e in ...
[ "0.77725506", "0.77538705", "0.7744785", "0.76412094", "0.7635089", "0.7626129", "0.76229495", "0.7537509", "0.75358", "0.75358", "0.7468231", "0.7464318", "0.74601215", "0.7418059", "0.7418059", "0.7418059", "0.74112684", "0.7407795", "0.73824275", "0.73780024", "0.73205614"...
0.6659353
94
DO NOT EDIT Defines "==" (equality) for two linked lists
def __eq__(self, other): if self.size != other.size: return False if self.head != other.head or self.tail != other.tail: return False # Traverse through linked list and make sure all nodes are equal temp_self = self.head temp_other = other.head while temp_self is not None: if temp_self == temp_other: temp_self = temp_self.next_node temp_other = temp_other.next_node else: return False # Make sure other is not longer than self if temp_self is None and temp_other is None: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other: LinkedList) -> bool:\n curr1 = self._first\n curr2 = other._first\n are_equal = True\n\n while are_equal and curr1 is not None and curr2 is not None:\n if curr1.item != curr2.item:\n are_equal = False\n curr1 = curr1.next\n ...
[ "0.82909065", "0.77274597", "0.76242423", "0.75131154", "0.7275534", "0.7268777", "0.714763", "0.714763", "0.714763", "0.714763", "0.714763", "0.71005964", "0.7045595", "0.70243096", "0.6943484", "0.69265825", "0.6903196", "0.6843115", "0.68402064", "0.6791717", "0.676546", ...
0.7345923
4
DO NOT EDIT String representation of a linked list
def __repr__(self): temp_node = self.head values = [] if temp_node is None: return str([]) while temp_node is not None: values.append(temp_node.value) temp_node = temp_node.next_node return str(values)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n temp = self.__head\n ss = []\n while temp is not None:\n ss.append(str(temp.data))\n temp = temp.next_node\n return ('\\n'.join(ss))", "def to_string(self):\n try:\n items = \" \"\n current = self.head\n ...
[ "0.72847897", "0.7202857", "0.71419424", "0.71419424", "0.6963336", "0.69505835", "0.6936421", "0.6885288", "0.6866368", "0.6856697", "0.68190056", "0.67749923", "0.6762058", "0.6762058", "0.67520875", "0.6743596", "0.66924685", "0.6669105", "0.6654589", "0.6606938", "0.65600...
0.6343675
30
Gets the number of nodes of the linked list
def length(self): return self.size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_length(self):\n pointer = self.head\n counter = 0\n while pointer:\n counter += 1\n pointer = pointer.next_node\n return counter", "def size(self):\n\n count = 0\n curr_node = self.head\n while curr_node is not None:\n curr...
[ "0.8711247", "0.8629149", "0.8546763", "0.8544969", "0.85332114", "0.8501063", "0.84799534", "0.84799534", "0.8410636", "0.8409078", "0.84006345", "0.83499175", "0.83401936", "0.83310866", "0.8329662", "0.8320223", "0.8318683", "0.82849824", "0.828266", "0.82563204", "0.81936...
0.0
-1
Determines if the linked list is empty
def is_empty(self): return self.size == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty(self):\n return self.linked_list.length() == 0", "def is_empty(self):\n\n if self.head == None:\n return True\n else:\n return False", "def is_empty(self):\n\n if self.head == None:\n return True\n else:\n return False"...
[ "0.89005077", "0.86401933", "0.86401933", "0.86349124", "0.85868573", "0.8544384", "0.85096204", "0.84913164", "0.8477131", "0.84724826", "0.8409223", "0.83905214", "0.8383425", "0.83583224", "0.8358173", "0.834816", "0.834816", "0.8316606", "0.8197637", "0.8186564", "0.81037...
0.7669198
50
Gets the first value of the list
def front_value(self): if self.is_empty(): return None return self.head.value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first(items):\r\n return items[0]", "def first(xs):\n if not xs:\n return None\n return xs[0]", "def first(xs):\n if not xs:\n return None\n return xs[0]", "def peek_first(self):\n if self.is_empty(): raise RuntimeError(\"Empty list\")\n return self.head.data", ...
[ "0.8075285", "0.7880562", "0.7880562", "0.78380233", "0.7835295", "0.7812245", "0.7767049", "0.7702108", "0.76995987", "0.7623594", "0.7603262", "0.7571921", "0.7567571", "0.730875", "0.7265243", "0.72589153", "0.7241536", "0.720047", "0.7198273", "0.7198273", "0.7179391", ...
0.6397124
76
Adds a node to the front of the list with value 'val'
def push_front(self, val): new_node = Node(val, self.head) if self.is_empty(): self.tail = new_node self.head = new_node self.size += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push_front(self, val: Generic[T]) -> None:\n first_node = self.node.next\n\n self.node.next = Node(val)\n latest_first = self.node.next\n\n latest_first.prev = self.node #pushes the node to the front\n latest_first.next = first_node\n first_node.prev = latest_f...
[ "0.80221725", "0.7826861", "0.7751701", "0.77292", "0.7605654", "0.75942093", "0.75738394", "0.755168", "0.7545137", "0.7532508", "0.75297654", "0.75297654", "0.75270396", "0.75006205", "0.7481478", "0.7417329", "0.7411148", "0.7410026", "0.7406186", "0.74055594", "0.738027",...
0.7917012
1
Adds a node to the back of the list with value 'val'
def push_back(self, val): new_node = Node(val) # Update current head and tail, if necessary if self.is_empty(): self.head = new_node else: self.tail.next_node = new_node # new_node is now the tail self.tail = new_node self.size += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push_back(self, val: Generic[T]) -> None:\n last_node = self.node.prev\n self.node.prev = Node(val) #pushes the node to the back\n latest_first = self.node.prev\n\n latest_first.next = self.node #rearranges the list\n latest_first.prev = last_node\n ...
[ "0.8086445", "0.7602821", "0.75396514", "0.74361414", "0.7427383", "0.7410255", "0.74002004", "0.7388654", "0.73812497", "0.7362498", "0.7361017", "0.73132956", "0.73118097", "0.7306703", "0.72853166", "0.7268352", "0.72647965", "0.7225639", "0.7210625", "0.7206143", "0.71408...
0.80715704
1
Removes a node from the front of the list
def pop_front(self): if self.is_empty(): return None val = self.head.value # Update head and size self.head = self.head.next_node self.size -= 1 # If the only node was removed, also need to update tail if self.is_empty(): self.tail = None return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_node_at_start(self):\n if not self.head:\n print('List already empty.')\n return\n self.head = self.head.next", "def pop_front(self):\n if self.head is None:\n raise IndexError('pop_front from empty list')\n node = self.head \n if nod...
[ "0.7608564", "0.7596137", "0.75486904", "0.73908806", "0.7308479", "0.7298663", "0.72594917", "0.72341925", "0.72223204", "0.72218394", "0.72170967", "0.7206209", "0.7150894", "0.71452713", "0.7012732", "0.6987773", "0.69702953", "0.6955942", "0.6948797", "0.69455516", "0.692...
0.70528644
14
Sorts the singly linked list using a placeholder list.
def insertion_sort(self): if self.is_empty(): return #new_list = LinkedList() curr_ele = self.head curr_ele = curr_ele.next_node while (curr_ele is not None): new = self.head while new !=curr_ele: if new.value > curr_ele.value: holder = curr_ele.value curr_ele.value = new.value new.value = holder else: new = new.next_node curr_ele = curr_ele.next_node
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_1(l):\n pass", "def reorderList(self, head: ListNode) -> None:\n node_list = []\n dummy = head\n while dummy:\n node_list.append(dummy)\n dummy = dummy.next\n \n\n l, r = 0, len(node_list) - 1\n while r >= l:\n if l == r:\n ...
[ "0.70741075", "0.67025137", "0.66831917", "0.66423726", "0.66087323", "0.6591983", "0.65739864", "0.65520513", "0.6516934", "0.64655", "0.6462724", "0.64343417", "0.64046", "0.6401858", "0.6391598", "0.6389351", "0.6371825", "0.6366405", "0.63644326", "0.63390523", "0.6335447...
0.6693736
2
List all registered posts
def get(self): return get_all_posts()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_all_posts():\n post = Post.query.all()\n\n return render_template('all-posts.html', post=post)", "def get_posts(self):\n return self.blog_posts.all()", "def post_list(request):\n # Only show the posts that have been published\n posts = Post.objects.filter(date_published__isnull=Fals...
[ "0.743275", "0.69572014", "0.687439", "0.6832434", "0.67154205", "0.66296536", "0.66215444", "0.65834826", "0.6543941", "0.6530415", "0.6451439", "0.64244354", "0.6422649", "0.6408737", "0.6408558", "0.6405169", "0.6393117", "0.6386442", "0.6368651", "0.6358445", "0.63418925"...
0.7320014
1
Creates a new post
def post(self): data = request.json return save_new_post(data=data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_post():\n\n #Get prompt id\n prompt_id = request.form.get('prompt_id')\n\n # Get post text\n post_text = request.form.get('user_post')\n\n # Create post timestamp\n created_at = datetime.now()\n user_facing_date = created_at.strftime(\"%B %d, %Y\")\n\n # Save post and related dat...
[ "0.8113914", "0.81014496", "0.79021746", "0.7772084", "0.7706724", "0.77013963", "0.7577628", "0.7545204", "0.75398254", "0.7489573", "0.74113435", "0.7390827", "0.73677677", "0.7294691", "0.72843033", "0.7280017", "0.7245222", "0.7231795", "0.7203827", "0.72005934", "0.71879...
0.6461794
70
get a post given its title
def get(self, title): post = get_a_post(title) if not post: api.abort(404) else: return post
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_by_title(title: str) -> dict:\n post = Posts.query.filter_by(title=title).first()\n if post is None:\n return {\"status\": 404, \"message\": \"No Post Available\"}\n return {\n \"title\": post.title,\n \"body\": markdown.markdo...
[ "0.7257662", "0.6715822", "0.6635556", "0.66111004", "0.66026914", "0.65306", "0.64700407", "0.6466437", "0.64379615", "0.62551534", "0.6247926", "0.6238597", "0.6233855", "0.6216439", "0.61509603", "0.61505276", "0.6148375", "0.6121378", "0.61104965", "0.60835755", "0.603844...
0.8569673
0
Creates and saves a User with the given email and password.
def _create_user(self, email, password, is_staff, is_superuser, **extra_fields): now = timezone.now() if not email: raise ValueError('The given email must be set') email = self.normalize_email(email) user = self.model(email=email, is_staff=is_staff, is_active=True, is_superuser=is_superuser, last_login=now, date_joined=now, **extra_fields) 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.84163386", "0.8407691", "0.8396383", "0.83900774", "0.83900774", "0.83900774", "0.83818454", "0.83800155", "0.83791924", "0.83788806", "0.83781564", "0.83751047", "0.83726776", "0.83633083", "0.83633083", "0.83633083", "0.8360308", "0.8360308", "0.8347122", "0.8345504", "0...
0.0
-1
Returns the short name for the user required for admin.
def get_short_name(self): return self.full_name.split(' ')[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_short_name(self):\n return self.username", "def get_short_name(self):\n return self.username", "def get_short_name(self):\n return self.username", "def get_short_name(self):\n # The user is identified by the email address\n return self.email", "def get_short_name(...
[ "0.84520036", "0.84520036", "0.84520036", "0.81706136", "0.7997721", "0.78412324", "0.774481", "0.76969534", "0.76969534", "0.76969534", "0.758758", "0.7569117", "0.753553", "0.7458962", "0.7458962", "0.7417198", "0.7403298", "0.7393031", "0.73588586", "0.73505044", "0.730875...
0.6856764
66
Checks whether the user has activated their account.
def is_pending_activation(self): if (self.auth_token_is_used and self.is_active): return False else: return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_active(self, user):\r\n if not self.require_active:\r\n # Ignore & move on.\r\n return True\r\n\r\n return user.is_active", "def user_is_activated(self, user_name):\n return not self._simultanious_log_ins and \\\n user_name in self._active_users_nam...
[ "0.77060133", "0.7657495", "0.74019575", "0.7384715", "0.724473", "0.72160727", "0.72082347", "0.70193785", "0.6999122", "0.6985526", "0.6979906", "0.6939069", "0.6910385", "0.6892355", "0.68483496", "0.68368363", "0.67889947", "0.67825264", "0.675138", "0.67420274", "0.67201...
0.72469395
4
Checks whether the user is an invited user who has not yet activated their account.
def is_invited_pending_activation(self): if self.registration_method == self.INVITED \ and self.is_pending_activation(): return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_approved_user(self):\n (_,\n joining_user_id,\n conversation_id,\n _) = self.setup_invites(is_approved=None)\n self.set_session_cookie(joining_user_id, conversation_id)\n self.set_user_cookie(joining_user_id, conversation_id)\n uri = '/status/{}/{}'....
[ "0.70103204", "0.6990121", "0.69247997", "0.68423045", "0.6763782", "0.6740842", "0.6381607", "0.63654363", "0.63654363", "0.6342342", "0.63128126", "0.6306948", "0.6245732", "0.62384367", "0.6224568", "0.614176", "0.61390686", "0.61390686", "0.6134246", "0.6127191", "0.61174...
0.68240666
4
Checks whether the user has requested an account and is awaiting a decision.
def is_pending_approval(self): if self.registration_method == self.REQUESTED \ and self.is_pending_activation(): return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consent_check():\n\n auth = current.auth\n\n person_id = auth.s3_logged_in_person()\n if not person_id:\n return None\n\n has_role = auth.s3_has_role\n if has_role(\"ADMIN\"):\n required = None\n elif has_role(\"VOUCHER_ISSUER\"):\n req...
[ "0.63010466", "0.63010466", "0.6016238", "0.6006359", "0.600314", "0.5988364", "0.59785503", "0.59660965", "0.59252214", "0.592486", "0.59096104", "0.58924055", "0.58714646", "0.584293", "0.58214206", "0.5796933", "0.5795883", "0.5789712", "0.57822067", "0.5771979", "0.576563...
0.6145321
2
Invite an inactive user (who needs to activate their account). Returns none if user already exists.
def invite_new_user(self, email, full_name): User = get_user_model() if self.is_moderator and self.has_perm('accounts.invite_user'): try: User.objects.get(email=email) except User.DoesNotExist: new_user = create_inactive_user(email, full_name) new_user.registration_method = new_user.INVITED new_user.moderator = self new_user.moderator_decision = new_user.PRE_APPROVED new_user.decision_datetime = timezone.now() new_user.auth_token = generate_unique_id() new_user.save() return new_user else: return None else: raise PermissionDenied
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invite_user(request):\r\n params = request.params\r\n\r\n email = params.get('email', None)\r\n user = request.user\r\n\r\n if not email:\r\n # try to get it from the json body\r\n email = request.json_body.get('email', None)\r\n\r\n if not email:\r\n # if still no email, I ...
[ "0.73747605", "0.68626577", "0.68586427", "0.6745645", "0.6459462", "0.6449257", "0.6446634", "0.6362106", "0.6320504", "0.6254038", "0.62451524", "0.6238193", "0.6215016", "0.62053627", "0.61985564", "0.61859196", "0.61620253", "0.61389893", "0.61187315", "0.61107427", "0.61...
0.6778383
3