query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns a step dictionary which is compatible with annotator.py.
def __call__(self, name, cmd, ok_ret=None, infra_step=False, wrapper=(), timeout=None, allow_subannotations=None, trigger_specs=None, stdout=None, stderr=None, stdin=None, step_test_data=None): # Calculate our full step name. If a step already has that name, add an # index to the end of it. # # Note that another step could exist with that index already added to it # by the user. If this happens, we'll continue appending indexes until we # have a unique step name. with self.m.context(name_prefix=name): base_name = self.m.context.name_prefix name_suffix = '' while True: full_name = base_name + name_suffix if full_name not in self._seen_steps: break step_count = self._step_names.setdefault(full_name, 1) + 1 self._step_names[full_name] = step_count name_suffix = ' (%d)' % step_count self._seen_steps.add(full_name) assert isinstance(cmd, (types.NoneType, list)) if cmd is not None: cmd = list(wrapper) + cmd for x in cmd: if not isinstance(x, (int, long, basestring, Path, Placeholder)): raise AssertionError('Type %s is not permitted. ' 'cmd is %r' % (type(x), cmd)) cwd = self.m.context.cwd if cwd and cwd == self.m.path['start_dir']: cwd = None with self.m.context(env_prefixes={'PATH': self._prefix_path}): env_prefixes = self.m.context.env_prefixes if ok_ret in ('any', 'all'): ok_ret = self.step_client.StepConfig.ALL_OK return self.step_client.run_step(self.step_client.StepConfig( name=full_name, base_name=full_name or name, cmd=cmd, cwd=cwd, env=self.m.context.env, env_prefixes=self.step_client.StepConfig.EnvAffix( mapping=env_prefixes, pathsep=self.m.path.pathsep, ), env_suffixes=self.step_client.StepConfig.EnvAffix( mapping=self.m.context.env_suffixes, pathsep=self.m.path.pathsep, ), allow_subannotations=bool(allow_subannotations), trigger_specs=[self._make_trigger_spec(trig) for trig in (trigger_specs or ())], timeout=timeout, infra_step=self.m.context.infra_step or bool(infra_step), stdout=stdout, stderr=stderr, stdin=stdin, ok_ret=ok_ret, step_test_data=step_test_data, nest_level=self.m.context.nest_level, ))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSteps():", "def generation_step_to_dict(generation_step: GenerationStep) -> Dict[str, Any]:\n return {\n \"__type\": generation_step.__class__.__name__,\n \"model\": generation_step.model,\n \"num_trials\": generation_step.num_trials,\n \"min_trials_observed\": generation_st...
[ "0.69314784", "0.66943085", "0.6273986", "0.61101913", "0.60612357", "0.60612357", "0.6031463", "0.6012955", "0.59872484", "0.5910651", "0.58814424", "0.58362293", "0.58362293", "0.58136266", "0.57853806", "0.5746236", "0.57229125", "0.5714291", "0.57003534", "0.56915283", "0...
0.0
-1
Delete or drop table
def _delete_table(self, db, table_name): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_table(self, name: str) -> None:", "def drop_table(cls)->None:\n database.cursor.execute(\n \"DROP TABLE IF EXISTS {}\".format(cls.table_name))\n database.connection.commit()", "def deleteTable(self):\n return self.db.table_drop(self.entity).run(self.r)", "def sqlite...
[ "0.81365436", "0.80147094", "0.8011938", "0.785006", "0.7730077", "0.7719094", "0.77065164", "0.76392746", "0.7639245", "0.7558649", "0.75291914", "0.7528163", "0.7518751", "0.75040466", "0.7492301", "0.7477169", "0.7466884", "0.7411313", "0.7407684", "0.73777705", "0.7354117...
0.7943311
3
Insert single row into a table
def _insert_table_row(self, db: str, table: str, row: Dict[str, Any]): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_row(self, table: str, row_data: dict):\r\n\r\n columns = \"\".join([f\"'{i}',\" for i in row_data]).rstrip(\",\")\r\n keys = \"\".join([f\"'{row_data[i]}',\" for i in row_data]).rstrip(\",\")\r\n sql_statement = f\"INSERT INTO {table} ({columns}) VALUES({keys});\"\r\n try:\r\...
[ "0.7340923", "0.7256007", "0.7239077", "0.7177126", "0.71218693", "0.70833904", "0.7065664", "0.69191945", "0.68331724", "0.682139", "0.68028295", "0.67609316", "0.6746725", "0.6736111", "0.673245", "0.6703915", "0.6692947", "0.6680959", "0.66731584", "0.6654706", "0.6627586"...
0.7353583
0
select data from a table (select from db.table where column_filers ...)
def _select_data( self, db: str, table: str, column_filters: Dict[str, str] ) -> List[List]: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data(db, columns, table, condition=\"\"):\n cur = db.cursor()\n cur.execute(SELECT.format(columns, table) + \" \" + condition)\n return cur.fetchall()", "def select_db(table, cond):\n query = \"SELECT * FROM \" + table + \" WHERE \" + cond\n cursor.execute(query)\n records = cursor.fetc...
[ "0.7451726", "0.7248107", "0.69168055", "0.69079506", "0.68438905", "0.6825986", "0.6800241", "0.6792302", "0.6681862", "0.6657107", "0.66489816", "0.6637284", "0.66219336", "0.66154295", "0.654893", "0.6454015", "0.641332", "0.6410601", "0.63980806", "0.63969445", "0.6383279...
0.6876609
4
Return DB API Connection
def _db_connection(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_connection(self):\n\n\t\treturn dbapi.connect(credentials.SERVER,\\\n\t\t\t\t\t\t\t credentials.PORT,\\\n\t\t\t\t\t\t\t credentials.USER,\\\n\t\t\t\t\t\t\t credentials.PASSWORD)", "def get_dbapi20_connection ():\n return cherrypy.engine.pool.connect ()", "def get_connection():\n con = psy...
[ "0.8348434", "0.82954013", "0.78892154", "0.7847629", "0.77854586", "0.7766536", "0.7627953", "0.75845844", "0.75740683", "0.7564091", "0.7547969", "0.7504719", "0.7473917", "0.7430099", "0.7425724", "0.74137056", "0.74033695", "0.7394597", "0.73863715", "0.73794466", "0.7379...
0.74661154
13
Converts a tuple to its string representation. Uses different separators (;, /, |) for different depths of the representation.
def tuple_to_string(tuptup): def join_deepest(tup, sep=';'): """ Recursive function to create the string representation for the deepest level of the tuptup list. Parameters ---------- tup : object Element to join if list or list of lists. sep : str, optional Separation character to join the list elements by. Returns ------- object List containing joined string in max depth. Str if input depth = 1. """ if not isinstance(tup, list): return tup if not isinstance(tup[0], list): return sep.join(tup) for idx, val in enumerate(tup): tup[idx] = join_deepest(val, sep) return tup tup = copy.deepcopy(tuptup) tup = join_deepest(tup, ';') tup = join_deepest(tup, '/') tup = join_deepest(tup, '|') return tup
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _tupstr(tuple_):\n return ', '.join(list(map(str, tuple_)))", "def _tuple_to_str(self, the_tuple):\r\n ret = \"\"\r\n for item in the_tuple:\r\n ret += (\" \" + str(item))\r\n return ret[1:]", "def tupleStrFormat(tupl):\n string = \"this is a tuple (\"\n for element...
[ "0.80097777", "0.77167994", "0.7229197", "0.72018117", "0.7117311", "0.707209", "0.70130855", "0.70075023", "0.6833385", "0.6807723", "0.67460287", "0.6742025", "0.6638861", "0.66135544", "0.6548663", "0.64345735", "0.6370722", "0.63114953", "0.6277102", "0.627624", "0.625884...
0.74598444
2
Recursive function to create the string representation for the deepest level of the tuptup list.
def join_deepest(tup, sep=';'): if not isinstance(tup, list): return tup if not isinstance(tup[0], list): return sep.join(tup) for idx, val in enumerate(tup): tup[idx] = join_deepest(val, sep) return tup
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tree_str(self, depth: int = 0) -> str:\n temp = \" \" * depth + str(self.head) + \"\\n\"\n for son in self.sons:\n temp += son.get_tree_str(depth + 1)\n return temp", "def tuple_to_string(tuptup):\n\n def join_deepest(tup, sep=';'):\n \"\"\" Recursive function to...
[ "0.6911783", "0.6560992", "0.64162666", "0.64148694", "0.63143986", "0.6257376", "0.6203628", "0.6170759", "0.6084149", "0.60680145", "0.60680145", "0.6012516", "0.60102165", "0.60009885", "0.59931505", "0.59649897", "0.59439313", "0.59319067", "0.5925515", "0.5863372", "0.58...
0.0
-1
Compares two response objects based on equality.
def compare(obj_a, obj_b): return tuple_to_string(obj_a) == tuple_to_string(obj_b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if not isinstance(other, Response):\n return False\n\n return self.__dict__ == other.__dict__", "def __eq__(self, other):\n if not isinstance(other, InlineResponse200):\n return False\n\n return self.to_dict() == other.to_dict()", "de...
[ "0.7743906", "0.7587754", "0.7484174", "0.7346719", "0.73336023", "0.73172593", "0.7316397", "0.7289357", "0.72549665", "0.724851", "0.72303915", "0.722987", "0.7205563", "0.7172449", "0.71693856", "0.7155242", "0.7135397", "0.7128382", "0.71163017", "0.71147203", "0.71114576...
0.0
-1
Compares two response objects based on their NVCness. Only returns true if both responses are in agreement with either responding NVC or not NVC.
def compare(obj_a, obj_b): return (tuple_to_string(obj_a) == 'NVC') == (tuple_to_string(obj_b) == 'NVC')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_vn_in_api_server(self):\n self.api_verification_flag = True\n self.api_s_vn_obj = self.api_s_inspect.get_cs_vn(\n domain=self.domain_name, project=self.project_name,\n vn=self.vn_name, refresh=True)\n if not self.api_s_vn_obj:\n self.logger.debug(\"V...
[ "0.57760257", "0.57723004", "0.57442796", "0.5704212", "0.5581943", "0.55500567", "0.5549865", "0.55349195", "0.55025715", "0.54922974", "0.544647", "0.5440523", "0.54150635", "0.5412424", "0.5370746", "0.5357937", "0.535282", "0.5340017", "0.53387195", "0.5306857", "0.529481...
0.6934954
0
Parse script input arguments.
def parse_arguments(): arguments_parser = argparse.ArgumentParser() arguments_parser.add_argument('--libvirt', help='Using KVM-libvirt as VM provider', action="store_true") arguments_parser.add_argument('--virtualbox', help='Using KVM as VM provider', action="store_true") arguments_parser.add_argument('-i', '--img', required=True, action='store', dest='vm_image', help='Vagrant VM image') arguments_parser.add_argument('-m', '--memory', required=True, action='store', dest='vm_memory', help='VM box memory size') arguments_parser.add_argument('-c', '--cpu', required=True, action='store', dest='vm_cpu', help='VM box CPU count') arguments_parser.add_argument('-n', '--node', required=True, action='store', dest='vm_node', help='VM box nodes count') arguments_parser.add_argument('-p', '--netprefix', required=True, action='store', dest='vm_netprefix', help='VM box network prefix ex: 10.10.0') arguments_parser.add_argument('-e', '--exec', action='store', dest='exec_path', help='VM box init path') arguments = arguments_parser.parse_args() return arguments
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def parse_arguments():\n # shift away script name\n scriptname=sys.argv[0]\n shift()\n ncl_cmd=list()\n quali_cmd=list()\n id_cmd=list() \n while(len(sys.argv)>0):\n carg = sys.argv[0]\n shift()\n if(carg == \"--nucleotide\"):\n n...
[ "0.79977995", "0.7492374", "0.74865186", "0.74785024", "0.73592305", "0.72400653", "0.71956307", "0.7175748", "0.7048367", "0.70400876", "0.70262593", "0.7005223", "0.6989726", "0.69382596", "0.6925051", "0.69050217", "0.69037956", "0.68907475", "0.6834261", "0.68291724", "0....
0.0
-1
Returns the html of url or None if status code is not 200
def get_html(url): req = urllib.request.Request( url, headers={ 'User-Agent': 'Python Learning Program', 'From': 'hklee310@gmail.com' } ) resp = urllib.request.urlopen(req) if resp.code == 200: return resp.read() # returns the html document else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simple_get(self, url):\r\n \"\"\"\r\n The simple_get function accepts a single url argument. \r\n It then makes a GET request to that url. \r\n If nothing goes wrong, you end up with the raw HTML content for the page you requested. \r\n If there were any problems with your re...
[ "0.73372376", "0.6996886", "0.6942967", "0.69052494", "0.6894238", "0.6819237", "0.68131924", "0.68110603", "0.68110603", "0.68110603", "0.6805156", "0.6804368", "0.6774557", "0.67645854", "0.67645854", "0.67632246", "0.6751196", "0.6743401", "0.67430574", "0.6718777", "0.671...
0.6987104
2
Decodes char byte array to string.
def decode_to_string(self, value): #if python3 or python 2.7 ret = bytearray(value).decode(encoding='UTF-8') #if python2.7 #ret = str(bytearray(value)) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_bytes(data: bytearray) -> str:\n pattern = re.compile('\\r', re.UNICODE)\n res = data.decode('utf-8', 'ignore')\n res = pattern.sub('', res)\n return res", "def _bytes_bytearray_to_str(s):\n if isinstance(s, (bytes, bytearray)):\n return s.decode()\n return s", "def bytes_to...
[ "0.7620947", "0.7159157", "0.6875555", "0.6810529", "0.6642219", "0.65613323", "0.6543301", "0.6531421", "0.6475144", "0.6392671", "0.639041", "0.639041", "0.6374796", "0.6297807", "0.62701327", "0.6170347", "0.616709", "0.61501384", "0.6131751", "0.6120125", "0.60999626", ...
0.69120693
2
Runs main gobject loop.
def run_main_loop(): mainloop = GObject.MainLoop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loop( self ):\n import gtk\n while self.count >= 1:\n log.debug( 'GTK loop restarting' )\n while gtk.events_pending():\n gtk.main_iteration()\n log.debug( 'GTK loop exiting' )\n try:\n del self.t_loop\n except AttributeError, er...
[ "0.760594", "0.7460419", "0.72110164", "0.7099442", "0.7034407", "0.691706", "0.6902692", "0.68630695", "0.6785323", "0.67737657", "0.6773619", "0.6746319", "0.6662695", "0.66581476", "0.66040593", "0.6601622", "0.65761584", "0.6574493", "0.65733767", "0.6544273", "0.65289533...
0.8040331
0
Initialie dbus system bus acquire adapter/interface for org.bluez.GattManager1 register application for 'org.bluez.GattService1'
def __init__(self): dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) self.bus = dbus.SystemBus() self.adapter = self._find_adapter() if not self.adapter: IFaceNotFoundException('%s interface not found' % GATT_MANAGER_IFACE) self.service_manager = dbus.Interface( self.bus.get_object(BLUEZ_SERVICE_NAME, self.adapter), GATT_MANAGER_IFACE) self.mainloop = GObject.MainLoop() self.ctx = GattContext(self.bus, self.mainloop) self.app = Application(self.ctx) #print('Registering GATT application...') self.service_manager.RegisterApplication(self.app.get_path(), {}, reply_handler=register_app_cb, error_handler=register_app_error_cb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, alias, adapter=None):\n\n dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n\n self.bus = dbus.SystemBus()\n\n if not adapter:\n adapter = self._find_adapter()\n if not adapter:\n logger.error(\"Could not find any adapter implementin...
[ "0.7221227", "0.61894155", "0.6014742", "0.59280574", "0.5923623", "0.57182866", "0.57111996", "0.56961524", "0.56900334", "0.56577533", "0.5630222", "0.5583196", "0.5564716", "0.5501188", "0.54448515", "0.54448307", "0.5401305", "0.5356949", "0.5353707", "0.5304931", "0.5298...
0.77838093
0
Adds service to previously initialize app.
def add_service(self, service): self.app.add_service(service)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addService(self, service):\n\t\tself.services.append(service)\n\t\treturn self", "def add(self, service: AbstractService):\n self.services.append(service)", "def initService(self):", "def add_app(self):\n \n pass", "def add_service(self, zeroconf, service_type, name):\n self...
[ "0.70407766", "0.6967143", "0.6634693", "0.6463807", "0.6374438", "0.628673", "0.62649804", "0.6252654", "0.62386537", "0.62090975", "0.61053437", "0.6091435", "0.605257", "0.6042793", "0.60172504", "0.599833", "0.599623", "0.59924555", "0.5940163", "0.58883333", "0.5873045",...
0.8112667
0
Return today's date (UTC) formatted as YYYYMMDD.
def _today() -> str: return strftime(DATE_FORMAT, gmtime())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date_today() -> str:\n return datetime.now().strftime(\"%Y-%m-%d\")", "def today():\n today_object = datetime.utcnow()\n today_string = today_object.strftime('%m/%d/%Y')\n return today_string", "def utc_today_str():\n return datetime.datetime.strftime(datetime.datetime.utcnow(), \"%Y...
[ "0.8165175", "0.77760684", "0.77601326", "0.77202994", "0.76923996", "0.7595528", "0.7585238", "0.7497268", "0.7361167", "0.7340656", "0.73232466", "0.7306702", "0.72497416", "0.7205314", "0.71836877", "0.71293193", "0.7124812", "0.70916235", "0.7083198", "0.7062737", "0.7011...
0.7295072
12
Return the date (UTC) from 10 days ago formatted as YYYYMMDD.
def _ten_days_ago() -> str: ten_days_ago = gmtime(mktime(gmtime()) - TEN_DAYS_SECONDS) return strftime(DATE_FORMAT, ten_days_ago)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ago(self):\n return human(self.timestamp/1000.0, precision=1, abbreviate=True)", "def relativeTime(date):\n diff = datetime.utcnow() - date\n\n if diff.days > 7 or diff.days < 0:\n return date.ctime()\n elif diff.days == 1:\n return '1 day ago'\n elif diff.days > 1:\n return '%d days ago'...
[ "0.63436246", "0.6039876", "0.5983086", "0.5962784", "0.58728963", "0.581312", "0.58069855", "0.5791033", "0.5787348", "0.5763219", "0.56588507", "0.5579537", "0.5577654", "0.55374175", "0.5471164", "0.539841", "0.53682923", "0.5352607", "0.53389454", "0.53330094", "0.5331382...
0.7581562
0
Return the last month (UTC) formatted as YYYYMM.
def _last_month() -> str: time_now = gmtime() return ( f"{time_now.tm_year}-{time_now.tm_mon - 1:02d}" if time_now.tm_mon > 1 else f"{time_now.tm_year - 1}-12" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_month_day():\r\n return (datetime.now().replace(day=1) + relativedelta(months=1) + timedelta(days=-1)).strftime(\r\n '%d-%m-%Y')", "def make_last_month_period(dt=None):\n if not dt:\n dt = datetime.utcnow()\n dt = dt.replace(day=1) - timedelta(days=1)\n return dt.strftime('%Y%m...
[ "0.7890911", "0.77757496", "0.7772196", "0.74962604", "0.7192194", "0.6839517", "0.6807995", "0.6761683", "0.6746424", "0.6616606", "0.66151744", "0.6588002", "0.6588002", "0.6579385", "0.6565151", "0.65579987", "0.65383244", "0.64961576", "0.6473222", "0.64433897", "0.639331...
0.8435946
0
Retrieve the ECB exchange rate data based on the arguments provided.
def _get_ecb_data(frequency: str, start: str, end: str) -> bytes: content = bytearray() query_url = urljoin(ECB_DATA_API, ECB_EXR_GBP_EUR.format(frequency)) query_url = urljoin(query_url, ECB_QUERY_PARAMS.format(start, end)) with requests.get(query_url) as response: response.raise_for_status() # The data we're requesting is relatively small so we can just read it # one chunk; to do that we'll set the chunk size to something bigger # than the data we're reading. Based on some trial and error, it looks # like 3 KBytes is the right number. for chunk in response.iter_content(chunk_size=1024 * 3): # 3 KBytes content.extend(chunk) return bytes(content)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_exchange_rate_data(self, source_currency, exchanged_currency, valuation_date):\n raise NotImplementedError", "def getData(self):\n\n url = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.zip'\n try:\n file, _ = urlretrieve(url)\n zip_file_object = zipf...
[ "0.6843077", "0.67887974", "0.6766991", "0.67545015", "0.6378838", "0.6367499", "0.62257475", "0.619634", "0.6012515", "0.5951624", "0.57854265", "0.5767857", "0.57583064", "0.5754834", "0.57475054", "0.57261825", "0.5651264", "0.5597155", "0.557165", "0.5563183", "0.5555224"...
0.58530164
10
Retrieve the latest exchange rate from the given ECB data.
def _get_latest_ecb_rate(data: bytes) -> float: root = etree.fromstring(data) values = root.xpath('.//generic:ObsValue/@value', namespaces=root.nsmap) last_value = len(values) - 1 return float(values[last_value])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_and_store_latest_ecb_exrates():\n response = requests.get(DAILY_ECB_URL)\n # Raise exception if status_code != 200 or ConnectionError\n response.raise_for_status()\n info = ET.fromstring(response.content)[2][0]\n datestamp = datetime.strptime(info.attrib['time'], \"%Y-%m-%d\").date()\n ...
[ "0.7017314", "0.6967795", "0.6684886", "0.6548335", "0.65449774", "0.65055674", "0.6461167", "0.6431432", "0.64266616", "0.6394351", "0.62385744", "0.62312907", "0.62306887", "0.62064004", "0.61375725", "0.6130839", "0.6130635", "0.6115328", "0.60870564", "0.6060977", "0.5914...
0.759938
0
Retrieve and store the 15min delayed BTC market price in EUR.
def _get_btc_eur_15min(self) -> None: with requests.get(BITCOIN_TICKER) as response: response.raise_for_status() json_data = response.json() self.btc_eur_15min = json_data["EUR"]["15m"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getprice():\n\n print(\"Get price\")\n latest_price = get_latest_price(item_code)\n return latest_price", "def do_work(self) -> None:\n self._get_btc_eur_15min()\n print(\n f\"1 BTC = {self.btc_eur_15min} EUR\"\n f\"\\t\\t(15min delayed market price)\"\n )\...
[ "0.65415394", "0.6299414", "0.62688947", "0.6254417", "0.62187046", "0.6205762", "0.620122", "0.61773175", "0.61718124", "0.6161998", "0.6105141", "0.60968745", "0.6074585", "0.6072953", "0.601132", "0.5992859", "0.5969653", "0.5964009", "0.5900362", "0.5885169", "0.586665", ...
0.70017016
0
Retrieve and store last month's EUR to GBP average rate.
def _get_eur_gbp_last_month(self) -> None: last_month = _last_month() data = _get_ecb_data(FREQUENCY_MONTHLY, last_month, last_month) self.eur_gbp_last_month = _get_latest_ecb_rate(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_eur_gbp_last_daily(self) -> None:\n data = _get_ecb_data(FREQUENCY_DAILY, _ten_days_ago(), _today())\n\n self.eur_gbp_last_day = _get_latest_ecb_rate(data)", "def get_avg(self):\r\n df = pd.read_csv(\"MonthlyRate.csv\")\r\n df = df[df.CurrencyCode == self.choice]\r\n m...
[ "0.65970474", "0.6344092", "0.5897189", "0.5880332", "0.58152103", "0.5769175", "0.57214457", "0.5711045", "0.55768675", "0.5523535", "0.5501505", "0.5479372", "0.5457628", "0.54402447", "0.542044", "0.5388946", "0.5384516", "0.5383942", "0.53801686", "0.53687716", "0.5363499...
0.7096632
0
Retrieve and store the latest daily EUR to GBP average rate.
def _get_eur_gbp_last_daily(self) -> None: data = _get_ecb_data(FREQUENCY_DAILY, _ten_days_ago(), _today()) self.eur_gbp_last_day = _get_latest_ecb_rate(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bitcoinaverage(site):\n url = \"https://apiv2.bitcoinaverage.com/frontend/constants/exchangerates/local\"\n try:\n session = requests.Session()\n cfscrape_requests = cfscrape.create_scraper(sess=session)\n ret = cfscrape_requests.get(url, timeout=(15, 15)).json()[\"rates\"]\n ...
[ "0.65365905", "0.62230974", "0.61657596", "0.6133238", "0.60252744", "0.5859477", "0.58187735", "0.58073163", "0.5803112", "0.5690306", "0.56884164", "0.56819123", "0.56722516", "0.5655974", "0.56529254", "0.56445503", "0.5622465", "0.5596036", "0.559005", "0.5584927", "0.558...
0.714428
0
Calculate the 15min delayed BTC market price in GBP.
def _get_btc_gbp_15min(self) -> None: self._get_eur_gbp_last_daily() self.btc_gbp_15min = self.btc_eur_15min * self.eur_gbp_last_day
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_work(self) -> None:\n self._get_btc_eur_15min()\n print(\n f\"1 BTC = {self.btc_eur_15min} EUR\"\n f\"\\t\\t(15min delayed market price)\"\n )\n\n self._get_eur_gbp_last_month()\n print(\n f\"1 EUR = {self.eur_gbp_last_month} GBP\"\n ...
[ "0.6735869", "0.6266725", "0.61613244", "0.6135455", "0.6012119", "0.5998848", "0.5924012", "0.5846881", "0.58299065", "0.58050394", "0.5770253", "0.5769695", "0.576529", "0.5724111", "0.57105625", "0.5661389", "0.563068", "0.56113887", "0.560933", "0.5585725", "0.5583436", ...
0.7985306
0
Retrieve and display the data requested in the requirements.
def do_work(self) -> None: self._get_btc_eur_15min() print( f"1 BTC = {self.btc_eur_15min} EUR" f"\t\t(15min delayed market price)" ) self._get_eur_gbp_last_month() print( f"1 EUR = {self.eur_gbp_last_month} GBP" f"\t(last month average rate)" ) self._get_btc_gbp_15min() print( f"1 BTC = {self.btc_gbp_15min:.6f} GBP" f"\t(BTC 15min delayed market price; GBP latest daily average rate)" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_required():\n return display_required()", "def _get_information(self):\n pass", "def get_details(self):", "def get_data():\n pass", "def get_entry(name, req, form):\n entry = {'requirement': name, 'form': form}\n form.initial['credits_needed'] = 0\n ...
[ "0.6163567", "0.60463357", "0.6041842", "0.59421384", "0.59399956", "0.58859646", "0.58683854", "0.5867265", "0.5864334", "0.5829533", "0.57291526", "0.57291526", "0.57073796", "0.5669223", "0.5638486", "0.5616218", "0.560131", "0.55974495", "0.5584069", "0.5578408", "0.55744...
0.0
-1
Instantiate and run the worker.
def main() -> None: worker = Worker() worker.do_work()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_and_run_worker(self):\n\n # Run processing on QThread worker - prevents GUI lock up\n # Create processing object, map control data\n processing_hub = ProcessingHub(control=self.control)\n\n # Create worker thread, connect signals to methods in this class and start, which call...
[ "0.7279886", "0.7101314", "0.70331264", "0.7012368", "0.70091134", "0.69631004", "0.6924996", "0.68743694", "0.6871539", "0.6871292", "0.68372667", "0.6789902", "0.67830294", "0.6669269", "0.6668853", "0.6661168", "0.6640133", "0.6624162", "0.6593175", "0.6540589", "0.6489322...
0.7226993
1
Return the cosmology that is being used
def get_cosmology(cosmology=conf.cosmology): if cosmology.lower() not in available_cosmologies: raise ValueError( "Unrecognised cosmology {}. Available cosmologies are {}".format( cosmology, ", ".join(available_cosmologies) ) ) elif cosmology.lower() in _astropy_cosmologies: ind = [ num for num, name in enumerate(_astropy_cosmologies) if name == cosmology.lower() ][0] return getattr(cosmo, list(parameters.available)[ind]) elif cosmology.lower() == "planck15_lal": return Planck15_lal_cosmology() elif "_with_riess2019_h0" in cosmology.lower(): base_cosmology = cosmology.lower().split("_with_riess2019_h0")[0] return Riess2019_H0_cosmology(base_cosmology)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_cos_dscp(self):\n return self.__cos_dscp", "def set_cosmology(self, cosmo):\n self.cosmo = cosmo\n self.h70 = cosmo['h'] # Hubble parameter, H0 = 100h km/s/Mpc\n self.Om = cosmo['omega_M_0'] # Omega_matter\n self.Ol = cosmo['omega_lambda_0'] # Omega_Lambda", "def _get_co...
[ "0.6441433", "0.64167005", "0.6164821", "0.6161581", "0.6125467", "0.60074854", "0.59982276", "0.5963294", "0.5915752", "0.58894485", "0.5884741", "0.57696545", "0.5693378", "0.5673406", "0.5641914", "0.56051314", "0.56012136", "0.55621797", "0.55592734", "0.55408865", "0.547...
0.7251539
0
Return the Planck15 cosmology coded up in lalsuite
def Planck15_lal_cosmology(): return cosmo.LambdaCDM(H0=67.90, Om0=0.3065, Ode0=0.6935)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cie_lab(self):\n K = Fraction(1, 3) * Fraction(29, 6) ** 2\n e = Fraction(6, 29) ** 3\n x, y, z = (n / m for n, m in zip(self.cie_xyz, D65))\n fx, fy, fz = (\n n ** Fraction(1, 3) if n > e else K * n + Fraction(4, 29)\n for n in (x, y, z)\n )\n ...
[ "0.55920184", "0.549476", "0.54696536", "0.54056984", "0.53960073", "0.5380349", "0.53594655", "0.53576845", "0.53418833", "0.53027004", "0.5290028", "0.5287675", "0.5284653", "0.52330744", "0.51322997", "0.50801104", "0.5078625", "0.50296295", "0.50066954", "0.5004581", "0.4...
0.70417845
0
Return the base cosmology but with the Riess2019 H0 value. For details
def Riess2019_H0_cosmology(base_cosmology): _base_cosmology = get_cosmology(base_cosmology) return cosmo.LambdaCDM( H0=74.03, Om0=_base_cosmology.Om0, Ode0=_base_cosmology.Ode0 )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sound_horizon_EH(self):\n om_m = self.omega_cb\n om_b = self.omega_b\n om_n = np.sum(self.omega_nu)\n h = self.h \n if self.M_nu_tot == 0.: rs = 44.5*np.log(9.83/om_m)/np.sqrt(1+10*om_b**0.75)*h\n else: rs = 55.154*np.exp(-72.3*(om_n+0.0006)*...
[ "0.6274564", "0.6107101", "0.60727805", "0.58837694", "0.5814193", "0.5814193", "0.56165946", "0.55797195", "0.5553944", "0.5534817", "0.553009", "0.55183256", "0.5515757", "0.5511963", "0.5507393", "0.54924595", "0.5484746", "0.5456038", "0.5441649", "0.54290783", "0.5415065...
0.70496
0
Returns the supported components e.g. set(['mmic_autodock_vina',...]). Returns Set[str]
def tactic_comps(cls) -> Set[str]: return set(["mmic_autodock_vina"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_supported_components(self):\n props = [cdav.SupportedCalendarComponentSet()]\n response = self.get_properties(props, parse_response_xml=False)\n response_list = response.find_objects_and_props()\n prop = response_list[unquote(self.url.path)][\n cdav.SupportedCalendarC...
[ "0.7520092", "0.6942378", "0.6502353", "0.64853776", "0.64341474", "0.6051912", "0.603774", "0.58496153", "0.58443105", "0.58355975", "0.5832998", "0.5783114", "0.5783114", "0.577528", "0.57419336", "0.57056123", "0.56868654", "0.5655444", "0.5626463", "0.5625516", "0.5606547...
0.7170247
1
Define test variables and initialize app.
def setUp(self): self.app = create_app() self.client = self.app.test_client self.database_name = os.environ.get( "TEST_DATABASE_NAME", "abc123abc1234" ) self.database_path = "postgres://postgres:postgres@{}/{}".format( "localhost:5432", self.database_name ) setup_db(self.app, self.database_path) # drop db, create and populate with test data setup_db_for_test() self.casting_assistant_auth_header = { "Authorization": "Bearer " + CASTING_ASSISTANT_TOKEN } self.casting_director_auth_header = { "Authorization": "Bearer " + CASTING_DIRECTOR_TOKEN } self.executive_producer_auth_header = { "Authorization": "Bearer " + EXECUTIVE_PRODUCER_TOKEN } self.create_actor_success = { "name": "Chris Hemsworth", "age": 37, "gender": "Male", } self.create_actor_fail = { "name": "Chris Evans", "age": 39, } self.create_movie_success = { "title": "Captain America: Civil War", "release_date": "12/04/2016", "actors_ids": [1, 2, 3], } self.create_movie_fail_1 = { "title": "Avenger: Infinity War", } self.create_movie_fail_2 = { "title": "Avenger: Infinity War", "release_date": "27/04/2018", "actors_ids": [], } self.create_movie_fail_3 = { "title": "Avenger: Infinity War", "release_date": "27/04/2018", "actors_ids": [100], } # binds the app to the current context with self.app.app_context(): self.db = SQLAlchemy() self.db.init_app(self.app) # create all tables self.db.create_all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.app = init_api()", "def setUp(self):\r\n self.app = app.test_client()\r\n self.app.testing = True", "def setUp(self):\n self.app = app.test_client()\n self.app.testing = True", "def setUp(self) -> None:\n self.app = app.app.test_client()\n ...
[ "0.8074992", "0.799192", "0.79715896", "0.7904655", "0.7897552", "0.7884764", "0.77985597", "0.7775213", "0.77417946", "0.77252287", "0.77252287", "0.7690111", "0.7678627", "0.7651094", "0.7564304", "0.7556179", "0.74967074", "0.74653935", "0.7387983", "0.73835796", "0.737744...
0.0
-1
Load the specified mojofile, and return its model id.
def load_model(self, mojofile: str) -> str: return self._request("GET /loadmojo", params={"file": mojofile})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_model(self, filename):\r\n pass", "def load_model(self, file=None):\n return None", "def load_model(self, file_name=None):\n try:\n if file_name:\n self.agent.load_model(file_name)\n else:\n self.agent.load_model()\n print...
[ "0.6718768", "0.654268", "0.61337996", "0.6125505", "0.6113581", "0.6078083", "0.60401374", "0.60291064", "0.5945967", "0.5840561", "0.5827812", "0.5739245", "0.5689958", "0.5678766", "0.5677562", "0.5670736", "0.56696165", "0.5610047", "0.5605511", "0.55876744", "0.5587407",...
0.78735054
0
Shutdown / kill the server. Sometimes the ``POST /shutdown`` request may fail. In any case we attempt to terminate the process with the SIGKILL signal if it still seems to be running.
def shutdown(self): try: self._request("POST /shutdown") time.sleep(0.300) except requests.exceptions.ConnectionError: pass if self._process and self._process.poll() is None: self._process.kill() if self._session: self._session.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shutdown():\n os.kill(os.getpid(), signal.SIGTERM)", "def shutdown():\n self_pid = os.getpid()\n logging.info('Forcibly terminating program (PID=%s)', self_pid)\n os.kill(self_pid, signal.SIGKILL)", "def stop(self):\n self.shutdown_ = True\n if self.running():\n os.kill...
[ "0.8043204", "0.7408491", "0.74051774", "0.73047185", "0.7299", "0.7294056", "0.72432417", "0.7183416", "0.7163862", "0.7163367", "0.7136405", "0.71052444", "0.70983547", "0.70959175", "0.70620507", "0.70323277", "0.70266837", "0.7002895", "0.6961565", "0.696054", "0.69446033...
0.81470776
0
Update the kernelspecs table.
def refresh_kernelspecs() -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_kernels() -> None:\n ...", "def modify_devices(self):\n\n for i in self._nodes.items():\n node = i[1]\n devices = node[\"devices\"]\n other_devices = devices[\"other_devices\"]\n kernel_devices = devices[\"kernel_devices\"]\n dpdk_devic...
[ "0.5808753", "0.5629541", "0.5591042", "0.5496405", "0.54948765", "0.5418482", "0.52984756", "0.5270303", "0.5197712", "0.5154047", "0.5119544", "0.5119544", "0.51178193", "0.5101636", "0.50797075", "0.5073883", "0.5045194", "0.50378954", "0.50309587", "0.5014471", "0.5006939...
0.7550118
0
Update the status table.
def refresh_status() -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_status(self):\n self._db_update({'status': self.status})", "def updateStatus(self, status):\n pass", "def UpdateStatus(self, status):\r\n self.status.update(status)", "def update_status(self, id, status):\n sql = f\"UPDATE incidences SET status = \\'{status}\\'\\\n ...
[ "0.8145079", "0.7746542", "0.7465801", "0.69591504", "0.69093305", "0.6833517", "0.6802735", "0.6739377", "0.6701322", "0.6697481", "0.6673145", "0.6655026", "0.6641906", "0.6636951", "0.64802206", "0.64509493", "0.6405129", "0.64037913", "0.64026374", "0.6361408", "0.6330876...
0.62391394
31
Creates a new terminal and returns the name.
def create_terminal() -> str: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n return \"Terminal('{}')\".format(self.name)", "def addTerminal(self, name, **opts):\n opts.update(renamable=True, removable=True)\n name = self.nextTerminalName(name)\n term = NetTerminal(self, name, **opts)\n self.terminals[name] = term\n if term.i...
[ "0.6440198", "0.6267893", "0.62144405", "0.60047346", "0.5891908", "0.5890155", "0.5865237", "0.57142264", "0.5690836", "0.5674329", "0.56701756", "0.56039375", "0.5576599", "0.5536455", "0.5528613", "0.5440345", "0.5381108", "0.5373771", "0.52840245", "0.52517766", "0.521793...
0.80201596
0
Update the kernels table.
def refresh_kernels() -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_kernelspecs() -> None:\n ...", "def callUpdateTable(self):\r\n self.updateTable()", "def gpu_kernels(self, node, name):\r\n raise MethodNotDefined, 'gpu_kernels'", "def run(self):\n\n self.sess.run(self.update_operations)", "def update(self, x_train_single, updated_h):\n ...
[ "0.6155734", "0.57529676", "0.5730305", "0.56955045", "0.56193566", "0.5611958", "0.5498789", "0.5324433", "0.5293424", "0.5292726", "0.5291626", "0.52879345", "0.5268349", "0.5242812", "0.52361995", "0.52361995", "0.51978123", "0.5197042", "0.51949096", "0.5192662", "0.51908...
0.7096408
0
Creates a new kernel and returns the ID
def create_kernel(name: str) -> str: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_kernel(self, kernel_id):", "def testCreateKernel(self):\n try:\n contextID, retErr = PyOpenCLInterface.CreateContext(self.testResources.listDevicesIDs, self.testResources.dictProperties)\n self.assertEqual(retErr, 0)\n # create program\n programID, retEr...
[ "0.6998178", "0.6430162", "0.59596896", "0.59022087", "0.58619636", "0.58563536", "0.5824651", "0.5798457", "0.5699474", "0.56958765", "0.5624578", "0.5619856", "0.560809", "0.5569131", "0.5542638", "0.5518145", "0.5472115", "0.5447868", "0.5417481", "0.54118687", "0.5337183"...
0.7782273
0
Creates a new session or returns existing one if path exists
def create_session( path: str, type: str, name: Optional[str] = None, kernel_name: Optional[str] = None, kernel_id: Optional[str] = None, ) -> str: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_new_session():\n session = Session.objects.create(uuid=str(uuid4()), container_id=None)\n return session.id", "def _insert_new_session():\n request = self._make_request()\n session_existing = self._set_up_session_in_Redis_and_makeOne( # noqa: F841\n request, s...
[ "0.7212364", "0.6900169", "0.6895351", "0.6759798", "0.6726369", "0.6653804", "0.6640182", "0.65958303", "0.65842575", "0.65202713", "0.6479733", "0.64455444", "0.6434389", "0.64199865", "0.63682336", "0.6362771", "0.63557774", "0.63264036", "0.6294936", "0.6289158", "0.62681...
0.70272946
1
Updates an existing session.
def update_session( id: str, path: Optional[str] = None, name: Optional[str] = None, type: Optional[str] = None, kernel_name: Optional[str] = None, kernel_id: Optional[str] = None, ) -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upsert_session(session_data):\n g_db['sessions'].update(\n get_session_id(session_data),\n {\n \"$set\": session_data,\n },\n upsert=True\n )", "def test_update_session(self):\r\n now = time.time()\r\n\r\n # Make sure the session has data so that it ...
[ "0.7159977", "0.686218", "0.68574136", "0.66107583", "0.6506551", "0.6489274", "0.6447803", "0.64465", "0.63691455", "0.63294715", "0.62878484", "0.6127597", "0.6104474", "0.6089136", "0.6085308", "0.6046978", "0.6046949", "0.60441613", "0.5959553", "0.59453976", "0.5927981",...
0.726062
0
Updates the content and returns the ID
def refresh_content( path: str, content: Optional[bool] = False, type: Optional[str] = None, format: Optional[str] = None, ) -> str: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateContent(content, **kwargs):", "def update_content(self):\n raise NotImplementedError", "def on_update(self):\n self.contentnode.make_content_id_unique()", "def put(self,id):\r\n data = request.json\r\n return update(id=id,data=data)", "def update(self, data):\n ...
[ "0.7222523", "0.6997383", "0.62771076", "0.6275982", "0.62165546", "0.6215696", "0.61253357", "0.6119364", "0.6075601", "0.603036", "0.6030269", "0.59868115", "0.5979657", "0.59795225", "0.59764755", "0.596385", "0.59549665", "0.59367526", "0.589859", "0.5896499", "0.5894518"...
0.0
-1
Creates new content and returns the ID.
def create_content( copy_from: Optional[str] = None, ext: Optional[str] = None, type: Optional[str] = None, path: str = "", ) -> str: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_create(self):\n self.contentnode.make_content_id_unique()", "def _create(self, title=''):\n return ContentObject(title)", "def create_with_content_and_title(db, content, title):\n sequence_list = SequenceList(str(uuid.uuid1()))\n sequence_list.content = content\n seque...
[ "0.72641987", "0.6442757", "0.64032644", "0.6294966", "0.6188546", "0.61151767", "0.6097857", "0.60493034", "0.5894949", "0.58636135", "0.58631575", "0.5804538", "0.5788969", "0.5767498", "0.57668734", "0.57604814", "0.5739654", "0.57271385", "0.57177323", "0.5717616", "0.571...
0.5430152
51
Returns policy and value estimates for given observations.
def step(self, obs): obs = torch.from_numpy(obs) _, pi, v = self.forward(obs) return pi.detach().numpy(), v.detach().numpy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_observations(\n self, obs: Dict[str, Any], *args: Any, **kwargs: Any\n ) -> Dict[str, Any]:\n\n for uuid in self.compute_order:\n if uuid not in obs:\n obs[uuid] = self.preprocessors[uuid].process(obs)\n\n return {uuid: obs[uuid] for uuid in self.observatio...
[ "0.5557971", "0.548167", "0.54308265", "0.5420844", "0.5312977", "0.53012514", "0.52951914", "0.5293624", "0.52801895", "0.52599216", "0.5253742", "0.52483994", "0.5174865", "0.517392", "0.51706284", "0.5163968", "0.5154146", "0.51273954", "0.5124976", "0.5118999", "0.5116802...
0.0
-1
Modified from DASHAgent to replace activation with SocogSys1 variable binding function.
def update_beliefs(self, result, action): if self.traceUpdate: print("Updating beliefs based on action", action, "with result", result) if result == 'TryAgain': return None elif not result and not self.isTransient(action): if self.traceUpdate: print("Adding known false", action) self.knownFalseTuple(action) if isinstance(result, list): for bindings in result: concrete_result = substitute(action, bindings) if not self.isTransient(concrete_result): if self.traceUpdate: print("Adding known true and performed", concrete_result) self.knownTuple(concrete_result) self.knownTuple(('performed', concrete_result)) self.update_variable_binding(concrete_result)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _activation(self,components,activation):\r\n \r\n if activation == \"ReLU\":\r\n components.append(nn.ReLU())\r\n elif activation == \"Sigmoid\":\r\n components.append(nn.Sigmoid())\r\n else:\r\n raise Exception(\"Invalid activation fn: \"+activation...
[ "0.58555764", "0.57150984", "0.54634446", "0.5329766", "0.5275407", "0.5234855", "0.5234301", "0.5216041", "0.51913345", "0.5126263", "0.5109353", "0.5107513", "0.50998616", "0.5097742", "0.5060914", "0.5060419", "0.5039985", "0.5010341", "0.50005376", "0.4995609", "0.4991565...
0.0
-1
Takes a two element tuple. The second element must be a Beliefs object which system1 will use to update the belief module. Once updated, the action queue will be emptied and the rules will be checked for satisfied conditions. The action queue will be refilled with new active actions from the rule list.
def process_belief(self, args): goal, belief = args if isinstance(belief, Beliefs): self.belief_module.process_belief(belief) self.initialize_action_queue() return [{}]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_beliefs(self, result, action):\n if self.traceUpdate:\n print(\"Updating beliefs based on action\", action, \"with result\", result)\n\n if result == 'TryAgain':\n return None\n\n elif not result and not self.isTransient(action):\n if self.traceUpdat...
[ "0.62839353", "0.5601004", "0.54203224", "0.523504", "0.523504", "0.523504", "0.523504", "0.52241856", "0.51511395", "0.5150723", "0.5111748", "0.50751257", "0.5067793", "0.50459915", "0.5037544", "0.50247914", "0.4989329", "0.4953486", "0.49498907", "0.49385783", "0.49159616...
0.60782725
1
Calls the belief module's emit_belief method to get and return a Beliefs object with the agents chosen belief for emission.
def emit_belief(self, args): goal, belief = args return [{belief: self.belief_module.emit_belief()}]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_belief(self, args):\n goal, belief = args\n\n if isinstance(belief, Beliefs):\n self.belief_module.process_belief(belief)\n self.initialize_action_queue()\n\n return [{}]", "def calculateBeliefs(self):\n\n belief = {}\n\n for question in self.g...
[ "0.6572719", "0.60047936", "0.58963394", "0.5791217", "0.5663534", "0.5584099", "0.5567305", "0.550817", "0.54517233", "0.53226274", "0.53167677", "0.5304004", "0.51742756", "0.51660204", "0.5156423", "0.5151522", "0.5149159", "0.51191115", "0.5110184", "0.50023305", "0.49014...
0.74441326
0
Checks if an incoming belief is in conflict with internal beliefs. A conflict occurs when the belief is of opposite valence to a current belief. This method does not update own or perceived beliefs.
def belief_conflict(self, args): goal, belief = args if isinstance(belief, Beliefs): if self.belief_module.is_conflicting_belief(belief): return [{}] return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_conflict(self):\n for diffstat in self.diffstat():\n if diffstat.has_conflict:\n return True\n return False", "def checkConflicts(self):\n\t\treturn", "def refine_conflict(self):\n self._raise_not_supported()", "def check_conflicts(self):\n\t\tshutit_glo...
[ "0.60755587", "0.5997811", "0.5935477", "0.5858629", "0.57589734", "0.56303644", "0.5552522", "0.55062824", "0.54827005", "0.54471344", "0.5424391", "0.54060894", "0.53555745", "0.53466696", "0.53354824", "0.5331523", "0.5313019", "0.530491", "0.5267892", "0.52595043", "0.522...
0.66045004
0
quad(f, a, b) > \int_a^b f(x) dx Uses some quadrature rule to evaluate the integral.
def quad(f, a, b): S, D = (b+a)/2.0, (b-a)/2.0 def rescaled_f(x): return f(x*D + S)*D return sum(w * rescaled_f(p) for w, p in zip(quad_weights, quad_points))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quad(func, a, b, args=()):\n\tx_units = a.units\n\tf_units = func(.5*(a+b)).units\n\n\tI, abserr = sciquad(\n\t\tlambda x : func(x*x_units).to(f_units).magnitude,\n\t\ta.magnitude, b.to(x_units).magnitude,\n\t\targs)\n\n\treturn I*x_units*f_units, abserr*x_units*f_units", "def add_quad(a, b):\n s = np.sqr...
[ "0.7321034", "0.66224813", "0.6437059", "0.64194804", "0.62829626", "0.62496614", "0.6247555", "0.6206842", "0.6206842", "0.6199654", "0.61690414", "0.6163885", "0.61347663", "0.6107581", "0.60302866", "0.60202134", "0.6018099", "0.6005248", "0.60019904", "0.5973936", "0.5925...
0.7673257
0
Run setup before each request.
def before_request(): id = request.headers.get("User-Id", None) if id: user = User.query.get(id) if user is None: raise CustomError(400, message="Invalid User-Id in Header.") g.user = user else: g.user = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_request():\r\n\r\n\tinit_classes()", "def setup(ctx):\n handle_no_cache(ctx)", "def _setup(self) -> None:\n\t\treturn", "def setup_once():\n # type: () -> None\n _install_httpx_client()\n _install_httpx_async_client()", "def _setup(self):\n pass", "def _setup(sel...
[ "0.727703", "0.69686836", "0.69070673", "0.68600476", "0.683981", "0.683981", "0.683981", "0.683981", "0.683981", "0.6837512", "0.68245745", "0.6805248", "0.67752415", "0.676644", "0.67472184", "0.67328984", "0.67298096", "0.67094517", "0.66988313", "0.6659573", "0.6658358", ...
0.0
-1
Return whether or not an email or password combination is valid.
def authenticate(): # Get JSON data from request json = request.get_json() if 'email' not in json or 'password' not in json: raise CustomError(400, message='Must include an email and a password') # Check email user = User.query.filter_by(email=json['email']).first() if user is None: raise CustomError(401, message='Email or password were not found.') # Check password if not check_password_hash(user.password, json['password']): raise CustomError(401, message='Email or password were not found.') return jsonify({'success': True, 'user': user.to_dict()}), 201
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_auth(email, password):\n if not email or not password:\n return False\n sha = sha1(email).hexdigest()\n user_info = redis.hgetall(\"sl:account:{}\".format(sha))\n\n return bool(\n type(user_info) == dict and\n user_info.get(\"password\") == pas...
[ "0.7349685", "0.68957275", "0.6839669", "0.6783419", "0.67657584", "0.6671322", "0.66452736", "0.663105", "0.6579197", "0.6508494", "0.6490613", "0.647486", "0.6462656", "0.6462656", "0.6454392", "0.64511716", "0.64275295", "0.64244556", "0.6408592", "0.6401601", "0.64013714"...
0.0
-1
Create new User from supplied infomation.
def signup(): # Get JSON from request json = request.get_json() if json is None: raise CustomError(400, message="No JSON included or " "Content-Type is not application/json") expected_keys = ['first_name', 'last_name', 'email', 'password'] if not all(key in json for key in expected_keys): raise CustomError(400, message="Must include a first name, last name," "email and password.") # # Check if email is unique if User.query.filter_by(email=json['email']).first() is not None: raise CustomError(409, message='Email already in use.') # # TODO: Add password validation user = User(json['first_name'], json['last_name'], json['email'], json['password']) db.session.add(user) db.session.commit() return jsonify({'success': True, 'user': user.to_dict()}), 201
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self, validated_data:tuple):\n user = user_details.objects.create(user_name=validated_data[0], email=validated_data[1], password=validated_data[2])\n return user", "def create(cls, **data):\n user = cls()\n for attribute in data:\n if hasattr(user, attribute):\n ...
[ "0.7371264", "0.715452", "0.70016223", "0.6986368", "0.69517016", "0.6951686", "0.69164294", "0.6909793", "0.6909042", "0.68905514", "0.68693435", "0.68369526", "0.6824223", "0.6820779", "0.6811556", "0.6802563", "0.68015856", "0.67980665", "0.67485744", "0.67480195", "0.6740...
0.0
-1
Get a user by its id.
def get_user_by_id(id): user = User.query.get(id) if user is None: raise CustomError(404, 'User with id: {} was not found.'.format(id)) return jsonify({'success': True, 'user': user.to_dict()})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_by_id(self, id):\n\t\treturn self.users.get(id)", "def get(self, id):\n\t\ttry:\n\t\t\tflask_app.logger.debug('We are getting the user: %d', id)\n\t\t\treturn user_service.get(id)\n\t\texcept AssertionError as e:\n\t\t\tuser_space.abort(400, e.args[0], status = \"Could not get user\", statusCode = \...
[ "0.89340585", "0.8621323", "0.85916656", "0.8508148", "0.8499932", "0.84347427", "0.8386604", "0.8384479", "0.8328696", "0.8305895", "0.82829595", "0.82829595", "0.82829595", "0.82829595", "0.8282169", "0.82745594", "0.8266114", "0.82544875", "0.82501876", "0.8243749", "0.821...
0.8168108
27
Return all of the current user's friends.
def friends(): friends = [u.to_dict() for u in g.user.get_friends()] return jsonify({'success': True, 'friends': friends})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friends(self) -> List['Friend']:\n\n return self.sObj.getFriends()", "async def get_friends(self) -> List[User]:\n me = await self.get_self()\n r = await self.request.request(url=f'https://friends.roblox.com/v1/users/{me.id}/friends', method=\"GET\")\n data = r.json()\n fri...
[ "0.80327207", "0.80079186", "0.79557514", "0.77440524", "0.74695307", "0.737918", "0.73686486", "0.7360085", "0.7259125", "0.7249176", "0.71591926", "0.70998305", "0.70950127", "0.70513386", "0.70225525", "0.7008113", "0.6999867", "0.6982058", "0.6899615", "0.68960917", "0.68...
0.7357716
8
List or create friendrequests. Create an unconfirmed friendship between two users. Or return all friendships which are not confirmed for the current user.
def create_friend_request(): if request.method == "GET": friend_requests = [f.to_dict() for f in g.user.get_friend_requests()] return jsonify({'success': True, 'friend_requests': friend_requests}) if request.method == "POST": # Get recieving user id from request json = request.get_json() if json is None: raise CustomError(400, message="No JSON included or Content-Type" "is not application/json") if 'recieving_user_id' not in json: raise CustomError(400, message="Must include recieving_user_id") recieving_user_id = json['recieving_user_id'] # Get the user object recieving_user = User.query.get(recieving_user_id) if recieving_user is None: raise CustomError( 404, message='User with id: {} was not found.'.format( recieving_user_id) ) # Check friendship does not already exist friendship_exists = Friendship.query.filter( (Friendship.actioning_user_id == g.user.id) | (Friendship.recieving_user_id == g.user.id), (Friendship.actioning_user_id == recieving_user_id) | (Friendship.recieving_user_id == recieving_user_id) ).first() if friendship_exists: raise CustomError( 409, message="There is either a pending friend request between the" "two users or the two users are already friends." ) # Insert friend request friend_request = Friendship(g.user, recieving_user) db.session.add(friend_request) db.session.commit() return jsonify({'success': True}), 201
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pending_friendships(self):\n url = 'friendships/pending/'\n return self.send_request(url)", "def get_friend_requests(self, user):\n return self.filter(addresser_user=user, status=Friendship.STATUS_PENDING, active=True)", "def friend_request():\n if 'username' not in session:\n ...
[ "0.66678417", "0.65838015", "0.64492136", "0.6419166", "0.6355479", "0.6347656", "0.63212603", "0.6301099", "0.6292718", "0.62728006", "0.6239098", "0.62126476", "0.61244184", "0.60886", "0.6074877", "0.6053998", "0.6042511", "0.60373974", "0.59732705", "0.5967323", "0.59309"...
0.7035371
0
Get, update or delete friendship with the specified id.
def get_friend_request_with_id(id): # Get friend request friendship = Friendship.query.get(id) if friendship is None: raise CustomError( 404, message="Friendship with id: {} not found.".format(id) ) can_view = friendship.actioning_user_id == g.user.id or \ friendship.recieving_user_id == g.user.id # Check user is has permission to view that request if not can_view: raise CustomError( 401, message="You are not authorised to view this resource." ) if request.method == "GET": return jsonify({'success': True, 'friendship': friendship.to_dict()}) if request.method == "PATCH": if friendship.recieving_user_id != g.user.id: raise CustomError( 401, message="You are not authorised to update this object." ) json = request.get_json() if json is None: raise CustomError(400, message="No JSON included or Content-Type" "is not application/json") if 'confirmed' in json: friendship.confirmed = json['confirmed'] db.session.commit() return jsonify({'success': True, 'friendship': friendship.to_dict()}) if request.method == "DELETE": db.session.delete(friendship) db.session.commit() return jsonify({'success': True})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_friend(request, id):\n user = request.user\n friend = get_object_or_404(User, id=id)\n user.profile.friends.remove(friend)\n friend.profile.friends.remove(user)\n messages.success(\n request,\n 'User deleted from your friends list'\n )\n return redirect('profiles:profi...
[ "0.6267513", "0.60474205", "0.5893467", "0.57769", "0.57769", "0.57769", "0.55159366", "0.5514679", "0.5414053", "0.53229433", "0.5308454", "0.52603304", "0.52275467", "0.5149211", "0.51255256", "0.51151985", "0.51151985", "0.5048067", "0.49942237", "0.49900073", "0.49625716"...
0.74585414
0
sendEmails will send an email to all emails associated with a person
def sendEmails( receiverName, retainedCompany, companyName, emailList, senderName, senderEmail, emailPassword, senderTitle, senderCompany, senderCompanyHomePage, senderPhone, port=465, returnHTML = True ): for emailToTry in emailList: # change back the next line after testing time.sleep(np.random.uniform(5,15)) # I introduced this because I was being rate limited, and I want to see if this will help avoid that - it seems to help print(f'trying {emailToTry}') message = MIMEMultipart('alternative') message['Subject'] = f'Engineering Positions at {companyName}' # change this back when ready to send actual emails message['From'] = senderEmail message['To'] = emailToTry # note that this only affects the headers - it does not affect to whom the message gets sent to [text, html] = emailTextHTML(receiverName, retainedCompany, companyName, senderName, senderTitle, senderCompany, senderEmail, senderCompanyHomePage, senderPhone, returnHTML=returnHTML) part1 = MIMEText(text, 'plain') part2 = MIMEText(html, 'html') message.attach(part1) message.attach(part2) # create a secure SSL context context = ssl.create_default_context() # now loop over each email message and extract what we need: with smtplib.SMTP_SSL('smtp.gmail.com', port, context=context) as server: # Using with smtplib.SMTP_SSL() as server: makes sure that the connection is automatically closed at the end of the indented code block. If port is zero, or not specified, .SMTP_SSL() will use the standard port for SMTP over SSL (port 465). server.login(senderEmail, emailPassword) server.sendmail(senderEmail, emailToTry, message.as_string()) # the above line is how we actually change whom the message is sent to
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_email_users():\n\n # Get users emails\n users_emails = User.objects.exclude(\n Q(email='') |\n Q(email=None)\n ).values_list(\n 'email',\n flat=True\n )\n\n # Send email to each user\n # for email_user in users_emails:\n\n title = 'Se han calculado nuevos H...
[ "0.76834345", "0.7484118", "0.71810454", "0.7061762", "0.70294595", "0.69372624", "0.68464893", "0.6761992", "0.6630803", "0.6604708", "0.6564017", "0.65435404", "0.64834946", "0.64148235", "0.6410648", "0.6408025", "0.63622856", "0.63590986", "0.6358885", "0.6347821", "0.628...
0.6047232
42
outLookSender is not utilized in this module but wrote the function in case we want to send from an outlook account in the future
def outLookSender(receiverAddress, receiverName, retainedCompany, companyName, senderName, senderTitle, senderCompany, senderEmail, senderCompanyHomePage, senderPhone, returnHTML=False): subj = f'Engineers from {retainedCompany} Search' if returnHTML: [text, html] = emailTextHTML(receiverName, retainedCompany, companyName, senderName, senderTitle, senderCompany, senderEmail, senderCompanyHomePage, senderPhone, returnHTML=returnHTML) else: [text] = emailTextHTML(receiverName, retainedCompany, companyName, senderName, senderTitle, senderCompany, senderEmail, senderCompanyHomePage, senderPhone, returnHTML=returnHTML) outlook = app('Microsoft Outlook') msg = outlook.make( new=k.outgoing_message, with_properties={ k.subject: subj, k.plain_text_content: text } ) msg.make( new=k.recipient, with_properties={ k.email_address: { k.name: receiverName, k.address: receiverAddress } } ) msg.send()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pcorMacVerification(window,refrenceid,objectidentifier,texttoenter):\n try:\n buttons = getAppButtons(window)\n atomacclick(buttons[9])\n childwindow = refrenceid.windowsR()\n protectMoreDevicestitle = getApplicatontitle(childwindow[0])\n entertext(protectMoreDevicestitle,...
[ "0.5824598", "0.5588486", "0.5576109", "0.55656964", "0.55588704", "0.5537601", "0.55139714", "0.55043477", "0.5502522", "0.54980785", "0.54489857", "0.5415622", "0.5409443", "0.53969055", "0.5394186", "0.5353212", "0.5353212", "0.534986", "0.5313206", "0.5311404", "0.5300741...
0.65203226
0
emailJobs is a function that is used to email jobs/careers email addresses for companies in a dataframe
def emailJobs( df, retainedCompany, senderName, defaultSenderEmail, emailPassword, senderTitle, senderCompany, senderCompanyHomePage, senderPhone, noContactCompanyListPickleFileName, port=465, returnHTML=True ): try: with open(noContactCompanyListPickleFileName, 'rb') as inputFile: noContactCompanyList = pickle.load(inputFile) except: noContactCompanyList = [] for i in range(len(df)): companyName = df['Organization Name'][i] if companyName.lower() in noContactCompanyList: pass try: domainName = df['Domain'][i] jobsEmails = [prefix + '@' + domainName for prefix in ['jobs', 'careers']] # email all the jobs pages for that copmany sendEmails( 'guys', # addressing general company, so use 'guys' instead of individual name retainedCompany, companyName, jobsEmails, senderName, defaultSenderEmail, emailPassword, senderTitle, senderCompany, senderCompanyHomePage, senderPhone, port=port, returnHTML = returnHTML ) except: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_email(jobs):\n jobs = jobs\n server = smtplib.SMTP(\"smtp.gmail.com\", 587)\n server.ehlo()\n server.starttls()\n server.ehlo()\n\n server.login(EMAIL, PASS)\n\n subject = f\"Job Scraper Results\"\n\n if jobs != \"Not working\":\n body = []\n job_ids = [\n ...
[ "0.6686441", "0.573404", "0.5680976", "0.5586321", "0.5568828", "0.5565883", "0.5497524", "0.54533464", "0.537631", "0.5351467", "0.5310948", "0.5301148", "0.52795285", "0.5278291", "0.5266971", "0.52349377", "0.5156166", "0.51303834", "0.51244825", "0.5099825", "0.5099411", ...
0.8165515
0
Return checked to HTML input (checkbox)
def check_ignore(self): return "checked" if not self.ignore else ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uiCheckboxChecked(checkbox):\n\n return clibui.uiCheckboxChecked(checkbox)", "def htmlCheckbox(labelText, parName, args, labelAttr='', attr=''):\n snippet = htmlLabel(labelText,parName,labelAttr)\n checked = 'checked=\"checked\"' if parName in args else ''\n snippet += '<input type=\"checkbox\" n...
[ "0.73874754", "0.7013393", "0.67862654", "0.6326686", "0.6137979", "0.61240286", "0.61000293", "0.60839576", "0.60712683", "0.60165775", "0.5976162", "0.59326965", "0.58932775", "0.588823", "0.5887761", "0.5884953", "0.5875955", "0.5836536", "0.5805211", "0.57928985", "0.5773...
0.49396482
93
Function for updating packages
def update(self, package=None): if package: query = package to_update = package.package.name else: query = PackageUpdate.objects.filter(server=self, ignore=False) to_update = " ".join(list(query.values_list('package__name', flat=True))) if self.os == 0: cmd = "apt-get install --only-upgrade {}".format(to_update,) elif self.os == 1: cmd = "yum update -y {}".format(to_update,) r = self.send_command(cmd) query.delete() if PackageUpdate.objects.filter(server=self, ignore=False).count() == 0: self.status = 0 self.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_package(self, **kwargs):\n logging.warning('Updating a package removes all existing data. '\n 'If you wish to keep the existing data, use `CachedCKAN.patch_package`.')\n results = self.api.action.package_update(**kwargs)\n self.get_ckan_metadata(True)\n ...
[ "0.7270838", "0.72650665", "0.7251651", "0.7214989", "0.7085298", "0.7072634", "0.66923255", "0.668152", "0.6604724", "0.65995777", "0.65975875", "0.6594511", "0.656834", "0.6567808", "0.6567808", "0.6559777", "0.65499485", "0.65261453", "0.64859855", "0.64815766", "0.6460241...
0.7036477
6
Display HTML icon of OS distribution.
def show_os_icon(self): if self.os == 0: return "<i class='devicon-debian-plain'></i>" elif self.os == 1: return "<i class='devicon-redhat-plain'></i>" else: return "?"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def downloadicon_name(self):\n return 'platform_%s.gif' % \\\n re.sub(r'\\W', '_', self.context.getPlatform()).lower()", "def icon(self) -> str:\n return ICON_SERVER", "def icon(self):\n return \"mdi:hubspot\"", "def icon(self):\n return ICON_BUS", "def icon(s...
[ "0.6832323", "0.68212587", "0.6478877", "0.6392684", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63691825", "0.63597417", "0.63435024", "0.63178104", "0.6314043", "0.6314043", "0.6243124", "0...
0.83448386
0
Sets "_total_posts" as amount of posts in the VK domain.
async def _set_total_posts_in_domain(self) -> None: logger.info('Getting total posts in "vk.com/%s"...', self.vk_domain) params = { "v": settings.VKAPI_VERSION, "access_token": settings.VKAPI_TOKEN, "count": 1, # Enough just to get total post in domain. "domain": self.vk_domain, } # Data fetching. response = await vk_asynchronous_request( self._url_wall_get, params, domain=self.vk_domain, ) self._total_posts_in_domain = response["response"]["count"] logger.info("Total posts in VK domain: %s", self._total_posts_in_domain)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posts_count(self):\n return Post.objects.filter(user__username = self.user.username).count()", "def num_posts(self):\n\n return FlicketTicket.query.filter_by(started_id=self.id).count() + FlicketPost.query.filter_by(\n user_id=self.id).count()", "def _update_count(self):\n s...
[ "0.63555706", "0.6204205", "0.56337523", "0.55793494", "0.5573961", "0.5543833", "0.5520672", "0.55201143", "0.5465146", "0.5398032", "0.53932655", "0.53263414", "0.52809906", "0.52755684", "0.5259448", "0.5227877", "0.51914954", "0.5175302", "0.51708394", "0.5170826", "0.516...
0.84554565
0
Fetches posts from VK domain asynchronously and put it into "posts" attribute.
async def fetch_posts(self) -> None: async def fetch_posts_for_offset(offset) -> list: logger.info( "(offset %i) Start fetching posts from vk.com/%s...", offset, self.vk_domain, ) # VK Script code for /execute method. vks_code = get_wall_post_template.substitute( { "domain": self.vk_domain, "offset": offset, "posts_per_portion": self._posts_per_portion, "execution_times": self._execution_times, } ) params = { "v": settings.VKAPI_VERSION, "access_token": settings.VKAPI_TOKEN, "code": vks_code, } url = self._url_execute # Posts fetching. resp_json = await vk_asynchronous_request( url, params, domain=self.vk_domain, offset=offset, ) logger.info( "(offset %i) End fetching posts from vk.com/%s...", offset, self.vk_domain, ) # Gathered posts handling. posts_from_vk = resp_json["response"]["items"] posts = posts_as_schemas(posts_from_vk) del posts_from_vk return posts # Checks and preparations. await self._set_total_posts_in_domain() if not self._total_posts_in_domain: return # Creating tasks for fetching. tasks = [] posts_per_task = self._posts_per_portion * self._execution_times offsets = list(range(0, self._total_posts_in_domain, posts_per_task)) for offset in offsets: tasks.append(asyncio.create_task(fetch_posts_for_offset(offset))) # Running tasks. logger.info("Start fetching posts from vk.com/%s...", self.vk_domain) results = await asyncio.gather(*tasks) logger.info("End fetching posts from vk.com/%s...", self.vk_domain) # Flatting results from many tasks into one list. self._posts = [post for result in results for post in result] # Final actions. if self.sort_by_likes: self._posts = list(sorted(self.posts, key=lambda p: p.likes, reverse=True)) if self.amount_to_fetch: self._posts = self._posts[: self.amount_to_fetch]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_posts():\n get_chain_address = F\"{CONNECTED_NODE_ADDRESS}/chain\"\n response = requests.get(get_chain_address)\n if response.status_code == 200:\n content = []\n chain = json.loads(response.content)\n for block in chain[\"chain\"]:\n for tx in block[\"transaction...
[ "0.655602", "0.65269387", "0.6413515", "0.6018604", "0.5916808", "0.59025943", "0.5787382", "0.57700604", "0.5734009", "0.57019544", "0.5652772", "0.56395626", "0.5616751", "0.5613428", "0.56133306", "0.56015396", "0.5592875", "0.5583471", "0.5548579", "0.551852", "0.55078864...
0.7330048
0
Creates posts as Pydantic schemas based on posts data given from VK API.
def posts_as_schemas(posts_from_vk: list[dict]) -> list[Post]: posts = [] for post_from_vk in posts_from_vk: try: post = Post( date=post_from_vk["date"], likes=post_from_vk["likes"]["count"], text=post_from_vk["text"], path=f"wall{post_from_vk['owner_id']}_" f"{post_from_vk['id']}", photos=[], videos=[], ) except KeyError as exc: logger.error("No key %s for post: %s", exc, post_from_vk) continue # Collect attachments (photos, videos etc.). if "attachments" in post_from_vk: attachments = post_from_vk["attachments"] for attachment in attachments: if attachment["type"] == "photo": try: photo = PostPhoto(url="") photo.url = attachment["photo"]["sizes"][-1]["url"] post.photos.append(photo) except KeyError as exc: logger.error("No key %s for photo: %s", exc, post_from_vk) elif attachment["type"] == "video": video = PostVideo(first_frame_url="") video_from_vk = attachment["video"] if "first_frame" in video_from_vk: video.first_frame_url = video_from_vk["first_frame"][-1]["url"] elif "image" in video_from_vk: video.first_frame_url = video_from_vk["image"][-1]["url"] else: logger.error("No video image found: %s", post) continue post.videos.append(video) posts.append(post) return posts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posts_post():\n data = request.json\n\n try:\n validate(data, post_schema)\n except ValidationError as error:\n data = {\"message\": error.message}\n return Response(json.dumps(data), 422, mimetype=\"application/json\")\n\n post = Post(title=data[\"title\"], body=data[\"body\"]...
[ "0.6354075", "0.6284115", "0.6081727", "0.59250623", "0.57985914", "0.57881165", "0.56837225", "0.5657414", "0.56563574", "0.56495565", "0.56208336", "0.56018806", "0.55971843", "0.55958605", "0.557369", "0.55589396", "0.5542766", "0.5523133", "0.5506989", "0.5501767", "0.550...
0.7757099
0
Builds Enter Query Sequence up to Job Title
def buildEnter(self): ttk.Label(self, text='Enter accession number(s), gi(s), or FASTA sequence(s)', font=('Arial', '12', 'bold')).grid(row = self.ROW , column = 1, columnspan=4, sticky ='w') self.clear_button = tk.Button(self, text='Clear', font=('Arial', '9', 'underline'),command = (lambda view = self: self.controller.clear_query(view))) self.clear_button.grid(row = self.ROW, column =5, sticky = 'E') ttk.Label(self, text = 'Subrange:', font=('Arial', '12', 'bold', 'underline') ).grid(row = self.ROW, column = 6, columnspan = 2, sticky = 'E') self.ROW += 1 self.query_box = scrolledtext.ScrolledText(self, width = 70, height = 7, wrap=tk.CHAR) self.query_box.grid(row = self.ROW, column = 1, rowspan = 6, columnspan = 5) self.model_vars['textbox'] = self.query_box #Event generated only refers to scrolledtext need a reference to load_query_button self.query_box.bind('<Key>', lambda event, view = self : self.controller.disable_upload_button(event, view)) tk.Label(self, text = 'From:').grid(row = self.ROW, column = 6, sticky = 'E') self.query_from = ttk.Entry(self, textvariable = self.model_vars['from'], font=('Arial', 10), width = 15) self.query_from.grid(row = self.ROW, column = 7, columnspan = 2, sticky = 'W') self.ROW+=2 tk.Label(self, text = 'To:').grid(row = self.ROW, column = 6, sticky = 'E') self.query_to = tk.Entry(self, textvariable = self.model_vars['to'], font=('Arial', 10), width = 15) self.query_to.grid(row = self.ROW, column = 7, columnspan =2 , sticky = 'W') self.ROW+=5 #There are objects that inherit from this one that will need to know this value for genetic code widget self.upload_file_row = self.ROW ttk.Label(self, text ='Or, Upload File:', font=('Arial', 10, 'bold')).grid(row = self.ROW, column=1, sticky = 'E') self.load_query_button = ttk.Button(self, text='Choose File', command = (lambda view = self: self.controller.load_handler(view))) self.load_query_button.grid(row = self.ROW, column = 2) self.load_status = ttk.Label(self, text='No file chosen', font=('Arial', '10')) self.load_status.grid(row = self.ROW , column = 3, columnspan = 7, sticky = 'W')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seq_query():\n query_type = input(\n '1.Specific fragment\\n'\n '2.Specific Organism\\n'\n '3.Specific gene\\n'\n '4.All\\n'\n '5.All cds\\n'\n )\n organize = input('Organize output?(y/n)\\n')\n if query_type not in ['1', '2', '3', '4', '5']:\n raise ValueE...
[ "0.57784486", "0.5282127", "0.51783377", "0.5130702", "0.512259", "0.50177485", "0.49613672", "0.49327144", "0.48891747", "0.48707858", "0.4861328", "0.4850734", "0.48490104", "0.48305196", "0.48305196", "0.47956473", "0.4788198", "0.47836232", "0.47815114", "0.4765019", "0.4...
0.44272318
75
\'w\' means Way > str r will output as float betwenn rangestart and rangeend ri will output as int betwenn rangestart and rangeend
def r(w,rangestart,rangeend): if w == 'r': print(random.random(rangestart , rangeend)) if w == 'ri': print(random.randint(rangestart,rangeend))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_range(self):\r\n\t\tif self.battery_size == 70:\r\n\t\t\trange = 240\r\n\t\telif self.battery_size == 85:\r\n\t\t\trange = 270\r\n\t\t\t\r\n\t\tmessage = \"This car can go approx. \" + str(range)\r\n\t\tmessage += \" miles on a full charge.\"\r\n\t\tprint(message)", "def get_range(self):\n if self...
[ "0.59787583", "0.59501344", "0.5829102", "0.5819392", "0.5818934", "0.57981986", "0.5792976", "0.5778558", "0.5731891", "0.57078105", "0.56870514", "0.56870514", "0.56675357", "0.5645643", "0.56384957", "0.5616127", "0.55904025", "0.5577517", "0.5560445", "0.5550442", "0.5536...
0.55370027
20
Initializes the model parameters.
def __init__(self, hparams, batch_size=None, num_classes=None, summary_dir=None, verbose=False): self._model = None self._hparams = hparams self._verbose = verbose self._batch_size = batch_size self._num_classes = num_classes self._summary_dir = summary_dir
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, **kwargs):\n super(Model, self).__init__(**kwargs)\n self._params = self.find_params()", "def _initialize_model_params(self):\n\n if 'model' not in self._raw_data_dict:\n raise Error('The \"model\" key is not found in the configuration file. Looks like the parse...
[ "0.8004957", "0.76819557", "0.7654317", "0.75942737", "0.7463661", "0.7323001", "0.7311815", "0.7258441", "0.7244055", "0.72392327", "0.7186368", "0.71451765", "0.709025", "0.7045288", "0.7019865", "0.7001315", "0.69580907", "0.69482946", "0.69447833", "0.68896854", "0.684116...
0.0
-1
Builds an HParam object with default hyperparameters.
def default_hparams(): raise NotImplementedError('Not implemented')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_hparams():\n\n model_hparams = hparams.ModelHparams(\n model_name='imagenet_resnet_50',\n model_init='kaiming_normal',\n batchnorm_init='uniform',\n )\n\n dataset_hparams = hparams.DatasetHparams(\n dataset_name='imagenet',\n b...
[ "0.70342475", "0.7031786", "0.6892825", "0.67746496", "0.6762069", "0.6687497", "0.66754377", "0.6643588", "0.6621793", "0.65395397", "0.6534683", "0.6510586", "0.64588934", "0.6378265", "0.63729376", "0.63572174", "0.62473166", "0.62324756", "0.6184058", "0.61717397", "0.612...
0.74614435
0
Setup the model with specified hyperparameters and train the model.
def train(self, features, labels, seed=None): raise NotImplementedError('Not implemented')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_model(self, *args, **kwargs):\n raise NotImplementedError", "def _setupModel(self, parameters):\r\n ModelFitterCore.setupModel(self.roadrunnerModel, parameters,\r\n logger=self.logger)", "def train_model(self, *args, **kwargs):\n self.model.train(self.training, *args...
[ "0.7335617", "0.72743934", "0.7272043", "0.71031904", "0.70921487", "0.70791066", "0.70587295", "0.70124644", "0.6923429", "0.69174415", "0.68890333", "0.68263906", "0.6823547", "0.68021375", "0.6764099", "0.6710221", "0.6695851", "0.6694311", "0.66900265", "0.6688204", "0.66...
0.0
-1
Evaluates the trained model using the specified features and labels.
def evaluate(self, features, labels): raise NotImplementedError('Not implemented')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(model, eval_data, num_labels): \n # Turn on the evaluation state to ignore dropouts\n model.eval()\n results = [predict(model, x) for x, y in eval_data]\n f1_score, accuracy = get_metrics(np.array([y for x, y in eval_data]), results, num_labels)\n return f1_score, accuracy", "def m...
[ "0.71969485", "0.6895252", "0.68876994", "0.6868299", "0.6828266", "0.68280625", "0.6817962", "0.6815478", "0.6739548", "0.66729695", "0.66729695", "0.6669808", "0.6641863", "0.65919566", "0.6583201", "0.6532106", "0.6510232", "0.6506622", "0.65015924", "0.64879614", "0.64562...
0.8275948
0
Simple wrapper around sklearn's learning curve module
def learning_curve(self, features, labels): return learning_curve(self._model, features, labels)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train(self,features,y):\r\n \r\n if self.learn_type == \"nn\":\r\n #generate supervised dataset\r\n return(self.learner.train_on_batch(features,y))\r\n elif self.learn_type == \"linear\":\r\n grad = 0\r\n n = len(features)\r\n for i in...
[ "0.64221656", "0.63034314", "0.6246641", "0.6199103", "0.61902195", "0.6133346", "0.6075857", "0.6074158", "0.6016552", "0.5998704", "0.59975034", "0.59883845", "0.59740204", "0.59331024", "0.5884026", "0.58812094", "0.5867041", "0.58130425", "0.5809215", "0.5798471", "0.5792...
0.70836437
0
Create an agent membership
def create_agent_membership(self, context, agent_membership): am = agent_membership['agent_membership'] with context.session.begin(subtransactions=True): am_db = AgentMembership(id=am['id'], ip_address=am['ip_address']) context.session.add(am_db) return self._make_agent_membership_dict(am_db)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_member(self, body=None):\r\n return self.post(self.members_path, body=body)", "def add_member():\n client = RequestManager()\n client.set_method(\"POST\")\n client.set_endpoint(\"/accounts/{0}/memberships\".format(CONFIG_DATA['account_id']))\n body = {\"person_id\": ...
[ "0.6627206", "0.63848805", "0.6290456", "0.6268151", "0.62504977", "0.624233", "0.6192578", "0.59588885", "0.5937359", "0.59215134", "0.589374", "0.5893678", "0.58593506", "0.58082986", "0.58055055", "0.5803748", "0.580091", "0.5796165", "0.5793468", "0.57622015", "0.57265323...
0.7037421
0
Test load class works correctly and raises right exceptions.
def test_load_class(): full_classname = 'collections.namedtuple' cls_ = load_class(full_classname) assert cls_ is collections.namedtuple with pytest.raises(ValueError): full_classname = 'collections.Foobar' load_class(full_classname) with pytest.raises(ImportError): full_classname = 'barfoo.Foobar' load_class(full_classname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_testcase(self):\n tests = self.loader.load(\"tests.sampletest.hellotest.HelloTest\")\n self.assertEqual(len(tests), 1)\n from tests.sampletest.hellotest import HelloTest\n\n self.assertEqual(type(tests[0]), HelloTest)", "def test_load_testcase_in_module(self):\n t...
[ "0.7552986", "0.7182643", "0.70636034", "0.686629", "0.6754328", "0.67336494", "0.6622316", "0.6577228", "0.65132713", "0.6475406", "0.6446178", "0.6431292", "0.6425918", "0.63992125", "0.6388809", "0.6313314", "0.6301513", "0.62873274", "0.6244719", "0.62361884", "0.6233843"...
0.72938436
1
irq_handler contains the code you want to execute when the interrupt occurs. Define your own callback function here by rewriting the code. We make an LED flash in this example.
def irq_handler(): # open an LED session with LEDs() as LED: # specify the LED which you want to control led = Led.LED1 # specify the LED status led_on_off = True # writes values 10 times, which makes LED1 flash for 3 seconds for x in range(0, 10): # turn LED0 on or off LED.write(led, led_on_off) # add a short delay time.sleep(0.3) # if the LED is on, set the parameter to off # if the LED is off, set the parameter to on led_on_off = not led_on_off
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def irq(self, handler: Callable, trigger: int, hard: bool = False) -> Callable:", "def enable_irq(state:int):", "def extirq_cbf(task):\n try:\n if not execute_LM_function_Core(task.split(' ')):\n console_write(\"[IRQ] EXTIRQ execute_LM_function_Core error: {}\".format(task))\n except Ex...
[ "0.6793415", "0.59784335", "0.5772505", "0.5751147", "0.569456", "0.56923246", "0.55878675", "0.5526748", "0.53978044", "0.50646555", "0.4927286", "0.4895538", "0.47954524", "0.4737531", "0.4658877", "0.4636048", "0.46294534", "0.46239135", "0.45867148", "0.45833647", "0.4576...
0.72954494
0
Creates a newly initialised datasource with the specified training or test data. If _load_test_data and _load_training_data are implemented, they are called as well, and saving/loading is handled there.
def __init__(self, _expected_d_input=None, shuffled=False, _training_data=None, _test_data=None): self._training_data = _training_data self._test_data = _test_data self._num_training_samples = None self._num_test_samples = None self._available_training_lengths = [] self._available_test_lengths = [] self._training_data_path = os.path.join(type(self).__name__, "training_data.npy") if not os.path.isdir(type(self).__name__): os.mkdir(type(self).__name__) self._expected_d_input = _expected_d_input if self._training_data is None: if os.path.isfile(self._training_data_path): self._training_data = np.load(self._training_data_path).item() for _, value in self._training_data.items(): print(value[0].shape) print(_expected_d_input) if value[0].shape[2] != _expected_d_input: self._training_data = None break self._test_data_path = os.path.join(type(self).__name__, "testing_data.npy") if self._test_data is None: if os.path.isfile(self._test_data_path): self._test_data = np.load(self._test_data_path).item() for _, value in self._test_data.items(): if value[0].shape[2] != _expected_d_input: self._test_data = None break if self._test_data is None: self._load_test_data() if self._training_data is None: self._load_training_data() if shuffled: print("Shuffling not supported at this point!") self.current_index = {} for key, _ in self._training_data.items(): self.current_index[key] = 0 self._initialise_available_training_lengths() self._initialise_available_test_lengths() self._swapped_test_data = None self._swapped_training_data = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_creator(config):\n train_dataset, val_dataset = LinearDataset(2, 5), LinearDataset(2, 5)\n train_loader = DataLoader(train_dataset, batch_size=config[\"batch_size\"])\n val_loader = DataLoader(val_dataset, batch_size=config[\"batch_size\"])\n return train_loader, val_loader", "def _init_trai...
[ "0.66052645", "0.6420619", "0.63613456", "0.63351035", "0.6321313", "0.6239802", "0.62257236", "0.6179237", "0.61755306", "0.6175438", "0.6154874", "0.60897607", "0.6085115", "0.60844827", "0.60654354", "0.60575354", "0.6012859", "0.60088485", "0.59914017", "0.5959267", "0.59...
0.0
-1
This property returns the test data, and loads the test data if it doesn't exist. Note that this function returns the test data and labels in the form ([MPS input size, batch, other dimensions], [batch, classifications]) in accordance with how it is used in the MPS and MPSOptimizer classes. If the data is required in the form ([batch, MPS input size, other dimensions], [batch, classifications]), the variable _test_data should be used
def test_data(self): if self._test_data is None: self._load_test_data() if self._swapped_test_data is None: self._swapped_test_data = {} for key, value in self._test_data.items(): self._swapped_test_data[key] = value return self._swapped_test_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_data(self):\n\n return self.__valid_data, self.__valid_labels", "def get_data():\r\n if not path_validation(MODEL_PATH, read_access=True):\r\n exit(0) \r\n if not path_validation(TEST_DATA_PATH, read_access=True):\r\n exit(0) \r\n if not path_validation(TEST_LABEL_PATH, rea...
[ "0.70449495", "0.6995364", "0.6777924", "0.66745436", "0.65272325", "0.6480013", "0.6461336", "0.63587755", "0.63330346", "0.630707", "0.6300786", "0.6267064", "0.6254497", "0.62507844", "0.6207419", "0.62047035", "0.61748314", "0.6138185", "0.61186504", "0.6097096", "0.60467...
0.637961
7
Get test data (perhaps from remote server) and preprocess in shape [batch, expected shape of element]. Remember to call this from a subclass to save the things.
def _load_test_data(self): self._save_test_data()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_test_batch(self):\n data = self.data\n # size of train dataset\n num_train = data['train'].shape[0]\n image_size = self.image_size\n # index of test image that is being classified in this batch\n batch_index = self.test_batch_index\n\n # create batch array...
[ "0.6583765", "0.6574852", "0.6408957", "0.6383224", "0.63410145", "0.62234724", "0.6203767", "0.60811645", "0.60587937", "0.60369897", "0.60160315", "0.6011207", "0.6007375", "0.5988163", "0.5982726", "0.59650534", "0.5962204", "0.59511745", "0.59286445", "0.59174746", "0.590...
0.56260467
56
This property returns the training data, and loads the training data if it doesn't exist. Note that this function returns the training data and labels in the form ([MPS input size, batch, other dimensions], [batch, classifications]) in accordance with how it is used in the MPS and MPSOptimizer classes. If the data is required in the form ([batch, MPS input size, other dimensions], [batch, classifications]), the variable _training_data should be used
def training_data(self): if self._training_data is None: self._load_training_data() if self._swapped_training_data is None: self._swapped_training_data = {} for key, value in self._training_data.items(): self._swapped_training_data[key] = value return self._swapped_training_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_training_data(self) -> Tuple[List[np.ndarray], np.ndarray]:\n return self._load_set(config.TRAIN_DIR, True)", "def getTrainingData(self):\n raise NotImplementedError", "def get_training_data() -> GraphDataset:\n _load_data_if_needed()\n return training_data", "def get_data_train(...
[ "0.7380025", "0.71378094", "0.6946885", "0.69251007", "0.6852432", "0.6813262", "0.6799918", "0.6751542", "0.6742031", "0.6650401", "0.6590069", "0.65826356", "0.64915186", "0.6483886", "0.6470438", "0.6446683", "0.6443755", "0.62918407", "0.6268519", "0.6244086", "0.6243447"...
0.72757715
1
Get training data (perhaps from remote server) and preprocess in shape [batch, expected shape of element] Remember to call this from a subclass to save the things.
def _load_training_data(self): self._save_training_data()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTrainingData(self):\n raise NotImplementedError", "def preprocess_data(self):\n\n self._preprocess_train_data()\n self._preprocess_test_data()", "def preprocess_train_data(self):\r\n print(\"* Preprocessing training data.\", flush=True)\r\n prep.create_HDF_file(self.C....
[ "0.6737078", "0.6703798", "0.6572939", "0.6394934", "0.6370723", "0.6355788", "0.63249135", "0.63132846", "0.62849104", "0.62823945", "0.6275704", "0.6259968", "0.6241224", "0.62354356", "0.6223649", "0.6207623", "0.616901", "0.6163054", "0.6130993", "0.61243504", "0.611347",...
0.611388
20
Gets the next n data and label points from the training dataset, where n = batch_size length is the expected length of the inputs
def next_training_data_batch(self, batch_size, expected_length): if self._training_data is None: self._load_training_data() if expected_length in self._training_data: actual_length = expected_length else: differences = np.abs(self._available_training_lengths - expected_length) mininimum_loc = np.argmin(differences) actual_length = self._available_training_lengths[mininimum_loc] all_data, all_labels = self._training_data[actual_length] if batch_size > len(all_data): print("Probably shouldn't do this; your batch size is greater than the size of the dataset") data = None labels = None while batch_size > 0: if len(all_data) - self.current_index[actual_length] < batch_size: # print("A" + str(self.current_index)) batch_size -= (len(all_data) - self.current_index[actual_length]) if self.current_index[actual_length] != len(all_data): if data is None: data = np.array(all_data[self.current_index[actual_length]:]) labels = np.array(all_labels[self.current_index[actual_length]:]) else: data = np.concatenate((data, all_data[self.current_index[actual_length]:]), axis=0) labels = np.concatenate((labels, all_labels[self.current_index[actual_length]:]), axis=0) self.current_index[actual_length] = 0 else: # print("B" + str(self.current_index)) if data is None: data = all_data[self.current_index[actual_length]:self.current_index[actual_length] + batch_size] labels = np.array(all_labels[self.current_index[actual_length]:self.current_index[actual_length] + batch_size]) else: data = np.concatenate((data, all_data[self.current_index[actual_length]:self.current_index[actual_length] + batch_size]), axis=0) labels = np.concatenate((labels, all_labels[self.current_index[actual_length]:self.current_index[actual_length] + batch_size]), axis=0) self.current_index[actual_length] += batch_size batch_size = 0 data = np.array(data) data = np.swapaxes(data, 0, 1) return (actual_length, (data, labels))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_batch(data, labels, batch_size):\n global _index_in_epoch\n start = _index_in_epoch\n _index_in_epoch += batch_size\n _num_examples = len(data)\n\n if _index_in_epoch > _num_examples:\n # Shuffle the data\n perm = np.arange(_num_examples)\n np.random.shuffle(perm)\n ...
[ "0.74909896", "0.72481114", "0.7209859", "0.7209859", "0.7201162", "0.71773523", "0.7172384", "0.7135985", "0.7022579", "0.7018331", "0.700701", "0.69525987", "0.69326574", "0.6926339", "0.6913601", "0.6876563", "0.6874372", "0.6864877", "0.6839137", "0.6839137", "0.6784926",...
0.7202597
4
Property giving the number of training samples for each key
def num_train_samples(self): if self._num_training_samples is None: for key, value in self._training_data.items(): self._num_training_samples[key] = len(value[0]) return self._num_training_samples
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_training_examples(self):", "def get_num_train_samples(self):\n raise NotImplementedError", "def __len__(self):\n if self.TRAIN_BOOL is True:\n count = len(self.dict_batch_1[b'data'])\n count += len(self.dict_batch_2[b'data'])\n count += len(self.dict_batch...
[ "0.76472265", "0.72392845", "0.7154465", "0.71007866", "0.6989497", "0.6887514", "0.68653405", "0.6852151", "0.6844715", "0.680676", "0.6782863", "0.67534184", "0.6745939", "0.6720424", "0.670524", "0.66739583", "0.66528374", "0.66478294", "0.66011435", "0.659892", "0.6594394...
0.7513668
1
Property giving the number of test samples
def num_test_samples(self): if self._num_test_samples is None: for key, value in self._test_data.items(): self._num_test_samples[key] = len(value[0]) return self._num_test_samples
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _number_of_samples(self):\n return len(self._raw_data.samples)", "def setTestSampleSize(self, Ntest):\n self.Ntest = Ntest", "def getNrSamples(self): \r\n return self.numSamples", "def num_training_examples(self):", "def sample_count(self):", "def get_number_of_testing(self):\...
[ "0.76248336", "0.7584526", "0.7412485", "0.74109805", "0.7401342", "0.7390789", "0.72752166", "0.726213", "0.7233075", "0.7224675", "0.71610683", "0.71362716", "0.71249604", "0.70941573", "0.7070653", "0.704998", "0.70279443", "0.7010169", "0.6996375", "0.6985382", "0.6942792...
0.8134777
0
Parse nonchimeric alignments with walkspolicy mask with pysam backend.
def test_mock_pysam(): mock_sam_path = os.path.join(testdir, "data", "mock.sam") mock_chroms_path = os.path.join(testdir, "data", "mock.chrom.sizes") try: result = subprocess.check_output( [ "python", "-m", "pairtools", "parse", "--walks-policy", "mask", "-c", mock_chroms_path, mock_sam_path, ], ).decode("ascii") except subprocess.CalledProcessError as e: print(e.output) print(sys.exc_info()) raise e # check if the header got transferred correctly sam_header = [l.strip() for l in open(mock_sam_path, "r") if l.startswith("@")] pairsam_header = [l.strip() for l in result.split("\n") if l.startswith("#")] for l in sam_header: assert any([l in l2 for l2 in pairsam_header]) # check that the pairs got assigned properly for l in result.split("\n"): if l.startswith("#") or not l: continue print(l) assigned_pair = l.split("\t")[1:8] simulated_pair = l.split("CT:Z:SIMULATED:", 1)[1].split("\031", 1)[0].split(",") print(assigned_pair) print(simulated_pair) print() assert assigned_pair == simulated_pair
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recover_para_segmentations(aligned_data, gt_paras_sents, human_translator_data):\n sents_covered = 0\n outputs = \"\"\n for p1, s1, src in zip(aligned_data[\"gt_paras\"], gt_paras_sents, aligned_data[\"source_paras\"]):\n num_sents = len(s1)\n outputs += f\"<b>Source</> = {src}\\n<b>Goog...
[ "0.54760754", "0.53752476", "0.50093", "0.49865466", "0.49599963", "0.49551886", "0.49462736", "0.49260557", "0.48655975", "0.48339373", "0.48032323", "0.47868657", "0.47548297", "0.47518492", "0.47361124", "0.4728765", "0.47222483", "0.47153112", "0.4694921", "0.46828434", "...
0.0
-1
Parse all alignment in each read with walkspolicy all and pysam backend.
def test_mock_pysam_parse_all(): mock_sam_path = os.path.join(testdir, "data", "mock.parse-all.sam") mock_chroms_path = os.path.join(testdir, "data", "mock.chrom.sizes") try: result = subprocess.check_output( [ "python", "-m", "pairtools", "parse", "--walks-policy", "all", "-c", mock_chroms_path, "--add-pair-index", mock_sam_path, ], ).decode("ascii") except subprocess.CalledProcessError as e: print(e.output) print(sys.exc_info()) raise e # check if the header got transferred correctly sam_header = [l.strip() for l in open(mock_sam_path, "r") if l.startswith("@")] pairsam_header = [l.strip() for l in result.split("\n") if l.startswith("#")] for l in sam_header: assert any([l in l2 for l2 in pairsam_header]) # check that the pairs got assigned properly id_counter = 0 prev_id = "" for l in result.split("\n"): if l.startswith("#") or not l: continue if prev_id == l.split("\t")[0]: id_counter += 1 else: id_counter = 0 prev_id = l.split("\t")[0] assigned_pair = l.split("\t")[1:8] + l.split("\t")[-2:] simulated_pair = ( l.split("CT:Z:SIMULATED:", 1)[1] .split("\031", 1)[0] .split("|")[id_counter] .split(",") ) print(assigned_pair) print(simulated_pair, prev_id) print() assert assigned_pair == simulated_pair
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def align(aligner, reads):\n counter = 0\n for read in SeqIO.parse(reads, \"fasta\"): \n try:\n alignInfo = next(aligner.map(str(read.seq)))\n print(alignInfo) \n except StopIteration:\n print(read.format(\"fasta\"), end='')", "def align_reads(self):\n ...
[ "0.64816856", "0.6445793", "0.6301667", "0.62004644", "0.61849123", "0.6097089", "0.60698086", "0.58538115", "0.5847832", "0.5827765", "0.5823239", "0.581179", "0.581081", "0.57999784", "0.57905626", "0.57769024", "0.5743529", "0.5681", "0.5614261", "0.55853", "0.5562853", ...
0.4956526
87
Highlights currentSelection on stdscr.
def highlightSelection(stdscr, selection): s = tuple(list(selection.addStrArgs)+[curses.A_REVERSE]) stdscr.addstr(*s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def switchSelection(stdscr, lastSelection, currentSelection):\n stdscr.addstr(*lastSelection.addStrArgs)\n highlightSelection(stdscr, currentSelection)", "def draw_selected(self):\n if self.get_selected() is not None and not self.check_if_locked(self.get_selected()):\n self.color_cell(pos...
[ "0.77326286", "0.6310758", "0.62849665", "0.6241305", "0.6179359", "0.6145725", "0.6066579", "0.5976721", "0.59747756", "0.5841172", "0.5825609", "0.5814059", "0.57745796", "0.5750539", "0.5745168", "0.5714649", "0.56804645", "0.5667968", "0.5662644", "0.56395173", "0.5605114...
0.75370693
1
Removes highlight of lastSelection and highlights currentSelection.
def switchSelection(stdscr, lastSelection, currentSelection): stdscr.addstr(*lastSelection.addStrArgs) highlightSelection(stdscr, currentSelection)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unhighlight(self, current=False):\n if current:\n if self.currentEditor is not None:\n self.currentEditor.highlight()\n else:\n for editor in self.editors:\n editor.highlight()", "def Unselect(self):\r\n\r\n if self._current:\r\n ...
[ "0.71389216", "0.7015364", "0.65264606", "0.6345358", "0.63410205", "0.6158486", "0.61175185", "0.6002156", "0.59705675", "0.5914801", "0.5895148", "0.58718735", "0.5871529", "0.579935", "0.5699949", "0.56871504", "0.5649178", "0.5641103", "0.5631721", "0.5626519", "0.5604202...
0.66989064
2
Opens a display of the todoList for the user to select an item and choose an action to take.
def selectTodoItem(stdscr, todoList): selectionList = displayTodoList(stdscr, todoList) currentSelection = selectionList.current() highlightSelection(stdscr, currentSelection) while True: lastSelection = currentSelection k = stdscr.get_wch() if k in ['k', curses.KEY_UP]: currentSelection = selectionList.prev() elif k in ['j', curses.KEY_DOWN]: currentSelection = selectionList.next() elif k in ['d']: return Action(Action.REMOVE, currentSelection.todoItem) elif k == 'q': return None switchSelection(stdscr, lastSelection, currentSelection) stdscr.refresh()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trigger_open(self):\n self.get_selected()\n if self.selected_item:\n self.controller.display_item(self.selected_item)", "def do_todo_open(self, arg):\n try:\n open_list = arg[\"<list_param>\"]\n choice = arg[\"--choice\"]\n if choice == \"name\...
[ "0.7201459", "0.6838654", "0.6731044", "0.61206925", "0.61021215", "0.6093656", "0.6077997", "0.600439", "0.5995444", "0.59719115", "0.5954215", "0.5914398", "0.5907249", "0.584988", "0.58350575", "0.58085567", "0.5782954", "0.5759071", "0.57363194", "0.5728824", "0.5727189",...
0.5482432
50
Creates an initial display of todoList.
def displayTodoList(stdscr, todoList): stdscr.clear() i = 1 selectionList = SelectionList() for category in todoList.categories: stdscr.addstr(i, 1, '='*len(category)) stdscr.addstr(i+1, 1, category) stdscr.addstr(i+2, 1, '='*len(category)) i+=4 j = 1 for item in todoList[category]: stdscr.addstr(i, 1, str(j)+'. '+item.name) selectionList.append(Selection((i, 1, str(j)+'. '+item.name), item)) i += 1 j += 1 i += 1 return selectionList
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_todo_list_view(request: HttpRequest, pk: int) -> HttpResponse:\n todo_list = TodoListModel.objects.get(id=pk)\n\n return render(request, 'todo/display_todo_list.html', {'todo_list': todo_list})", "def __init__(self, todolist):\n\t\tself.todolist = todolist\n\t\tself.selection_id = None;\n\t\t\n...
[ "0.66892177", "0.6522817", "0.637842", "0.62759596", "0.6237733", "0.6173121", "0.61659193", "0.602686", "0.59981143", "0.59325516", "0.5924609", "0.59100825", "0.5881322", "0.58435386", "0.58121586", "0.5809451", "0.5808901", "0.58015496", "0.5759406", "0.573308", "0.5713373...
0.62428325
4
This initializes the DotStars object by setting a buffer, and creating an SPI object. The start and end frames for the SPI communication are created, and the leds are cleared of values.
def __init__(self, leds): self.ledcount = leds # create a buffer self.buffersize = self.ledcount * 4 self.buffer = bytearray(self.ledcount * 4) self.emptybuffer = bytearray(self.ledcount * 4) for i in range(0, self.buffersize, 4): self.emptybuffer[i] = 0xff self.emptybuffer[i + 1] = 0x0 self.emptybuffer[i + 2] = 0x0 self.emptybuffer[i + 3] = 0x0 # Start frame and endframe for the SPI communication (end frame is not # needed) self.startframe = bytes([0x00, 0x00, 0x00, 0x00]) self.endframe = bytes([0xff, 0xff, 0xff, 0xff]) # initialize SPI (needs to be at 45 MHz in order to maximize the speed. # This is the limiting factor for the system's speed) self.spi = SPI(1, SPI.MASTER, baudrate=45000000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB) self.clearleds()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, spi, dc, rst, led):\n self._spi = spi\n self._spi.open()\n self._spi.set_mode(0)\n self._spi.set_clock_frequency(4000000)\n\n self._dc = dc\n self._rst = rst\n self._led = led\n self._enabled = False", "def SPIsetup(self):\n self.w...
[ "0.6566145", "0.6351516", "0.63373953", "0.6181888", "0.61446565", "0.6111663", "0.59349567", "0.57059205", "0.55544007", "0.554452", "0.5522998", "0.5509588", "0.5503774", "0.5380477", "0.53760433", "0.5336554", "0.5321746", "0.5299691", "0.52520025", "0.5248618", "0.5240898...
0.74753237
0
This method clears all the LEDs in the DotStar object
def clearleds(self): self.buffer = self.emptybuffer[:]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n for tlight in self.trafficLights:\n self.trafficLights[tlight].reset()", "def clear(tft, oled):\n oled.fill(tft.BLACK)", "def clear(self):\n self._delayvalue = _CFG[\"delay\"]\n self._colormode = _CFG[\"colormode\"]\n self._delete(\"all\")\n ...
[ "0.7280109", "0.71445733", "0.70629704", "0.7045428", "0.7045238", "0.6974367", "0.6902242", "0.6812371", "0.679938", "0.6789614", "0.6783468", "0.6701193", "0.6695715", "0.66421294", "0.6637276", "0.6621712", "0.6612257", "0.6599522", "0.6587036", "0.6560823", "0.65587413", ...
0.7821158
0
This sets the led to the specified color
def setled(self, led, red=0, green=0, blue=0): # Set the offset for the bytes to be sent over SPI offset = led * 4 self.buffer[offset] = 255 # equals a 1 or 0 self.buffer[offset + 1] = blue self.buffer[offset + 2] = green self.buffer[offset + 3] = red
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_color(self, color):\n pass", "def led(color: int, /) -> None:", "def set_color(self, color):\n\t\tpass", "def set_status_led(self, color):\n raise NotImplementedError", "def set_led_color(color):\n requests.post('http://192.168.4.1/pixel', data=json.dumps(color))", "def set_color...
[ "0.79685086", "0.7963265", "0.7882642", "0.7830038", "0.7777075", "0.7772559", "0.7689048", "0.7609751", "0.7561696", "0.7547319", "0.7526898", "0.75140256", "0.74926007", "0.7445177", "0.74438715", "0.7430585", "0.741375", "0.73898387", "0.73771507", "0.7346666", "0.7305123"...
0.76878345
7
This method send the led data over SPI
def send(self): self.spi.send(self.startframe + self.buffer)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send(self, data):\n self._serial.write('spi = SPI(2, SPI.SLAVE, baudrate=500000, polarity=0, phase=0)\\r\\n'.encode('utf-8'))\n self._serial.write('data=bytearray({})\\r\\n'.format(data).encode('utf-8'))\n self._serial.write('spi.send(data, timeout=50000)\\r\\n'.encode('utf-8'))\n s...
[ "0.79480565", "0.75796175", "0.74145585", "0.71241754", "0.70519936", "0.7026349", "0.69845456", "0.69544286", "0.68782145", "0.68735623", "0.6855078", "0.6780902", "0.67396015", "0.6739508", "0.6665076", "0.66579545", "0.6576727", "0.6573629", "0.6531924", "0.6527273", "0.64...
0.58544874
44
Extracts function arguments for the decorated function.
def _extract_func_args( obj: str, arg_formats: Dict[str, int], arg_defaults: Dict[str, Any], input_dict: Dict[str, List[tfx_types.Artifact]], output_dict: Dict[str, List[tfx_types.Artifact]], exec_properties: Dict[str, Any], beam_pipeline: Optional[_BeamPipeline] = None, ) -> Dict[str, Any]: result = {} for name, arg_format in arg_formats.items(): if arg_format == function_parser.ArgFormats.INPUT_ARTIFACT: input_list = input_dict.get(name, []) if len(input_list) == 1: result[name] = input_list[0] elif not input_list and name in arg_defaults: # Do not pass the missing optional input. pass else: raise ValueError( ('Expected input %r to %s to be a singleton ValueArtifact channel ' '(got %s instead).') % (name, obj, input_list)) elif arg_format == function_parser.ArgFormats.OUTPUT_ARTIFACT: output_list = output_dict.get(name, []) if len(output_list) == 1: result[name] = output_list[0] else: raise ValueError( ('Expected output %r to %s to be a singleton ValueArtifact channel ' '(got %s instead).') % (name, obj, output_list)) elif arg_format == function_parser.ArgFormats.ARTIFACT_VALUE: input_list = input_dict.get(name, []) if len(input_list) == 1: result[name] = input_list[0].value elif not input_list and name in arg_defaults: # Do not pass the missing optional input. pass else: raise ValueError( ('Expected input %r to %s to be a singleton ValueArtifact channel ' '(got %s instead).') % (name, obj, input_list)) elif arg_format == function_parser.ArgFormats.PARAMETER: if name in exec_properties: result[name] = exec_properties[name] elif name in arg_defaults: # Do not pass the missing optional input. pass else: raise ValueError( ('Expected non-optional parameter %r of %s to be provided, but no ' 'value was passed.') % (name, obj)) elif arg_format == function_parser.ArgFormats.BEAM_PARAMETER: result[name] = beam_pipeline if name in arg_defaults and arg_defaults[name] is not None: raise ValueError('beam Pipeline parameter does not allow default ', 'value other than None.') else: raise ValueError('Unknown argument format: %r' % (arg_format,)) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_captured_arguments(func):\n captured_arguments = getattr(func, ATTR_NAME)\n if type(captured_arguments) is not _CapturedArguments: # pylint: disable=unidiomatic-typecheck\n # The attribute was not set by tcm, so effectively it does not exist.\n raise AttributeError\n delattr(fun...
[ "0.73196673", "0.72977483", "0.70101774", "0.69297165", "0.67886466", "0.6777163", "0.66621184", "0.66599494", "0.6646892", "0.6559392", "0.6559392", "0.6526404", "0.6525048", "0.6484637", "0.6477483", "0.63901955", "0.6309247", "0.6304008", "0.6285241", "0.6279031", "0.62567...
0.0
-1
Validates and assigns the outputs to the output_dict.
def _assign_returned_values( function, outputs: Dict[str, Any], returned_values: Dict[str, Any], output_dict: Dict[str, List[tfx_types.Artifact]], json_typehints: Dict[str, Type], # pylint: disable=g-bare-generic ) -> Dict[str, List[tfx_types.Artifact]]: result = copy.deepcopy(output_dict) if not isinstance(outputs, dict): raise ValueError( ('Expected component executor function %s to return a dict of ' 'outputs (got %r instead).') % (function, outputs)) # Assign returned ValueArtifact values. for name, is_optional in returned_values.items(): if name not in outputs: raise ValueError( 'Did not receive expected output %r as return value from ' 'component executor function %s.' % (name, function)) if not is_optional and outputs[name] is None: raise ValueError('Non-nullable output %r received None return value from ' 'component executor function %s.' % (name, function)) try: result[name][0].value = outputs[name] except TypeError as e: raise TypeError( ('Return value %r for output %r is incompatible with output type ' '%r.') % (outputs[name], name, result[name][0].__class__)) from e # Handle JsonValue runtime type check. if name in json_typehints: ret = function_parser.check_strict_json_compat(outputs[name], json_typehints[name]) if not ret: raise TypeError( ('Return value %r for output %r is incompatible with output type ' '%r.') % (outputs[name], name, json_typehints[name])) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_output_dictionary(self):\n\n return_dictionary = {}\n\n for output_path in self.provided_outputs:\n return_dictionary[output_path.full_path] = self.get_value(output_path)\n\n return return_dictionary", "def _check_output_observable_dict(\n self, output_observab...
[ "0.6837641", "0.67924696", "0.6737341", "0.6717199", "0.65907484", "0.64653313", "0.64050525", "0.6332762", "0.6276232", "0.62465364", "0.62231946", "0.61539495", "0.6134005", "0.61062723", "0.6100173", "0.60465825", "0.60387117", "0.6037164", "0.60108835", "0.60005236", "0.5...
0.5601338
53
View all the images in the dataset, on a 3 by X grid size.
def view_images(dataset, size): images, labels = dataset assert images.shape[0] == labels.shape[0] num_images = images.shape[0] num_cols = 3 num_rows = np.ceil(num_images / num_cols).astype("int") plt.figure(figsize=size) for i in range(num_images): image = images[i] label = labels[i] ax = plt.subplot(num_rows, num_cols, i + 1) plt.imshow(np.array(image, dtype="float")) plt.title("Number: " + str(label)) plt.axis("off")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_imgs(dataset, n_imgs, plot_size=(15, 15), cmap=None):\n n_cols = int(np.sqrt(n_imgs))\n n_rows = int(np.ceil(np.sqrt(n_imgs)))\n class_idx = dataset.class_to_idx\n idx_class = idx_to_class(class_idx)\n\n fig, axes = plt.subplots(n_rows, n_cols, figsize=plot_size)\n for i, ax in enumerate...
[ "0.6872789", "0.6706518", "0.66048354", "0.65576744", "0.6477456", "0.6438162", "0.64273864", "0.6386546", "0.6381494", "0.63184965", "0.6311449", "0.62808603", "0.6278003", "0.6259482", "0.6259482", "0.62534124", "0.6243781", "0.6227257", "0.6224085", "0.6216505", "0.6158989...
0.760682
0
Normalises and reshapes the images in the dataset.
def normalise(dataset): # Scale images to the [0, 1] range dataset = dataset.astype("float32") / 255 # Make sure images have shape (28, 28, 1) return np.expand_dims(dataset, -1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_dataset(self):", "def normalize_images(data, blend_cat, Args):\n im = data['X_train']['blend_image']\n std = np.std(im)\n mean = np.mean(im)\n data['X_train']['blend_image'] = (im - mean) / std\n data['X_val']['blend_image'] = (data['X_val']['blend_image'] - mean) / std\n data['X_...
[ "0.69572496", "0.67912114", "0.67600954", "0.6746723", "0.6741553", "0.6741553", "0.6712757", "0.667788", "0.66753983", "0.66424495", "0.6628572", "0.6604109", "0.657797", "0.65456814", "0.6539488", "0.64729387", "0.6469001", "0.64613545", "0.6418981", "0.63990253", "0.639689...
0.7404679
0
Randomly chooses some data from the dataset.
def choice(dataset, size): x, y = dataset assert x.shape[0] == y.shape[0] num_datapoints = x.shape[0] mask = np.zeros(num_datapoints).astype("bool") mask[:size] = True np.random.default_rng().shuffle(mask) return x.compress(mask, axis=0), y.compress(mask, axis=0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRandom(self):\n return random.choice(self.data)", "def data_source():\n dataset = [0.1, 0.2, 0.3, 0.4, 0.5]\n while True:\n time.sleep(2)\n yield random.choice(dataset)", "def randomRow(self):\r\n l = []\r\n for row in self.data:\r\n l.append(row)\r\n ...
[ "0.73725927", "0.7179318", "0.70049816", "0.6915993", "0.68809456", "0.6742614", "0.66800225", "0.6568194", "0.65536875", "0.65441173", "0.6533348", "0.652268", "0.65050435", "0.64911234", "0.6435912", "0.64282745", "0.6402564", "0.6368382", "0.63608557", "0.6303325", "0.6302...
0.65095335
12
__init__(self, filename) Create a configparser object and store config values in class variables for later retrieval
def __init__(self, filename="config.ini"): if not os.path.isfile(filename): self.set_default_config(filename) self.config = configparser.ConfigParser() self.config.read(filename) self.filename = filename self.database_name = self.config.get('config', 'database_name', fallback='manga.db') self.volume_limit = self.config.getint('config', 'volume_limit', fallback=128) self.series_per_page = self.config.getint('config', 'series_per_page', fallback=0) self.compact_list = self.config.getboolean('config', 'compact_list', fallback=False) self.show_empty_series = self.config.getboolean('config', 'show_empty_series', fallback=False) self.default_to_gui = self.config.getboolean('config', 'default_to_gui', fallback=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, filename, dirname='~'):\n self.config = configparser.ConfigParser()\n\n expanded_dirname = os.path.expanduser(dirname)\n self.configuration_filename = os.path.join(expanded_dirname, filename)\n if os.path.isfile(self.configuration_filename):\n self.config.r...
[ "0.8556377", "0.8332688", "0.83071285", "0.83033603", "0.80947435", "0.80304974", "0.79447347", "0.7944664", "0.7938114", "0.79321945", "0.7806958", "0.77945864", "0.7792556", "0.777831", "0.7728286", "0.7725837", "0.77198017", "0.7715732", "0.7694171", "0.768226", "0.7636645...
0.792374
10
set_property(self, prop_name, prop_value) Set a config property to a new value. Checks to ensure that prop_name refers to a valid property, and prop_value is a valid value for that property
def set_property(self, prop_name, prop_value): if prop_name == "database_name": if (prop_value and isinstance(prop_value, str) and prop_value[-3:] == ".db"): self.config["config"]["database_name"] = prop_value self.database_name = prop_value elif prop_name == "volume_limit": if isinstance(prop_value, int) and prop_value > 0: self.config["config"]["volume_limit"] = str(prop_value) self.volume_limit = prop_value elif prop_name == "series_per_page": if isinstance(prop_value, int) and prop_value >= 0: self.config["config"]["series_per_page"] = str(prop_value) self.series_per_page = prop_value elif prop_name == "compact_list": if ((isinstance(prop_value, int) and prop_value in [0, 1]) or isinstance(prop_value, bool)): self.config["config"]["compact_list"] = str(prop_value) self.compact_list = prop_value elif prop_name == "show_empty_series": if ((isinstance(prop_value, int) and prop_value in [0, 1]) or isinstance(prop_value, bool)): self.config["config"]["show_empty_series"] = str(prop_value) self.show_empty_series = prop_value elif prop_name == "default_to_gui": if ((isinstance(prop_value, int) and prop_value in [0, 1]) or isinstance(prop_value, bool)): self.config["config"]["default_to_gui"] = str(prop_value) self.default_to_gui = prop_value with open(self.filename, 'w') as config_ini: self.config.write(config_ini)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetProp(self, name, value):\n self._props[name] = value\n self._changed(name, value)", "def set_prop(prop, value, config_type=\"\", config_path=\"\"):\n\n path = get_config_path(config_type, config_path)\n set_property_value(prop, value, path)", "def set_property(self, name, value):\n ...
[ "0.7744824", "0.7589677", "0.7511228", "0.71817976", "0.7180543", "0.71250933", "0.70207524", "0.6867484", "0.6805842", "0.66848767", "0.6684025", "0.6615753", "0.64751947", "0.6462285", "0.6445133", "0.6340753", "0.6315831", "0.6308148", "0.62673914", "0.6257923", "0.6245488...
0.7238388
3
set_default_config() Saves default config to desired filename
def set_default_config(self, filename): if os.path.isfile(filename): os.remove(filename) config = configparser.ConfigParser() default_cfg = {'config': {'database_name': 'manga.db', 'volume_limit': 128, 'series_per_page': 0, 'compact_list': 0, 'show_empty_series': False, 'default_to_gui': True}} config.read_dict(default_cfg) with open(filename, 'w') as config_ini: config.write(config_ini) # Reset class variables for config object as well self.config = config self.filename = filename self.database_name = 'manga.db' self.volume_limit = 128 self.series_per_page = 0 self.compact_list = False self.show_empty_series = False self.default_to_gui = True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writeDefaultConfig(conffile='default.conf', defaults={}):\n if not os.path.exists(conffile):\n cp = createConfigParserfromDict(defaults, ['base'])\n cp.write(open(conffile,'w'))\n return conffile", "def write_default_config():\n # TODO: BROKEN!\n config_path = pathlib.Path(xdg.BaseD...
[ "0.7795459", "0.76893884", "0.7577117", "0.7335307", "0.7192635", "0.71420926", "0.71333855", "0.7080361", "0.70510966", "0.7046068", "0.70410866", "0.7012563", "0.70065206", "0.693917", "0.6721765", "0.6714416", "0.67111033", "0.66713166", "0.66688925", "0.66178155", "0.6423...
0.67744064
14