query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Make a dataset for training or evaluating SMURF.
def make_dataset(self, path, mode, height=None, width=None): # Split up the possibly comma seperated directories. if ',' in path: l = path.split(',') d = '/'.join(l[0].split('/')[:-1]) l[0] = l[0].split('/')[-1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dataset(dataset_type, soruce, opts): \n\n p = PreProcessor(dataset_type, opts)\n\n # If we are NOT running \"implementation.py\", we read the data from file\n if dataset_type == \"train\" or dataset_type == \"dev\" or dataset_type == \"test\":\n path_to_data = soruce\n p.read_labe...
[ "0.71976507", "0.7156453", "0.6980805", "0.6959531", "0.688197", "0.68500346", "0.6844109", "0.6841355", "0.68199223", "0.6816855", "0.6813762", "0.68059635", "0.67992455", "0.67547446", "0.6730391", "0.6708142", "0.6706259", "0.66852164", "0.6672077", "0.6619019", "0.6602753...
0.0
-1
Return a prettified taxon name.
def pname(name): ranks = list(reversed(name.split(';'))) for i, rank in enumerate(ranks): if rank in ['Others', 'Unassigned']: return rank if rank == '__': continue if rank.split('__')[1] is '': return ranks[i+1] + ';' + rank return rank
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def taxonParser(taxon):\r\n parser = TaxonParser(taxon)\r\n scientific_name = \"\"\r\n\r\n try:\r\n parsed_name = parser.parse()\r\n if parsed_name.isBinomial() is True:\r\n scientific_name = str(parsed_name.genus) + \" \" + str(parsed_name.specificEpithet)\r\n if str(p...
[ "0.64729476", "0.63083935", "0.62381494", "0.62266713", "0.61525995", "0.6145447", "0.6030031", "0.59031326", "0.58614546", "0.58417225", "0.58398944", "0.5793541", "0.57750577", "0.5752416", "0.57239914", "0.5706593", "0.56737465", "0.56687945", "0.56369525", "0.5615086", "0...
0.0
-1
Default action if no subcommand is passed.
def _default(self): self.app.render(infoNetwork.all())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_handler(self, _: argparse.Namespace) -> int:\n print(\"No command specified!\")\n self.parser.print_usage()\n return 1", "def run(self):\n if self.subcommand_parser is None:\n self.exit(1, 'Command defines no subcommands')\n\n args = self.parse_args()\n ...
[ "0.7499549", "0.6950549", "0.68918645", "0.6662167", "0.65991306", "0.6514817", "0.650766", "0.6461696", "0.64330965", "0.6416854", "0.6334393", "0.6319114", "0.63075733", "0.6286679", "0.6237047", "0.6179591", "0.61773044", "0.61754835", "0.6156815", "0.61317736", "0.6086994...
0.0
-1
Returns the current training instance.
def getTrainInstance(self): #NOTE: Probably faster way of doing this than additional 'if' statement every learning iteration return [self.currentTrainState, self.currentTrainPhenotype] #Return unadulterated training data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTrainInstance(self):\n self.train_inst_condition = self.format_data.trainFormatted[self.data_ref][0]\n self.train_inst_phenotype = self.format_data.trainFormatted[self.data_ref][1]\n if self.data_ref < (self.format_data.numTrainphenotypes - 1):\n self.data_ref += 1\n e...
[ "0.6745298", "0.65309036", "0.652377", "0.64405304", "0.64387655", "0.63725954", "0.63721037", "0.6339007", "0.633087", "0.6328472", "0.6328472", "0.631136", "0.62620455", "0.6256982", "0.6194044", "0.61931723", "0.61446357", "0.61241245", "0.6090343", "0.6074379", "0.6053777...
0.7190633
0
Returns the current training instance.
def getTestInstance(self): return [self.currentTestState, self.currentTestPhenotype]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTrainInstance(self): #NOTE: Probably faster way of doing this than additional 'if' statement every learning iteration\r\n return [self.currentTrainState, self.currentTrainPhenotype] #Return unadulterated training data\r", "def getTrainInstance(self):\n self.train_inst_condition = self.forma...
[ "0.71910805", "0.6746282", "0.65304893", "0.6523471", "0.6442107", "0.64365894", "0.6372113", "0.637159", "0.63391674", "0.633235", "0.63296", "0.63296", "0.63115346", "0.6262467", "0.6256379", "0.61942786", "0.6191379", "0.61420786", "0.612376", "0.6089886", "0.6073037", "...
0.0
-1
Shifts the environment to the next instance in the data.
def newInstance(self, isTraining): #------------------------------------------------------- # Training Data #------------------------------------------------------- if isTraining: if self.dataRef < (self.formatData.numTrainInstances-1): self.dataRef += ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def advance(self):\n self._state = self._next_state", "def step(self, env):\n self.loc = env.look_and_move(self.loc, self.vision)\n self.sugar += env.harvest(self.loc) - self.metabolism\n self.age += 1", "def advance(self):\n self.last = self.next\n self.next = {}", ...
[ "0.6054279", "0.60246956", "0.5994793", "0.5764017", "0.5736582", "0.5727876", "0.5688803", "0.5682906", "0.568099", "0.5655789", "0.562545", "0.5563428", "0.5542813", "0.5464575", "0.5454749", "0.5453741", "0.54400635", "0.54220384", "0.53969413", "0.5393709", "0.5387718", ...
0.0
-1
Resets the iteration count through the current data set.
def resetDataRef(self, isTraining): self.dataRef = 0 if isTraining: self.currentTrainState = self.formatData.trainFormatted[self.dataRef][0] self.currentTrainPhenotype = self.formatData.trainFormatted[self.dataRef][1] else: self.currentTestState = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.reset_count += 1\n self._init_data()", "def reset(self):\n self.__sets = []\n self._computed = False", "def reset(self):\n self._idx = 0", "def reset(self):\n self.counter = 0", "def reset (self):\n self.counter = 0", "def restart(s...
[ "0.76493454", "0.7592407", "0.75396395", "0.7494579", "0.7469788", "0.74186695", "0.7362823", "0.72185916", "0.7206081", "0.7201951", "0.7198221", "0.7198221", "0.7175789", "0.71727675", "0.71725744", "0.71486783", "0.7148364", "0.7142279", "0.7115226", "0.7083241", "0.703967...
0.0
-1
Turns on evaluation mode. Saves the instance we left off in the training data. Also important when using RAIN.
def startEvaluationMode(self): self.storeDataRef = self.dataRef
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self):\n self.training = False", "def eval(self):\n self.train(mode=False)", "def startEvaluationMode(self):\n self.saved_dat_ref = self.data_ref", "def _set_eval(self):\n\n if self.model.__dict__['training']:\n self.model.eval()", "def test(self):\n ...
[ "0.77029514", "0.7351376", "0.6970109", "0.69243413", "0.67273355", "0.6641681", "0.6606844", "0.65508974", "0.65234417", "0.6444228", "0.6444228", "0.63508517", "0.63474333", "0.6293147", "0.6250714", "0.6239057", "0.62286705", "0.62021804", "0.6135565", "0.61062217", "0.608...
0.6623913
6
Turns off evaluation mode. Reestablishes place in dataset.
def stopEvaluationMode(self): self.dataRef = self.storeDataRef
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stopEvaluationMode(self):\n self.data_ref = self.saved_dat_ref", "def eval(self):\n self.train(mode=False)", "def evaluate(self):\n self.training = False", "def startEvaluationMode(self):\n self.saved_dat_ref = self.data_ref", "def startEvaluationMode(self):\r\n self....
[ "0.7714545", "0.7181543", "0.71166897", "0.7048885", "0.6880281", "0.6681234", "0.6602843", "0.6505008", "0.64479685", "0.6384801", "0.622787", "0.61700326", "0.6166375", "0.61271054", "0.612519", "0.6065476", "0.5972313", "0.59697014", "0.5949517", "0.58708465", "0.5826638",...
0.77148956
0
Return True if password is valid for user, else False
def check_password(self, password): if self.password_expire_epoch != 0 and \ time.time() > self.password_expire_epoch: lg.debug("Password invalid for user '%s': user password is expired"\ %self.name) return False if self.password_hash is None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_password_valid(password):\n #TODO : This should also be handled by the front_end\n pass", "def get_has_password(self, user):\n return True if user.password else False", "def check_password(self, password):\n return self.password == password", "def verify_password(self, pass...
[ "0.8181345", "0.80773896", "0.80308294", "0.79664797", "0.78895646", "0.78841513", "0.7839702", "0.78388", "0.7825555", "0.7808887", "0.775599", "0.775599", "0.77107185", "0.77031857", "0.7691626", "0.7690411", "0.7689362", "0.76876014", "0.7684381", "0.76713455", "0.7656842"...
0.7833034
8
Return deferred returning User object if auth successful, else None
def simple_auth(self, name, password, user=None): if not self._is_initialized(): return self._not_initialized_deferred() def _do_auth(res=None, state="entry", user=None): if state == 'entry': d = self.get_user_record(name) d.addCallback(_do_auth, s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth(session, db):\n\tif (session.auth != None) and db(db.User.id == session.auth).count() == 1:\n\t\treturn User(session.auth, db)\n\telse:\n\t\treturn None", "def get_user(self, token: str) -> Optional[User]:", "def get_user(self, token: str) -> Optional[User]:", "def getUser():\n username = pos...
[ "0.7104391", "0.69574493", "0.69574493", "0.68695545", "0.6855984", "0.67873764", "0.6775833", "0.6756567", "0.6676308", "0.6669874", "0.6645674", "0.66192853", "0.66097975", "0.65966207", "0.656263", "0.65613914", "0.6555194", "0.65526843", "0.6551315", "0.65439045", "0.6524...
0.0
-1
Return a brief description of how to use this command, by default from the attribute ``self.help``.
def usage(self, subcommand): if subcommand == self.run_alias: return self.usage_alias(subcommand) return """ ./manage.py alias ./manage.py alias name ./manage.py alias name[=value] ./manage.py unalias name Save commands and parameters as shortcuts. Aliases are stored...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def help(self) -> str:\n raise NotImplementedError", "def help(self) -> str:\n\t\treturn None", "def help_help(self):\n print(\"List commands or print details about a command\")", "def help_description():\n pass", "def help(self):\r\n self._short_help(None, None, None, None)", "de...
[ "0.86134076", "0.8328481", "0.83243597", "0.82085884", "0.8195443", "0.81407374", "0.81246716", "0.8114379", "0.8072708", "0.790892", "0.7887833", "0.7887833", "0.7855178", "0.78480136", "0.7847862", "0.77800506", "0.77442", "0.773133", "0.7728289", "0.7712405", "0.76743376",...
0.0
-1
PLots the features in a 3d plot including the hyperplane that separates the data
def plot_3d_plot(self, features, headers, labels): self.master_plot.scatter(features[:, 0], features[:, 1], features[:, 2], c=labels) self.master_plot.set_xlabel(headers[0]) self.master_plot.set_ylabel(headers[1]) self.master_plot.set_zlabel(headers[2]) plot_hyperplane(self.clf,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot3d(self):\n plot_rupture_wire3d(self)", "def svm_add_3d_hyperplane(model, ax, plotted_points):\n SPACE_SAMPLING_POINTS = 70\n X_MIN = np.min(plotted_points[:, 0])\n X_MAX = np.max(plotted_points[:, 0])\n Y_MIN = np.min(plotted_points[:, 1])\n Y_MAX = np.max(plotted_points[:, 1])\n ...
[ "0.7302647", "0.7106038", "0.7101418", "0.69293755", "0.6890816", "0.6856431", "0.6853505", "0.6824226", "0.67982167", "0.6775323", "0.67729586", "0.67109203", "0.67087954", "0.6701973", "0.66566586", "0.6629957", "0.66192967", "0.6613964", "0.66003513", "0.6584965", "0.65722...
0.75784415
0
Graphs the features from the log file. Creates a 3D graph with time, average power to motors and velocity as axises. It also decomposes the dimensions into individual 2D graphs.
def graph(self, file_data): self.file_data = file_data self.features, self.headers = get_features(file_data) # FIXME make it so that the outliers can be visualized as well self.new_scaled_features, self.features = manipulate_features(self.features, file_data) # features = scale...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logplot(in_dir, fname, xlim, ylim, title):\n\n with open(in_dir + fname,'r') as logfile:\n lf_lines = logfile.readlines()\n\n traj_x = []\n traj_y = []\n\n for row in lf_lines:\n if row[:4] == 'pose':\n #print(float(row[10:-2]))\n tup = row[7:]\n sep_p...
[ "0.5589732", "0.5531616", "0.54918617", "0.54734266", "0.5443798", "0.5409416", "0.5401678", "0.5318455", "0.5291172", "0.5280342", "0.52708125", "0.52629036", "0.5238679", "0.5226329", "0.5199443", "0.5171123", "0.5170337", "0.51116526", "0.50877655", "0.5086324", "0.5083493...
0.5361183
7
Clears all the axes
def clear_graphs(self): for ax in (self.master_plot, self.time_velocity, self.time_power, self.power_velocity): ax.cla()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n\n # Clear\n self.axes.cla()\n try:\n self.figure.clf()\n except KeyError:\n FlatCAMApp.App.log.warning(\"KeyError in MPL figure.clf()\")\n\n # Re-build\n self.figure.add_axes(self.axes)\n self.axes.set_aspect(1)\n self...
[ "0.82477164", "0.7836058", "0.7796212", "0.77853906", "0.7656969", "0.7641738", "0.7476974", "0.74030435", "0.738647", "0.7372803", "0.7297088", "0.7183157", "0.7169569", "0.71616346", "0.71613884", "0.70750993", "0.70736307", "0.6969796", "0.69636786", "0.69146824", "0.68999...
0.80753964
1
Shows the grids for the major ticks in the plot.
def show_grid(self): for ax in (self.time_velocity, self.time_power, self.power_velocity): ax.grid(True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nicegrid():\n pl.grid(b=True, which='major', color='black', linestyle='-')\n\n pl.grid(b=True, which='minor', color='silver', linestyle=':')", "def show_grid(frame, episode_nr):\n plt.grid('on')\n ax = plt.gca()\n ax.set_xticks(np.arange(0.5, 10, 1))\n ax.set_yticks(np.arange(0.5, 10, 1))\n...
[ "0.68624645", "0.67270374", "0.66225463", "0.6502822", "0.6419999", "0.6419999", "0.6344717", "0.63419735", "0.62765646", "0.6247754", "0.6218179", "0.6216362", "0.61837363", "0.6176579", "0.6159757", "0.6152556", "0.6152556", "0.61514324", "0.61219585", "0.6111579", "0.60773...
0.7353925
0
Creates an addition figure that will display the a graph with the constants on it and also the lines of best fit of the accelerating portion of it, the decelerating portion of it and the average of both of those lines
def show_constants_graph(self, features, file_data, labels, c=None): if is_straight_line(file_data): easygui.msgbox("It was determined that the robot was trying to go straight. " "As an ongoing feature the program will be able detect kLag, etc... " ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_graph(self):\r\n A = self.a_grid ; V = self.V1 ; Pol = self.Pol\r\n A_opt = A[Pol.astype(int)]\r\n \r\n fig = plt.subplots(figsize = (8,5))\r\n ax = [None,None]\r\n pltgrid = (1,2)\r\n \r\n ax[0] = plt.subplot2grid(pltgrid, (0,0))\r\n ax[1] = ...
[ "0.67043483", "0.66094536", "0.6536485", "0.6489944", "0.6460383", "0.6324786", "0.63169456", "0.63111645", "0.62606317", "0.62522936", "0.6246969", "0.61507666", "0.61484957", "0.6146962", "0.61454314", "0.6120756", "0.6114009", "0.61120445", "0.607397", "0.6066781", "0.6062...
0.6149567
12
This is the main loop which runs until the user no selects any file. Retrieves the saved model for separating the data.
def find_constants(open_path): if not os.path.exists(MODEL_FILE): easygui.msgbox("There are no models to use to classify the data. Please train algorithm first.") return clf = joblib.load(MODEL_FILE) if is_empty_model(clf): easygui.msgbox("The model has not been fitted yet. Please...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\r\n # Close any open models\r\n self.cleanUp()\r\n # Dynamically select file to preview\r\n self.selectTrial() \r\n # Add adjusted COM (RRA/CMC) model\r\n self.loadAdjustedModel()\r\n # Hide the markers from view\r\n self.hideModelMarker...
[ "0.69089055", "0.6218082", "0.6208536", "0.61605316", "0.60690135", "0.5954537", "0.5932205", "0.59236944", "0.5921074", "0.5898295", "0.5871303", "0.5865246", "0.58392626", "0.5826997", "0.58248043", "0.5769699", "0.5768321", "0.57621425", "0.5759154", "0.57176274", "0.57117...
0.0
-1
Creates and initializes a card
def __init__(self, suit: str, rank: str) -> None: self.suit = suit self.rank = rank self.value = Card.values[rank] self.hidden = False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createCard(self,id,name):\n card = Card(id,name)\n self.cards[id] = card\n print('Created Card:'+id)", "def define_card(card):\n try:\n value = define_card_value(card[0])\n color = define_card_color(card[1])\n return Card(value, color)\n except AttributeError:\...
[ "0.7489538", "0.74147695", "0.73503184", "0.7285862", "0.7285862", "0.7158202", "0.71478814", "0.71125865", "0.70091987", "0.6920996", "0.6901048", "0.6856007", "0.681001", "0.67669064", "0.67593235", "0.6752542", "0.6734627", "0.6703586", "0.66528183", "0.66227216", "0.66011...
0.6388992
45
both threads will call this function to try to acquire the lock
def try_lock_acquire(lock): logging.debug('Starting') for i in range(2): time.sleep(0.5) logging.debug('Trying to acquire') """.acqire() returns false if the timeout passed in has elapsed.""" have_it = lock.acquire(0) try: if have_it: """ only one thread will acquire the lock each iteration """ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acquire_lock(self):\n self._multistore._lock()", "def acquire_lock(self):\n if self.lock:\n self.lock.acquire()", "def lock(self):\n self.mtx.acquire()", "def lock(self):\n raise NotImplementedError", "def acquire_lock (self):\n\n self._exec (self.selec...
[ "0.8146044", "0.80489576", "0.7777038", "0.76436627", "0.7439585", "0.7301035", "0.7277469", "0.7263061", "0.7245742", "0.72069293", "0.718976", "0.7181839", "0.71141493", "0.70146245", "0.7011094", "0.6964797", "0.69139475", "0.68795747", "0.6869598", "0.68481034", "0.684688...
0.68544126
19
Return all the matching commands. Only for the submode which is passed in. Be sensitive to features, be sensitive to the prefix. For commands which have a first keyword which is a pattern, use the command description's completio
def commands_for_submode(prefix): candidates = _lookup_command_candidates(prefix, command_registry) # print type(candidates), [x['self'] for x in candidates] # print [x.get('all-help') for x in candidates] if debug.cli(): # print 'commands_for_submode:', sorted(dict([[x['name']['title'] if type(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matching_commands(self, command_word, is_no_command, command_list):\n candidates = []\n current_mode = bigsh.run.finder.mode_stack.current_mode()\n command_word_lower = command_word.lower()\n\n try:\n for command in command_list:\n # If this command is ...
[ "0.66676307", "0.6511643", "0.6412278", "0.63640773", "0.6297366", "0.62761074", "0.6274068", "0.6131544", "0.6130938", "0.60968447", "0.6082013", "0.6057049", "0.5983618", "0.5955035", "0.5952809", "0.58883524", "0.58177805", "0.5813151", "0.5804144", "0.5801285", "0.5795904...
0.8093101
0
Save some state about the version/module
def add_command_module_name(version, module): if version not in command_syntax_version: command_syntax_version[version] = [module] else: command_syntax_version[version].append(module)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_state(self):\n pass", "def save_state(self):\r\n state = {\r\n 'next_student_module_id': self.next_student_module_id,\r\n }\r\n with open(self.STATE_FILE, \"w\") as state_file:\r\n json.dump(state, state_file)\r\n self.say(\"Saved state: {}\".form...
[ "0.67257243", "0.65780526", "0.64473563", "0.6440833", "0.64254165", "0.621508", "0.6183765", "0.61343235", "0.611661", "0.610986", "0.604875", "0.6012745", "0.60035145", "0.5991767", "0.5912925", "0.58604914", "0.5834747", "0.5828542", "0.5822429", "0.57592875", "0.57477856"...
0.0
-1
Returns whether or not the given value is a valid boundary value. Valid values are integers or the special strings 'min' or 'max' (caseinsensitive)
def _is_range_boundary(boundary): return (isinstance(boundary, numbers.Integral) or (_is_string(boundary) and (boundary.lower() in ('min','max'))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self, value: Union[int, float]) -> bool:\n if self.left_boundary['open']:\n if self.left_boundary['value'] >= value:\n return False\n else:\n if self.left_boundary['value'] > value:\n return False\n if self.right_boundary['open']...
[ "0.7001806", "0.69449776", "0.69125473", "0.6847961", "0.6784564", "0.6771291", "0.6754776", "0.671932", "0.67118704", "0.6632516", "0.6568673", "0.6539237", "0.65292275", "0.6448011", "0.6417884", "0.64089316", "0.6399697", "0.6356775", "0.6352202", "0.63023275", "0.6292374"...
0.8070116
0
Converts the given boundary value to an appropriate integral boundary value. This is used to handle the special "min' and 'max' string values. The test_value argument should be the value which is being tested for whether or not it's in a range. Since long integral values have an unlimited precision there is no actual M...
def _convert_range_boundary(boundary, test_value): if _is_string(boundary): if boundary.lower() == 'min': boundary = test_value - 1 elif boundary.lower() == 'max': boundary = test_value + 1 else: raise error.CommandDescriptionError('Invalid range boundary ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_range_boundary(boundary):\n return (isinstance(boundary, numbers.Integral) or\n (_is_string(boundary) and (boundary.lower() in ('min','max'))))", "def clean_int(\n i: int,\n ub: int,\n lb: int = 0,\n ) -> int: \n\n # Initialisations\n i_temp = i\n\n # Check if the in...
[ "0.6226162", "0.6110354", "0.5956353", "0.5869911", "0.5851052", "0.5840057", "0.58316064", "0.5831372", "0.5728684", "0.569103", "0.56804085", "0.56803036", "0.5654331", "0.56315446", "0.55944073", "0.5495219", "0.5494189", "0.5409632", "0.5409632", "0.539477", "0.5389832", ...
0.7728433
0
Returns whether or not the argument is a valid single range. A valid range is either a single integral value or else a sequence (tuple or list) with 2 elements, each of which is a valid range boundary value.
def _is_single_range(r): return (isinstance(r, numbers.Integral) or (isinstance(r, collections.Sequence) and (len(r) == 2) and _is_range_boundary(r[0]) and _is_range_boundary(r[1])))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_one_range(r):\n if not _is_single_range(r):\n raise error.RangeSyntaxError(str(r))", "def acceptsArgument(self):\n range = self.validateRange(self.range)\n return not(not(range[1]))", "def isRangeValid(self) -> bool:\n ...", "def _is_range(cls, rng):\n match = re....
[ "0.7808903", "0.7591454", "0.7182697", "0.71769637", "0.7123997", "0.7108595", "0.6981113", "0.69550073", "0.6891303", "0.688228", "0.686025", "0.6788622", "0.6352424", "0.63459134", "0.63131315", "0.62641954", "0.6227245", "0.6194634", "0.61821723", "0.6179093", "0.6149241",...
0.86027473
0
Checks that the argument is a valid single range as determined by _is_single_range. If it is, then the function returns None. It it's not, then a RangeSyntaxError exception is raised.
def _check_one_range(r): if not _is_single_range(r): raise error.RangeSyntaxError(str(r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_single_range(r):\n return (isinstance(r, numbers.Integral) or\n (isinstance(r, collections.Sequence) and (len(r) == 2) and\n _is_range_boundary(r[0]) and _is_range_boundary(r[1])))", "def _check_range(r): \n if _is_single_range(r):\n _check_one_range(r)\n elif isin...
[ "0.71708286", "0.6784762", "0.6421671", "0.63540816", "0.6278021", "0.6267585", "0.61784256", "0.5972375", "0.5945648", "0.5697895", "0.5589983", "0.5469726", "0.53853506", "0.533863", "0.531605", "0.5294728", "0.52871644", "0.528131", "0.5274676", "0.5242175", "0.51893365", ...
0.81059533
0
Checks that the argument is a valid range. If it is, then the function returns None. It it's not, then a RangeSyntaxError exception is raised.
def _check_range(r): if _is_single_range(r): _check_one_range(r) elif isinstance(r, collections.Sequence): for r2 in r: _check_one_range(r2) else: raise error.RangeSyntaxError(str(r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_range(parser, arg, minimum=0, maximum=100):\n if arg < minimum:\n parser.error(\"%s < %s\", arg, minimum)\n else:\n if arg > maximum:\n parser.error(\"%s > %s\", arg, maximum)\n\n return arg", "def _check_one_range(r):\n if not _is_single_range(r):\n raise...
[ "0.77003306", "0.7608936", "0.7103421", "0.68035877", "0.6748383", "0.67366076", "0.673641", "0.6694982", "0.64401865", "0.64094526", "0.6375695", "0.63503134", "0.6252607", "0.6230385", "0.6222785", "0.61698633", "0.61226755", "0.60937774", "0.6084571", "0.6073749", "0.60656...
0.7267727
2
Look up the given name in a typedef. If it's not found in the given typedef it recursively searches for the value in the base typedefs. Returns None if the value is not found.
def _lookup_typedef_value(typedef, name): assert typedef is not None assert name is not None # Check if the typedef has the attribute value = typedef.get(name) if value: return value # Otherwise, see if it's defined in the base type(s) base_type_name = typedef.get('base-typ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkLookup(self, name):\n if not self.symbols.has_key(name):\n # we don't care\n return None\n # is it one we really care about\n t = self.symbols[name].getType()\n if t == \"typedef\":\n t = self.symbols[name].getAliasType()\n if t == \"...
[ "0.62882066", "0.6006309", "0.5985091", "0.58943266", "0.5891234", "0.58053267", "0.57933515", "0.5666294", "0.5659589", "0.556779", "0.5549444", "0.5516995", "0.5516995", "0.54696757", "0.5459081", "0.5456446", "0.5453206", "0.5431234", "0.5415231", "0.5371446", "0.53526515"...
0.8076759
0
Called when an argument doesn't match the expected type. Raises an ArgumentValidationError exception. The message for the exception can be customized by specifying a error format string in the type definition. The format string is called ' validationerrorformat'.
def _raise_argument_validation_exception(typedef, value, detail, expected_tokens=None): typedef_name = typedef.get('help-name') if typedef_name is None: typedef_name = typedef.get('name') if typedef_name is None: typedef_name = typedef.get('field') if typedef_name is None...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_incorrect_arg_type(self):\n\n with pytest.raises(TypeError) as exc_info:\n upper_incomplete_gamma(a='A', z=0.3)\n\n expected_error_msg = (\n 'type of argument \"a\" must be one of (int, float); got str instead'\n )\n assert str(exc_info.value) == expected_...
[ "0.69686395", "0.66745853", "0.6643091", "0.6587547", "0.6579584", "0.646052", "0.6447449", "0.64430845", "0.6376854", "0.63049024", "0.63008493", "0.62791383", "0.6219893", "0.61986107", "0.61303514", "0.6127861", "0.6121139", "0.6109378", "0.6102843", "0.60939085", "0.60928...
0.7721112
0
Gets the args item from the given item. The item may be a command or subcommand description or a nested arg list inside a 'choice' argument. If there's no item names "args", then it returns None. If the args item is a single argument, then it's converted into a tuple containing that single argument, so that the caller ...
def _get_args(item): args = item.get('args') if args and not isinstance(args, collections.Sequence): args = (args,) return args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _item_or_tuple(self, seq):\n t = tuple(seq)\n if self._is_multi:\n return t\n else:\n return t[0]", "def _item_or_tuple(self, seq):\n t = tuple(seq)\n if self._is_multi:\n return t\n else:\n return t[0]", "def _item_or_tuple(self, seq):\n ...
[ "0.60065734", "0.5978255", "0.5978255", "0.57647127", "0.5749274", "0.5505375", "0.5469559", "0.5410199", "0.53327376", "0.5265627", "0.52116334", "0.5186901", "0.51850796", "0.5178818", "0.5167262", "0.5139123", "0.5139123", "0.51254106", "0.50968003", "0.5068587", "0.506782...
0.7316674
0
Get the syntax help string for an argument list.
def _get_command_args_syntax_help_string(command, is_no_command, args): syntax_string = '' if args: for i, arg in enumerate(args): if i > 0: syntax_string += ' ' if _is_string(arg): syntax_string += arg continue ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_help(args):", "def help():\n return statement(help_text)", "def help_list(self):\n help_str = \"\"\"Lists command(s) from history in a flexible/searchable way.\n\n Usage: list [arg]\n\n Where arg is:\n no arg -> list most recent command\n arg is inte...
[ "0.66476196", "0.6568818", "0.6546846", "0.64866126", "0.64727557", "0.64497846", "0.64382064", "0.633312", "0.6330669", "0.63208956", "0.6274658", "0.6242831", "0.62242854", "0.6200293", "0.6198663", "0.61940193", "0.6166287", "0.60947055", "0.6091308", "0.60767895", "0.6057...
0.63734406
7
Predicate to provide some indication of whether or not the command allows the 'no' prefix
def is_no_command_supported(command): command_type = command.get('command-type') if command_type: if command_type in ['display-table','display-rest', 'show']: return False no_supported = command.get('no-supported', True) if no_supported == False: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_skip(self, value):\n return value.startswith(self.flag_prefix) or value == '--'", "def possible_negation_prefix(text: str) -> bool:\n prefixes = (\"de\", \"dis\", \"im\", \"in\", \"ir\", \"il\", \"non\", \"un\", \"mis\")\n # Length is mentioned to limit wrong prefix recongnition such as \...
[ "0.6331741", "0.6209631", "0.6140443", "0.61398494", "0.6138786", "0.6078261", "0.6060077", "0.6056548", "0.60399204", "0.596429", "0.5939109", "0.5934993", "0.58885604", "0.5875812", "0.58206064", "0.5796699", "0.57939255", "0.57747096", "0.57518256", "0.57354045", "0.571539...
0.58597386
14
Returns the list of matching command candidates from the command list.
def get_matching_commands(self, command_word, is_no_command, command_list): candidates = [] current_mode = bigsh.run.finder.mode_stack.current_mode() command_word_lower = command_word.lower() try: for command in command_list: # If this command is tied to a fe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _lookup_command_candidates(command_prefix, command_list):\n candidates = []\n current_mode = bigsh.run.finder.mode_stack.current_mode()\n try:\n for command in command_list:\n modes = _get_applicable_modes(command)\n if _match_current_modes(command, current_mode, modes):\n...
[ "0.78405523", "0.6468865", "0.63149947", "0.62614846", "0.6214467", "0.6194494", "0.6165398", "0.6153341", "0.6145241", "0.61329925", "0.5982471", "0.59805346", "0.5973649", "0.5963104", "0.59585357", "0.5950532", "0.5916563", "0.59144855", "0.5905247", "0.5900076", "0.589186...
0.71730745
1
Parse the given args from the given command words.
def parse_arguments(self, args, words, start_word_index, scopes, arg_data, fields, actions, prefix_matches, command): if len(args) == 0: return [[0, [], scopes, arg_data, fields, actions]] parse_results = [] arg = args[0] if _is_string(arg): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def parse_args(args):\n parser = argparse.ArgumentParser(\n description=\"Command line bot application, e.g. bot how do you work?\")\n parser.add_argument(\n '--version',\n action='version',\n version='nlpia_bot {ver}'.format(ver=__version__))\n ...
[ "0.73245573", "0.7055901", "0.66049635", "0.6526766", "0.652343", "0.650238", "0.6472132", "0.64673615", "0.6459616", "0.6401424", "0.6397366", "0.638948", "0.63884", "0.6379766", "0.6367825", "0.63568634", "0.63269633", "0.631822", "0.6295588", "0.6281215", "0.6237192", "0...
0.705395
2
Select the most appropriate localized text to associate with the completionreason for some completiontext
def complete_help(self, arg_scopes): c_help = _lookup_in_scopes('conpletion-text', arg_scopes) if c_help: return c_help c_help = _lookup_in_scopes('syntax-help', arg_scopes) if c_help: return c_help c_help = _lookup_in_scopes('all-help', arg_scopes) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completion_set(self, completions, text, reason):\n if completions == None:\n completions = {text : reason}\n return\n current_text = completions.get(text)\n # current_text could possibly be None from the lookup\n if current_text != None and current_text[0] == '...
[ "0.6259234", "0.61822283", "0.59109974", "0.57965857", "0.5733555", "0.56752014", "0.5584407", "0.5546678", "0.5533903", "0.5503533", "0.5498424", "0.54351395", "0.5376525", "0.5369051", "0.5360784", "0.53588665", "0.5344191", "0.531261", "0.53013414", "0.5272706", "0.5260305...
0.55057406
9
In situations where multiple commands match for some completion text, the last commanditeratedover will populate the text for the completion dictionary. Use the first character of the completion string for this command to identify when the text represents the most "base" variant of the command to display for completion...
def completion_set(self, completions, text, reason): if completions == None: completions = {text : reason} return current_text = completions.get(text) # current_text could possibly be None from the lookup if current_text != None and current_text[0] == '!': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete_help(self, arg_scopes):\n c_help = _lookup_in_scopes('conpletion-text', arg_scopes)\n if c_help:\n return c_help\n c_help = _lookup_in_scopes('syntax-help', arg_scopes)\n if c_help:\n return c_help\n c_help = _lookup_in_scopes('all-help', arg_sc...
[ "0.6587769", "0.6476927", "0.64444095", "0.62364894", "0.610779", "0.6104665", "0.60427445", "0.5979768", "0.5978135", "0.59669816", "0.5960604", "0.5933637", "0.5852868", "0.58415747", "0.5825542", "0.5779125", "0.57398105", "0.5697792", "0.5675063", "0.56458724", "0.5634846...
0.0
-1
Print the completions ourselves in sorted multiple column format. We use this when the completions are are pseudo/help completions that aren't real tokens that we want readline to use for completions.
def print_completions(self, completions): meta_completions = [completion[0] if isinstance(completion, tuple) else completion for completion in completions] meta_completions.sort() bigsh.print_completion_help(bigsh.choices_text_builder(meta_completions))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cli_completions(self) -> str:\n completions = []\n for cmd_name in self.cli_parser.cmd_names:\n completions.append(cmd_name)\n for plugin_name in self.name_to_plugin_class:\n completions.append(plugin_name)\n\n return \",\".join(completions)", "def displaySor...
[ "0.60223293", "0.5749722", "0.57289875", "0.5696492", "0.56638753", "0.55966675", "0.5560439", "0.5553174", "0.5548504", "0.55221015", "0.5500452", "0.5498528", "0.5395442", "0.5389106", "0.53512865", "0.5325396", "0.530939", "0.53022945", "0.5282126", "0.5232109", "0.5226291...
0.7565795
0
The canonical (i.e. most general) representation of a validation result is a list of 2item tuples where the first item in the tuple is the validated value that should be used to update the arg_data and the second item is the actual token that was matched, which may not be the same as the word in the command. For exampl...
def _canonicalize_validation_result(result): if result is None: result = [] elif _is_list(result): if len(result) > 0 and not _is_list(result[0]): result = [result] else: matching_token = result if _is_string(result) else str(result) result = [(result, matching_to...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _process_validator_results(ret, level, object_data, obj):\n\n # The first object in the tuple is the one being validated\n if isinstance(obj, tuple):\n real_obj = obj[0]\n else:\n real_obj = obj\n\n if not ret:\n is_valid = True\n return i...
[ "0.5750961", "0.55248684", "0.5506295", "0.54921216", "0.5306934", "0.5261992", "0.5246164", "0.52409977", "0.51459575", "0.5136628", "0.51328367", "0.5111515", "0.50920993", "0.5087317", "0.5069478", "0.5063956", "0.5053605", "0.5051444", "0.50409806", "0.5040384", "0.502853...
0.7486084
0
Validate that the specified value matches the validation in the specified type definition and any inherited type definitions
def validate_type(type_name, value, arg_data, scopes, command): # Look up the type definition and perform any validation specified there typedef = typedef_registry.get(type_name) if not typedef: raise error.CommandDescriptionError('Unknown type: %s' % type_name) type_result = None validatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkType(self, value):\n pass", "def validate(self, value):\n value = super(Type,self).validate(value)\n if self.type is None:\n return value\n if value is not None and not isinstance(value,self.type):\n try:\n if isinstance(value, list) or is...
[ "0.71427083", "0.6972905", "0.6835837", "0.67700577", "0.671566", "0.6649001", "0.6594712", "0.65906966", "0.65582323", "0.6530636", "0.6525814", "0.6501799", "0.6471414", "0.6450656", "0.6442439", "0.6424564", "0.6416181", "0.64132726", "0.6408936", "0.64036417", "0.6397485"...
0.6791413
3
Build output lines from the passed in text. If the text has leading spaces, then leave the spaces intact (starting at the indent).
def dumb_formatter(out, text, left, right = None): if right == None: (right, line_length) = bigsh.pp.get_terminal_size() if right - 20 > left: # XXX needs work right = right - 20 right = min(right, 120) left_indent = ' ' * left out_len = left out_line = left_indent ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __indent_text_block(text):\n lines = text.splitlines()\n if len(lines) > 1:\n out = lines[0] + \"\\r\\n\"\n for i in range(1, len(lines)-1):\n out = out + \" \" + lines[i] + \"\\r\\n\"\n out = out + \" \" + lines[-1]\n return out\n return text", "...
[ "0.73112255", "0.66962504", "0.6664648", "0.66639674", "0.6600784", "0.6528203", "0.6523025", "0.6511936", "0.6481735", "0.6391032", "0.6383207", "0.6354279", "0.6329117", "0.63085085", "0.6291374", "0.6235841", "0.6215798", "0.61852205", "0.61840844", "0.6153983", "0.6147103...
0.6057945
24
qualify Generate qualify version of the permutations field_values Generate instance of command using these fields
def __init__(self, qualify = False, field_values = None): super(CommandPermutor, self).__init__() self.commands = [] self.collect = [] # intended to be boolean, but any predicate type will do. self.qualify = qualify # field_values is intended to be a dictionary of name:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def field_to_generator(self, field, field_values):\n if self.qualify:\n # Many of the fields are actually fields in\n # the named obj-type. Take a shot at seeing if that's\n # the case, and call a sample value collector\n\n if self.path_other:\n # ...
[ "0.59003377", "0.5237725", "0.5203437", "0.5165361", "0.50387293", "0.50179744", "0.4940163", "0.49088612", "0.48980182", "0.48827323", "0.48454884", "0.48104414", "0.4796751", "0.4788122", "0.47654617", "0.47645807", "0.47437337", "0.47381946", "0.47369894", "0.47285095", "0...
0.60619706
0
Convert the field name to a text field. When 'qualify' is set, replace the field name with a likely procedure to call instead
def field_to_generator(self, field, field_values): if self.qualify: # Many of the fields are actually fields in # the named obj-type. Take a shot at seeing if that's # the case, and call a sample value collector if self.path_other: # These are ty...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_field(identifier: str) -> str:\n return identifier.lower()", "def __call__(self, field_name):\n try:\n return getattr(self, field_name)\n except Exception:\n return self._encoded_fields[field_name]", "def capnp_field_name(self, field):\n name = field.name\n return as_ide...
[ "0.59077346", "0.57926226", "0.55189836", "0.54694974", "0.5461919", "0.5446574", "0.5430781", "0.5419817", "0.5418746", "0.5403276", "0.5351895", "0.5326152", "0.52837604", "0.5249325", "0.5220029", "0.5216379", "0.5213939", "0.5204398", "0.51758146", "0.5173832", "0.5161701...
0.4900808
54
Permute command for a submode, takes the command, finds all the related submodesmodes, permutes all the commands in the submode, then a recursive call to any submodes found within this one. submode_command command dictionary of the submode command. Can be set to None as an indication of "root" qualify boolean, describe...
def permute_single_submode(submode_command, qualify): permuted = [] permute_submodes = [] if submode_command == None: mode = 'login' else: # first, the submode. There ought to be only one permutation. permute = CommandPermutor(qualify) permuted.append(permute.permute_co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permute_command(words, qualify):\n if len(words) == 0:\n return permute_single_submode(None, qualify)\n else:\n permute = CommandPermutor(qualify)\n return permute.handle_command(words)", "def commands_for_submode(prefix):\n candidates = _lookup_command_candidates(prefix, comman...
[ "0.6088499", "0.5510981", "0.5013558", "0.4904283", "0.48374233", "0.47861892", "0.47663242", "0.4672153", "0.4592035", "0.45495653", "0.45457467", "0.4542132", "0.4524321", "0.45221865", "0.44939885", "0.4493422", "0.4463644", "0.44468173", "0.4442733", "0.44194564", "0.4403...
0.78541815
0
Permute all the commands (with no parameters), or a sigle command. The command is named via the name
def permute_command(words, qualify): if len(words) == 0: return permute_single_submode(None, qualify) else: permute = CommandPermutor(qualify) return permute.handle_command(words)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_command_direct(self, name, args=None, kwargs=None):\n comm,_=self._commands[name]\n return comm(*(args or []),**(kwargs or {}))", "def _transform_command(self) -> None:\n self.command = None if self.command == [] else self.command", "def __call__(self, cmd):\n cmdname = cmd...
[ "0.5660321", "0.55383295", "0.54060173", "0.539535", "0.5362111", "0.5255111", "0.5249829", "0.524142", "0.5200568", "0.5195856", "0.51837564", "0.51559633", "0.51405185", "0.5124075", "0.51221806", "0.5109466", "0.50891364", "0.50802135", "0.5072316", "0.5067867", "0.503808"...
0.69490945
0
Returns whether or not the argument is a string (either a "str" or "unicode")
def _is_string(arg): return isinstance(arg, types.StringTypes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def typeIsString(obj):\n return type(obj) is str or _haveTypeUnicode and type(obj) is unicode", "def is_string(atype):\n if atype == str:\n return True\n elif PY2:\n if atype == unicode:\n return True\n return False", "def is_string(value):\n return isinstanc...
[ "0.85439533", "0.8531232", "0.85032046", "0.8458424", "0.8457038", "0.8448985", "0.84387064", "0.84377694", "0.84271085", "0.82765406", "0.82513785", "0.8241974", "0.8218465", "0.81970197", "0.81306636", "0.81137633", "0.8081129", "0.80713755", "0.7998069", "0.7932523", "0.78...
0.9257119
0
Returns whether or not the argument is a list. This means that it's an instance of a sequence, but not including the string types
def _is_list(arg): return isinstance(arg, collections.Sequence) and not _is_string(arg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_list ( self, s ):\r\n\t\treturn isinstance ( s, type( list () ) )", "def is_list_of(seq, expected_type):\n return is_seq_of(seq, expected_type, seq_type=list)", "def _is_list(item):\n return isinstance(item, list)", "def _is_list(val):\n\n return isinstance(val, list)", "def is_sequence_o...
[ "0.83214027", "0.81061", "0.8065349", "0.79083794", "0.7902992", "0.78376174", "0.78361946", "0.78166515", "0.7780776", "0.7772325", "0.7759591", "0.77538717", "0.7664642", "0.7664073", "0.7621871", "0.7563922", "0.75465405", "0.7468648", "0.73699504", "0.73252976", "0.728769...
0.90609455
0
Look up the given name in the given list of scopes. Returns the default value if the name is not defined in any of the scopes.
def _lookup_in_scopes(name, scopes, default=None): assert name assert scopes is not None # We iterate over the items in the scope (rather than using 'get') # so we can do a case-insensitive lookup. name_lower = name.lower() for scope in scopes: for key, value in scope.items(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup(scopes, name):\n # type: (Scopes[T], str) -> Optional[T]\n\n for scope in scopes:\n for key, val in scope:\n if key == name:\n return val\n return None", "def get_by_name(self, name):\n scopes = self._client.get_all()\n result = [x for x in scope...
[ "0.79767394", "0.71245885", "0.6058012", "0.6011732", "0.59649855", "0.5573654", "0.5547338", "0.55172366", "0.54739946", "0.53942615", "0.53553236", "0.53401506", "0.53022784", "0.52925473", "0.52719605", "0.5179497", "0.51721185", "0.5171616", "0.5151544", "0.5137249", "0.5...
0.8805875
0
Helper function for _get_applicable_modes to add any modes for this command
def _add_applicable_modes(command, mode_dict): description_feature = command.get('feature') if description_feature: if not feature.feature_enabled(description_feature): return mode = command.get('mode') if mode: if type(mode) == list: for m in mode: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_applicable_modes(command):\n mode_dict = {}\n _add_applicable_modes(command, mode_dict)\n return mode_dict.keys()", "def append_modes(self,modes):\n self.modes = np.append(self.modes,np.array(modes,dtype=modetype))", "def apply_mode_command(self, channel, command):\n direction, ...
[ "0.753973", "0.71372646", "0.6752454", "0.6620678", "0.6579078", "0.65712893", "0.6447186", "0.6447186", "0.64453655", "0.64104617", "0.64058155", "0.63210326", "0.6265792", "0.61772203", "0.61080694", "0.6099957", "0.6079826", "0.607896", "0.60186535", "0.6015669", "0.600954...
0.87255466
0
Returns a list of all of the modes that are specified for this command
def _get_applicable_modes(command): mode_dict = {} _add_applicable_modes(command, mode_dict) return mode_dict.keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modes(self) -> List[str]:\n return [m.name for m in self._modes]", "def _get_modes(self):\n return self.__modes", "def get_modes(self):\n return self.circuit.get_modes()", "def modes(self):\n return np.hstack(tuple(self.operator.modes))", "def get_modes(self):\n return [i...
[ "0.8445033", "0.82154745", "0.80214876", "0.7829724", "0.78250915", "0.7822188", "0.7747393", "0.7696896", "0.7645572", "0.75551045", "0.75231206", "0.745426", "0.7388421", "0.73145664", "0.72621864", "0.7185098", "0.71638507", "0.71492827", "0.7133864", "0.7105226", "0.70994...
0.82162344
1
Return True when this command_mode is an exact match for this current mode (used to partition list of commands into two groups, one exact level, and for for related mode matches)
def _exact_mode_match(current_mode, command_modes): if not type(command_modes) == list: command_modes = [command_modes] for mode in command_modes: if mode == current_mode: return True if mode.endswith('*') and mode[:-1] == current_mode: return True return Fals...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _match_current_modes(command, current_mode, modes):\n if current_mode in modes:\n return True\n #\n # if the modes is enable, this works everywhere\n #\n if 'login' in modes:\n return True\n #\n # if the modes is login, and the mode is anything but login,\n # then this is ...
[ "0.7462347", "0.60965776", "0.5913109", "0.57950515", "0.5736853", "0.5670262", "0.5664345", "0.5632514", "0.5624758", "0.5591398", "0.5580854", "0.5562407", "0.5527055", "0.5523893", "0.54978305", "0.5474427", "0.5451625", "0.54250956", "0.5420091", "0.54136974", "0.5408295"...
0.81015956
0
Even when the current mode isn't in the list of modes, there's a few modes in the mode list which are intended to
def _match_current_modes(command, current_mode, modes): if current_mode in modes: return True # # if the modes is enable, this works everywhere # if 'login' in modes: return True # # if the modes is login, and the mode is anything but login, # then this is true # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_modes(self):\n return self.__modes", "def mode(self):\r\n pass", "def mode(self) -> Mode:\n ...", "def __check_mode(self):\n self.mode[\"auto_mode\"] = self.communications.get_mode()", "def mode(self, mode: Optional[int] = None) -> Optional[int]:\n ...", "def cmd_m...
[ "0.74098396", "0.7371424", "0.7287743", "0.70694387", "0.7034376", "0.69173056", "0.6859695", "0.6854071", "0.68327373", "0.68093693", "0.68080527", "0.68073785", "0.6804063", "0.6792828", "0.67795384", "0.6770016", "0.67179525", "0.6708704", "0.6704747", "0.66946924", "0.668...
0.6675021
21
Returns the list of command candidates from the given command list. A candidate must have a 'mode' value that matches the current mode, and its name must begin with the given command prefix.
def _lookup_command_candidates(command_prefix, command_list): candidates = [] current_mode = bigsh.run.finder.mode_stack.current_mode() try: for command in command_list: modes = _get_applicable_modes(command) if _match_current_modes(command, current_mode, modes): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matching_commands(self, command_word, is_no_command, command_list):\n candidates = []\n current_mode = bigsh.run.finder.mode_stack.current_mode()\n command_word_lower = command_word.lower()\n\n try:\n for command in command_list:\n # If this command is ...
[ "0.6808836", "0.6215403", "0.60658646", "0.59883577", "0.5964308", "0.59415025", "0.58491945", "0.584738", "0.57828355", "0.57461345", "0.5679819", "0.5637294", "0.56194764", "0.56044847", "0.5591293", "0.5573114", "0.55270916", "0.5516119", "0.5515833", "0.55114114", "0.5507...
0.86891496
0
Opens a new database connection if there is none yet for the current application context.
def get_db(): top = _app_ctx_stack.top if not hasattr(top, 'sqlite_db'): top.sqlite_db = sqlite3.connect(app.config['DATABASE']) top.sqlite_db.row_factory = sqlite3.Row return top.sqlite_db
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db", "def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)", "def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec...
[ "0.7738929", "0.7583458", "0.7317899", "0.7169646", "0.70223415", "0.69680053", "0.6955745", "0.6949704", "0.68988895", "0.6843065", "0.6830136", "0.68184245", "0.68068093", "0.6795719", "0.6770086", "0.67619467", "0.67508566", "0.6747435", "0.6732536", "0.67013234", "0.66885...
0.6672212
26
Closes the database again at the end of the request.
def close_database(exception): top = _app_ctx_stack.top if hasattr(top, 'sqlite_db'): top.sqlite_db.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_request():\n db.close()", "def close(self):\n\t\tself.db.close()", "def close(self):\n self.db.close()", "def close(self):\n if getattr(self, \"_db\", None):\n self._db.close()\n self._db = None", "def close(self):\n self._flush()\n self.databa...
[ "0.82172483", "0.8109686", "0.7960271", "0.7959435", "0.79532206", "0.79365206", "0.79365206", "0.79365206", "0.78534675", "0.7839457", "0.78294516", "0.77948606", "0.7794269", "0.76857483", "0.766378", "0.76578975", "0.7632097", "0.7593259", "0.7591888", "0.7591824", "0.7581...
0.0
-1
Creates the database tables.
def init_db(): with app.app_context(): db = get_db() with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_db_tables():\n\n try:\n webapp.dbsql.create_all()\n webapp.dbsql.session.commit()\n except Exception as e:\n # TODO: melhorar o ...
[ "0.91241604", "0.91241604", "0.8920711", "0.8715738", "0.8659642", "0.8593035", "0.85459346", "0.84720796", "0.8466383", "0.8454938", "0.84451497", "0.8281925", "0.82708716", "0.8220735", "0.82034945", "0.81462497", "0.8125565", "0.8086544", "0.80096585", "0.79545003", "0.790...
0.0
-1
Queries the database and returns a list of dictionaries.
def query_db(query, args=(), one=False): cur = get_db().execute(query, args) rv = cur.fetchall() return (rv[0] if rv else None) if one else rv
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict_query(self) -> list:\n return [row.to_dict() for row in self.all()]", "def get_query(query):\n global database\n res = database.conn.execute(query)\n out = res.fetchall()\n return [dict(zip(i.keys(), i)) for i in out]", "async def db_query(self, *args, **kwargs):\n rows = []\n...
[ "0.740623", "0.73176324", "0.7065287", "0.70045894", "0.6963166", "0.6914262", "0.6902726", "0.68810415", "0.68354386", "0.6817908", "0.67895174", "0.67873615", "0.6780232", "0.67508334", "0.6716449", "0.6702382", "0.6694209", "0.6687523", "0.6651072", "0.6647847", "0.6639653...
0.0
-1
Convenience method to look up the id for a username.
def get_user_id(username): rv = query_db('select user_id from user where username = ?', [username], one=True) return rv[0] if rv else None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(self, username):\n\n users_list = self.get_list()\n for user_info in users_list:\n if user_info['username'] == username:\n return user_info['id']\n # return None\n raise UserNotFoundException(\"User {0} not found\".format(username))", "def user_id_...
[ "0.83481854", "0.79321814", "0.7773568", "0.7773353", "0.7484976", "0.7484976", "0.7484976", "0.7456012", "0.7427511", "0.7414133", "0.7376001", "0.73518324", "0.73131895", "0.7263178", "0.71839017", "0.7131035", "0.7069776", "0.70134205", "0.70006573", "0.692825", "0.6890176...
0.73150337
13
Format a timestamp for display.
def format_datetime(timestamp): return datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d @ %H:%M')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _format_ts(cls, timestamp):\n return localtime(timestamp).strftime('%Y-%m-%d %H:%M:%S')", "def formatTimestamp(self, timestamp):\n return time.strftime('%Y%m%d-%H%M%S-%Z', time.localtime(timestamp))", "def render_timestamp(timestamp):\n return datetime.fromtimestamp(timestamp).strftime(\"%...
[ "0.83113927", "0.8024185", "0.78500414", "0.7596884", "0.7578498", "0.7574983", "0.7447329", "0.743664", "0.7395809", "0.73817986", "0.727902", "0.71649474", "0.7120334", "0.70975757", "0.70693433", "0.7055185", "0.698", "0.698", "0.6962262", "0.6930938", "0.69197065", "0.6...
0.7109238
15
Shows a users leaderboard for modeling contest. If not logged in then forward user to contest description.
def defaultlanding(): #send user to description page if not logged in if not g.user: return redirect(url_for('description')) #display leaderboard for competition if logged in return redirect(url_for('leaderboard'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leaderboard():\n # Get leaderboard and user information\n leaderboard, current_user_info = gdb.getleaderboard(current_user.userID)\n # Get top gainer leaderboards\n weektopgainers, monthtopgainers = gdb.gettopgainers()\n # Render template\n return render_template('leaderboard.html',\n ...
[ "0.7132831", "0.6990279", "0.698829", "0.6592735", "0.6456158", "0.63978505", "0.63156646", "0.62179524", "0.61793965", "0.61651367", "0.6143687", "0.6069071", "0.6069068", "0.6031999", "0.60070384", "0.5922585", "0.5920286", "0.5916132", "0.5897987", "0.5893534", "0.5756729"...
0.6577176
4
Displays a markdown doc describing the predictive modeling contest. Note ./content/contest/.md must be modified for contest.
def description(): #rule = request.url_rule #print(rule) file = open('./contest/content/description.md', 'r') rawText = file.read() file.close() content = Markup(markdown(rawText, extensions=['markdown.extensions.fenced_code', 'markdown.extensions.tables'])) return render_template('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markov_story():\n return render_template(\"markovstory.html\")", "def evaluation():\n file = open('./contest/content/evaluation.md', 'r')\n rawText = file.read()\n file.close()\n content = Markup(markdown(rawText, \n extensions=['markdown.extensions.fenced_code', 'markdown.extensions.ta...
[ "0.6716274", "0.61918634", "0.61094517", "0.6046048", "0.5814884", "0.57651407", "0.5678175", "0.56608206", "0.56433624", "0.5626179", "0.56228733", "0.5610109", "0.5568798", "0.5550789", "0.5529062", "0.55206585", "0.54883075", "0.546363", "0.54536027", "0.54217476", "0.5419...
0.6056569
3
Displays a markdown doc describing the predictive modeling contest. Note ./content/contest/.md must be modified for contest.
def evaluation(): file = open('./contest/content/evaluation.md', 'r') rawText = file.read() file.close() content = Markup(markdown(rawText, extensions=['markdown.extensions.fenced_code', 'markdown.extensions.tables'])) return render_template('markdowntemplate.html', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markov_story():\n return render_template(\"markovstory.html\")", "def show_story():\n print(story)\n ans = request.args\n mad_story = story.generate(ans)\n return render_template(\"story.html\", story=mad_story)", "def description():\n #rule = request.url_rule\n #print(rule)\n file ...
[ "0.6715872", "0.6109959", "0.605513", "0.60453767", "0.58141357", "0.5764724", "0.56801903", "0.56615716", "0.564484", "0.5626134", "0.56238323", "0.560941", "0.5568852", "0.55506897", "0.55294514", "0.552025", "0.54897755", "0.54637724", "0.54536664", "0.54208964", "0.541954...
0.6191105
1
Displays a markdown doc describing the predictive modeling contest. Note ./content/contest/.md must be modified for contest.
def rules(): file = open('./contest/content/rules.md', 'r') rawText = file.read() file.close() content = Markup(markdown(rawText, extensions=['markdown.extensions.fenced_code', 'markdown.extensions.tables'])) return render_template('markdowntemplate.html', title=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markov_story():\n return render_template(\"markovstory.html\")", "def evaluation():\n file = open('./contest/content/evaluation.md', 'r')\n rawText = file.read()\n file.close()\n content = Markup(markdown(rawText, \n extensions=['markdown.extensions.fenced_code', 'markdown.extensions.ta...
[ "0.6716376", "0.61918926", "0.61108327", "0.60579824", "0.6045585", "0.581355", "0.57638925", "0.5676026", "0.56627285", "0.5643063", "0.56268203", "0.562448", "0.5607453", "0.55694515", "0.5551792", "0.5530864", "0.5521991", "0.54890364", "0.5463644", "0.5454346", "0.5422025...
0.5060308
51
Displays a markdown doc describing the predictive modeling contest. Note ./content/contest/.md must be modified for contest.
def data(): file = open('./contest/content/data.md', 'r') rawText = file.read() file.close() content = Markup(markdown(rawText, extensions=['markdown.extensions.fenced_code', 'markdown.extensions.tables'])) return render_template('markdowntemplate.html', title='D...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markov_story():\n return render_template(\"markovstory.html\")", "def evaluation():\n file = open('./contest/content/evaluation.md', 'r')\n rawText = file.read()\n file.close()\n content = Markup(markdown(rawText, \n extensions=['markdown.extensions.fenced_code', 'markdown.extensions.ta...
[ "0.67163235", "0.61921257", "0.6109971", "0.60564226", "0.60465986", "0.5814859", "0.576513", "0.5678197", "0.56455314", "0.5626489", "0.56233984", "0.56087315", "0.5568962", "0.5550528", "0.55295354", "0.55203474", "0.5489993", "0.54648334", "0.54543287", "0.5421151", "0.541...
0.5661878
8
Displays a markdown doc describing the predictive modeling contest. Note ./content/contest/.md must be modified for contest.
def prizes(): file = open('./contest/content/prizes.md', 'r') rawText = file.read() file.close() content = Markup(markdown(rawText, extensions=['markdown.extensions.fenced_code', 'markdown.extensions.tables'])) return render_template('markdowntemplate.html', titl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markov_story():\n return render_template(\"markovstory.html\")", "def evaluation():\n file = open('./contest/content/evaluation.md', 'r')\n rawText = file.read()\n file.close()\n content = Markup(markdown(rawText, \n extensions=['markdown.extensions.fenced_code', 'markdown.extensions.ta...
[ "0.6716274", "0.61918634", "0.61094517", "0.6056569", "0.6046048", "0.5814884", "0.57651407", "0.5678175", "0.56608206", "0.56433624", "0.5626179", "0.56228733", "0.5610109", "0.5568798", "0.5550789", "0.5529062", "0.55206585", "0.54883075", "0.546363", "0.54536027", "0.54217...
0.0
-1
Allow user to select the upload they'd like to use for submission Default selection should be most recent submissions
def select_model(): try: #check if contest has ended if contestEndBool(): flash("Error: contest has ended") raise Exception("contest has ended") input = request.form print(str(input)) for count, x in enumerate(input): print(count, x) if len(inp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_file_upload_method():\n\n if not Settings.prompt(\"upload files\"): \n return \"unset\"\n Settings.print(\"Select an upload source\")\n sources = Settings.get_source_options()\n question = {\n 'type': 'list',\n 'name': 'upload',\n '...
[ "0.5997314", "0.5983872", "0.589526", "0.576531", "0.5642785", "0.5381244", "0.5381244", "0.5363477", "0.5341594", "0.5295605", "0.5283472", "0.5279332", "0.5256086", "0.5177524", "0.5163761", "0.5152573", "0.5134435", "0.51217484", "0.5096993", "0.50757486", "0.5058516", "...
0.6039245
0
Allow users to upload submissions to modeling contest Users must be logged in.
def upload_file(): #query the db and render the table used to display the leaderboard to users userBoard = query_db(''' select submission_id, submit_date, public_score from submission sub where user_id = '%s' order by public_score %s''' % (session['user_id'], orderBy)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_allowed_to_submit(request):\n return not settings.REQUIRE_LOGIN or request.user.is_authenticated()", "def test_access_cartography_upload_form(self):\n\t\tc = Client()\n\t\tUser.objects.create_superuser('bobby', 'bobby@foo.com', 'bob')\n\t\tlog = c.login(username='bobby', password='bob')\n\t\tself.asser...
[ "0.6346095", "0.6128161", "0.60236895", "0.5991602", "0.59610605", "0.58730686", "0.57726794", "0.57536113", "0.573331", "0.5728953", "0.5707575", "0.56958395", "0.5684615", "0.5650055", "0.56336886", "0.562404", "0.5591402", "0.55805683", "0.5559244", "0.5558897", "0.5550839...
0.5735105
8
Displays the latest messages of all users.
def public_timeline(): return render_template('timeline.html', messages=query_db(''' select message.*, user.* from message, user where message.author_id = user.user_id order by message.pub_date desc limit ?''', [PER_PAGE]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list(request):\r\n usermessages = request.user.profile.recent_messages()\r\n d = {\r\n 'form': NewMessageForm(),\r\n 'usermessages': usermessages,\r\n 'title': 'Messages',\r\n }\r\n return render_to_response('usermessages/list.html', d, \r\n context_instance=RequestConte...
[ "0.7695993", "0.7487634", "0.6752437", "0.67180043", "0.6717233", "0.6611216", "0.6601907", "0.6523693", "0.6414698", "0.6396658", "0.6388416", "0.63542783", "0.63322663", "0.6324767", "0.6306849", "0.63036233", "0.6260323", "0.62598145", "0.6252585", "0.6237499", "0.621526",...
0.68704623
3
Logs the user in.
def login(): if g.user: return redirect(url_for('leaderboard')) error = None if request.method == 'POST': user = query_db('''select * from user where username = ?''', [request.form['username']], one=True) if user is None: error = 'Invalid username' eli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_in(self):\n\t\tpass", "def log_in(self):\n print('-=' * 12 + \" Log in \" + '-=' * 12)\n mob_num, password = self._input_mob_num('Mobile Number :'), input(\"Password: \")\n self._user = self.auth.log_in(mob_num, password)\n if self._user:\n print(\"you are logged in...
[ "0.79675275", "0.7852267", "0.7533633", "0.7426753", "0.74120265", "0.73694736", "0.73554826", "0.7352218", "0.73194534", "0.73194534", "0.72863114", "0.72628456", "0.71599513", "0.7111777", "0.70810497", "0.70796275", "0.7071781", "0.70487857", "0.70274097", "0.7014469", "0....
0.0
-1
Logs the user out.
def logout(): flash('You were logged out') session.pop('user_id', None) return redirect(url_for('leaderboard'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out_user(self):\n flask_login.logout_user()", "def sign_out(self):\n self.auth.log_out(self._user)\n self._user = None\n print(\"Signed out successfully\")\n return self.logging_page()", "def logOut(self):\n self.client.logout()", "def logout_user():\n pas...
[ "0.85989505", "0.8412849", "0.8397216", "0.8393396", "0.82630706", "0.8261279", "0.82022554", "0.81415004", "0.81156605", "0.80973995", "0.80543846", "0.8053196", "0.804197", "0.79746354", "0.79651797", "0.7959803", "0.789355", "0.78747684", "0.78555274", "0.78462565", "0.783...
0.7539114
55
Find the minimum number of edits required to convert str_1 to str_2
def edit_distance(str_1, str_2): return edit_distance_dp(str_1, len(str_1), str_2, len(str_2))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def editing_distance(str1: str, str2: str) -> int:\r\n if not str1 and not str2:\r\n return 0\r\n if not str1:\r\n return len(str2)\r\n if not str2:\r\n return len(str1)\r\n if str1[0] == str2[0]:\r\n return min(editing_distance(str1[1::], str2[1::]), 1 + editing_distance(st...
[ "0.78606004", "0.7667521", "0.7666502", "0.7485708", "0.7342039", "0.7078117", "0.7051589", "0.7030334", "0.7002312", "0.6992367", "0.68882006", "0.68589854", "0.68285865", "0.6781553", "0.67763644", "0.6762268", "0.6755266", "0.66761094", "0.66730696", "0.665412", "0.663446"...
0.7184663
5
Find the minimum number of edits required to convert str_1 to str_2
def edit_distance_dp(str_1, m, str_2, n): # table for storing sub-problems sub = [[0 for i in range(n + 1)] for j in range(m + 1)] # padded for empty cases # fill table for i in range(m + 1): for j in range(n + 1): if i == 0: # str_1 is empty, or we have not selecte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def editing_distance(str1: str, str2: str) -> int:\r\n if not str1 and not str2:\r\n return 0\r\n if not str1:\r\n return len(str2)\r\n if not str2:\r\n return len(str1)\r\n if str1[0] == str2[0]:\r\n return min(editing_distance(str1[1::], str2[1::]), 1 + editing_distance(st...
[ "0.78606004", "0.7667521", "0.7666502", "0.7485708", "0.7342039", "0.7184663", "0.7078117", "0.7051589", "0.7030334", "0.7002312", "0.6992367", "0.68882006", "0.68589854", "0.68285865", "0.67763644", "0.6762268", "0.6755266", "0.66761094", "0.66730696", "0.665412", "0.663446"...
0.6781553
14
Collapses input of dim TNH to (TN)H, and applies to a module. Allows handling of variable sequence lengths and minibatch sizes.
def __init__(self, module): super(SequenceWise, self).__init__() self.module = module
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def H_layer(nqubits):\n for idx in range(nqubits):\n qml.Hadamard(wires=idx)", "def H_layer(self, nqubits):\n for idx in range(nqubits):\n qml.Hadamard(wires=idx)", "def build_model(hype_space):\n print(\"Hyperspace:\")\n print(hype_space)\n\n input = Input(shape=(MAXLEN_SE...
[ "0.5513121", "0.5469915", "0.52214915", "0.521163", "0.5186334", "0.5182777", "0.51315635", "0.49392486", "0.4894024", "0.48866612", "0.48558587", "0.4839549", "0.48389077", "0.4814754", "0.48115247", "0.47978458", "0.47978264", "0.47797433", "0.47725466", "0.47584283", "0.47...
0.0
-1
Splice multiple frames. Helpful for implementing Time Delayed Neural Network (TDNN).
def __init__(self, context, full_context=False, batch_first=True, keep_dims=False): super(Splice, self).__init__() self.check_valid_context(context) self.context = self.normalize_context(context, full_context) self.batc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delace(self):\n if not self.isdelaced:\n newframes = []\n self.frame_dt /= 2\n for i, frame in enumerate(self.frames):\n newframes.append(\n Frame(\n frame.data[1::2, :],\n self.starttime\n ...
[ "0.6003755", "0.5650122", "0.55415636", "0.5539786", "0.55298394", "0.5410173", "0.52612764", "0.5251893", "0.52402836", "0.5198621", "0.517389", "0.5163097", "0.512419", "0.51004255", "0.5084766", "0.50782037", "0.5070901", "0.50673556", "0.50505686", "0.5041725", "0.5038684...
0.49631998
25
Download Reistijden GeoJSON and save it to the database.
def download_and_update(): with tempfile.TemporaryDirectory(dir=TEMP_DOWNLOAD_DIR) as temp_dir: reistijden_jsonfile = os.path.join(temp_dir, 'reistijdenAmsterdam.geojson') r = requests.get(REISTIJDEN_TARGET_URL) with open(reistijden_jsonfile, 'w') as f: f.write(r.text) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_geojson():\n\n # check the file was already downloaded\n global GEOJSON\n if GEOJSON: return GEOJSON\n\n conn = None\n cur = None\n try:\n\n conn = utils.pgconnect(**settings.DEFAULT_CONNECTION)\n cur = conn.cursor()\n cur.execute( \"\"\"SELECT row_to_json(fc) FROM...
[ "0.65090847", "0.6401234", "0.629521", "0.62839437", "0.6232702", "0.61436486", "0.6100601", "0.60972625", "0.5967515", "0.5946081", "0.5935013", "0.5935013", "0.58112276", "0.5717537", "0.5706458", "0.5656695", "0.5588673", "0.55623233", "0.55592436", "0.55287975", "0.552224...
0.751995
0
Parse source GeoJSON with travel times.
def _parse_and_store_geojson(filename): ds = DataSource(filename) _sanity_check_datasource(ds) logger.info('Data file %s was opened', ds.name) lm = LayerMapping(WegStuk, ds, MAPPING) with transaction.atomic(): WegStuk.objects.all().delete() lm.save(strict=True, verbose=False) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(res):\n res=res[0]\n steps = []\n if not isinstance(res, dict):\n return {}\n\n for step in res[\"legs\"][0][\"steps\"]:\n instruction = re.sub('<[^<]+?>', '', step[\"html_instructions\"])\n distance = step[\"distance\"][\"text\"]\n duration = step[\"duration\"][\"...
[ "0.5746532", "0.54747635", "0.5376057", "0.53146565", "0.52925307", "0.5279979", "0.52677", "0.5224246", "0.5183527", "0.51704335", "0.5142615", "0.51053476", "0.5066675", "0.5046991", "0.5043811", "0.50331575", "0.502856", "0.5015569", "0.50040835", "0.49954006", "0.49932897...
0.5041001
15
Hardcoded sanity checks, assumes input GeoJSON does not change.
def _sanity_check_datasource(ds): if len(ds) != 1: raise SanityCheckError('GeoJSON should have only 1 layer.') # TODO: add more checks
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_geojson(data):\n \"\"\"Enforces camelcasing of properties\"\"\"\n if 'id' in data:\n del data['id']\n try:\n data['type'] = data['type'] if 'type' in data else \"Feature\"\n data['geometry'] = data['geometry'] if 'geometry' in data else None\n if 'properties' not in ...
[ "0.7562509", "0.7042181", "0.66670763", "0.6600149", "0.64749795", "0.64165884", "0.6416432", "0.6386212", "0.6275836", "0.61825293", "0.61635286", "0.6162776", "0.609787", "0.6077802", "0.60744584", "0.5965066", "0.5861117", "0.58045316", "0.580073", "0.57666594", "0.5733157...
0.69514114
2
At this point it is completely built and ready to be fired; it is "prepared". However pay attention at the formatting used in this function because it is programmed to be pretty printed and may differ from the actual request.
def pretty_print_POST(req): print('{}\n{}\n{}\n\n{}'.format( '-----------START-----------', req.method + ' ' + req.url, '\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()), req.body, ))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare(self, request):\n pass", "def prepare(self):\n\t\treturn self.api.prepare_request(self)", "def _prepare(self):", "def _prepare(self):", "def prepare(self):", "def prepare(self):\n pass", "def prepare(self):\n pass", "def prepare(self):\n pass", "async def pre...
[ "0.66846484", "0.6565005", "0.6478224", "0.6478224", "0.6324114", "0.60384876", "0.60384876", "0.60384876", "0.6034071", "0.5947664", "0.5901407", "0.5881416", "0.58444005", "0.5784762", "0.5779519", "0.57518095", "0.5715669", "0.5696821", "0.5693568", "0.5689683", "0.5686989...
0.0
-1
Scrieti o functie care returneaza numarul de cuvinte din string. Cuvintele sunt separate de spatii, semne de punctuatie (, ;, ? ! . ).
def nrWords(text): list = text.replace(',', ' ').replace('.', ' ').replace(';', ' ') list = list.replace('!', ' ').replace('?', ' ').split() return len(list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_punct(self,text):", "def get_nummeric_only(text):\n\n nummeric_string =\"\"\n \n for character in text:\n if character.isnumeric():\n \n nummeric_string+=character\n \n return nummeric_string", "def remove_punctuation(string):\n return NON_AL...
[ "0.62161505", "0.61967057", "0.6113026", "0.60086334", "0.59861207", "0.5784456", "0.57690686", "0.57293624", "0.5693772", "0.56806844", "0.56788987", "0.56788987", "0.56788987", "0.5674587", "0.56661344", "0.5631285", "0.5630559", "0.5609727", "0.56001705", "0.5596847", "0.5...
0.0
-1
Return the XPath from node a to node b, assumes b is a descendant of a.
def xpath(a, b): if a.isSameNode(b): return "" return xpath(a, b.parentNode) + "/" + b.localName
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_path8(self):\n xpb = XPathBuilder()\n xp_1 = xpb.foo.baz\n xp_2 = xpb.bar.abc.join(xp_1)\n exp = '/bar/abc/foo/baz'\n self.assertEqual(xp_1, xp_2)\n self.assertEqual(xp_2.tostring(), exp)", "def get_xpath(tag_name: str, parent, suffix = ''):\n xpath =...
[ "0.5497289", "0.5488446", "0.5398042", "0.53868425", "0.5333837", "0.5326444", "0.53179765", "0.5249903", "0.5121286", "0.5086263", "0.5082444", "0.5056868", "0.50500554", "0.5035871", "0.5035871", "0.49958196", "0.49624732", "0.49436888", "0.49340647", "0.49328429", "0.49323...
0.8103554
0
Add a label to node's list of children, the XML contained in that label comes from xml_str. We want to make referencing variables easier, maybe using $varname.
def add_label(xml_str, node): if xml_str: s = u'<?xml version="1.0" ?><label>' + xml_str + u"</label>" node.appendChild( parseString(s.encode("utf-8")).documentElement )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, label):\n self.label = label\n self.children = list()", "def addLabels(t):\n if not t.label:\n t.label = \"\".join([choice(\"abcdefghijklmnopqrstuvwxyz\") for i in range(4)])\n for r,w in t.children:\n addLabels(r)", "def __init__(self, label):\n self...
[ "0.64232975", "0.6181848", "0.60131395", "0.5892141", "0.5781065", "0.57423294", "0.5731213", "0.5660578", "0.56166065", "0.5590489", "0.5573439", "0.5515644", "0.5477117", "0.54630226", "0.5416833", "0.5409699", "0.5392758", "0.53465724", "0.5339193", "0.5337083", "0.5324728...
0.71521944
0
Return a dictionary of multiple choice lists from the Excel Worksheet 'sheet'. The Worksheet named 'Select Choices' defines the choices for all multiple choice questions. This sheet must have three
def construct_choice_lists(sheet): d = {} for row in range(1,sheet.nrows): c = {} for col in range(0,sheet.ncols): c[sheet.cell(0,col).value] = sheet.cell(row,col).value list_name = c.pop("list name") if list_name in d: d[list_name].append(c) else:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_menu_options():\n workbook_path = get_workbook_path()\n wb = openpyxl.load_workbook(workbook_path)\n sheet_names = wb.sheetnames\n return sheet_names", "def get_sheet_data(self) -> List[SheetData]:\n result: List[SheetData] = []\n\n for c in range(self.columnCount() - 1):\n s = Sh...
[ "0.60501075", "0.575098", "0.5318569", "0.53165835", "0.5285447", "0.52561027", "0.52561027", "0.52561027", "0.52561027", "0.52438134", "0.51110536", "0.50920993", "0.50747657", "0.5074488", "0.5042221", "0.5003982", "0.49192867", "0.49099895", "0.4886586", "0.48812103", "0.4...
0.7654838
0
Convert a properly formatted excel file into XForms for use with Open Data Kit. Return a list of all the XForms created.
def write_xforms(xls_file_path): xforms = [] workbook = open_workbook(xls_file_path) folder = os.path.dirname(xls_file_path) choice_sheet = "Select Choices" choices = construct_choice_lists( workbook.sheet_by_name(choice_sheet) ) for sheet in workbook.sheets(): if sheet.name != choice...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_xlsx_sheet(f, n=0):\n xl_file = pd.ExcelFile(f)\n dfs = xl_file.parse(xl_file.sheet_names[n], na_values=['n.a.', 'n.d.'])\n return dfs", "def read_xlsx(self, filename):\n xlsx = pd.ExcelFile(filename)\n for sheet in xlsx.sheet_names:\n table_index_header = cfg.get_list...
[ "0.5343978", "0.52173615", "0.5207813", "0.5159541", "0.5144205", "0.5137643", "0.51044893", "0.50839716", "0.506976", "0.5050417", "0.5023947", "0.4986781", "0.49759924", "0.49596763", "0.4947392", "0.49413222", "0.49334276", "0.49067864", "0.48902297", "0.4873562", "0.48344...
0.6615536
0
Replace all instances of '${tag}' with the XPath corresponding to the tag.
def sub_tag(str): bracketed_tag = r"(\${" + tag_start_char + tag_char + r"*})" m = re.search(bracketed_tag, str) if m: tag = m.group(1) tag = tag[2:len(tag)-1] if tag not in tag_xpath: rai...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_tag(tag, value, file):\r\n with open(file, \"r\") as origin:\r\n with open(file+\".replaced\", \"w\") as dest:\r\n dest.write(origin.read().replace(tag, str(value)))\r\n return file+\".replaced\"", "def replace_tag_value( msg, tag, value ) :\n _TAG_RE = re.compile('\\x01' +...
[ "0.5578515", "0.5398839", "0.53104943", "0.5310126", "0.5291188", "0.5275091", "0.52065635", "0.51992667", "0.5098113", "0.5070617", "0.5046198", "0.5034003", "0.4993068", "0.49627715", "0.4956388", "0.49514914", "0.4910291", "0.48976448", "0.4868524", "0.4832289", "0.4815513...
0.581539
0
execute multiplication and division immediately.
def _exec_md(self, stack, operand): if stack and stack[-1] in {'*', '/'}: operator, v = stack.pop(), stack.pop() if operator == "*": stack.append(v * operand) else: stack.append(v // operand) else: stack.append(operand) return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mul(a, b):\n c = Calculator()\n result = c.mul(a, b)\n click.echo('{} * {} = {}'.format(a, b, result))", "def multiplication():\r\n error_handler()\r\n f1.delete(0, END)\r\n m1 = float(operand.get())\r\n m2 = float(operator.get())\r\n result = m1 * m2\r\n f1.insert(10, str(result))...
[ "0.64342624", "0.61805516", "0.60382664", "0.60203797", "0.59576017", "0.5952465", "0.5950916", "0.59389263", "0.5899231", "0.58606964", "0.5821872", "0.581016", "0.57954544", "0.5795213", "0.5795213", "0.5795213", "0.5795213", "0.5795213", "0.5763967", "0.5756619", "0.575159...
0.55101085
55
execute plus and minus at the end of all parsed.
def _exec_pm(self, stack): rslt = stack.popleft() while stack: operator, operand = stack.popleft(), stack.popleft() if operator == "+": rslt += operand else: # operator == "-" rslt -= operand return rslt
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_substract_and_sum(numbers, operators):\n while len(numbers) > 1:\n if operators[0] == \"+\": \n result = calc.sum(numbers[0], numbers[1])\n elif operators[0] == \"-\":\n result = calc.substract(numbers[0], numbers[1])\n operators, numbers = change_list_elemen...
[ "0.5932352", "0.57771915", "0.5509978", "0.5507815", "0.545019", "0.53565687", "0.53443295", "0.52802455", "0.527417", "0.525476", "0.5217023", "0.5186919", "0.5115234", "0.5087408", "0.5062166", "0.5044847", "0.50009185", "0.49736407", "0.49415055", "0.49372658", "0.49316794...
0.5188196
11
Return a list of level seeds for a given gamekey
def ajax_levelseeds(request, gamekey): seed_lst = tools.getLevelSeedsFromGameKey(gamekey) data_response = { "data": seed_lst, "status": "OK" } return HttpResponse(json.dumps(data_response), content_type="application/json")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_game_levels(self):\n\n self._katakana_database.create_katakana_database_connection()\n\n raw_game_levels = self._katakana_database.katakana_db.execute(\n \"\"\"SELECT game_level FROM Games\"\"\").fetchall()\n\n all_game_levels = []\n for i in raw_game_levels:\n ...
[ "0.5885322", "0.5726993", "0.5407367", "0.5301738", "0.5284191", "0.5212815", "0.50632656", "0.50508773", "0.505008", "0.5045081", "0.4962722", "0.49233738", "0.488766", "0.4876195", "0.486169", "0.48457703", "0.4844681", "0.482408", "0.4821691", "0.47913313", "0.4763049", ...
0.5952363
0
register a user on the fly because i hate users in django
def ajax_register(request, username, password): user = User.objects.create_user(username, "", password) if not user: status = "ERROR" message = "Invalid username or password" else: user.save() status = "OK" message = str.format("Created user '{0}', you may login now", username) response = { "status": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_user():\n pass", "def user_register():\n \n data = user_obj.user_register(request.forms) \n return data", "def register_user(self):\n User.add_user(User(self.email.data, self.password.data))", "def signup(self, request, user):\n pass", "def register(user_...
[ "0.8530308", "0.78690624", "0.7817005", "0.75655466", "0.74967426", "0.7426039", "0.7367931", "0.7360617", "0.73598593", "0.7309681", "0.72699374", "0.7269463", "0.7240562", "0.7205366", "0.7192249", "0.71875334", "0.71837413", "0.7179749", "0.71564066", "0.7136671", "0.71356...
0.0
-1
log a death in the database
def ajax_died(request, game_id, user_id, depth, reason): myGame = tools.getGameFromGameId(int(game_id)) myUser = tools.getUserFromUserId(int(user_id)) tools.logDeath(myGame, myUser, int(depth), str(reason)) response = { "status": "OK", "message": "logged death" } return HttpResponse(json.dumps(response), c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_death(self, state):", "def die(self):\n events.trigger_event(\"on_entity_death\", self)", "def record_death(self, name):\n self.log.info('{0} has died'.format(name))\n self.health_panels[name].set_dead()\n self.conversation.removeKnowledge('{0}-alive'.format(name))\n s...
[ "0.72399086", "0.701081", "0.67726815", "0.6647561", "0.662502", "0.65819335", "0.64344263", "0.62199175", "0.6132314", "0.60777444", "0.59452045", "0.59283155", "0.5908845", "0.5903316", "0.5892717", "0.5827417", "0.5791009", "0.5779763", "0.5734716", "0.56824976", "0.568101...
0.0
-1
log a win in the database
def ajax_victory(request, game_id): myGame = tools.getGameFromGameId(int(game_id)) tools.logVictory(myGame) response = { "status": "OK", "message": "logged victory" } return HttpResponse(json.dumps(response), content_type="application/json")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(self, game: str, outcome: str):\n current_time = datetime.now()\n self.user.record.append([current_time.strftime(\"%c\"), game, outcome, self.user.balance])", "def event_player_wins(self) -> None:\n win_amount = self.user.bet\n print(\"Congratulations, you win:\", win_amount)\...
[ "0.67273533", "0.6163771", "0.6120701", "0.6114181", "0.6078899", "0.6041982", "0.6039192", "0.6013895", "0.5989878", "0.5979451", "0.5954383", "0.5947308", "0.59428173", "0.5881893", "0.5870078", "0.58621216", "0.5859779", "0.5834164", "0.57967937", "0.5786986", "0.5754396",...
0.0
-1
log level progress for stat keeping
def ajax_progress(request, game_id, user_id, depth): myGame = tools.getGameFromGameId(int(game_id)) myUser = tools.getUserFromUserId(int(user_id)) tools.logProgress(myGame, myUser, int(depth)) response = { "status": "OK", "message": "logged progress" } return HttpResponse(json.dumps(response), content_type...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _log_progress(self):\n self.num_of_requests_in_pipeline += 1\n if self.num_of_requests_in_pipeline % 20 == 0:\n print('-' * 200)\n print(f'DB PIPELINE: {self.num_of_requests_in_pipeline} items wenth though pipeline.')\n print('-' * 200)", "def transfer_progress(...
[ "0.714131", "0.71269464", "0.70470834", "0.69629145", "0.6934919", "0.6782616", "0.67440385", "0.6740498", "0.6710249", "0.6569314", "0.65626985", "0.6546168", "0.6487", "0.64472675", "0.64472675", "0.6433927", "0.6432851", "0.64311254", "0.64308006", "0.64246374", "0.6358968...
0.0
-1
Main function This is the flow of actions of this main
def main(argv): # 0: Initial steps print_configuration_info() # fix random seed for reproducibility np.random.seed(7) # Make an instance of the class Utils utils = Utils() # Obtain the file number maxnumber = utils.find_file_maxnumber(RESULTS + DATASET + '/') filenumber = ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(self):\r\n pass", "def main(self):", "def main(self) -> None:\n pass", "def main():\n pass", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():",...
[ "0.8427905", "0.8220689", "0.8114415", "0.80345976", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", "0.80257344", ...
0.0
-1
Dummy function to print configuration parameters expressed as global variables in the script
def print_configuration_info(): print("Selected dataset:", DATASET) print("Dataset base directory:", BASE_INPUT_DIR) print("Daytime option:", DAYTIME) print("Nones option:", NONES) print("Selected action/activity representation:", OP) print("Number of epochs: ", EPOCHS) prin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printConf(self):\n print \"\"\n for pname, pvalue in self.neededParams.items():\n print pname, pvalue\n for pname, pvalue in self.optionalParams.items():\n print pname, pvalue", "def printSettings():\n print \">>>\\n>>> SettingsTool: global variables:\"\n for ...
[ "0.7461699", "0.7036818", "0.70333016", "0.6937575", "0.6927378", "0.6777318", "0.6775346", "0.6666382", "0.6586468", "0.6535474", "0.64919525", "0.6467023", "0.6425723", "0.64183", "0.64038175", "0.6391235", "0.63494974", "0.6276289", "0.62646157", "0.62633955", "0.6179124",...
0.6767941
7
Solve the discrete algebraic ricatti equation to compute the optimal feedback.
def sda_estimate(A, B, Q, R): X = sda(A, B, Q, R) K = np.linalg.inv(R + B.T @ X @ B) @ B.T @ X @ A return -K
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaltr(x_solution): \n \n large = 10.0**30\n pred = np.zeros(cfg.ntrain)\n e0 = 0.0 # mean of observed values\n y=0.0\n for i in range(cfg.ntrain): # Computation of correct piece\n e0 += cfg.a_unscaled[i][-1]\n pind = 0\n ipbest = ...
[ "0.61143297", "0.6101354", "0.6066659", "0.6060728", "0.603991", "0.6005973", "0.59834266", "0.5945585", "0.5919671", "0.5912027", "0.5907284", "0.586913", "0.58657324", "0.58402", "0.5801388", "0.57696843", "0.5769187", "0.5742733", "0.5734056", "0.5726234", "0.56925076", ...
0.0
-1
Solve A^T P A P + Q = 0
def solve_discrete_lyapunov(A, Q, method=None): # newer versions of scipy solve A P A^T - P + Q = 0, # while older ones solve A^T P A - P + Q = 0. I do not # remember exactly which version of scipy made the change. # I am going to assume you have the newer version installed. # If the assertion bel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve(P, Q):\n L = cho_factor(P)\n return cho_solve(L, Q)", "def sol_p(t, p0, s0, u0, alpha, beta, gamma, eta, delta):\n u = sol_u(t, u0, alpha, beta)\n s = sol_s(t, s0, u0, alpha, beta, gamma)\n exp_gt = np.exp(-delta * t)\n p = p0 * exp_gt + eta / (delta - gamma) * (\n s - s0 * exp...
[ "0.7112369", "0.6747462", "0.67439276", "0.6622388", "0.6503022", "0.63728845", "0.6270085", "0.6223849", "0.6211934", "0.6202324", "0.61933964", "0.61361104", "0.61264217", "0.60995156", "0.6012261", "0.6007698", "0.5980388", "0.5958294", "0.5952482", "0.5946611", "0.5936482...
0.621849
8
Compute infinite time horizon average LQR cost. Returns 1e6 if A+BK is not stable
def LQR_cost(A, B, K, Q, R, sigma_w): L = A + B.dot(K) if spectral_radius(L) >= 1: return 1e6 M = Q + K.T.dot(R).dot(K) P = solve_discrete_lyapunov(L, M) return (sigma_w ** 2) * np.trace(P)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lksprob(alam):\r\n fac = 2.0\r\n sum = 0.0\r\n termbf = 0.0\r\n a2 = -2.0*alam*alam\r\n for j in range(1,201):\r\n term = fac*math.exp(a2*j*j)\r\n sum = sum + term\r\n if math.fabs(term) <= (0.001*termbf) or math.fabs(term) < (1.0e-8*sum):\r\n return sum\r\n ...
[ "0.60029477", "0.5933232", "0.58607453", "0.5827601", "0.57766134", "0.57220405", "0.5690132", "0.5665845", "0.56634825", "0.56570524", "0.5628769", "0.5604078", "0.55918825", "0.5588187", "0.5571809", "0.55503905", "0.55435735", "0.55359924", "0.5530741", "0.55281013", "0.55...
0.6573204
0
Solve for K recursively. Not used.
def estimate_K(self, horizon, A, B): Q, R = self.Q, self.R # Calculate P matrices first for each step P_matrices = np.zeros((horizon + 1, Q.shape[0], Q.shape[1])) P_matrices[horizon] = Q for i in range(horizon - 1, 0, -1): P_t = P_matrices[i + 1] P_matrices[i] = Q + (A.T @ P_t @ A) -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterate(rk):\n y = scipy.sparse.linalg.spsolve(P1, rk)\n RHS = scipy.sparse.csr_matrix.dot(P4, y) + rk\n zk = scipy.sparse.linalg.spsolve(P3, RHS)\n return zk", "def fn(n, k):\n if n == k: return 1\n if k == 0: return 0\n return ((n-1)*fn(n-1, k) +...
[ "0.65435326", "0.6303995", "0.62335324", "0.6223404", "0.61771244", "0.61697197", "0.6146142", "0.6124515", "0.61158085", "0.6081433", "0.60603875", "0.60549337", "0.6022816", "0.6015567", "0.60017824", "0.5987519", "0.59837985", "0.59735906", "0.5944474", "0.59432894", "0.59...
0.0
-1
Solve the discrete time lqr controller. x[k+1] = A x[k] + B u[k] cost = sum x[k].TQx[k] + u[k].TRu[k]
def dlqr(A,B,Q=None,R=None): #ref Bertsekas, p.151 if Q is None: Q = np.eye(A.shape[0]) if R is None: R = np.eye(B.shape[1]) P = scipy.linalg.solve_discrete_are(A, B, Q, R) K = -scipy.linalg.solve(B.T.dot(P).dot(B) + R, B.T.dot(P).dot(A), sym_pos=True) A_c = A + B.dot(K) TO...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LQRStep(n_state,\n n_ctrl,\n T,\n u_lower=None,\n u_upper=None,\n u_zero_I=None,\n delta_u=None,\n linesearch_decay=0.2,\n max_linesearch_iter=10,\n true_cost=None,\n true_dynamics=None,\n d...
[ "0.6856822", "0.67716205", "0.6512035", "0.63664174", "0.6199675", "0.6168004", "0.6133567", "0.6129773", "0.6099672", "0.6093726", "0.6058491", "0.5990289", "0.59402376", "0.58544946", "0.58435804", "0.58374304", "0.58292556", "0.58270043", "0.58121234", "0.58121234", "0.581...
0.0
-1
Check that the observability matrix is full rank. We check this by using the standard condition that [C CA CA^2 . . . CA^{n1}] is full rank
def check_observability(A, C): assert len(A.shape) == 2 dim = A.shape[0] stack = [] for i in range(dim): term = C @ np.linalg.matrix_power(A, i) stack.append(term) obs_grammian = np.vstack(stack) return np.linalg.matrix_rank(obs_grammian) == dim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _board_is_full(self):\n return (self.get_counts()[0] + self.get_counts()[1] == self._num_rows * self._num_cols)", "def fullGrid(state):\n return not ((state[:, :, 0] + state[:, :, 1]) == 0).any()", "def is_full_row_rank(G):\n assert len(G.shape) == 2, \"should be a 2d numpy arrayp\"\n rows ...
[ "0.58528364", "0.575484", "0.570392", "0.5627623", "0.5623395", "0.5601164", "0.5532206", "0.5532206", "0.5532206", "0.5532206", "0.5505377", "0.5505377", "0.5463339", "0.54319173", "0.542496", "0.5393358", "0.53866196", "0.5373487", "0.5358698", "0.535044", "0.53352785", "...
0.62513566
0
Check that the controllability matrix [B, BA, ..., BA^{n1}] is full rank
def check_controllability(A, B): assert len(A.shape) == 2 dim = A.shape[0] stack = [] for i in range(dim): term = B @ np.linalg.matrix_power(A, i) stack.append(term) grammian = np.hstack(stack) return np.linalg.matrix_rank(grammian) == dim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _board_is_full(self):\n return (self.get_counts()[0] + self.get_counts()[1] == self._num_rows * self._num_cols)", "def fullGrid(state):\n return not ((state[:, :, 0] + state[:, :, 1]) == 0).any()", "def check_grid_full(self):\n for row in self.game_state:\n for e in row:\n ...
[ "0.64367396", "0.6185774", "0.61180735", "0.6107293", "0.61059", "0.6050762", "0.6046627", "0.6046486", "0.59971195", "0.5967931", "0.59551543", "0.5925763", "0.59230703", "0.59230703", "0.59198326", "0.5916389", "0.58971936", "0.5856238", "0.5807457", "0.58016616", "0.579588...
0.67005306
0
Returns a random dim x dim matrix with top eigenvalue bounded by bound dim
def sample_matrix(dim, bound): return np.random.uniform(low=-bound, high=bound, size=(dim, dim))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_biggest_eigenvalue(cls, covariance_matrix):\n timer = TimerHandler()\n timer.start(\"eigen2\")\n eigvals = scipy.linalg.eigh(covariance_matrix, \n eigvals_only = True, \n eigvals = (covariance_matrix.shape[0] -1,...
[ "0.5875326", "0.5783161", "0.5597876", "0.5518314", "0.54774606", "0.53589374", "0.53341335", "0.52804285", "0.52785826", "0.52338797", "0.52313197", "0.52312946", "0.52151245", "0.5212694", "0.5212556", "0.5212227", "0.5209878", "0.52093714", "0.52040935", "0.5180018", "0.51...
0.59177387
0