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
Sleeps until we're ready to make a call again
def _sleep(self): while 1: diff = (time.time()-self.lastcall) - self.mindelay if diff >= 0: return time.sleep(max(-diff/2.0, 0.01))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _wait_before_call(self):\n while (dt.datetime.now() - self._last_call_ts) <= dt.timedelta(\n seconds=self.api_timeout\n ):\n time.sleep(0.5)\n self._last_call_ts = dt.datetime.now()", "def _wait_before_call(self) -> None:\n while (datetime.now() - self._last_...
[ "0.72283506", "0.70473284", "0.7040449", "0.6982203", "0.6924638", "0.67761457", "0.67761457", "0.67761457", "0.6768626", "0.6690188", "0.6678289", "0.66534007", "0.66428673", "0.6601506", "0.6587237", "0.65673304", "0.6564877", "0.6560657", "0.6520853", "0.6513019", "0.64942...
0.71504414
1
Returns the archival path for a given cache filename. Appends the last modified timestamp for it.
def archivepath(self, cachefname): modtime = os.stat(cachefname).st_mtime ext = '.'+self.serializer base = cachefname.rsplit(ext, 1)[0] ret = '%s-%f%s' % (base, modtime, ext) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cachefile(filename):\n if not os.path.exists(cachedir):\n os.makedirs(cachedir)\n return os.path.join(cachedir, filename)", "def get_cache_file(self, dependencies):\n filename = '%s.tar' % self.get_cache_key(dependencies)\n return os.path.join(self.cache_directory, filename)", ...
[ "0.69801885", "0.68424743", "0.6686933", "0.6672214", "0.6626115", "0.65499896", "0.65381086", "0.6537387", "0.6528383", "0.6528383", "0.649913", "0.649913", "0.6485715", "0.64468354", "0.6443828", "0.6428211", "0.6415024", "0.64056045", "0.6385045", "0.6383729", "0.6363894",...
0.7945767
0
Loads the cache from the given cachepath. If not found, raises IOError.
def loadcache(self, cachepath): loadfunc = json.load if self.serializer == 'json' else pickle.load try: # check for recency if self.expiration > 0: elapsed = time.time() - os.stat(cachepath).st_mtime #print >>sys.stderr, '%s exp, %s elapsed' % (sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_cache(self, path):\n if self._cache:\n cache_path = os.path.join(self._cache, path)\n\n if os.path.exists(cache_path):\n with io.open(cache_path, encoding='utf-8') as f:\n text = f.read()\n\n return text\n\n msg = ('Unab...
[ "0.69977164", "0.6749261", "0.6732635", "0.67183495", "0.65936494", "0.65107465", "0.65056586", "0.63451797", "0.6232331", "0.60423887", "0.6003267", "0.5985406", "0.59646606", "0.5915458", "0.5858328", "0.5852859", "0.57651997", "0.57651997", "0.57532793", "0.5717989", "0.56...
0.76469654
0
Saves the given obj to the given cachepath. Returns the file size of the cache file.
def savecache(self, obj, cachepath): try: os.makedirs(os.path.dirname(cachepath)) except OSError: pass tmpfname = cachepath+'.tmp-%d' % (int(time.time()*1000)) f = open(tmpfname, 'wb') if self.serializer == 'json': json.dump(obj, f, indent=2, s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_save(item: str, obj: object) -> None:\n\titem = str(item)\n\tcache = \"Cached/\" + item\n\n\tcache_create()\n\n\tpickle.dump(obj, open(cache, \"wb\"))\n\tuux.show_debug(\"Cached object to \" + cache)", "def save_obj(obj, path: str):\n with open(path, 'wb') as h:\n pickle.dump(obj, h)", "def...
[ "0.639193", "0.60019094", "0.59937465", "0.5935359", "0.5934574", "0.58999723", "0.5722097", "0.56716526", "0.5670551", "0.5631007", "0.5631007", "0.5607497", "0.55910337", "0.55860263", "0.55671954", "0.5562444", "0.556237", "0.55445635", "0.55445635", "0.55445635", "0.55445...
0.86657774
0
Calls the api function many times. Put tuples of (args, kw) into allargs. Yields results in the same order as inputs, as we compute them.
def callmany(self, allargs): seqs = [] # add all inputs to queue for args, kw in allargs: t = time.time() seqs.append(t) self.inq.put((t, args, kw)) # read all outputs outs = {} while len(seqs) > 0: t, ret = self.outq.get() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_call(self, name, *args, **kwargs):\r\n return self.client.iter_call(self.name, name, *args, **kwargs)", "def all_(*args, **kwargs):\n ...", "def call_each(self, methname, *args, **kwargs):\n return MultiCall(self.listattr(methname), *args, **kwargs).execute()", "def loop(func):\n ...
[ "0.6339846", "0.6080391", "0.5980732", "0.5929507", "0.5679536", "0.56711113", "0.5670682", "0.5644141", "0.5629318", "0.5613347", "0.5596558", "0.55757564", "0.5565455", "0.55366033", "0.5532328", "0.5532285", "0.55107445", "0.54587275", "0.5406769", "0.5400489", "0.5386842"...
0.6574676
0
upload music url and music preview
def upload_url(self, url, preview): return super(PicovicoMusic, self).upload_url(url, preview_url=preview)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_music(handler):\n user_id = handler.get_argument('user_id')\n music_path = handler.get_argument('path') #Having problems parsing this out\n sound_cloud_client = Petitions.instantiate_user(user_id)\n track = sound_cloud_client.post('/tracks', track={\n 'title': 'Tes...
[ "0.73513263", "0.61659884", "0.6155535", "0.598074", "0.5892458", "0.58604306", "0.58441514", "0.5799063", "0.5745149", "0.5745149", "0.5745149", "0.5745149", "0.56834704", "0.56557757", "0.56421643", "0.5635405", "0.55895376", "0.55888253", "0.55803883", "0.55577713", "0.553...
0.76914215
0
update maxcounts and subjcounts
def update_max_counts(self, label, nvals): if label not in self.maxcounts: if self.verb > 1: print('** found new label key: %s' % label) self.maxcounts[label] = nvals else: # rcr - safe as one line? will it be parsed? if nvals > self.maxcounts[label]: self.maxcounts[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_counts(self, msg, subtype, by):\n\n try:\n counts = self.get_local(msg, \"counts\")\n except KeyError:\n counts = defaultdict(int)\n\n counts['all'] += by\n counts[subtype] += by\n self.set_local(msg, \"counts\", counts)", "def update_frequenci...
[ "0.58235234", "0.57351094", "0.56918263", "0.56449956", "0.5610702", "0.5506785", "0.5486935", "0.54524773", "0.5449593", "0.5420955", "0.5404708", "0.5353762", "0.5347782", "0.534608", "0.52927333", "0.52230465", "0.5207815", "0.51916337", "0.5191431", "0.5174872", "0.516509...
0.7142012
0
insert the new label into the labels list and init maxcounts
def insert_new_label(self, label, index, nvals): if label in self.labels: return self.labels.append(label) self.parents.append(self.find_parent_label(label)) self.maxcounts[label] = nvals self.subjcounts[label] = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_max_counts(self, label, nvals):\n if label not in self.maxcounts:\n if self.verb > 1:\n print('** found new label key: %s' % label)\n self.maxcounts[label] = nvals\n\n else: # rcr - safe as one line? will it be parsed?\n if nvals > self.maxcounts[label]: sel...
[ "0.77373195", "0.6748753", "0.64776474", "0.61958253", "0.6102394", "0.60787904", "0.60749143", "0.5959312", "0.59497046", "0.59487486", "0.593107", "0.5894521", "0.58929664", "0.5848322", "0.5846774", "0.58393145", "0.5825734", "0.5815149", "0.58101875", "0.57937914", "0.577...
0.71766055
1
try to get subject and possibly group names from infiles fill self.snames and self.gnames, if possible 1. get SID if files look like out.ss_review.SID.txt, that is a good start else, look for varying part of filename 2. get GID replace SID in infile names and for varying group name
def parse_infile_names(self): rv, slist = UTIL.list_minus_pref_suf(self.infiles,'out.ss_review.','.txt') if rv < 0: return if rv > 0: if self.verb > 1: print('++ trying to get SID from glob form') slist = UTIL.list_minus_glob_form(self.infiles, strip='dir') else: if s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_subjects_info(data_folder, dataset_id, format=\"dict\"):\r\n subjects_info = {} # build of dictionnary of all session for each subject\r\n\r\n if dataset_id == \"raw_clean_32\":\r\n \"\"\" High Versus Low inhibitory Stimuli of Tinnitus and control patients\r\n \"\"\"\r\n patient...
[ "0.617442", "0.6138864", "0.5529454", "0.54885745", "0.54767644", "0.5435723", "0.54309344", "0.5426276", "0.5394026", "0.5354435", "0.53199375", "0.5302326", "0.5287302", "0.5281108", "0.5234611", "0.52154994", "0.51984787", "0.51866984", "0.5181254", "0.5164858", "0.5163682...
0.83686924
0
display the final labels list
def display_labels(self): nsubj = len(self.infiles) print('-- final label table (length %d):' % len(self.labels)) for label in self.labels: nv = self.maxcounts[label] if nv == 1: cstr = '%3d val' % nv else: cstr = '%3d vals' % nv nv = self.subjcounts[label] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_labels(self,labels):\n\t\tfor key in labels:\n\t\t\tprint key, ':\\t', labels[key]", "def display_name_labels(self):\n for name in self.names:\n # create a label for each name\n self.root.add_widget(Label(text=name))", "def label_list(entry):\n printing_resident_sheets...
[ "0.7338853", "0.71385354", "0.6938978", "0.67793345", "0.67660046", "0.67345864", "0.67238367", "0.6704955", "0.66717625", "0.663407", "0.6592146", "0.65798926", "0.65646005", "0.6542965", "0.6540552", "0.6459968", "0.64576674", "0.64520043", "0.6444454", "0.6407432", "0.6397...
0.8096897
0
write value lines, "left justified" to maxcount fields for each infile for each label
def write_value_lines(self, fp): if len(self.labels) < 1: return 1 nfiles = len(self.infiles) # labels, starting with input files # start with subject, if possible dosubj = len(self.snames) == len(self.infiles) dogrp = len(self.gnames) == len(self.infiles) for ind, infile ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_file(file_, maxn, maxl):\n width = len(str(maxl))\n with open(file_, 'w') as out:\n for i in range(1, maxl+1):\n out.write(f'[{i:{width}}] ' + write_line(maxn) + '\\n')", "def write_output(label1, label2, label3, submission_file):\n with open(submission_file, 'w') as f:\n ...
[ "0.6208772", "0.5949596", "0.5829664", "0.56889254", "0.5601088", "0.5511065", "0.5442443", "0.54381067", "0.53155595", "0.52923715", "0.52864933", "0.5261997", "0.5236052", "0.51551807", "0.5138517", "0.5135748", "0.5129272", "0.51155114", "0.51106626", "0.50788087", "0.5068...
0.6836115
0
Returns all variable of the default tensorflow graph with the given prefix. The return value is a dictionary 'NAME_OF_VARIABLE' => 'VARIABLE'. If a prefix is given, the prefix is deleted in 'NAME_OF_VARIABLE'.
def get_op(prefix=None): dict = {} if prefix is not None and len(prefix) > 1: if prefix[-1] != '/': prefix += '/' res = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope=prefix) for t in res: key = t.name key = key[len(prefix):] dict[str(key)] = t ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_vars_by_prefix(self, prefix):\n\n t_vars = tf.global_variables()\n return [var for var in t_vars if prefix in var.name]", "def get_named_variables(dct, name=True, overwrite=False, prefix=''):\n exprs = [('%s%s' % (prefix, k), v) for k, v in dct.items()\n if isinstance(v, thea...
[ "0.7297888", "0.62253565", "0.5879272", "0.5852968", "0.57585263", "0.56440735", "0.56411254", "0.56251013", "0.5550454", "0.5432469", "0.54197264", "0.5389389", "0.53701025", "0.52444595", "0.52265084", "0.5222102", "0.51667374", "0.51649207", "0.5147349", "0.5144244", "0.51...
0.7121777
1
Check the behaviour of the `kind` parameter. In short, "borderline2" generates sample closer to the boundary decision than "borderline1". We generate an example where a logistic regression will perform worse on "borderline2" than on "borderline1".
def test_borderline_smote_kind(): X, y = make_classification( n_samples=500, n_features=2, n_informative=2, n_redundant=0, n_repeated=0, n_clusters_per_class=1, n_classes=3, weights=[0.1, 0.2, 0.7], class_sep=1.0, random_state=1, ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_borderline_smote_no_in_danger_samples(kind):\n X, y = make_classification(\n n_samples=500,\n n_features=2,\n n_informative=2,\n n_redundant=0,\n n_repeated=0,\n n_clusters_per_class=1,\n n_classes=3,\n weights=[0.1, 0.2, 0.7],\n class_sep=...
[ "0.59879875", "0.5278893", "0.5067222", "0.50639474", "0.50141376", "0.4952348", "0.48771766", "0.4809434", "0.47661296", "0.4752564", "0.4752564", "0.4720459", "0.4624556", "0.45733762", "0.45580173", "0.45507464", "0.45396474", "0.45207068", "0.45138627", "0.45116305", "0.4...
0.61739796
0
Test that login is required to retrieve tags
def test_login_required_to_view_tags(self): res = self.client.get(TAGS_URL) self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_login_required_to_retrieve_tags(self):\n\n response = self.client.get(URL_TAGS)\n\n self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)", "def test_login_required(self):\n res = self.client.get(TAGS_URL)\n self.assertEqual(res.status_code, status.HTTP_401_UNA...
[ "0.8512646", "0.8236491", "0.8236491", "0.8216921", "0.8152566", "0.8152566", "0.79444635", "0.7274527", "0.7273791", "0.71287364", "0.71203995", "0.70111114", "0.693236", "0.6897866", "0.68918276", "0.6823461", "0.68113005", "0.6805346", "0.675212", "0.67194724", "0.67154175...
0.8265167
1
Test that the tags retrieved are for the authenticated user
def test_tags_limited_to_user_tags(self): user2 = create_user( fname='Test2', lname='User2', email='test2@gmail.com', password='testpass2' ) Tag.objects.create(user=user2, name='Vegan') tag = Tag.objects.create(user=self.user, name='Desse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tags_limited_to_authenticated_user(self):\n\n # Create a new user in addition to the user created in\n # the setUp, and leave it without an authentication.\n credentials = {'email': 'newuser@gmail.com', 'password': 'Testpass34'}\n new_user = get_user_model().objects.create_user...
[ "0.849094", "0.81080294", "0.81041294", "0.80561423", "0.8038318", "0.80258954", "0.80212194", "0.79648906", "0.7838485", "0.78236586", "0.74280965", "0.7302066", "0.7256315", "0.7233424", "0.6953861", "0.6921536", "0.68587327", "0.684185", "0.68384755", "0.68327254", "0.6808...
0.81783974
1
Cast a list of names into rnndigestable matrix.
def to_matrix(names, max_len=None, pad=0, dtype="int32"): max_len = max_len or max(map(len,names)) names_ix = np.zeros([len(names),max_len],dtype) + pad for i in range(len(names)): name_ix = list(map(token_to_id.get,names[i])) names_ix[i,:len(name_ix)] = name_ix return names_ix.T
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_features(names):\n Alphabet = ['a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o',\n 'p', 'q', 'r', 's', 't','u', 'v', 'w', 'x', 'y' , 'z']\n \n N = len(names)\n Feature_matrix = np.zeros((N, 260))\n for row in range(0, N):\n firstLast = names[row]....
[ "0.53580344", "0.5232146", "0.5220881", "0.5063171", "0.5013838", "0.5013702", "0.49942318", "0.48702893", "0.48425204", "0.4825524", "0.48236102", "0.4823267", "0.47998914", "0.47902778", "0.47831476", "0.477888", "0.47715646", "0.47602817", "0.47384185", "0.47281095", "0.47...
0.6554735
0
Test that pause and delay rely on two separate pause types, and do not resume each other
def test_pause_and_delay_separation(): pause_mgr = PauseManager(door_state=DoorState.CLOSED) assert pause_mgr.queue == [] pause_mgr.pause(PauseType.PAUSE) assert pause_mgr.queue == [PauseType.PAUSE] pause_mgr.pause(PauseType.DELAY) assert pause_mgr.queue == [PauseType.PAUSE, PauseType.DELAY] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pause_unit_helper(configs):\n _pause_resume_helper(pause_unit, configs)", "def test_pause(self):\n source = procedural.WhiteNoise(0.5)\n player = media.Player()\n player.queue(source)\n player.play()\n start_time = time.time()\n\n stage = 0\n while player.s...
[ "0.7281035", "0.7201257", "0.71017355", "0.6926161", "0.69036686", "0.68986255", "0.67866415", "0.6734228", "0.669614", "0.6636806", "0.6619378", "0.6573626", "0.6556387", "0.6468316", "0.64680254", "0.64634264", "0.64600056", "0.64432734", "0.6406104", "0.6340547", "0.629104...
0.84556085
0
Test that when the door safety switch is enabled, pause cannot be resumed until the door is closed
def test_door_pause_protocol(enable_door_safety_switch): pause_mgr = PauseManager(door_state=DoorState.CLOSED) assert pause_mgr.queue == [] pause_mgr.set_door(door_state=DoorState.OPEN) pause_mgr.pause(PauseType.PAUSE) assert pause_mgr.queue == [PauseType.PAUSE] with pytest.raises(PauseResumeE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_pause_and_delay_separation():\n pause_mgr = PauseManager(door_state=DoorState.CLOSED)\n assert pause_mgr.queue == []\n\n pause_mgr.pause(PauseType.PAUSE)\n assert pause_mgr.queue == [PauseType.PAUSE]\n\n pause_mgr.pause(PauseType.DELAY)\n assert pause_mgr.queue == [PauseType.PAUSE, Pause...
[ "0.6591592", "0.64406085", "0.6390791", "0.631739", "0.6298093", "0.6271643", "0.6247215", "0.62062687", "0.61953586", "0.6184892", "0.61199874", "0.60921264", "0.6024901", "0.5980132", "0.5977752", "0.5963126", "0.5947802", "0.5931819", "0.59252495", "0.59242266", "0.5908363...
0.8009721
0
Extracts used strings from a %(foo)s pattern.
def extract_pattern(fmt): class FakeDict(object): def __init__(self): self.seen_keys = set() def __getitem__(self, key): self.seen_keys.add(key) return '' def keys(self): return self.seen_keys fake = FakeDict() try: fmt % fak...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_strings(f):\n strings = re.findall(strregex,f)\n return strings", "def extractDef(c: Cmdr, s: str) -> str:\n for pat in c.config.getData('extract-patterns') or []:\n try:\n pat = re.compile(pat)\n m = pat.search(s)\n if m:\n return m.gro...
[ "0.5958557", "0.55669093", "0.54235214", "0.52379817", "0.5219056", "0.5214103", "0.5189378", "0.5168074", "0.5166035", "0.5159953", "0.5145372", "0.51319027", "0.5097553", "0.5061075", "0.5056262", "0.50380015", "0.50376844", "0.5022514", "0.5001648", "0.49748185", "0.487237...
0.57127404
1
Returns a dictionary containing all attributes of a given node. Attributes whose name occurs in the set skip are ignored.
def _filterAttr(self, node, skip): attr = {} for key, val in node.items(): if not key in skip: attr[key] = val return attr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attributes_of_node(core, node):\n attributes = {}\n for attribute in core.get_attribute_names(node):\n attributes[attribute] = core.get_attribute(node,attribute)\n return attributes", "def get_node_attributes(graph: BaseGraph, attr_key: str) -> Dict:\n return get_node_attributes(gr...
[ "0.67991483", "0.6495876", "0.6291643", "0.6113402", "0.608586", "0.6012828", "0.5955157", "0.59021395", "0.589775", "0.58977383", "0.5892174", "0.58709115", "0.58429515", "0.58203477", "0.5813974", "0.5740156", "0.573371", "0.57268363", "0.5715512", "0.57122576", "0.5706236"...
0.8172322
0
Listen indefinitely for scanner input. If student's ID numbers is found in the database, update the attendance roster, otherwise add the student to the database.
def get_input(conn): while True: student_id = input('') c = conn.cursor() c.execute('SELECT * FROM students WHERE student_id=?', (student_id,)) selection = c.fetchone() if (selection == None): name = prompt() student = name + (student_id,) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ui_update_student(self):\n student_id = input(\"student id: \")\n student_name = input(\"student discipline_name: \")\n disciplines_list = []\n\n discipline_name = None\n while discipline_name != '':\n discipline_name = input(\"Discipline discipline_name: \")\n ...
[ "0.57680213", "0.5578818", "0.5524008", "0.5456833", "0.5360587", "0.5212382", "0.5199357", "0.51914966", "0.51305926", "0.5081897", "0.50623494", "0.5052733", "0.504723", "0.50306654", "0.5011259", "0.49893084", "0.4986669", "0.4959946", "0.49570683", "0.4955665", "0.489259"...
0.6865095
0
Return a scrambled version of wf.ANSWER >>> random.seed(42) >>> generate_starting_point() 'ACTGODOXFMUE'
def generate_starting_point() -> str: starter = '' for i in range(len(wf.ANSWER) // wf.SECTION_LENGTH): section = list(wf.ANSWER[wf.SECTION_LENGTH * i:wf.SECTION_LENGTH * (i + 1)]) random.shuffle(section) starter = starter + ''.join(section) return starter
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_random_sequence(self) -> int:\n return random.randint(0, TWO_BYTES)", "def _random_start_position(self):\r\n self.position = np.array(random.choice(self.start_positions),\r\n dtype=np.int16)", "def _starting_prob(self, s):\n return self._starting_s...
[ "0.5797676", "0.5748072", "0.5625717", "0.5550335", "0.55358267", "0.5495027", "0.5467237", "0.54466385", "0.5418034", "0.53874934", "0.52591026", "0.5216048", "0.52145153", "0.52141696", "0.52128077", "0.52029085", "0.5193149", "0.5172854", "0.5165869", "0.5153036", "0.51502...
0.78475887
0
Return a random section_num corresponding to a section of state that is not correctly arranged. >>> random.seed(42) >>> get_section_hint('CATDGOXOFMUE') 3 >>> get_section_hint('CTADGOXOFMUE') 4
def get_section_hint(state: str) -> int: section_nums = [i + 1 for i in range(len(state) // wf.SECTION_LENGTH)] random.shuffle(section_nums) for section_num in section_nums: if not wf.check_section(state, section_num): return section_num return 0 # should never get here
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick_section(signal, section=None):\n len_noise = signal.shape[-1]\n if section is None:\n len_sig = len_noise\n ii = 0\n elif isinstance(section, int):\n len_sig = section\n ii = np.random.randint(0, len_noise - len_sig)\n else:\n ...
[ "0.61764073", "0.6048128", "0.5957858", "0.58769643", "0.5857279", "0.5694491", "0.5605851", "0.55351967", "0.5389725", "0.5279265", "0.52681446", "0.5125589", "0.5080668", "0.5071636", "0.5045724", "0.5045724", "0.5005661", "0.49288523", "0.4920502", "0.4882837", "0.48555204...
0.87867403
0
Return True if and only if mode is a valid mode, and False otherwise. >>> is_valid_mode('T') True >>> is_valid_mode('S') False
def is_valid_mode(mode: str) -> bool: return mode in (TEST, EASY, HARD)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isMode(mode, check):\n if mode==\"default\" or mode==\"all\":\n return True\n \n if mode.__contains__(check):\n return True\n\n if check.__contains__(\"_\"):\n check_modes = check.split(\"_\")\n for check_mode in check_modes:\n if not isMode(mode, check_mode):...
[ "0.68416965", "0.6592954", "0.65321696", "0.64740825", "0.6327304", "0.63070184", "0.6277338", "0.5980799", "0.5936964", "0.5894869", "0.58809364", "0.5868526", "0.5779383", "0.57723993", "0.5761688", "0.57445145", "0.57384235", "0.57228845", "0.5719184", "0.5700653", "0.5692...
0.8136188
0
Return True if and only if mode indicates the game is in test mode, and False otherwise. >>> in_test_mode('T') True >>> in_test_mode('E') False
def in_test_mode(mode: str) -> bool: return mode == TEST
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_mode(mode: str) -> bool:\n return mode in (TEST, EASY, HARD)", "def in_test_mode(self, repo):\n return config.get('test_mode', repo=repo)", "def test_test_mode(self):\n\n # Ensure that we default to test mode off\n self.assertFalse(self.driver._test_mode)\n\n excepti...
[ "0.72444856", "0.6852615", "0.65411115", "0.6474507", "0.6274849", "0.621066", "0.6163532", "0.5953138", "0.5897571", "0.58896554", "0.5868408", "0.5852036", "0.5784398", "0.57723427", "0.5732893", "0.5709262", "0.5681045", "0.56652296", "0.5612993", "0.5609369", "0.5585378",...
0.82374626
0
Return True if and only if mode indicates the game is in easy mode, and False otherwise. >>> in_easy_mode('E') True >>> in_easy_mode('H') False
def in_easy_mode(mode: str) -> bool: return mode == EASY
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_mode(mode: str) -> bool:\n return mode in (TEST, EASY, HARD)", "def eco_mode_enabled(self) -> bool:\n return self._device_info[\"EcoMode\"] == \"on\"", "def is_support(mode: int) -> bool:\n return mode in supported_modes\n pass", "def check_enable_mode(self, check_string='#'):\n ...
[ "0.6544077", "0.6287514", "0.5981719", "0.59426105", "0.5845831", "0.5844486", "0.580687", "0.57966757", "0.56680804", "0.55833864", "0.55572945", "0.5481888", "0.5474338", "0.5474338", "0.5473657", "0.54406446", "0.5424466", "0.5370847", "0.5350441", "0.5343598", "0.5343355"...
0.79923415
0
Return the new game state after performing the game move specified by move on the section of state correspoding to section_num. >>> make_move('ATCDOGFOXEMU', 1, 'R') 'CATDOGFOXEMU' >>> make_move('CATDOGFOXUME', 4, 'C') The section is incorrect 'CATDOGFOXUME'
def make_move(state: str, section_num: int, move: str) -> str: if move == wf.CHECK: check_result = wf.check_section(state, section_num) if check_result: print('The section is correct') else: print('The section is incorrect') else: state = wf.change_state(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_move(self, move):\n if type(move) == str:\n move = int(move)\n\n new_state = SubtractSquareState(not self.p1_turn,\n self.current_total - move)\n return new_state", "def make_move(self, move: Any) -> \"StonehengeState\":\n new...
[ "0.70182574", "0.6673007", "0.6612107", "0.65497804", "0.6517106", "0.647525", "0.63786256", "0.63121843", "0.6278452", "0.6199623", "0.61955255", "0.6136059", "0.6130135", "0.60747117", "0.60397965", "0.5908862", "0.59013885", "0.58989275", "0.5887443", "0.5865713", "0.58464...
0.8437671
0
Return a valid game mode entered by the user.
def get_mode() -> str: mode = input('Enter the mode to play [(T)est, (E)asy, or (H)ard]: ') while not is_valid_mode(mode): print('Invalid mode!') mode = input('Enter the mode to play [(T)est, (E)asy, or (H)ard]: ') return mode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_mode(self):\n return self._get(\"game_mode\")", "def get_player_mode(mode=None):\n if mode == \"1\":\n print(\"You've chosen Solo Mode! Can you beat a computer?\")\n return mode\n elif mode == \"2\":\n print(\"You've chosen Multiplayer Mode! Can you beat a human?\")\n ...
[ "0.75565565", "0.7202764", "0.6821942", "0.66530854", "0.6651077", "0.6651077", "0.6563576", "0.65586215", "0.6554351", "0.6524634", "0.65119785", "0.64491296", "0.63630396", "0.6348841", "0.6338388", "0.6233118", "0.6232582", "0.6226205", "0.62008864", "0.620042", "0.6192885...
0.77662545
0
Return a valid section number entered by the user.
def get_section_number() -> int: section_num = input('Enter a section number (1 - 4): ') while not (section_num.isdigit() and wf.is_valid_section(int(section_num))): print('Invalid section number!') section_num = input('Enter a section number (1 - 4): ') return int(section_num)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def section(self, idx: int) -> int:\n if self.sections >= (idx + 1):\n return int(RE_DIGIT.match(self.string.split(\".\")[idx]).group(1))\n return 0", "def get_section_hint(state: str) -> int:\n section_nums = [i + 1 for i in range(len(state) // wf.SECTION_LENGTH)]\n random.shuffle...
[ "0.6522393", "0.6294414", "0.5988498", "0.59530413", "0.57162154", "0.56322765", "0.5559978", "0.55530655", "0.5531887", "0.5508567", "0.54969805", "0.54601294", "0.5433692", "0.5413692", "0.53559995", "0.5241563", "0.52240914", "0.5203008", "0.515979", "0.5142805", "0.513927...
0.8810455
0
Return a valid move entered by the user.
def get_move() -> str: msg = 'Enter a move for that section (C to check, S to swap, R to rotate): ' move = input(msg) while not wf.is_valid_move(move): print('Invalid move!') move = input(msg) return move
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_move(self, board):\n\n valid_moves = [move for move in board.legal_moves]\n is_valid_move = False\n while not is_valid_move:\n move = input(\"Enter a valid move in uci format: \").lower()\n if len(move) == 4 or len(move) == 5:\n try:\n ...
[ "0.790794", "0.7603971", "0.75918245", "0.7441765", "0.7396418", "0.72964424", "0.72695065", "0.72305745", "0.720543", "0.7186338", "0.70309246", "0.70161897", "0.70109475", "0.6986676", "0.6979692", "0.69704807", "0.69599783", "0.6916412", "0.69141704", "0.6911527", "0.68819...
0.81562686
0
Return 1 if a hint was given, and 0 if not. Prompt the user to answer whether they would like a hint of type hint_type if and only if mode indicates the game is in easy mode. If yes, generate the hint on how to rearrange state (only using section_num if hint_type corresponds to a move hint) and print the hint.
def get_hints(state: str, mode: str, hint_type: str, section_num: int = 0) -> int: if in_easy_mode(mode): if hint_type == SECTION_HINT: hint = input('Enter Y if you want a section hint: ') if hint == 'Y': print('Your section hint is: ' + str(get_section_hint(state))) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hint(self):\r\n # Sample variables x and y in the range [-10, 10]\r\n sample_dict = {'x': (-10, 10), 'y': (-10, 10)}\r\n\r\n # Give a hint if the user leaves off the coefficient\r\n # or leaves out x\r\n hints = [('x + 3*y', 'y_coefficient', 'Check the coefficient of y')...
[ "0.5843901", "0.5729622", "0.57262224", "0.57114905", "0.56002575", "0.5516281", "0.5414793", "0.54023033", "0.53952", "0.53130263", "0.5303876", "0.52066034", "0.518067", "0.51021737", "0.50333303", "0.4967362", "0.49285474", "0.49111894", "0.48984668", "0.48977473", "0.4880...
0.83458793
0
Return the number of moves taken to arrive at the correct answer. Run the main loop in gamemode mode, prompting the user for input and consequently updating state.
def play_game(state: str, mode: str) -> int: moves = 0 if in_test_mode(mode): print('Answer: ' + wf.ANSWER) while state != wf.ANSWER: print('Current state: ' + state) moves += get_hints(state, mode, SECTION_HINT) section_num = get_section_number() m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\r\n noMove = 0\r\n while(noMove < 2):\r\n options = self.get_valid_moves()\r\n if len(options) > 0:\r\n res = False\r\n while(not res):\r\n move = self.players[self.turn-1].get_move(self.board.copy(),options.copy())...
[ "0.70284015", "0.6404722", "0.6338472", "0.62832123", "0.62282634", "0.61336094", "0.5992224", "0.5973218", "0.594925", "0.5926609", "0.5920745", "0.591415", "0.59038174", "0.58734757", "0.5852002", "0.58160967", "0.5811705", "0.5810292", "0.57928646", "0.5756727", "0.5756169...
0.7799572
0
Run an autosegmentation on an input image. Choose which algorithm to run and pass the path to the Nitfti input image OR a directory containing a DICOM series. Optionally, pass in a configuration file for the segmentation algorithm. Output the default configuration for an algorithm using the default flag.
def click_command(algorithm, input_path, config, default, output): algorithm_config = segmentation_algorithms[algorithm]["default_settings"] if default: print(json.dumps(algorithm_config, indent=4)) return # If we get to here but no input_path was set, we need to inform the user if no...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applySegmentationSteps(input_img, input_mode, output_root, save_intermediate=False, overwrite=False):\n\n np_img = loadImage(input_img)\n\n if save_intermediate == False:\n np_dist = getDistanceRaster(input_img, input_mode=input_mode)\n np_ridge = ridgeDetection(np_dist, 'np', method='meije...
[ "0.6112436", "0.6015282", "0.5750639", "0.56479937", "0.5598787", "0.5504381", "0.5437937", "0.5428975", "0.54104406", "0.53636897", "0.5304661", "0.52893245", "0.5221492", "0.5198504", "0.5196194", "0.5154485", "0.5152543", "0.51421636", "0.51167274", "0.5087006", "0.5060494...
0.73100406
0
Squares the numbers in num_list
def squared_nums(num_list): new_list = [] # initialize a new list for num in num_list: # iterate through the list squared_num = pow(num, 2) # raises to the power of 2 new_list.append(squared_num) # appends the result to the new list return new_list # returns the new list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def square_nums(number_list):", "def squared(num_list):\n new_list=[]\n for num in num_list:\n sq_num=pow(num,2)\n new_list.append(sq_num)\n return new_list", "def lsquare_of_sums(inlist):\r\n s = sum(inlist)\r\n return float(s)*s", "def raizCuadrada(listNum):\n\n return [math.s...
[ "0.8848842", "0.78166455", "0.7215354", "0.7150204", "0.70824355", "0.6997519", "0.69374", "0.69096386", "0.688807", "0.677243", "0.6726922", "0.67053944", "0.66111624", "0.66106373", "0.6603098", "0.65683067", "0.64936507", "0.64936507", "0.64936507", "0.64936507", "0.647839...
0.79106903
1
Removes strings in title_list that have numbers and are not title case title_list = list of strings
def check_title(title_list): new_list = [] #Initialize a new list for title in title_list: # iterates through the list to look for the non-titles if title.istitle(): # checks for titles new_list.append(title) # if found, appends to the new list return new_list # returns the new appended list.
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_title(title_list):\n for w_index in range(len(title_list)):\n title_list[w_index] = title_list[w_index].replace('_', ' ')\n return [word for word in title_list if word.istitle()]", "def keep_lowercase(str_list):", "def fix_title(title):\n words = re.findall('[A-Z][^A-Z]*', title[0])\n...
[ "0.7345439", "0.6368069", "0.6325404", "0.62862766", "0.62849927", "0.6161935", "0.61029637", "0.6091569", "0.6063799", "0.60401946", "0.6009834", "0.5965418", "0.5922428", "0.59212744", "0.59212744", "0.58840847", "0.5883111", "0.5882404", "0.58639055", "0.58502173", "0.5848...
0.65617573
1
Increases inventory of each item in dictionary by 10
def restock_inventory(inventory): new_dictionary = {} # create a new emply dictionary for key, value in inventory.items(): # look for key value pairs inventory[key] = value + 10 # in the inventory with the key lets say pencil increase the value by 10 return (inventory) # returns the updated dictionary
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restock_inventory(inventory):\n for k in inventory.keys():\n inventory[k] = inventory[k] + 10\n return inventory", "def add_to_inventory(self, item):\n\t\tif item in self.inventory:\n\t\t\tself.inventory[item] += 1\n\t\telse:\n\t\t\tself.inventory[item] = 1", "def getitem(self):\n self....
[ "0.7979997", "0.6748842", "0.6425087", "0.6418131", "0.6270335", "0.6233188", "0.6208321", "0.62063247", "0.6127558", "0.6091178", "0.5963571", "0.58908564", "0.57726574", "0.574582", "0.57426375", "0.57053244", "0.56772745", "0.5624655", "0.55953807", "0.558694", "0.55852354...
0.7672343
1
Removes items that have a value of 0 from a dictionary of inventories
def filter_0_items(inventory): new_list = [] # create an empty dictionary for key in inventory: # iterate through the list if inventory[key] == 0: # check for key = 0, if it is then new_list.append(key) # add it to a new list for keys in new_list:#iterting through new_list del inventory[keys] re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_0_items(inventory):\n for k,v in inventory.copy().items():\n if inventory[k] == 0:\n inventory.pop(k)\n return inventory", "def clean_up_map(self):\n self.items = [i for i in self.items if i.quantity != 0]", "def remove_outlier(dict_object, keys):\n for key in keys:...
[ "0.8096963", "0.7588919", "0.6413768", "0.63757044", "0.6367684", "0.63517725", "0.62293726", "0.6169815", "0.61511654", "0.6059877", "0.58848983", "0.57959706", "0.5737003", "0.5694725", "0.5673215", "0.55944765", "0.5577092", "0.55735654", "0.5566581", "0.55288976", "0.5514...
0.8019575
1
Takes grades values from a dictionary ad averages them into a final grade
def average_grades(grades): for key, value in grades.items(): # iterate through the dictionary for key and value grades[key] = sum(value)/len(value) # average of the value return (grades) #return grades
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_grades(grades):\n\n for k in grades.keys():\n new_list = grades[k]\n str_len = len(new_list)\n total = float(sum(new_list) / str_len)\n grades[k] = total\n return grades", "def average_scores(self, scores, education, count):\n\n for key in scores.keys():\n ...
[ "0.7873713", "0.6943277", "0.68400115", "0.6595139", "0.6455717", "0.6418605", "0.6334242", "0.62684715", "0.623619", "0.62083447", "0.61359245", "0.61074245", "0.60298246", "0.59715956", "0.5936197", "0.59098405", "0.5870836", "0.58561456", "0.58551854", "0.58504546", "0.584...
0.8427332
0
Checks if the input word is valid or not. Returns boolean accordingly. Filters out any tokens that are links or stop words.
def is_valid_lemma(self, word): # Expression for finding links. Return false if one is found # Expression found at https://stackoverflow.com/questions/27515969/regular-expression-validation-php/27516155 expression = re.compile(r'(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self, word):\n\n return self.valid_word(word)", "def validate(self, word):\n\n return self.valid_word(word)", "def filter_tokens(x):\n if x in _STOP_WORDS:\n return False\n if not re.search(r'\\w', x):\n # Does not contain at least one word character\n retu...
[ "0.70614296", "0.70614296", "0.67371285", "0.66866434", "0.66483504", "0.6411789", "0.6401606", "0.6308335", "0.63083124", "0.62643343", "0.62420446", "0.6230033", "0.62088037", "0.62052774", "0.6191632", "0.61900467", "0.6139754", "0.61169666", "0.6110598", "0.6090266", "0.6...
0.7445588
0
Inputs a single string that represents a line of data (tweet, news article, etc). Breaks string into a list of sentances, and passes each sentance through a lemmatizer and validator. Returns a list of prepared sentances.
def prepare_data(self, data): # Break string into a list of sentances in_sentances = tokenize.sent_tokenize(data) out_sentances = list() for sentance in in_sentances: # Turn each word in sentance into its lemma lemmas = [self.lemmatizer.lemmatize(word) for word in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parser(sent_list): #input: list of sentences", "def process(self, sentence):\n\n # selects onlt alphanumeric words\n words = self.tokenizer.tokenize(sentence)\n\n # lemmatize the words\n words = [self.lemmatizer.lemmatize(word) for word in words]\n\n # lowercase all the wor...
[ "0.6374897", "0.62834436", "0.6217632", "0.61962837", "0.60802025", "0.59153664", "0.5852285", "0.57940227", "0.5789301", "0.5753251", "0.5715902", "0.5711697", "0.56845933", "0.5679322", "0.5672883", "0.56566954", "0.5654694", "0.5646494", "0.5638076", "0.5634727", "0.563451...
0.7173315
0
Iterates over input list of sentances. Gets sentiment of each sentance and returns the average sentiment.
def get_sentiment(self, sentances): sentiment_total = 0 # Add each sentances combined sentiment to a total tally for sentance in sentances: sentiment = self.sentiment_analyzer.polarity_scores(sentance) sentiment_total += sentiment['compound'] return sentiment_tota...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_average_sentiment(self, list_sentiments):\n average_polarity = 0\n for sentiment in list_sentiments: \n polarity = sentiment[1]\n average_polarity += polarity \n average_polarity /= len(list_sentiments)\n return average_polarity", "def averages():\r\n ...
[ "0.7829622", "0.75677633", "0.7163454", "0.71054775", "0.70540977", "0.68959516", "0.67398673", "0.67392325", "0.6698907", "0.66943854", "0.6660001", "0.6407294", "0.6405679", "0.63865983", "0.6334893", "0.6324999", "0.6322835", "0.6309016", "0.63056993", "0.629432", "0.62619...
0.77835083
1
Inputs a string and returns a list of all emoticons that are found.
def get_emoticons_value(self, line): emoticons = list() # Finds any substring which represents an emote # Expression found at https://stackoverflow.com/questions/28783420/cannot-compile-8-digit-unicode-regex-ranges-in-python-2-7-re emoticons.extend(re.findall(u'[\U00010000-\U0010ffff]', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_emojis(text):\n emojis = []\n for emoji in emot.emoji(text):\n emojis.append(emoji['value'])\n text = text.replace(emoji['value'], '')\n\n return text, emojis", "def get_emojis(self):\n return self.tweets.str.findall(r':{1}[\\d\\w\\-]+:{1}')", "def emotions(self):\n ...
[ "0.68734354", "0.64763284", "0.64244825", "0.6348878", "0.6011213", "0.5939441", "0.5886352", "0.57929456", "0.5788512", "0.5787994", "0.5787994", "0.57172185", "0.570008", "0.56960046", "0.5693696", "0.56645405", "0.56580323", "0.56060207", "0.55989766", "0.55843586", "0.557...
0.749108
0
Iterates over each sentance and counts the number of words that are in each of the seven emotion categories. Returns dictionary of results.
def get_mood(self, sentances): moods = { "happiness": 0, "anxiety": 0, "sadness": 0, "affection": 0, "aggression": 0, "expressive": 0, "glory": 0 } for sentance in sentances: sentance = sentance.lower...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def frequency_feelings(self):\n feelings = {}\n for response in self.responses:\n if response.question.text == \"In one word, how does this text make you feel?\":\n lower_case_word = response.response.lower()\n if feelings.get(lower_case_word, 0) == 0:\n ...
[ "0.64196604", "0.63828003", "0.6320231", "0.624571", "0.6229315", "0.62036866", "0.61986345", "0.6181265", "0.6176596", "0.61327237", "0.60983986", "0.6078352", "0.60563964", "0.6022864", "0.60128236", "0.6010636", "0.6002797", "0.5984998", "0.59828514", "0.59767723", "0.5962...
0.7067273
0
Runs analytics; takes all the data from the specified file, collects sentiment, emotional, and emoticon data. Stores results into dictionaries and returns them.
def run(self, input_type, file_name): data = self.get_data(file_name) sentiment = dict() mood = dict() emoticon = dict() for line in data: weight = 1 # Twitter data has a weight defined before the | if input_type == "Twitter": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vader_analyse(file_input):\n sentences = getdata_from_db(1000)\n print(\"Working on %d tweets\" % (len(sentences)))\n headers = ('text', 'label', 'score')\n analyzed_data = []\n sid = SentimentIntensityAnalyzer()\n for line in sentences:\n text = pre.clean(line)\n scores = sid.p...
[ "0.6742306", "0.64086676", "0.631625", "0.6295548", "0.6106927", "0.60053074", "0.5944882", "0.5902826", "0.58235234", "0.5807723", "0.57983965", "0.57389295", "0.5731411", "0.5680243", "0.5669391", "0.56486934", "0.55876726", "0.55819345", "0.5570177", "0.5555029", "0.553321...
0.7130047
0
checks if no_bell map doesn't prohibit bells today
def is_no_bell_day(): today = time.localtime()[:3] for r in no_bell: if today >= r[0] and today <= r[1]: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _user_assigned_bell(self, bell: Bell) -> bool:\n return not self._bot_assigned_bell(bell)", "def power_bells(state):\n if not pinlessMode:\n if state:\n for pin in bellPins:\n GPIO.output(pin, GPIO.HIGH)\n elif not state:\n for pin in bellPins:\n ...
[ "0.63722193", "0.6049356", "0.5962841", "0.59310937", "0.5906065", "0.5905496", "0.5834034", "0.58233607", "0.5822433", "0.5809948", "0.5805469", "0.57956964", "0.57908773", "0.5769487", "0.5678093", "0.5604709", "0.5599803", "0.5576898", "0.5575153", "0.55698776", "0.5542476...
0.7161038
0
schedule events for current day, this is usually called at the begginning of each new day to scedule events for that day only + one event for rescheduling next day
def reschedule(): if not schedule.empty(): purge_events() today_s = tuple_to_str(time.localtime()[:3]) # first check if exception entry exist for today in datemap if today_s in datemap: schedule_day(datemap[today_s]) else: # otherwise schedule it as normal weekday sc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def schedule_task(self, name, date):\n pass", "def startSchedule(self):\n DPxStartDinSched()", "def bootstrap_events():\n import datetime\n import random\n # let's have each event occur once between 3 and 6 pm, \n # some day in the next month, and then recur for the next 1 to 8 weeks\...
[ "0.63996965", "0.6364515", "0.6270511", "0.6233818", "0.61795765", "0.6167035", "0.61531335", "0.60690117", "0.6052733", "0.60286534", "0.6019136", "0.5975083", "0.5972812", "0.5967778", "0.5949784", "0.5916603", "0.58772904", "0.5870145", "0.5862457", "0.58550876", "0.581195...
0.7430452
0
Using the Fiona library convert GeopackageHelper to GeoJSON
def convert_gpkg_to_geojson(self,shape_fname, destdirectory): features = [] crs = None if not os.path.isfile(shape_fname): self.logger.error('File not found: %s' % shape_fname) self.opstatus.add_info(stage=6, msg = "Rounding coordinates to six decimal precision") out_fname = os.path.join(destdire...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default(self, o): \n if isinstance(o, GEOSGeometry):\n dictval = json.loads(o.geojson)\n #raise Exception(o.ewkt)\n dictval['__GEOSGeometry__'] = ['__init__', [o.ewkt]] #json class hint; see http://json-rpc.org/wiki/specification\n return dictval\n else...
[ "0.6658173", "0.66399086", "0.6400657", "0.6355311", "0.63249147", "0.6312711", "0.6296247", "0.62948203", "0.62946975", "0.6292872", "0.62386644", "0.62367254", "0.61942255", "0.6115604", "0.60356015", "0.60196793", "0.5957294", "0.59480387", "0.59430397", "0.59273314", "0.5...
0.6736785
0
Rebuild the LCI/LCIA matrices from a new Monte Carlo sample or provided vector.
def rebuild_all(self, vector=None): if not hasattr(self, "positions"): self.load_data() if vector is not None and not isinstance(vector, np.ndarray): raise ValueError("`vector` must be a 1-d numpy array") if vector is not None: assert vector.shape == self.pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebuild_the_laplacians():\n local_matrix = InteractomeInterface()\n local_matrix.full_rebuild()\n\n annot_matrix = AnnotomeInterface()\n annot_matrix.full_rebuild()", "def reconstruct(self, vector):\n return self.reconstruct_vectors(vector[None, :]).flatten()", "def build_augmented_matri...
[ "0.5767239", "0.54645854", "0.5186119", "0.5121431", "0.51160043", "0.51107913", "0.5103802", "0.510151", "0.50146663", "0.49944654", "0.49386817", "0.4923459", "0.48787823", "0.4870082", "0.48589543", "0.48388454", "0.48099792", "0.48059684", "0.48047376", "0.48034263", "0.4...
0.5868529
0
serialize struct_time to timezone
def serialize_datetime(date_time) -> timezone: if isinstance(date_time, struct_time): return timezone.datetime.fromtimestamp(mktime(date_time)).replace(tzinfo=pytz.UTC) else: raise TypeError("Can't convert this type to datetime")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_struct_to_datetime(struct_time_object):\n return datetime.datetime(*struct_time_object[:6])", "def _serialize_time(val):\n return val.isoformat()", "def serialized_time(time):\n formatted = time.isoformat()\n if formatted.endswith(\"+00:00\"):\n formatted = formatted[:-6] + \"Z\"\n\...
[ "0.6696328", "0.66784537", "0.6304099", "0.6207683", "0.605701", "0.5979643", "0.5960567", "0.5920082", "0.5860897", "0.5860897", "0.5845807", "0.5836228", "0.58273715", "0.5815514", "0.5766322", "0.5720496", "0.5704188", "0.5628591", "0.56161356", "0.5607155", "0.56001204", ...
0.7104688
0
set properties for object from parsed_data.
def set_properties(self): # assign feed entries from the root of the parsed data if hasattr(self.parsed_data, "entries"): self.items = self.parsed_data.entries # check if it is a feed root or feed element if hasattr(self.parsed_data, "feed"): source_data = self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, data):\n # add play_guid as it sometimes doesn't exist\n if 'play_guid' not in data:\n data['play_guid'] = ''\n # loop through data\n for x in data:\n # set information as correct data type\n mlbgame.object.setobjattr(self, x, data[x])...
[ "0.6668565", "0.66331637", "0.6311598", "0.6184064", "0.61690265", "0.6161215", "0.614354", "0.6140493", "0.60973036", "0.6087782", "0.60834193", "0.6038224", "0.59710634", "0.5877489", "0.58292496", "0.5816957", "0.5805474", "0.5780091", "0.5763294", "0.5756133", "0.5750351"...
0.73541945
0
This method finds the nearest neighbors in a table/view called 'datatable' for each object in 'objectlist' within a search radius 'radius'.
def object_finder( self, datatable, objectlist, ralist, declist, radius, longquery=True ): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_nearest_neighbors(self, kdt, radius=8):\n neighbors = kdt.query_radius(np.array([self.position[:-1]]), r = radius)\n return neighbors[0][1:]", "def get_neighbours(self, business, num=5, add_self=False):\n\n def radius_step(radius, num_longtidues, num_latitudes, time):\n \"...
[ "0.6175332", "0.60992473", "0.6093694", "0.60548466", "0.5978704", "0.5970773", "0.5889855", "0.5846486", "0.57988584", "0.57911736", "0.5780814", "0.5780404", "0.5774157", "0.5773087", "0.57641494", "0.57413846", "0.5715195", "0.57103866", "0.57003397", "0.5674021", "0.56690...
0.7034364
0
Load data file, parse spike data, then send initalization data to dim reduction
def setup(self): # get unsorted vs sorted units data_dict = mat73.loadmat(self.file) units_unsorted = [] units_sorted = [] for ch_curr in data_dict['spikes']: units_unsorted.append(ch_curr[0]) # from data description, first unit is unsorted for unit_curr i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadSimData(datafile):\n \n global dt, ti, Lx, Ly, nsamp, N, M, L, B, totalStep, Fmc, Kbend, kT, \\\n dtSamp, T, box_area, nt, body_length, Pe, persistence, flexure \n\n datafile = open(datafile,\"r\")\n for line in datafile:\n A = line.split()\n if A[0] == \"dt\": ...
[ "0.65616596", "0.6557325", "0.65071505", "0.63667995", "0.61828595", "0.61617154", "0.60358214", "0.6017118", "0.60101986", "0.5990661", "0.5955847", "0.5955847", "0.5915603", "0.5910003", "0.58991474", "0.5885808", "0.5876386", "0.586066", "0.58460534", "0.58357775", "0.5824...
0.67746013
0
Alters the cube, scaling, transforming
def b_transform_cube(b_obj): b_scale_object() b_scale_single_face(b_obj)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform(self, data):\n self.cube = self.trf.transform(data)", "def transform_cube(self,\n cube: xr.Dataset,\n gm: GridMapping,\n cube_config: CubeConfig) -> TransformedCube:", "def scale(self, x, y, z) -> None:\n ...", "def...
[ "0.6694423", "0.66168797", "0.6367737", "0.6105498", "0.6039283", "0.60163206", "0.5980319", "0.5951304", "0.5907383", "0.5883287", "0.58437085", "0.58133626", "0.5810219", "0.57776093", "0.5776965", "0.57480514", "0.5731953", "0.57181156", "0.5717602", "0.5705528", "0.567461...
0.7299694
0
Scale a single face of the object.
def b_scale_single_face(b_obj): # scale single face for poly in b_obj.data.polygons: poly.select = False b_obj.data.polygons[2].select = True for b_vert_index in b_obj.data.polygons[2].vertices: b_obj.data.vertices[b_vert_index].co[1] = b_obj.data.vertices[b_vert_index].co[1] * 0....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale(self, size):\n self._surf = pygame.transform.smoothscale(self._surf, size).convert_alpha()", "def scale(self, size):\n self._surf = pygame.transform.smoothscale(self._surf,\n size).convert_alpha()\n self._version += 1\n return...
[ "0.70263743", "0.6940709", "0.6471854", "0.6386272", "0.63822234", "0.636569", "0.63525623", "0.63352567", "0.62949914", "0.6202851", "0.6201046", "0.61532867", "0.6143922", "0.6116454", "0.6085282", "0.6083255", "0.60789496", "0.60042995", "0.597115", "0.597115", "0.59677833...
0.7857056
0
Returns resturant ratings from file as a dictionary.
def return_restaurant_rating_dictionary(filename): the_file = open(filename) for line in the_file: line = line.rstrip() ratings = line.split(":") restaurant_name = ratings[0] rating = ratings[1] restaurant_ratings[restaurant_name] = rating return restaurant_rating...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ratings(filename):\n\n all_ratings = {}\n\n with open(filename) as f:\n for line in f:\n line = line.rstrip()\n restaurant, rating = line.split(\":\")\n all_ratings[restaurant] = rating\n\n return all_ratings", "def process_file(file_name):\n \n rest...
[ "0.8314891", "0.7977691", "0.76466507", "0.74871945", "0.7121011", "0.705934", "0.7026679", "0.699601", "0.68067664", "0.6801764", "0.6788466", "0.6650362", "0.65753245", "0.6558319", "0.63981", "0.62826574", "0.61762506", "0.6133874", "0.61258125", "0.6095542", "0.60633177",...
0.8010539
1
Prints restaurant ratings, alphabetized by restaurant name.
def print_alph_restaurant_ratings(restaurant_dict): for restaurant_name, rating in sorted(restaurant_dict.items()): # print "{} is rated at {}.".format(restaurant_name, # rating) restaurant_name = restaurant_dict.items[0] rating = restau...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_ratings(all_ratings):\n print(\"Here is the current list of all ratings:\")\n for restaurant, rating in sorted(all_ratings.items()):\n print(f'{restaurant} is rated at {rating}.')", "def alphabetized_restaurant_ratings(restaurant_ratings_dictionary):\n for name, rating in sorted(restaur...
[ "0.80544746", "0.7714753", "0.7306745", "0.72122705", "0.69183373", "0.6862691", "0.67796004", "0.6312141", "0.63108295", "0.61446047", "0.61174047", "0.61114484", "0.6057809", "0.6020447", "0.6011145", "0.59918296", "0.5936555", "0.5930612", "0.5908128", "0.5902657", "0.5881...
0.7954401
1
This function samples the brightness parameters, mu_flor and mu_back using Hamiltonian Monte Carlo.
def sample_mu(self, val) -> None: # get data data = self.data.reshape((1, -1)) # get values gain = val.gain states = val.states mu_flor = val.mu_flor mu_flor_mean = val.mu_flor_mean mu_flor_shape = val.mu_flor_shape mu_back = val.mu_back ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_posterior(self):\n \n# print (\"SAMPLING FROM LINEAR SIMILARITY VB\")\n if (self.posterior_mean == False):\n self.weight = Vil.sample_posterior(self.mu_weight, Vil.softplus(self.rho_weight))\n self.bias = Vil.sample_posterior(self.mu_bias, Vil.softplus(self.rho...
[ "0.598156", "0.5978819", "0.5822451", "0.5607292", "0.5564162", "0.55608475", "0.5511193", "0.54922384", "0.5477683", "0.5445564", "0.5433154", "0.542647", "0.54067206", "0.5380345", "0.53725094", "0.53361946", "0.53319806", "0.5330416", "0.53189874", "0.5314222", "0.5311392"...
0.6618311
0
This function runs a Gibbs sampler algorithm over the posterior to collect samples from the posterior.
def gibbs_sampler(self, data=None, parameters=None, save_name='test', save_path='outfiles/', plot_status=False, log_file=False, **kwargs): print('\n{}\n{}\n{}'.format('-'*len(save_name), save_name, '-'*len(save_name))) # creates a log file if specified if log_file: log = save_name +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gibbs_sample(self):\n # Initialize the initial state of Markov Chain.\n self.initialize()\n # Gibbs Sampling.\n for iteration_index in range(0, self.iteration_number, 1):\n for m in range(0,self.document_number,1):\n for n in range(0, len(self.documents[m])...
[ "0.7207733", "0.6881152", "0.66835207", "0.6576732", "0.64802915", "0.64319247", "0.6256353", "0.6235843", "0.6132594", "0.6085217", "0.6061682", "0.6050526", "0.5930381", "0.5884115", "0.58757025", "0.58688474", "0.58540446", "0.58322746", "0.5747067", "0.5743532", "0.574040...
0.6882195
1
load pretrained word embedding
def load_pretrained_embedding(self, pre_embeddings): assert (pre_embeddings.size()[1] == self.embedding_dim) self.word_embeds.weight = nn.Parameter(pre_embeddings)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embedding_file(self):\n if self.language == 'en':\n embed_file_dir = self.embedding_path\n wv = KeyedVectors.load_word2vec_format(embed_file_dir, binary=True)\n self.pretrained_embedding = {}\n for word in wv.vocab.keys():\n normalized_word...
[ "0.81451064", "0.78315616", "0.7747075", "0.7655655", "0.76149315", "0.76103157", "0.7528007", "0.74930793", "0.7491543", "0.74675125", "0.7453024", "0.7405483", "0.73980623", "0.7379225", "0.73778546", "0.73011637", "0.7276894", "0.7208229", "0.7112189", "0.71097624", "0.704...
0.8000602
1
Handle the installation of the firmware file.
def install_firmware(self, firmware_file_path: str) -> None: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install_firmware(self, image_path):\n \"\"\"Not Implement\"\"\"\n return False", "def test_handle_install_file_present(self):\n mock_status_callback = MagicMock()\n mock_firmware_handler = self.MockFirmwareHandler()\n mock_firmware_handler.get_current_version = MagicMock(\n...
[ "0.68683445", "0.6780528", "0.6478671", "0.64072794", "0.62866247", "0.6233456", "0.6227008", "0.61777616", "0.6163451", "0.6149231", "0.6125689", "0.61148953", "0.60847825", "0.6048365", "0.5996529", "0.5972869", "0.59377974", "0.59254813", "0.5879711", "0.58544075", "0.5840...
0.7618573
0
Test passing an invalid firmware handler.
def test_invalid_firmware_handler(self): mock_status_callback = MagicMock() self.assertRaises( ValueError, OSFirmwareUpdate, 1, mock_status_callback )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_handle_install_file_not_present(self):\n mock_status_callback = MagicMock()\n mock_firmware_handler = self.MockFirmwareHandler()\n firmware_version = \"1.0\"\n mock_firmware_handler.get_current_version = MagicMock(\n return_value=firmware_version\n )\n\n ...
[ "0.66562074", "0.64156896", "0.60923696", "0.6086644", "0.59546596", "0.58879626", "0.5856399", "0.58014596", "0.5759754", "0.57540214", "0.5742313", "0.57324404", "0.5703995", "0.5692802", "0.5641137", "0.5623746", "0.56231046", "0.5616834", "0.56164026", "0.56005", "0.55944...
0.8097426
0
Test getting firmware version from firmware handler.
def test_get_firmware_version(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() firmware_version = "1.0" mock_firmware_handler.get_current_version = MagicMock( return_value=firmware_version ) firmware_update = OSFirm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_firmware_version(self):\n self._verify_firmware_version()", "def test_fw_version(mocker):\n mocker.patch('serial.Serial.open')\n mocker.patch('serial.Serial.flushInput')\n mocker.patch('pysds011.driver.SDS011.cmd_set_sleep')\n mocker.patch('pysds011.driver.SDS011.cmd_set_mode')\n cfv =...
[ "0.8165977", "0.77345246", "0.7501908", "0.742611", "0.7408754", "0.73981726", "0.7255102", "0.72426367", "0.7198219", "0.71152556", "0.71115816", "0.7102065", "0.70699406", "0.70607394", "0.69946396", "0.6961693", "0.6862018", "0.68567574", "0.6851694", "0.6814915", "0.66981...
0.8004265
1
Test receiving install command and file exists on device.
def test_handle_install_file_present(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() mock_firmware_handler.get_current_version = MagicMock( return_value="1.0" ) mock_firmware_handler.install_firmware = MagicMock() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verifyInstalled(cmd):\n\tprint \"Verifying %s works...\" % cmd\n\tif (sys.platform == 'win32'):\n\t\ttry:\n\t\t\tstatus = subprocess.call(shlex.split(cmd))\n\t\t\tprint \"Installation was successful.\"\n\t\t\treturn True\n\t\texcept OSError as e:\n\t\t\tprint >>sys.stderr, \"Execution failed with verification:...
[ "0.67005706", "0.6697824", "0.66566634", "0.653048", "0.65262645", "0.64361185", "0.6433776", "0.64265186", "0.64114606", "0.638161", "0.63736176", "0.6365181", "0.6316361", "0.6308801", "0.6239025", "0.62156874", "0.62092596", "0.6183086", "0.6174404", "0.6156247", "0.614589...
0.68001217
0
Test receiving the abort command when module not idle.
def test_handle_abort_when_not_idle(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() firmware_update = OSFirmwareUpdate( mock_firmware_handler, mock_status_callback ) firmware_update.logger.setLevel(logging.CRITICAL) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def abort() -> NoReturn:\n raise AbortSignal", "def abort(self):\n print(\"abort\")", "def abort(self):\n try:\n self.acqRunning = False\n except:\n print('Cannot abort properly')", "def aborting(self):\n \n pass", "def _thread_check_abort_event(self)...
[ "0.686748", "0.6848484", "0.6717514", "0.6581567", "0.65720046", "0.6555663", "0.6496909", "0.645464", "0.6448417", "0.64369285", "0.6343544", "0.6331832", "0.63009477", "0.6273014", "0.6263834", "0.62392724", "0.62390983", "0.62250054", "0.6198961", "0.6179422", "0.61697525"...
0.6867068
1
Test the abort command when not idle and version file exists.
def test_handle_abort_when_not_idle_and_version_file(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() firmware_update = OSFirmwareUpdate( mock_firmware_handler, mock_status_callback ) firmware_update.logger.setLevel(logging....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_handle_abort_when_not_idle(self):\n mock_status_callback = MagicMock()\n mock_firmware_handler = self.MockFirmwareHandler()\n firmware_update = OSFirmwareUpdate(\n mock_firmware_handler, mock_status_callback\n )\n firmware_update.logger.setLevel(logging.CRITIC...
[ "0.65638506", "0.62183833", "0.6206509", "0.6062271", "0.60525274", "0.60190946", "0.59591633", "0.5886924", "0.5834233", "0.5819208", "0.5789556", "0.5770664", "0.5753073", "0.5743728", "0.57052815", "0.56777036", "0.56483227", "0.5645267", "0.56043744", "0.56035477", "0.560...
0.7593396
0
Test reporting result with no stored firmware version.
def test_report_result_no_stored_file(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() firmware_update = OSFirmwareUpdate( mock_firmware_handler, mock_status_callback ) firmware_update.logger.setLevel(logging.CRITICAL) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_firmware_version(self):\n self._verify_firmware_version()", "def test_report_result_unchanged_version(self):\n mock_status_callback = MagicMock()\n mock_firmware_handler = self.MockFirmwareHandler()\n firmware_version = \"1.0\"\n mock_firmware_handler.get_current_version =...
[ "0.7455106", "0.71597755", "0.69234776", "0.68397397", "0.65961516", "0.6509185", "0.6464707", "0.6347834", "0.63399565", "0.62981254", "0.6261175", "0.62452495", "0.622332", "0.62195474", "0.6128874", "0.6124425", "0.6118026", "0.6103822", "0.6097841", "0.6080674", "0.605103...
0.7216541
1
Test reporting result with unchanged version.
def test_report_result_unchanged_version(self): mock_status_callback = MagicMock() mock_firmware_handler = self.MockFirmwareHandler() firmware_version = "1.0" mock_firmware_handler.get_current_version = MagicMock( return_value=firmware_version ) firmware_updat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_version(self):\n pass", "def test_report_result_changed_version(self):\n mock_status_callback = MagicMock()\n mock_firmware_handler = self.MockFirmwareHandler()\n firmware_version = \"1.0\"\n mock_firmware_handler.get_current_version = MagicMock(\n return_va...
[ "0.72260493", "0.70254093", "0.69303596", "0.6838647", "0.6824102", "0.67868227", "0.66719574", "0.6652942", "0.66527915", "0.6641951", "0.6631518", "0.6617154", "0.65960985", "0.653902", "0.6528611", "0.6521069", "0.6505069", "0.64921314", "0.64686817", "0.6458891", "0.64576...
0.73677313
0
Build a heap from ``data`` inplace. Returns a sequence of swaps performed by the algorithm.
def build_heap(data): # The following naive implementation just sorts the given sequence # using selection sort algorithm and saves the resulting sequence # of swaps. This turns the given array into a heap, but in the worst # case gives a quadratic number of swaps. # # TODO: replace by a more ef...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_heap(data):\n # The following naive implementation just sorts the given sequence\n # using selection sort algorithm and saves the resulting sequence\n # of swaps. This turns the given array into a heap, but in the worst\n # case gives a quadratic number of swaps.\n #\n data_ = [0] * (le...
[ "0.8641238", "0.8321778", "0.8191848", "0.7983638", "0.6863657", "0.6691737", "0.64889646", "0.64148825", "0.63708085", "0.6335683", "0.62689", "0.6231121", "0.6208545", "0.6204041", "0.61974216", "0.6182186", "0.6120005", "0.6103361", "0.6030695", "0.600491", "0.5994693", ...
0.85100245
1
Reads waypoints from a csv file.
def read_from_csv_file(cls, csv_file_name: str, target_speed): csv_file = open(csv_file_name) csv_reader = csv.reader(csv_file) waypoints = [] for row in csv_reader: x = float(row[0]) y = float(row[1]) z = float(row[2]) waypoint = pylot.uti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_csv():", "def walk_csv(self, filepath: str):\n with open(filepath, encoding='ISO-8859-1') as f:\n reader = csv.DictReader(f)\n for row in reader:\n logger.debug('Loading map {}'.format(row.get('id', None)))\n yield row", "def loadCSV(input_fil...
[ "0.676114", "0.6605252", "0.6556858", "0.64591825", "0.6443623", "0.626401", "0.6216206", "0.62039834", "0.62009734", "0.6184218", "0.6182193", "0.6118941", "0.60933214", "0.6092776", "0.6089563", "0.60847956", "0.6071656", "0.6070581", "0.60534495", "0.60489684", "0.6046502"...
0.72340965
0
Returns the waypoints as a numpy array of lists of x and y.
def as_numpy_array_2D(self): wx = [] wy = [] for wp in self.waypoints: wx.append(wp.location.x) wy.append(wp.location.y) return np.array([wx, wy])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points(self):\n return np.vstack((self.x(), self.y()))", "def points(self):\n p = []\n for v in self.iter():\n p.append((v.x, v.y))\n return p", "def points(self):\n return self._arr.T.ravel().view(\n dtype=[('x', self.dtype), ('y', self.dtype), (...
[ "0.74419016", "0.71239907", "0.69828236", "0.6943635", "0.69008195", "0.67944545", "0.6707484", "0.6685052", "0.66268176", "0.65956616", "0.65912074", "0.6582299", "0.65334374", "0.65076655", "0.65031314", "0.64859104", "0.6408881", "0.63892144", "0.63890857", "0.63744074", "...
0.8419584
0
Finds the closest waypoint to the location.
def closest_waypoint(self, location: pylot.utils.Location): min_dist = np.infty min_index = 0 for index, waypoint in enumerate(self.waypoints): dist = waypoint.location.distance(location) if dist < min_dist: min_dist = dist min_index = inde...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_closest_waypoint(self, pose):\n # Find the nearest waypoint\n closest_distance = float('inf')\n closest_waypoint = 0\n for i in range(len(self.waypoints)):\n this_distance = self.distance_to_position(self.waypoints, i, pose.position)\n if this_distance < cl...
[ "0.80371714", "0.77580124", "0.7752407", "0.7701288", "0.7662863", "0.7629899", "0.7607416", "0.7569968", "0.7476396", "0.74598616", "0.72960234", "0.7292274", "0.7150513", "0.7143684", "0.7138067", "0.7007108", "0.69992584", "0.69735056", "0.682834", "0.66521144", "0.6640904...
0.783909
1
Removes the first waypoint if it is less than distance m away.
def remove_waypoint_if_close(self, location: pylot.utils.Location, distance: float = 5) -> bool: if self.waypoints is None or len(self.waypoints) == 0: return False if location.distance(self.waypoints[0].location) < distance: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to(self, waypoint):\n self.set_final_wp(waypoint)\n self.go()\n currPos = np.asarray(self.rexarm.get_positions())\n while(np.linalg.norm(np.asarray(waypoint) - currPos) > 0.15):\n time.sleep(0.01)", "def __spur_on_if_needed(self):\n if len(self.waypoints) < ...
[ "0.5926494", "0.58535093", "0.57727855", "0.56410366", "0.5638744", "0.56016695", "0.5599047", "0.557397", "0.5569027", "0.55392486", "0.55283374", "0.5494964", "0.5493939", "0.5467968", "0.54155433", "0.5393493", "0.5383858", "0.53701687", "0.53489786", "0.5347584", "0.53435...
0.7161757
0
Removes waypoints that the ego vehicle has already completed. The method first finds the closest waypoint to the location, and then removes all waypoints that are before the closest waypoint.
def remove_completed(self, location: pylot.utils.Location, ego_transform: pylot.utils.Transform = None): min_index = self.closest_waypoint(location) # Remove waypoints that are before the closest waypoint. The ego # vehicle already completed them...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_waypoint_if_close(self,\n location: pylot.utils.Location,\n distance: float = 5) -> bool:\n if self.waypoints is None or len(self.waypoints) == 0:\n return False\n if location.distance(self.waypoints[0].location) < ...
[ "0.66268104", "0.61959696", "0.584867", "0.57383746", "0.56080455", "0.5463144", "0.5447195", "0.5391344", "0.53584206", "0.5355911", "0.531375", "0.5229986", "0.5179607", "0.5134207", "0.51061606", "0.50994265", "0.50901127", "0.5024311", "0.50144416", "0.50069064", "0.49792...
0.76615846
0
Returns the angle between the transform and the first waypoint that is at least min_distance away.
def get_angle(self, transform: pylot.utils.Transform, min_distance: float) -> float: wp_index = self._get_index(transform, min_distance) angle, _ = transform.get_angle_and_magnitude( self.waypoints[wp_index].location) return angle
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle(self):\n v = self.p1 - self.p0\n return atan2(v.y, v.x)", "def angle(self):\n return math.degrees(math.atan2(self[1], self[0]))", "def find_allowable_angle(self, dist: float) -> float:\n angle = math.atan(self.TRUE_TARGET_RADIUS / dist)\n # print(f\"angle tolerance ...
[ "0.64367676", "0.63680017", "0.6264427", "0.6071864", "0.6054758", "0.60400385", "0.6021209", "0.6013427", "0.6007506", "0.59982485", "0.5993357", "0.5977916", "0.5957898", "0.5948635", "0.59239256", "0.59089994", "0.5888465", "0.58789474", "0.5874491", "0.5872852", "0.584439...
0.8047479
0
Returns the vector between the transform and the first waypoint that is at least min_distance away.
def get_vector(self, transform: pylot.utils.Transform, min_distance: float): wp_index = self._get_index(transform, min_distance) return self.waypoints[wp_index].location.as_vector_2D() - \ transform.location.as_vector_2D()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_closest_waypoint(self, pose):\n #TODO implement - Done\n # Iterate the base_waypoints' x value with current position's x value and find the closest\n # match, and pick that waypoint location index. \n min_idx = 0\n min_dist = None\n cur_x = pose.position.x\n ...
[ "0.6716802", "0.66186583", "0.65528345", "0.64339", "0.6338922", "0.6274757", "0.62589484", "0.62559295", "0.62322426", "0.6176124", "0.61617625", "0.61426383", "0.61366576", "0.6133993", "0.60911924", "0.6088077", "0.6038042", "0.6036377", "0.6024675", "0.5993986", "0.599398...
0.7559864
0
Gets the target speed at the first waypoint that is at least min_distance away.
def get_target_speed(self, transform: pylot.utils.Transform, min_distance: float) -> float: wp_index = self._get_index(transform, min_distance) return self.target_speeds[wp_index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance_to_current_waypoint():\n nextwaypoint = vehicle.commands.next\n if nextwaypoint == 0:\n return None\n missionitem = vehicle.commands[nextwaypoint -\n 1] #commands are zero indexed\n lat = missionitem.x\n lon = missionitem.y\n alt = missionite...
[ "0.73220944", "0.7246206", "0.66607845", "0.6493784", "0.64006424", "0.63146424", "0.6259501", "0.6218519", "0.6188682", "0.6162573", "0.6152221", "0.61325127", "0.60963005", "0.609057", "0.6078571", "0.6012068", "0.6007863", "0.600322", "0.5992872", "0.5969203", "0.594895", ...
0.7603735
0
Draw waypoints on a frame.
def draw_on_frame(self, bgr_frame, inverse_transform=None): extrinsic_matrix = bgr_frame.camera_setup.get_extrinsic_matrix() intrinsic_matrix = bgr_frame.camera_setup.get_intrinsic_matrix() for index, wp in enumerate(self.waypoints): if inverse_transform: wp = inverse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_on_world(self, world):\n for index, wp in enumerate(self.waypoints):\n # Adds 0.5 to z to ensure that the point is above the road surface.\n loc = (wp.location +\n pylot.utils.Location(0, 0, 0.5)).as_simulator_location()\n world.debug.draw_point(lo...
[ "0.675669", "0.65576106", "0.6354201", "0.62983316", "0.62944514", "0.618031", "0.61121047", "0.60885686", "0.597918", "0.59416425", "0.5930113", "0.59220034", "0.59125364", "0.5894867", "0.5890554", "0.5888072", "0.5857224", "0.5854743", "0.58358055", "0.5806921", "0.5794626...
0.7305699
0
Draw waypoints on the simulator world.
def draw_on_world(self, world): for index, wp in enumerate(self.waypoints): # Adds 0.5 to z to ensure that the point is above the road surface. loc = (wp.location + pylot.utils.Location(0, 0, 0.5)).as_simulator_location() world.debug.draw_point(loc, size=0....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_waypoints(world, waypoints, z=0.01):\n for wpt in waypoints:\n wpt_t = wpt.transform\n begin = wpt_t.location + carla.Location(z=z)\n angle = math.radians(wpt_t.rotation.yaw)\n end = begin + carla.Location(x=math.cos(angle), y=math.sin(angle))\n world.debug.draw_arrow...
[ "0.66840714", "0.66795164", "0.6600115", "0.6580789", "0.6300364", "0.62473875", "0.6230317", "0.62090623", "0.6182935", "0.6165176", "0.61582327", "0.61322266", "0.6123043", "0.6115214", "0.6110336", "0.61087155", "0.6090101", "0.6089843", "0.6085808", "0.6067363", "0.606234...
0.8217965
0
params table_name string dynamodb table name params key_name string dynamodb table primary key
def __init__(self, table_name, key_name) -> None: if not DB_ENDPOINT: self.client = boto3.resource("dynamodb") else: self.client = boto3.resource("dynamodb", endpoint_url=DB_ENDPOINT) # for testing -> was not working with env variable for some reason. # need to in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_table(table_name, filter_key=None, filter_value=None):\n table = dynamodb.Table(table_name)\n\n if filter_key and filter_value:\n filtering_exp = Key(filter_key).eq(filter_value)\n response = table.query(KeyConditionExpression=filtering_exp)\n else:\n response = table.query(...
[ "0.62873125", "0.62679005", "0.62276125", "0.6227167", "0.62052846", "0.60579866", "0.602017", "0.58784723", "0.58703464", "0.5857174", "0.5849382", "0.5844431", "0.5825517", "0.5795559", "0.56661654", "0.56511134", "0.56288356", "0.5625783", "0.56059664", "0.55820763", "0.55...
0.6615286
0
Registers a combination of one or more models, one or more keys and one or more signals. Whenever one of the signals is sent by one of the models, the associated cache keys will be deleted. By default, if you omit the `signals` parameter it will use the Django `post_save` signal.
def register(self, models, keys, signals=post_save, **kwargs): if not isinstance(signals, (list, tuple)): signals = [signals] for signal in signals: if settings.DEBUG: err = "{} is not a valid Signal subclass.".format(signal) assert isinstance(sign...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self):\n for signal, models in six.iteritems(self._registry):\n for model, keys in six.iteritems(models):\n # Local function the current signal is going to be\n # connected to.\n # Defining it dynamically allows us to pass in the current\n ...
[ "0.66491324", "0.6442545", "0.58168805", "0.57932657", "0.552136", "0.548373", "0.5481442", "0.52676225", "0.5223032", "0.51982576", "0.5167057", "0.5161264", "0.51268774", "0.5116198", "0.50248075", "0.50216794", "0.49629274", "0.4926565", "0.49122542", "0.4890563", "0.48737...
0.78166646
0
Connects all current registered signals to the cache delete function.
def connect(self): for signal, models in six.iteritems(self._registry): for model, keys in six.iteritems(models): # Local function the current signal is going to be # connected to. # Defining it dynamically allows us to pass in the current ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self, cache_key):\r\n pass", "def on_delete(key):\n pass", "def disconnect(self):\n for signal, models in six.iteritems(self._registry):\n for model, keys in six.iteritems(models):\n signal.disconnect(sender=model, weak=False, dispatch_uid=signal)\n ...
[ "0.63536656", "0.6163808", "0.59302086", "0.59195465", "0.58715653", "0.5742273", "0.5662632", "0.5651707", "0.56499434", "0.55677015", "0.5546776", "0.55031997", "0.54978436", "0.54933244", "0.5492756", "0.54902864", "0.5485602", "0.5471204", "0.5457612", "0.5454246", "0.545...
0.7473073
0
Disconnects all current registered signals. To reconnect, signals must be registered again.
def disconnect(self): for signal, models in six.iteritems(self._registry): for model, keys in six.iteritems(models): signal.disconnect(sender=model, weak=False, dispatch_uid=signal) self._registry = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disconnect_signals(self, *args):\n children = self.children()\n Pair.disconnect_signals(self, *args)\n for child in children:\n child.disconnect_signals(*args)", "def unregister_signals(self):\n for _, callback in self.signal_callbacks:\n Signal.unsubscribe(s...
[ "0.7635583", "0.7409263", "0.71576667", "0.70118153", "0.6968156", "0.6782369", "0.6688207", "0.6678641", "0.6602246", "0.6402267", "0.6377517", "0.63748914", "0.63205457", "0.6311291", "0.63096774", "0.63037467", "0.627339", "0.627339", "0.627339", "0.627339", "0.627339", ...
0.8220706
0
Yield raw feature strings from the inputed file paths
def raw_feature_iterator(file_paths): for path in file_paths: with open(path, "r") as fin: for line in fin: yield line
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_feature_files(paths: list[str], **kwargs: Any) -> tuple[list[Feature], list[ScenarioTemplate], list[Step]]:\n features = get_features(paths, **kwargs)\n scenarios = sorted(\n itertools.chain.from_iterable(feature.scenarios.values() for feature in features),\n key=lambda scenario: (sce...
[ "0.6346424", "0.6260554", "0.6087644", "0.60024726", "0.5857876", "0.5802286", "0.579959", "0.57831514", "0.5770136", "0.57632935", "0.57309633", "0.5721869", "0.5705221", "0.56793064", "0.5656468", "0.5652713", "0.56373656", "0.56315863", "0.5627689", "0.5627689", "0.559542"...
0.7716821
0
Vectorize a single sample of raw features and write to a large numpy file
def vectorize(irow, raw_features_string, X_path, y_path, extractor, nrows): raw_features = json.loads(raw_features_string) feature_vector = extractor.process_raw_features(raw_features) y = np.memmap(y_path, dtype=np.float32, mode="r+", shape=nrows) y[irow] = raw_features["label"] X = np.memmap(X_p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vectorize(irow, raw_features_string, X_path, y_path, nrows):\n extractor = PEFeatureExtractor()\n raw_features = json.loads(raw_features_string)\n feature_vector = extractor.process_raw_features(raw_features)\n\n y = np.memmap(y_path, dtype=np.float32, mode=\"r+\", shape=nrows)\n y[irow] = raw_f...
[ "0.62940425", "0.6106697", "0.60896504", "0.5908478", "0.586378", "0.5802398", "0.57704306", "0.5692055", "0.5680772", "0.56781024", "0.5660835", "0.5647756", "0.563185", "0.56275016", "0.5625246", "0.56193984", "0.5572783", "0.5572056", "0.55287766", "0.55282754", "0.5521531...
0.6187531
1
Pass through function for unpacking vectorize arguments
def vectorize_unpack(args): return vectorize(*args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_vector_b(args):\n\treturn [f(arg) for arg in args]", "def vectorize_inputs(f):\n return lambda args: f(*np.hsplit(args, args.shape[1]))", "def vectorize_method(func):\n @wraps(func)\n def inner(obj, *iargs, **ikwargs):\n\n def functionalized_method(*args, **kwargs):\n return ...
[ "0.6970474", "0.6857698", "0.64146477", "0.62835205", "0.62835205", "0.6027144", "0.5954756", "0.59166986", "0.5904902", "0.5775839", "0.5764978", "0.5747971", "0.5725748", "0.5675826", "0.5659955", "0.5659955", "0.5634167", "0.5625573", "0.5567981", "0.551946", "0.5516323", ...
0.8652428
0
Create feature vectors from raw features and write them to disk
def create_vectorized_features(data_dir, feature_version=2): extractor = PEFeatureExtractor(feature_version) print("Vectorizing training set") X_path = os.path.join(data_dir, "X_train.dat") y_path = os.path.join(data_dir, "y_train.dat") raw_feature_paths = [os.path.join(data_dir, "train_features_{}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creating_feature_vector():\r\n\twordlist = []\r\n\tlabel = \"\"\r\n\tfw = open(\"feature_vector.txt\", \"w+\", encoding = \"utf-8\")\r\n\twith open(\"D:\\\\Python_Prac\\\\wordstag\\\\modules\\\\HI_EN_TRAIN.txt\", \"r\", encoding = \"utf-8\") as f:\r\n\t\tfor line in f:\r\n\t\t\twordlist.append(line)\r\n\t\tfor...
[ "0.68451023", "0.6687783", "0.66236377", "0.66236335", "0.6608172", "0.651898", "0.65123", "0.63167775", "0.6315384", "0.63149315", "0.625614", "0.6229033", "0.6199346", "0.6194556", "0.61851686", "0.6167491", "0.6155025", "0.6137881", "0.6135727", "0.61232656", "0.6087816", ...
0.69787437
0
Decode a raw features string and return the metadata fields
def read_metadata_record(raw_features_string): all_data = json.loads(raw_features_string) metadata_keys = {"sha256", "appeared", "label", "avclass"} return {k: all_data[k] for k in all_data.keys() & metadata_keys}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_metadata_record(raw_features_string):\n full_metadata = json.loads(raw_features_string)\n return {\"sha256\": full_metadata[\"sha256\"], \"appeared\": full_metadata[\"appeared\"], \"label\": full_metadata[\"label\"]}", "def decode_data(features, reader_settings):\n if features.dtype == tf.strin...
[ "0.7640253", "0.6727874", "0.6480235", "0.6434632", "0.6149312", "0.61184937", "0.6096524", "0.6088268", "0.60809267", "0.603969", "0.60149556", "0.5988124", "0.5919679", "0.59035814", "0.5876347", "0.5871728", "0.58618104", "0.58504206", "0.58429444", "0.580738", "0.5801658"...
0.73563117
1
Read an already created metadata file and return its dataframe
def read_metadata(data_dir): return pd.read_csv(os.path.join(data_dir, "metadata.csv"), index_col=0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_metadata_file():\n metadata = None\n if not os.path.isfile(META_DATA_FILE):\n ppg.log_info(\"No metadata found. The earthquake splitting might have not been ran yet.\")\n else:\n ppg.log_info(\"Found metadata file\")\n metadata = pd.read_csv(META_DATA_FILE)\n return metada...
[ "0.75550187", "0.73237497", "0.7193487", "0.69972616", "0.69912016", "0.6918955", "0.67753977", "0.6759768", "0.6757957", "0.6754", "0.6751405", "0.6681768", "0.66246736", "0.65975994", "0.6565998", "0.65403295", "0.65184593", "0.65184593", "0.65184593", "0.65133196", "0.6494...
0.7495927
1
Train the LightGBM model from the EMBER dataset from the vectorized features
def train_model(data_dir, params={}, feature_version=2): # update params params.update({"application": "binary"}) # Read data X_train, y_train = read_vectorized_features(data_dir, "train", feature_version) # Filter unlabeled data train_rows = (y_train != -1) # Train lgbm_dataset = lgb...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_lightgbm(x_train, train_labels, x_test, orig_test):\n train_labels = train_labels['Col2']\n num_lgbm_ensemble = 17\n lgb_forests = []\n for i in range(num_lgbm_ensemble):\n print(\"training LGBC model {}\".format(i))\n params = {\n 'n_estimators': 17,\n 'max_depth': 7,\n 'learnin...
[ "0.72763", "0.6727893", "0.65406424", "0.63562286", "0.6320691", "0.6302329", "0.6298004", "0.6286214", "0.62784106", "0.6252643", "0.61828154", "0.6118745", "0.6105687", "0.60919255", "0.6041456", "0.6040824", "0.6040496", "0.6013378", "0.60047317", "0.5980098", "0.5949575",...
0.73816603
0
Predict a PE file with an LightGBM model
def predict_sample(lgbm_model, file_data, feature_version=2): extractor = PEFeatureExtractor(feature_version) features = np.array(extractor.feature_vector(file_data), dtype=np.float32) return lgbm_model.predict([features])[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_sample(lgbm_model, file_data):\n extractor = PEFeatureExtractor()\n features = np.array(extractor.feature_vector(file_data), dtype=np.float32)\n return lgbm_model.predict([features])[0]", "def predict(self, datafile):", "def predict_proba(self):\n ...", "def predict():\n if (no...
[ "0.6942636", "0.66490805", "0.6243864", "0.6220594", "0.619182", "0.6052634", "0.6038517", "0.60092866", "0.5975578", "0.592887", "0.59086394", "0.5866465", "0.5832725", "0.58074164", "0.57809746", "0.5778944", "0.5771282", "0.5757018", "0.5744", "0.5714554", "0.56919616", ...
0.6835541
1
gaussian(centre, k, x, intensity) == (intensity exp((k (x centre))^2))
def gaussian(centre, k, intensity, xpos): return intensity * np.exp(- np.power(k * (xpos - centre), 2))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian_k(x0, y0, sigma, height, width):\n y = np.arange(0, width, 1, float)\n x = np.arange(0, height, 1, float)[:, np.newaxis]\n return np.exp(-((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))", "def gaussian(x, amplitude=1.0, center=0.0, sigma=1.0):\n \n return (amplitude/(np.sqrt(2.*np...
[ "0.75760573", "0.71707886", "0.7004626", "0.69898623", "0.69898623", "0.69898623", "0.69565445", "0.6826124", "0.6816904", "0.6770682", "0.6768502", "0.67603844", "0.6753947", "0.6737203", "0.67277646", "0.672466", "0.66839015", "0.66783154", "0.66724944", "0.6649369", "0.657...
0.87825394
0
Checks if the goal state or start state is in the obstacle area
def obstacle_prone_area(self,image): start_x=int(self.start[0]) start_y=int(self.start[1]) goal_x=int(self.goal[0]) goal_y=int(self.goal[1]) print(goal_x,goal_y) if (image[int(self.maximum_size-goal_x),int(goal_y),0]==0) or ((image[int(self.maximum_size-start_x),i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def goal_occupied(self, view):\n for line in view.obstacles:\n if linesegdist2(line.p1, line.p2, self.goal) < self.radius ** 2:\n return True\n\n for p in view.pedestrians:\n if p.velocity.length2() == 0.0:\n if p.position.distance_to2(self.goal) < ...
[ "0.73806673", "0.7085184", "0.705285", "0.7039204", "0.7030871", "0.691709", "0.6894923", "0.67947966", "0.67904234", "0.6745311", "0.6700286", "0.6694245", "0.6691153", "0.6671266", "0.6661765", "0.66572803", "0.6646301", "0.6644943", "0.66365445", "0.662294", "0.66006845", ...
0.7400996
0
Create all obstacles in the images by calling various obstacle functions
def obstacles_form(self,image): major_axis=60 minor_axis=30 c_y=246 c_x=145 c_y1=90 c_x1=70 radius=35 for i in range(len(image)): for j in range(len(image[0])): #self.ellipse(image,major_axis,minor_axis,i,j,c_x,c_y)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_obstacles_map(obstacles, placed_pecies):\n \n #create a mask image to draw the obstacles on\n blocks = np.zeros(ARENA_SIZE[::-1], np.uint8)\n\n #get the grid points where the robot needs to placed\n grid = get_grid(ARENA_SIZE)\n\n #draw the obstacles and their safety region on the map\n ...
[ "0.7210673", "0.71489096", "0.71302867", "0.7099033", "0.7065752", "0.6955419", "0.68727446", "0.6848929", "0.6677928", "0.6603184", "0.6546827", "0.6510921", "0.64350826", "0.6417596", "0.63998944", "0.63848907", "0.62678915", "0.62417763", "0.61390275", "0.6092278", "0.6092...
0.7757402
0
Checks if the goal is reached or not if reached return True and if not reached continues exploring
def goal_reached(self): pos_0=self.goal[0] pos_1=self.goal[1] #self.start_score=self.string(self.start[0],self.start[1]) #self.data_with_string[self.start_score]=self.start #self.goal_score=self.string(pos_0,pos_1) if self.h(self.current_score[0],self.current_score[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reached_goal(self):\n for i in range(self.simulator_.num_agents):\n if rvo_math.abs_sq(self.simulator_.agents_[i].position_ - self.goals_[i]) > self.simulator_.agents_[i].radius_ * self.simulator_.agents_[i].radius_:\n return False\n\n return True", "def goal_reached(s...
[ "0.764153", "0.75423175", "0.74891615", "0.73719585", "0.7327295", "0.7301565", "0.7220743", "0.7139437", "0.70832837", "0.7046251", "0.7040974", "0.70182705", "0.6996969", "0.6996969", "0.6945148", "0.69250876", "0.69134796", "0.6900344", "0.6892872", "0.6848054", "0.6762561...
0.7737054
0
This function give points that lies in slanted rectangle.
def slanted_rect(self,image,i,j): s1 = 0.7 s2 = -1.42814 x1 = np.arctan(s1) x2 = np.arctan(s2) d1 = np.cos(np.pi - x1) d2 = np.cos(np.pi - x2) a = -(self.padding/d1) b = -(self.padding/d2) if (-0.7*j+1*i)>=(73.4 - a) and (i+1.42814*j)>=(17...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triPoints(rect, orientation): \r\n p1 = (rect.center[0]+orientation[0]*rect.size[0]/3.,\r\n rect.center[1]+orientation[1]*rect.size[1]/3.)\r\n p2 = (rect.center[0]-orientation[0]*rect.size[0]/4.,\r\n rect.center[1]-orientation[1]*rect.size[1]/4.)\r\n orthdir = (orientation[1], -or...
[ "0.62138176", "0.58339304", "0.58308536", "0.5803912", "0.5787294", "0.57711476", "0.5743119", "0.57425475", "0.57074183", "0.56752676", "0.56694865", "0.5656441", "0.5636366", "0.5605589", "0.5577327", "0.5554112", "0.55472916", "0.5546715", "0.5545921", "0.5541117", "0.5533...
0.62317324
0
Interrupt handler allows suspension via SIGHUP and resumption via SIGCONT; and termination via SIGABRT, SIGINT, and/or preferably SIGTERM.
def sighandler(signum, frame): global _terminate global _interruptcnt print >> FileKeyUtils.WMSlog, 'sighandler> ', signum ++_interruptcnt if signum in(signal.SIGABRT, signal.SIGINT, signal.SIGTERM): print >> FileKeyUtils.WMSlog, 'sighandler> terminate pid: ', os.getpid(), signum _terminate = True ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_interrupt(self, *args) -> None: #pylint: disable=unused-argument\r\n if not self.stop_requested:\r\n self.stop_requested = True\r\n self.logger.critical('SIGINT detected - will stop at the end of the current evolution')\r\n else:\r\n stop_from = time.time() - 5...
[ "0.6873077", "0.6834924", "0.6801791", "0.6721506", "0.6706197", "0.6688984", "0.66876125", "0.6626961", "0.6563405", "0.6527134", "0.6487581", "0.648722", "0.6463762", "0.6410054", "0.63769895", "0.63597256", "0.63591284", "0.63388664", "0.6319095", "0.6309224", "0.62986", ...
0.7475745
0
Uses os.system() to pkill and then invokes the Apache httpd with the specified
def restartHTTPd(htconf): parentpid = pidHTTPd(htconf) if parentpid <= 1: return # hopefulle killing the parent proc. will do the trick print >> FileKeyUtils.WMSlog, 'restartHTTPd> kill parentpid:', parentpid os.system('kill -TERM '+repr(parentpid)) apache = '/devstore/apache2/bin/httpd -f /devstore/apach...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kill_process(self,PID):\n os.system(\"sudo kill {}\".format(PID))\n return True", "def webserver_stop():\n run(\"kill $(cat %s)\" % GUNICORN_PIDFILE)\n run(\"rm %s\" % GUNICORN_PIDFILE)", "def remote_kill():", "def webserver_restart():\n try:\n run(\"kill -HUP $(cat %s)\" % ...
[ "0.6258043", "0.6232436", "0.62181044", "0.60765", "0.60613805", "0.5952444", "0.5894394", "0.58898026", "0.58821464", "0.579318", "0.5760136", "0.5709812", "0.5701586", "0.5648284", "0.5647017", "0.56396043", "0.5619126", "0.5600666", "0.55770516", "0.5537543", "0.552522", ...
0.7323256
0
Printout global _modinfo text, followed by module help().
def printInfoDoc(): global _modinfo print _modinfo help("ProcUtils")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_help():\n print(sys.modules[__name__].__doc__)", "def module_info():\n pass", "def info():\n print(\"\"\"\n Module for use in WMDframe. Just an interaction with the git\n repo changeme by ztgrace.\n\n \"Getting default credentials added to commercial scanners is\n ...
[ "0.73787487", "0.7280849", "0.72768086", "0.7214288", "0.70121974", "0.6946926", "0.6916308", "0.68961084", "0.6881714", "0.6879395", "0.67717725", "0.67190427", "0.6707886", "0.6603345", "0.6558752", "0.6526451", "0.652423", "0.6444417", "0.64231575", "0.6407718", "0.6405413...
0.82748777
0
Symbolically calculates the generating polynomial for a lagrange polynomial of a given order. Our HyperCube elements use N + 1 Lagrange polynomials of order N for the spatial discretisation. This function returns N + 1 generating polynomials, which can be used to calculate the value of a Lagrange polynomial at an arbit...
def generating_polynomial_lagrange(N, coordinate, gll_points): # Symbols. coord, phi, d_phi = sym.symbols('{} Phi dPhi'.format(coordinate)) # Equation A.19 phi = 1 for x in gll_points: phi *= (coord - x) # Get derivative in coordinate direction d_phi = sym.diff(phi, coord) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lagrange_poly(x, xp, fp):\n\n f = 0.0\n \n # sum over points\n m = 0\n while (m < len(xp)):\n\n # create the Lagrange basis polynomial for point m \n l = None\n\n n = 0\n while (n < len(xp)):\n if n == m:\n n += 1\n cont...
[ "0.67642653", "0.65641516", "0.6269907", "0.6085851", "0.59619576", "0.5891837", "0.5783319", "0.5757106", "0.5720937", "0.56095165", "0.5596212", "0.5561844", "0.5558487", "0.5481505", "0.54707587", "0.5437779", "0.54326445", "0.53526294", "0.53392595", "0.5330124", "0.53080...
0.7209638
0
Loads the given json schema file
def load_json_schema(filename): relative_path = join('../schema', filename) absolute_path = join(dirname(__file__), relative_path) base_path = dirname(absolute_path) base_uri = 'file://{}/'.format(base_path) with open(absolute_path) as schema_file: return jsonref.loads( schema_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_json_schema(filename):\n\n relative_path = join('schemas', filename)\n absolute_path = join(dirname(__file__), relative_path)\n\n with open(absolute_path) as schema_file:\n return json.loads(schema_file.read())", "def _load_json_schema(filename: str):\n relative_path = path.join('sch...
[ "0.84585667", "0.8389199", "0.83260584", "0.8293592", "0.77692807", "0.7753466", "0.75813144", "0.7514916", "0.7409711", "0.7408482", "0.7398229", "0.7358662", "0.7209835", "0.71893764", "0.708138", "0.70652896", "0.69564265", "0.69377166", "0.68508154", "0.6835237", "0.68270...
0.839412
1