query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Returns the associated namespace.
def namespace(self): assert self._namespace return self._namespace
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def namespace(self):\n return self._namespace", "def namespace (self) :\n\n return self.__namespace__", "def get_namespace(self) -> str:\n return self._namespace", "def namespace(self):\n return self.__key.namespace()", "def namespace(self) -> Optional[str]:\n return pulumi.g...
[ "0.8301226", "0.82265085", "0.818686", "0.8104186", "0.801612", "0.801612", "0.801612", "0.7965273", "0.79465747", "0.79465747", "0.79465747", "0.79465747", "0.79465747", "0.7858032", "0.7766813", "0.7728095", "0.76953185", "0.7662718", "0.76589555", "0.7560276", "0.7560276",...
0.823305
1
Return an isolated command step.
def _run(self, name, cmd, step_test_data=None): return self.m.step(name, [self._client] + list(cmd), step_test_data=step_test_data, infra_step=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self):\n return self._step", "def get_step(self):\n return self.step", "def get_step(self):\n return self.step", "def getCurrentStep():", "def step(self, uuid):\n return self.__get_object(self.get(\"steps/{}\".format(uuid)))", "def get_command(self):\n return self....
[ "0.6168318", "0.61497265", "0.61497265", "0.6130134", "0.6023391", "0.59871185", "0.5979402", "0.59364986", "0.5912161", "0.581418", "0.581418", "0.57889986", "0.5718435", "0.5718435", "0.5718435", "0.5718435", "0.57063425", "0.570546", "0.56717896", "0.5647837", "0.5647209",...
0.62240005
0
This context manager ensures the go isolated client is available on $PATH.
def on_path(self): client_dir = self.m.path.dirname(self._client) with self.m.context(env_prefixes={'PATH': [client_dir]}): yield
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _client(self):\n return self.m.cipd.ensure_tool('infra/tools/luci/isolated/${platform}',\n self._version)", "def client_setup(self):\n self.client = Client()", "def _test_cli_package(self):\n self.keystone_url = self.bootstrap_inputs['keystone_url']\n ...
[ "0.6464941", "0.55805904", "0.54529524", "0.53483063", "0.52949923", "0.52789223", "0.5271369", "0.5265023", "0.5257343", "0.523397", "0.522878", "0.5222899", "0.5219656", "0.5180423", "0.5105806", "0.5090765", "0.5046014", "0.50457245", "0.5038725", "0.502869", "0.50205666",...
0.6967328
0
Returns an Isolated object that can be used to archive a set of files and directories, relative to a given root directory.
def isolated(self, root_dir): return Isolated(self.m, root_dir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def archive_root(self):\n return join(self._root, self._archive)", "def zip(root, **kwds):\n # ensure {root} is an absolute path, just in case the application changes the current\n # working directory\n root = primitives.path(root).resolve()\n # check whether the location exists\n if not ro...
[ "0.6258837", "0.61597353", "0.59445935", "0.5897992", "0.57909524", "0.5659723", "0.5550307", "0.5482791", "0.5470575", "0.5361523", "0.53320026", "0.5226069", "0.5189857", "0.5162201", "0.5153717", "0.51217246", "0.50809765", "0.50668275", "0.50631607", "0.5030572", "0.50270...
0.73860335
0
Returns the path format consumed by the isolated CLI.
def _isolated_path_format(self, path): if self._root_dir.is_parent_of(path): return '%s:%s' % ( self._root_dir, self._api.path.join(*path.pieces[len(self._root_dir.pieces):]) ) else: assert path == self._root_dir, \ "isolated path must be equal to or within %s" % se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path_format(self):\n return '{}{}'.format(\n self.config['serve_at'],\n self.sub_base_pod_path)", "def disk_file_format(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"disk_file_format\")", "def format_path (in_path):\n return os.path.realpath(os.pa...
[ "0.62535906", "0.6227505", "0.6223479", "0.6097844", "0.60713947", "0.5983591", "0.5956249", "0.59553003", "0.5924657", "0.59050536", "0.5810407", "0.5769285", "0.5710894", "0.569906", "0.569906", "0.569622", "0.567152", "0.56644523", "0.56624186", "0.56579506", "0.5619296", ...
0.6578791
0
Stages a list of files to be added to the isolated.
def add_files(self, paths): for path in paths: self.add_file(path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ingest(self, files):\n for file in files:\n self.files.add(file)", "def add_files(self, filenames):\n for filename in filenames:\n self.add_file(filename)", "def addFiles(self, filePaths): \n \n for filePath in filePaths: \n self.addFile(filePath...
[ "0.67607766", "0.6389441", "0.62125987", "0.6110949", "0.6020164", "0.6016923", "0.58645403", "0.5850484", "0.5790572", "0.57312334", "0.56890637", "0.5663774", "0.56432503", "0.555807", "0.5549957", "0.5549061", "0.5546403", "0.5528841", "0.54846084", "0.54714", "0.5461322",...
0.6500593
1
Step to archive all staged files and directories. If no isolate_server is provided, the IsolatedApis's default server will be used instead.
def archive(self, step_name, isolate_server=None): isolate_server = isolate_server or self._api.isolated.isolate_server cmd = [ 'archive', '-verbose', '-isolate-server', isolate_server, '-namespace', self._api.isolated.namespace, '-dump-hash', self._api.raw_io.output_text...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _archive(self, name, contents, isolate_content):\n # Shared code for all test_isolated_* test cases.\n root = os.path.join(self.tmpdir, name)\n # Refuse reusing the same task name twice, it makes the whole test suite\n # more manageable.\n self.assertFalse(os.path.isdir(root), root)\n os.mkdi...
[ "0.5930329", "0.5796813", "0.5763609", "0.5613954", "0.54219216", "0.517943", "0.5152365", "0.5150462", "0.5119233", "0.5085717", "0.50684077", "0.505072", "0.5043521", "0.50158405", "0.50121504", "0.4965583", "0.49599376", "0.49383888", "0.4899507", "0.48494533", "0.48445463...
0.66462725
0
Wait until the namespace is deleted
def wait_for_namespace_deletion(self, namespace_name, timeout=None, number_of_events=None): timeout = timeout or WAIT_TIMEOUT number_of_events = number_of_events or 10 watcher = Watch() for event in watcher.stream(self.client_core.list_namespace, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def unload(self) -> None:", "def test_delete_net_namespace(self):\n pass", "async def cleanup(self):\n pass", "def __del__(self):\n for req in self._outbox:\n req.Wait()", "def destroyNamespace(self, remoteNamespace):\r\n for namespace in self._namespaces:\r\n ...
[ "0.62862295", "0.6194238", "0.61335224", "0.6022985", "0.58431864", "0.5789227", "0.5789227", "0.5789227", "0.5789227", "0.57834387", "0.57751626", "0.5702497", "0.5648569", "0.56282973", "0.56054837", "0.556215", "0.5552353", "0.5503148", "0.5503148", "0.5486182", "0.5484627...
0.6882417
0
Wait to namespace creation
def wait_for_namespace_creation(self, namespace_name, timeout=None, number_of_events=None): timeout = timeout or WAIT_TIMEOUT number_of_events = number_of_events or 10 watcher = Watch() for event in watcher.stream(self.client_core.list_namespace, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_to_create(name, namespace, timeout):\n return watch.wait_created_cr(name, namespace,\n timeout=timeout, group=GROUP, plural=PLURAL,\n version=VERSION)", "def test_create_net_namespace(self):\n pass", "def wait(self):\n pa...
[ "0.6600159", "0.6185692", "0.6082369", "0.6082369", "0.60474634", "0.60139877", "0.5979952", "0.5917022", "0.5863015", "0.5863015", "0.5863015", "0.5863015", "0.5798366", "0.5784207", "0.5752264", "0.56965196", "0.56893945", "0.5646247", "0.56422293", "0.56306446", "0.5569635...
0.7068143
0
Return namespace obj or dictionary
def get(self, name, dict_output=False): namespace = self.client_core.read_namespace(name=name) logger.info(f"Got namespace {name}") # convert the obj to dict if required if dict_output: namespace = convert_obj_to_dict(namespace) else: namespace.metadata.r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_namespace(self, namespace, lowercase=True, trim_namespace=True):\n\t\treturn self.get_namespace_view(namespace, lowercase, trim_namespace).copy()", "def _get_namespace(self, data):\n ns_name = data['filename'].namespace\n try:\n return models.Namespace.objects.get(name=ns_name)\n...
[ "0.6161733", "0.60738766", "0.6067657", "0.6011654", "0.5962022", "0.59318334", "0.5853783", "0.57571125", "0.5704726", "0.5699859", "0.5664662", "0.5580817", "0.55396724", "0.55396724", "0.55396724", "0.55396724", "0.55396724", "0.5532388", "0.5505792", "0.54882395", "0.5488...
0.69154835
0
Called repeatedly to report progress. `arg` is an opaque argument, the caller can use it for whatever they want. `num_done` is a int indicating the count of progress. There is no defined range for `num_done`, it is assumed that the caller knows what work is being done, and what the number mean. `info` is a string givin...
def progress(self, arg, num_done, info=''): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_progress(self, done):\r\n if done % 100 == 0:\r\n print >>sys.stderr, \" %d processed, run time %d secs\" % (done, (datetime.now() - self.started_at).seconds)", "def print_progress(self, info_dict):\n if self.n_print != 0:\n t = info_dict['t']\n if t == 1 or t % self.n_...
[ "0.6159376", "0.5550284", "0.55239606", "0.5474332", "0.5473138", "0.5412904", "0.5396161", "0.5361802", "0.5273552", "0.5249497", "0.5244479", "0.5238669", "0.5211333", "0.5207787", "0.5196239", "0.517752", "0.5156459", "0.515257", "0.51422656", "0.5141201", "0.51345533", ...
0.80820996
0
m a numpy array of mean anomalies ecc the eccentricity of the orbit (single float value from 01)
def eccen_anomaly(m, ecc, thresh=1e-10): # set default values #if (ecc < 0. or ecc >= 1.): # print('Eccentricity must be 0<= ecc. < 1') # # Range reduction of m to -pi < m <= pi # mx = m.copy() ## ... m > pi zz = (where(mx > pi_g)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eccentricanomaly(ecc, manom=None, tanom=None, tol=1e-8):\n # 2011-04-22 14:35 IJC: Created\n\n \n\n ret = None\n if manom is not None:\n if not hasattr(manom, '__iter__'):\n mwasscalar = True\n manom = [manom]\n else:\n mwasscalar = False\n # So...
[ "0.665927", "0.6445406", "0.6429114", "0.63525724", "0.6329776", "0.63214946", "0.62894714", "0.6270412", "0.62492627", "0.6179386", "0.614965", "0.61419576", "0.61416465", "0.61279696", "0.6115407", "0.6099943", "0.60476834", "0.6020593", "0.59769976", "0.5973304", "0.597191...
0.68656766
0
Search for a video on youtube
async def youtube(self, ctx, *, query): url = f"https://www.googleapis.com/youtube/v3/search?part=snippet&q={query}&type=video&maxResults=1&key={google_api_key}" response = requests.get(url) try: await ctx.send( f"https://www.youtube.com/watch?v={response.json()['item...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def youtube(self, ctx, *args):\n if not args:\n await ctx.send(\"usage: `>youtube [search string]`\")\n return\n search_string = \" \".join(args)\n search_string = urllib.parse.urlencode({'search_query': search_string})\n response = requests.get('http://www.y...
[ "0.7901911", "0.78483903", "0.7726353", "0.76796186", "0.75152266", "0.745053", "0.7307586", "0.72384375", "0.72006804", "0.7163148", "0.7102828", "0.707449", "0.7072971", "0.7040022", "0.6963728", "0.6957675", "0.6920918", "0.6903776", "0.68742484", "0.6830216", "0.68088526"...
0.78555787
1
Read train file by chunks, split data for each core, run calculations for statistics
def fit_train(self, train_filename="data/train.tsv", chunksize=500, sep="\t",n_jobs=cpu_count): all_result_maps = [] for chunk in pd.read_csv(train_filename, chunksize=chunksize, sep=sep): chunk_split = np.array_split(chunk.values, n_jobs) pool = Pool(n_jobs) result_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_process(self):\n logging.info('Processing the data and split files')\n lines = Utility.file_len(self.fname)\n self.lines_to_be, self.split_files = Utility.split_files(self.fname, lines,\n cpu_count().real)", "def split_...
[ "0.6607906", "0.6406573", "0.63375854", "0.6251789", "0.61709857", "0.6124084", "0.6076839", "0.6068475", "0.60246277", "0.5950408", "0.5947295", "0.5938464", "0.59381825", "0.5903154", "0.59011054", "0.59000415", "0.58158547", "0.5811185", "0.5808208", "0.5808067", "0.580794...
0.662056
0
Read test file by chunks, split data for each core, run process function for each row, save rows in output file
def process_test(self, test_filename="data/test.tsv", output_folder="result", output_filename="test_proc.tsv", chunksize=500, sep="\t", n_jobs=cpu_count, process_method="standardization"): append = False #for creating file and later appending self._check_path(output_folder) #check if exists output_fold...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_process(self):\n logging.info('Processing the data and split files')\n lines = Utility.file_len(self.fname)\n self.lines_to_be, self.split_files = Utility.split_files(self.fname, lines,\n cpu_count().real)", "def split_...
[ "0.6632668", "0.6247376", "0.620011", "0.6188816", "0.6157059", "0.6094607", "0.6075842", "0.6023016", "0.59825665", "0.5945156", "0.58856434", "0.5864536", "0.5840756", "0.58405", "0.5825849", "0.5813613", "0.5795663", "0.5778641", "0.57741404", "0.5760587", "0.5743364", "...
0.7437358
0
Load saved TopicModel object
def load_topic_model(fname): with open(fname+'.tm_vect', 'rb') as f: vectorizer = pickle.load(f) with open(fname+'.tm_model', 'rb') as f: model = pickle.load(f) with open(fname+'.tm_params', 'rb') as f: params = pickle.load(f) tm = get_topic_model(n_topics=params['n_topics'], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_model(self):\n pass", "def load(path_to_model):\n pass", "def load_model(self) -> Any:", "def load_model(self, path):\n pass", "def test_load_model(base_bertopic):\n base_bertopic.save(\"test\")\n loaded_bertopic = BERTopic.load(\"test\")\n assert type(base_bertopic) ...
[ "0.69447595", "0.6890895", "0.6870776", "0.66944945", "0.6618696", "0.66106296", "0.65611994", "0.64651227", "0.63429344", "0.6337718", "0.63330495", "0.63133436", "0.62857485", "0.6260645", "0.6244856", "0.6205325", "0.6166717", "0.6156449", "0.61534286", "0.61470234", "0.61...
0.7293775
0
Define the tuning target function, e.g., to achieve higher precision score in RandomForest
def rf_tuning(n_estimators, min_samples_leaf, min_samples_split, max_leaf_nodes, max_features, max_depth, train_x, test_x, train_y, test_y): rf_tuning = RandomForestClassifier(n_estimators=n_estimators, min_samples_leaf=min_samples_leaf, min_samples_split=min_sam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tuneRandomForest(train_set):\n\n auc_score = make_scorer(roc_auc_score)\n acc = make_scorer(accuracy_score)\n\n train_set = pd.read_csv(train_set, sep=\"\\t\", low_memory=False)\n\n train_output = train_set[\"output\"].values\n train_features = train_set[train_set.columns.drop([\"labels\", \"out...
[ "0.68066823", "0.6708006", "0.65701663", "0.629161", "0.6221826", "0.60788506", "0.6072627", "0.604771", "0.6045968", "0.5995953", "0.5984529", "0.5968938", "0.5928244", "0.59180135", "0.59156346", "0.5882706", "0.5860943", "0.5849483", "0.5843874", "0.58190167", "0.57908344"...
0.6845773
0
Called when a stage is being built
def stage(self, stage: osbuild.Stage):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _stage(self):\n\n pass", "def pre_build(self):", "def stage(self):\n pass", "def pre_build_hook(self):", "def begin(self, pipeline: osbuild.Pipeline):", "def pre_build(self):\n pass", "async def on_building_construction_started(self, unit: Unit):", "def post_build_hook(self):...
[ "0.74907845", "0.7203234", "0.7191722", "0.7183883", "0.7159949", "0.71584487", "0.70312715", "0.6951613", "0.6900671", "0.6890196", "0.68117076", "0.67545205", "0.6660531", "0.654558", "0.6497399", "0.6467976", "0.6467976", "0.6465072", "0.6383561", "0.62539464", "0.6230354"...
0.7806438
0
Called when an assembler is being built
def assembler(self, assembler: osbuild.Stage):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_build(self):", "def buildStarted(builderName, build):", "def pre_build(self):\n pass", "def pre_build_hook(self):", "def build(parameters):\n\n\n print(\"In Build module\")", "def build(self):\n env = ConfigureEnvironment(self.deps_cpp_info, self.settings)\n\n set_path_com...
[ "0.643814", "0.6398292", "0.62869644", "0.6221196", "0.6200806", "0.6150591", "0.61354285", "0.6060119", "0.60254914", "0.6023925", "0.60055375", "0.5970003", "0.5940269", "0.5936709", "0.5883629", "0.57498807", "0.574776", "0.57236654", "0.57236654", "0.5641678", "0.5628825"...
0.8085987
0
Read credentials from ~/.config/mosquitto_pub.
def read_mqtt_config(): with open(join(env.get('XDG_CONFIG_HOME', join(expanduser('~'), '.config')), 'mosquitto_pub')) as f: d = dict(line.replace('-', '').split() for line in f.read().splitlines()) return dict(host=d['h'], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def credentials():\n\n username = os.environ.get('OS_USERNAME')\n password = os.environ.get('OS_PASSWORD')\n tenant_name = (os.environ.get('OS_TENANT_NAME') or\n os.environ.get('OS_PROJECT_NAME'))\n auth_url = os.environ.get('OS_AUTH_URL')\n\n config = configparser.RawConfigParser(...
[ "0.6340217", "0.6296227", "0.6204503", "0.6097042", "0.6086547", "0.6054747", "0.60135573", "0.60046065", "0.59239966", "0.58909726", "0.58854157", "0.5877398", "0.584713", "0.5802988", "0.57966644", "0.57963914", "0.5793956", "0.5772505", "0.5772505", "0.57675225", "0.575429...
0.7487623
0
Give a id for this Player.
def set_id(self, player_id): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_player_id(self, player_id):\n self.player_id = player_id", "def player_id(self, player_id):\n\n self._player_id = player_id", "def player_id(self, player_id):\n\n self._player_id = player_id", "def set_id(self, id):\n self.id = id\n print(\"self id = \" + str(self.i...
[ "0.74370134", "0.72394824", "0.72394824", "0.6987468", "0.69843906", "0.69656116", "0.69278145", "0.68677753", "0.68520963", "0.68513745", "0.6809674", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807274", "0.6807...
0.8435845
0
Worker Placement. This will be called with a copy of the board when it is this player's turn to place. The board contains a dictionary of workers mapped to their positions, and each worker knows which player it is associated with. When a player places a worker, its position is updated in this dictionary in the next pla...
def place_worker(self, cur_board): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place_worker(self, worker, pos):\n self.assert_bounds(pos)\n self._workers[worker] = pos", "def __init__(self, board=None, workers=None):\n if board:\n self._board = []\n for row in range(self.BOARD_SIZE):\n self._board.append([])\n for...
[ "0.63027805", "0.6016232", "0.5981999", "0.58976746", "0.5829737", "0.5799489", "0.57679766", "0.5713904", "0.56547904", "0.5652346", "0.56477", "0.56376296", "0.559558", "0.5550681", "0.54910564", "0.5466501", "0.5357388", "0.53165835", "0.5316234", "0.53069353", "0.5304483"...
0.67579776
0
Uses a binary search algorithm (find_contour_center) to locate the contour with flux closest to 'ref_flux'. Overrides the parent find_centers routine.
def find_centers(self,ref_flux, flux_function,field_names=('u_tot',), calc_area=True, trajectory_file=None,outlines_file=None, weighted_center=True, contour_closure=None, min_contour_points=10, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recenter(flux, center):\n y1, y2 = int(center)-3, int(center)+4\n ydata = flux[y1:y2]\n xdata = np.arange(y1,y2)\n p0 = [ydata.min(), ydata.max()-ydata.min(), ydata.argmax()+y1, 2.5]\n p1,succ = opt.leastsq(errfunc2, p0[:], args=(xdata,ydata))\n return p1[2]", "def center_reference(x: np.ar...
[ "0.6167109", "0.58532804", "0.58144784", "0.58129096", "0.57351565", "0.57167184", "0.56818557", "0.5644109", "0.5618091", "0.5570962", "0.555928", "0.5556484", "0.5536987", "0.55324554", "0.54991186", "0.5491362", "0.5451639", "0.5445005", "0.5317139", "0.5295501", "0.528908...
0.6692693
0
Test writing arbitray metadata into the tiff image directory Use case is ImageJ private tags, one numeric, one arbitrary
def test_rt_metadata(): img = lena() textdata = "This is some arbitrary metadata for a text field" info = TiffImagePlugin.ImageFileDirectory() info[tag_ids['ImageJMetaDataByteCounts']] = len(textdata) info[tag_ids['ImageJMetaData']] = textdata f = tempfile("temp.tif") img.save(f, ti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_rt_metadata(self):\n\n img = hopper()\n\n # Behaviour change: re #1416\n # Pre ifd rewrite, ImageJMetaData was being written as a string(2),\n # Post ifd rewrite, it's defined as arbitrary bytes(7). It should\n # roundtrip with the actual bytes, rather than stripped text...
[ "0.731719", "0.6607689", "0.64368963", "0.6222618", "0.6127548", "0.5911637", "0.58965516", "0.58761317", "0.58613825", "0.5830516", "0.57202834", "0.57158023", "0.5677788", "0.5651575", "0.5631641", "0.55870885", "0.5575606", "0.55613315", "0.5553178", "0.5520936", "0.551427...
0.74291915
0
Check if self.blocks contains valid gcode
def check(self): # full program r = re.compile('(?!(^(((?!;)[A-Z][+-]?\d+(\.\d+)?\s?)*(\s*;\s.*)?)$))') for line in self.blocks: if r.match(line) and line and line != '\r' and line != '\n': return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isValid(self) :\n try :\n pos = 0\n while self.firstblock[pos] == chr(0) :\n pos += 1\n except IndexError : \n return False\n else : \n firstblock = self.firstblock[pos:]\n if firstblock.startswith(\"\\033E\\03...
[ "0.7012864", "0.6698109", "0.6426528", "0.64249265", "0.6310562", "0.61605674", "0.61298716", "0.6124994", "0.61003184", "0.60510874", "0.60130966", "0.6006122", "0.5977139", "0.5911065", "0.5901872", "0.5898445", "0.5861289", "0.58446175", "0.5838854", "0.58188945", "0.57694...
0.67364305
1
Delete all comments from text
def del_comm(self, blocks=False): logging.debug('Delete comments from text') if not(self.check()): raise GcodeError("Invalid g-codes") temp = [] comment = re.compile(';\ .*') for line in self.blocks: n = comment.search(line) if n: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DropComment(text):\n grp = re.compile(r'/\\*[^/]*\\*/').split(text)\n result = string.join(grp);\n grp = re.compile(r'//.*').split(result);\n result = string.join(grp);\n #result = string.join(result.split('\\n')) #remove the line break\n return(' '+result);", "def comment_remover(text):\n\...
[ "0.747929", "0.7322149", "0.7155819", "0.7041084", "0.6727462", "0.67104644", "0.65827173", "0.6577723", "0.652806", "0.6325452", "0.6226701", "0.6181498", "0.61190176", "0.609235", "0.60881513", "0.60600317", "0.60562253", "0.59839445", "0.5958102", "0.5958102", "0.5927883",...
0.7487489
0
Method to turn ship right by Ship.TURN degrees
def turn_right(self): turn = self.__heading - Ship.TURN if turn < Ship.MIN_HEADING: turn += Ship.MAX_HEADING self.__heading = turn
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_ship_right(self):\n self.degrees -= movement", "def turn_right(self):\n temp = self.direction[0]\n self.direction[0] = -self.direction[1]\n self.direction[1] = temp", "def turn_ship_left(self):\n self.degrees += movement", "def turn_right(self):\n self.facin...
[ "0.8436725", "0.73522484", "0.71720445", "0.71529585", "0.71389383", "0.7047949", "0.69325846", "0.68661433", "0.68342847", "0.6657572", "0.66527474", "0.6648351", "0.66412", "0.66124254", "0.6579643", "0.6469108", "0.6406132", "0.640586", "0.6394655", "0.6328568", "0.6320902...
0.7680086
1
Method to turn ship left by Ship.TURN degrees
def turn_left(self): turn = self.__heading + Ship.TURN if turn >= Ship.MAX_HEADING: turn -= Ship.MAX_HEADING self.__heading = turn
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_ship_left(self):\n self.degrees += movement", "def turn_left(self):\n\t\tself.direction = (self.direction - 1)%4", "def turn_left(self):\n temp = self.direction[0]\n self.direction[0] = self.direction[1]\n self.direction[1] = -temp", "def turn_ship_right(self):\n s...
[ "0.86232084", "0.7546365", "0.75377375", "0.7507496", "0.7276685", "0.7247818", "0.7132797", "0.7096866", "0.7019987", "0.70000345", "0.6957412", "0.67816466", "0.67313766", "0.66781867", "0.6656814", "0.6622794", "0.65872854", "0.6566861", "0.65618527", "0.65618527", "0.6512...
0.7933516
1
Method to accelerate the ship
def accelerate(self): x_speed = self.__calc_speed(Ship._X) y_speed = self.__calc_speed(Ship._Y) self._speed_vect = (x_speed, y_speed)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accelerate(self):\n\t\tself.velocity += self.direction * self.ACCELERATION", "def _ship_acceleration(player, ship_name, way, game_data):\n\n # Get the current speed and position\n position = game_data['ships'][player][ship_name]\n speed = game_data['board'][position][player][ship_name]['speed']\n ...
[ "0.7123249", "0.6890222", "0.67654395", "0.66809374", "0.6653349", "0.6563948", "0.6562654", "0.6535885", "0.6401255", "0.63440686", "0.6228308", "0.6185042", "0.61571777", "0.613889", "0.60902125", "0.60860234", "0.60823995", "0.6016455", "0.6006803", "0.5981901", "0.5966785...
0.78907406
0
Method to fire a torpedo
def fire_torpedo(self): return Torpedo(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fire(self):", "def fire(self):\n pass", "def firing(self) -> None:\n self.shooter.fire()\n # self.next_state(\"tracking\")\n self.state = self.tracking", "def onFireCommand(self, *args):\n self.post(events.AttackRequest(self._entity_id))", "def Fire(self, *args):\n ...
[ "0.7026466", "0.6985827", "0.6160507", "0.6084971", "0.6057547", "0.5960621", "0.58774024", "0.58442867", "0.57457834", "0.5693623", "0.56508946", "0.56043684", "0.55783373", "0.5578002", "0.55775243", "0.556469", "0.555759", "0.55396205", "0.55359447", "0.5501531", "0.549943...
0.73905456
0
Method to get a tuple representing all necessary data for a draw.
def get_draw_data(self): x, y = self._coordinates return x, y, self.__heading
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve_data_tuple(self):\n return ((42,))", "def get_info_in_tuple(self):\r\n return self.key, self.value, self.get_color(), self.size_tree", "def provide_data(self):\r\n # import pdb; pdb.set_trace()\r\n # for k, v in self.data:\r\n # print k,v\r\n return [(...
[ "0.67769736", "0.652479", "0.64892304", "0.6417278", "0.6417278", "0.6309785", "0.6031905", "0.6030113", "0.6000795", "0.5971416", "0.59278166", "0.59245974", "0.59244204", "0.5918011", "0.59173", "0.58823514", "0.58533686", "0.58120334", "0.57628167", "0.56997234", "0.569378...
0.7267898
0
Method to get the current ship heading
def get_heading(self): return self.__heading
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_heading(self):\n return self.heading[0]", "def heading(self) -> float:\n return self._state[2]", "def getPosHeading(self) :\n\t\treturn (self.avatarNP.getX(), self.avatarNP.getY(), \\\n\t\t\tself.avatarNP.getZ(), (self.avatarNP.getHpr()[0])%360)", "def heading(self):\n return flo...
[ "0.7326886", "0.6786411", "0.6748737", "0.6676657", "0.6671916", "0.6618297", "0.644787", "0.64413476", "0.6398698", "0.63561726", "0.62648475", "0.61915606", "0.6046004", "0.5948993", "0.5930137", "0.5906802", "0.588873", "0.58622503", "0.5861941", "0.5857708", "0.58480597",...
0.70842975
1
Private function to calculate and return the new speed of the ship after after accelerating.
def __calc_speed(self, axis): old_speed = self._speed_vect[axis] radian = math.radians(self.__heading) if axis == Ship._X: heading_factor = math.cos(radian) else: # axis == Ship.Y heading_factor = math.sin(radian) return old_speed + heading_f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accelerate(self):\n x_speed = self.__calc_speed(Ship._X)\n y_speed = self.__calc_speed(Ship._Y)\n self._speed_vect = (x_speed, y_speed)", "def calculate_speed(self, old):\n self.speed[0] = self.center[0] - old.center[0]\n self.speed[1] = self.center[1] - old.center[1]", "...
[ "0.7494613", "0.7129068", "0.7085912", "0.683693", "0.67696875", "0.67696875", "0.6686311", "0.6680164", "0.662618", "0.6595132", "0.6588159", "0.6586106", "0.65781283", "0.6577624", "0.65364206", "0.64930075", "0.64930075", "0.6480005", "0.64632934", "0.64079183", "0.6401731...
0.72639495
1
Returns a list of the unique tags present in label_matches.
def get_tag_options(label_matches): tag_options = [] for key in label_matches.keys(): if key[1] not in tag_options: tag_options.append(key[1]) return tag_options
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_known_words(label_matches):\r\n\tknown_words = set()\r\n\tfor key in label_matches.keys():\r\n\t\tif key[0] not in known_words:\r\n\t\t\tknown_words.add(key[0])\r\n\treturn known_words", "def get_labels(self):\n return set(k.label for k in self)", "def get_tag_counts(label_matches):\r\n\ttag_cou...
[ "0.6625351", "0.6470974", "0.6346422", "0.630371", "0.61135185", "0.6109803", "0.6073266", "0.60634893", "0.6018564", "0.6017819", "0.60162514", "0.60025984", "0.5998588", "0.58771294", "0.5826338", "0.5826256", "0.5822295", "0.5822173", "0.58106333", "0.57846075", "0.5777449...
0.7273571
0
Returns a list of the unique words present in label_matches.
def get_known_words(label_matches): known_words = set() for key in label_matches.keys(): if key[0] not in known_words: known_words.add(key[0]) return known_words
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def known(words: list[str]) -> list[str]:\n return [z for z in list(set(words)) if z in self.words]", "def get_unique_words():\n # Unique words\n words_set = set()\n for i in range(1, 114+1):\n sura = quran.get_sura(i)\n for aya in sura:\n wordsList = aya.split(' ')\...
[ "0.64026016", "0.6349737", "0.63116974", "0.628503", "0.6211167", "0.61971766", "0.61800045", "0.60963327", "0.6086975", "0.60145116", "0.5976359", "0.59693927", "0.59693706", "0.5951315", "0.59495366", "0.5945353", "0.5930459", "0.5918251", "0.5916345", "0.59144545", "0.5855...
0.8203771
0
Reads the file with the given file_path. Creates dictionary containing the transition unigram counts
def generate_transition_counts(file_path): transition_unigram_counts = dict() transition_bigram_counts = dict() transition_bigram_counts_two_start_tokens = dict() transition_trigram_counts = dict() with open(file_path) as f: line_count = 0 for line in f: line_count+=1 if line_count%3 != 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_transition_trigram_counts(file_path):\r\n\ttransition_trigram_counts = dict()\r\n\twith open(file_path) as f:\r\n\t\tline_count = 0\r\n\t\tfor line in f:\r\n\t\t\tline_count+=1\r\n\t\t\tif line_count%3 != 0:\r\n\t\t\t\tcontinue\r\n\t\t\ttag_set = [\"<START>\"] + [\"<START>\"] + line.lower().split()\r\...
[ "0.76684386", "0.76119274", "0.69861144", "0.6745581", "0.67360884", "0.67299443", "0.6703781", "0.6630748", "0.6471724", "0.6386249", "0.6383424", "0.6283747", "0.62113553", "0.62034535", "0.61963993", "0.6176253", "0.6152365", "0.61492646", "0.61308765", "0.61255187", "0.61...
0.81698674
0
Reads the file with the given file_path. Creates dictionary containing the transition bigram counts
def generate_transition_bigram_counts(file_path): transition_bigram_counts = dict() with open(file_path) as f: line_count = 0 for line in f: line_count+=1 if line_count%3 != 0: continue tag_set = ["<START>"] + line.lower().split() i = 1 while(i<len(tag_set)): tag_tuple = (tag_set...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_transition_counts(file_path):\r\n\ttransition_unigram_counts = dict()\r\n\ttransition_bigram_counts = dict()\r\n\ttransition_bigram_counts_two_start_tokens = dict()\r\n\ttransition_trigram_counts = dict()\r\n\r\n\twith open(file_path) as f:\r\n\t\tline_count = 0\r\n\t\tfor line in f:\r\n\t\t\tline_cou...
[ "0.77718", "0.73665285", "0.727848", "0.6965463", "0.6698259", "0.6696651", "0.6448026", "0.6277117", "0.6237499", "0.61924875", "0.61556566", "0.61360013", "0.6091194", "0.6062285", "0.60072225", "0.5986118", "0.59836245", "0.5983197", "0.59720534", "0.5952777", "0.593601", ...
0.8298964
0
Reads the file with the given file_path. Creates dictionary containing the transition trigram counts
def generate_transition_trigram_counts(file_path): transition_trigram_counts = dict() with open(file_path) as f: line_count = 0 for line in f: line_count+=1 if line_count%3 != 0: continue tag_set = ["<START>"] + ["<START>"] + line.lower().split() i = 2 while(i<len(tag_set)): tag_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_transition_counts(file_path):\r\n\ttransition_unigram_counts = dict()\r\n\ttransition_bigram_counts = dict()\r\n\ttransition_bigram_counts_two_start_tokens = dict()\r\n\ttransition_trigram_counts = dict()\r\n\r\n\twith open(file_path) as f:\r\n\t\tline_count = 0\r\n\t\tfor line in f:\r\n\t\t\tline_cou...
[ "0.80836344", "0.74761456", "0.7057639", "0.6884323", "0.67624533", "0.6482301", "0.64668167", "0.64232504", "0.6300666", "0.62923586", "0.620068", "0.61971086", "0.6108668", "0.6103164", "0.60838234", "0.60781157", "0.6045412", "0.598321", "0.59739476", "0.5961463", "0.59252...
0.80102456
1
Takes in the bigram and trigram count matrices. Creates dictionary containing the transition trigram
def generate_transition_trigram_probabilities(transition_bigram_counts, transition_trigram_counts): transition_trigram_probabilities = dict() for tag_trigram in transition_trigram_counts: transition_trigram_probabilities[tag_trigram] = float(transition_trigram_counts[tag_trigram])/transition_bigram_counts[(tag_t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trigram_model(list_of_words, bigram_count, trigram_count):\n c_start = list_of_words.count(start_phrase)\n c_end = list_of_words.count(end_phrase)\n if c_start == 0:\n list_of_words.insert(0, start_phrase)\n list_of_words.insert(0, start_phrase)\n if c_start == 1:\n list_of_wor...
[ "0.71833175", "0.6813381", "0.66167456", "0.6477611", "0.63177574", "0.6289271", "0.62849665", "0.62597877", "0.6214876", "0.6181606", "0.6166743", "0.610528", "0.59698135", "0.5955361", "0.5951989", "0.5938834", "0.59333706", "0.5900553", "0.58923835", "0.58705944", "0.58686...
0.6922297
1
Returns a dictionary with the counts of all the tags in label_matches
def get_tag_counts(label_matches): tag_counts = {} for word_and_tag in label_matches.keys(): current_count = tag_counts.get(word_and_tag[_TAG], 0) tag_counts[word_and_tag[_TAG]] = current_count+1 return tag_counts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getClassCounts(b):\n c = {k:0 for k in labels.keys()}\n for r in b:\n c[r[0]] += 1\n return c", "def count_label_frequency(self):\n label_frequency = {}\n for label in set(self.labels):\n label_frequency[label] = self.labels.count(label)\n return label_frequenc...
[ "0.68163496", "0.6815171", "0.6771721", "0.67234075", "0.6647901", "0.6618084", "0.65923005", "0.65323097", "0.6528963", "0.6487152", "0.64834577", "0.632755", "0.62347037", "0.61757433", "0.60921115", "0.6062502", "0.6043209", "0.60065335", "0.6001471", "0.60004634", "0.5981...
0.8928364
0
Calculates the emissions probability of associating a given
def get_emissions_probability(label_matches, given_tag, given_word, tag_counts): lookup_tuple = (given_word, given_tag) word_tag_frequency = label_matches.get(lookup_tuple, 0) tag_frequency = tag_counts[given_tag] if tag_frequency == 0: emissions_probability = 0 else: emissions_probability = float(word_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_probability(k: int, m: int, n: int) -> float:\n population = [\"AA\" for _ in range(k)] + [\"Aa\" for _ in range(m)] + [\"aa\" for _ in range(n)]\n pairings = it.combinations(population, 2)\n probabilities = [PROBABILITIES[pairing] for pairing in pairings]\n output = sum(probabilities) / ...
[ "0.67085516", "0.6678255", "0.6655425", "0.65890175", "0.65150297", "0.6475731", "0.6463045", "0.64526755", "0.64317846", "0.63033015", "0.6302224", "0.629942", "0.6276994", "0.62702", "0.6263263", "0.62584615", "0.6215324", "0.6213207", "0.6186947", "0.6179532", "0.61672133"...
0.66901255
1
Smoothes the given label_matches dictionary using the KneserNey method. 0.75 for frequency>=2 times. 0.5 for once.
def kneser_ney_smoothing(transition_probabilities): for tag_tuple in transition_probabilities.keys(): count = transition_probabilities[tag_tuple] if count <2: transition_probabilities[tag_tuple] = count - 0.5 else: transition_probabilities[tag_tuple] = count - 0.75 return transition_probabilities
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regressor_nsimilar(clf,df_features_seen,df_features_unseen,n_similar = 5,\r\n features = [\"edge_length_diff\", \"origin_connections_diff\", \r\n \"target_connections_diff\", \"total_connections_diff\", \r\n \"max_angle_dif...
[ "0.54763556", "0.54344356", "0.538757", "0.5350314", "0.5347675", "0.5321295", "0.5317157", "0.5308842", "0.52925783", "0.52911806", "0.5286041", "0.5279192", "0.5214389", "0.5183816", "0.51771045", "0.51401776", "0.5136764", "0.50965965", "0.50926226", "0.5073001", "0.506539...
0.57358396
0
Implements the viterbi algorithm based on bigram probabilities. Cycles through the possible tags, calculates the emissions probability of the tag with the given word and the transition probability between the tag and the previous tag. The ultimate probability is the product of the two. Returns the tag with the highest ...
def viterbi_bigrams(transition_probabilities, label_matches, prev_tag, word, tag_possibilities): max_prob = 0 best_tag = "" tag_counts = get_tag_counts(label_matches) for tag in tag_possibilities: emissions_probability = get_emissions_probability(label_matches, tag, word, tag_counts) tag_bigram = (prev_ta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def viterbi_trigrams(transition_probabilities, label_matches, prev_tag, prev_prev_tag, word, tag_possibilities):\r\n\tmax_prob = 0\r\n\tbest_tag = \"\"\r\n\ttag_counts = get_tag_counts(label_matches)\r\n\tfor tag in tag_possibilities:\r\n\t\temissions_probability = get_emissions_probability(label_matches, tag, wor...
[ "0.78398895", "0.7575846", "0.7092957", "0.7056177", "0.6792222", "0.67743134", "0.6705217", "0.6657058", "0.6625327", "0.6525003", "0.6502904", "0.6495616", "0.64206594", "0.63801074", "0.620898", "0.6154972", "0.6119174", "0.6018136", "0.6000017", "0.5998327", "0.59878457",...
0.8281742
0
Implements the viterbi algorithm based on trigram probabilities. Cycles through the possible tags, calculated the emiisions probability of the tag with the given word and the transition probability between the tag and the previous tag. The ultimate probability is the product of the two. Returns the tag with the highest...
def viterbi_trigrams(transition_probabilities, label_matches, prev_tag, prev_prev_tag, word, tag_possibilities): max_prob = 0 best_tag = "" tag_counts = get_tag_counts(label_matches) for tag in tag_possibilities: emissions_probability = get_emissions_probability(label_matches, tag, word, tag_counts) tag_t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def viterbi_bigrams(transition_probabilities, label_matches, prev_tag, word, tag_possibilities):\r\n\tmax_prob = 0\r\n\tbest_tag = \"\"\r\n\ttag_counts = get_tag_counts(label_matches)\r\n\tfor tag in tag_possibilities:\r\n\t\temissions_probability = get_emissions_probability(label_matches, tag, word, tag_counts)\r...
[ "0.7979451", "0.7680766", "0.7000966", "0.6946457", "0.68778133", "0.65478873", "0.65473735", "0.6517358", "0.64992255", "0.64647686", "0.6461738", "0.64148885", "0.6215549", "0.61520606", "0.61137164", "0.6099309", "0.6059834", "0.604622", "0.6020217", "0.6002478", "0.600084...
0.81082374
0
Goes through a sentence word by word, using the viterbi algorithm (with bigrams) to determine the correct tag. If a word is not in the test set it is marked . Returns a dictionary that has labels (besides 'o') and the corresponding indices of the words that belong to them.
def process_sentence_bigrams(sentence, base_index, label_matches, label_index_dict, transition_probabilities): "New line!" sentence_process_index = 0 label = '' prev_tag = "<START>" known_words = get_known_words(label_matches) tag_options = get_tag_options(label_matches) prev_is_valid = False curr_is_va...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Viterbi(self, sent):\n viterbi = defaultdict(dict)\n backpointer = defaultdict(dict)\n sent_tag = []\n pos_list = [end_token]\n viterbi['0'] = 1.0\n\n # Initialization step\n # This loop will run for all the tags of each first word (sent[1][0])(word next to <S>)...
[ "0.66180146", "0.65979624", "0.6517469", "0.64747304", "0.6308425", "0.6218716", "0.6210991", "0.61804456", "0.6169213", "0.61689466", "0.61420095", "0.60751987", "0.60655195", "0.60367507", "0.5941508", "0.59251827", "0.59222484", "0.5892546", "0.5886804", "0.5859522", "0.58...
0.6861965
0
Goes through a sentence word by word, using the viterbi algorithm (with trigrams) to determine the correct tag. If a word is not in the test set it is marked . Returns a dictionary that has labels (besides 'o') and the corresponding indices of the words that belong to them.
def process_sentence_trigrams(sentence, base_index, label_matches, label_index_dict, transition_probabilities): sentence_process_index = 0 label = '' prev_tag = "<START>" prev_prev_tag = "<START>" known_words = get_known_words(label_matches) tag_options = get_tag_options(label_matches) prev_is_valid = Fal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_sentence_bigrams(sentence, base_index, label_matches, label_index_dict, transition_probabilities):\r\n\t\"New line!\"\r\n\tsentence_process_index = 0\r\n\tlabel = ''\r\n\tprev_tag = \"<START>\"\r\n\tknown_words = get_known_words(label_matches)\r\n\ttag_options = get_tag_options(label_matches)\r\n\tprev...
[ "0.65369964", "0.6518635", "0.62548566", "0.6231402", "0.61907464", "0.6117018", "0.61095", "0.6092801", "0.6067307", "0.6062292", "0.60450864", "0.6044512", "0.6023481", "0.5968852", "0.5941505", "0.5904639", "0.5874908", "0.5864064", "0.5852413", "0.58313733", "0.5829522", ...
0.6808528
0
Adds the given indices to the label_index_dict, where the label is the key.
def add_to_label_index_dict(label, starting_index, ending_index, label_index_dict): label = label.upper() if label in label_index_dict.keys(): label_index_dict[label] = label_index_dict[label] + ' ' + str(starting_index) + '-' + str(ending_index) else: label_index_dict[label] = str(starting_index) + '-' + s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_labels_dict(self, label_names):\n\n for i in range(len(label_names)):\n self.labels_index[label_names[i]] = i", "def get_label_map(labels):\n label_map = dict()\n for i,v in enumerate(np.ravel(labels.data)):\n if v in label_map.keys():\n label_map.get(v).appen...
[ "0.72286975", "0.6400756", "0.6300745", "0.5888792", "0.57911897", "0.5631435", "0.56288207", "0.5621887", "0.5532212", "0.5525654", "0.5492529", "0.5472471", "0.5468045", "0.54592884", "0.5440561", "0.54233086", "0.54079926", "0.539964", "0.5398608", "0.5374181", "0.5327287"...
0.7351961
0
Exports the dictionary that contains labels and corresponding indices of words to a csv file.
def export_label_index_dict(label_index_dict): csv_file = open('output.csv', 'w') writer = csv.writer(csv_file) row = '' header = 'Type,Prediction\n' csv_file.write(header) for key in label_index_dict.keys(): row = key + ',' + label_index_dict[key] + '\n' csv_file.write(row)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_csv_label(labels, csv_file):\n with open(csv_file, 'w') as f:\n writer = csv.writer(f)\n for key, value in labels.items():\n writer.writerow([key, value])", "def writeFeatures(features, labels, output_filename):\n\twith open(output_filename, 'w') as csvfile:\n\t fieldname...
[ "0.69237185", "0.6917255", "0.6597108", "0.64524686", "0.6431126", "0.6369213", "0.6276799", "0.6133733", "0.6117025", "0.6115065", "0.60727835", "0.5991292", "0.59355754", "0.5916147", "0.5897449", "0.58910143", "0.5890916", "0.587915", "0.58785033", "0.5864244", "0.58566916...
0.80066663
0
Unpack bytes into a TuyaHeader.
def parse_header(data): header_len = struct.calcsize(MESSAGE_HEADER_FMT) if len(data) < header_len: raise DecodeError("Not enough data to unpack header") prefix, seqno, cmd, payload_len = struct.unpack( MESSAGE_HEADER_FMT, data[:header_len] ) if prefix != PREFIX_VALUE: # s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _unpack(self, headerBytes):\n pass", "def _unpack(self, headerBytes):\n cqcH = struct.unpack(self.PACKAGING_FORMAT, headerBytes)\n self.version = cqcH[0]\n self.tp = cqcH[1]\n self.app_id = cqcH[2]\n self.length = cqcH[3]", "def _unpack(self, headerBytes):\n ...
[ "0.7509994", "0.66005826", "0.6573002", "0.65299237", "0.639016", "0.6377969", "0.63483346", "0.6279804", "0.62367994", "0.62331414", "0.6203726", "0.61142117", "0.6110036", "0.60908437", "0.5914104", "0.58459884", "0.57917315", "0.5790603", "0.5717158", "0.5714141", "0.57063...
0.670831
1
Initialize a new AESCipher.
def __init__(self, key): self.block_size = 16 self.cipher = Cipher(algorithms.AES(key), modes.ECB(), default_backend())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.key = b'FSMF73R873YM187R'\n self.signer = AES.new(self.key, AES.MODE_EAX)\n self.verifier = AES.new(self.key, AES.MODE_EAX, nonce=self.signer.nonce)", "def new(key,mode=MODE_ECB,IV=None,counter=None,segment_size=None):\n return AES(key,mode,IV,counter,segment_si...
[ "0.7342245", "0.7117497", "0.7018199", "0.6859594", "0.67889833", "0.66308665", "0.6579635", "0.6513494", "0.65096825", "0.6489995", "0.64592123", "0.64198273", "0.64188313", "0.6392943", "0.6379902", "0.6376344", "0.6232911", "0.62084687", "0.61672944", "0.60397255", "0.6020...
0.74823785
0
Wait for response to a sequence number to be received and return it.
async def wait_for(self, seqno, cmd, timeout=5): if seqno in self.listeners: raise Exception(f"listener exists for {seqno}") self.debug("Command %d waiting for seq. number %d", cmd, seqno) self.listeners[seqno] = asyncio.Semaphore(0) try: await asyncio.wait_for(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_till_read_out():\n\n\trespond = send_command('waitreadout')", "def _get_response(self):\n if self.sync:\n self.newline_available.wait()\n response = self.newline\n self.newline_available.clear()\n response_match = self.respose_regex....
[ "0.603021", "0.59996504", "0.5989943", "0.5966225", "0.5965407", "0.59105134", "0.5868674", "0.5865372", "0.5796939", "0.5753582", "0.5733329", "0.5732373", "0.5725445", "0.5718986", "0.57173795", "0.57005185", "0.5684445", "0.5678074", "0.56746876", "0.56625193", "0.5634541"...
0.6196859
0
Add new data to the buffer and try to parse messages.
def add_data(self, data): self.buffer += data header_len = struct.calcsize(MESSAGE_RECV_HEADER_FMT) while self.buffer: # Check if enough data for measage header if len(self.buffer) < header_len: break header = parse_header(self.buffer) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_to_buffer(self, data):\n for byte in data:\n self.next_fn(byte) \n self._parse_cmds()", "def on_data_received(self, data):\n # pylint: disable=too-many-branches,too-many-statements\n\n if self.is_receiving_data is True:\n self._buffer += data\n ...
[ "0.7580829", "0.7279915", "0.7009498", "0.69777685", "0.6917022", "0.68963844", "0.6780056", "0.6685657", "0.6664628", "0.6623899", "0.66231585", "0.6581655", "0.6542151", "0.65416604", "0.6517732", "0.6473368", "0.64608604", "0.644074", "0.6429221", "0.6396759", "0.63674045"...
0.7694306
0
Render my receipt page.
def my_receipt(): title = 'Мои покупки' form = PurchaseForm() form_category = AddCategoryForm() category_choices = Category.query.all() form_category.category.choices = [ (category.id, category.category) for category in category_choices ] my_purchase = Purchase.query.filter( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_receipt(request, ordernum):\r\n try:\r\n order = Order.objects.get(id=ordernum)\r\n except Order.DoesNotExist:\r\n raise Http404('Order not found!')\r\n\r\n if order.user != request.user or order.status != 'purchased':\r\n raise Http404('Order not found!')\r\n\r\n order_it...
[ "0.6870936", "0.65709907", "0.6414998", "0.6264908", "0.62298715", "0.62156445", "0.6199932", "0.6155702", "0.61208695", "0.60477495", "0.60477495", "0.60477495", "0.6015922", "0.6008993", "0.600077", "0.59992266", "0.59954256", "0.5993284", "0.5987939", "0.59447235", "0.5944...
0.6802801
1
Render detailed receipt page.
def my_detailed_receipt(purchase): title = 'Мой чек' form = AddSubcategoryForm() subcategory_choices = Subcategory.query.all() form.subcategory.choices = [ (subcategory.id, subcategory.subcategory) for subcategory in subcategory_choices ] my_det_receipt = Receipt.query.filter( Re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_receipt(request, ordernum):\r\n try:\r\n order = Order.objects.get(id=ordernum)\r\n except Order.DoesNotExist:\r\n raise Http404('Order not found!')\r\n\r\n if order.user != request.user or order.status != 'purchased':\r\n raise Http404('Order not found!')\r\n\r\n order_it...
[ "0.68972766", "0.64607847", "0.64592475", "0.638989", "0.6233143", "0.6117534", "0.6063707", "0.6052415", "0.5986999", "0.59201425", "0.5820012", "0.5777705", "0.5775921", "0.57727534", "0.57567734", "0.5701739", "0.56989634", "0.5692379", "0.5673297", "0.5664232", "0.5662232...
0.6743314
1
Render template with QR scanner.
def qrscaner(): title = 'Сканер' return render_template( 'receipt/qrscaner.html', page_title=title, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def qrcode():\n return render_template('sampleCoupon.html')", "def render(self, template: str, **vars) -> str:", "def _render(self) -> str:\n html = self._template.render(self._transient_context)\n self._transient_context = None\n return html", "def ocr():\n return render_template(...
[ "0.72753304", "0.63011295", "0.6175603", "0.6153713", "0.614025", "0.61249405", "0.60755914", "0.60755914", "0.60755914", "0.60755914", "0.60755914", "0.60755914", "0.60680467", "0.6028753", "0.59960765", "0.5974158", "0.5933719", "0.5915871", "0.5887521", "0.5885855", "0.588...
0.7640817
0
Add a category to the purchase and write to a database.
def commit_category_to_purchase(): form_category = AddCategoryForm() if form_category.validate_on_submit(): purchase = Purchase.query.get(form_category.purchase_id.data) category = Category.query.get(form_category.category.data) change_category = PurchaseCategory.query.filter(PurchaseCat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_categorization(item_uuid, category_name, category_type):\n try:\n record_to_insert = (item_uuid, category_name, category_type)\n cursor = db.get_cursor()\n cursor.execute('INSERT INTO categorization VALUES (%s, %s, %s);', record_to_insert)\n db.get_db().commit()\n\n re...
[ "0.7143255", "0.7124733", "0.6989467", "0.69371825", "0.69208163", "0.69051385", "0.68921965", "0.6841887", "0.68062943", "0.67592484", "0.6744", "0.66638225", "0.6647763", "0.6585535", "0.6553912", "0.6538997", "0.6419046", "0.64073443", "0.638802", "0.6372696", "0.6361807",...
0.7283347
0
Add a subcategory to the receipt and write to a database.
def commit_subcategory_to_receipt(): form_subcategory = AddSubcategoryForm() if form_subcategory.validate_on_submit(): receipt = Receipt.query.get(form_subcategory.receipt_id.data) subcategory = Subcategory.query.get(form_subcategory.subcategory.data) change_subcategory = ReceiptSubcateg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subcategory(self, subcategory):\n\n self._subcategory = subcategory", "def subcategories(data):\n if data:\n for i in data:\n cat_obj = CategoriesModel.objects.get(id=i['catid'])\n sub_category = SubCategories(cat_id=cat_obj, sub_categories=i['subcategory'])\n ...
[ "0.6831374", "0.6306485", "0.6211606", "0.6173412", "0.60600036", "0.5989454", "0.5928676", "0.58737725", "0.5845874", "0.58417475", "0.5837922", "0.57441574", "0.563114", "0.56192935", "0.55983526", "0.5585727", "0.5543316", "0.5517744", "0.55170095", "0.5509467", "0.5485956...
0.7262088
0
Returns `True` iff the lexer operates in strict mode.
def strictMode(self): return self._strictMode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strictMode(self, strictMode):\n self._strictMode = strictMode", "def isSetStrict(self):\n return _libsbml.FbcModelPlugin_isSetStrict(self)", "def test_is_strict(self):\n assert self.RNA(\"\").is_strict()\n assert self.PROT(\"A\").is_strict()\n assert self.RNA(\"UAGCACUgca...
[ "0.6363372", "0.6327493", "0.6191673", "0.599479", "0.5782966", "0.57747173", "0.5458269", "0.53475696", "0.5347434", "0.5346497", "0.5338783", "0.53371626", "0.53371626", "0.53194696", "0.52970725", "0.52132356", "0.5209595", "0.51437414", "0.5140049", "0.5120177", "0.511703...
0.70139605
0
Sets whether the lexer operates in strict mode or not.
def strictMode(self, strictMode): self._strictMode = strictMode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strictMode(self):\n return self._strictMode", "def setStrict(self, *args):\n return _libsbml.FbcModelPlugin_setStrict(self, *args)", "async def strictcmd(self, message):\n self._db.set(__name__, 'strict', True)\n await utils.answer(message, self.strings[\"strict_on\"])", "def ...
[ "0.63424605", "0.633808", "0.5930209", "0.577641", "0.56784534", "0.561826", "0.5483293", "0.5369114", "0.53288263", "0.5297454", "0.5213123", "0.5194622", "0.5130337", "0.5117905", "0.51133573", "0.508551", "0.5058619", "0.5043523", "0.50165874", "0.49829915", "0.49545503", ...
0.7395983
0
Return the next token from the character stream and records this last token in case it resides on the default channel. This recorded token is used to determine when the lexer could possible match a regex literal.
def nextToken(self): # Get the next token. next = super(ECMAScriptLexer, self).nextToken() if next.channel == Token.DEFAULT_CHANNEL: # Keep track of the last token on the default channel. self._lastToken = next return next
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_token(self):\n p = self.re_token.search(self.remain)\n if not p:\n return None\n # move forward.\n s = p.start()\n self.buffer.append(self.remain[:s].encode(string_escape))\n self.cur += s + len(p.group())\n\n return p", "def get_next_token(sel...
[ "0.7192419", "0.702564", "0.6976392", "0.67677176", "0.6682286", "0.6677674", "0.65965503", "0.65141934", "0.6385944", "0.63393706", "0.624432", "0.6211106", "0.61588615", "0.61353314", "0.6130076", "0.6073466", "0.6070033", "0.6033976", "0.6007451", "0.5994449", "0.5970619",...
0.7654318
0
Returns `True` iff the lexer can match a regex literal.
def isRegexPossible(self): if self._lastToken is None: # No token has been produced yet: at the start of the input, # no division is possible, so a regex literal _is_ possible. return True if self._lastToken.type == ECMAScriptLexer.Identifier or \ sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_valid_regex(regex_pattern: str, text: str) -> bool:\n match = re.match(regex_pattern, text)\n return match is not None", "def isliteral(token):\n\n # Literals are wrapped in quotes, parens, wildcards or numeric.\n return token and (token.startswith((\"'\", '\"', \",\", \"(\", \")\", \...
[ "0.67646426", "0.6748692", "0.6446042", "0.63183534", "0.62313235", "0.6186271", "0.61720145", "0.61444443", "0.6125995", "0.60644007", "0.6012191", "0.5945762", "0.59185165", "0.58855075", "0.57637095", "0.57133186", "0.56620175", "0.56437945", "0.56031704", "0.55870795", "0...
0.81235754
0
Loads all features saved as .pckl files in load_dir. Assumes temporary files are named in order 0.pckl, 1.pckl, ...
def load_temp(temp_dir: str) -> Tuple[List[List[float]], int]: features = [] temp_num = 0 temp_path = os.path.join(temp_dir, f'{temp_num}.pckl') while os.path.exists(temp_path): with open(temp_path, 'rb') as f: features.extend(pickle.load(f).todense().tolist()) temp_num...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preload_all(self):\n for tp in self.tps:\n for f in self.featurefiles + self.maskfiles:\n file = os.path.join(tp, f)\n print('preloading {}'.format(file))\n self.load(file, lazy=False)", "def load_cleaned_data(self):\n try:\n se...
[ "0.63542026", "0.622923", "0.6225778", "0.6176938", "0.6145942", "0.6114523", "0.6100938", "0.6095534", "0.60908407", "0.59987974", "0.59812504", "0.59734666", "0.5885715", "0.5843664", "0.58296454", "0.5808799", "0.58010346", "0.5794536", "0.5786768", "0.576896", "0.57370263...
0.7497788
0
Saves features as a sparse 2D array in a .pckl file.
def save(save_path: str, features: List[List[int]]): features = np.stack(features) sparse_features = sparse.csr_matrix(features) with open(save_path, 'wb') as f: pickle.dump(sparse_features, f)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_sparse_csr(filename,array, labels, vocab):\n np.savez(filename,data = array.data ,indices=array.indices,\n indptr =array.indptr, shape=array.shape, labels=labels, vocab=vocab)", "def write_features(self):\r\n def pack_keypoint(keypoints, descriptors):\r\n kpts = np.array...
[ "0.67501915", "0.66873586", "0.656412", "0.63253766", "0.61887836", "0.61680484", "0.60859734", "0.60263306", "0.5971248", "0.59471333", "0.5908365", "0.5906807", "0.5899714", "0.58502316", "0.58263576", "0.5813861", "0.57842207", "0.57829225", "0.5779973", "0.5777876", "0.57...
0.77198964
0
Context manager for writing Nifti images. Write nifti images in a temporary location, and remove them at the end of the block.
def write_tmp_imgs(*imgs, **kwargs): valid_keys = set(("create_files",)) input_keys = set(kwargs.keys()) invalid_keys = input_keys - valid_keys if len(invalid_keys) > 0: raise TypeError("%s: unexpected keyword argument(s): %s" % (sys._getframe().f_code.co_name, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tempWrite(img):\n\tfilename = \"{}.png\".format(os.getpid())\n\tcv2.imwrite(filename, img)\n\treturn filename", "def temporary_otf(psf, **kwargs) -> Iterator[str]:\n temp_otf = NamedTemporaryFile(suffix=\".tif\", delete=False)\n temp_otf.close()\n kwargs[\"out_file\"] = temp_otf.name\n try:\n ...
[ "0.57791656", "0.559986", "0.5568264", "0.5489825", "0.5458124", "0.5455938", "0.5269913", "0.52326995", "0.52260333", "0.52223533", "0.52214986", "0.5218835", "0.5213988", "0.5208156", "0.519537", "0.51795727", "0.51483214", "0.51410943", "0.5132695", "0.5120044", "0.5085515...
0.59094065
0
Generate some random timeseries.
def generate_timeseries(n_instants, n_features, rand_gen=None): if rand_gen is None: rand_gen = np.random.RandomState(0) # TODO: add an "order" keyword return rand_gen.randn(n_instants, n_features)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_timeseries(F=F, H=H, stop=2000, x0=np.array([-0.72, -0.64]),\n R_v=np.eye(2)*0, R_n=np.eye(2)*0.001):\n dim = 2 # Number of dimensions for the system\n U, Y = [], []\n\n x = x0\n for k in range(stop):\n U.append(u(k, dim))\n x = F(x, U[-1]) + np.random....
[ "0.70383114", "0.69929093", "0.6980777", "0.67623866", "0.657515", "0.65121454", "0.64440536", "0.6420202", "0.6412522", "0.62945265", "0.6267221", "0.6247034", "0.6239323", "0.61976844", "0.61852556", "0.6142638", "0.6083203", "0.607253", "0.60519725", "0.59896535", "0.59625...
0.7802924
0
Similar to generate_labeled_regions, but suitable for a large number of regions. See generate_labeled_regions for details.
def generate_labeled_regions_large(shape, n_regions, rand_gen=None, affine=np.eye(4)): if rand_gen is None: rand_gen = np.random.RandomState(0) data = rand_gen.randint(n_regions + 1, size=shape) if len(np.unique(data)) != n_regions + 1: raise ValueError("So...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_labeled_regions(shape, n_regions, rand_gen=None, labels=None,\n affine=np.eye(4), dtype=np.int):\n n_voxels = shape[0] * shape[1] * shape[2]\n if labels is None:\n labels = range(0, n_regions + 1)\n n_regions += 1\n else:\n n_regions = len(labe...
[ "0.73343444", "0.6563286", "0.6261711", "0.62581253", "0.6233945", "0.6222684", "0.6134825", "0.6032802", "0.60190785", "0.58821195", "0.58546543", "0.5852284", "0.58343166", "0.5798799", "0.5758949", "0.57411385", "0.57374746", "0.57368535", "0.5723029", "0.57016504", "0.568...
0.7379657
0
Generate a signal which can be used for testing. The return value is a 4D array, representing 3D volumes along time. Only the voxels in the center are nonzero, to mimic the presence of brain voxels in real signals. Setting n_blocks to an integer generates condition blocks, the remaining of the timeseries corresponding ...
def generate_fake_fmri(shape=(10, 11, 12), length=17, kind="noise", affine=np.eye(4), n_blocks=None, block_size=None, block_type='classification', rand_gen=np.random.RandomState(0)): full_shape = shape + (length, ) fmri = np.zeros(full_shape) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_power_mat(Blocks, n_time=None, window=None, deconvolve=True,\n subtract_slope=False, normalize=True, split_scans=False) :\n \n if split_scans:\n if n_time < 0:\n nt = 0\n for Data in Blocks:\n nt = max(nt, Data.dims[0])\n time_...
[ "0.54218876", "0.5347044", "0.5209925", "0.50923383", "0.50685", "0.49923864", "0.4989412", "0.4971845", "0.49567068", "0.49511606", "0.49350876", "0.4910832", "0.49014923", "0.49002606", "0.48869562", "0.48048225", "0.4780173", "0.47642916", "0.4733879", "0.47295997", "0.472...
0.58028567
0
Returns whether we are running the nose test loader
def is_nose_running(): if 'nose' not in sys.modules: return try: import nose except ImportError: return False # Now check that we have the loader in the call stask stack = inspect.stack() from nose import loader loader_file_name = loader.__file__ if loader_file_na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_test(self):\r\n return self.has_label('tests')", "def in_test_mode(mode: str) -> bool:\n return mode == TEST", "def is_debug_environment():\n return find_loader('cli') is None", "def has_test(args):\n return (args.test_set or args.test_source or args.test_dataset or\n args.test_...
[ "0.6710294", "0.65085256", "0.6501002", "0.643152", "0.6334279", "0.6331781", "0.6207894", "0.61747146", "0.6098017", "0.60761607", "0.6036826", "0.6007059", "0.59931827", "0.59918535", "0.59651667", "0.596192", "0.5960737", "0.5939169", "0.5939169", "0.5937096", "0.5912477",...
0.82869864
0
Raise a SkipTest if we appear to be running the nose test loader.
def skip_if_running_nose(msg=''): if is_nose_running(): import nose raise nose.SkipTest(msg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skipped (func):\n try:\n from nose.plugins.skip import SkipTest\n\n def skipme (*a, **k):\n raise SkipTest()\n\n skipme.__name__ = func.__name__\n return skipme\n except ImportError:\n # no nose, we'll just skip the test ourselves\n def skipme (*a, **k...
[ "0.68719923", "0.67888", "0.6715446", "0.66168034", "0.6573704", "0.6552569", "0.64676446", "0.6338194", "0.6295717", "0.6274743", "0.6261666", "0.62551445", "0.62430686", "0.62061006", "0.6199096", "0.6144063", "0.61341745", "0.6050069", "0.60070395", "0.5978082", "0.5947236...
0.74961287
0
The goal is to take all of the rabbits in list x and distribute them equally across the original list elements.
def answer(x): total = sum(x) length = len(x) # Find out how many are left over when distributing niavely. div, mod = divmod(total, length) # Because of the variable size of the list, the remainder # might be greater than the length of the list. # I just realized this is unnecessary. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Grundy(x):\n # n taille bianire max des xi; m longeur de x\n \n # Calcul de la longueur binaire utilisée\n # Complexité en O(m)\n \n n = 0\n \n for val in x :\n t = taille(val)\n if n < t :\n n = t\n \n \n \n # Ecriture de la liste x en binaire\n ...
[ "0.62214047", "0.6016501", "0.57494277", "0.5728374", "0.56744075", "0.565092", "0.5598182", "0.5584444", "0.5572034", "0.55388814", "0.54754066", "0.54414487", "0.54307544", "0.5420037", "0.54140496", "0.53838485", "0.53592545", "0.5343972", "0.5335226", "0.53238034", "0.531...
0.7346859
0
Wind degree increment and direction labels This is useful for labeling a matplotlib wind direction axis ticks.
def wind_degree_labels(res="m"): labels = [ "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N", ] degrees = np.arange(0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def direction(self, value) -> str:\n if value is None:\n return \"N\"\n\n direction_array = [\n \"N\",\n \"NNE\",\n \"NE\",\n \"ENE\",\n \"E\",\n \"ESE\",\n \"SE\",\n \"SSE\",\n \"S\",\...
[ "0.60139704", "0.5973254", "0.586569", "0.5836478", "0.54933774", "0.54433167", "0.5428965", "0.5380825", "0.52725774", "0.5225931", "0.51691425", "0.5119801", "0.5084086", "0.5076434", "0.50719297", "0.5047696", "0.5044402", "0.5040369", "0.50316596", "0.50309575", "0.502943...
0.64912957
0
Calculate the u and v wind components from wind speed and direction.
def spddir_to_uv(wspd, wdir): if isinstance(wspd, list) or isinstance(wdir, list): wspd = np.array(wspd, dtype=float) wdir = np.array(wdir, dtype=float) rad = 4.0 * np.arctan(1) / 180.0 u = -wspd * np.sin(rad * wdir) v = -wspd * np.cos(rad * wdir) # If the speed is zero, then u and...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_wdir(u,v):\n wdir = np.arctan2(u,v) * dper + 180.\n return wdir", "def wind_uv_to_spd(U, V):\n WSPD = np.sqrt(np.square(U) + np.square(V))\n return WSPD", "def windcal(v,u):\r\n \r\n ws = (u**2 + v**2)**0.5\r\n wd = np.arctan2(u,v)\r\n wd_ang = wd *180/np.pi\r\n wd_ang = wd_...
[ "0.6676565", "0.6648414", "0.64769393", "0.64678985", "0.64521706", "0.61794984", "0.6178912", "0.61161715", "0.6090697", "0.60595447", "0.6014731", "0.5993724", "0.5987498", "0.594977", "0.58914006", "0.58911014", "0.5884545", "0.5880258", "0.5867097", "0.5857762", "0.584073...
0.690899
0
generates a list of numbers between initial and final. eg. input fill_between(0,10) output [1,2,...,9]
def fill_between(initial,final): return np.arange(initial + 1, final)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_list(start: int, stop: int, step: int = 1) -> List[int]:\n # if start == stop:\n # print(start)\n # else:\n # res = []\n # while start < (stop + 1):\n # res.append(start)\n # start += step\n # print(res)\n\n return [item for item in range(star...
[ "0.6757427", "0.6554503", "0.6540405", "0.64606386", "0.6450871", "0.64365226", "0.63656837", "0.63607585", "0.63012767", "0.6230167", "0.62118906", "0.6154418", "0.6078806", "0.60544646", "0.6024539", "0.5990913", "0.5986559", "0.5980868", "0.59468067", "0.59426254", "0.5931...
0.83161664
0
Create a new cache manager from the filepath
def __init__(self, config, cache_filename, path): self.config = config self.cache_path = os.path.join(path, cache_filename) self._cache = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cached(factory, cache_file_name, **kwargs):\n if os.path.exists(cache_file_name):\n _logger.info('Loading {}'.format(cache_file_name))\n cached = deserialize(cache_file_name)\n return cached\n\n _logger.info('Creating {}'.format(cache_file_name))\n data = factory()\n serial...
[ "0.6535663", "0.62747574", "0.6271472", "0.62008804", "0.61269826", "0.61267143", "0.6085783", "0.6075361", "0.6040413", "0.6005393", "0.5999963", "0.5990663", "0.5967084", "0.5963094", "0.5963094", "0.59488666", "0.5915283", "0.59102154", "0.5901501", "0.5876344", "0.5870961...
0.6481817
1
Check and return possible config locations in preference order Tries to look at local, then environmentvariable set, then default global config locations. If none are found raises an error.
def _config_location(cls): local = cls._find_local() if local is not None: return local, ConfigLocations.local global_path = cls._find_global() if global_path is not None: return global_path, ConfigLocations.config env = cls._find_env() if env is n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess_a_config_location():\n names = ['gridrealm.cfg', 'gr.cfg', 'config.cfg', 'dev.cfg']\n home_paths = [os.path.join(os.getenv('HOME'), stub)\n for stub in ['.%s', 'gridrealm/%s']]\n other_paths = ['/etc/gridrealm/%s']\n paths = [os.path.join(os.getcwd(), name) for name in names]...
[ "0.6970471", "0.62514764", "0.61309", "0.6124601", "0.60156304", "0.5973742", "0.5923498", "0.58747023", "0.58732814", "0.58700407", "0.5792729", "0.57852584", "0.5765626", "0.5713048", "0.5693334", "0.56778693", "0.56434774", "0.56368756", "0.5636028", "0.5630168", "0.562964...
0.7685157
0
Set up the file structures required to run from scratch Can be given a type of config location to set up. Does not currently overwrite existing files. Not overwriting may cause some issues, as proper validation is not yet done so this could leave incomplete structures untouched. However it prevents data loss until more...
def setup(cls, config_location_type=None, filepath=None): if config_location_type is None: config_location_type = ConfigLocations.config try: config_dir = cls._config_dirpath() if cls._config_location_type() != config_location_type: raise FileNotFoundE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup(parser):\n global debug\n global config\n global file_list\n global job_sets\n global from_saved_state\n\n args = parser.parse_args()\n\n if args.debug:\n debug = True\n print_message('Running in debug mode', 'ok')\n\n # read through the config file and setup the con...
[ "0.69891685", "0.6866163", "0.655242", "0.65018666", "0.64563316", "0.63907486", "0.6361503", "0.6355713", "0.6311247", "0.6296911", "0.6244698", "0.62441015", "0.62441015", "0.62441015", "0.6225075", "0.62146336", "0.61982673", "0.61658627", "0.61618257", "0.6145451", "0.614...
0.7058799
0
Parse a given prefix and postfix into a period. prefix and postfix are possibly empty strings, and gfyear is an int.
def get_period(prefix, postfix, gfyear): prefix = prefix.upper() if not re.match(r'^([KGBOT][0-9]*)*$', prefix): raise ValueError("Invalid prefix: %r" % prefix) if not re.match(r'^([0-9]{2}){0,2}$', postfix): raise ValueError("Invalid postfix: %r" % postfix) if not postfix: per...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rewrite (substr):\r\n\r\n slengths = [0]* (2*numpops-1)\r\n firstint = [0] * (2*numpops - 1)\r\n holdsubs = [[]] * (2*numpops - 1)\r\n periodi = [0] * (2*numpops - 1)\r\n pos = 1\r\n subpos = pos\r\n subcount = 0\r\n pcount = 0\r\n slengths[subcount] = 0\r\n while 1:\r\n if...
[ "0.50715554", "0.5068828", "0.5033946", "0.49539757", "0.49275348", "0.49094987", "0.49025503", "0.4851792", "0.48479527", "0.48254976", "0.47523782", "0.47306678", "0.47023422", "0.46756333", "0.46660507", "0.46481925", "0.4610277", "0.45811", "0.4565813", "0.45560893", "0.4...
0.82148147
0
Resolve a BEST/FU alias into a (kind, root, period)tuple where kind is 'BEST', 'FU' or 'EFU', root is the actual title, and period is which period the title refers to. >>> parse_bestfu_alias('OFORM', 2016) ('BEST', 'FORM', 2013)
def parse_bestfu_alias(alias, gfyear): alias = alias.upper() prefix_pattern = r"(?P<pre>(?:[KGBOT][KGBOT0-9]*)?)" postfix_pattern = r"(?P<post>(?:[0-9]{2}|[0-9]{4})?)" letter = '[A-Z]|Æ|Ø|Å|AE|OE|AA' letter_map = dict(AE='Æ', OE='Ø', AA='Å') title_patterns = [ ('BEST', 'CERM|FORM|INKA|K...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_legacy_fusion_langauge(concept: ParserElement, reference: str) -> ParserElement:\n break_start = (ppc.integer | \"?\").setParseAction(_fusion_break_handler_wrapper(reference, start=True))\n break_end = (ppc.integer | \"?\").setParseAction(_fusion_break_handler_wrapper(reference, start=False))\n\n ...
[ "0.48906887", "0.48889995", "0.47315535", "0.47176993", "0.46773595", "0.4650028", "0.4588476", "0.45437825", "0.44782794", "0.44273108", "0.43642148", "0.43582878", "0.43426895", "0.4333364", "0.43115208", "0.4306738", "0.42991564", "0.42988628", "0.4293423", "0.42913708", "...
0.86312157
0
Generates list of buttons for one row
def generateColumnButtons(self): ret = [] for i in range(self.shapeColumn): ret.append(QPushButton(" ")) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_buttons(self):\r\n return []", "def generate_buttons(self):\n raise Exception('Implement me!')", "def generate_buttons(self):\n buttons = []\n for mtime, player in self.mainwindow.data.get_all_players():\n button = OpenByPlayerName.PlayerNameButton(self, player...
[ "0.7556989", "0.745377", "0.7307188", "0.7302164", "0.69251347", "0.6906728", "0.68929255", "0.68411815", "0.6804531", "0.67634076", "0.67016643", "0.667886", "0.6662659", "0.6617823", "0.66163635", "0.6595827", "0.65853846", "0.65589654", "0.6513123", "0.6506611", "0.6470687...
0.7474345
1
Extracts list of strings(text property of QPushButton in self.buttons) for one given row.
def extractValuesColumn(self, row): ret = [] for j in range(self.shapeColumn): ret.append(self.buttons[row][j].text()) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_results(self) -> List[str]:\n output = []\n for row in self.row_layout.children():\n if self.possible_values is None:\n text = row.itemAt(0).widget().text()\n else:\n text = row.itemAt(0).widget().currentText()\n\n if text != \"\"...
[ "0.6112099", "0.609661", "0.594698", "0.574644", "0.56583315", "0.56475604", "0.5609093", "0.5601508", "0.55659944", "0.549222", "0.5457595", "0.54499114", "0.5398269", "0.53693503", "0.5359774", "0.53166217", "0.5315597", "0.5313688", "0.52665055", "0.5211151", "0.5202507", ...
0.74068636
0
Shows Information QMessageBox to the players and calls self.reset()
def endGame(self, msg): title = "Game Over" QMessageBox.information(self, title, msg) self.reset()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_game_ui(self):\n for button in self.button_list:\n button.configure(state='normal', text='')\n self.instructions.configure(text=self.PROMPT.format(self.players[self.game.whose_turn]))\n self.player_0_score_label.configure(text=self.SCORE_LABEL.format(self.players[0], self....
[ "0.65145206", "0.6381196", "0.63136333", "0.62095165", "0.61601335", "0.60611784", "0.59672", "0.5965515", "0.59582233", "0.5950194", "0.59451926", "0.58958036", "0.5882915", "0.58761793", "0.5849919", "0.5844486", "0.5820559", "0.58174527", "0.58068293", "0.5803182", "0.5771...
0.68728095
0
Resets the value of text property of QPushButtons in self.buttons to the initial value
def reset(self): for i in range(self.shapeRow): for j in range(self.shapeColumn): self.buttons[i][j].setText(" ")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\r\n\r\n self.make_board()\r\n\r\n # configure each buttons text option to an empty string\r\n for row in range(3):\r\n for column in range(3):\r\n self.board[row][column][0]['text'] = ''", "def clear_text(self):\n # use the .children attribut...
[ "0.6957211", "0.6805629", "0.66721416", "0.66121054", "0.6475105", "0.6377304", "0.63075817", "0.6248069", "0.6224556", "0.61870503", "0.6175603", "0.6147187", "0.6140553", "0.60580295", "0.5933571", "0.5933337", "0.5932643", "0.59222335", "0.58841836", "0.5836833", "0.583167...
0.6927504
1
get the data from a station by name, e.i. "Arnhem"
def station_by_name(self, name): for station in self.stations: if name.lower() in station.stationname.lower(): return station print(str.format("Could not find station with name '{0}'", name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def station(id_or_name):\n with open(\"/data/station_data.json\") as j:\n data = json.load(j)\n # if id is passe\n if id_or_name in data:\n return data[id_or_name]\n # if name is passed\n for _, v in data.items():\n if v[\"name\"] == id_or_name:\n return v\n ...
[ "0.7311504", "0.6826527", "0.6621788", "0.6372976", "0.6352849", "0.61800164", "0.6144457", "0.6104845", "0.60976386", "0.60952127", "0.60513043", "0.6051014", "0.6021073", "0.60205555", "0.60079426", "0.6000053", "0.5998479", "0.5972637", "0.59509563", "0.5950716", "0.591446...
0.6981374
1
get the data from a station by id, e.i. 6370 corresponds to Eindhoven
def station_by_id(self, id): for station in self.stations: if id == station.stationid: return station print(str.format("Could not find station with '{0}'",str(id)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getStationData(self, stationId):\n if (stationId == 'all'):\n return self.stationData\n else:\n station = np.where(self.stationData == stationId)[0][0]\n return self.stationData[station]", "def get_station_data(self, content_id):\n params = [('selectitemi...
[ "0.7653374", "0.7219824", "0.703812", "0.697056", "0.6943071", "0.6935172", "0.6807949", "0.6779699", "0.66777605", "0.6672282", "0.650662", "0.6505391", "0.6499075", "0.6467972", "0.64022017", "0.63915503", "0.63865626", "0.63454056", "0.61420006", "0.6116356", "0.6077994", ...
0.72415614
1
return "Active", "NoActive", "NoUser"; also False in case the connection with the repo fails
def checkUserStatus(self, userId, passwd, userIdB): if not self._reposervice.connection(): msg = "ERROR: Connection with the Image Repository failed" self.logger.error(msg) return False else: self.logger.debug("Checking User Status") status= se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_connection_status(self):\n\n if not self.pk:\n status = self.NOT_SAVED\n msg = \"<span class='errors'>No connection. Please save and reload to connect to dropbox </span>\"\n\n # if no access keys have been set validation still needs to occur\n elif self.access_tok...
[ "0.5968085", "0.5880365", "0.57035387", "0.56564885", "0.56564885", "0.56433654", "0.5607298", "0.55909824", "0.5560767", "0.5530319", "0.5514828", "0.5498519", "0.547868", "0.5463859", "0.5458047", "0.54489917", "0.5448285", "0.5445072", "0.5440849", "0.5432132", "0.5395406"...
0.6159137
0
It will boot a VM using XMLRPC API for OpenNebula from lib/ruby/OpenNebula/VirtualMachine.rb index start in 0 VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED} LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG SHUTDOWN...
def boot_VM(self, server, vmfile): vmaddr = "" fail = False #print vmfile #-----read template into string ------------------------- #s=open('./share/examples/ubuntu_context.one','r').read() s = open(os.path.expanduser(vmfile), 'r').read() #self.logge...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def boot_VM(self, server, vmfile,n):\n \n fail = False\n \n #print vmfile\n #-----read template into string -------------------------\n #s=open('./share/examples/ubuntu_context.one','r').read()\n \n s = open(os.path.expanduser(vmfile), 'r').read()\n #self....
[ "0.6974966", "0.6542071", "0.6174419", "0.60944587", "0.593424", "0.5932572", "0.5740052", "0.5729967", "0.5676518", "0.56402546", "0.56302965", "0.5621988", "0.5603456", "0.5555332", "0.55472946", "0.5540855", "0.55207574", "0.55127215", "0.5511323", "0.550356", "0.55033886"...
0.72371
0
Sharpen the image using laplacian operator
def sharp_laplace1(img): # Shapening the image with laplacian involves adding the image concolved # with the laplacian back to the original image. Since laplace operator # can generate negative values we need to use a int type image img = np.asarray(img, dtype=np.int) # Perform the operation sharp = img -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lapsharp(image, maskret = False):\n #padded_image = np.pad(img, (1, 1), mode = 'symmetric')\n # lap is linear therefore;\n # lap f(x,y) = f(x + 1, y) + f(x - 1, y) + f(x, y + 1) + f(x, y - 1) - 4f(x,y)...\n #--------------------\n c = -1 # Depends on kernel\n # make ze...
[ "0.6956539", "0.6852815", "0.6612176", "0.65127355", "0.64412785", "0.6402566", "0.63263977", "0.6262676", "0.6129621", "0.6088573", "0.6081865", "0.6055082", "0.6042514", "0.60067093", "0.5978222", "0.58495253", "0.5839093", "0.5835235", "0.5770221", "0.57674384", "0.5733162...
0.6990299
0
Sharpen the image using laplacian operator. This version does shapening in the x,y directions, taking into account diagonal effects. Produce more sharpening than shap_laplace1.
def sharp_laplace2(img): # the laplacian kernel laplace_kern = np.array([[-1., -1., -1.], [-1., 0., -1.], [-1., -1., -1.]]) # See laplace 1 above for the following lines img = np.asarray(img, dtype=np.int) sharp = img + ndi.convolve(img, laplace_kern) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sharp_laplace1(img):\n\n # Shapening the image with laplacian involves adding the image concolved\n # with the laplacian back to the original image. Since laplace operator\n # can generate negative values we need to use a int type image\n img = np.asarray(img, dtype=np.int)\n\n # Perform the operation\n ...
[ "0.78536755", "0.6877913", "0.63893634", "0.59705347", "0.5950476", "0.5926851", "0.5800112", "0.56938", "0.5640643", "0.5614657", "0.5610272", "0.5568397", "0.5531451", "0.5526421", "0.55252945", "0.54793257", "0.5406822", "0.53333384", "0.5251543", "0.5242818", "0.5196331",...
0.73254424
1
Sharpen image using the unsharp masking.
def unsharp_mask(img, size=3): # apply the averaging filter avg = average(img, size) # subtract the average from the image, for a "diference" mask int_img = np.asarray(img, np.int) diff_mask = int_img - avg # Finally add the mask to the original image sharp = int_img + diff_mask return np.asarray(np...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsharp_mask(image, kernel_size=(5, 5), sigma=1.0, amount=1.0, threshold=0):\n blurred = cv2.GaussianBlur(image, kernel_size, sigma)\n sharpened = float(amount + 1) * image - float(amount) * blurred\n sharpened = np.maximum(sharpened, np.zeros(sharpened.shape))\n sharpened = np.mini...
[ "0.74546635", "0.74264693", "0.728012", "0.6843109", "0.6629832", "0.660978", "0.6607981", "0.65305245", "0.64847285", "0.6479211", "0.64688325", "0.6374778", "0.63293505", "0.61248046", "0.60356426", "0.6032625", "0.5863463", "0.58398944", "0.56587666", "0.564856", "0.561179...
0.7427577
1
If player has not yet pressed a pokemon or cancel then move cursor around menu. Otherwise, pass event to give handler.
def handle_event(self, event): if self.give_event_handler is not None: self.give_event_handler.handle_event(event) elif event.key in [BattleActions.UP.value, BattleActions.DOWN.value, BattleActions.LEFT.value, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_event(self, event):\n if self.threw_away_dialogue is not None:\n if event.key == BattleActions.SELECT.value:\n self.is_dead = True\n self.player.bag.subtract_item(self.item, self.num_selected)\n elif self.confirm_toss_response_dialogue is not None:\...
[ "0.65703744", "0.6526224", "0.6395934", "0.6236886", "0.62309253", "0.61795455", "0.61788315", "0.6114897", "0.6076895", "0.60537875", "0.6048677", "0.5988578", "0.5968678", "0.5957603", "0.59342355", "0.58606815", "0.5843472", "0.5824476", "0.58213717", "0.5797019", "0.57956...
0.7411565
0
Pass control to sub event.
def handle_event(self, event): self.give_sub_event.handle_event(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_event(self, event):", "def process_event(self, event):\n\t\tself.current_screen.control_manager.process_event(event)", "def on_event(self, event):", "def __call__(self, trigger, type, event):", "def handle_event(self, event):\n if self.sub_event is not None:\n self.sub_event.ha...
[ "0.65463436", "0.63625574", "0.6313055", "0.62816155", "0.6237508", "0.62124205", "0.62124205", "0.62124205", "0.62124205", "0.60723734", "0.6068834", "0.6058454", "0.6033045", "0.60304993", "0.5990957", "0.5969153", "0.59590864", "0.59377724", "0.59323525", "0.5917756", "0.5...
0.7090374
0
Once the user presses select give the pokemon the item and end the sub event.
def handle_event(self, event): if event.key == BattleActions.SELECT.value: self.pokemon.held_item = self.item self.bag.subtract_item(self.item) self.is_dead = True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_event(self, event):\n if event.key == BattleActions.SELECT.value:\n prev_item = self.pokemon.held_item\n self.pokemon.held_item = self.item\n self.bag.subtract_item(self.item)\n self.bag.add_item(prev_item)\n self.is_dead = True", "def _han...
[ "0.75080955", "0.7133411", "0.6695631", "0.6665145", "0.6607717", "0.64676195", "0.64621747", "0.6387541", "0.63765347", "0.63644207", "0.63472676", "0.633178", "0.631691", "0.63150346", "0.62574077", "0.61786926", "0.6070302", "0.6041557", "0.6028456", "0.60168976", "0.59468...
0.76115954
0
Draw parent and either the sub event (if it exists) or the text cursor.
def draw(self, draw_surface): super().draw(draw_surface) if self.sub_event is not None: self.sub_event.draw(draw_surface) else: self.text_cursor.draw(draw_surface)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, draw_surface):\n if self.sub_event is not None:\n self.sub_event.draw(draw_surface)\n else:\n super().draw(draw_surface)\n self.response_box.draw(draw_surface)", "def draw(self, surface, offset=(0,0)):\n mouse = pg.mouse.get_pos()\n pos ...
[ "0.627118", "0.6109929", "0.5881829", "0.58441406", "0.57228583", "0.5715464", "0.5616364", "0.56010973", "0.5558435", "0.5526324", "0.5523188", "0.5452996", "0.5434051", "0.5407732", "0.53939015", "0.5368208", "0.5346662", "0.53387624", "0.5331886", "0.5319257", "0.53099644"...
0.76767075
0
Update the parent and either the sub event (if it exists) or the text cursor.
def update(self, ticks): super().update(ticks) if self.sub_event is not None: self.sub_event.update(ticks) if self.sub_event.is_dead: self.is_dead = True else: self.text_cursor.update(ticks)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, parent):\r\n pass", "def _parentChanged(self, event):\n if event == ItemChangedType.DATA:\n self._syncDataWithParent()", "def _parentChanged(self, event):\n if event == ItemChangedType.DATA:\n self._syncDataWithParent()", "def _notify_parent_change(...
[ "0.63008475", "0.6243823", "0.6243823", "0.62403256", "0.60885787", "0.5960349", "0.589688", "0.58327436", "0.5800853", "0.571153", "0.5553321", "0.5444877", "0.5435372", "0.5327991", "0.53258544", "0.53013504", "0.52698797", "0.52413714", "0.5221217", "0.5192681", "0.5172669...
0.6748975
0
Once the user presses control for the first time create the ProposeQuestion sub event. Then pass control to that.
def handle_event(self, event): if self.sub_event is not None: self.sub_event.handle_event(event) return # Return instead of if else to save from indentation. if event.key == BattleActions.SELECT.value: self.sub_event = ProposeQuestion(self.pokemon, self.item, self.b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _onPremade(self, event):\n self.openPremade()", "def CreatePresentation(self, event):\n pass", "def handle_event(self, event):\n if self.sub_event is not None:\n self.sub_event.handle_event(event)\n else:\n self.confirm_response.handle_event(event)", "def _...
[ "0.5931917", "0.57346004", "0.5685744", "0.56454235", "0.56135863", "0.55824924", "0.5517988", "0.5504992", "0.5463824", "0.53784907", "0.53600204", "0.5305437", "0.52160716", "0.5215624", "0.5207972", "0.5181632", "0.5172987", "0.5171561", "0.5149044", "0.51483107", "0.51481...
0.69369715
0
Returns the position for the text cursor. Uses the ending position for the surface created by the text maker and adds the offset (9, 128) to said position. Why this offset? The 9 comes from wanting the cursor to appear 9 pixels to the right of the last word. The 128 is calculated from two parts 120 and 8. 120 comes fro...
def get_cursor_pos(self): return (self.text_maker.pos[0] + 9, self.text_maker.pos[1] + 120 + 8)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cursor(self):\n k, font, txt = self._cursor, self.font, self.txt\n index2pixel = self._index2pixel\n\n return Rect(index2pixel(k), font.size(txt[k]))\n print k", "def fl_drw_text_cursor(align, xpos, ypos, width, height, colr, style, size,\n txtstr, cursco...
[ "0.7106266", "0.67025995", "0.6598012", "0.65792054", "0.65152574", "0.64523005", "0.6008566", "0.59492326", "0.59292054", "0.591991", "0.5904845", "0.5904845", "0.5845101", "0.5830657", "0.5822291", "0.5808893", "0.5773932", "0.5740669", "0.5740669", "0.5718189", "0.5712245"...
0.7913087
0
If the user has not responded yet then keep drawing the response box. Otherwise draw the active sub event.
def draw(self, draw_surface): if self.sub_event is not None: self.sub_event.draw(draw_surface) else: super().draw(draw_surface) self.response_box.draw(draw_surface)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, draw_surface):\n if self.sub_event is not None:\n self.sub_event.draw(draw_surface)\n else:\n self.confirm_response.draw(draw_surface)", "def draw(self, draw_surface):\n if not self._initial_prompt.is_over():\n self._initial_prompt.draw(draw_su...
[ "0.6663868", "0.613772", "0.61316454", "0.61022747", "0.60418385", "0.5897732", "0.58548343", "0.5786412", "0.57719547", "0.57631606", "0.5761421", "0.57605785", "0.5737207", "0.5717125", "0.570114", "0.57003915", "0.5693072", "0.5664772", "0.56597024", "0.5648264", "0.562333...
0.72234386
0
If the user has not responded yet then pass control of events to the response box otherwise pass control to the active sub event.
def handle_event(self, event): if self.sub_event is not None: self.sub_event.handle_event(event) return elif not self.response_box.is_dead: self.response_box.handle_event(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_event(self, event):\n if self.sub_event is not None:\n self.sub_event.handle_event(event)\n else:\n self.confirm_response.handle_event(event)", "def handle_event(self, event):\n # Get rid of all non keydown events\n if event.type != pygame.KEYDOWN:\n ...
[ "0.70562786", "0.65823364", "0.6070701", "0.58491206", "0.58307445", "0.57533306", "0.5735693", "0.57237697", "0.57080597", "0.56929004", "0.5680088", "0.5645506", "0.5591976", "0.55501693", "0.55050266", "0.5454733", "0.5428536", "0.5380919", "0.53773695", "0.5376115", "0.53...
0.7219368
0
Tests retrieving comments by post.
def test_retrieve_comment_by_post(self): self.factory.force_authenticate(user=self.user) response = self.factory.get(self.comment_by_post_url) self.assertEqual(1, response.data.get('count'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_comments_by_post(self):\n\n CommentFactory(author=self.user, body='Test comment 2', post=self.post)\n data = {\n 'post': self.post.id,\n }\n response = self.client.get(reverse('api:comments-list'), data)\n self.assertEqual(response.status_code, status.HTTP...
[ "0.8731827", "0.7249414", "0.7116133", "0.6883682", "0.6843346", "0.68232113", "0.67878413", "0.67185014", "0.667185", "0.6663989", "0.6632818", "0.6631826", "0.659794", "0.6547392", "0.6530747", "0.65231174", "0.64825916", "0.6480644", "0.63485324", "0.6344378", "0.6305463",...
0.8269749
1
Tests retrieving child comment.
def test_retrieve_child_comment(self): self.factory.force_authenticate(user=self.user) response = self.factory.get(self.child_comment_url) self.assertEqual(1, response.data.get('count'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_issue_get_comment(self):\n pass", "def test_post_matches_parent_when_parent_is_comment(self):\n post = create_a_post()\n parent = Comment.create(body=\"I'm a parent comment\", post=post)\n comment = Comment.create(body=\"I'm a child comment\", parent=parent)\n self.ass...
[ "0.67906404", "0.6775625", "0.66820216", "0.66153044", "0.6589334", "0.64227855", "0.64161164", "0.6391682", "0.625861", "0.6256233", "0.62547976", "0.62407607", "0.6169852", "0.6104241", "0.6091013", "0.60809535", "0.60560757", "0.6047148", "0.6045318", "0.59804225", "0.5978...
0.7927583
0