query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Try to move 1 customer to anywhere it can be put, and see if the move can cut the total cost.
def shift_1_cust(self, sol_in1, cust, c_loc, curr_temp, sol_type1, sa_lns): route_ing = copy.deepcopy(sol_in1[c_loc[0]]) route_new = route_ing move_to_route = c_loc[0] orgn_type1 = sol_type1[c_loc[0]] origin_cost1 = check_violation(route_ing, orgn_type1)[1] route_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_3_cust(self, sol_in6, cust, c_loc, curr_temp, sol_type6, sa_lns):\r\n\r\n route_ing = copy.deepcopy(sol_in6[c_loc[0]])\r\n route_new = route_ing\r\n move_to_route = c_loc[0]\r\n orgn_type1 = sol_type6[c_loc[0]]\r\n cust_folw1 = route_ing[c_loc[1] + 1]\r\n cust_fo...
[ "0.6117333", "0.60589105", "0.5994203", "0.59595776", "0.5953622", "0.5933493", "0.59228426", "0.5878984", "0.58387893", "0.5838295", "0.58261937", "0.5800863", "0.5800339", "0.5784758", "0.5716828", "0.5699591", "0.5699348", "0.5658605", "0.563691", "0.5607451", "0.5571733",...
0.6281938
0
Try to move 2 consecutive customers to anywhere they can be put, see if they move can cut the total cost.
def shift_2_cust(self, sol_in2, cust, c_loc, curr_temp, sol_type2, sa_lns): route_ing = copy.deepcopy(sol_in2[c_loc[0]]) route_new = route_ing move_to_route = c_loc[0] orgn_type1 = sol_type2[c_loc[0]] cust_folw = route_ing[c_loc[1]+1] origin_cost1 = check_violatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_1_cust(self, sol_in1, cust, c_loc, curr_temp, sol_type1, sa_lns):\r\n\r\n route_ing = copy.deepcopy(sol_in1[c_loc[0]])\r\n route_new = route_ing\r\n move_to_route = c_loc[0]\r\n orgn_type1 = sol_type1[c_loc[0]]\r\n origin_cost1 = check_violation(route_ing, orgn_type1)[1...
[ "0.63458234", "0.6205083", "0.5944662", "0.5919286", "0.58585805", "0.5844579", "0.5750275", "0.5711178", "0.56468445", "0.56443506", "0.56095916", "0.5584599", "0.5448591", "0.5444054", "0.5442395", "0.54375905", "0.54311484", "0.5415993", "0.53907067", "0.53784865", "0.5372...
0.6756745
0
Try to move 3 consecutive customers to anywhere they can be put, see if they move can cut the total cost.
def shift_3_cust(self, sol_in6, cust, c_loc, curr_temp, sol_type6, sa_lns): route_ing = copy.deepcopy(sol_in6[c_loc[0]]) route_new = route_ing move_to_route = c_loc[0] orgn_type1 = sol_type6[c_loc[0]] cust_folw1 = route_ing[c_loc[1] + 1] cust_folw2 = route_ing[c_l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movable_intraroute_customers(route, customers):\n mcust = []\n for c in range(route.ncustomers):\n if len(factible_route_positions(route.customers[c+1],\n route,customers)) > 1:\n mcust.append(c)\n return mcust", "def exchange_1_cust(self, sol...
[ "0.6071524", "0.60635555", "0.6033704", "0.58507174", "0.5694917", "0.54907", "0.54892546", "0.54756105", "0.54441667", "0.54237115", "0.539738", "0.5397061", "0.53634334", "0.5358302", "0.53474575", "0.53194606", "0.528759", "0.52711314", "0.525795", "0.52506185", "0.5243177...
0.67974746
0
Exchange the position of two customers(same route or not) if feasible, and see if it can cut the total cost.
def exchange_1_cust(self, sol_in3, cust, c_loc, curr_temp, sol_type3, sa_lns): route_ing = copy.deepcopy(sol_in3[c_loc[0]]) route_new_1 = route_ing route_new_2 = route_ing exch_to_route = c_loc[0] orgn_type1 = sol_type3[exch_to_route] origin_cost1 = check_violat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exchange_2_cust(self, sol_in4, cust, c_loc, curr_temp, sol_type4, sa_lns):\r\n\r\n route_ing = copy.deepcopy(sol_in4[c_loc[0]])\r\n route_new_1 = route_ing\r\n route_new_2 = route_ing\r\n cust_folw = route_ing[c_loc[1] + 1]\r\n exch_to_route = c_loc[0]\r\n origin_cost1...
[ "0.69025654", "0.6613349", "0.6586741", "0.64510596", "0.61748725", "0.60695565", "0.583845", "0.5822859", "0.57592994", "0.56153905", "0.55894005", "0.5581832", "0.55210274", "0.55059487", "0.54630905", "0.54596806", "0.54371494", "0.5428905", "0.53805614", "0.5376348", "0.5...
0.6756957
1
Exchange 2 consecutive customers' position with another 2 customers' position, and see if it can cut cost.
def exchange_2_cust(self, sol_in4, cust, c_loc, curr_temp, sol_type4, sa_lns): route_ing = copy.deepcopy(sol_in4[c_loc[0]]) route_new_1 = route_ing route_new_2 = route_ing cust_folw = route_ing[c_loc[1] + 1] exch_to_route = c_loc[0] origin_cost1 = check_violation(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_2_cust(self, sol_in2, cust, c_loc, curr_temp, sol_type2, sa_lns):\r\n\r\n route_ing = copy.deepcopy(sol_in2[c_loc[0]])\r\n route_new = route_ing\r\n move_to_route = c_loc[0]\r\n orgn_type1 = sol_type2[c_loc[0]]\r\n cust_folw = route_ing[c_loc[1]+1]\r\n origin_cos...
[ "0.63171464", "0.6038648", "0.6019486", "0.5787042", "0.5624252", "0.5611005", "0.5577099", "0.5519468", "0.54916805", "0.54847175", "0.5430665", "0.54237324", "0.5396291", "0.53698677", "0.5358428", "0.5347584", "0.53337723", "0.53297913", "0.5312368", "0.5293557", "0.528052...
0.6249691
1
creation du fichier xml de destination ecriture de la phrase d'entete xml fermeture fichier
def creer_fichier(nom_file): fichier = open(nom_file, 'w') fichier.write("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n") fichier.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saving_file(xml):\r\n\r\n xml_string = etree.tostring(xml)\r\n parsed = minidom.parseString(xml_string)\r\n with open(self.app_path + \"\\\\temp_\\\\\" + file_name + \".xml\", \"w\") as file:\r\n file.write(parsed.toprettyxml(indent=\" \"))", "def create...
[ "0.6573223", "0.6557936", "0.6554724", "0.6526124", "0.64474225", "0.6354408", "0.6259751", "0.6257362", "0.62307924", "0.61982656", "0.61907524", "0.618365", "0.61595833", "0.61466527", "0.61005646", "0.6085232", "0.6055169", "0.6042117", "0.6034879", "0.59065783", "0.590543...
0.7440519
0
Solves the given system of |equations|. |equations| should be a list of lists of terms summing to 0. Each term should be a tuple of the form (coeff, var), where coeff is a number and var is a variable (string). Constants can be represented by (const, None). Returns a dictionary mapping the variables in the equations to...
def solve_equations(equations): # variables in the system of equations var_list = list(reduce(set.union, (set(var for coeff, var in eqn if var) for eqn in equations))) # number of variables num_vars = len(var_list) # the index of each variable in |var_list| var_index = dict(zip(var_list, range(num_var...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve_solvableEquations(equations: List):\n solvedEquations = []\n updatedUnknowns = set()\n\n for equation in equations:\n equation.update()\n if equation.isSolvable():\n solution = equation.solve()\n unknownAddress = list(solution.keys())[0]\n setattr_f...
[ "0.64777213", "0.6045988", "0.5746843", "0.5743898", "0.54364383", "0.54286045", "0.53808516", "0.5295969", "0.52503586", "0.5218554", "0.51738834", "0.51685405", "0.51086473", "0.5097052", "0.50915754", "0.50875384", "0.50407755", "0.50407755", "0.5009267", "0.49932858", "0....
0.80595094
0
Gives default department by checking if present in the context
def get_default_department_id(self, cr, uid, context=None): user_obj = self.pool.get('res.users').browse(cr,uid,uid).employee_ids if user_obj: dept_id = self.pool.get('res.users').browse(cr,uid,uid).employee_ids[0].department_id and self.pool.get('res.users').browse(cr,uid,uid).employee_id...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def department(self):\n if \"department\" in self._prop_dict:\n return self._prop_dict[\"department\"]\n else:\n return None", "def department(self):\n if \"department\" in self._prop_dict:\n return self._prop_dict[\"department\"]\n else:\n ...
[ "0.727264", "0.727264", "0.6299022", "0.62791663", "0.6205959", "0.6025972", "0.59099317", "0.58730555", "0.5781836", "0.5762072", "0.57508874", "0.5684379", "0.5670995", "0.564136", "0.5601505", "0.5576277", "0.5553041", "0.55370617", "0.5526694", "0.55206823", "0.5495728", ...
0.8002562
0
Parsed content of Config file into Dictionary [client] > becomes primarykey with values as what follows host="host" user="un" > becomes secondary keyvalues password="pw" > becomse secondary keyvalues port="port"
def load_config_file(cfgFile): with open(cfgFile) as f: content = f.readlines() cfg = {} primary_key = 0 # has primary key been discovered (the string enclosed in bracket in config file) for line in content: if primary_key: if '=' in line: kv = line.split('=')...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_dict_from_file(self, **kwargs):\r\n\r\n if not self.linux_handle.download(local_file='ipsec.conf', remote_file=self.conf_path, protocol='scp'):\r\n self.linux_handle.log(\"Downloading ipsec.conf file failed\")\r\n raise Exception(\"Downloading ipsec.conf file failed \")\r\n...
[ "0.6369596", "0.62699383", "0.62197447", "0.61826915", "0.61255795", "0.608884", "0.6068326", "0.60656905", "0.605204", "0.60274327", "0.60231185", "0.5968226", "0.5899399", "0.58986956", "0.5892832", "0.5862461", "0.585229", "0.57795405", "0.5766491", "0.5755049", "0.5753591...
0.6799325
0
Loads sql statments in sql_fn and replaces variables based on supplied var_replace dictionary SQL statements are returned as string
def read_sql(sql_fn,var_replace): with open(sql_fn,'r') as sql: sql_stmts = sql.read() for key in var_replace: sql_stmts = sql_stmts.replace(key,var_replace[key]) return sql_stmts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_sql_from_file(conn, path, replace={}):\n with open(path, 'r') as f:\n query = [s.strip() + ';' for s in f.read().split(';')[:-1]]\n for s in query:\n for k, v in replace.items():\n s = s.replace(k, v)\n run_sql_from_string(conn, s)", "def replace_para...
[ "0.6825659", "0.6823968", "0.65025157", "0.6472315", "0.6245375", "0.6126365", "0.6013925", "0.59643203", "0.5952251", "0.5904826", "0.58467245", "0.5834276", "0.5786407", "0.575063", "0.57417893", "0.57417893", "0.5704225", "0.56946456", "0.5686", "0.56783825", "0.5657021", ...
0.8187875
0
Tells if the target is newer than the source. Return true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Return false if both exist and 'target' is the same age or younger than 'source'. Raise DistutilsFileError if 'source' does not exist.
def newer(source, target): if not os.path.exists(source): raise DistutilsFileError("file '%s' does not exist" % os.path.abspath(source)) if not os.path.exists(target): return True return os.stat(source).st_mtime > os.stat(target).st_mtime
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newer (source, target):\r\n\r\n if not os.path.exists (target):\r\n return 1\r\n\r\n from stat import ST_MTIME\r\n mtime1 = os.stat(source)[ST_MTIME]\r\n mtime2 = os.stat(target)[ST_MTIME]\r\n\r\n return mtime1 > mtime2", "def newer_group(sources, target, missing='error'):\n # If the...
[ "0.8297187", "0.7296959", "0.7276083", "0.71889526", "0.69265825", "0.67073405", "0.6665101", "0.65951735", "0.6554066", "0.6270341", "0.6233283", "0.62098014", "0.61658466", "0.6140355", "0.6124453", "0.6110864", "0.60843563", "0.5883249", "0.5821825", "0.58091307", "0.57776...
0.88327926
0
Sets the platform string identifier returned by get_platform(). Note that this change doesn't impact the value returned by sysconfig.get_platform() and is local to Distutils
def set_platform(identifier): global _PLATFORM _PLATFORM = identifier
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setPlatform(self):\n\t\treturn None", "def platform(self, platform):\n # type: (string_types) -> None\n\n if platform is not None:\n if not isinstance(platform, string_types):\n raise TypeError(\"Invalid type for `platform`, type has to be `string_types`\")\n\n ...
[ "0.7211347", "0.7159676", "0.7013561", "0.6954458", "0.68570656", "0.6601686", "0.6520827", "0.6483991", "0.64623207", "0.64623207", "0.64210874", "0.6305744", "0.6305564", "0.6298814", "0.6271021", "0.62246704", "0.6183877", "0.60754293", "0.6066876", "0.6018605", "0.596566"...
0.81388736
0
Return 'pathname' as a name that will work on the native filesystem. i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them...
def convert_path(pathname): if os.sep == '/': return pathname if not pathname: return pathname if pathname[0] == '/': raise ValueError("path '%s' cannot be absolute" % pathname) if pathname[-1] == '/': raise ValueError("path '%s' cannot end with '/'" % pathname) path...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _path(unix_path):\n return unix_path.replace(\"/\", os.path.sep)", "def normalized_file_path(path: str) -> str:\n # Convert Unix path to Windows path for WSL\n if PLATFORM == \"WSL\":\n return path.replace(\"/\", \"\\\\\")\n\n return path", "def nt_path_to_posix_path(path):\r\n path =...
[ "0.67207557", "0.6290176", "0.6238237", "0.6112074", "0.61115247", "0.606076", "0.5939797", "0.5932711", "0.59231985", "0.58520925", "0.58230126", "0.57967067", "0.5790922", "0.57871675", "0.57529", "0.57496727", "0.57496727", "0.5720282", "0.5685239", "0.566036", "0.56340814...
0.68549985
0
Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.
def change_root(new_root, pathname): if os.name == 'posix': if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: return os.path.join(new_root, pathname[1:]) elif os.name == 'nt': (drive, path) = os.path.splitdrive(pathname) if pat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addPathPrefix(prefix, pathname):\n new_pathname = os.path.join(os.path.dirname(pathname), prefix + os.path.basename(pathname))\n return new_pathname", "def makepath(plname,root):\n if (root.endswith('/') and not plname[0] =='/' ) or ( not root.endswith('/') and plname[0] =='/') :\n return ro...
[ "0.6437045", "0.59677273", "0.5884409", "0.57894766", "0.5737389", "0.56540275", "0.5632758", "0.560187", "0.55786604", "0.55463153", "0.54867226", "0.5479389", "0.5465328", "0.5434634", "0.5426187", "0.5377088", "0.5376396", "0.52881503", "0.5265455", "0.5238494", "0.5189643...
0.77424914
0
Ensure that 'os.environ' has all the environment variables needed. We guarantee that users can use in config files, commandline options,
def check_environ(): global _environ_checked if _environ_checked: return if os.name == 'posix' and 'HOME' not in os.environ: import pwd os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] if 'PLAT' not in os.environ: os.environ['PLAT'] = _sysconfig.get_platform() _en...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_environment():\n reqs = ['NAME', 'RECIPIENT', 'SUBJECT', 'MESSAGE',\n 'MAILGUN_API_KEY', 'MAILGUN_DOMAIN']\n for req in reqs:\n if not os.getenv(req):\n logging.error('Environment variable ' + req + ' is not set')\n sys.exit(2)", "def _check_env():\n\tif o...
[ "0.7685037", "0.768269", "0.74665606", "0.7349859", "0.72101486", "0.7192757", "0.7188985", "0.7085273", "0.6954072", "0.692295", "0.6899005", "0.68856543", "0.6869819", "0.68643546", "0.68599814", "0.68545455", "0.68270725", "0.6821289", "0.6815573", "0.6815573", "0.6815573"...
0.8246562
0
Perform shell/Perlstyle variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guarantee that it cont...
def subst_vars(s, local_vars): check_environ() def _subst(match, local_vars=local_vars): var_name = match.group(1) if var_name in local_vars: return str(local_vars[var_name]) else: return os.environ[var_name] try: return re.sub(r'\$([a-zA-Z_][a-zA-Z_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand_vars(string, env_vars=None):\n if env_vars is None:\n env_vars = os.environ\n # create a replacement callback function that uses env_vars as it's first\n # argument, additional arguments will be added after it\n repl_callback = functools.partial(_var_repl, env_vars)\n return re.sub...
[ "0.7734589", "0.73284125", "0.6958385", "0.62611526", "0.61794424", "0.61206144", "0.6119231", "0.5942183", "0.5825754", "0.5727875", "0.5716061", "0.56829596", "0.56288034", "0.56126416", "0.56008154", "0.5499839", "0.5496333", "0.5489837", "0.54745865", "0.5474001", "0.5453...
0.8150585
0
Generate a useful error message from an EnvironmentError. This will generate an IOError or an OSError exception object. Handles Python 1.5.1 and 1.5.2 styles, and does what it can to deal with exception objects that don't have a filename (which happens when the error is due to a twofile operation, such as 'rename()' or...
def grok_environment_error(exc, prefix="error: "): # check for Python 1.5.2-style {IO,OS}Error exception objects if hasattr(exc, 'filename') and hasattr(exc, 'strerror'): if exc.filename: error = prefix + "%s: %s" % (exc.filename, exc.strerror) else: # two-argument functi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exception_message():\n def get_os_release():\n \"\"\"Returns detailed OS release.\"\"\"\n if platform.linux_distribution()[0]:\n return \" \".join(platform.linux_distribution())\n elif platform.mac_ver()[0]:\n return \"%s %s\" % (platform.mac_ver()[0], platform.mac...
[ "0.6228609", "0.61467487", "0.6119618", "0.6091069", "0.6041068", "0.6019442", "0.60053355", "0.60053355", "0.60053355", "0.59858197", "0.59780866", "0.59780866", "0.59780866", "0.59780866", "0.59780866", "0.59780866", "0.59780866", "0.59780866", "0.5958574", "0.59230393", "0...
0.79304963
0
Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else.
def strtobool(val): val = val.lower() if val in ('y', 'yes', 't', 'true', 'on', '1'): return 1 elif val in ('n', 'no', 'f', 'false', 'off', '0'): return 0 else: raise ValueError("invalid truth value %r" % (val,))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strtobool(val: str) -> int:\n val = val.lower()\n if val in (\"y\", \"yes\", \"t\", \"true\", \"on\", \"1\"):\n return 1\n elif val in (\"n\", \"no\", \"f\", \"false\", \"off\", \"0\"):\n return 0\n else:\n raise ValueError(\"invalid truth value %r\" % (val,))", "def str_to_b...
[ "0.81975126", "0.8017742", "0.78834474", "0.78206813", "0.77842885", "0.77564293", "0.75404084", "0.7537402", "0.7356985", "0.73436004", "0.7292158", "0.7287533", "0.7237012", "0.72188634", "0.72188634", "0.7196758", "0.7194048", "0.71899515", "0.71899515", "0.71899515", "0.7...
0.81308395
1
Bytecompile a collection of Python source files to either .pyc or .pyo files in the same directory. 'py_files' is a list of files to compile; any files that don't end in
def byte_compile(py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None): # nothing is done if sys.dont_write_bytecode is True if hasattr(sys, 'dont_write_bytecode') and sys.dont_write_bytecode: raise DistutilsByteCompileError('byte-compiling is di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pyo():\n local('python -O -m compileall .')", "def pyo():\n local('python -O -m compileall .')", "def compile_coffeescript(*files):\r\n if not files:\r\n files = [\"`{}`\".format(coffeescript_files())]\r\n sh(cmd(\r\n \"node_modules/.bin/coffee\", \"--compile\", *files\r\n ))",...
[ "0.64949733", "0.64949733", "0.62953174", "0.6256713", "0.61585885", "0.6012568", "0.58619845", "0.58467686", "0.58408356", "0.5704187", "0.56957185", "0.5693709", "0.5662455", "0.5645903", "0.5611024", "0.5549595", "0.55396736", "0.5538459", "0.5522446", "0.5512065", "0.5488...
0.6693471
0
Return a version of the string escaped for inclusion in an RFC822 header, by ensuring there are 8 spaces space after each newline.
def rfc822_escape(header): lines = header.split('\n') sep = '\n' + 8 * ' ' return sep.join(lines)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tidy_string(s: str\n ) -> str:\n s = s.encode('ascii', errors='ignore').decode(FORMAT)\n s = s.replace(\"\\r\", \"\").replace(\"\\t\", \"\").replace('\\n', '') \n return s", "def beautify(text):\n text = re.sub('\\n{3,}', '\\n\\n', text)\n text = re.sub('\\n+$', '\\n', text)\n ...
[ "0.6096191", "0.5934842", "0.59084433", "0.59060633", "0.5887525", "0.5677352", "0.5667074", "0.56499064", "0.56388175", "0.55878687", "0.55177206", "0.5498205", "0.5489415", "0.54656357", "0.5455645", "0.54367644", "0.54303896", "0.5425611", "0.53949904", "0.538119", "0.5353...
0.7909112
0
Finds the ld version. The version scheme differs under Mac OSX.
def _find_ld_version(): if sys.platform == 'darwin': return _find_exe_version('ld -v', _MAC_OS_X_LD_VERSION) else: return _find_exe_version('ld -v')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version():\n # this implementation avoids calling Foundation and will work on\n # non Apple OSes.\n vers = \"UNKNOWN\"\n build = \"\"\n # find the munkilib directory, and the version file\n munkilibdir = os.path.dirname(os.path.abspath(__file__))\n versionfile = os.path.join(munkilibdi...
[ "0.7059902", "0.6503561", "0.64812005", "0.64738697", "0.6416523", "0.6415537", "0.61217123", "0.6084685", "0.6074208", "0.6074208", "0.60129017", "0.60093343", "0.5987961", "0.59856707", "0.593912", "0.59271336", "0.59125006", "0.5905193", "0.58683425", "0.5782932", "0.57724...
0.8556363
0
Find the version of an executable by running `cmd` in the shell. `pattern` is a compiled regular expression. If not provided, default to _RE_VERSION. If the command is not found, or the output does not match the mattern, returns None.
def _find_exe_version(cmd, pattern=_RE_VERSION): from subprocess import Popen, PIPE executable = cmd.split()[0] if find_executable(executable) is None: return None pipe = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) try: stdout, stderr = pipe.stdout.read(), pipe.stderr.read() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version():\n import subprocess\n from tempfile import NamedTemporaryFile\n proc = subprocess.Popen(lm_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n try:\n out, stderr = proc.communicate(timeout=15)\n except TimeoutError:\n proc.kill()\n outs, stderr = proc.commu...
[ "0.6729657", "0.64490074", "0.61166817", "0.58071357", "0.5795342", "0.5723984", "0.5637662", "0.5618396", "0.5613655", "0.55541384", "0.55272096", "0.54937875", "0.5464113", "0.5462051", "0.53953546", "0.5378721", "0.5374339", "0.5371101", "0.53526723", "0.5351424", "0.53498...
0.842616
0
Returns a tuple providing the versions of gcc, ld and dllwrap For each command, if a command is not found, None is returned. Otherwise a string with the version is returned.
def get_compiler_versions(): gcc = _find_exe_version('gcc -dumpversion') ld = _find_ld_version() dllwrap = _find_exe_version('dllwrap --version') return gcc, ld, dllwrap
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_gcc_ver(exe=\"gcc\"):\n cmd = [exe, '-v']\n major = -1\n minor = -1\n patch = -1\n raw = sub.check_output(cmd, stderr=sub.STDOUT).decode('ascii').lower().split('\\n')\n for line in raw:\n if line.startswith('gcc version'):\n tokens = line.split()\n # we obtain...
[ "0.6619813", "0.6580038", "0.64875406", "0.6457868", "0.64217746", "0.63849837", "0.6326838", "0.6278378", "0.624311", "0.61986893", "0.6176207", "0.6146404", "0.60950166", "0.60890126", "0.60757", "0.6046186", "0.60224766", "0.601256", "0.59944826", "0.599008", "0.59763354",...
0.7286158
0
Return true if 'target' is outofdate with respect to any file listed in 'sources'. In other words, if 'target' exists and is newer than every file in 'sources', return false; otherwise return true. 'missing' controls what we do when a source file is missing; the default ("error") is to blow up with an OSError from insi...
def newer_group(sources, target, missing='error'): # If the target doesn't even exist, then it's definitely out-of-date. if not os.path.exists(target): return True # Otherwise we have to find out the hard way: if *any* source file # is more recent than 'target', then 'target' is out-of-date and...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newer(source, target):\n if not os.path.exists(source):\n raise DistutilsFileError(\"file '%s' does not exist\" %\n os.path.abspath(source))\n if not os.path.exists(target):\n return True\n\n return os.stat(source).st_mtime > os.stat(target).st_mtime", "...
[ "0.68539894", "0.6768285", "0.6579951", "0.6263332", "0.6170721", "0.6142411", "0.6040172", "0.60333484", "0.5950948", "0.5950353", "0.5943889", "0.5890367", "0.565034", "0.563318", "0.5581962", "0.5574001", "0.5522218", "0.54946536", "0.5422363", "0.5406527", "0.5402316", ...
0.7944473
0
Returns True if path is a package (a dir with an __init__ file.
def _is_package(path): if not os.path.isdir(path): return False return os.path.isfile(os.path.join(path, '__init__.py'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def IsPackage(path):\n init_base_path = os.path.join(path, '__init__.py')\n return (os.path.isfile(init_base_path) or\n os.path.isfile(init_base_path + 'c') or\n os.path.isfile(init_base_path + 'o'))", "def _is_package(path):\n return (\n os.path.isdir(path)\n and os....
[ "0.9028623", "0.8911071", "0.8911071", "0.8750731", "0.8576869", "0.81681454", "0.803935", "0.76286083", "0.7427226", "0.7406388", "0.6980071", "0.6966034", "0.6936042", "0.6757917", "0.67051244", "0.6700581", "0.6627893", "0.6593783", "0.6561629", "0.6427087", "0.6419333", ...
0.89318365
1
Returns a dotted package name, given a subpath.
def _package_name(root_path, path): if not _under(path, root_path): raise ValueError('"%s" is not a subpath of "%s"' % (path, root_path)) return path[len(root_path) + 1:].replace(os.sep, '.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _resolve_name(name, package, level):\n if not hasattr(package, 'rindex'):\n raise ValueError(\"'package' not set to a string\")\n dot = len(package)\n for x in xrange(level, 1, -1):\n try:\n dot = package.rindex('.', 0, dot)\n except ValueErr...
[ "0.680801", "0.68059653", "0.67358416", "0.67321527", "0.6679984", "0.647044", "0.6385544", "0.6206499", "0.60818356", "0.60691476", "0.60549533", "0.6032795", "0.60183483", "0.60061336", "0.5967444", "0.59654856", "0.59017694", "0.5867805", "0.5845933", "0.5839538", "0.58301...
0.8235141
0
Return a list all Python packages found recursively within directories 'paths' 'paths' should be supplied as a sequence of "crossplatform" (i.e. URLstyle) path; it will be converted to the appropriate local path syntax. 'exclude' is a sequence of package names to exclude; '' can be used as a wildcard in the names, such...
def find_packages(paths=(os.curdir,), exclude=()): packages = [] discarded = [] def _discarded(path): for discard in discarded: if _under(path, discard): return True return False for path in paths: path = convert_path(path) for root, dirs, fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_packages(paths, extensions=['.py', '.ipynb'],\n include_imported_dependencies=False):\n if isinstance(paths, str):\n paths = [paths]\n\n all_packages = set()\n for path in paths:\n if os.path.isfile(path):\n basename, ext = os.path.splitext(path)\n ...
[ "0.7080239", "0.6244361", "0.61578315", "0.6144756", "0.60934895", "0.59585524", "0.59447527", "0.59435344", "0.58972776", "0.58844006", "0.5858805", "0.58424145", "0.5818661", "0.57693875", "0.5734302", "0.57293177", "0.56524205", "0.5640559", "0.5630103", "0.5587548", "0.55...
0.8303452
0
Like os.path.splitext, but take off .tar too
def splitext(path): base, ext = posixpath.splitext(path) if base.lower().endswith('.tar'): ext = base[-4:] + ext base = base[:-4] return base, ext
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_ext(filepath):\n\t(fn, ext) = os.path.splitext(filepath)\n\tif ext=='.gz':\n\t\t(fn, ext) = os.path.splitext(fn)\n\t\text += '.gz'\n\treturn (fn, ext)", "def splitext( filename ):\n index = filename.find('.')\n if index == 0:\n index = 1+filename[1:].find('.')\n if index == -1:\n ...
[ "0.7256462", "0.7026987", "0.68934464", "0.6722942", "0.66994846", "0.66748786", "0.66710615", "0.66696054", "0.66661364", "0.6614728", "0.65565413", "0.6543803", "0.6525695", "0.64786565", "0.645979", "0.64352673", "0.64048153", "0.63310933", "0.6310813", "0.62845665", "0.62...
0.80011797
0
Returns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)
def has_leading_dir(paths): common_prefix = None for path in paths: prefix, rest = split_leading_dir(path) if not prefix: return False elif common_prefix is None: common_prefix = prefix elif prefix != common_prefix: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def areInSamePaths(path1, path2):\n return areSamePaths(os.path.dirname(path1), os.path.dirname(path2))", "def predicate(path):\n p = os.path.abspath(path)\n return any(p == d or p.startswith(d + os.path.sep)\n for d in directories)", "def _verify_prefix(prefix, f...
[ "0.68663764", "0.66934335", "0.6670413", "0.6565162", "0.6515844", "0.6405397", "0.6379137", "0.6338458", "0.6308368", "0.62838936", "0.62717277", "0.6256882", "0.6211285", "0.61961395", "0.6110255", "0.609404", "0.6081909", "0.60518205", "0.6041078", "0.6039395", "0.6034955"...
0.8242421
0
Quote commandline arguments for DOS/Windows conventions. Just wraps every argument which contains blanks in double quotes, and returns a new argument list.
def _nt_quote_args(args): # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, other than spaces, # have to be escaped? Is there an escaping mechanism other than # quo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quote_arguments(args):\n if isinstance(args, str):\n args_list = [args]\n else:\n args_list = args\n\n quoted_args = []\n for a in args_list:\n qa = _double_up_quotes(a)\n if \" \" in qa or \"'\" in qa:\n qa = \"'\" + qa + \"'\"\n quoted_args.append(qa)...
[ "0.727529", "0.7251283", "0.72008514", "0.685263", "0.67948896", "0.6764882", "0.6530536", "0.6420306", "0.637898", "0.63067955", "0.6251415", "0.62015647", "0.6195781", "0.6184979", "0.6129439", "0.6106405", "0.6061542", "0.5926107", "0.5858475", "0.5774904", "0.5765774", ...
0.78102744
0
Creates a default .pypirc file.
def generate_pypirc(username, password): rc = get_pypirc_path() f = open(rc, 'w') try: f.write(DEFAULT_PYPIRC % (username, password)) finally: f.close() try: os.chmod(rc, 0600) except OSError: # should do something better here pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_default_config(self, parser):\n parser.add_section('irc')\n parser.set('irc', 'channels', '')\n \n # create the full path, and the file\n try:\n os.makedirs(self.config_dir_path, mode=0700)\n except OSError:\n pass\n file_resource = ...
[ "0.6558019", "0.62628806", "0.58864355", "0.573295", "0.5716338", "0.5681678", "0.56687874", "0.5664316", "0.5623866", "0.5536374", "0.553043", "0.5503424", "0.5500698", "0.5489507", "0.5476311", "0.54706043", "0.5446161", "0.54202074", "0.5416349", "0.5378271", "0.5377565", ...
0.74003255
0
Wrapper function around the refactor() class which performs the conversions on a list of python files. Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done inplace.
def run_2to3(files, doctests_only=False, fixer_names=None, options=None, explicit=None): #if not files: # return # Make this class local, to delay import of 2to3 from lib2to3.refactor import get_fixers_from_package, RefactoringTool ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _refactor_2to3(self, path):\n # self.logger.debug('Refactoring: %s' % path)\n source, encoding = self.refactoring_tool._read_python_source(path)\n\n source += '\\n' # Silence certain parse errors.\n tree = self.refactoring_tool.refactor_string(source, path)\n return str(tree)...
[ "0.6804691", "0.65736985", "0.6213052", "0.5742118", "0.529011", "0.5283378", "0.5246217", "0.51765335", "0.51484454", "0.51378375", "0.5068919", "0.50683546", "0.50638443", "0.50514895", "0.50448775", "0.4973271", "0.49656966", "0.49321887", "0.49237916", "0.4915581", "0.489...
0.73142666
0
Issues a call to util.run_2to3.
def run_2to3(self, files, doctests_only=False): return run_2to3(files, doctests_only, self.fixer_names, self.options, self.explicit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_2to3(files, doctests_only=False, fixer_names=None, options=None,\n explicit=None):\n\n #if not files:\n # return\n\n # Make this class local, to delay import of 2to3\n from lib2to3.refactor import get_fixers_from_package, Refacto...
[ "0.6248613", "0.6005194", "0.5644888", "0.5473579", "0.54017115", "0.5398377", "0.53385645", "0.5264664", "0.5233024", "0.5117116", "0.5111273", "0.51092243", "0.5096129", "0.5089467", "0.50623655", "0.5041441", "0.504088", "0.50230515", "0.50128806", "0.5006936", "0.49927324...
0.6521159
0
This verifies a vote input is in the allowable range
def voteCheck(number): if number >= MIN_VOTES and number <= MAX_VOTES: return True else: return False number = input("\n\tEnter votes: ")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_vote(age):\n return age >= 18", "def isRangeValid(self) -> bool:\n ...", "def isInRange(val, minv, maxv):\n\treturn val >= minv and val <= maxv", "def _validate_val_range(self, proposal):\n val_range = proposal[\"value\"]\n if len(val_range) != 2:\n raise traitlets....
[ "0.6918635", "0.64611727", "0.6432009", "0.63926494", "0.63070136", "0.6304111", "0.6279981", "0.62616414", "0.62209725", "0.62109786", "0.6138942", "0.6124066", "0.61222", "0.60989904", "0.60964143", "0.60828257", "0.6061203", "0.6046962", "0.60301083", "0.60255885", "0.5988...
0.7730605
0
Replace the ``step()`` method of env with a tracing function that calls callbacks with an events time, priority, ID and its instance just before it is processed.
def trace(self): # noqa # pylint: disable=protected-access,invalid-name def get_wrapper(env_step): """Generate the wrapper for env.step().""" @wraps(env_step) def tracing_step(): # noqa """Call *__monitor* for the next event if one exist before ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tracing_step(): # noqa\n if len(self.__env._queue) > 0:\n t, prio, eid, event = self.__env._queue[0]\n self.__monitor(t, prio, eid, event)\n return env_step()", "def get_wrapper(env_step):\n @wraps(env_step)\n def trac...
[ "0.69365823", "0.6761876", "0.63075596", "0.63075596", "0.6298799", "0.60999227", "0.60761", "0.60579455", "0.6035825", "0.599109", "0.5944866", "0.5925591", "0.5841467", "0.58281803", "0.5821764", "0.5817346", "0.5761727", "0.5733629", "0.56965375", "0.56544715", "0.5641167"...
0.78040206
0
Call __monitor for the next event if one exist before calling ``env.step()``.
def tracing_step(): # noqa if len(self.__env._queue) > 0: t, prio, eid, event = self.__env._queue[0] self.__monitor(t, prio, eid, event) return env_step()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trace(self): # noqa\n\n # pylint: disable=protected-access,invalid-name\n def get_wrapper(env_step):\n \"\"\"Generate the wrapper for env.step().\"\"\"\n @wraps(env_step)\n def tracing_step(): # noqa\n \"\"\"Call *__monitor* for the next event if ...
[ "0.67177457", "0.6353171", "0.61669993", "0.6071973", "0.59611213", "0.5918542", "0.58596504", "0.58400434", "0.58186984", "0.581662", "0.57855827", "0.57379687", "0.5727999", "0.5711669", "0.5704478", "0.567846", "0.567341", "0.5660299", "0.56587714", "0.5639612", "0.5639612...
0.6955955
0
set MHCI Database directory path
def __setMHCI_DB_Path(self, mhcidb_dirname): if not hasattr(self, "mhcIdb_path") or self.mhcIdb_path is None: cwd = self.getCWD() pre_dir, after = cwd.split(mhcidb_dirname) self.mhcIdb_path = self.joinPath(pre_dir,mhcidb_dirname ) print(("# MHCIDB workding path: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_db_file():\n\n return os.path.join(db_path, db_file)", "def get_database_directory(self):\n pass", "def setMHCIDBPath(self, mhcidb_dirname=\"MHCIDB\", data_dir=\"existing_data\"):\n self.__setMHCI_DB_Path(mhcidb_dirname)\n self.mhcIdb_existing_data_path = self.joinPath(self.mhcI...
[ "0.70672226", "0.683271", "0.66077834", "0.6452278", "0.64162743", "0.63795066", "0.62165344", "0.61757326", "0.6167116", "0.61049265", "0.60585093", "0.6023727", "0.60130346", "0.6011672", "0.5975978", "0.5875537", "0.58486605", "0.5841338", "0.5835576", "0.5833521", "0.5804...
0.74962735
0
set MHCIDB working directory path and there existing data
def setMHCIDBPath(self, mhcidb_dirname="MHCIDB", data_dir="existing_data"): self.__setMHCI_DB_Path(mhcidb_dirname) self.mhcIdb_existing_data_path = self.joinPath(self.mhcIdb_path, data_dir) self.mhcIdb_hla_path = self.joinPath(self.mhcIdb_existing_data_path, "hla" ) self.mhcIdb_pdb_path ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __setMHCI_DB_Path(self, mhcidb_dirname):\n if not hasattr(self, \"mhcIdb_path\") or self.mhcIdb_path is None:\n cwd = self.getCWD() \n pre_dir, after = cwd.split(mhcidb_dirname)\n self.mhcIdb_path = self.joinPath(pre_dir,mhcidb_dirname )\n print((\"# MHCIDB wo...
[ "0.7445844", "0.66888374", "0.6555975", "0.64608467", "0.6353928", "0.6310838", "0.6264556", "0.61646134", "0.61341184", "0.60911024", "0.601722", "0.58324337", "0.57763416", "0.5768574", "0.5744997", "0.5684497", "0.56657374", "0.5663596", "0.5662311", "0.5661884", "0.565863...
0.75485724
0
return the path of the file contains the alinged protein seqeuences of HLA gene A, B and C
def get_hla_aligned_seq_fp(self): fn_aln = "ClassI_prot.txt" return self.joinPath(self.mhcIdb_hla_path, fn_aln)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_path(self, protein_id: int):\n protein_name = self.files_refined[protein_id]\n path_protein = os.path.join(\n self.init_refined, protein_name, protein_name + \"_protein.pdb\"\n )\n path_ligand = os.path.join(\n self.init_refined, protein_name, protein_name...
[ "0.6313968", "0.6223646", "0.60979223", "0.6060333", "0.6025667", "0.6019102", "0.5903507", "0.576424", "0.5727223", "0.5694345", "0.5682708", "0.56573516", "0.56486446", "0.56058353", "0.5595129", "0.55100703", "0.54998416", "0.548543", "0.54813707", "0.5469157", "0.5459987"...
0.6534873
0
Sets Driver's node list.
def set_nodes(self, nodes): self._drv_nodes = nodes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodes(self, nodes):\n\n self._nodes = nodes", "def set_node_positions(self):", "def nodes(self, nodes_array):\n self.nodes_set = nodes_array", "def set_node(self, node):\n self.__node = node", "def set_nodes(self, nodes_list):\n try:\n self.node_from = nodes_list[...
[ "0.623272", "0.61300147", "0.58855206", "0.58536756", "0.58154875", "0.57913256", "0.57402974", "0.572732", "0.5669491", "0.5631962", "0.55938464", "0.55284536", "0.5516289", "0.5496053", "0.54852945", "0.54835105", "0.54743034", "0.5465144", "0.54392004", "0.5405577", "0.540...
0.7336902
0
Snapshot an image of the specified instance
def snapshot(self, context, instance, image_id, update_task_state): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snapshot(self, instance, name):\n # TODO(imsplitbit): Need to implement vzdump\n pass", "def get_snapshot(project, zone, instance):\n snapshot_disks(project, zone, *get_disks(instance))", "def take_snapshot(instance_id, objects_created, instance_name=None,\n public=False, ...
[ "0.7108288", "0.6922023", "0.6767384", "0.6702588", "0.6634366", "0.6420016", "0.6365674", "0.63577205", "0.6300057", "0.6296758", "0.62549734", "0.61733276", "0.61012477", "0.60931534", "0.6068985", "0.60444653", "0.5981253", "0.5933683", "0.5925053", "0.59189266", "0.591204...
0.7582861
0
Power off the specified instance.
def power_off(self, instance, timeout=0, retry_interval=0): azure_name = self._get_omni_name_from_instance(instance) utils.stop_instance(self.compute_client, drv_conf.resource_group, azure_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def power_off(self, instance, node=None):\n if not node:\n node = _get_baremetal_node_by_instance_uuid(instance['uuid'])\n pm = get_power_manager(node=node, instance=instance)\n pm.deactivate_node()\n if pm.state != baremetal_states.DELETED:\n raise exception.Insta...
[ "0.8163168", "0.778168", "0.74489874", "0.7349463", "0.7315433", "0.726085", "0.71212804", "0.71180135", "0.7100586", "0.69825584", "0.6973217", "0.69285697", "0.69209427", "0.68579257", "0.6851049", "0.68323034", "0.67938197", "0.67203593", "0.66902196", "0.66892743", "0.663...
0.7834359
1
Azure doesn't support pause and cannot save system state and hence we've implemented the closest functionality which is to poweroff the instance.
def pause(self, instance): self.power_off(instance)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def power_off(self):\n ...", "def suspend(self, context, instance):\n LOG.info(\"Suspending instance %s\" % instance.uuid)\n self.power_off(instance)", "def poweroff(self) -> None:\n pass", "def unpause(self, instance):\n self.power_on(\n context=None,\n ...
[ "0.69178873", "0.6913627", "0.6892047", "0.6817895", "0.67467296", "0.6689266", "0.66683525", "0.6530523", "0.6501536", "0.6460379", "0.6408786", "0.63833135", "0.6374186", "0.6365973", "0.6355397", "0.63161796", "0.6303939", "0.6271553", "0.62554705", "0.6237528", "0.6232611...
0.73265564
0
Azure doesn't support suspend and cannot save system state and hence Azure doesn't support suspend and cannot save system state and hence we've implemented the closest functionality which is to poweroff the instance.
def suspend(self, context, instance): LOG.info("Suspending instance %s" % instance.uuid) self.power_off(instance)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def power_off(self):\n ...", "def poweroff(self) -> None:\n pass", "def powerOff(self):\n self._sendCommand(self.SONY_CMD_ExtBackupCommunicator_ForcePowerOff, bufferSize=0)", "def poweroff(self):\n raise NotImplementedError()", "def power_off(vmname):\n\n _conn.lookupByName(v...
[ "0.6929162", "0.6777848", "0.66953474", "0.66884506", "0.66733646", "0.6653961", "0.6581523", "0.65645", "0.6513084", "0.6512412", "0.6495168", "0.64791274", "0.6453871", "0.6394145", "0.62952673", "0.62936836", "0.6290737", "0.62712413", "0.62297374", "0.6217458", "0.6208989...
0.70598346
0
Since Azure doesn't support resume and we cannot save system state, Since Azure doesn't support resume and we cannot save system state, we've implemented the closest functionality which is to power on the instance.
def resume(self, context, instance, network_info, block_device_info=None): LOG.info("Resuming instance %s" % instance.uuid) self.power_on(context, instance, network_info, block_device_info)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def power_on(self, context, instance, network_info, block_device_info):\n azure_name = self._get_omni_name_from_instance(instance)\n utils.start_instance(self.compute_client, drv_conf.resource_group,\n azure_name)", "def power_on(vmname):\n\n _conn.lookupByName(vmname...
[ "0.6904723", "0.6538291", "0.64492124", "0.6384998", "0.6321347", "0.62968606", "0.62499666", "0.62253034", "0.6220497", "0.6195912", "0.6123734", "0.6116155", "0.6062253", "0.6062095", "0.6025022", "0.5974641", "0.59555715", "0.5953936", "0.5952198", "0.5934965", "0.5905421"...
0.73453075
0
Return data about VM diagnostics.
def get_diagnostics(self, instance): # Fake diagnostics return { 'cpu0_time': 17300000000, 'memory': 524288, 'vda_errors': -1, 'vda_read': 262144, 'vda_read_req': 112, 'vda_write': 5778432, 'vda_write_req': 488, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diagnostics(self):\r\n # NB: should be not None for multiprocessing works\r\n return {}", "def compute_diagnostics(self) -> Dict[str, Any]:\n return {}", "def get_diagnostics(self) -> List[Diagnostic]:\n raise NotImplementedError", "def diagnostics(self, oid):\n path = ...
[ "0.7394385", "0.7127574", "0.68339425", "0.6612228", "0.64488685", "0.6354231", "0.61432654", "0.61270887", "0.604643", "0.6037903", "0.5928791", "0.5822542", "0.58160037", "0.5722499", "0.56864506", "0.5682793", "0.56672037", "0.560802", "0.5604313", "0.5590717", "0.55809945...
0.79608166
0
Return usage info for volumes attached to vms on a given host.
def get_all_volume_usage(self, context, compute_host_bdms): volusage = [] return volusage
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_volume_info(host, disk_object, dc_obj):\n host_resource = get_host_resource_by_name(host)\n\n vol_id = disk_object.get_image_id()\n sd_id = disk_object.get_storage_domains().get_storage_domain()[0].get_id()\n image_id = disk_object.get_id()\n sp_id = dc_obj.get_id()\n\n args = {\n ...
[ "0.64672023", "0.62748015", "0.6236638", "0.60684156", "0.5916731", "0.5862034", "0.5846422", "0.57962835", "0.57623684", "0.57531667", "0.56755435", "0.5626542", "0.56177384", "0.560629", "0.5597559", "0.55715716", "0.55710214", "0.55689335", "0.55505204", "0.553369", "0.552...
0.7157881
1
Return Azure Host Status of name, ram, disk, network.
def get_host_stats(self, refresh=False): stats = [] for nodename in self._drv_nodes: host_status = self.host_status_base.copy() host_status['hypervisor_hostname'] = nodename host_status['host_hostname'] = nodename host_status['host_name_label'] = nodename ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_host_stats(self, refresh=False):\n return self.host_status", "def poll_host(self, server, obj, name):\n\n self.log.debug('found host: %s' % (name,))\n\n status = 0\n cpu_total = cpu_usage = cpu_percent = cpu_count = cpu_mhz_per_core = 0\n mem_total = mem_usage = mem_per...
[ "0.6819568", "0.6763305", "0.65834033", "0.6454942", "0.64086723", "0.6327985", "0.62002283", "0.6168387", "0.6132985", "0.6122318", "0.60854673", "0.60717744", "0.6018915", "0.6010263", "0.6002129", "0.59691036", "0.59649265", "0.5933538", "0.5916599", "0.5898467", "0.589074...
0.6995629
0
Check if inputs is video or not
def check_is_video(self, inputs): if isinstance(inputs, list): return True if isinstance(inputs, np.ndarray) and len(inputs.shape) == 4: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self):\n #\n # *****************\n # *****************\n # TODO: Check really if video is valid\n # *****************\n # *****************\n return True", "def __check_for_video_file(self):\n formats = ('avi', 'mpg', 'mpeg', 'mp4')\n if os.path.splitext(self.args.inp...
[ "0.7698217", "0.75833863", "0.7378489", "0.72596055", "0.70826477", "0.6927467", "0.6915077", "0.68082577", "0.65910804", "0.65723324", "0.65678036", "0.65032965", "0.64527184", "0.64243037", "0.64173114", "0.6349831", "0.63205665", "0.63025355", "0.6205517", "0.61707026", "0...
0.7646629
1
Evaluates the postfix expression 's'.
def eval_postfix(s): stack = Stack() s = s.split() for i in s: if operator(i) == False: stack.push(int(i)) else: b = stack.pop() a = stack.pop() result = evaluate(a, i, b) stack.push(result) return stack.pop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_postfix(s):\n stack = Stack()\n for x in s.split(): # rozděl 's' dle mezer\n if x == '+':\n stack.push(stack.pop() + stack.pop())\n elif x == '-':\n stack.push(-stack.pop() + stack.pop())\n elif x == '*':\n stack.push(stack.pop() * stack.pop())\...
[ "0.7593586", "0.67240876", "0.6409349", "0.6357244", "0.6297136", "0.6115302", "0.6042468", "0.59812856", "0.59177285", "0.5893105", "0.5851467", "0.58478415", "0.58040977", "0.5790237", "0.5779237", "0.5760268", "0.56968087", "0.5645114", "0.5584172", "0.5554141", "0.5540710...
0.79264116
0
Provide tests for request to retrieve all way`s Notification
def test_get_all(self): expected_response = [ { 'id': 101, 'start_time': '2019-11-27', 'end_time': '2020-12-27', 'week_day': 1, 'time': datetime.time(1, 12, 38), 'way': 100 }, { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_one(self):\n expected_response = {\n 'id': 100,\n 'start_time': datetime.date(2019, 10, 29),\n 'end_time': datetime.date(2019, 12, 29),\n 'week_day': 6,\n 'time': datetime.time(23, 58, 59),\n 'way': 100\n }\n url = ...
[ "0.6836307", "0.6532002", "0.6530318", "0.642929", "0.63247854", "0.6228781", "0.6221926", "0.6138092", "0.60473317", "0.5991408", "0.5955423", "0.5921455", "0.58701456", "0.5856785", "0.5830087", "0.5830087", "0.5800119", "0.5795136", "0.57847846", "0.5759199", "0.57577235",...
0.7460129
0
Provide tests for request to retrieve non owner Notification instance.
def test_get_non_owner(self): another_user = CustomUser(id=101, email='another_user@mail.com', is_active=True) another_user.set_password('testpassword') another_user.save() self.client.login(email='another_user@mail.com', password='testpassword') url = reverse('notification', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_and_retrieve_notification(client):\n create_user_response = create_user(client, TEST_USER_NAME, TEST_USER_PASS)\n assert create_user_response.status_code == HttpStatus.created_201.value\n\n new_notification_message = 'Welcome to the eSports Competition'\n new_notification_category = 'In...
[ "0.64804983", "0.6367157", "0.6242152", "0.61259156", "0.60889626", "0.60715795", "0.5970538", "0.5970538", "0.5964811", "0.5955176", "0.59446895", "0.59405893", "0.59327626", "0.5912421", "0.5892791", "0.57778025", "0.5776532", "0.57747215", "0.5748287", "0.5742399", "0.5742...
0.668843
0
Provide tests for request to retrieve Notification instance with another `way_id`.
def test_get_from_another_way(self): url = reverse('notification', kwargs={'way_id': 101, 'notification_id': self.notification.id}) response = self.client.get(url) self.assertEqual(response.status_code, 403)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_one(self):\n expected_response = {\n 'id': 100,\n 'start_time': datetime.date(2019, 10, 29),\n 'end_time': datetime.date(2019, 12, 29),\n 'week_day': 6,\n 'time': datetime.time(23, 58, 59),\n 'way': 100\n }\n url = ...
[ "0.70815724", "0.6331676", "0.6276467", "0.6243297", "0.6123713", "0.601003", "0.5946206", "0.59328985", "0.58851916", "0.58831716", "0.5841439", "0.58281595", "0.5776078", "0.5759275", "0.5752853", "0.5731845", "0.5693253", "0.5669554", "0.5616581", "0.5574464", "0.5537879",...
0.70245445
1
Method that tests the success post request for creating notification.
def test_post_success(self): data = { 'start_time': '2019-10-29', 'end_time': '2019-12-29', 'week_day': 6, 'time': '23:58:59' } expected_data = { 'way': 100, 'start_time': '2019-10-29', 'end_time': '2019-12-29'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_successfully_create_notifications(self):\n pre_function_notifications = Notification.objects.all()\n self.assertEqual(len(pre_function_notifications), 0)\n\n create_notification(\n user=self.user_with_targets,\n title=\"Hi.\",\n body=\"Hello there, fri...
[ "0.7629735", "0.7618578", "0.7364911", "0.7363563", "0.7363563", "0.7052963", "0.7042657", "0.69984055", "0.6988693", "0.6985212", "0.6984905", "0.68905956", "0.6883018", "0.68676347", "0.6836012", "0.6821067", "0.67853075", "0.6779246", "0.6734471", "0.6721667", "0.66970336"...
0.7656309
0
Method that tests unsuccessful post request for creating notification with invalid post data.
def test_post_invalid_data(self): data = { 'week_day': 'd', 'time': 'd' } url = reverse('notification', kwargs={'way_id': self.notification.way_id, 'notification_id': self.notification.id}) response = self.client.post(url, json.dumps(data, cl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_invalid_submission(self):\n with self.client:\n # invalid submission registration\n sub_response = register_illegal_submission(self, self.token)\n response_data = json.loads(sub_response.data.decode())\n self.assertTrue(response_data['errors']!=Non...
[ "0.748908", "0.7362392", "0.727116", "0.7229355", "0.7158507", "0.7016817", "0.69638264", "0.695092", "0.69368654", "0.689105", "0.6859958", "0.6832937", "0.68327", "0.68105704", "0.67939985", "0.6764749", "0.6753879", "0.6751137", "0.6747767", "0.67406535", "0.67373455", "...
0.77954644
0
Method that tests unsuccessful post request with empty JSON data.
def test_post_empty_json(self): data = {} url = reverse('notification', kwargs={'way_id': self.notification.way_id, 'notification_id': self.notification.id}) response = self.client.post(url, json.dumps(data, cls=DjangoJSONEncoder), content_type='application/json') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testMissingData(self):\n data = {\n \"title\": \"Example Post\",\n }\n\n response = self.client.post(\"/api/posts\",\n data=json.dumps(data),\n content_type=\"application/json\",\n headers=[(\"Accept\", \"application/json\")]\n )\n\n ...
[ "0.80441666", "0.7749052", "0.77270865", "0.7574347", "0.7527644", "0.7512489", "0.7511428", "0.7503339", "0.750238", "0.7471226", "0.73760986", "0.73705995", "0.7363015", "0.73613787", "0.7355544", "0.73533607", "0.73203945", "0.72921515", "0.7282576", "0.72331876", "0.72312...
0.7766148
1
Provide tests post request for creating notification with another `way_id`.
def test_post_wrong_way_id(self): data = { 'start_time': '2019-10-29', 'end_time': '2019-12-29', 'week_day': 6, 'time': '23:58:59' } url = reverse('notification', kwargs={'way_id': 908, 'notification_id': self.notification.id}) response = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post_success(self):\n\n data = {\n 'start_time': '2019-10-29',\n 'end_time': '2019-12-29',\n 'week_day': 6,\n 'time': '23:58:59'\n }\n\n expected_data = {\n 'way': 100,\n 'start_time': '2019-10-29',\n 'end_ti...
[ "0.76020175", "0.74337363", "0.7126387", "0.6757347", "0.6724071", "0.6624706", "0.65971375", "0.65209603", "0.64011407", "0.6349355", "0.634253", "0.62249684", "0.618803", "0.6092924", "0.6064552", "0.5966692", "0.5936303", "0.59089214", "0.58871806", "0.58849657", "0.588496...
0.7806376
0
Method that test success put request for the updating Notification
def test_put_success(self): data = { 'time': '23:58:53' } url = reverse('notification', kwargs={'way_id': self.notification.way_id, 'notification_id': self.notification.id}) response = self.client.put(url, json.dumps(data, cls=DjangoJSONEncoder), content_type='application/j...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update(self):\n self.client.force_authenticate(user=self.admin)\n\n data = {\n 'retreat': reverse(\n 'retreat:retreat-detail', args=[self.retreat.id]\n ),\n 'user': reverse('user-detail', args=[self.user2.id]),\n }\n\n response = ...
[ "0.749496", "0.7354682", "0.7336386", "0.72968656", "0.7277956", "0.726332", "0.7205782", "0.72020173", "0.7130923", "0.7110041", "0.70423526", "0.70081943", "0.69901866", "0.69531584", "0.6885239", "0.68768865", "0.68694884", "0.6864684", "0.68584836", "0.6839003", "0.682881...
0.8032294
0
Method that tests for request to update non owner Notification instance.
def test_put_non_owner(self): another_user = CustomUser.objects.create(id=1067, email='another_user1@mail.com', is_active=True) another_user.set_password('testpassword') another_user.save() self.client.login(email='another_user1@mail.com', password='testpassword') data = { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_notification(client):\n create_user_response = create_user(client, TEST_USER_NAME, TEST_USER_PASS)\n assert create_user_response.status_code == HttpStatus.created_201.value\n\n new_notification_message_one = 'Fortnite has a new winner'\n new_notification_category_one = 'Information'\n ...
[ "0.6825002", "0.65637267", "0.6478547", "0.642229", "0.62722844", "0.6249249", "0.6242472", "0.6202908", "0.61824554", "0.6136467", "0.61097735", "0.60909486", "0.60642284", "0.60447806", "0.6032072", "0.6032072", "0.6029723", "0.60040575", "0.5982113", "0.5950152", "0.592269...
0.6854053
0
Provide tests post request for updating notification with another `way_id`.
def test_put_wrong_way_id(self): data = { 'start_time': '2019-10-29', 'end_time': '2019-12-29', 'week_day': 6, 'time': '23:58:59' } url = reverse('notification', kwargs={'way_id': 543, 'notification_id': self.notification.id}) response = se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post_wrong_way_id(self):\n data = {\n 'start_time': '2019-10-29',\n 'end_time': '2019-12-29',\n 'week_day': 6,\n 'time': '23:58:59'\n }\n url = reverse('notification', kwargs={'way_id': 908, 'notification_id': self.notification.id})\n ...
[ "0.7309353", "0.7287713", "0.70464474", "0.69682556", "0.68557084", "0.6814788", "0.6658717", "0.6463719", "0.64070153", "0.6393831", "0.63803446", "0.63698304", "0.6313824", "0.6292307", "0.62720644", "0.6193457", "0.61715186", "0.6160451", "0.6157474", "0.6146517", "0.60856...
0.75480807
0
Provide tests for request to delete Notification instance with another `way_id`.
def test_delete_another_way_id(self): url = reverse('notification', kwargs={'way_id': 101, 'notification_id': self.notification.id}) response = self.client.delete(url) self.assertEqual(response.status_code, 403)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_wrong_way_id(self):\n\n url = reverse('notification',\n kwargs={'way_id': 38987, 'notification_id': self.notification.id})\n response = self.client.delete(url)\n\n self.assertEqual(response.status_code, 400)", "def test_delete_non_notification_id(self):\n...
[ "0.78409946", "0.77346075", "0.75048524", "0.72533673", "0.7238364", "0.6442438", "0.6423715", "0.6412782", "0.63466054", "0.63466054", "0.62805015", "0.62805015", "0.6271731", "0.623744", "0.6173104", "0.61633974", "0.61517215", "0.6149768", "0.61421883", "0.60912126", "0.60...
0.814844
0
Method that tests for request to delete non owner Notification instance.
def test_delete_non_owner(self): another_user = CustomUser.objects.create(id=134, email='another_user2@mail.com', is_active=True) another_user.set_password('qwerty12345') another_user.save() self.client.login(email='another_user2@mail.com', password='qwerty12345') url = reverse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_non_notification_id(self):\n\n url = reverse('notification', kwargs={'way_id': self.notification.way_id})\n response = self.client.delete(url)\n self.assertEqual(response.status_code, 400)", "def action_delete():\n try:\n deleted = delete_notification()\n ...
[ "0.72411215", "0.69432837", "0.6825985", "0.68125653", "0.6811813", "0.6811813", "0.66271573", "0.66271573", "0.6599707", "0.65833205", "0.6556676", "0.6446615", "0.64434767", "0.64428777", "0.64428586", "0.6442772", "0.6441421", "0.6401548", "0.6354622", "0.63353646", "0.629...
0.75843847
0
Method that tests unsuccessful delete request when db deleting is failed.
def test_error_db_deleting(self): url = reverse('notification', kwargs={'way_id': self.notification.way_id, 'notification_id': self.notification.id}) with mock.patch('notification.views.Notification.delete_by_id') as notification_delete: notification_delete.return_valu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_invalid_db_delete(env_setup, env_table, db_delete_test_data, response_test_data):\n test_string = DbManager(SqLiteHelper, {\"db_path\": env_setup, \"master_table\": env_table}) \\\n .processor(db_delete_test_data.get(\"invalid\"))\n assert test_string == response_test_data.get(\"invalid_delet...
[ "0.7845363", "0.7661133", "0.7618815", "0.7579205", "0.74916613", "0.74349666", "0.73349035", "0.7333713", "0.72599447", "0.72522247", "0.7246481", "0.722398", "0.72110033", "0.71876705", "0.7169879", "0.7162017", "0.7146241", "0.7146241", "0.70829624", "0.707316", "0.7072797...
0.80490714
0
Function to get the coding of a text. text text to inspect (string) coding string
def get_coding(text): for line in text.splitlines()[:2]: result = CODING_RE.search(line) if result: return result.group(1) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coding(text: str) -> str:\n text = list(itertools.chain(text.upper()))\n coded_text = []\n for letter in text:\n completed = False\n for coding in Encoder.__ALPHABET:\n if coding.code == letter:\n completed = True\n ...
[ "0.707069", "0.6810811", "0.6544954", "0.65068567", "0.65035826", "0.64848405", "0.6453819", "0.64496917", "0.6330471", "0.6172013", "0.6076432", "0.6043792", "0.59862036", "0.5981213", "0.5981213", "0.5981213", "0.5981213", "0.5981213", "0.59120387", "0.59068704", "0.5875831...
0.805322
0
Function to encode a text. text text to encode (string) orig_coding type of the original coding (string) encoded text and encoding
def encode(text, orig_coding): if orig_coding == 'utf-8-bom': return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom' # Try declared coding spec coding = get_coding(text) if coding: try: return text.encode(coding), coding except (UnicodeError, LookupError): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode(self, text):", "def encoding(text: str) -> str:\n text = [text[i:i + 3] for i in range(0, len(text), 3)]\n encoded_text = []\n for letter in text:\n completed = False\n for coding in Encoder.__ALPHABET:\n if coding.encode == letter:\n ...
[ "0.78429985", "0.73863465", "0.72532046", "0.7069336", "0.68364793", "0.6779326", "0.66536885", "0.66491073", "0.6570643", "0.6511079", "0.6476293", "0.6476293", "0.64474636", "0.6437557", "0.6430884", "0.6375071", "0.6368134", "0.6325877", "0.6323018", "0.62958544", "0.62450...
0.7889577
0
Write 'text' to file ('filename') assuming 'encoding' Return (eventually new) encoding
def write(text, filename, encoding='utf-8', mode='wb'): text, encoding = encode(text, encoding) with open(filename, mode) as textfile: textfile.write(text) return encoding
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_file(filename=\"\", text=\"\"):\n with open(filename, mode=\"w\", encoding=\"utf-8\") as m:\n return m.write(text)", "def write_file(filename=\"\", text=\"\"):\n with open(filename, mode='w', encoding=\"utf-8\") as myFile:\n chars_written = myFile.write(text)\n return chars_writt...
[ "0.7557955", "0.7544506", "0.7533237", "0.75145644", "0.7479202", "0.7241678", "0.70433176", "0.70286334", "0.69647485", "0.69500077", "0.6922134", "0.6919635", "0.6918923", "0.6918923", "0.6891338", "0.6771927", "0.67655516", "0.6725522", "0.6717722", "0.671073", "0.6706911"...
0.87326086
0
Write 'lines' to file ('filename') assuming 'encoding' Return (eventually new) encoding
def writelines(lines, filename, encoding='utf-8', mode='wb'): return write(os.linesep.join(lines), filename, encoding, mode)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_to_file(filepath, lines):\n with open(filepath, 'w', encoding='utf-8') as f:\n f.write(''.join([line.replace('\\r\\n', '\\n') for line in lines]))", "def lines_to_file(file_name: str, write_dir: str, lines: Sequence[str]):\n with open(os.path.join(write_dir, file_name), \"w\", encoding=\"u...
[ "0.6922916", "0.66539276", "0.6571761", "0.65292937", "0.642268", "0.62827504", "0.60700613", "0.6031235", "0.59540445", "0.59286505", "0.59032005", "0.5897087", "0.5857801", "0.58426356", "0.58392614", "0.57965297", "0.57942283", "0.57908106", "0.5772628", "0.5734947", "0.57...
0.7489392
0
Read text from file ('filename') Return text and encoding
def read(filename, encoding='utf-8'): text, encoding = decode( file(filename, 'rb').read() ) return text, encoding
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read(filename, encodings=['ascii', 'utf-8', 'utf-16', 'latin-1']):\n text = None\n\n for encoding in encodings:\n try:\n f = open(filename, encoding=encoding)\n text = f.read()\n f.close()\n except UnicodeDecodeError:\n f.close()\n except ...
[ "0.8138041", "0.7998457", "0.7998457", "0.79705226", "0.78938377", "0.7879223", "0.7831182", "0.7786197", "0.7733396", "0.7665402", "0.76034033", "0.7577817", "0.7550896", "0.75384855", "0.75316525", "0.7510268", "0.7503345", "0.74948895", "0.7489632", "0.74461335", "0.744271...
0.8679592
0
Read lines from file ('filename') Return lines and encoding
def readlines(filename, encoding='utf-8'): text, encoding = read(filename, encoding) return text.split(os.linesep), encoding
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_lines(file_name: str) -> List[str]:\n try:\n return open(file_name, encoding='utf8').readlines()\n except UnicodeDecodeError:\n return open(file_name, encoding='cp1252').readlines()", "def read_file(filename):\n with open(filename, encoding='utf-8') as src:\n ...
[ "0.7824536", "0.7728978", "0.7454107", "0.7385729", "0.73801655", "0.73738843", "0.7366425", "0.7290574", "0.7284927", "0.72171664", "0.7186186", "0.7184496", "0.71711564", "0.7166647", "0.7075612", "0.7070739", "0.69983697", "0.6996958", "0.6993472", "0.6980073", "0.6935585"...
0.81567216
0
validate the access keys for this tenant
def _ensure_tenant_and_validate(tenant_, access_key): tenant_data = registry.TENANT_DATA_GATEWAY tenant = tenant_data.tenant_by_name(tenant_) if tenant is None: raise TenantNotFoundError( "Tenant not found error. tenant='{}', access_key='{}'".format( tenant_, access_key))...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_keystone_tenants(self, client):\n u.log.debug('Checking keystone tenants...')\n expected = [\n {'name': 'services',\n 'enabled': True,\n 'description': 'Created by Juju',\n 'id': u.not_null},\n {'name': 'demoTenant',\n ...
[ "0.6086632", "0.59554845", "0.5888044", "0.5835416", "0.58168113", "0.5784612", "0.56935436", "0.5656515", "0.56534857", "0.5633115", "0.55855936", "0.5562494", "0.5473357", "0.5468281", "0.54314995", "0.5400806", "0.5358791", "0.5337157", "0.5333666", "0.5327647", "0.5299893...
0.70454735
0
validates access to the tenant REQUIRES that arg 0 of the calling function contains an object with the following fields (tenant (str), access_key(str))
def access_key_and_tenant_required(f): @wraps(f) def wrapper(*args, **kwargs): tenant = _ensure_tenant_and_validate(args[0].tenant, args[0].access_key) kwargs['tenant'] = tenant return f(*args, **kwargs) return wrapper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _ensure_tenant_and_validate(tenant_, access_key):\n tenant_data = registry.TENANT_DATA_GATEWAY\n tenant = tenant_data.tenant_by_name(tenant_)\n if tenant is None:\n raise TenantNotFoundError(\n \"Tenant not found error. tenant='{}', access_key='{}'\".format(\n tenant_,...
[ "0.7270588", "0.61245686", "0.60244095", "0.60244095", "0.5603974", "0.5583817", "0.5576855", "0.5457372", "0.54482836", "0.53795445", "0.53709066", "0.5356738", "0.533243", "0.5332021", "0.53286314", "0.5317975", "0.5316835", "0.5304212", "0.5273722", "0.5255667", "0.5255489...
0.7408233
0
validates access to the bucket for the given fields. REQUIRES that arg 0 of the calling function contains an object with the following fields (tenant (str), access_key(str), bucket(str))
def access_to_bucket_required(f): @wraps(f) def wrapper(*args, **kwargs): tenant = _ensure_tenant_and_validate(args[0].tenant, args[0].access_key) bucket = tenant.get_bucket(args[0].bucket) kwargs['bucket'] = bucket return f(*args, **k...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access_key_and_tenant_required(f):\n @wraps(f)\n def wrapper(*args, **kwargs):\n tenant = _ensure_tenant_and_validate(args[0].tenant,\n args[0].access_key)\n\n kwargs['tenant'] = tenant\n return f(*args, **kwargs)\n return wrapper", "d...
[ "0.6362296", "0.6169604", "0.60709274", "0.5856636", "0.5740477", "0.5719126", "0.5697819", "0.5665839", "0.5654232", "0.5581581", "0.5573217", "0.5561906", "0.5506819", "0.5506553", "0.546765", "0.5461047", "0.54366624", "0.543023", "0.5401997", "0.5385422", "0.5363991", "...
0.7128565
0
>>> validate_n_digits()("") False >>> validate_n_digits()("a") False >>> validate_n_digits()("asdf") False >>> validate_n_digits()("asdfghj") False >>> validate_n_digits()("123") False >>> validate_n_digits()("1234") True >>> validate_n_digits()("1235678") False >>> validate_n_digits(n=9)("000000001") True >>> validate...
def validate_n_digits(n: int = 4) -> bool: def func(s: str): if len(s) != n: return False if not s.isdigit(): return False return True return func
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_n_digits_range(min_val: int, max_val: int, n: int = 4) -> bool:\n def func(s: str):\n return validate_n_digits(n)(s) and min_val <= int(s) <= max_val\n return func", "def validate(value):\n if str.isdigit(value) or value == \"\":\n return True\n else:\n return False"...
[ "0.6967983", "0.69240135", "0.6848611", "0.6823944", "0.67357725", "0.6591856", "0.6506189", "0.64677304", "0.64408034", "0.64399856", "0.6419439", "0.6367101", "0.6340759", "0.6191284", "0.6188791", "0.6156608", "0.61299425", "0.61085176", "0.6107948", "0.6074612", "0.603432...
0.8455768
0
>>> validate_n_digits_range(1920, 2002)("2002") True >>> validate_n_digits_range(1920, 2002)("2003") False
def validate_n_digits_range(min_val: int, max_val: int, n: int = 4) -> bool: def func(s: str): return validate_n_digits(n)(s) and min_val <= int(s) <= max_val return func
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_n_digits(n: int = 4) -> bool:\n def func(s: str):\n if len(s) != n:\n return False\n if not s.isdigit():\n return False\n return True\n return func", "def is_valid_birth_number(birth_number: int):\n if birth_number in range(1, 1000):\n retur...
[ "0.71524906", "0.7093412", "0.70692015", "0.69911283", "0.6924774", "0.6916429", "0.6841534", "0.66205734", "0.66151506", "0.661108", "0.6566998", "0.65198666", "0.6514695", "0.6487208", "0.64803034", "0.64262885", "0.64223665", "0.6400888", "0.6372396", "0.6336665", "0.63363...
0.81118214
0
>>> validate_hgt("60in") True >>> validate_hgt("190cm") True >>> validate_hgt("190in") False >>> validate_hgt("190") False
def validate_hgt(hgt: str) -> bool: if hgt[-2:] == 'cm': return 150 <= int(hgt[:-2]) <= 193 if hgt[-2:] == 'in': return 59 <= int(hgt[:-2]) <= 76 return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_hgt(cls, hgt):\n check = re.search(r\"^(\\d+)(in|cm)$\", hgt)\n if not check:\n raise ValueError(f\"Invalid hgt {hgt}\")\n n, unit = check.groups()\n n = int(n)\n if unit == \"in\":\n if not (76 >= n >= 59):\n raise ValueError(\"Inva...
[ "0.84475106", "0.6317095", "0.61406976", "0.5876957", "0.5799034", "0.5661624", "0.56512386", "0.56129754", "0.5500368", "0.54911727", "0.5486033", "0.5481811", "0.54454076", "0.54362947", "0.5415607", "0.53925407", "0.5391829", "0.53789145", "0.53327215", "0.5327332", "0.530...
0.9066648
0
>>> validate_hcl("123abc") True >>> validate_hcl("123abz") False >>> validate_hcl("123abc") False >>> validate_hcl("000000") True >>> validate_hcl("999999") True >>> validate_hcl("aaaaaa") True >>> validate_hcl("ffffff") True
def validate_hcl(hcl: str) -> bool: if len(hcl) != 7 or hcl[0] != '#': return False for x in hcl[1:]: if x not in list(map(str, range(9 + 1))) + \ list(map(chr, range(ord('a'), ord('f') + 1))): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_hash(h):\n if len(h) not in (32, 40, 64, 128):\n return False\n\n return bool(re.match(\"[0-9a-fA-F]*$\", h))", "def valid(h):\n h = bytes.decode(h)\n if h[0].islower():\n if set(h).issubset(ALNUM):\n # Yes! Digits, Upper- and lowercase are present\n ...
[ "0.66823274", "0.65741116", "0.63123316", "0.6178835", "0.6109796", "0.6095078", "0.60738504", "0.5964063", "0.59419316", "0.59182006", "0.5900173", "0.5891105", "0.58870363", "0.58630085", "0.5845556", "0.58441126", "0.5839956", "0.57940686", "0.5791709", "0.57306457", "0.57...
0.74781597
0
>>> validate_ecl("brn") True >>> validate_ecl("wat") False
def validate_ecl(ecl: str) -> bool: return ecl in ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ecssa_verify(ec: EC, hf, m: bytes, P: Point, sig: ECSS) -> bool:\n\n # this is just a try/except wrapper\n # _ecssa_verify raises Errors\n try:\n return _ecssa_verify(ec, hf, m, P, sig)\n except Exception:\n return False", "def validate():", "def test_is_valid(self, address):\n ...
[ "0.62015206", "0.61072654", "0.6074642", "0.6051566", "0.60084826", "0.5970571", "0.59182256", "0.59039706", "0.59022427", "0.58978814", "0.58941233", "0.58641183", "0.58630884", "0.5861052", "0.58596045", "0.58547425", "0.5842046", "0.5841408", "0.5838524", "0.5835987", "0.5...
0.85189974
0
Takes a list of vectors and returns their average
def compute_average(vec_list): return np.sum(vec_list, axis = 0)/len(vec_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_vectors(vectors_list):\n return np.mean(vectors_list, axis=0)", "def average(cls, vectors):\n return cls.sum(vectors) / len(vectors)", "def vector_mean(vectors: List[Vector]) -> Vector:\n n = len(vectors)\n return scalar_multiply(1/n, vector_sum(vectors))", "def vector_mean(vector...
[ "0.8681849", "0.79531354", "0.78980136", "0.78980136", "0.7865671", "0.7705014", "0.7705014", "0.7705014", "0.769987", "0.769987", "0.76556635", "0.7569094", "0.7538223", "0.753232", "0.7523211", "0.7509719", "0.7479618", "0.74456024", "0.737489", "0.72875494", "0.72845083", ...
0.8858376
0
Computes a sentence2vece embedding for preprocessed user input.
def compute_user_input_embedding(txt, model): embeddings = [] tokens = txt.split(" ") for word in tokens: embeddings.append(model.wv[word]) sentence_embedding = compute_average(embeddings) return sentence_embedding
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_pre_trained_embedding(self):\n\n if self.embedding_type['type'] == 'glove':\n self.logging.info('use pre-trained glove word2vec')\n # a. load pre trained glove\n GLOVE_DIR = '../data/glove_pretrained/glove.6B'\n glove_suffix_name = 'glove.6B.' + str(self....
[ "0.6891252", "0.6638002", "0.66288036", "0.65824366", "0.6558864", "0.6556217", "0.64891624", "0.6487913", "0.6419915", "0.6406742", "0.6390424", "0.6382159", "0.63630146", "0.6351706", "0.63423693", "0.628914", "0.628678", "0.6255382", "0.62375826", "0.6213522", "0.6198622",...
0.7118841
0
Returns the n most similar products for a given user input embedding.
def get_similar_products(user_input_emb, ref_catalog, n = 5): sim_list = [] for i in range(len(ref_catalog)): desc_id = ref_catalog.iloc[i]['id'] emb = ref_catalog.iloc[i]['desc_embedding'] cos_sim = compute_cosine_sim(emb,user_input_emb) sim_list.append((desc_id, cos_sim))...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topn_similarity(word_vecs, word, n):\n vec = word_vecs[word]\n sim = dict()\n for w in word_vecs:\n if w != '<TOP>' and w != '<BOT>':\n # sim[w] = np.dot(vec, np.transpose(word_vecs[w]))\n sim[w] = 1 - spatial.distance.cosine(vec, word_vecs[w])\n # sim[w] = np....
[ "0.6303444", "0.6231034", "0.6041034", "0.6041034", "0.59895635", "0.59817195", "0.5981174", "0.587914", "0.5833353", "0.5826179", "0.57493174", "0.57406974", "0.57392347", "0.57307845", "0.5707042", "0.5693564", "0.5679855", "0.567223", "0.5671902", "0.56702316", "0.5668979"...
0.74809283
0
Removes html tags from txt
def remove_html(txt): TAG_RE = re.compile(r'<[^>]+>') return TAG_RE.sub("", txt).strip()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_html_tags(text):\n import re\n clean = re.compile('<.*?>|\\\\n')\n return re.sub(clean, '', text)", "def remove_html_tags(text):\n print('VOU REMOVER AS TAGS DA STRING')\n clean = re.compile('<.*?>')\n print('',re.sub(clean, '', text))\n return re.sub(clean, '', text)", "def rem...
[ "0.82413596", "0.81933254", "0.8151002", "0.81288743", "0.8118329", "0.8103889", "0.8095974", "0.8079586", "0.8077638", "0.8077638", "0.80603147", "0.7991694", "0.79077923", "0.7896608", "0.78903127", "0.7843595", "0.7843595", "0.7835371", "0.7812128", "0.7812128", "0.7775047...
0.8495694
0
return the goal weight question and save the user's answers
def return_goal_weight_text_save_weight(self, data_dict, id_user): # get robot advice to user : defined this weight goal actual_weight = data_dict.get("actual_weight") if actual_weight is not False: # if the user answered to the goal weight question # the parser method r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_return_goal_weight_text_save_weight(self):\n # create user\n user_created = self.create_user_questionnaire_in_progress()\n\n # data\n data_dict = {\"height\": \"1,60\", \"actual_weight\": \"80\",\n \"cruising_weight\": \"50\", \"weight_goal\": \"70\"}\n\n ...
[ "0.7202105", "0.69144183", "0.6901956", "0.65887946", "0.6515546", "0.63579017", "0.63563627", "0.6148189", "0.6041054", "0.6025184", "0.60155094", "0.60127217", "0.6002536", "0.59930605", "0.59860015", "0.5915728", "0.58932304", "0.5890873", "0.5890676", "0.58757055", "0.584...
0.7461492
0
save advices to user
def save_advices_to_user(self, user_answer_id, old_question_id, id_user): # get data id_advice = DiscussionSpace.objects.values_list("robot_advices"). \ filter(robot_question=old_question_id).get(user_answer=user_answer_id)[0] # if the user's answer # contains a robot advice...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_advices_to_user(self, id_user):\n # get data\n advice_type_id = RobotAdviceType.objects.values_list(\"id\").get(type=\"default\")\n advices_id = RobotAdvices.objects.values_list(\"id\").filter(robot_advice_type=advice_type_id)\n\n # add new advices to user\n for advice_id...
[ "0.7048428", "0.6602138", "0.6419206", "0.64026564", "0.6258406", "0.622147", "0.62191874", "0.6178238", "0.6152282", "0.61215186", "0.6086368", "0.59979254", "0.59565187", "0.59565187", "0.5946988", "0.5928566", "0.59229535", "0.5900002", "0.5873121", "0.58391154", "0.583911...
0.6839697
1
return weekly question and save user's answer
def return_weekly_questions_save_weight(self, weekly_weight, id_user): # get data context = {} weighing_date = ResultsUser.objects.values_list("weighing_date") last_weighing_date = weighing_date.filter(user=id_user).order_by("weighing_date").last()[0] one_week_after_weighing = la...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_return_weekly_questions_save_weight(self):\n # create user\n user_created = self.create_user_start_program_number_days_ago(7)\n\n # TEST NEW WEIGHT DON'T EXISTS\n # data\n weekly_weight = False\n\n # call method\n context = self.new_controller.return_weekly...
[ "0.66659147", "0.6612688", "0.5977455", "0.57612425", "0.57137007", "0.55952173", "0.5567274", "0.55584353", "0.5535094", "0.5429015", "0.54175264", "0.5411817", "0.5410731", "0.54016536", "0.5363783", "0.5358611", "0.5342742", "0.53238475", "0.53221977", "0.5289323", "0.5275...
0.7340768
0
add new robot advices to user
def add_advices_to_user(self, id_user): # get data advice_type_id = RobotAdviceType.objects.values_list("id").get(type="default") advices_id = RobotAdvices.objects.values_list("id").filter(robot_advice_type=advice_type_id) # add new advices to user for advice_id in advices_id: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_advice_to_user_created(cls, user, list_advice_id):\n for id_advice in list_advice_id:\n advice = RobotAdvices.objects.get(id=id_advice)\n AdvicesToUser.objects.create(user=user, advice=advice)", "def test_add_advices_to_user(self):\n # create user\n user_created...
[ "0.65682614", "0.6457554", "0.6085961", "0.60834557", "0.6056406", "0.5792387", "0.5729461", "0.5710384", "0.5673903", "0.56236", "0.559872", "0.5590028", "0.55840814", "0.5548293", "0.5532204", "0.5513462", "0.54895794", "0.5481246", "0.5480195", "0.5451334", "0.54244864", ...
0.73527414
0
reads a slope text data file
def read_slope(fname): # http://milford.nserl.purdue.edu/weppdocs/usersummary/HillSlopeData.html meta = {} OFEs = [] meta['fname'] = fname meta['id'] = ''.join([L for L in fname if L in '0123456789']) fid = open(fname, 'r') lines = fid.readlines() lines = [L for L in lines i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_multinest_file(shower_name):\n\twith open(fit_dir+'fit_'+shower_name+'.out') as file:\n\t\tline = file.readline().split()\n\t\tslope = 1-float(line[0])\n\t\tslope_err_plus = -float(line[1])\n\t\tslope_err_minus = float(line[2])\n\t\ty_int = float(file.readline().split()[0])\n\treturn slope, slope_err_plus...
[ "0.69637036", "0.62119883", "0.6132573", "0.6100909", "0.60567594", "0.60152274", "0.5964745", "0.59628475", "0.591921", "0.58862406", "0.5842147", "0.5832435", "0.58309996", "0.5762316", "0.5758946", "0.57343227", "0.5713052", "0.5700565", "0.5696346", "0.5679199", "0.564583...
0.7150037
0
Create index, extracting substrings of length 'ln'
def __init__(self, t, ln): self.t = t self.ln = ln self.index = [] size = len(t) for i in range(len(t) - ln + 1): self.index.append((t[i:i + ln], i)) # add <substr, offset> pair self.index.sort() # sort pairs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def substrings(a, b, n):\n\n # TODO\n return []", "def retrieve_sub(s, n):\n subs = []\n for idx, char in enumerate(s):\n sub = char\n c = 1\n for next_char in s[idx + 1:]:\n if c >= n:\n break\n else:\n sub += next_char\n c ...
[ "0.58004004", "0.57035714", "0.5630862", "0.5502177", "0.5499872", "0.5449966", "0.54482114", "0.537926", "0.53484404", "0.53246045", "0.5313119", "0.5283813", "0.5277651", "0.5237471", "0.51850224", "0.51836663", "0.5134227", "0.51330423", "0.51146626", "0.507412", "0.506099...
0.6595219
0
Load classes for a given excel_data string, containing 3 columns on each line separated by tabs. Load the schedule to a global variable for later access.
def load_classes(excel_data, slot_count): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_class_list():\r\n try:\r\n firstLine = True #keeping track of the first line in the csv file (the header)\r\n index = 0\r\n if os.access(\"mySchedule.csv\", os.F_OK): #If the file exists\r\n f = open(\"mySchedule.csv\")\r\n for row in csv.reader(f):\r\n ...
[ "0.62730616", "0.5840638", "0.5721444", "0.55272853", "0.5497005", "0.5484389", "0.53764915", "0.53338474", "0.52232695", "0.5209564", "0.5174315", "0.509816", "0.5041172", "0.50368327", "0.5036266", "0.5027175", "0.5022386", "0.49693894", "0.49673653", "0.49530467", "0.49271...
0.67227983
0
Get the names of exams available to pick for a given slot_number Returns list of names of exams.
def get_potential_classes_for_slot(slot_number): return ["econ", "biz", "wtf"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_slots(intent_request):\n return intent_request[\"currentIntent\"][\"slots\"]", "def _list_of_availability_strings():\n names = [availability.name for availability in Availability]\n return names", "def getResiduesByName(self, resn):\n\n\t\treslist = []\n\t\tfor chn in self.chain:\n\t\t\tfor re...
[ "0.52379185", "0.5172876", "0.50573343", "0.5030471", "0.5021936", "0.49109137", "0.4860436", "0.4856028", "0.48363858", "0.48315743", "0.47921562", "0.47723097", "0.4765679", "0.47527313", "0.4746533", "0.47408932", "0.4725023", "0.47146904", "0.4711878", "0.46946704", "0.46...
0.52736354
0
Select a class_name for a certain slot_number. Class name is selected from one of get_potential_classes_for_slot(slot_number) Do the necessary manipulation
def select_class_for_slot(class_name, slot_number): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_potential_classes_for_slot(slot_number):\n return [\"econ\", \"biz\", \"wtf\"]", "def get_skill_class(cursor, _class):\n cursor.execute('SELECT id FROM classes WHERE temp_id = ?', (_class,))\n data = cursor.fetchone()\n try:\n return data[0]\n except TypeError:\n l.error(\"Th...
[ "0.6997579", "0.590257", "0.56273097", "0.5527541", "0.54824317", "0.5280297", "0.5246553", "0.5108651", "0.5095877", "0.5084751", "0.5055355", "0.50318855", "0.49355", "0.49338344", "0.49330693", "0.49220127", "0.49219468", "0.4920611", "0.4900326", "0.4871079", "0.4848637",...
0.8108506
0
Resets all made selection, returning to initial state
def reset_selections(): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Reset_Selection(self):\r\n #if previous selection\r\n if( self.selected != 0 ):\r\n self.canvas_one.delete( self.selected ) #remove bounding rectangle\r\n #return chosen node to branch_color\r\n self.canvas_one.itemconfig( self.selected_ls.line_handle , fill = self.br...
[ "0.79201347", "0.77571887", "0.7379118", "0.7340211", "0.73181266", "0.721911", "0.7197248", "0.7190832", "0.71431947", "0.71210617", "0.7112716", "0.7112716", "0.7112716", "0.7112716", "0.7075982", "0.70753473", "0.70753473", "0.70753473", "0.70569086", "0.70569086", "0.7054...
0.79584837
0
Returs a list of all pandigital primes up to ``n``.
def pandigital_primes(n=10000000): pri = [x for x in primes(n) if is_pandigital(x)] return pri
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_primes(n):\n\n return list(primes_sieve(n))", "def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]", "def get_n_primes(n):\n\n primes = [' ']\n num = 2\n while len(primes) < n + 1:\n if is_prime(num):\n primes.append(num)\n num += 1\n return p...
[ "0.8037789", "0.79828346", "0.78280413", "0.7799131", "0.7784345", "0.77557623", "0.7705573", "0.7680708", "0.75602317", "0.75260603", "0.75113", "0.74893403", "0.7445755", "0.74427813", "0.74221474", "0.7414387", "0.739986", "0.736477", "0.7353285", "0.7333225", "0.73293346"...
0.83678913
0
Retrieve the local code for a device using the EufyHome account's username and password.
def get_local_code(username: str, password: str, ip_address: str): client_id = 'eufyhome-app' client_secret = 'GQCpr9dSp3uQpsOMgJ4xQ' login_payload = {'client_id': client_id, 'client_Secret': client_secret, 'email': username, 'password': password} login_request = requests.post("https://home-api.eufylif...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_address():\n ret = subprocess.getoutput([\"swift auth\"])\n ret = ret.split(\"\\n\")[0]\n ret = ret.split(\"=\")[1]\n return ret", "def query_device_credential(self, device_code):\n raise NotImplementedError()", "def get_device_data():\n user = input('Username: ')...
[ "0.58795834", "0.5864797", "0.5834147", "0.57331693", "0.55483615", "0.5507485", "0.54629534", "0.54514444", "0.54253983", "0.54025495", "0.53247046", "0.53159016", "0.5302662", "0.5299826", "0.5280781", "0.5280781", "0.52279246", "0.52222973", "0.52222973", "0.51973945", "0....
0.7983226
0
Encrypt data using the Eufy AES key and IV. Handles padding to a 16 byte interval.
def _encrypt(data): cipher = AES.new(bytes(_AES_KEY), AES.MODE_CBC, bytes(_AES_IV)) # Pad to 16 bytes for AES CBC for i in range(16 - (len(data) % 16)): data += b'\0' return cipher.encrypt(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encryptData(self, key, iv, data, align = True):\r\n\t\tif((len(data) % self.align) != 0 and align):\r\n\t\t\treturn AES.new(key, AES.MODE_CBC, iv).encrypt(data + (\"\\x00\" * (self.align - (len(data) % self.align))))\r\n\t\telse:\r\n\t\t\treturn AES.new(key, AES.MODE_CBC, iv).encrypt(data)", "def encrypt(dat...
[ "0.6828749", "0.67845535", "0.673316", "0.6700717", "0.6700098", "0.66566104", "0.6576784", "0.65596473", "0.6475029", "0.6362078", "0.6355538", "0.6347096", "0.6343566", "0.6307382", "0.62541276", "0.62478405", "0.62115437", "0.61893487", "0.6187919", "0.61566067", "0.615564...
0.71610576
0
Compile the given mode and command into the bytes data sent to the RoboVac.
def _build_robovac_command(mode, command): mcu_ota_header_0xa5 = 0xA5 cmd_data = (mode.value + command.value) return bytes([mcu_ota_header_0xa5, mode.value, command.value, cmd_data, 0xFA])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_compile_cmd(self):\n ld = self.nvcc_options_json[\"ld\"]\n objcopy = self.nvcc_options_json[\"objcopy\"]\n cmd = \" \".join([ld, \"-r -b binary -o {target} {src}\"])\n # Support models with >2GB constants on Linux only\n if is_linux():\n cmd += (\n ...
[ "0.6167799", "0.5937154", "0.59241605", "0.59028786", "0.5817669", "0.579884", "0.57838464", "0.5774759", "0.5737887", "0.570226", "0.56056356", "0.55847764", "0.55546546", "0.5552185", "0.54988945", "0.5478312", "0.5477653", "0.5468052", "0.5432817", "0.54185456", "0.5405838...
0.71921897
0
Parse a decrypted response into a Protobuf Local Server Message
def _parse_local_server_message_from_decrypted_response(decrypted_response): # First 2 bytes indicate length of the actual data length = struct.unpack("<H", decrypted_response[0:2])[0] protobuf_data = decrypted_response[2:length + 2] message = LocalServerInfo_pb2.LocalServerMessage() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_reply(self, msg_list): #{\n logger = self.logger\n\n if len(msg_list) < 4 or msg_list[0] != b'|':\n logger.error('bad reply: %r' % msg_list)\n return None\n\n msg_type = msg_list[2]\n data = msg_list[3:]\n result = None\n srv_id = ...
[ "0.6336118", "0.6241895", "0.6204218", "0.61142474", "0.61068696", "0.6064688", "0.60642505", "0.60597825", "0.605668", "0.6025478", "0.5981453", "0.5966325", "0.59572643", "0.5868557", "0.5867732", "0.5841865", "0.5841581", "0.58406657", "0.5827033", "0.58100164", "0.5783654...
0.80403924
0
Get the status of the RoboVac device (battery level, mode, charging, etc).
def get_status(self) -> RobovacStatus: message = self._build_get_device_status_user_data_message() robovac_response = self._send_packet(message, True) received_status_bytes = robovac_response.c.usr_data received_status_ints = [x for x in received_status_bytes] return RobovacStat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_get_status(self):\n logging.info(__name__ + ' : Get status of the device.')\n result = self._execute('X')\n usage = {\n 0: \"Channel not in use\",\n 1: \"Channel used for Nitrogen level\",\n 2: \"Channel used for Helium Level (Normal pulsed operation)\"...
[ "0.7337816", "0.7083738", "0.6949301", "0.69253254", "0.6892618", "0.67979217", "0.6779467", "0.6734082", "0.6590052", "0.65739864", "0.6554852", "0.6528611", "0.6488979", "0.6386227", "0.6384382", "0.6353202", "0.6342102", "0.63400286", "0.62900186", "0.62873715", "0.6286426...
0.80862015
0
Tell the RoboVac to start its autoclean programme.
def start_auto_clean(self): command = _build_robovac_command(RobovacModes.WORK, RobovacCommands.AUTO_CLEAN) message = self._build_command_user_data_message(command) self._send_packet(message, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run():\r\n autostartup()", "def manual_start(self):\n self.manual_seqnum = 0\n return self.send(\"app_rc_start\")", "def execute(self):\n\t\tself.drivetrain.bad_auto_drive()\n\t\tself.drivetrain.stop_robot()", "def start():\n # Have the car begin at a stop\n rc.drive.stop()\n # ...
[ "0.6365878", "0.6246379", "0.60141903", "0.59858924", "0.59144974", "0.58120424", "0.5807724", "0.577712", "0.57759285", "0.57748395", "0.5772731", "0.5752366", "0.5745088", "0.57284355", "0.57284355", "0.57284355", "0.57284355", "0.57233566", "0.5711464", "0.5709139", "0.568...
0.6807182
0
Tell the RoboVac to start its spotclean programme.
def start_spot_clean(self): command = _build_robovac_command(RobovacModes.WORK, RobovacCommands.SPOT_CLEAN) message = self._build_command_user_data_message(command) self._send_packet(message, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runmain():\n\n if roboapps.Unchecked():\n roboapps.Exit()\n else:\n AddDeleteObjectsScript()", "def start_auto_clean(self):\n command = _build_robovac_command(RobovacModes.WORK, RobovacCommands.AUTO_CLEAN)\n message = self._build_command_user_data_message(command)\n\n ...
[ "0.59675306", "0.59310967", "0.5914191", "0.5898601", "0.58888316", "0.5851248", "0.5851248", "0.5851248", "0.5851248", "0.5819597", "0.57119226", "0.57067347", "0.57007897", "0.56571686", "0.56343114", "0.562878", "0.5624732", "0.5615956", "0.56120574", "0.55993724", "0.5591...
0.6891785
0
Tell the RoboVac to start its edgeclean programme.
def start_edge_clean(self): command = _build_robovac_command(RobovacModes.WORK, RobovacCommands.EDGE_CLEAN) message = self._build_command_user_data_message(command) self._send_packet(message, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runmain():\n\n if roboapps.Unchecked():\n roboapps.Exit()\n else:\n AddDeleteObjectsScript()", "def _commitSuicide(self):\n\n # Kill multicast and zeroconf.\n self.multicast.kill()\n self.zeroconf.kill()\n\n # Stop us from running any further.\n self.ali...
[ "0.6004148", "0.5909393", "0.5895026", "0.5822715", "0.5812425", "0.58039004", "0.5768682", "0.57507056", "0.5685349", "0.5663432", "0.56619793", "0.548184", "0.54683137", "0.5454407", "0.5450739", "0.5444596", "0.543697", "0.5409681", "0.53943235", "0.5380903", "0.53745776",...
0.77722454
0