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
Parses data in FASTA format, returning a dictionary of ID's and values
def parse_fasta(dataset): records = {} record_id = None for line in [lines.strip() for lines in dataset.splitlines()]: if line.startswith('>'): records_id = line[1:] records[records_id] = "" else: records[records_id] += line #print r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_fasta(idfile):\n seqids = set()\n data = OrderedDict()\n fatalerror = False\n\n with open(idfile, 'r') as f:\n for l in f:\n p=l.strip().split(\"\\t\")\n seqids.add(p[0])\n for meta in re.findall('\\\\[(.*?)\\\\]', p[1]):\n tag,value=meta...
[ "0.7144738", "0.71094316", "0.70937115", "0.70374626", "0.70087034", "0.6974227", "0.69666076", "0.68982494", "0.6752071", "0.6681565", "0.6603911", "0.6540116", "0.6527103", "0.6511424", "0.6392904", "0.63163024", "0.6290002", "0.62782574", "0.6245942", "0.62225056", "0.6218...
0.7457893
0
defines paths used in the project
def setup_paths(self): # TODO: separate out paths based on android, json patch, server_gen. app_base_path = os.path.join(self.base_dir, self.app_name) build_dir = os.path.join(app_base_path, "build") api_spec_dir = os.path.join(app_base_path, "api_specs") api_spec_migrations_dir ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setPaths(self):\n self.local_path = g.os_path_join(g.app.loadDir,\"..\",\"plugins\",\"trees\")\n # self.remote_path = r\"cvs.sourceforge.net/viewcvs.py/leo/leo/plugins/trees\"\n self.remote_path = r'leo.tigris.org/source/browse/leo/plugins/trees'", "de...
[ "0.74094725", "0.69851", "0.69373894", "0.6904175", "0.67793167", "0.67096126", "0.6699563", "0.6644919", "0.6609328", "0.65943074", "0.654705", "0.65294915", "0.6497519", "0.64822596", "0.6475735", "0.6452517", "0.6397596", "0.6387752", "0.6367492", "0.6322775", "0.63158435"...
0.71442705
1
Merges the spec file if the api_spec folder cotains the spec folder which further contains the spec file as small parts divided into directories
def merge_spec(self): from django_swagger_utils.spec_client.merge_spec import MergeSpec merge_spec = MergeSpec(self.paths['api_spec_dir'], self.paths['base_dir']) merge_spec.merge()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_spec(self):\n from django_swagger_utils.spec_client.split_spec import SplitSpec\n from django_swagger_utils.core.utils.check_path_exists import check_path_exists\n\n if check_path_exists(os.path.join(self.paths['api_spec_dir'], \"specs\")):\n from shutil import rmtree\n ...
[ "0.70815337", "0.61341095", "0.58212", "0.570059", "0.56672597", "0.56513107", "0.5622673", "0.5533613", "0.5514947", "0.54947674", "0.5479076", "0.5448764", "0.5425334", "0.54163367", "0.53205514", "0.5305159", "0.52052", "0.5197745", "0.5196432", "0.5189943", "0.51627874", ...
0.8237632
0
splits the present api_spec.json into further spec folder divided into smaller bits
def split_spec(self): from django_swagger_utils.spec_client.split_spec import SplitSpec from django_swagger_utils.core.utils.check_path_exists import check_path_exists if check_path_exists(os.path.join(self.paths['api_spec_dir'], "specs")): from shutil import rmtree rmtr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_spec(self):\n from django_swagger_utils.spec_client.merge_spec import MergeSpec\n merge_spec = MergeSpec(self.paths['api_spec_dir'], self.paths['base_dir'])\n merge_spec.merge()", "def _get_spec(test_api_path=None):\n if test_api_path:\n with open(test_api_path) as fp:\n ...
[ "0.69047695", "0.6243941", "0.6083736", "0.59182966", "0.58347684", "0.58153063", "0.5641667", "0.56367815", "0.5471387", "0.54492575", "0.5409104", "0.54044205", "0.53588295", "0.5327551", "0.53110534", "0.5310031", "0.53096753", "0.529483", "0.5286684", "0.52753186", "0.526...
0.7731074
0
checks if settings file is present else writes app name to settings file
def check_create_settings_file(self): path = self.paths["settings_file"] from django_swagger_utils.core.utils.check_path_exists import check_path_exists settings_file = check_path_exists(path) if not settings_file: settings_file_contents = "# '%s' settings" % self.app_name ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_settings(self):\n #Check if file exists. If not, try to create it. Will handle permission error.\n if os.path.exists(self.file[\"file_name\"]):\n log.debug(\"'\"+ self.file[\"file_name\"] + \"' found.\")\n self.file[\"exists\"] = True\n else:\n log.d...
[ "0.617828", "0.60181403", "0.5886222", "0.5847448", "0.58236176", "0.57995415", "0.5792649", "0.5708491", "0.57047427", "0.56878984", "0.5684652", "0.55933803", "0.55093914", "0.54978377", "0.5385641", "0.53762406", "0.5350928", "0.5346491", "0.53076804", "0.5301256", "0.5297...
0.75049746
0
checks if build folder exists
def check_build_exists(self): path = self.base_dir + "/" + self.app_name + "/" + "build" from django_swagger_utils.core.utils.check_path_exists import check_path_exists build_dir = check_path_exists(path) if build_dir: raise Exception("Build Directory Already Exist, please ru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_build_dir(self):\n build_dir = local.path(str(CFG['build_dir']))\n self.assertTrue(build_dir.exists())", "def BuildExists(buildname):\n for platform in platforms:\n if not os.path.exists(builds_basedir+'/'+platform+'/'+buildname):\n return False\n return True", "d...
[ "0.7710627", "0.69909513", "0.67265636", "0.6623319", "0.65883416", "0.6535104", "0.6439045", "0.63865423", "0.6363125", "0.63009286", "0.628624", "0.62751466", "0.6261038", "0.6231834", "0.6209773", "0.6198998", "0.6178353", "0.61636716", "0.6153733", "0.6151091", "0.6145768...
0.8521299
0
generates the elements present in spec file
def generate_specs_build(self): from django_swagger_utils.drf_server.generators.swagger_generator import SwaggerGenerator swagger_gen = SwaggerGenerator(self.parser, self.paths, self.app_name) # generating request_response files swagger_gen.generate_request_response() # testing ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testgen(self):\n self.parse()\n self.generate()", "def generate():", "def generate(self):\n self._open_file()\n # copied from GenerateCSPEC.py\n self._write_header_and_defaults()\n self._write_source()\n self._write_sample()\n\n self._write_all_compon...
[ "0.69315565", "0.609186", "0.6035652", "0.6022456", "0.5891557", "0.58498234", "0.5791427", "0.5780457", "0.57448894", "0.5737415", "0.5737415", "0.57230824", "0.56962883", "0.5693901", "0.56797636", "0.56742364", "0.56742364", "0.56742364", "0.56725043", "0.56418717", "0.563...
0.6751265
1
deletes the build and docs
def clean(self): if os.path.exists(self.paths['build_dir']): shutil.rmtree(self.paths['build_dir']) if os.path.exists(os.path.join(self.base_dir, 'docs')): shutil.rmtree(os.path.join(self.base_dir, 'docs'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_docs(c):\n c.run(f\"rm -fr {DOCS_BUILD_DIR}\")", "def clean():\n if os.path.exists('_build'):\n shutil.rmtree('_build')", "def clean():\n shutil.rmtree(BUILD_PATH, ignore_errors=True)\n shutil.rmtree(os.path.join(SOURCE_PATH, \"reference\", \"api\"), ignore_errors=True)", ...
[ "0.8008018", "0.73921525", "0.7202849", "0.71937937", "0.7191889", "0.71879315", "0.71226585", "0.71223074", "0.6785936", "0.675218", "0.66965014", "0.6622752", "0.6595002", "0.6550336", "0.6538673", "0.6537447", "0.6501988", "0.6487052", "0.6486671", "0.645849", "0.6454612",...
0.76615465
1
Parse date string in PDB format into date object.
def date_parse(date_string) -> datetime: return datetime.strptime(date_string, DATE_FMT)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_date(str_date):\n return ciso8601.parse_datetime(str_date)", "def parse(self, str):\n values = self._exp.findall(str)\n if values is None or len(values) == 0:\n return None\n\n values = values[0]\n assert(len(values) == 3)\n\n day = int(values[self._dmy_...
[ "0.70005536", "0.69507515", "0.6785745", "0.67294407", "0.6724376", "0.66933346", "0.66749436", "0.6632981", "0.6629444", "0.6627965", "0.66267604", "0.6625223", "0.65931207", "0.65875304", "0.65659595", "0.65577215", "0.6555612", "0.65031195", "0.64657944", "0.6454686", "0.6...
0.71310633
0
Convert a CIF object to a DataFrame.
def cif_df(cif_object) -> DataFrame: if cif_object is None: return DataFrame() row_list = cif_object.row_list attr_list = cif_object.attribute_list return DataFrame(data=row_list, columns=attr_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pif_to_dataframe(pifobj):\n data = dict([(p.name, p.scalars) for p in pifobj.properties])\n return pd.DataFrame(data)", "def arcgis_table_to_dataframe(in_fc, input_fields=None, query=\"\", skip_nulls=False, null_values=None):\n OIDFieldName = arcpy.Describe(in_fc).OIDFieldName\n if input_fields:\...
[ "0.67621255", "0.6124349", "0.6089718", "0.5857996", "0.5655795", "0.564409", "0.5605601", "0.5597169", "0.5587554", "0.557797", "0.55756384", "0.5562676", "0.55154836", "0.55151707", "0.5467921", "0.54509425", "0.5448615", "0.54308015", "0.5425808", "0.5422454", "0.5410389",...
0.8306937
0
Parse line of PDB file.
def parse_pdb(self, line): if line is not None: self.original_text.append(line.rstrip("\r\n"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_pdb(self, line):\n super().parse_pdb(line)\n self.num_remark = int(line[10:15].strip())\n self.num_het = int(line[20:25].strip())\n self.num_helix = int(line[25:30].strip())\n self.num_sheet = int(line[30:35].strip())\n self.num_turn = int(line[35:40].strip())\n ...
[ "0.77458894", "0.7673778", "0.68397", "0.6473047", "0.63162446", "0.6258802", "0.6155045", "0.6090509", "0.6081808", "0.60300386", "0.6014474", "0.5998233", "0.5998233", "0.5998233", "0.5998233", "0.59687793", "0.5947438", "0.5922465", "0.5905766", "0.59041876", "0.5825254", ...
0.7706522
1
Parse CIF container for information about this record.
def parse_cif(self, container) -> bool: raise NotImplementedError("BaseRecord does not implement parse_cif.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_record(self, in_rec):\n \n self.metadata = {}\n for k, v in in_rec.items():\n if k == 'parameters':\n for m, mv in v.items():\n self.metadata[m] = mv\n else:\n self.metadata[k] = v\n \n if se...
[ "0.6264302", "0.6196998", "0.61213064", "0.564772", "0.55726945", "0.5529491", "0.54910994", "0.54539806", "0.5418217", "0.53826207", "0.5313438", "0.5291224", "0.5283259", "0.5281808", "0.5279189", "0.5270132", "0.5259035", "0.52574104", "0.51915336", "0.5189451", "0.5167783...
0.70957905
0
Adds and removes the given words from the query, returning the new ?q.
def modify_search(add=[], remove=[]): query = request.args.get('q', '').split() query = [x.strip() for x in query if x.strip()] for word in remove: if word in query: query.remove(word) for word in add: if word and word not in query: query.append(word) retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter(q_words):\n filtered_words = [\"how\",\"what\"]\n for word in q_words:\n if word in filtered_words:\n q_words.remove(word)", "def removestopwords(query):\n wordlist = [word for word in query.split() if word not in stopwords.words('english')]\n return \" \".join(wordlist)"...
[ "0.64603466", "0.63632005", "0.6250111", "0.6125075", "0.6096852", "0.6071776", "0.5995022", "0.58438754", "0.57594866", "0.5692303", "0.5623006", "0.56003267", "0.55980396", "0.5558742", "0.5541352", "0.5461948", "0.54305816", "0.5427023", "0.541576", "0.5401241", "0.5363689...
0.7439704
0
Execute the strategy (in self.strat) in its directory with option. Threre will be file playfield.txt with all the required data in CWD of the strategy. Make sure we have some way how to run strategy as different user, under some ulimit settings (both not by default) and with timeout of, say, 3 seconds. Return STDOUT, l...
def execute(self, current_round=0): # We do expect playfield.txt file for this strategy exists # Execute the strategy ###print ">>> execute: Going to run './%s %s'" % (self.stratbin, str(self.id)) def runuser(uid=os.getuid(), gid=os.getgid()): return lambda : (os.setgid(gid), os.setuid(uid)) # gro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_test(self, testcase, name, options):\n name = options.suite+'_'+name\n cmd = options.solver+' '\n if not options.cat_options is None:\n cmd += options.cat_options+' '\n cmd += options.file\n print( \"Running test suite '%s' test '%s' command '%s'\" % \\\n ...
[ "0.5147259", "0.5145172", "0.51435417", "0.51267624", "0.510539", "0.5068345", "0.5063051", "0.504805", "0.501544", "0.49921215", "0.4969483", "0.49090382", "0.4906397", "0.4894149", "0.48909965", "0.48695678", "0.48690993", "0.4868202", "0.48600283", "0.48330626", "0.4827129...
0.7317411
0
Return structure with list of ingredients (connected by this strategy paths) this strategy could turn into potion. Format of the structure
def want_to_use(self, plan): # Get list of all ingredients available # (we do not care about stones - i.e. multiple paths, these will be # taken care later when brewing the potion) ingredients = {} for path in plan.get_paths_for_strat(self.id): for cell in path: for ingredient in plan[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getIngredients():\n ingredients = ['Whiskey', 'Tequila', 'Vodka', 'Blue Curacao', 'Orange Juice',\n 'Pineapple Juice', 'Cranberry Juice', 'Sour Mix']\n return ingredients", "def get_ingredients(self):\n try:\n ingredients = self.soup.find_all(class_=\"ingredient-grou...
[ "0.58865327", "0.5872826", "0.58088017", "0.56609994", "0.5642955", "0.55576724", "0.5556588", "0.55418646", "0.54594487", "0.54061735", "0.53916126", "0.5350365", "0.53464746", "0.5283408", "0.5280605", "0.52669126", "0.52427673", "0.5220994", "0.5215416", "0.51952523", "0.5...
0.5980633
0
repeat alarm sound for n times
def alarm(n): for i in range(n): playsound(sound_file) time.sleep(2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def repeat(ctx, times : int, content='repeating...'):\n for i in range(times):\n await bot.say(content)", "async def repeat(times : int, content='repeating...'):\n for i in range(times):\n await bot.say(content)", "async def alarm(ctx, on_time:float=1, off_time:float=0.6, n:int=5):\n ...
[ "0.68770796", "0.6849259", "0.68342257", "0.67419875", "0.66999686", "0.66024566", "0.6568434", "0.6567636", "0.65670884", "0.6516643", "0.64148456", "0.62770265", "0.6269237", "0.6208329", "0.60853404", "0.6065996", "0.6037698", "0.60132885", "0.6004515", "0.595587", "0.5875...
0.8713805
0
Provides direct, containerlike read access to the stash contents.
def __getitem__(self, key): return self.__contents.get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, key) -> Any:\n return self.__stash[key]", "def read(self, store):\r\n path = f\"{self.system.config_path}/.storage/{STORES[store]}\"\r\n content = None\r\n if os.path.exists(path):\r\n with open(path, \"r\", encoding=\"utf-8\") as storefile:\r\n ...
[ "0.59898967", "0.57666814", "0.568542", "0.5532821", "0.54642844", "0.54636073", "0.5312285", "0.5279004", "0.52746546", "0.52423954", "0.5224223", "0.521369", "0.52109045", "0.5177152", "0.5157556", "0.5149593", "0.51343304", "0.51218504", "0.51195395", "0.51047087", "0.5095...
0.59172964
1
Creates a copy of the current stash object to effect localisation of variables. The new stash is blessed into the same class as the parent (which may be a derived class) and has a '__parent' member added which contains a reference to the parent stash that created it (self). This member is used in a successive declone()...
def clone(self, params=None): params = params or {} import_ = params.get("import") if isinstance(import_, dict): del params["import"] else: import_ = None clone = Stash() clone.__contents.update(self.__contents) clone.__contents.update(para...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self):\n new_state = State(self.final)\n for symbol in self.children:\n child = self.children[symbol]\n new_state.add_child(child.copy(), symbol)\n return new_state", "def copy(self):\n return self.__class__(dict(self))", "def clone(self):\n # c...
[ "0.6140688", "0.60793346", "0.6044713", "0.604228", "0.5949979", "0.592476", "0.5805445", "0.57796705", "0.5771301", "0.575878", "0.5753265", "0.56917924", "0.5665738", "0.5663182", "0.56335366", "0.56281644", "0.5624358", "0.5609338", "0.55612534", "0.553797", "0.5529686", ...
0.6740829
0
Similar to __dotop, but assigns a value to the given variable instead of simply returning it. The first three parameters are the root item, the item and arguments, as per __dotop, followed by the value to which the variable should be set and an optional 'default' flag. If set true, the variable will only be set if curr...
def __assign(self, root, item, args=None, value=None, default=False): item = util.unscalar(item) args = util.unscalar_list(args) atroot = root is self if root is None or item is None: return None elif self.PRIVATE and re.search(self.PRIVATE, item): return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __dotop(self, root, item, args=None, lvalue=False):\n root = util.unscalar(root)\n item = util.unscalar(item)\n args = util.unscalar_list(args)\n atroot = root is self\n result = None\n\n # return undef without an error if either side of dot is unviable\n if roo...
[ "0.5400656", "0.5252006", "0.5194746", "0.5177184", "0.5176615", "0.50971186", "0.508259", "0.5026646", "0.49248418", "0.48988074", "0.48834684", "0.4870692", "0.48477024", "0.48428822", "0.4824025", "0.48189852", "0.48185033", "0.48094812", "0.47769058", "0.47708303", "0.476...
0.65668845
0
This is the core 'dot' operation method which evaluates elements of variables against their root. All variables have an implicit root which is the stash object itself. Thus, a noncompound variable 'foo' is actually '(stash.)foo', the compound 'foo.bar' is '(stash.)foo.bar'. The first parameter is the current root, init...
def __dotop(self, root, item, args=None, lvalue=False): root = util.unscalar(root) item = util.unscalar(item) args = util.unscalar_list(args) atroot = root is self result = None # return undef without an error if either side of dot is unviable if root is None or ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, ident, args=None):\n ident = util.unscalar(ident)\n root = self\n if isinstance(ident, str) and ident.find(\".\") != -1:\n ident = [y for x in ident.split(\".\")\n for y in (re.sub(r\"\\(.*$\", \"\", x), 0)]\n if isinstance(ident, (list, tupl...
[ "0.61540854", "0.56396735", "0.54283345", "0.5222373", "0.51779175", "0.5170587", "0.5035488", "0.49996212", "0.49987176", "0.49969715", "0.49589795", "0.4893627", "0.48422173", "0.48420754", "0.48354545", "0.48255888", "0.48199978", "0.4772765", "0.4737523", "0.4691546", "0....
0.6878302
0
Defines a virtual method of type 'type' ('scalar', 'item', 'hash', 'list', or 'array'), with name 'name', that invokes 'func' when called. It is expected that func be able to handle the type that it will be called upon.
def define_vmethod(self, type, name, func): try: self.OPS[type.lower()][name] = func except KeyError: raise Error("invalid vmethod type: %s\n" % type)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def virtual(func: \"callable\"):\n return func", "def method(rtype):\n\n def decorator(func):\n argcount = func.__code__.co_argcount\n argnames = func.__code__.co_varnames[:argcount]\n ndefaults = 0\n if func.__defaults__:\n ndefaults = len(func.__defaults__)\n\n ...
[ "0.60031813", "0.56447136", "0.54803646", "0.5472923", "0.5422841", "0.52681327", "0.5243924", "0.5217417", "0.5195495", "0.5195495", "0.51676446", "0.5024345", "0.5000798", "0.49887475", "0.49710283", "0.49486372", "0.49339885", "0.492594", "0.48926035", "0.48863173", "0.488...
0.7534037
0
Merges the `n2` into `n1` in a serial manner which means that the infinite pole from `n1` is identified with the 0pole from `n2`.
def merge_networks_in_series(n1, n2): new_l_size = n1.l_size + n2.l_size + 1 # One additional vertex in between. new_u_size = n1.u_size + n2.u_size # Connect the 0-pole and the inf-pole in the result network. new_link_edge = n1.zero_pole.insert_before() new_link_edge_opp = n2.inf_pole.insert_after...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(self, nums1, m, nums2, n):\n nums1.extend([0]*n)\n j=0\n for i in range(len(nums1)):\n if nums2[j]<nums1[i]:\n nums1.remove(0)\n nums1.insert(i,nums2[j])\n j=j+1", "def merge_networks_in_parallel(n1, n2):\n # This operation...
[ "0.6919478", "0.68806326", "0.6808735", "0.67938113", "0.6787921", "0.6732088", "0.6728672", "0.6711408", "0.6710587", "0.66686463", "0.6582117", "0.6526806", "0.6468124", "0.64402544", "0.6433177", "0.6428149", "0.64224076", "0.6422399", "0.6395181", "0.6382939", "0.6371392"...
0.7410205
0
Merges network `n1` and network `n2` in parallel which means their respective infpoles and 0poles coincide.
def merge_networks_in_parallel(n1, n2): # This operation is not defined if both networks are linked. assert not (n1.is_linked and n2.is_linked), (n1, n2) if n1.is_linked: return merge_networks_in_parallel(n2, n1) # Either n2 is linked and n1 not or both are not linked. assert not n1.is_lin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_networks_in_series(n1, n2):\n new_l_size = n1.l_size + n2.l_size + 1 # One additional vertex in between.\n new_u_size = n1.u_size + n2.u_size\n\n # Connect the 0-pole and the inf-pole in the result network.\n new_link_edge = n1.zero_pole.insert_before()\n new_link_edge_opp = n2.inf_pole.i...
[ "0.7803285", "0.66647637", "0.64747465", "0.6251946", "0.6150154", "0.6033627", "0.59893656", "0.5977883", "0.5924674", "0.5888481", "0.5885177", "0.58404946", "0.58275425", "0.578211", "0.57813644", "0.5741289", "0.5734445", "0.572294", "0.5633455", "0.56284475", "0.5612441"...
0.8240344
0
Substitute the edge from the three connected graph with the whole network given as an argument.
def substitute_edge_by_network(half_edge_for_sub, network): assert half_edge_for_sub.opposite is not None assert half_edge_for_sub.next is not None assert half_edge_for_sub.opposite.next is not None # Plug it in. half_edge_for_sub.insert_all_before(network.zero_pole.prior) half_edge_for_sub.op...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multi_edge():\n from networkx.readwrite import json_graph\n import networkx as nx\n import autonetkit\n # returns a house graph\n data = {'directed': False,\n 'graph': [],\n 'links': [{'_ports': {'r4': 2, 'r5': 1},\n 'raw_interfaces': {},\n ...
[ "0.63468057", "0.59780157", "0.5947577", "0.5717881", "0.56756675", "0.5651474", "0.56309015", "0.5630487", "0.5559175", "0.5521967", "0.5509478", "0.54803336", "0.5439024", "0.5435109", "0.5388986", "0.53773564", "0.53773415", "0.5350341", "0.5348793", "0.5345469", "0.534234...
0.6164189
1
Parse the output of the ATI command.
def parse_ati(output: typing.List[str]) -> typing.Tuple[str, str, str]: i = 0 for line in output: line = line.strip() if not line: # skip empty lines continue if line == "ATI": # skip the command itself continue if line[0] == "^": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_output(result):\n output = result['output']\n parsed = output.split('\\n')\n output = []\n for _line in parsed:\n output.append(_line.strip())\n log.debug(_line)\n return output", "def parse_cli_output(self, output, operation, name, index):\n state = None\n re...
[ "0.61722517", "0.6016628", "0.60104716", "0.5935387", "0.59182775", "0.58249426", "0.57234156", "0.5719187", "0.57040447", "0.57002324", "0.5595886", "0.5567088", "0.5558696", "0.5558696", "0.5558696", "0.5558696", "0.5524446", "0.55037874", "0.54675514", "0.54522246", "0.544...
0.7263934
0
Parse the output of the AT+GSN command.
def parse_atgsn(output: typing.List[str]) -> str: for line in output: line = line.strip() if not line: # skip empty lines continue if line == "AT+GSN": # skip the command itself continue if line[0] == "^": # skip unsolicited...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_atcsq(output: typing.List[str]) -> typing.Tuple[int, int]:\n for line in output:\n line = line.strip()\n if not line:\n # skip empty lines\n continue\n if line == \"AT+GSN\":\n # skip the command itself\n continue\n if line[0] == ...
[ "0.6080721", "0.5836673", "0.5618207", "0.5559816", "0.549535", "0.5150543", "0.5116782", "0.50926626", "0.49595982", "0.49542406", "0.4950551", "0.49218398", "0.4903271", "0.48995614", "0.4896791", "0.48894602", "0.48577568", "0.48234838", "0.48179063", "0.480966", "0.479565...
0.81624514
0
Parse the output of the AT+CSQ command.
def parse_atcsq(output: typing.List[str]) -> typing.Tuple[int, int]: for line in output: line = line.strip() if not line: # skip empty lines continue if line == "AT+GSN": # skip the command itself continue if line[0] == "^": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def QCC(fp, csiz):\n lqcc = unpack('>H', fp.read(2))[0]\n if csiz < 257:\n cqcc = unpack('B', fp.read(1))[0]\n else:\n cqcc = unpack('>H', fp.read(2))[0]\n\n sqcc = unpack('B', fp.read(1))[0]\n\n _spqcc = []\n\n info = {\n\n }\n\n return info", "def parse_cp_xml_output(data)...
[ "0.59397763", "0.55422676", "0.54964143", "0.51435274", "0.5113471", "0.5090068", "0.5009076", "0.49979028", "0.49873358", "0.49716341", "0.49417123", "0.48660752", "0.48624974", "0.4856454", "0.48349488", "0.48331365", "0.48136386", "0.47969127", "0.47849038", "0.47531924", ...
0.7439061
0
return csv file path given ticker symbol.
def symbol_to_path(symbol, base_dir="data"): return os.path.join(base_dir,"{}.csv".format(str(symbol)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def symbol_to_path(symbol, base_dir=\"../data\"):\n return os.path.join(base_dir, \"{}.csv\".format(str(symbol)))", "def symbol_to_path(symbol, base_dir=\"../data\"):\n return os.path.join(base_dir, \"{}.csv\".format(str(symbol)))", "def symbol_to_path(symbol, base_dir=\"../data\"):\n return os.path.j...
[ "0.746073", "0.746073", "0.746073", "0.7443982", "0.7443982", "0.74315524", "0.73397034", "0.7248237", "0.71703756", "0.7162625", "0.7087608", "0.6146116", "0.61356944", "0.5987317", "0.5883038", "0.5757225", "0.5753798", "0.5753684", "0.5679381", "0.5649763", "0.56201315", ...
0.7537187
0
Return a list of tuples of all heartbeats.
def list_heartbeats(issuer=None, vo='def'): kwargs = {'issuer': issuer} if not permission.has_permission(issuer=issuer, vo=vo, action='list_heartbeats', kwargs=kwargs): raise exception.AccessDenied('%s cannot list heartbeats' % issuer) return heartbeat.list_heartbeats()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slice_heartbeats(self):\n sampling_rate = self.additional_fields['fs'] # 360 samples per second\n logging.info(\"Sampling rate: {}\".format(sampling_rate))\n assert sampling_rate == 360\n before = 0.2 # 0.2 seconds == 0.2 * 10^3 miliseconds == 200 ms\n after = 0.4 # --> 40...
[ "0.63400567", "0.6096023", "0.60586447", "0.5924782", "0.5654347", "0.5629577", "0.5601344", "0.5517192", "0.5344003", "0.533629", "0.5288832", "0.5286065", "0.5274333", "0.52735746", "0.5261861", "0.5242322", "0.524048", "0.52402", "0.5228762", "0.52170825", "0.52088976", ...
0.6105099
1
r""" Initializes a cell, accepting a location and either a single value or a collection of potential values. Locations should uniquely identify cells within a puzzle. All potential values should be hashable and truthy. The collection of symbols used by a puzzle will most likely be integers. If the puzzle uses 0 as a va...
def __init__(self, location: tuple, value: Hashable = None, potential_values: Collection[Hashable] = None): assert bool(value) ^ bool(potential_values), ( "A Cell must have either a single value or a collection of \ potential values. At least one must be truthy, but not both." ) self._location = location...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(cell, value):\n\t\tcell.value = value\n\t\tcell.parent = None\n\t\tcell.visited = False", "def __init__(self, cell_type, explicit_values,\n derived_values=None, non_column_labels=None, align='',\n sort_values=True):\n self.type = cell_type\n self.align = align\n ...
[ "0.638228", "0.60452604", "0.588155", "0.588155", "0.5862274", "0.58448195", "0.58274966", "0.5748701", "0.56810075", "0.5671946", "0.56705356", "0.56476027", "0.5589364", "0.55377805", "0.55342674", "0.5533705", "0.5515791", "0.551168", "0.5489072", "0.54860216", "0.54807574...
0.8121236
0
Retrieves the value of the cell, if the value has been set or if the set of potential values only contains one item. If this result is truthy, it indicates that the cell is solved.
def value(self) -> Optional[Hashable]: if self._value: return self._value if len(self._potential_values) == 1: self.set_value(next(iter(self._potential_values))) return self._value return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def val(self) -> bool:\n return self._val", "def getCellValue_quick(self, row, column):\n\n\t\t\t\treturn self.thing[f\"{column}{row}\"].value", "def value(self):\n '''\n if self.hash_pattern:\n msg = \"\"\"It is too costly to construct the full value of a deep cell\n Use cel...
[ "0.64555347", "0.64073485", "0.6395754", "0.62796843", "0.62663734", "0.6234748", "0.621787", "0.621787", "0.61359787", "0.6126846", "0.6120597", "0.6035258", "0.6024566", "0.60172796", "0.5995119", "0.5991808", "0.59882987", "0.5969819", "0.5952601", "0.5951196", "0.59438795...
0.6921653
0
Returns the set of potential values for the cell.
def potential_values(self) -> Set[Hashable]: return set(self.iter_potential_values())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def potential_value_map(self) -> DefaultDict[Hashable, Set[Cell]]:\n\n\t\tvalue_to_cell_map = defaultdict(set)\n\n\t\tfor cell in self:\n\t\t\tif not cell.value():\n\t\t\t\tfor value in cell.potential_values():\n\t\t\t\t\tvalue_to_cell_map[value].add(cell)\n\n\t\treturn value_to_cell_map", "def values(self):\n ...
[ "0.69516367", "0.65804684", "0.65563345", "0.65232474", "0.64810246", "0.6365607", "0.6365607", "0.6299644", "0.62220335", "0.61794114", "0.61606157", "0.6149264", "0.614006", "0.6139558", "0.61122125", "0.6106272", "0.60677105", "0.604364", "0.6042069", "0.603631", "0.603211...
0.7606223
0
Removes a set of values from the set of potential values for this cell. Returns true if any values were removed.
def remove_values(self, values: Collection[Hashable]) -> bool: any_values_removed = False for value in values: if value in self._potential_values: self._potential_values.remove(value) any_values_removed = True return any_values_removed
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(self, val: int) -> bool:\n if val in self.value_set:\n self.value_set.remove(val)\n if val in self.values:\n self.values.remove(val)\n return True\n else:\n return False", "def remove_values(self, name, remove):\n # Do we ...
[ "0.6935836", "0.6639579", "0.63820225", "0.63244003", "0.63180715", "0.62305385", "0.6206004", "0.6184352", "0.6167851", "0.6142277", "0.60859245", "0.60808724", "0.6015888", "0.5993626", "0.5955171", "0.5798452", "0.57944524", "0.5752395", "0.57440424", "0.5700627", "0.56881...
0.8618023
0
Returns a set of the solved cells within the group.
def solved_cells(self) -> Set[Cell]: return set(self.iter_solved_cells())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsolved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_unsolved_cells())", "def unsolved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_unsolved_cells())", "def iter_solved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif cell.value()\n\t\t)", "def known_mines(se...
[ "0.65669245", "0.65669245", "0.64022344", "0.6374435", "0.61963224", "0.6166903", "0.60594565", "0.60156053", "0.5990616", "0.5949934", "0.59069836", "0.5874509", "0.58058786", "0.57834136", "0.5769051", "0.5742712", "0.57256174", "0.57071185", "0.56887406", "0.56554234", "0....
0.7764358
0
Returns a set of the unsolved cells within the group.
def unsolved_cells(self) -> Set[Cell]: return set(self.iter_unsolved_cells())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_unsolved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif not cell.value()\n\t\t)", "def solved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_solved_cells())", "def solved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_solved_cells())", "def iter_unsolved_ce...
[ "0.73319674", "0.7275504", "0.7275504", "0.71549755", "0.68509763", "0.65893537", "0.6252384", "0.6164879", "0.6162847", "0.61160684", "0.6070986", "0.5977714", "0.5958569", "0.59541273", "0.59089404", "0.5905999", "0.5869687", "0.57962584", "0.5629947", "0.56231874", "0.5583...
0.8278758
0
Returns an iterator over the unsolved cells within the group.
def iter_unsolved_cells(self) -> Iterable[Cell]: return ( cell for cell in self if not cell.value() )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_unsolved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif not cell.value()\n\t\t)", "def iter_solved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif cell.value()\n\t\t)", "def iter_solved_cells(self) -> Iterable[Cell]:\n\t\treturn (\n\t\t\...
[ "0.7526114", "0.7240534", "0.69938797", "0.6757442", "0.6757442", "0.6729137", "0.63677096", "0.5864948", "0.58371526", "0.58285975", "0.58285975", "0.5664698", "0.5543313", "0.5404385", "0.53992265", "0.5355664", "0.5341837", "0.5341571", "0.5285871", "0.52575755", "0.523965...
0.73706084
1
Returns a default dict that maps each of the distinct hashable values from the group's collection of cells to sets containing the unsolved cells that have the value in their set of potential values.
def potential_value_map(self) -> DefaultDict[Hashable, Set[Cell]]: value_to_cell_map = defaultdict(set) for cell in self: if not cell.value(): for value in cell.potential_values(): value_to_cell_map[value].add(cell) return value_to_cell_map
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possible_values(self) -> Set[int]:\n return {x for x in SudokuTile.UNIVERSE_OF_TILE_VALUES if\n (x not in self._row) and\n (x not in self._column) and\n (x not in self._box)}", "def potential_values(self) -> Set[Hashable]:\n\t\treturn set(self.iter_potentia...
[ "0.63580453", "0.613797", "0.61278075", "0.5977299", "0.5821767", "0.5821767", "0.563843", "0.5638131", "0.5638131", "0.5632904", "0.55578595", "0.5538161", "0.5535749", "0.55279213", "0.5506499", "0.5484133", "0.54443246", "0.5401276", "0.5389691", "0.53285205", "0.5322204",...
0.7748872
0
Returns `PuzzleState.Solved` if all of the cells in this puzzle have a value and there are no value conflicts. Returns `PuzzleState.Conflict` if there are any groups that contain a duplicate value or if there are any cells that have Returns `PuzzleState.Unsolved` otherwise.
def state(self) -> PuzzleState: for cell in self._cells: if not (cell.value() or any(cell.potential_values())): return PuzzleState.Conflict for group in self._groups: if len(group.unsolved_cells()) > 0: return PuzzleState.Unsolved distinct_values = set() for cell in group: value = cell.val...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_solved(self):\n # Iterate through each square of the puzzle\n for row in range(self.sl):\n for col in range(self.sl):\n val = self.puzzle[row][col]\n\n # If any square value is blank (0), not solved, return False\n if val == 0:\n ...
[ "0.6175382", "0.6018127", "0.58406824", "0.5810999", "0.5751895", "0.5744773", "0.57415646", "0.5707494", "0.5695524", "0.56833696", "0.5678637", "0.563252", "0.5609082", "0.560853", "0.5607858", "0.5603728", "0.55887574", "0.5579692", "0.55738354", "0.55738354", "0.55736774"...
0.857463
0
Returns a set of the solved cells within the puzzle.
def solved_cells(self) -> Set[Cell]: return set(self.iter_solved_cells())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsolved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_unsolved_cells())", "def unsolved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_unsolved_cells())", "def iter_solved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif cell.value()\n\t\t)", "def iter_solved_ce...
[ "0.7662385", "0.7662385", "0.7452958", "0.7315246", "0.6874305", "0.6783004", "0.6691106", "0.66309947", "0.66179585", "0.6562532", "0.6532909", "0.65113026", "0.64803386", "0.64668894", "0.6466478", "0.64366716", "0.64361703", "0.6427201", "0.64164346", "0.64058936", "0.6328...
0.88874316
1
Returns a set of the unsolved cells within the puzzle.
def unsolved_cells(self) -> Set[Cell]: return set(self.iter_unsolved_cells())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_solved_cells())", "def solved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_solved_cells())", "def iter_unsolved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif not cell.value()\n\t\t)", "def iter_unsolved_ce...
[ "0.8286306", "0.8286306", "0.78360254", "0.7729228", "0.76062495", "0.7410148", "0.68055063", "0.66795325", "0.66605866", "0.65803957", "0.65233576", "0.6479214", "0.6407047", "0.6404423", "0.6384383", "0.6331265", "0.6312287", "0.62504005", "0.62066376", "0.6196511", "0.6187...
0.8960129
0
Returns all of the groups that contain the cell.
def get_groups(self, cell: Cell) -> Set[Group]: assert cell in self._cells return self._cells_to_group_map[cell]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getGroups(self):\n return [g[0] for g in grp.getgrall()]", "def find_groups(self, mesh):\n grp_names = []\n for grp in self._grps.values():\n grp_names.extend(grp.find_groups(mesh))\n return grp_names", "def all_groups(self):\n return self._all_groups", "def ...
[ "0.70231766", "0.70046043", "0.6893363", "0.6822474", "0.68041486", "0.67781246", "0.6750775", "0.6714758", "0.6709411", "0.66921616", "0.66921616", "0.66921616", "0.6601558", "0.6598648", "0.65426993", "0.65381634", "0.6530643", "0.6529657", "0.64851063", "0.64066243", "0.63...
0.8159539
0
Returns an iterator over the groups in the puzzle.
def iter_groups(self): return iter(self._groups)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n try:\n groupNames = sorted(self.groups)\n except Exception: # pragma: no cover\n groupNames = self.groups.keys()\n\n for groupName in groupNames:\n yield groupName, self[groupName]", "def groups(self):\n yield self\n for me...
[ "0.73305964", "0.7212274", "0.67755157", "0.67335814", "0.6647471", "0.6565033", "0.6516427", "0.6505143", "0.65034115", "0.6448981", "0.64324117", "0.6395778", "0.6394258", "0.63677824", "0.63666403", "0.635868", "0.6304126", "0.6304126", "0.6304126", "0.6256036", "0.6235972...
0.852828
0
Returns an iterator over the cells in the puzzle.
def iter_cells(self): return iter(self._cells)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_solved_cells(self) -> Iterable[Cell]:\n\t\treturn (\n\t\t\tcell\n\t\t\tfor cell in self\n\t\t\tif cell.value()\n\t\t)", "def iter_solved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif cell.value()\n\t\t)", "def __iter__(self) -> Iterator[Position]:\n for row in ...
[ "0.71127427", "0.7054564", "0.6944437", "0.6774976", "0.6749472", "0.6650549", "0.6609113", "0.6598986", "0.6592537", "0.658324", "0.652659", "0.64958423", "0.64883626", "0.6471173", "0.6449361", "0.64390534", "0.6435048", "0.6384694", "0.6382912", "0.63688135", "0.6364963", ...
0.8153685
0
Returns an iterator over the unsolved cells in the puzzle.
def iter_unsolved_cells(self): return ( cell for cell in self._cells if not cell.value() )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_solved_cells(self):\n\t\treturn (\n\t\t\tcell for cell in\n\t\t\tself._cells\n\t\t\tif cell.value()\n\t\t)", "def iter_unsolved_cells(self) -> Iterable[Cell]:\n\t\treturn (\n\t\t\tcell\n\t\t\tfor cell in self\n\t\t\tif not cell.value()\n\t\t)", "def iter_solved_cells(self) -> Iterable[Cell]:\n\t\tretu...
[ "0.79956746", "0.7966442", "0.7800592", "0.7351259", "0.7351259", "0.68564415", "0.68095136", "0.67133224", "0.67133224", "0.6521327", "0.6262557", "0.6174534", "0.61681205", "0.60406977", "0.60084456", "0.59465307", "0.590435", "0.5882613", "0.5840154", "0.5832151", "0.58065...
0.805968
0
Returns an iterator over the solved cells in the puzzle.
def iter_solved_cells(self): return ( cell for cell in self._cells if cell.value() )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_solved_cells(self) -> Iterable[Cell]:\n\t\treturn (\n\t\t\tcell\n\t\t\tfor cell in self\n\t\t\tif cell.value()\n\t\t)", "def iter_cells(self):\n\t\treturn iter(self._cells)", "def solved_cells(self) -> Set[Cell]:\n\t\treturn set(self.iter_solved_cells())", "def solved_cells(self) -> Set[Cell]:\n\t\t...
[ "0.7774136", "0.76822346", "0.7124125", "0.7124125", "0.6504885", "0.6445126", "0.6438824", "0.6412531", "0.6322154", "0.62992907", "0.62624913", "0.6245896", "0.62423897", "0.6198973", "0.6179868", "0.6176164", "0.61689204", "0.6119468", "0.6090956", "0.6089468", "0.6079688"...
0.78568774
0
Retrieves a single cell given a location.
def get_cell(self, location: Hashable) -> Cell: return self._location_to_cell_map.get(location, None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cell(self, location):\n if 0 <= location[0] < self.boardSize and 0 <= location[1] < self.boardSize:\n return self.board[location[0]][location[1]]\n else:\n raise Exception(\"There is no cell at the given location\")", "def get_cell(self, index, column):\n idx = ...
[ "0.8082742", "0.736209", "0.73140186", "0.70865417", "0.7082656", "0.7052371", "0.6962005", "0.69540155", "0.69432884", "0.6920298", "0.6893466", "0.6889122", "0.6838327", "0.67824155", "0.6779269", "0.6689697", "0.6649001", "0.655728", "0.6527815", "0.6525578", "0.6503857", ...
0.8568169
0
Initializes the BatchEmbedder and adds all words in `word_to_index` to the nn.Embedding cache.
def __init__(self, embedder: Embedder, word_to_index: OrderedDict, init_cache_size: int = 1, cuda: bool = False): if set(range(len(word_to_index))) != set(word_to_index.values()): raise ValueError('word_to_index must map to every in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,\n embedder: Embedder,\n word_to_index: Dict[str, int],\n cuda: bool = False):\n super(IndexBatchEmbedder, self).__init__(embedder, OrderedDict(word_to_index), cuda=cuda)", "def __init__(self,\n embedder: Embedder,\n ...
[ "0.7753382", "0.74987406", "0.6924036", "0.67547274", "0.64866227", "0.6432364", "0.6411349", "0.63214135", "0.62944937", "0.6267745", "0.62198126", "0.6190684", "0.6160179", "0.613955", "0.6138261", "0.6119968", "0.6108442", "0.60730577", "0.60652846", "0.6037334", "0.597381...
0.7850813
0
Returns the word embedding dimension.
def get_dimension(self) -> int: return self.embedder.get_dimension()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _embedding_dim(vocab_size):\n if not vocab_size or (vocab_size <= 0):\n raise ValueError(\"Invalid vocab_size %g.\" % vocab_size)\n return int(round(6.0 * math.sqrt(math.sqrt(vocab_size))))", "def dimension(self):\n return self._dim", "def input_dim(use_word_emb, embedding_dim, word_emb_enc_dim...
[ "0.76153374", "0.7237442", "0.7191883", "0.7161444", "0.71207756", "0.71207756", "0.71207756", "0.71207756", "0.7087317", "0.7069829", "0.70642155", "0.7048754", "0.7035747", "0.70297676", "0.70257556", "0.6992874", "0.6979675", "0.6955945", "0.6948382", "0.69256014", "0.6917...
0.7833573
0
Moves the cached embeddings to GPU and changes `self.embed` to return GPU tensors.
def cuda(self) -> 'BatchEmbedder': self.is_cuda = True self.embedding_layer = self.embedding_layer.cuda() return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _warm_cache(self):\n for word, index in self.word_to_index.items():\n self.embedding_layer.weight.data[index].copy_(torch.from_numpy(self.embedder.get_word_vector(word)))", "def _embed(self):\n with tf.variable_scope('word_embedding'):\n self.pretrained_word_mat = tf.get_v...
[ "0.63232076", "0.6321871", "0.62385434", "0.61168504", "0.6080526", "0.6074833", "0.5765937", "0.5742658", "0.56909585", "0.56149906", "0.5582397", "0.5580662", "0.5568149", "0.55318266", "0.5526888", "0.5514868", "0.5486344", "0.5478865", "0.5454689", "0.54333633", "0.542969...
0.64183444
0
Moves the cached embeddings to CPU and changes `self.embed` to return CPU tensors.
def cpu(self) -> 'BatchEmbedder': self.is_cuda = False self.embedding_layer = self.embedding_layer.cpu() return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _warm_cache(self):\n for word, index in self.word_to_index.items():\n self.embedding_layer.weight.data[index].copy_(torch.from_numpy(self.embedder.get_word_vector(word)))", "def cpu(self) -> MultiIndicesEmbedding:\n super().cpu()\n\n self.offsets = self.offsets.cpu()\n\n ...
[ "0.67640376", "0.6339149", "0.58991015", "0.57273114", "0.56587225", "0.5629123", "0.5383725", "0.53714436", "0.536308", "0.53385025", "0.53363657", "0.5335483", "0.5332339", "0.53278846", "0.5311937", "0.5308921", "0.52931446", "0.5281892", "0.52500963", "0.52314204", "0.520...
0.6716693
1
Uses `self.embedder` to fill the cache with word vectors for all words in `self.word_to_index`.
def _warm_cache(self): for word, index in self.word_to_index.items(): self.embedding_layer.weight.data[index].copy_(torch.from_numpy(self.embedder.get_word_vector(word)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reindex(self):\n self._index = {w: i for i, w in enumerate(self._words)}\n self.n, self.d = self._vecs.shape\n assert self.n == len(self._words) == len(self._index)\n self._neighbors = None", "def refresh_index(self):\n synchronize()\n # TODO: add logger call here\n ...
[ "0.6949835", "0.6747895", "0.669777", "0.66929364", "0.66919273", "0.66792655", "0.6574889", "0.6530671", "0.6529153", "0.6484495", "0.64738023", "0.64709294", "0.64318967", "0.64147925", "0.6378979", "0.6358644", "0.6329185", "0.6269669", "0.62328255", "0.6209618", "0.620607...
0.8175326
0
Embeds a batch of indices and returns a tensors with the embeddings and sequence lengths.
def _embed(self, index_batch: List[List[int]]) -> Tuple[FloatTensor, LongTensor]: # Get lengths lengths = LongTensor([len(sequence) for sequence in index_batch]) # TODO: switch to pytorch version 0.4.1 and add .item() seq_len = lengths.max() if torch.__version__[:3] == '0.3' else lengths...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def embed(self, index_batch: List[List[int]]) -> Tuple[FloatTensor, LongTensor]:\n return self._embed(index_batch)", "def embedding(self, seqs):\n batch_size, seqlen = seqs.shape\n seqs = np.reshape(seqs, (-1)) # convert to 1-d indexes [(batch_sz*seqlen)]\n embs = self.word2vec[seqs]...
[ "0.6865791", "0.6635888", "0.6587195", "0.6567269", "0.6499882", "0.6358613", "0.63392216", "0.6330702", "0.6308136", "0.6270366", "0.6195017", "0.61304456", "0.6113752", "0.6086269", "0.60836214", "0.60664815", "0.60590225", "0.6053414", "0.60495", "0.60274565", "0.6023334",...
0.77606255
0
Initializes the IndexBatchEmbedder and adds all words in `word_to_index` to the nn.Embedding cache.
def __init__(self, embedder: Embedder, word_to_index: Dict[str, int], cuda: bool = False): super(IndexBatchEmbedder, self).__init__(embedder, OrderedDict(word_to_index), cuda=cuda)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,\n embedder: Embedder,\n word_to_index: OrderedDict,\n init_cache_size: int = 1,\n cuda: bool = False):\n if set(range(len(word_to_index))) != set(word_to_index.values()):\n raise ValueError('word_to_index must map ...
[ "0.78529996", "0.7251771", "0.6624524", "0.6535453", "0.64045215", "0.63577086", "0.6283389", "0.6256116", "0.6207637", "0.6195715", "0.6150329", "0.6144532", "0.60955024", "0.60627717", "0.60555243", "0.604957", "0.5984213", "0.598365", "0.5951499", "0.59443426", "0.5869841"...
0.7875888
0
Embeds a batch of indices and returns a tensors with the embeddings and sequence lengths.
def embed(self, index_batch: List[List[int]]) -> Tuple[FloatTensor, LongTensor]: return self._embed(index_batch)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _embed(self, index_batch: List[List[int]]) -> Tuple[FloatTensor, LongTensor]:\n # Get lengths\n lengths = LongTensor([len(sequence) for sequence in index_batch])\n # TODO: switch to pytorch version 0.4.1 and add .item()\n seq_len = lengths.max() if torch.__version__[:3] == '0.3' els...
[ "0.7760315", "0.6634717", "0.6587012", "0.65664893", "0.64994836", "0.63582104", "0.6339279", "0.6329513", "0.63075686", "0.627123", "0.61942405", "0.61302567", "0.61130947", "0.6086139", "0.60825896", "0.6066114", "0.6058864", "0.60536265", "0.60491276", "0.60273635", "0.602...
0.68655646
1
Initializes the WordBatchEmbedder and adds all words in `words` to the nn.Embedding cache.
def __init__(self, embedder: Embedder, words: Set[str] = None, init_cache_size: int = 1, max_cache_size: int = None, cuda: bool = False): self.max_cache_size = max_cache_size or sys.maxsize if init_cache_size > self.max...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_embeddings(self, weight, words):\n # wrap in tensor\n if isinstance(weight, list):\n weight = torch.Tensor(weight).float()\n if isinstance(weight, np.ndarray):\n weight = torch.from_numpy(weight).float()\n # check embedding size\n if weight.size(1) ...
[ "0.72391534", "0.6847199", "0.67708296", "0.67521733", "0.67207134", "0.6509784", "0.64822894", "0.6471098", "0.6444924", "0.641689", "0.63426006", "0.63363665", "0.6316754", "0.63134974", "0.6286122", "0.6260804", "0.62373984", "0.619299", "0.61914337", "0.61836845", "0.6163...
0.7703591
0
Creates a mapping from each word in the set provided to a unique index in the range(0, len(words)).
def _init_word_to_index(self, words: Set[str]) -> OrderedDict: word_to_index = OrderedDict() for word in words: if len(word_to_index) >= self.max_cache_size: break word_to_index[word] = len(word_to_index) return word_to_index
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makewordindex(wordset):\n indexmap = {}\n sortwords = sorted(list(wordset))\n for i in range(len(sortwords)):\n word = sortwords[i]\n indexmap[word] = i\n return indexmap", "def word_mapping(sentences, lower):\n words = [[x[0].lower() if lower else x[0] for x in s] for s in sente...
[ "0.7658892", "0.67814326", "0.6707323", "0.6532016", "0.64898413", "0.63947743", "0.63076824", "0.62990844", "0.62972", "0.6224596", "0.61713886", "0.6164539", "0.611668", "0.60819465", "0.6058087", "0.6041863", "0.60393083", "0.6001811", "0.5999061", "0.59772164", "0.5970356...
0.68910867
1
Expands the nn.Embedding cache to double the currently required size, with a maximum of `self.max_cache_size`.
def _expand_cache(self, size: int): # Don't expand if already at max cache size if self.embedding_layer.num_embeddings - 1 >= self.max_cache_size: # - 1 for pad return # Expand embedding to double required size (up to maximum cache size) new_num_embeddings = min(size * 2, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _warm_cache(self):\n for word, index in self.word_to_index.items():\n self.embedding_layer.weight.data[index].copy_(torch.from_numpy(self.embedder.get_word_vector(word)))", "def _enforce_lru_size(self):\n\n # if a limit was defined and we have blown it\n if self._max_lru and l...
[ "0.61545545", "0.56813884", "0.56542236", "0.56230056", "0.5590128", "0.5562092", "0.55296063", "0.55228764", "0.551203", "0.55062634", "0.5458703", "0.54552156", "0.5443454", "0.54410785", "0.5423879", "0.5414264", "0.54082215", "0.53881574", "0.53847736", "0.53210753", "0.5...
0.8553656
0
Ensures that all words provided are in the cache and returns info about cache. Words which are already in the cache are moved to the front of the cache to prevent removal under the LRU caching scheme. Words which are not in the cache are added to the cache, which may require removing the least recently used words which...
def _cache_words(self, words: Set[str]) -> Dict[str, int]: # Raise error if more words than can fit in cache if len(words) > self.max_cache_size: raise ValueError('Cannot fit entire batch of words into cache.' 'Found {} unique words but cache only fits {} words.'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_word_to_index(self, words: Set[str]) -> OrderedDict:\n word_to_index = OrderedDict()\n for word in words:\n if len(word_to_index) >= self.max_cache_size:\n break\n word_to_index[word] = len(word_to_index)\n\n return word_to_index", "def known(se...
[ "0.6047211", "0.57848907", "0.57630837", "0.57423764", "0.5576098", "0.555305", "0.55502623", "0.5534474", "0.55148304", "0.5472149", "0.5471676", "0.54487675", "0.5439615", "0.54040724", "0.5387516", "0.53468174", "0.53033954", "0.52984196", "0.5296476", "0.52686775", "0.526...
0.77092266
0
The maximum number of bits a signed 2's complement vint can contain.
def vint_2sc_max_bits(self): return self._vint_2sc_max_bits
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _bitsfor(maxval):\n maxvalbits = int(round(math.log(maxval) / math.log(2)))\n if maxval != (1 << maxvalbits):\n raise ValueError(\"maxval must be a power of 2, not %d\" % maxval)\n return maxvalbits", "def int_bits(self):\n max_abs_val = max(abs(self.__max), abs(self.__min))\n r...
[ "0.7192541", "0.70834017", "0.6996253", "0.68475395", "0.68231374", "0.6768569", "0.67017317", "0.6585333", "0.6579988", "0.6561389", "0.6561389", "0.6545677", "0.6532409", "0.65263987", "0.65242046", "0.650321", "0.6502089", "0.6497201", "0.64897275", "0.6458789", "0.6454415...
0.76230174
0
Similar to _parse() but for keyvalue format lists.
def _parse_kvfmt(self, fmtlist): t_fmt = self.__class__._T_FMT t_prefix = self.__class__._T_PREFIX parsed_list = [] field_id = 1 for entry in fmtlist: name = entry[0] fmt = entry[1] parsed_field = {} parsed_field['name'] = name ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_list(value: str) -> list[str]:\n segments = _QUOTED_SEGMENT_RE.findall(value)\n for segment in segments:\n left, match, right = value.partition(segment)\n value = ''.join([left, match.replace(',', '\\000'), right])\n return [_dequote(x.strip()).replace('\\000', ',') for x in value....
[ "0.6126084", "0.6112435", "0.60868454", "0.59998274", "0.5990529", "0.5985781", "0.5966788", "0.59469175", "0.5918464", "0.5915731", "0.5844116", "0.583293", "0.57652086", "0.57629853", "0.57033306", "0.5695714", "0.5616596", "0.5615887", "0.56044614", "0.5588705", "0.5568833...
0.63801485
0
Parse format string to something more machine readable. Called internally inside the class.
def _parse(self, fmtstr): def _match_brace(string, start_pos, pair='[]'): """Pairing brackets (used internally in _parse method)""" depth = 1 if string[start_pos] != pair[0]: return None for index, char in enumerate(string[start_pos + 1:]): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, format_string):\r\n if not isinstance(format_string, Compatibility.string):\r\n raise TypeError('format_string should be a string, instead got %s' % type(format_string))\r\n self._re_pattern, self._applicators = self._preprocess_format_string(format_string)\r\n self._re = re.compil...
[ "0.6600368", "0.6170651", "0.6080922", "0.6078067", "0.60339344", "0.60117424", "0.5922885", "0.582842", "0.5826775", "0.5816205", "0.5765926", "0.5696702", "0.56563073", "0.5654135", "0.5615877", "0.560002", "0.5599914", "0.559688", "0.55761653", "0.5532612", "0.5522763", ...
0.6607187
0
Encode a single field to binary wire format Called internally in _encode_wire() function
def _encode_field(self, field_type, field_data, subcontent=None): self.logger.debug( '_encode_field(): pytype %s values %s', type(field_data).__name__, repr(field_data) ) field_encoded = None # nested if field_type == 'a' and subcontent: fiel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _encode_wire(self, stuff, fmtable=None):\n if fmtable == None:\n fmtable = self._fmt\n\n # Can be a index number or field name\n stuff_id = 0\n encoded = io.BytesIO()\n for fmt in fmtable:\n if self._kv_fmt:\n assert 'name' in fmt, 'Encode...
[ "0.7129987", "0.67063594", "0.6627883", "0.65548587", "0.65372694", "0.6536835", "0.6426712", "0.64151233", "0.64112705", "0.63306385", "0.6315507", "0.6208824", "0.61958075", "0.6168954", "0.6140479", "0.61334693", "0.6121104", "0.6121104", "0.6121104", "0.6095303", "0.60953...
0.6930919
1
Encode a header Called internally in _encode_wire() function
def _encode_header(self, f_type, f_id): hdr = (f_id << 3) | f_type return self._encode_vint(hdr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _encode_header(self):\n\t\theader = self.config.get('header')\n\t\tif header is not None:\n\t\t\treturn self._encode_tuple(header)", "def encode_header(value):\n return str(Header(unicode(value), 'iso-8859-1'))", "def encode_header(header_text):\n if not header_text:\n return \"\"\n header_...
[ "0.77162707", "0.72243726", "0.6750412", "0.67463887", "0.66943806", "0.66772294", "0.66069555", "0.65417516", "0.65349436", "0.6502592", "0.6393289", "0.633702", "0.6317234", "0.62250197", "0.61937225", "0.6172917", "0.61674654", "0.6162315", "0.61364144", "0.6109409", "0.61...
0.7553477
1
Encode a number to vint (Wire Type 0). Numbers can only be signed or unsigned. Any number less than 0 must be processed either using zigzag or 2's complement (2sc) before passing to this function. Called internally in _encode_field() function
def _encode_vint(number): assert number >= 0, 'number is less than 0' result = bytearray() while 1: tmp = number & 0x7f number >>= 7 if number == 0: result.append(tmp) break result.append(0x80 | tmp) return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_int(n):\n return struct.pack(\">I\", n)", "def encode_int(v):\n if v < 240:\n return chr(v)\n elif v <= 2287:\n v -= 240\n d, m = divmod(v, 256)\n return chr(241 + d) + chr(m)\n elif v <= 67823:\n v -= 2288\n d, m = divmod(v, 256)\n return '...
[ "0.6787155", "0.65838295", "0.64805037", "0.6352588", "0.6347903", "0.6328711", "0.62935853", "0.62935853", "0.6293228", "0.6289896", "0.62866306", "0.62433004", "0.62371284", "0.6230838", "0.62132573", "0.6193727", "0.6121768", "0.6108021", "0.60906667", "0.60673034", "0.604...
0.7853587
0
Decode vint encoded integer. Raises EndOfMessage if there is no or only partial data available. Called internally in decode() method.
def _decode_vint(buf): ctr = 0 result = 0 tmp = bytearray(1) partial = False while 1: count = buf.readinto(tmp) if count == 0: raise EndOfMessage(partial) else: partial = True result |= (tmp[0] & 0x7f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _decode_int(data: BencodedString) -> int:\n data.del_prefix(1)\n end_marker_index = data.bytes.find(END_MARKER)\n\n if end_marker_index > 0:\n result_bytes = data.get_prefix(end_marker_index)\n data.del_prefix(end_marker_index + 1)\n else:\n raise ValueError(\n \"Can...
[ "0.7160499", "0.6777412", "0.67718077", "0.66731423", "0.66685796", "0.64943415", "0.6345453", "0.6302733", "0.6132602", "0.6105601", "0.60572004", "0.60480267", "0.6032056", "0.59614956", "0.59408325", "0.59239155", "0.5921895", "0.59012246", "0.58777654", "0.58574456", "0.5...
0.79508525
0
Decode Protobuf variable length string to Python string. Raises EndOfMessage if there is no or only partial data available. Called internally in _decode_field() function.
def _decode_str(self, buf): length = self._decode_vint(buf) result = buf.read(length) if len(result) != length: raise EndOfMessage(True) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _decode_message(self, label: str, buf, typedef=None, pos=0, end=None, group=False):\n print(str(pos) + \" decode_message \" + label)\n if end is None:\n end = len(buf)\n\n if typedef is None:\n typedef = {}\n else:\n # Don't want to accidentally modi...
[ "0.6479612", "0.6470706", "0.64537084", "0.64008707", "0.63654953", "0.6364747", "0.6343193", "0.6308439", "0.6273576", "0.62662095", "0.6245633", "0.62437236", "0.6153663", "0.6130874", "0.612169", "0.612169", "0.612169", "0.60320556", "0.60250723", "0.6022556", "0.5976542",...
0.6905175
0
Helper method to 'break down' a wire string into a list for further processing. Pass type_override and id_override to decompose headerless wire strings. (Mainly used for unpacking packed repeated fields) Called internally in _decode_wire() function
def _break_down(self, buf, type_override=None, id_override=None): assert (id_override is not None and type_override is not None) or\ (id_override is None and type_override is None),\ 'Field ID and type must be both specified in headerless mode' while 1: field = {}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_deserializedata(datastr):\r\n\r\n if type(datastr) != str:\r\n raise TypeError(\"Cannot deserialize non-string of type '\"+str(type(datastr))+\"'\")\r\n typeindicator = datastr[0]\r\n restofstring = datastr[1:]\r\n\r\n # this is essentially one huge case statement...\r\n\r\n # None\r\n if ty...
[ "0.5909716", "0.57623225", "0.53586185", "0.53134507", "0.52909553", "0.52694756", "0.5193718", "0.5173697", "0.5121207", "0.508394", "0.5020048", "0.49640128", "0.49630883", "0.49624395", "0.4914903", "0.49068055", "0.4894348", "0.48735815", "0.48704532", "0.4867412", "0.486...
0.5953128
0
Decode a single field Called internally in _decode_wire() function
def _decode_field(self, field_type, field_data, subcontent=None): # check wire type wt_schema = self.__class__.FIELD_WIRE_TYPE[field_type] wt_data = field_data['wire_type'] if wt_schema != wt_data: raise TypeError( 'Wire type mismatch (expect {0} but got {1})'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _decode_wire(self, buf, subfmt=None):\n def _concat_fields(fields):\n \"\"\"\n Concatenate 2 fields with the same wire type together\n \"\"\"\n result_wire = io.BytesIO()\n result = {'id': fields[0]['id'], 'wire_type': fields[0]['wire_type']}\n ...
[ "0.70245844", "0.699106", "0.6916342", "0.671876", "0.6656418", "0.65768635", "0.64793736", "0.64045924", "0.6394951", "0.6328536", "0.6261299", "0.62602377", "0.6213484", "0.6208949", "0.61995363", "0.61995363", "0.61982924", "0.617609", "0.61722684", "0.61564505", "0.615346...
0.7879641
0
Apply schema, decode nested structure and fixed length data. Used by the decode() method, may also be invoked by _decode_field() to decode nested structures
def _decode_wire(self, buf, subfmt=None): def _concat_fields(fields): """ Concatenate 2 fields with the same wire type together """ result_wire = io.BytesIO() result = {'id': fields[0]['id'], 'wire_type': fields[0]['wire_type']} for field i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _decode_field(self, field_type, field_data, subcontent=None):\n # check wire type\n wt_schema = self.__class__.FIELD_WIRE_TYPE[field_type]\n wt_data = field_data['wire_type']\n if wt_schema != wt_data:\n raise TypeError(\n 'Wire type mismatch (expect {0} bu...
[ "0.6383153", "0.60229206", "0.60195816", "0.56360984", "0.5551053", "0.5520048", "0.54716694", "0.54710317", "0.5370111", "0.5346839", "0.53381675", "0.52829057", "0.5265493", "0.5246363", "0.52377695", "0.52168685", "0.51901156", "0.5157146", "0.5153581", "0.51362276", "0.51...
0.61339116
1
Concatenate 2 fields with the same wire type together
def _concat_fields(fields): result_wire = io.BytesIO() result = {'id': fields[0]['id'], 'wire_type': fields[0]['wire_type']} for field in fields: assert field['id'] == result['id'] and \ field['wire_type'] == result['wire_type'], \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_str(self):\n outstr = self._field1 + \": \"\n outstr = outstr + str(self._field2)\n return outstr", "def _concatenate_fields(dset: \"Dataset\", fields: List[str]) -> List[str]:\n concatenated_fields = []\n for values in dset.values(*fields):\n line = \"\"\n for v...
[ "0.6258898", "0.6196037", "0.6167565", "0.60659873", "0.60408664", "0.60286474", "0.6024965", "0.6018515", "0.59459513", "0.5868452", "0.5850631", "0.58201784", "0.5806335", "0.5765344", "0.57595354", "0.5739644", "0.57178867", "0.56851006", "0.5651034", "0.5651034", "0.56510...
0.6912273
0
Encode given Python object(s) to binary wire using fmtstr
def encode(fmtstr, *stuff): return Wire(fmtstr).encode(*stuff)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_str(self, obj):\n if len(obj) < 0x100:\n return 'U' + struct.pack('<B', len(obj)) + obj\n return 'T' + struct.pack('<I', len(obj)) + obj", "def encode(self) -> bytes:\n return pack('<B' + self.fmt, *([self.type] + self.__args))", "def encode_raw(objs):\n return ...
[ "0.73843616", "0.7030456", "0.699366", "0.69122773", "0.6764407", "0.6672753", "0.65131843", "0.6479943", "0.64123094", "0.63880503", "0.63358074", "0.63358074", "0.6334243", "0.62786275", "0.62734145", "0.62694186", "0.6230107", "0.6184254", "0.6183114", "0.6183114", "0.6149...
0.75679874
0
Decode given binary wire to Python object(s) using fmtstr
def decode(fmtstr, data): return Wire(fmtstr).decode(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deserialize(self, str):\n try:\n end = 0\n start = end\n end += 8\n (self.i,) = _struct_d.unpack(str[start:end])\n return self\n except struct.error as e:\n raise genpy.DeserializationError(e) #most likely buffer underfill", "def deserialize(self, str):\n try:\n en...
[ "0.7200268", "0.69649065", "0.69608706", "0.6957644", "0.6938896", "0.6938896", "0.6857564", "0.68029433", "0.67802954", "0.67358536", "0.67278135", "0.67167133", "0.670314", "0.67009", "0.66937387", "0.6658453", "0.6648083", "0.66284424", "0.66216123", "0.6595662", "0.658009...
0.8044593
0
Encode a list of raw data and types to binary wire format Useful for analyzing Protobuf messages with unknown schema
def encode_raw(objs): return RawWire().encode(objs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pack_varint_list(data: List[int]) -> bytes:\n result = b\"\"\n for value in data:\n result += pack_varint(value)\n return result", "def bencode(data, f):\n\tif isinstance(data, int):\n\t\t_encode_int(data, f)\n\telif isinstance(data, (str, bytes)):\n\t\t_encode_buffer(data, f)\n\telif isinsta...
[ "0.6539514", "0.64441305", "0.6249652", "0.6207694", "0.6151132", "0.6116983", "0.598254", "0.5957528", "0.5956368", "0.5914576", "0.586663", "0.585578", "0.5831381", "0.57792765", "0.5774285", "0.57478744", "0.56950045", "0.5691308", "0.5677145", "0.56691283", "0.5661698", ...
0.6665738
0
Parses the detections file and gets a list of detections on each frame
def parse_detections_file(detections_file_name): try: detections_file = open(detections_file_name, 'r') except IOError: raise("Detection File provided doesn't exist") # Adapted from SouYoung's hard negative mining code. isNewFrame = True isReadingBox = False boxCount = 0 fra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_detections(det_dir):\n detections = []\n\n for curd in os.listdir(det_dir):\n sub_dir = os.path.join(det_dir, curd)\n if os.path.isdir(sub_dir):\n\n for f in os.listdir(sub_dir):\n filepath = os.path.join(sub_dir, f)\n\n if os.path.isfile(filepa...
[ "0.7604167", "0.7342485", "0.7065727", "0.6744877", "0.6700936", "0.66877735", "0.6678794", "0.6676469", "0.6556135", "0.64776367", "0.64435726", "0.6407385", "0.6403243", "0.6392155", "0.6371837", "0.6307559", "0.6273148", "0.6270847", "0.62591296", "0.6250686", "0.6217289",...
0.7378607
1
Draws rectangles on the frame using supplied detections
def _draw_detections(frame, frame_detections): boxColor = (0,255,0) for box in frame_detections: cv2.rectangle(frame,(int(box[0]),int(box[1])),(int(box[2]),int(box[3])),boxColor,7) # cv2.rectangle(frame,(int(box[0]),int(box[1])),(int(box[2]),int(box[3])),boxColor,7) cv2.putText(frame,str...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_rects(img, rects, color):\n for x1, y1, x2, y2 in rects:\n cv2.rectangle(img, (x1, y1), (x2, y2), color, 2)", "def draw_rectangles(self, draw_img):\n if not self.features_detected:\n raise Exception('Detect features before drawing')\n for (x,y,w,h) in self.features:\n ...
[ "0.73589575", "0.72010344", "0.69825554", "0.69611484", "0.68250644", "0.67629504", "0.6753694", "0.66821414", "0.66636276", "0.66467315", "0.6536832", "0.6524512", "0.6520364", "0.6509365", "0.6505393", "0.6433057", "0.64173335", "0.6401047", "0.63885826", "0.63817364", "0.6...
0.81449944
0
Set all the properties to None (except pyleecan object)
def _set_None(self): self.loss_list = None self.meshsol_list = None self.loss_index = None self.logger_name = None self.axes_dict = None self.Pstator = None self.Protor = None self.Pmagnet = None self.Pprox = None self.Pjoule = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_properties(self):\n self.properties.clear()", "def clearProperties(*args):", "def clearProperties(*args):", "def clearProperties(*args):", "def clearProperties(*args):", "def _set_None(self):\n\n self.description = None\n self.func = None", "def _set_None(self):\n for ...
[ "0.7057623", "0.6893722", "0.6893722", "0.6893722", "0.6893722", "0.68656975", "0.6816739", "0.6752936", "0.6714874", "0.66839135", "0.66490847", "0.6633532", "0.64807814", "0.63836867", "0.6347796", "0.633291", "0.633291", "0.633291", "0.633291", "0.62917364", "0.62625456", ...
0.69506824
1
Function to print the zigzak traversal of a binary tree. The function uses two queues to store the nodes at current level and nodes at next level. If the current level nodes are empty it swaps the current level and next level arrays. The direction of zigzak traversal can be changed by using a boolean parameter to decid...
def zigzak_using_bfs(root): current_level = [root] next_level = [] while current_level: node = current_level.pop() print(node.data, end=" ") if node.right: next_level.append(node.right) if node.left: next_level.append(node.left) if not current_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def level_order_traversal(self):\r\n level_queue = [self]\r\n next_level_queue = []\r\n curr_level = 0\r\n print (self.root)\r\n while level_queue:\r\n curr_node = level_queue.pop(0)\r\n if curr_node.left:\r\n next_level_queue.append(curr_node...
[ "0.7049383", "0.6851622", "0.66927886", "0.6571005", "0.65524936", "0.640786", "0.6403734", "0.63833225", "0.6360691", "0.6357607", "0.62780994", "0.6271259", "0.6259753", "0.6208521", "0.6183874", "0.6173341", "0.61629444", "0.61558646", "0.6151679", "0.6144767", "0.61329514...
0.7064585
0
Graders can optionally add comments to the student's solutions, so add the comment information into the database if it doesn't already exist. It should NOT overwrite existing comments that might have been added by a grader already.
def _get_comment(self, cell: NotebookNode, resources: ResourcesDict) -> None: # retrieve or create the comment object from the database comment = self.gradebook.find_comment( cell.metadata['nbgrader']['grade_id'], self.notebook_id, self.assignment_id, sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_comment() -> str:\n if \"markdown\" in request.form:\n if \"file\" in request.form:\n comment = Comment(\n markdown=request.form[\"markdown\"],\n submission_id=Submission.query.filter(\n Submission.filepath.contains(request.form[\"file\"...
[ "0.6076075", "0.5898363", "0.5782157", "0.574791", "0.57343876", "0.57101774", "0.5661916", "0.5660216", "0.55917895", "0.5577336", "0.5550118", "0.55246305", "0.54837686", "0.54734325", "0.54437375", "0.54409504", "0.5426168", "0.54043204", "0.53758365", "0.5375756", "0.5367...
0.6050853
1
If err is None (empty string == None), then there was no error. otherwise there was an we should log it and exit. Just a utility function for making error handling easier.
def check_error(err): if err != None: logging.error(err) sys.exit(-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_error(err):\n print(err)", "def _err(self, *args):\n logger.error(*args)\n exit(1)", "def err(string, exitval):\n\tprint >> sys.stderr, string.rstrip()\n\tsys.exit(exitval)", "def print_err(err):\n return stdout.write(err.args[0])", "def error():\n return None", "de...
[ "0.6911527", "0.68348825", "0.6515537", "0.6427753", "0.6398317", "0.63407", "0.63164777", "0.63164777", "0.6282877", "0.61402404", "0.6137779", "0.6129769", "0.6120549", "0.61108035", "0.60211885", "0.60211885", "0.59960926", "0.5992475", "0.59898823", "0.5987611", "0.594035...
0.8071433
0
Sets the 'desired' flag on asg_name to instance_count. This means AWS will scale the ASG UP to instance_count instances. Once actioned via the API, the function sits and waits for the activities to complete. A timeout is used to ensure the process doesn't run forever.
def scale_up_autoscaling_group(asg_name, instance_count): if_verbose("Scaling up ASG %s to %d instances" % (asg_name, instance_count)) asg.set_desired_capacity(AutoScalingGroupName=asg_name, DesiredCapacity=instance_count) activities = [] timer = time.time() while(True): if_verbose("Sle...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_for_instances(client, asg, desired_state=None, desired_health=None,\n desired_count=None):\n for i in range(61):\n if i == 60:\n raise Exception('Tried for 5 minutes, giving up.')\n sleep(10)\n _asg = client.describe_auto_scaling_groups(\n ...
[ "0.6804424", "0.6772462", "0.64209586", "0.6142117", "0.60537887", "0.59439796", "0.5764177", "0.5522598", "0.54044706", "0.5356006", "0.53550184", "0.5253972", "0.51828814", "0.5159127", "0.5132443", "0.512234", "0.50561136", "0.5014435", "0.4952821", "0.4926326", "0.4913183...
0.7370802
0
Once an ASG is active, this function can be used to loop over the instances to ensure they're all coming up and going live in a healthy manager. AWS does some checks for us, such as connectivity, and if these fails or the OS fails, then we don't get dead instances.
def check_autoscaling_group_health(asg_name, current_capacity_count): if_verbose("Checking the health of ASG %s" % asg_name) timer = time.time() while(True): if_verbose("Sleeping for %d seconds whilst waiting for ASG health" % args.update_timeout) time.sleep(args.update_timeout) if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_for_instances(client, asg, desired_state=None, desired_health=None,\n desired_count=None):\n for i in range(61):\n if i == 60:\n raise Exception('Tried for 5 minutes, giving up.')\n sleep(10)\n _asg = client.describe_auto_scaling_groups(\n ...
[ "0.7501585", "0.6900817", "0.6537971", "0.6500654", "0.6453184", "0.6393064", "0.63467896", "0.6328315", "0.6293055", "0.6287904", "0.62423927", "0.62201005", "0.6193964", "0.6188775", "0.6178318", "0.61549854", "0.6133032", "0.6083235", "0.6066922", "0.6060486", "0.6046863",...
0.71941525
1
Checks over the ELB to ensure the instances are in a healthy state. Health is determined by a healthcheck on the ELB which looks at Peter Kia's API endpoint.
def check_elb_instance_health(elb_name, instances): if_verbose("Checking ELB %s instance health for %s" % (elb_name, instances)) timer = time.time() while (True): if_verbose("Sleeping for %d ELB instance health" % args.update_timeout) time.sleep(args.update_timeout) if int(time.time...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_health_check(self):\n result = self.app.get('/v1/health')\n\n # assert the status code of the response 200 (OK)\n self.assertEqual(result.status_code, 200)\n self.assertEqual(result.data, b'UP')", "def get_elb_instance_states(elbclient, elbname):\r\n ret = {}\r\n try:\r...
[ "0.66283584", "0.66256905", "0.650751", "0.6428748", "0.6425779", "0.6399829", "0.63985234", "0.6304112", "0.62876934", "0.62136644", "0.6210402", "0.6129126", "0.6096772", "0.6077745", "0.6064055", "0.5985021", "0.59224385", "0.59224385", "0.5915696", "0.59056133", "0.590512...
0.78669006
0
Lock the environment via an S3 lock file. This used to prevent race conditions when multiple people or automated tasks want to do things to the environment.
def lock_environment(bucket, environment): s3.put_object(Bucket=bucket, Key="%s.lock"%environment)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock (self):\n self._createLockFileIfNeeded()\n self._lockHandle=open(self._lockFileName, \"r\")\n fcntl.flock(self._lockHandle, fcntl.LOCK_EX)", "def lock(project, env_spec_name):\n return _update_and_lock(project, env_spec_name, update=False)", "def put_object_lock_configuration(B...
[ "0.65973717", "0.64356905", "0.6120334", "0.61018366", "0.59653574", "0.5796178", "0.5700326", "0.5699753", "0.56808686", "0.56560415", "0.5644223", "0.56389296", "0.56269526", "0.5613335", "0.5580776", "0.557653", "0.55743897", "0.55678254", "0.5545653", "0.55447465", "0.554...
0.83685845
0
Test that span_names can be overwritten by our callback function.
def test_override_span_name(self): span_name = "Dymaxion" def get_predefined_span_details(_): return span_name, {} def update_expected_span_name(expected): for entry in expected: entry["name"] = " ".join( [span_name] + entry["name"].s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_override_span_name(self):\n span_name = \"Dymaxion\"\n\n def get_predefined_span_details(_):\n return span_name, {}\n\n def update_expected_span_name(expected):\n for entry in expected:\n if entry[\"kind\"] == trace_api.SpanKind.SERVER:\n ...
[ "0.684485", "0.6666653", "0.57759863", "0.5475528", "0.53881454", "0.5373521", "0.5327859", "0.51535195", "0.5149383", "0.51369727", "0.5121736", "0.5111007", "0.5095532", "0.5079476", "0.507555", "0.50628686", "0.505435", "0.50399286", "0.5032913", "0.502633", "0.50241566", ...
0.7252243
0
Test that middleware is ok when server is none in scope.
def test_behavior_with_scope_server_as_none(self): def update_expected_server(expected): expected[3]["attributes"].update( { "http.host": "0.0.0.0", "host.port": 80, "http.url": "http://0.0.0.0/", } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_behavior_with_scope_server_as_none(self):\n\n def update_expected_server(expected):\n expected[3][\"attributes\"].update(\n {\n SpanAttributes.HTTP_HOST: \"0.0.0.0\",\n SpanAttributes.NET_HOST_PORT: 80,\n SpanAttribu...
[ "0.67881715", "0.6421726", "0.62887543", "0.627802", "0.62571293", "0.609614", "0.60894525", "0.6052777", "0.60396963", "0.59555256", "0.58882743", "0.58479136", "0.58381426", "0.58093685", "0.5792621", "0.57923585", "0.57682794", "0.5765627", "0.5707247", "0.56999034", "0.56...
0.68050337
0
Test that host header is converted to http.server_name.
def test_host_header(self): hostname = b"server_name_1" def update_expected_server(expected): expected[3]["attributes"].update( {"http.server_name": hostname.decode("utf8")} ) return expected self.scope["headers"].append([b"host", hostname]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_host_header(self):\n hostname = b\"server_name_1\"\n\n def update_expected_server(expected):\n expected[3][\"attributes\"].update(\n {SpanAttributes.HTTP_SERVER_NAME: hostname.decode(\"utf8\")}\n )\n return expected\n\n self.scope[\"head...
[ "0.7925731", "0.7740137", "0.75569916", "0.747668", "0.73475033", "0.7347234", "0.72912675", "0.727561", "0.7237345", "0.71756035", "0.71303314", "0.711663", "0.71058095", "0.7063025", "0.70558643", "0.70247006", "0.7004435", "0.69855905", "0.6966486", "0.6950476", "0.6856809...
0.8008865
0
Test case for support_id_status_get
def test_support_id_status_get(self): headers = [('accept_language', 'accept_language_example'), ('api', 'api_example'), ('api_version', 'api_version_example'), ('maas_id', 'maas_id_example'), ('addressed_to', 'addressed_to_example')] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_status(self):\n pass", "def test_get_status(self):\n pass", "def status(self, id):", "def check_status(self, id):\n raise NotImplementedError()", "def test_getitem_id_column(self):\n self.assertEqual(self.tester['required_sample_info_status'],\n ...
[ "0.7293837", "0.7293837", "0.68609387", "0.6844575", "0.65635914", "0.64397395", "0.63641095", "0.6333602", "0.62414247", "0.6184268", "0.6146328", "0.6133589", "0.61134183", "0.6092105", "0.6088225", "0.6067923", "0.60656506", "0.6051208", "0.6029248", "0.60166204", "0.59771...
0.8254267
0
Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent.
def getNewsFeed(self, userId: int): tweets = heapq.merge(*(self.tweets[u] for u in self.followees[userId] | {userId})) return [t for _, t in itertools.islice(tweets, 10)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNewsFeed(self, userId):\r\n tweets = []\r\n \r\n tweets += self.tweets_by_user[userId]\r\n for other in self.follows[userId]:\r\n tweets += self.tweets_by_user[other]\r\n \r\n last_10_tweets = sorted(tweets)[-10:]\r\n return [tweetId for _, tweetId...
[ "0.7737455", "0.74340105", "0.7227295", "0.7207646", "0.7135396", "0.71263534", "0.71239245", "0.704648", "0.7038941", "0.70330626", "0.7020751", "0.7010667", "0.69603735", "0.6933525", "0.68580115", "0.6784043", "0.67043525", "0.66529995", "0.6638148", "0.66179687", "0.65714...
0.7581535
1
Function to convert text to instance for training and testing.
def text_to_instance(self, text_label: list): label = LabelField( self.label_to_idx[text_label[0]], skip_indexing=True ) tokens = [Token(token) for token in text_label[1].split()] sentence_field = TextField(tokens, self.token_indexers) fields = {"sentence": sentence_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_to_instance(self, # type: ignore\n tokens: List[str],\n labels: List[str] = None) -> Instance:\n wordpieces, offsets, start_offsets = self._wordpiece_tokenize_input(tokens)\n text_field = TextField([Token(t, text_id=self.bert_tokenizer.vocab[t...
[ "0.664931", "0.64830565", "0.64477307", "0.6242643", "0.61243576", "0.6111656", "0.60993505", "0.6028079", "0.59776634", "0.59750587", "0.5954576", "0.59463316", "0.5937891", "0.5925741", "0.579311", "0.57708377", "0.5755662", "0.5752704", "0.5729382", "0.5718061", "0.5704843...
0.7028149
0
Create instance of Map Reduce Manager for Mongo database
def __init__(self, db): # Get a logger handle (singleton) self._logger = logger.logger() # Set the database self._db = db # Pull the MapReduce manager collection self._storage = db["mr_manager"] ''' # Pull the MapReduce manager self._storage = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.user_dao = MongoUserDAO()\n self.meta_game_dao = MongoMetaGameDAO()", "def __init__(self):\n client = MongoClient(\n settings.MONGODB_SERVER,\n settings.MONGODB_PORT\n )\n db = client[settings.MONGODB_DB]\n self.collection...
[ "0.5725894", "0.5592595", "0.5560932", "0.555845", "0.5550333", "0.55005234", "0.5477762", "0.5472846", "0.54630035", "0.5459539", "0.538249", "0.537421", "0.5366733", "0.53657526", "0.53347063", "0.53318214", "0.5328786", "0.5313639", "0.529929", "0.5283994", "0.52732104", ...
0.7105232
0
This method performs an incremental mapreduce on any new data in 'source_table_name' into target_table_name. Each execution will process only the new, unprocessed records.
def incrementalMapReduce(self, map_f, reduce_f, db, source_table_name, target_table_name, mr_job_desc=None, query_qua...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n\t\tdf_iter = self.file_to_df(50000)\n\t\tdf_airport = self.airport_file_to_df()\n\t\tfor df in df_iter: # type: pd.DataFrame\n\t\t\tdf.drop_duplicates(inplace=True)\n\t\t\tdf = self.transform(df, df_airport)\n\n\t\t\tdf_result = self.get_only_new_records(\n\t\t\t\tdf=df,\n\t\t\t\tdf_columns=self....
[ "0.59600747", "0.59315765", "0.53499544", "0.51457566", "0.5121362", "0.5114944", "0.5109795", "0.50885224", "0.50589585", "0.5050361", "0.504682", "0.5045919", "0.50365466", "0.5031003", "0.5027877", "0.5025", "0.500719", "0.4990061", "0.4946623", "0.4946299", "0.49427825", ...
0.68553734
0
This method performs an derived mapreduce on a MapReduce collection in 'source_table_name' into target_table_name. Each execution will process the whole source table!
def derivedMapReduce(self, map_f, reduce_f, db, source_table_name, target_table_name, mr_job_desc=None, query_qualifier=None): # Check th...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def incrementalMapReduce(self,\n map_f,\n reduce_f,\n db,\n source_table_name,\n target_table_name,\n mr_job_desc=None,\n ...
[ "0.65149957", "0.56699103", "0.56197053", "0.5422209", "0.53279", "0.5256865", "0.5230983", "0.5194099", "0.51685894", "0.51520395", "0.5127229", "0.51203305", "0.50995386", "0.5089506", "0.5074175", "0.50740516", "0.50729954", "0.50718", "0.50587755", "0.5009032", "0.5000489...
0.66157967
0
RungeKutta integrator (4th order) Input arguments x = current value of dependent variable t = independent variable (usually time) tau = step size (usually timestep) derivsRK = right hand side of the ODE; derivsRK is the name of the function which returns dx/dt Calling format derivsRK(x,t). Output arguments xout = new v...
def rk4(x,t,tau,derivsRK,param): half_tau = 0.5*tau F1 = derivsRK(x,t,param) t_half = t + half_tau xtemp = x + half_tau*F1 F2 = derivsRK(xtemp,t_half,param) xtemp = x + half_tau*F2 F3 = derivsRK(xtemp,t_half,param) t_full = t + tau xtemp = x + tau*F3 F4 = derivsRK(xtemp,t_full,pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rk4(x,t,tau,derivsRK,param): #couldn't get it to import right so I just copy pasted.\r\n \r\n half_tau = 0.5*tau\r\n F1 = derivsRK(x,t,param) \r\n t_half = t + half_tau\r\n xtemp = x + half_tau*F1\r\n F2 = derivsRK(xtemp,t_half,param) \r\n xtemp = x + half_tau*F2\r\n F3 = derivsRK(xte...
[ "0.7336214", "0.6998067", "0.6613263", "0.6558026", "0.65555346", "0.65207446", "0.6412929", "0.6409204", "0.6259355", "0.6158023", "0.6139926", "0.6087352", "0.5972421", "0.5963317", "0.5951371", "0.5933581", "0.591119", "0.588777", "0.58801526", "0.58428586", "0.5841335", ...
0.73914784
0
Returns righthand side of Lorenz model ODEs Inputs s State vector [x y z] t Time (not used) param Parameters [r sigma b] Output deriv Derivatives [dx/dt dy/dt dz/dt]
def lorzrk(s,t,param): r = param[0] sigma = param[1] b = param[2] # For clarity, unravel input vectors x = s[0]; y = s[1]; z = s[2] # Return the derivatives [dx/dt dy/dt dz/dt] deriv = np.zeros(3) deriv[0] = sigma*(y-x) deriv[1] = r*x - y - x*z deriv[2] = x*y - b*z return der...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ODEfun(y,t,params):\n Im = y[0]\n Is = y[1]\n Ic = y[2]\n R = y[3]\n \n\n try:\n\n r = params['r']\n p = params['p']\n N = params['N']\n R0 = params['R0']\n k = params['k']\n m = params['m']\n n = params['n']\n m1 = params['m1']\n ...
[ "0.66438836", "0.6504343", "0.6395633", "0.6283376", "0.61942184", "0.59663343", "0.5957446", "0.59267986", "0.5906301", "0.5866138", "0.58415633", "0.58094597", "0.5762203", "0.5761693", "0.5753914", "0.5728177", "0.5714065", "0.57111335", "0.5697602", "0.56828713", "0.56374...
0.7054647
0
Generates data needed to plot the results of lorentz.py using rk4 as in Ch3 ex 25
def lorenz_data_gen(init_x,init_y,init_z,init_r): # Set initial state x,y,z and parameters r,sigma,b sxin,syin,szin = init_x,init_y,init_z state = np.zeros(3) state[0] = float(sxin); state[1] = float(syin); state[2] = float(szin) r = init_r sigma = 10 # Parameter sigma b = 8./3...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_lorenz_data(\r\n ics, t, n_points, normalization=None, sigma=10, beta=8 / 3, rho=28\r\n):\r\n n_ics = ics.shape[0]\r\n n_steps = t.size\r\n\r\n d = 3\r\n z = np.zeros((n_ics, n_steps, d))\r\n for i in range(n_ics):\r\n z[i] = simulate_lorenz(ics[i], t, sigma=sigma, beta=beta, ...
[ "0.6603893", "0.62499523", "0.60884094", "0.60417676", "0.6033515", "0.59004956", "0.58829135", "0.5864746", "0.58279246", "0.5826332", "0.5806816", "0.5796454", "0.5763703", "0.5701705", "0.56688136", "0.5663586", "0.56537783", "0.5642653", "0.56280464", "0.5612073", "0.5596...
0.7678646
0
Compute the sum of the oriented angles in the line. The angle at a given point X_k is the angle between vect(X_k1, X_k) and vect(X_k, X_k+1). If the winding angle is higher than 2 pi, the streamline is cut to keep the shortest streamline so that the winding angle is greater or equal to 2 pi. Args
def _set_winding_angle_and_angular_velocity(self, delta_time, cut_lines): coord = self.coord_list[:, 0] + 1j * self.coord_list[:, 1] coord += coord.real * np.cos(self.mean_pos[1] * np.pi / 180) vectors = coord[1:] - coord[:-1] # Remove the null vectors not_null_vect = vectors !...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle_alis(self, angle):\n if type(angle) == Angle:\n angle = angle.id\n vertex, end1 = self._extend_line(angle[1], angle[0], both_side=False)\n vertex, end2 = self._extend_line(angle[1], angle[2], both_side=False)\n if end1 > end2:\n end1, end2 = end2, end1\n ...
[ "0.5901829", "0.58920944", "0.58649194", "0.57791793", "0.5758988", "0.5709965", "0.55646765", "0.5560406", "0.55239946", "0.55088246", "0.54253876", "0.5408793", "0.5335384", "0.52876467", "0.5286658", "0.52797866", "0.52197593", "0.5210966", "0.52008986", "0.5189888", "0.51...
0.6170486
0
Compute the mean radius of the stream line. Compute the mean distance between the stream line mean pos and the list of coordinates. This value does not have any real meaning if the stream line winding is low.
def get_mean_radius(self): radius = np.array(self.coord_list) radius[:, 0] -= self.mean_pos[0] radius[:, 1] -= self.mean_pos[1] radius = np.sqrt(np.sum(radius ** 2, axis=1)) mean_radius = np.mean(radius) return mean_radius
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_radius(self):\n return self._mean_radius", "def mean_radius(self):\n return (self.semimajor_axis + self.semimedium_axis + self.semiminor_axis) / 3", "def get_average_start_radius(self):\n total_length = len(self.pixel_list)\n\n if not total_length:\n return 0\n ...
[ "0.7375978", "0.73593485", "0.65474296", "0.6530894", "0.6460363", "0.6122817", "0.6029525", "0.6000866", "0.59557384", "0.5878666", "0.58713186", "0.5846522", "0.5844902", "0.58444685", "0.58126503", "0.58068055", "0.57820034", "0.57629377", "0.5729428", "0.57215273", "0.571...
0.80870885
0
Compute the axis direction and lengths for the ellipse The eigen vectors are the directions of the axis of the ellipse. The length is computed so that sum{(x,y)}{(x/a)2+(y/b)21} is minimum.
def _set_axis_len_and_dir(self): # Constant R = EQUATORIAL_EARTH_RADIUS # Compute the covariance matrixe for finding the axis direction nb_coord = np.sum( [self.sl_list[k].nb_points for k in range(self.nb_sl)] ) merged_coord_list = np.zeros((nb_coord, 2)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ellipse_axes(S):\n absL = np.sqrt(S[..., 1]**2 + S[..., 2]**2)\n A = np.sqrt((S[..., 0] + absL)/2)\n B = np.sqrt((S[..., 0] - absL)/2)\n return A, B", "def ellipse_orientation(S):\n return 1/2 * np.arctan2(S[..., 2], S[..., 1])", "def fit_ellipse(x,y):\r\n \r\n def fit(x,y):\r\n ...
[ "0.66480786", "0.6346107", "0.6259243", "0.6248045", "0.61917263", "0.6154268", "0.6066329", "0.6062749", "0.60462", "0.5956802", "0.59499806", "0.58884776", "0.5849577", "0.5834417", "0.5799094", "0.57656425", "0.57555157", "0.5730433", "0.5660862", "0.56138384", "0.5601668"...
0.745603
0
Creates a distance matrix according to Dynamic Time Warping algorithm and save it into a file
def build_dm_from_data_to_file(data, filename, derivative=False): distance_matrix = [] for _ in range(len(data)): distance_matrix.append([0] * len(data)) for i in tqdm(range(len(data) - 1)): for j in range(i + 1, len(data)): distance = dtw(data[i], da...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_dm_from_frame_to_file(target_frame, interested_columns, filename, derivative=False):\n distance_matrix = []\n frame = target_frame\n frame.reset_index(inplace=True)\n\n for _ in range(len(frame)):\n distance_matrix.append([0] * len(frame))\n\n for i in tqdm(range(len(frame) - 1)):\n...
[ "0.5876931", "0.5769952", "0.5716714", "0.57099485", "0.5515118", "0.54750836", "0.5438548", "0.5387929", "0.53159475", "0.53112334", "0.5298661", "0.52733165", "0.5264601", "0.5262992", "0.52479166", "0.5245536", "0.52229714", "0.5217684", "0.5204797", "0.51915026", "0.51772...
0.6445782
0
It produces 10 new columns to attach to an existing data frame. Each column i represent the number of clicked items with category=category on page i.
def add_categories_per_page_clicks_to_frame(frame, category, drop_threshold): set_of_columns = [] for filename in os.listdir("WebApp_Results"): clicks_per_page = [0] * 10 file = open("WebApp_Results/" + filename, "r").read() file = file.split("-")[1] pages = file.split(";") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_category(df):\n df[\"category\"] = df.apply(lambda row: transform_cat(row), axis=1)\n df = drop_cols(df, [\"booking_bool\", \"click_bool\"])\n return df", "def get_all_categories_items(number_of_items: int) -> pd.DataFrame:\n all_items = pd.DataFrame()\n for (category_id, category_name) in...
[ "0.5869037", "0.58372617", "0.5754652", "0.55742335", "0.5507479", "0.5503295", "0.5369228", "0.52595186", "0.52587694", "0.5233981", "0.52212316", "0.52090067", "0.5188913", "0.5182142", "0.51801443", "0.5175269", "0.51522243", "0.5142138", "0.5123673", "0.51179165", "0.5105...
0.6953118
0