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
Create psql schema if not exists
def create_psql_schema(): conn = connect_to_postgres() if conn is None: return cur = conn.cursor() try: create_scheme_command = """ CREATE TABLE IF NOT EXISTS article ( id serial ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_schema(schema): \n\n query = \"CREATE SCHEMA IF NOT EXISTS {}\".format(schema)\n qdb.execute(query)", "def create_schema(query_root, host, port, db_name, user, password):\n try:\n conn = PGDB(host, port, db_name, user, password)\n try:\n conn.executeQueryFromFile(os.p...
[ "0.81544256", "0.77055806", "0.7497276", "0.74456424", "0.7393814", "0.7380695", "0.73745346", "0.7171981", "0.7128249", "0.7060936", "0.7000325", "0.69722676", "0.69573975", "0.6849358", "0.681153", "0.680344", "0.6766765", "0.6765254", "0.67648685", "0.672596", "0.667012", ...
0.7700555
2
Parse site and save data to databases
def parse(): G.go(SITE_URL) articles = [] for article in G.doc.select("//li[@class='regularitem']"): header = article.select('h4').text() text = article.select('div').text() url = article.select('h4/a/@href').text() dt_string = article.select('h5').text() # for date f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n\n conn = psycopg2.connect(**env.DATABASE)\n cursor = conn.cursor()\n\n for file, city in env.supported_cities().items():\n try:\n data = add_metadata(parse_html(city, get_html(city)))\n save_data_to_db(cursor, data, file.title())\n except Exception as e:\n...
[ "0.6539816", "0.6336807", "0.6209232", "0.58123845", "0.5725888", "0.5696291", "0.56313646", "0.56097174", "0.5586455", "0.55671376", "0.554704", "0.55415875", "0.5540671", "0.55284095", "0.5500706", "0.54944265", "0.549438", "0.54509497", "0.5435737", "0.54172915", "0.541244...
0.0
-1
Save articles in postgres db
def save_article_if_new_postgres(articles): conn = connect_to_postgres() if conn is None: return cur = conn.cursor() for article in articles: # check if already written in DB and write if not insert_command = """ INSERT INTO article ( header, url, dt,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_article(title,image,description,content,pub_date,news_url,note,user):\n article = Article(\n title=title,\n image=image,\n description=description,\n content = content,\n pub_date=datetime.strptime(pub_date, \"%Y-%m-%dT%H:%M:%SZ\"),\n news_url=news_url\n ...
[ "0.73172563", "0.6863781", "0.6768949", "0.65381116", "0.6503976", "0.64485466", "0.63395226", "0.6312849", "0.6307352", "0.6274374", "0.6257384", "0.625451", "0.62285715", "0.6206362", "0.61266017", "0.61232036", "0.6103075", "0.607053", "0.60469747", "0.6026209", "0.6017043...
0.75139326
0
Save articles in mongo db
def save_articles_mongo(articles): myclient = pymongo.MongoClient("mongodb://{host}:{port}/".format(host=os.environ['MONGO_HOST'], port=os.environ['MONGO_PORT'])) mongo_db = myclient[os.environ['MONGO_DATABASE']] col = mongo_db['artic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_new_article(article: Article = Body(...)):\n article_to_insert = article.dict()\n\n res = articles_db.post_articles_mongo(\n articles,\n keywords,\n article_to_insert\n )\n return res", "def save_article(title,image,description,content,pub_date,news_url,note,user):\n ...
[ "0.73897463", "0.6997813", "0.65601164", "0.6556793", "0.652823", "0.64266276", "0.6244929", "0.62407756", "0.62350714", "0.6227737", "0.61431664", "0.61152697", "0.6031079", "0.6001613", "0.5997048", "0.5939616", "0.59179276", "0.5911599", "0.5878683", "0.5847209", "0.584200...
0.77447826
0
Write articles for a specific date to CSV file resultsfile.csv
def retrieve_data_for_specific_date(articles_date): conn = connect_to_postgres() if conn is None: return cur = conn.cursor() query = "SELECT url, header, text, dt FROM article WHERE DATE(dt) = '{date}'".format(date=articles_date) outputquery = "COPY ({0}) TO STDOUT WITH DELIMITER ';' CSV HE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_to_file(self, results):\n with open(self.outputFilename, \"w\") as csvFile:\n csvWriter = csv.writer(csvFile, delimiter=',') \n title_row = ('asset_id', 'component_id', 'latitude', 'longitude', 'installation_date', 'commissioning_date', 'street_name', 'cabinet_id', 'nominal...
[ "0.71165556", "0.67996395", "0.6601403", "0.6560274", "0.649295", "0.64271957", "0.6424851", "0.6422594", "0.64133316", "0.62774163", "0.62692654", "0.62142366", "0.621073", "0.6196222", "0.61850923", "0.6164418", "0.61497664", "0.6112314", "0.6108876", "0.6106222", "0.609581...
0.7286791
0
Get article body by url
def get_article_body(url): G.go(url) text = G.doc.select('////div[@class="StandardArticleBody_body"]').text() return text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_article_body(url):\n headers = {'User-Agent': 'Codeup Data Science'}\n response = get(url, headers=headers)\n soup = BeautifulSoup(response.content, \"html.parser\") \n return soup.find('div', itemprop='text').text", "def get_news_text(news_url: str):\n print(\"Getting Article Content..\"...
[ "0.80219", "0.72327757", "0.7176655", "0.71069115", "0.7102558", "0.70835567", "0.6839535", "0.6642274", "0.6600342", "0.6591846", "0.6425075", "0.6403817", "0.6382481", "0.6372149", "0.6269961", "0.6259513", "0.625738", "0.6211645", "0.6158588", "0.6148016", "0.6120894", "...
0.79432315
1
compute the normalized distance transform map of foreground in binary mask
def compute_dtm01(img_gt, out_shape): normalized_dtm = np.zeros(out_shape) for b in range(out_shape[0]): # batch size # ignore background for c in range(1, out_shape[1]): posmask = img_gt[b].astype(np.bool) if posmask.any(): posdis = distance(posmask...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distMap(frame1, frame2):\r\n frame1_32 = np.float32(frame1)\r\n frame2_32 = np.float32(frame2)\r\n diff32 = frame1_32 - frame2_32\r\n norm32 = np.sqrt(diff32[:,:,0]**2 + diff32[:,:,1]**2 + diff32[:,:,2]**2)/np.sqrt(255**2 + 255**2 + 255**2)\r\n dist = np.uint8(norm32*255)\r\n return dist", ...
[ "0.6193267", "0.611686", "0.611686", "0.60621953", "0.60425967", "0.595029", "0.5920848", "0.5801215", "0.5768308", "0.56993896", "0.56273305", "0.56179357", "0.5551287", "0.55458856", "0.54960704", "0.5495191", "0.548971", "0.54587877", "0.5458727", "0.5453884", "0.5451818",...
0.5607268
12
compute the distance transform map of foreground in binary mask
def compute_dtm(img_gt, out_shape): fg_dtm = np.zeros(out_shape) for b in range(out_shape[0]): # batch size for c in range(1, out_shape[1]): posmask = img_gt[b].astype(np.bool) if posmask.any(): posdis = distance(posmask) fg_dtm[b][c] = posdis ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distMap(frame1, frame2):\r\n frame1_32 = np.float32(frame1)\r\n frame2_32 = np.float32(frame2)\r\n diff32 = frame1_32 - frame2_32\r\n norm32 = np.sqrt(diff32[:,:,0]**2 + diff32[:,:,1]**2 + diff32[:,:,2]**2)/np.sqrt(255**2 + 255**2 + 255**2)\r\n dist = np.uint8(norm32*255)\r\n return dist", ...
[ "0.6297242", "0.622284", "0.622284", "0.6207562", "0.61201155", "0.6047444", "0.60334665", "0.5835683", "0.58094954", "0.58044654", "0.5784289", "0.57662785", "0.5657348", "0.5597996", "0.55844146", "0.55831397", "0.55733967", "0.5535355", "0.5475472", "0.5433394", "0.5418763...
0.5752258
12
compute huasdorff distance loss for binary segmentation
def hd_loss(seg_soft, gt, seg_dtm, gt_dtm): delta_s = (seg_soft[:,1,...] - gt.float()) ** 2 s_dtm = seg_dtm[:,1,...] ** 2 g_dtm = gt_dtm[:,1,...] ** 2 dtm = s_dtm + g_dtm multipled = torch.einsum('bxyz, bxyz->bxyz', delta_s, dtm) hd_loss = multipled.mean() return hd_loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def one_hot2dist(seg):\n\n C = seg.shape[0]\n res = np.zeros_like(seg)\n for c in range(1, C): # background is excluded (C=0)\n posmask = seg[c].astype(np.bool)\n if posmask.any():\n negmask = ~posmask\n res[c] = distance(negmask) * negmask - (distance(posmask) - 1) * ...
[ "0.6661529", "0.64099824", "0.6366204", "0.6363473", "0.6323493", "0.6294771", "0.6266017", "0.6199597", "0.6166965", "0.61504185", "0.61312085", "0.611591", "0.61024386", "0.60867727", "0.6085334", "0.60677123", "0.60288733", "0.598568", "0.59616965", "0.59327346", "0.591597...
0.658907
1
Plot the game board.
def draw_gameBoard(self): # 15 horizontal lines for i in range(9): start_pixel_x = (i + 1) * CELL_PIXELS start_pixel_y = (0 + 1) * CELL_PIXELS end_pixel_x = (i + 1) * CELL_PIXELS end_pixel_y = (9 + 1) * CELL_PIXELS self.create_line(start_pixel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_game(self):\n display = plt.figure()\n\n # Plots dots.\n for dot in self.dots:\n plt.scatter(dot.x + .5, dot.y + .5, color=dot.color, s=1000)\n\n # Makes a uniform grid,\n axes = display.gca()\n axes.set_aspect('equal', adjustable='box')\n axe...
[ "0.7858056", "0.72502124", "0.7214515", "0.7201967", "0.7029387", "0.69352525", "0.6921453", "0.6867675", "0.6835099", "0.6799645", "0.67796713", "0.6748692", "0.6730312", "0.6723405", "0.6704865", "0.6669026", "0.66521883", "0.664082", "0.6609495", "0.6582655", "0.65821016",...
0.7261132
1
Draw a "star" on a given intersection
def draw_star(self, row, col): start_pixel_x = (row + 1) * CELL_PIXELS - 2 start_pixel_y = (col + 1) * CELL_PIXELS - 2 end_pixel_x = (row + 1) * CELL_PIXELS + 2 end_pixel_y = (col + 1) * CELL_PIXELS + 2 self.create_oval(start_pixel_x, start_pixel_y, end_pixel_x, end_pixel_y, fil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersection(x, y, f, p):", "def intersection(self, other): # -> BaseGeometry:\n ...", "def draw_star(x=0,y=0,radius=10):\n cx = x\n cy = y+radius\n bx = cx * math.cos(2*math.pi/3) - ( cy * math.sin(2*math.pi/3) )\n by = cx * math.sin(2*math.pi/3) + ( cy * math.cos(2*math.pi/3) )\n a...
[ "0.65930504", "0.6052898", "0.600595", "0.5820242", "0.58019805", "0.579242", "0.5746416", "0.57318807", "0.5646714", "0.56313306", "0.5611379", "0.5587743", "0.55852896", "0.557082", "0.5544653", "0.5444352", "0.5416826", "0.5405951", "0.54047537", "0.5399023", "0.5370266", ...
0.5407956
17
Draw a stone (with a circle on it to denote latest move) on a given intersection. Specify the color of the stone depending on the turn.
def draw_stone(self, row, col, color): inner_start_x = (row + 1) * CELL_PIXELS - 12 inner_start_y = (col + 1) * CELL_PIXELS - 12 inner_end_x = (row + 1) * CELL_PIXELS + 12 inner_end_y = (col + 1) * CELL_PIXELS + 12 outer_start_x = (row + 1) * CELL_PIXELS - 14 outer_star...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_housing():\n tess.pensize(3)\n tess.color(\"black\", \"darkgrey\")\n tess.begin_fill()\n tess.forward(80)\n tess.left(90)\n tess.forward(200)\n tess.circle(40, 180)\n tess.forward(200)\n tess.left(90)\n tess.end_fill()", "def highlight(self,screen,midpos = (800,450)):\n ...
[ "0.57206583", "0.56725216", "0.55646384", "0.55009794", "0.5484358", "0.54014266", "0.5391837", "0.5253059", "0.5235339", "0.5224439", "0.51809907", "0.512658", "0.5119194", "0.51087695", "0.50971544", "0.50619656", "0.5046779", "0.5035433", "0.50342214", "0.5009946", "0.5005...
0.56522876
2
Create a group in Keycloak
def create(self, name, **kwargs): payload = OrderedDict(name=name) for key in GROUPS_KWARGS: if key in kwargs: payload[to_camel_case(key)] = kwargs[key] return self._client.post( url=self._client.get_full_url( self.get_path('collection', r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_group():\n groupname = request.get_json().get(\"name\")\n description = request.get_json().get(\"description\")\n grp = admin.create_group(current_app.scoped_session(), groupname, description)\n if grp:\n response = admin.get_group_info(current_app.scoped_session(), groupname)\n el...
[ "0.76710826", "0.76241016", "0.7566701", "0.74329644", "0.7428723", "0.7428723", "0.73239356", "0.7273208", "0.7199069", "0.71675706", "0.7044097", "0.70311344", "0.6958737", "0.6930848", "0.6885804", "0.686129", "0.6823957", "0.68154734", "0.67869157", "0.67863613", "0.67823...
0.0
-1
Get group by given path
def by_path(self, path): return self._client.get( url=self._client.get_full_url( self. get_path('by_path', realm=self._realm_name, group_path=path) ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_group(group_data,path):\n path_name = path.label()\n group_name = re.sub(r'[0-9]+','',path_name)\n if group_name not in group_data:\n group_data[group_name] = len(group_data.keys())\n return group_data[group_name]", "def get_existing_group(self, path, id, name):\n v_id = re.matc...
[ "0.772978", "0.6525223", "0.64835656", "0.6461817", "0.63495713", "0.6327463", "0.6285342", "0.6127037", "0.60188633", "0.5930976", "0.5804726", "0.5801799", "0.5779514", "0.57688206", "0.5748913", "0.5744108", "0.57338333", "0.5729888", "0.5722318", "0.56843024", "0.5631451"...
0.6660683
1
Move a group as a subgroup to other group
def move(self, from_id, to_id): return self._client.post( url=self._client.get_full_url( self.get_path( 'children', realm=self._realm_name, group_id=to_id ) ), data=json.dumps({ 'id': from_id }) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_drag_group_into_group(self):\r\n expected_ordering = [{self.container_title: [self.group_a, self.group_empty]},\r\n {self.group_a: [self.group_b, self.group_a_item_1, self.group_a_item_2]},\r\n {self.group_b: [self.group_b_item_1, self.group_b...
[ "0.682986", "0.6606131", "0.6401541", "0.63874173", "0.62936264", "0.6221954", "0.6155218", "0.6143699", "0.6114369", "0.60979855", "0.6032083", "0.60089976", "0.5966626", "0.59524125", "0.5920026", "0.590848", "0.59053916", "0.58632976", "0.58456236", "0.5844179", "0.5842801...
0.54314286
60
Move group to root
def move_to_root(self, group_id, name): return self._client.post( url=self._client.get_full_url( self.get_path('collection', realm=self._realm_name) ), data=json.dumps({ 'id': group_id, 'name': name }) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setRoot(self):\n if self.state == BaseEditMode.ES_None:\n sheet = self._logic._getSheet()\n layout = sheet.getLayoutGroup()\n \n import suit.core.layout.LayoutGroupRadial as radialLayout\n if not isinstance(layout, radialLayout.LayoutGroupRadialSim...
[ "0.6359244", "0.6358635", "0.6273549", "0.6110124", "0.6003973", "0.5983621", "0.5983621", "0.5983621", "0.5983621", "0.5831443", "0.582785", "0.57909787", "0.578574", "0.57406604", "0.5727043", "0.5719707", "0.571599", "0.5661129", "0.5623719", "0.56196225", "0.5595319", "...
0.74857575
0
Return registered group with the given group id
def get(self): self._group = self._client.get( url=self._client.get_full_url( self.get_path( 'single', realm=self._realm_name, group_id=self._group_id ) ) ) self._group_id = self._group["id"] return self._group
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_group(self, group_id):\n return self.root.get(group_id)", "def getGroupById(self, id):\n for group in self.groups:\n if group.id == id:\n return group\n\n return None", "def get_group(self, group_id: str) -> dict:\n group = self.ms_client.http_reque...
[ "0.8029542", "0.79949456", "0.7972709", "0.7740636", "0.7728499", "0.7666988", "0.76289696", "0.75440896", "0.75185275", "0.74773175", "0.73800594", "0.7367363", "0.7357759", "0.7311793", "0.73070186", "0.7265864", "0.7263907", "0.7083139", "0.70819503", "0.7020503", "0.69858...
0.67001593
40
r"""Add the data entry with that key(string only). Do not use | in the key name. Do not use \n in directly passed strings. If you need to save strings with \n pack them into a list/tuple.
def setData(key, value): #only string keys are accepted if ( type(key) != str ): return None Co8PersistentData.__dataDict[key] = value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_strings(self, key, value):\n return self.redis.append(key, value)", "def data_append(ctx, data, key, value):\n assert isinstance(ctx, Wtp)\n assert isinstance(data, dict)\n assert isinstance(key, str)\n\n if key in str_keys:\n assert isinstance(value, str)\n elif key in dict_...
[ "0.6494339", "0.6331447", "0.63173616", "0.6216603", "0.61674356", "0.6129008", "0.61111337", "0.60945994", "0.60785055", "0.6062912", "0.602837", "0.59456736", "0.59448993", "0.5885598", "0.581578", "0.57508695", "0.5681362", "0.5679142", "0.5654532", "0.56521285", "0.563818...
0.5312992
46
Return the data entry with that key(string only). If the key is not in the data, return None.
def getData(key): #only string keys are accepted if ( type(key) != str ): return None try: return Co8PersistentData.__dataDict[key] except KeyError: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_if_exist(self, data, key):\n if key in data:\n return data[key]\n return None", "def __getitem__(self, key):\n return self.data.get(key, '')", "def get_value(self, key: str) -> Any:\r\n if key is None:\r\n return self.data\r\n try:\r\n ...
[ "0.82123154", "0.7309039", "0.72677135", "0.72277874", "0.7040932", "0.69868594", "0.69868594", "0.69660264", "0.6961794", "0.69375473", "0.6881359", "0.6826834", "0.682081", "0.68107283", "0.67963827", "0.67706054", "0.6757001", "0.6744611", "0.67237025", "0.67097914", "0.66...
0.74667233
1
Remove the data entry with that key(string only).
def removeData(key): #only string keys are accepted if ( type(key) != str ): return None try: del Co8PersistentData.__dataDict[key] except KeyError: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_key(self, key):\n del self.data[key]\n self.save_data()", "def remove(self, key):", "def remove(kv_data, key):\n if isinstance(kv_data, str):\n kv_data = loads(kv_data) # Turn into Dictionary\n try:\n del kv_data[key]\n except NameError:\n ...
[ "0.8042788", "0.7945503", "0.7696901", "0.7657578", "0.75942427", "0.7518757", "0.7511551", "0.74180245", "0.7405447", "0.7395271", "0.7338885", "0.73069334", "0.729629", "0.727901", "0.727901", "0.72788465", "0.72736", "0.7261323", "0.7245008", "0.7219925", "0.7194281", "0...
0.84150505
0
Clear all data entries
def clearData(): Co8PersistentData.__dataDict.clear()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n for key in self.__data.keys():\n del self.__data[key]", "def clear_data(self):\n if isinstance(self.data, DataManager):\n self.data._update_keys(clear=True)\n else:\n self.data = {}", "def clear(self):\n self._data = []", "def cl...
[ "0.8420439", "0.8049038", "0.8027784", "0.8027784", "0.8021053", "0.7924154", "0.79066306", "0.7828676", "0.7769692", "0.7729737", "0.7727894", "0.76899314", "0.7657845", "0.7657845", "0.7657845", "0.7657845", "0.7657845", "0.7657845", "0.7657845", "0.76527727", "0.76079994",...
0.77188724
11
Load the data from file. DO NOT USE FROM CLIENT CODE!
def load(savename): Co8PersistentData.__dataDict.clear() try: inFile = open(buildPath(savename), "r") except IOError: return for line in inFile: separatorPos = line.index("|") #read up to separator key = line[:separatorPos] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(self) -> None:", "def load_data(self):", "def load_data(filename) :\r\n data = Data()\r\n data.load(filename)\r\n return data", "def _load(self):\n if self.file_path.exists():\n with open(self.file_path) as fid:\n self.data = json.load(fid)", "def loa...
[ "0.8138814", "0.78625965", "0.75728893", "0.75419176", "0.7495744", "0.74865746", "0.7253415", "0.7172319", "0.71480846", "0.7133422", "0.7038904", "0.6991359", "0.6977568", "0.69752496", "0.6942895", "0.693721", "0.69046897", "0.68724054", "0.6872116", "0.68547493", "0.68218...
0.0
-1
Clustering assigns clusters to the samples
def cluster(self, X): return np.array(X, dtype=np.float32)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_clusters(self):\n running_perts = {}\n for name in self.tensor_info:\n item = self.tensor_info[name]\n pert_list = item[1]\n pert_names = []\n prob_list = []\n if pert_list is not None:\n for pert in pert_list:\n ...
[ "0.739987", "0.7321388", "0.73061186", "0.7217959", "0.72102505", "0.7160771", "0.71506834", "0.71484685", "0.70882785", "0.70537424", "0.70518494", "0.69797474", "0.69713855", "0.69336367", "0.6920394", "0.69037646", "0.68864375", "0.68537027", "0.67778146", "0.6777391", "0....
0.0
-1
Add a completion finder specify an existing finder with `before` or `after` to finetune the order in which the finder will have the opportunity to return its matches
def register_robot_completion_finder( completion_finder: Callable, before: Callable = None, after: Callable = None ): kernel = get_ipython().kernel finders = kernel.completer.completion_finders if completion_finder in finders: kernel.completer.completion_finders.remove(completion_finder) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_after(self, **opts):\n return self.parser.find(search_after=self, **opts)", "def set_custom_completer(self,completer,pos=0):\n\n newcomp = new.instancemethod(completer,self.Completer,\n self.Completer.__class__)\n self.Completer.matchers.insert(po...
[ "0.56004035", "0.5579921", "0.53368646", "0.53288037", "0.5268136", "0.50188124", "0.48547605", "0.4744556", "0.47388002", "0.47188815", "0.4714299", "0.46791056", "0.46681008", "0.4652077", "0.46503916", "0.4621655", "0.4608734", "0.4596069", "0.4594391", "0.45838556", "0.45...
0.7401616
0
Remove a completion finder
def unregister_robot_completion_finder(completion_finder: Callable): kernel = get_ipython().kernel kernel.completer.completion_finders.remove(completion_finder)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __del__( self ):\n self.suggest = None", "def _remove_finder(importer, finder):\r\n\r\n existing_finder = _get_finder(importer)\r\n\r\n if not existing_finder:\r\n return\r\n\r\n if isinstance(existing_finder, ChainedFinder):\r\n try:\r\n existing_finder.finders.remove(finder)\r\n exc...
[ "0.6519088", "0.63977975", "0.60877055", "0.607742", "0.6075447", "0.59601915", "0.59573257", "0.59435254", "0.59435254", "0.59435254", "0.59297496", "0.57765245", "0.5717672", "0.56873983", "0.5661162", "0.5658041", "0.5658041", "0.5655606", "0.56469905", "0.56457305", "0.56...
0.7751524
0
Handle complete_request payload and return a message spec for a set of completions
def do_complete(self, code: str, cursor_pos: int, history: List[str]) -> dict: matches = [] line, line_cursor, offset = find_line(code, cursor_pos) self.docs(history + [code]) matches = None experimental_matches = None metadata = {} for finder in self.completi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete(index, prefix, text, field='form_suggest', size=100):\n response = { 'prefix': prefix, 'text':text, 'length': 0, 'complete': [] }\n \n key = \"word_completion\"\n body = {\n key: {\n \"text\": text,\n \"completion\": {\n \"field\": field,\n ...
[ "0.5963723", "0.58597255", "0.57322633", "0.5678444", "0.56566155", "0.56151927", "0.55907565", "0.5580283", "0.55698997", "0.5555835", "0.5519421", "0.5441289", "0.54060966", "0.5404106", "0.5378598", "0.53647", "0.5355439", "0.53431594", "0.53357375", "0.53249985", "0.53081...
0.51148164
33
Handle inspect payload and return a message spec with some docs set of completions
def do_inspect( self, code: str, cursor_pos: int, detail_level: int, history: List[str] ) -> dict: doc = None line, line_cursor, offset = find_line(code, cursor_pos) tokens = DataRow(RobotReader.split_row(line)).data self.docs(history + [code]) if len(tokens) > 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_recognize_describe(self):\n pass", "async def help(self, message):\n response = []\n for skill in self.opsdroid.skills:\n if skill.__doc__:\n response.append(\"{}: {}\".format(skill.__name__, skill.__doc__))\n else:\n doc_string_no...
[ "0.557248", "0.5373576", "0.5249683", "0.50957936", "0.5081314", "0.5059435", "0.5058507", "0.5056015", "0.5020627", "0.49884364", "0.49349374", "0.4870771", "0.48620465", "0.47738937", "0.47626975", "0.47436956", "0.47226784", "0.47178307", "0.4716545", "0.47076792", "0.4699...
0.4761884
15
Return the docs available from cached, imported libraries and and history of the current run
def docs(self, history=[]): if self._doc_cache is None: self._doc_cache = {} for lib in ["BuiltIn"]: self._load_libdoc(lib) self._update_imports(history) docs = dict(**self._doc_cache, **self._history_docs(history)) return docs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docs():", "def get_docs(self):\n return self.retrieve_docstring()", "def get_docs(self):\n return self.retrieve_docstring()", "def get_docs(self):\n return self.retrieve_docstring()", "def get_docs_and_page():\n _, *args = sys.argv[:]\n if len(args) > 0:\n print(pydoc....
[ "0.7214914", "0.7208809", "0.7208809", "0.7208809", "0.7035019", "0.64107287", "0.6370273", "0.63667387", "0.63056684", "0.6242937", "0.62129766", "0.61954343", "0.61671525", "0.6120073", "0.60648566", "0.60035056", "0.5990763", "0.59571904", "0.59271187", "0.592674", "0.5901...
0.7643801
0
Try to load a libdoc, either by name, or named source. Tries to use the cache.
def _load_libdoc(self, name, source=None, use_cache=True): strategies = [name] if source is not None and source.endswith(".robot"): try: strategies += [find_file(source)] except Exception: pass for strategy in strategies: if u...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_for_cache(self, doc_uri, doc, parsed_uri):\n remote_uri = '{}://{}/{}'.format(\n parsed_uri.scheme, parsed_uri.netloc, parsed_uri.path)\n if self.verbose:\n print('Loading URI {}'.format(remote_uri), file=sys.stderr)\n response = self.session.get(remote_uri)\n ...
[ "0.5935057", "0.5904772", "0.57871795", "0.56727594", "0.54848313", "0.54818624", "0.54666173", "0.54666173", "0.5432692", "0.53918415", "0.5369334", "0.53154343", "0.52822685", "0.5280265", "0.5209134", "0.5153642", "0.5152831", "0.51441497", "0.5137212", "0.5116933", "0.509...
0.8219947
0
Return documentation for a library (or keyword)
def _lib_html(self, libname: str, history: List[str]) -> str: found = None for name, libdoc in self.docs(history).items(): if libname.lower().strip() == name.lower().strip(): found = libdoc break found = found or self._load_libdoc(libname) if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_documentation(self, *args, **dargs):\n pass", "def pythondoc(self, irc, msg, args, num, req):\n self.googleq('http://docs.python.org/library/', req, num, irc)", "def docs():", "def documentation():\n return auto.html()", "def documentation_only():\n pass", "def DocString():\n ...
[ "0.6844258", "0.6824048", "0.67639655", "0.6676564", "0.6667491", "0.65963817", "0.6480486", "0.64776915", "0.6475599", "0.6438893", "0.6424746", "0.6424746", "0.6424746", "0.6414946", "0.64008516", "0.6380649", "0.63650584", "0.6321805", "0.62929976", "0.62712777", "0.626505...
0.5621898
85
Strips out the elements we dont want
def clean_keys(keyList): for target in ['CM', 'Max', 'MI']: while True: try: i = keyList.index(target) keyList.pop(i) keyList[i] = '-'.join([target, keyList[i]]) except ValueError: break
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(self):\n return _coconut_tail_call((self.__class__), *filter(_coconut.functools.partial(_coconut.operator.ne, self.identity), self.elems))", "def _strip_list(list):\n return [x for x in list if x]", "def clean_duplicate(self):\r\n self.elements = list(set(self.elements))\r\n s...
[ "0.6614638", "0.65244913", "0.6456065", "0.6393501", "0.6360839", "0.632428", "0.6218525", "0.6218525", "0.6218525", "0.61512065", "0.61335945", "0.6113605", "0.61094624", "0.60160375", "0.59858555", "0.59366417", "0.593327", "0.5930981", "0.5927308", "0.5917738", "0.590845",...
0.0
-1
Get the elements of the file name we need
def get_name(fname): if fname.endswith('.nii.gz'): fname = fname.replace('.nii.gz', '') name_stuff = {} tmp = fname.split('_') # tmp is just a placeholder elems = tmp[-4:-1] # The elements of the file name in a list name_stuff['IC'] = elems[0][2:] # 18 name_stuff['Scan'] = elems[1][1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_file_names(self):\n return self.filename", "def GetFileNames(self):\n return self.files", "def getFilenamesAndGuid(thisfile):\n\n pfn = str(thisfile.getElementsByTagName(\"pfn\")[0].getAttribute(\"name\"))\n filename = os.path.basename(pfn)", "def get_file_data(filename):", "def fil...
[ "0.68651587", "0.6786306", "0.6695368", "0.6690862", "0.6536975", "0.65358084", "0.65094995", "0.6418115", "0.6400731", "0.63576955", "0.6337317", "0.6333919", "0.6291872", "0.629035", "0.62813634", "0.62736857", "0.62608516", "0.6252758", "0.6252308", "0.6237244", "0.6237051...
0.58450466
76
Creates a tab separated text document with the final results
def write_report(contents, fhandle=None): if fhandle is None: fhandle = open('cluster_report.txt', 'a') template = "{Img}\t\t\t\t{Scan}\t{IC}\t{Hemi}\t{MI-LR}\t{MI-PA}\t{MI-IS}\t{Volume}\t{Max-Int}\n" fhandle.write(template.format(**contents)) # Need to look over syntax again
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_txt_files(self, op_dir=None):\n for tb_nm, tb_cont in list(self.tables_info['tables'].items()):\n op_fl = '{}_{}.txt'.format(self.report_basename, tb_nm)\n if op_dir:\n op_fl = os.path.join(op_dir, op_fl)\n with open(op_fl, 'w') as TXT:\n ...
[ "0.6666238", "0.64195937", "0.633536", "0.6218186", "0.6173092", "0.6154481", "0.6116633", "0.60087687", "0.59864813", "0.58996713", "0.58977175", "0.5878276", "0.5876625", "0.58622724", "0.58558774", "0.58495855", "0.58385503", "0.58319664", "0.5821611", "0.57968044", "0.578...
0.0
-1
Return NPSH in ft given suction and vapor pressure in Pa and density in kg/m^3.
def calc_NPSH(P_suction, P_vapor, rho_liq): # Note: NPSH = (P_suction - P_vapor)/(rho_liq*gravity) # Taking into account units, NPSH will be equal to return value return 0.334438*(P_suction - P_vapor)/rho_liq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phosfracs(h,ks):\n k1p,k2p,k3p = ks\n h3po4 = h*h*h\n h2po4 = k1p*h*h\n hpo4 = k1p*k2p*h\n po4 = k1p*k2p*k3p\n denom = h3po4 + h2po4 + hpo4 + po4\n h3po4 /= denom\n h2po4 /= denom\n hpo4 /= denom\n po4 /= denom\n return h3po4,h2po4,hpo4,po4", "def get_f_s_gas(p: float, ...
[ "0.6685551", "0.639336", "0.6244425", "0.6082317", "0.60762024", "0.6053931", "0.60533136", "0.6028373", "0.6004268", "0.59924716", "0.5931524", "0.5906271", "0.5870304", "0.5837564", "0.58216316", "0.5757926", "0.5748486", "0.5741466", "0.57287925", "0.57140833", "0.56934816...
0.72387576
0
Given a list of numbers 1...max_num, find which one is missing.
def missing_number(nums, max_num): expected_sum = sum(range(1, max_num + 1)) actual_sum = sum(nums) missing_num = expected_sum - actual_sum return missing_num
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task8_missing_number(num):\n check_list = list(range(1, max(num) + 1))\n result = list(set(check_list) - set(num))\n return result", "def first_missing_positive_int_linear(nums):\n\t\n\t# Here's the trick: the first missing positive number must be \n\t# between 1 and len(array) + 1 \t\n\ts = set(num...
[ "0.71682376", "0.66200066", "0.6587165", "0.64158785", "0.64004153", "0.6262766", "0.6218174", "0.61476374", "0.601516", "0.5959102", "0.5955049", "0.5899052", "0.5875794", "0.5813601", "0.5809686", "0.57972556", "0.579456", "0.579384", "0.5793581", "0.5776495", "0.5772597", ...
0.7283265
0
Secure XMLRPC server. It it very similar to SimpleXMLRPCServer but it uses HTTPS for transporting XML data.
def __init__(self, server_address, HandlerClass, logRequests=False): self.logRequests = logRequests SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self) SocketServer.BaseServer.__init__(self, server_address, HandlerClass) ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.use_private...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ServerApp(stream, certfile, keyfile):\n\n def secured():\n print 'server secured!'\n wait()\n\n def read(line):\n line = line.strip()\n print 'client said: %r.' % line\n\n if line == 'QUIT':\n write('GOODBYE')\n elif line == 'STARTTLS':\n st...
[ "0.5891365", "0.57680714", "0.55865854", "0.5579839", "0.55737317", "0.55374026", "0.5511723", "0.5408151", "0.5328179", "0.52618873", "0.5247265", "0.52101576", "0.5188306", "0.51858515", "0.5183569", "0.5180495", "0.51675045", "0.51625985", "0.5136065", "0.51181674", "0.511...
0.5801445
1
Authenticates the headers against the credentials set in the configuration file. This method overrides the one with the same name in SimpleXMLRPCRequestHandler. whether authentication was successful or not
def authenticate(self, headers): try: from base64 import b64decode (basic, _, encoded) = headers.get('Authorization').partition(' ') assert basic == 'Basic', 'Only basic authentication supported' encodedByteString = encoded.encode() decodedBytes = b64d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_auth_header(self):\n self.auth_header = self.get_auth_header(self.login, self.password)\n return True if self.auth_header else False", "def authenticate(self, environ):\n try:\n hd = parse_auth_header(environ['HTTP_AUTHORIZATION'])\n except:\n return Fals...
[ "0.7003828", "0.6873419", "0.6723734", "0.666804", "0.66520137", "0.65985966", "0.65686065", "0.65346134", "0.65084785", "0.64767873", "0.64284766", "0.6428409", "0.6404516", "0.6397908", "0.6395942", "0.63829255", "0.6370441", "0.6318763", "0.6311569", "0.63074154", "0.63029...
0.7470838
0
Handles the HTTPS POST request. It was copied out from SimpleXMLRPCServer.py and modified to shutdown the socket cleanly.
def do_POST(self): try: # get arguments data = self.rfile.read(int(self.headers["content-length"])) # In previous versions of SimpleXMLRPCServer, _dispatch # could be overridden in this class, instead of in # SimpleXMLRPCDispatcher. To maintain backwa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_POST(self):\r\n SimpleXMLRPCRequestHandler.do_POST(self)\r\n try:\r\n # shut down the connection\r\n self.connection.shutdown()\r\n except:\r\n pass", "def do_POST(self):\n \n try:\n # get arguments\n data = self.rfile.read...
[ "0.74087286", "0.72158414", "0.64562505", "0.630423", "0.6071982", "0.60686713", "0.6047886", "0.59989196", "0.5930593", "0.58788216", "0.5838585", "0.5799158", "0.5740681", "0.5724067", "0.56990105", "0.5663073", "0.56385607", "0.5617192", "0.55833626", "0.5565715", "0.55318...
0.6749537
2
Recreates images from a torch variable, sort of reverse preprocessing
def recreate_image(im_as_var): recreated_im = im_as_var.data.numpy()[0] recreated_im[recreated_im > 1] = 1 recreated_im[recreated_im < 0] = 0 # recreated_im = np.round(recreated_im * 255) return recreated_im
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reconstruct_image(self, net, images, name):\n target_img_grid = torchvision.utils.make_grid(images)\n images = images.to(self.device)\n output = net(images)\n img_grid = torchvision.utils.make_grid(output.cpu().data)\n if self.writer is not None:\n self.writer.add_...
[ "0.6344635", "0.6262975", "0.60765135", "0.60504323", "0.60154146", "0.59801286", "0.5910857", "0.5901042", "0.588297", "0.579484", "0.57937944", "0.57394487", "0.57089525", "0.57089525", "0.56973785", "0.5683466", "0.5676998", "0.56759846", "0.56605226", "0.5660026", "0.5645...
0.6469008
0
generate a random string
def random_string(n, alphabet=string.ascii_lowercase): return "".join(random.choice(alphabet) for _ in range(n))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))", "def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec", "def __generate_random_string():\n return uuid4().hex[:6].upper()", "def r...
[ "0.850504", "0.84503955", "0.8107285", "0.8030303", "0.79917127", "0.7966936", "0.7955794", "0.783599", "0.7833559", "0.7833183", "0.7817233", "0.7802888", "0.7779429", "0.7768785", "0.7746513", "0.77311516", "0.7703917", "0.77027106", "0.7688608", "0.7673507", "0.7664003", ...
0.0
-1
split string in random places
def random_splits(s, n, nsplits=2): splits = sorted([random.randint(0, n) for _ in range(nsplits - 1)]) splits = [0] + splits + [n] for begin, end in zip(splits, splits[1:]): yield s[begin:end]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_split_string(self):\n mytext = '2011 Senior PGA Championship presented by'\n string1, string2 = split_string(mytext, 25, 25)\n self.assertEqual(string1, '2011 Senior PGA')\n self.assertEqual(string2, 'Championship presented')", "def _split(string: str, n: int):\n retur...
[ "0.6615401", "0.6526776", "0.6357068", "0.63472426", "0.62179184", "0.6086013", "0.60382074", "0.6032437", "0.6014499", "0.6010876", "0.6010876", "0.5914099", "0.5908766", "0.58987063", "0.58714265", "0.58691454", "0.5788112", "0.5784689", "0.57751167", "0.57537955", "0.57502...
0.594967
11
Empty Python string has same hash value as empty Unicode string
def test_string_unicode_32(self): self.assertEqual(CityHash32(EMPTY_STRING), CityHash32(EMPTY_UNICODE))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_string(self):\n self.assertEqual(hash_str(\"\", salt=\"\").hex()[:6], \"e3b0c4\")", "def default_hash():\n return \"!\"", "def test_string_unicode_128(self):\n self.assertEqual(\n CityHash128WithSeed(EMPTY_STRING), CityHash128WithSeed(EMPTY_UNICODE)\n )", "de...
[ "0.7878158", "0.74074453", "0.7208579", "0.7204362", "0.71196926", "0.7080304", "0.70066", "0.6828292", "0.6818237", "0.6800801", "0.6747518", "0.67276543", "0.6692963", "0.6683962", "0.66254395", "0.6612342", "0.65993917", "0.65985364", "0.6589796", "0.6578673", "0.65686995"...
0.70400286
6
Empty Python string has same hash value as empty Unicode string
def test_string_unicode_64(self): self.assertEqual( CityHash64WithSeed(EMPTY_STRING), CityHash64WithSeed(EMPTY_UNICODE) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_string(self):\n self.assertEqual(hash_str(\"\", salt=\"\").hex()[:6], \"e3b0c4\")", "def default_hash():\n return \"!\"", "def test_string_unicode_128(self):\n self.assertEqual(\n CityHash128WithSeed(EMPTY_STRING), CityHash128WithSeed(EMPTY_UNICODE)\n )", "de...
[ "0.78783447", "0.7407617", "0.72099966", "0.7118005", "0.70792556", "0.70417976", "0.7004675", "0.682642", "0.6816814", "0.6799749", "0.67451036", "0.67263263", "0.6692329", "0.6683981", "0.6624263", "0.6610932", "0.65980643", "0.6597351", "0.6587709", "0.6578163", "0.6566528...
0.72056234
3
Empty Python string has same hash value as empty Unicode string
def test_string_unicode_128(self): self.assertEqual( CityHash128WithSeed(EMPTY_STRING), CityHash128WithSeed(EMPTY_UNICODE) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_string(self):\n self.assertEqual(hash_str(\"\", salt=\"\").hex()[:6], \"e3b0c4\")", "def default_hash():\n return \"!\"", "def test_string_unicode_64(self):\n self.assertEqual(\n CityHash64WithSeed(EMPTY_STRING), CityHash64WithSeed(EMPTY_UNICODE)\n )", "def h...
[ "0.7878158", "0.74074453", "0.7204362", "0.71196926", "0.7080304", "0.70400286", "0.70066", "0.6828292", "0.6818237", "0.6800801", "0.6747518", "0.67276543", "0.6692963", "0.6683962", "0.66254395", "0.6612342", "0.65993917", "0.65985364", "0.6589796", "0.6578673", "0.65686995...
0.7208579
2
ASCIIrange Unicode strings have the same hash values as ASCII strings
def test_consistent_encoding_32(self): text = u"abracadabra" # pylint: disable=redundant-u-string-prefix self.assertEqual(CityHash32(text), CityHash32(text.encode("utf-8")))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customHashFunc(str):\n return sum(ord(chr) for chr in str)%128", "def get_hash_code(s):\n h = 0\n n = len(s)\n for i, c in enumerate(s):\n h = h + ord(c) * 31 ** (n - 1 - i)\n return StrUtil.convert_4_bytes(h)", "def hash(string):\n hs = 0\n for s in ...
[ "0.72499", "0.6899715", "0.68569535", "0.6825364", "0.66574484", "0.6637237", "0.65878505", "0.6574586", "0.65281165", "0.6458502", "0.6446409", "0.6423165", "0.63963395", "0.6389282", "0.6377862", "0.6376784", "0.6318318", "0.62828887", "0.62729996", "0.626349", "0.6259537",...
0.6511082
9
ASCIIrange Unicode strings have the same hash values as ASCII strings
def test_consistent_encoding_64(self): text = u"abracadabra" # pylint: disable=redundant-u-string-prefix self.assertEqual( CityHash64WithSeed(text), CityHash64WithSeed(text.encode("utf-8")) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customHashFunc(str):\n return sum(ord(chr) for chr in str)%128", "def get_hash_code(s):\n h = 0\n n = len(s)\n for i, c in enumerate(s):\n h = h + ord(c) * 31 ** (n - 1 - i)\n return StrUtil.convert_4_bytes(h)", "def hash(string):\n hs = 0\n for s in ...
[ "0.7250782", "0.6899607", "0.6857637", "0.68264836", "0.6657475", "0.66373086", "0.6589155", "0.6573762", "0.65283066", "0.6511661", "0.6459119", "0.6447571", "0.64222616", "0.6395716", "0.63899314", "0.6378682", "0.63773334", "0.63191444", "0.62842214", "0.6273212", "0.62647...
0.6159837
34
ASCIIrange Unicode strings have the same hash values as ASCII strings
def test_consistent_encoding_128(self): text = u"abracadabra" # pylint: disable=redundant-u-string-prefix self.assertEqual( CityHash128WithSeed(text), CityHash128WithSeed(text.encode("utf-8")) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customHashFunc(str):\n return sum(ord(chr) for chr in str)%128", "def get_hash_code(s):\n h = 0\n n = len(s)\n for i, c in enumerate(s):\n h = h + ord(c) * 31 ** (n - 1 - i)\n return StrUtil.convert_4_bytes(h)", "def hash(string):\n hs = 0\n for s in ...
[ "0.72520995", "0.6901969", "0.6859455", "0.6828412", "0.6658977", "0.6638631", "0.65911376", "0.65742284", "0.65299904", "0.65119684", "0.64613616", "0.64479655", "0.6422598", "0.63965815", "0.63916665", "0.63788897", "0.6321164", "0.6286169", "0.62752485", "0.6265631", "0.62...
0.6379118
15
Accepts Unicode input outside of ASCII range
def test_unicode_2_32(self): test_case = u"\u2661" # pylint: disable=redundant-u-string-prefix self.assertTrue(isinstance(CityHash32(test_case), int))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_ascii(message):\n return all(ord(c) < 128 for c in message)", "def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's st...
[ "0.674651", "0.6702276", "0.6633487", "0.65537524", "0.6456078", "0.64002144", "0.6400209", "0.63872474", "0.6362936", "0.6256813", "0.6243364", "0.61856616", "0.6158847", "0.6131808", "0.6129591", "0.61269665", "0.6125196", "0.6116816", "0.6101622", "0.6099073", "0.6020503",...
0.5419944
99
Accepts Unicode input outside of ASCII range
def test_unicode_2_64(self): test_case = u"\u2661" # pylint: disable=redundant-u-string-prefix self.assertTrue(isinstance(CityHash64WithSeed(test_case), long))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_ascii(message):\n return all(ord(c) < 128 for c in message)", "def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's st...
[ "0.674651", "0.6702276", "0.6633487", "0.65537524", "0.6456078", "0.64002144", "0.6400209", "0.63872474", "0.6362936", "0.6256813", "0.6243364", "0.61856616", "0.6158847", "0.6131808", "0.6129591", "0.61269665", "0.6125196", "0.6116816", "0.6101622", "0.6099073", "0.6020503",...
0.0
-1
Accepts Unicode input outside of ASCII range
def test_unicode_2_128(self): test_case = u"\u2661" # pylint: disable=redundant-u-string-prefix self.assertTrue(isinstance(CityHash128WithSeed(test_case), long))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_ascii(message):\n return all(ord(c) < 128 for c in message)", "def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's st...
[ "0.674651", "0.6702276", "0.6633487", "0.65537524", "0.6456078", "0.64002144", "0.6400209", "0.63872474", "0.6362936", "0.6256813", "0.6243364", "0.61856616", "0.6158847", "0.6131808", "0.6129591", "0.61269665", "0.6125196", "0.6116816", "0.6101622", "0.6099073", "0.6020503",...
0.0
-1
Accepts Unicode input outside of ASCII range
def test_unicode_2_128_seed(self): test_case = u"\u2661" # pylint: disable=redundant-u-string-prefix result = CityHash128WithSeed(test_case, seed=CityHash128WithSeed(test_case)) self.assertTrue(isinstance(result, long))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_ascii(message):\n return all(ord(c) < 128 for c in message)", "def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's st...
[ "0.6747206", "0.6701084", "0.66342264", "0.65539783", "0.64550126", "0.63995075", "0.63992745", "0.6385845", "0.6362202", "0.6256344", "0.62438875", "0.61859256", "0.6158354", "0.613039", "0.61301666", "0.61267245", "0.61254823", "0.6116461", "0.61011463", "0.61009413", "0.60...
0.0
-1
Should accept byte arrays and buffers
def test_argument_types(self): funcs = [ CityHash32, CityHash64, CityHash128, CityHash64WithSeed, CityHash64WithSeeds, CityHash128WithSeed, ] args = [b"ab\x00c", bytearray(b"ab\x00c"), memoryview(b"ab\x00c")] for fun...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_write_bufferprotocol(ctx):\n data = array('f', [1, 2, 3, 4])\n buff = ctx.buffer(data=data)\n assert buff.read() == data.tobytes()", "def from_bytes(self, ???):", "def test_array_as_buffer(parser):\n doc = parser.parse(b'''{\n \"d\": [1.2, 2.3, 3.4],\n \"i\": [-1, 2, -3, 4],\...
[ "0.71451235", "0.66783303", "0.6573056", "0.64107174", "0.6367898", "0.63394856", "0.63018113", "0.62852395", "0.6254181", "0.6254181", "0.6254181", "0.6225594", "0.61953485", "0.6175418", "0.6171095", "0.6171095", "0.6171095", "0.6171095", "0.6171095", "0.6171095", "0.617109...
0.0
-1
Argument reference count should not change
def test_refcounts(self): funcs = [ CityHash32, CityHash64, CityHash128, CityHash64WithSeed, CityHash64WithSeeds, CityHash128WithSeed, ] args = ["abc", b"abc", bytearray(b"def"), memoryview(b"ghi")] for func in funcs...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self, args):", "def __getnewargs__(self):\n return ()", "def needs_arglist(self):\n True", "def test_vargs(self):", "def function(args):\n pass", "def __init__(*args):", "def __init__(*args):", "def __init__(*args):", "def __init__(*args):", "def __init__(*args):", ...
[ "0.6719029", "0.668362", "0.6640839", "0.64241815", "0.6300849", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "0.62962115", "...
0.6173091
29
Different seeds should produce different results
def test_different_seeds(self): test_string = "just a string" funcs = [ CityHash64WithSeed, CityHash64WithSeeds, CityHash128WithSeed, ] for func in funcs: self.assertNotEqual(func(test_string, 0), func(test_string, 1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seed():", "def experiment4():\n np.random.seed()\n state['result'] = np.random.rand(1)", "def random_test(self, source):\r\n ret = 1\r\n for seed in range(1, 40):\r\n if source.run(temp_params={\"fitness_function\": (lambda x: -np.sum(x)**2+10),\r\n ...
[ "0.7611267", "0.74238944", "0.7090005", "0.7085885", "0.7085885", "0.69191396", "0.6861069", "0.68587035", "0.68375623", "0.68243855", "0.6790251", "0.6782352", "0.6744535", "0.6723264", "0.670855", "0.6704698", "0.6683288", "0.6674533", "0.6673856", "0.6625587", "0.6625587",...
0.0
-1
Raises type error on bad argument type
def test_func_raises_type_error(self): funcs = [ CityHash32, CityHash64, CityHash128, CityHash64WithSeed, CityHash64WithSeeds, CityHash128WithSeed, ] for func in funcs: with self.assertRaises(TypeError): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_incorrect_arg_type(self):\n\n with pytest.raises(TypeError) as exc_info:\n upper_incomplete_gamma(a='A', z=0.3)\n\n expected_error_msg = (\n 'type of argument \"a\" must be one of (int, float); got str instead'\n )\n assert str(exc_info.value) == expected_...
[ "0.7526827", "0.72410756", "0.7187433", "0.7163493", "0.7135743", "0.7118965", "0.71039313", "0.69994354", "0.6931593", "0.689284", "0.6857292", "0.6856748", "0.68440545", "0.6769542", "0.67432135", "0.67353684", "0.6731097", "0.6715765", "0.67052305", "0.669886", "0.66629344...
0.0
-1
Read the file with file_name name, except if it is not a csv file. Add the datas to the API of url API_BASE_URL.
def read_csv_file(file_name): csv_file = open(file_name, 'rb') rd = csv.reader(csv_file, delimiter=';',quoting=csv.QUOTE_ALL) nb_rd_rows = 0 current_wine = {} columns_name = ["name","vintage","appellation","color","wine_id","item_id","price","degustation","food_pairing","food_pairing_french","gws"]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_csv(self):\n self.function_name = '_read_csv'\n with open(os.path.join(self.task.downloads, self.csv_name)) as csv_file:\n reader = csv.reader(csv_file, dialect='excel')\n for row in reader:\n self.input_data.append(row)", "def _api_call(self, url):\n ...
[ "0.59968805", "0.58778507", "0.5870001", "0.5830529", "0.573776", "0.57139134", "0.5652763", "0.5635782", "0.56250834", "0.562066", "0.5591271", "0.55684465", "0.55138487", "0.5450169", "0.5424738", "0.53829974", "0.5364308", "0.5319306", "0.53148985", "0.53014076", "0.529086...
0.0
-1
Translate the string to_translate from the first language into the second language. The function look in the file of name file_name.
def search_translation(file_name,line_original_language,line_new_language,to_translate): csv_file = open(file_name, 'rb') rd = csv.reader(csv_file, delimiter=';',quoting=csv.QUOTE_ALL) nb_row = 0 for row in rd: nb_row += 1 if line_original_language >= 0 and line_new_language >= 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(self, filepath):\n pass", "def translate(translate_from, translate_to, string_to_translate=\"\"):\n dictionary = DICTIONARIES.get(\"%s_%s\" % (translate_from, translate_to))\n if not dictionary:\n print(\"Offline: No such translation direction in dictionary: %s-%s\" % (translate...
[ "0.7441076", "0.6528265", "0.6476275", "0.6362921", "0.6335557", "0.62679976", "0.62083405", "0.61017513", "0.6036801", "0.6030072", "0.6027264", "0.6020773", "0.5996547", "0.59200233", "0.5909412", "0.58698016", "0.5836439", "0.58202165", "0.5774534", "0.57701063", "0.574953...
0.6322236
5
Parameters required reload codegen for the fn_jira package
def codegen_reload_data(): return { "package": u"fn_jira", "message_destinations": [u"fn_jira"], "functions": [u"jira_create_comment", u"jira_open_issue", u"jira_transition_issue"], "workflows": [], "actions": [], "incident_fields": [u"jira_internal_url", u"jira_issue...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def codegen_reload_data():\n reload_params = {\"package\": u\"fn_microsoft_security_graph\",\n \"incident_fields\": [u\"microsoft_security_graph_alert_id\"], \n \"action_fields\": [u\"microsoft_security_graph_alert_assignedto\", u\"microsoft_security_graph_alert_closeddatet...
[ "0.6842905", "0.6677929", "0.6676545", "0.6523825", "0.65152633", "0.63794017", "0.6208954", "0.53216106", "0.5253385", "0.5147386", "0.51459956", "0.5096269", "0.50347793", "0.4986125", "0.49463722", "0.49400613", "0.49377644", "0.4926541", "0.4925193", "0.49187768", "0.4917...
0.70339006
0
Returns a Generator of ImportDefinitions (Customizations). Install them using `resilientcircuits customize`
def customization_data(client=None): res_file = os.path.join(os.path.dirname(__file__), RES_FILE) if not os.path.isfile(res_file): raise FileNotFoundError("{} not found".format(RES_FILE)) with io.open(res_file, mode='rt') as f: b64_data = base64.b64encode(f.read().encode('utf-8')) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customization_data(client=None):\n\n # This import data contains:\n # Function inputs:\n # execution_arn\n # lambda_function_name\n # lambda_payload\n # msg_body\n # phone_numbers\n # state_machine_async\n # state_machine_name\n # state_machine_pa...
[ "0.54030746", "0.5201062", "0.5176876", "0.51190823", "0.5096853", "0.5061608", "0.50155", "0.5003197", "0.48581797", "0.4855284", "0.47926742", "0.47414276", "0.47321308", "0.47228238", "0.47228238", "0.47156596", "0.47124314", "0.4709521", "0.47027344", "0.46970493", "0.467...
0.6443936
3
L21 Regularization (Slow implementation. Used for sanity checks.)
def l21_slow(parameter, reg=0.01, lr=0.1): w_and_b = parameter l21s = [] for row in w_and_b: L21 = reg l21 = lr * L21/row.norm(2) l21 = 1.0 - min(1.0, l21) l21s.append(l21) counter = 0 for row in parameter: updated = row * l21s[counter] paramete...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def l21_reg(data):\n m = data.size()[0] # number of data points\n n = data.size()[1] # number of dimensions on the data points\n # find L2,1 regularization term\n outer_sum = 0\n for i in range(m):\n inner_sum = 0\n for j in range(n):\n inner_sum += data[i][j] ** 2\n ...
[ "0.6191877", "0.59732497", "0.575761", "0.5728475", "0.56940013", "0.55422384", "0.54306394", "0.5372424", "0.53538555", "0.53306973", "0.52830714", "0.5253747", "0.52404445", "0.5176889", "0.5176168", "0.5161975", "0.5159993", "0.5121662", "0.5104742", "0.51026064", "0.50792...
0.49240744
29
Linfity1 Regularization using Proximal Gradients
def linf1(parameter, bias=None, reg=0.01, lr=0.1): Norm = reg*lr if bias is not None: w_and_b = torch.cat((parameter, bias.unfold(0,1,1)),1) else: w_and_b = parameter sorted_w_and_b, indices = torch.sort(torch.abs(w_and_b), descending=True) # CUDA or CPU devicetype="cuda" i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regularizer(self):\n \n # L2 regularization for the fully connected parameters.\n regularizers = (tf.nn.l2_loss(self.weights.wd1) + tf.nn.l2_loss(self.weights.bd1) + \n tf.nn.l2_loss(self.weights.wout) + tf.nn.l2_loss(self.weights.bout))\n return regularizers", "def apply_regul...
[ "0.6790315", "0.65769583", "0.6564281", "0.6502776", "0.64603174", "0.6347255", "0.6344418", "0.634242", "0.6181466", "0.6164174", "0.615544", "0.615243", "0.6098459", "0.60946435", "0.607628", "0.60118467", "0.59860426", "0.59834826", "0.5976717", "0.592351", "0.5918007", ...
0.0
-1
L Infinity Regularization using proximal gradients over entire tensor
def linf(parameter, bias=None, reg=0.01, lr=0.1): if bias is not None: w_and_b = torch.squeeze(torch.cat((parameter, bias.unfold(0,1,1)),1), 0) else: w_and_b = torch.squeeze(parameter, 0) print("w_and_b:", w_and_b) sorted_w_and_b, indices = torch.sort(torch.abs(w_and_b), descending=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relu_grad(self, X):\n X[X<=0]=0\n X[X>0]=1\n return X", "def stable_power_compression_norm_grad(x):\n e = tf.nn.relu(x) # add relu to x to avoid NaN in loss\n p = tf.pow(e,0.3)\n def grad(dy): #try to check for nans before we clip the gradients. (use tf.where)\n return dy...
[ "0.6723577", "0.6400831", "0.6361749", "0.6188336", "0.61723393", "0.6134872", "0.6111486", "0.6056231", "0.6003101", "0.59636617", "0.5851927", "0.5846111", "0.5844192", "0.58346534", "0.58274543", "0.5825811", "0.5821241", "0.58189046", "0.58184665", "0.58182406", "0.581489...
0.0
-1
L2 Regularization over the entire parameter's values using proximal gradients
def l2(parameter, bias=None, reg=0.01, lr=0.1): if bias is not None: w_and_b = torch.cat((parameter, bias.unfold(0,1,1)),1) else: w_and_b = parameter L2 = reg # lambda: regularization strength Norm = (lr*L2/w_and_b.norm(2)) if Norm.is_cuda: ones_w = torch.ones(parameter....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regularizer(self):\n \n # L2 regularization for the fully connected parameters.\n regularizers = (tf.nn.l2_loss(self.weights.wd1) + tf.nn.l2_loss(self.weights.bd1) + \n tf.nn.l2_loss(self.weights.wout) + tf.nn.l2_loss(self.weights.bout))\n return regularizers", "def l2_regulari...
[ "0.732037", "0.7097232", "0.68667233", "0.6864606", "0.6785814", "0.67145413", "0.6660481", "0.66591406", "0.66589856", "0.6555454", "0.6555454", "0.6555454", "0.6554955", "0.6523644", "0.65120846", "0.6436748", "0.64141876", "0.6316023", "0.6231523", "0.61185926", "0.6103275...
0.6558002
9
L1 Regularization using Proximal Gradients
def l1(parameter, bias=None, reg=0.01, lr=0.1): Norm = reg*lr # Update W if parameter.is_cuda: Norms_w = Norm*torch.ones(parameter.size(), device=torch.device("cuda")) else: Norms_w = Norm*torch.ones(parameter.size(), device=torch.device("cpu")) pos = torch.min(Norms_w, Norm*torch.c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_gradient_and_loss1(W, X, y, reg, reg_type, opt):\n if opt == 0: # compute gradient only if opt == 0\n dW = np.zeros(W.shape) # initialize the gradient as zero\n \n # compute the loss and the gradient\n num_classes = W.shape[1]\n num_train = X.shape[0]\n lo...
[ "0.671659", "0.6683239", "0.6634239", "0.6618806", "0.66151017", "0.6607401", "0.6544159", "0.6514964", "0.6497152", "0.6305238", "0.6179992", "0.61466056", "0.6127492", "0.6047718", "0.6011646", "0.59763753", "0.5965151", "0.59623665", "0.5961884", "0.59485924", "0.5923506",...
0.57152766
40
Elastic Net Regularization using Proximal Gradients. This is a linear combination of an l1 and a quadratic penalty.
def elasticnet(parameter, bias=None, reg=0.01, lr=0.1, gamma=1.0): if gamma < 0.0: print("Warning, gamma should be positive. Otherwise you are not shrinking.") #TODO: Is gamma of 1.0 a good value? Norm = reg*lr*gamma l1(parameter, bias, reg, lr) update_w = (1.0/(1.0 + Norm))*parameter pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_gradient_and_loss1(W, X, y, reg, reg_type, opt):\n if opt == 0: # compute gradient only if opt == 0\n dW = np.zeros(W.shape) # initialize the gradient as zero\n \n # compute the loss and the gradient\n num_classes = W.shape[1]\n num_train = X.shape[0]\n lo...
[ "0.66227907", "0.6600636", "0.6514245", "0.64999574", "0.637801", "0.6359115", "0.63405", "0.63107157", "0.6309577", "0.6239061", "0.62388265", "0.62184274", "0.6178135", "0.61189383", "0.6117194", "0.60978043", "0.6075984", "0.60631454", "0.60522306", "0.60491234", "0.602977...
0.57338107
58
Project onto logbarrier. Useful for minimization of f(x) when x >= b. F(A) = log(det(A))
def logbarrier(parameter, bias=None, reg=0.01, lr=0.1): Norm = reg*lr # Update W squared = torch.mul(parameter, parameter) squared = squared + 4*Norm squareroot = torch.sqrt(squared) update_w = (parameter + squareroot)/2.0 parameter.data = update_w if bias is not None: squared ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logbarrierfunc(delta, z, use_sigma):\n if use_sigma:\n z = np.where(z >= 0, np.tanh(z), z)\n k = 2\n return np.where(z > delta, -np.log(np.abs(z)),\n ((k - 1) / k) * (((z - k * delta) / ((k - 1) * delta)) ** k - 1) - np.log(delta))", "def _loglike(self, y, f):\n binc...
[ "0.6741824", "0.64290917", "0.60649145", "0.60545915", "0.60342085", "0.6012831", "0.5975654", "0.59622115", "0.59182394", "0.5911255", "0.5808303", "0.57899916", "0.57665676", "0.5762922", "0.575", "0.56905204", "0.56785864", "0.5675621", "0.5657112", "0.5648416", "0.564723"...
0.65788895
1
Counts the number of each type of decision in a dataset.
def getdecisionCounts(decision): countY = 0; countN = 0 for row in decision: # in our dataset format, the label is always the last column if row == 'No': countN += 1 else : countY += 1 return countY, countN
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_elements_in_dataset(dataset):\n return dataset.count()", "def trainCount(\n trainData, \n questionType,\n questionDict,\n questionIdict, \n objDict, \n objIdict,\n numAns):\n count_wa = np.zer...
[ "0.70031756", "0.6811811", "0.6684121", "0.6506254", "0.64955044", "0.6468372", "0.63262606", "0.630834", "0.62841123", "0.62841123", "0.62841123", "0.62519157", "0.62002695", "0.6189409", "0.6175214", "0.6160707", "0.6154031", "0.61376435", "0.6134713", "0.6132458", "0.61286...
0.75158674
0
Counts the number of each type of example in a dataset.
def getClassCounts(column, uniqueVal, decision, yes, no , total): dataDict = {} # a dictionary of labels for val in uniqueVal: label1 = val + '/Y' label2 = val + '/N' dataDict[label1] = 0; dataDict[label2] = 0 for dec, at in zip(decision, column): if at == va...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_elements_in_dataset(dataset):\n return dataset.count()", "def count_target_class_data(data, target_class):\n count = 0\n for row in data:\n if row[0] == target_class:\n count += 1\n\n return count", "def trainCount(\n trainData, \n questionT...
[ "0.7122261", "0.65463275", "0.6472701", "0.6428254", "0.64051133", "0.6381329", "0.63567305", "0.62966174", "0.62764716", "0.6246529", "0.6174667", "0.61692643", "0.6162817", "0.6133767", "0.6118095", "0.61074907", "0.61060363", "0.6090246", "0.60885185", "0.6077865", "0.6067...
0.0
-1
Function that calculates the FULL date for a METAR/TAF, based on the day, hour and minute As METARS can be expired, and TAFs can be in the future, we need to work out the Year and Month
def calc_metar_taf_date(day, hr, mn=0): yr=0 mth=0 # Now get the month and year: METARS/TAFs can be from the day before (eg around midnight) or older; TAF's can be valid for a tomorrow... # so we need to compare to today's date if day == datetime.utcnow().day: # METAR/TAF is from today...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_input():\n \n year = 2020\n month = 3 # number \n day = 12 # number in month\n hour = 12 # integer between 9 (= 9:00AM) and 17 (= 4:00PM) ## CHECK THIS\n minute = 0 # float between 0 (= 0 min) to 0.983 = 59 min)\n \n date=dt.datetime(year,month,day)\n time = date.timetuple().tm_...
[ "0.53826153", "0.5304163", "0.52935094", "0.520267", "0.5138873", "0.51071763", "0.50233746", "0.49142775", "0.49124345", "0.49063063", "0.49044997", "0.48882982", "0.4868934", "0.48479235", "0.4841657", "0.48159018", "0.48131526", "0.48040777", "0.4795018", "0.4777202", "0.4...
0.75091416
0
Function that webscrapes SIGMET and AIRMET data from specified URL, returning a list of SIGMET/AIRMET dictionary items for further processing
def read_sigmet_airmet_ZA(sigmet_url): sigair_met_list = [] # The list of disctionaries that will be returned, containing SIGMAT/AIRMET data # Regular expressions to extract the co-ordinats and the Flight Level coord_re = re.compile(r'([NS]\d{4,4} [EW]\d{5,5})') valid_re = re.compile(r'VALID ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data_from_web():\n pass", "def program_item(url):\n items = []\n \n soup = abcradionational.get_soup(url)\n\n playable_podcast = abcradionational.get_playable_podcast(soup)\n\n items = abcradionational.compile_playable_podcast(playable_podcast)\n\n return items", "def get_from_web(...
[ "0.59911746", "0.59453905", "0.5848602", "0.5834908", "0.58163935", "0.5807108", "0.57875293", "0.5772196", "0.576209", "0.57481354", "0.5744503", "0.5738256", "0.57149047", "0.5688065", "0.56816363", "0.5670173", "0.5655818", "0.5650575", "0.56476456", "0.5641101", "0.562150...
0.69745046
0
Function that accepts SIGMET and AIRMET data, and creates a list of GEOJSON features grouped into SIGMET and AIRMET Each Feature will form a layer on the map this allows for easy filtering of layers. The function also returns a list of the Groups applicable (eg. there may be no AIRMETS so only SIGMETS will be returned)
def generate_sigmet_geojson(sigair_met_list): # Initialise Variables used_groups = [] #contains applicable groupings for use on the web page (i.e. it excludes groupings that do not appear) - used to filter layers on the map used_layers = [] sigair_met_features = [] # If there are no Sig/Airme...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_features_geojson(self, geojson_tagset):\n kreis_region_bund_list = []\n only_regs_set = set()\n for feature in geojson_tagset:\n bundesl = feature.properties.get('NAME_1')\n region = feature.properties.get('NAME_2')\n kreis = feature.properties.get('NA...
[ "0.5929601", "0.5754891", "0.5700304", "0.56480706", "0.5514577", "0.544874", "0.5413403", "0.5413403", "0.5413403", "0.53773695", "0.53624165", "0.5340683", "0.5311254", "0.5300792", "0.5300585", "0.52863663", "0.5171702", "0.5116965", "0.51054764", "0.5100863", "0.50949407"...
0.72906536
0
Function that webscrapes METAR data from specified URL, returning a list of METAR dictionary items for further processing
def read_metar_ZA(metar_url, date_as_ISO_text=False): metar_list = [] # The list of dictionaries that will be returned, containing METAR data # Regular expressions to extract the wind re_wind_no_gust = re.compile(r'(?P<direction>[0-9]{3,3})(?P<spd>[0-9]{2,2})KT') # 10005KT re_wind_gust = re.c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scrape_mars():\n (news_title, news_p) = scrape_news()\n\n\n mars_data = {\n \"news_title\": news_title,\n \"news_p\": news_p,\n \"jpl_url\": scrape_jpl_images(),\n \"facts_tbl\": scrape_mars_facts(),\n \"weather\": scrape_weather(),\n \"hemi_pct\": scrape_hemisph...
[ "0.6425863", "0.62656265", "0.61560684", "0.61202806", "0.6082322", "0.60705894", "0.603539", "0.602477", "0.59803134", "0.5978208", "0.5974024", "0.5970704", "0.5949197", "0.59491205", "0.59410346", "0.59403086", "0.5926911", "0.59215087", "0.58880013", "0.58857656", "0.5870...
0.679931
0
Function that accepts METAR data, and creates a list of GEOJSON features
def generate_metar_geojson(metar_list): # Initialise Variables metar_features = [] # If there are no Metars (incase None is passed) if metar_list is None: return metar_features #Get the colours colr = current_app.config['WEATHER_METAR_COLOUR'] opacity = current_app.config[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0]['geometry']]", "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0]['geometry']]", "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0][...
[ "0.67721707", "0.67721707", "0.67721707", "0.67712075", "0.6762713", "0.6726054", "0.6585093", "0.6470925", "0.646173", "0.6427646", "0.6305461", "0.61622536", "0.60196996", "0.59077334", "0.59004563", "0.5895464", "0.58717555", "0.586631", "0.58627445", "0.58431137", "0.5829...
0.7444071
0
Function that webscrapes TAF data from specified URL, returning a list of TAF dictionary items for further processing
def read_taf_ZA(taf_url): taf_list = [] # The list of disctionaries that will be returned, containing SIGMAT/AIRMET data # Retrieve the webpage containing TAF data try: r = requests.get(taf_url, verify=False) except: current_app.logger.error(f"Error retrieving TAF - faile...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_data_in_api(url: str) -> list:\n\n try:\n resp = requests.request('GET', url, timeout=10)\n resp.raise_for_status\n\n return Froxy._data_filter(resp.text)\n\n except (\n requests.ConnectionError,\n requests.ConnectTimeout,\n r...
[ "0.66955215", "0.64286023", "0.6310379", "0.62667525", "0.6012198", "0.5954974", "0.59443146", "0.5918982", "0.5910473", "0.58493155", "0.5826196", "0.58011115", "0.5792379", "0.5791782", "0.5757033", "0.5722308", "0.57221663", "0.5651222", "0.56475663", "0.56458086", "0.5624...
0.6669442
1
Function that accepts METAR data, and creates a list of GEOJSON features
def generate_taf_geojson(taf_list): # Initialise Variables taf_features = [] # If there are no TAFs (incase None is passed) if taf_list is None: return taf_features #Get the colours colr = current_app.config['WEATHER_TAF_COLOUR'] opacity = current_app.config['WEATHER_TAF_O...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_metar_geojson(metar_list):\n\n # Initialise Variables\n metar_features = []\n \n # If there are no Metars (incase None is passed)\n if metar_list is None:\n return metar_features\n \n #Get the colours\n colr = current_app.config['WEATHER_METAR_COLOUR']\n opacity = cur...
[ "0.74435794", "0.67717606", "0.67717606", "0.67717606", "0.67702174", "0.6762394", "0.67256373", "0.65845263", "0.64701325", "0.6459503", "0.64272827", "0.6160495", "0.6018191", "0.5905373", "0.59010315", "0.5893976", "0.586995", "0.5866002", "0.5861123", "0.5841767", "0.5828...
0.63043964
11
Calculates and displays the program execution time.
def decorator(func): @functools.wraps(func) def inner(*args, **kwargs): start_time = time.time() func_result = func(*args, **kwargs) end_time = time.time() print(f'Time of execution of function "{func.__name__}": {end_time - start_time}') return func_result return inn...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exec_time(pl, segment_info):\n\n execution_time = getattr(segment_info.get(\"args\", None), \"execution_time\", 0)\n\n if execution_time:\n return [{\"contents\": f\"{execution_time:.2f}s\", \"highlight_groups\": [\"exec_time\"]}]", "def get_execution_time(self):\n self.execution_time = s...
[ "0.72106165", "0.7019986", "0.6822447", "0.6727521", "0.66923654", "0.65527064", "0.6526042", "0.6481335", "0.6347902", "0.6328485", "0.63142514", "0.631107", "0.6273711", "0.6248238", "0.6245437", "0.6218554", "0.6195462", "0.6185571", "0.6178434", "0.61587846", "0.6154177",...
0.0
-1
Returns a full path to the ISO 31661 alpha2 country code flag image.
def iso_flag(country_id, flag_path=u''): if country_id == '999': #Added for internal call - ie flag/phone.png return util_iso_flag('telephone', flag_path) try: obj_country = Country.objects.get(id=country_id) except: return u'' return util_iso_flag(obj_country.iso2, flag_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def country(alpha_2_code: str) -> None:", "def render_country_flag(self, width=40, height=27):\n try:\n flag_sign = self.user_info.country\n except:\n flag_sign = \"unk\"\n flag_path = f\"{IMG_FLAG_PATH}/{flag_sign}.png\"\n flag_img = Image.open(flag_path)\n ...
[ "0.6972606", "0.69058347", "0.6607304", "0.6459977", "0.63380766", "0.63158983", "0.6295187", "0.61313975", "0.6060842", "0.58440673", "0.5756431", "0.5609829", "0.5550354", "0.5505986", "0.5492482", "0.54741657", "0.5431371", "0.540271", "0.5379321", "0.5333902", "0.52401537...
0.65400416
3
Returns a country name >>> country_name(198) u'Spain'
def country_name(country_id): if country_id == '999': #Added for internal call - ie flag/phone.png return _('internal call').title() try: obj_country = Country.objects.get(id=country_id) return obj_country.countryname except: return _('unknown').title()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def country() -> str:", "def get_country_name(ip_addr):\n global geoip_db_reader\n try:\n name = geoip_db_reader.country(ip_addr).country.name\n return name\n except geoip2.errors.AddressNotFoundError:\n return None", "def city_country(city_name, country_name):\n city_country_c...
[ "0.7970611", "0.74789137", "0.7290018", "0.7256297", "0.72242415", "0.72170895", "0.7174187", "0.7125716", "0.7032557", "0.69968367", "0.6897612", "0.68448883", "0.68448883", "0.6844652", "0.6830179", "0.68273675", "0.68273675", "0.68217665", "0.6775136", "0.67616194", "0.670...
0.8094582
0
Computes maximum profit given an array of integers.
def max_profit(prices: List[int]) -> int:
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mxprofit(array):\n\n #initialize variables\n minimum_val = 10000\n profit = 0\n # edge cases\n if len(array) <= 1:\n return 0\n # iterate through list and store minimum value\n for i in range(len(array)):\n if array[i] < minimum_val:\n minimum_val = array[i]\n ...
[ "0.79491603", "0.7307924", "0.72126335", "0.71998954", "0.71405184", "0.7001814", "0.6913991", "0.681403", "0.6794797", "0.6759049", "0.67483675", "0.6679292", "0.66514146", "0.6540295", "0.6539902", "0.64617467", "0.6461604", "0.6277102", "0.6220039", "0.62115324", "0.620860...
0.7735168
1
Entry point for wxTruss
def run(): REDIRECT = False LOG_FILE = "truss.log" app = App(REDIRECT) app.MainLoop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Init():\n return wx.PySimpleApp()", "def setUp(self):\n self.app = wx.App()\n from sas.sasgui.perspectives.calculator.sld_panel import SldWindow\n self.sld_frame = SldWindow()", "def setup(self):\n self.statusbar = self.CreateStatusBar()\n pub.subscribe(self.update_feed,...
[ "0.65294397", "0.6290108", "0.6167626", "0.6111211", "0.6057925", "0.60288507", "0.60062486", "0.5940461", "0.5831495", "0.5823757", "0.5810578", "0.5807166", "0.57895", "0.5787753", "0.5774457", "0.5758001", "0.5728", "0.5722513", "0.56931776", "0.5652258", "0.56332666", "...
0.5332464
49
Encode an integer to a string, using this base. The ``n`` parameter must be an integer. Returns the encoded string, or raises ``ValueError`` if ``n`` is greater than the largest encodable integer.
def encode(self, n): if n > self.max_encodable_value: raise ValueError( '%d is greater than the largest encodable integer (%d)' % ( n, self.max_encodable_value)) ret = [] for base in reversed(self.bases): n, d = divmod(n, len(base)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_int(n):\n return struct.pack(\">I\", n)", "def encode(n, minlen=1, charset=CHARSET_DEFAULT):\n\n chs = []\n while n > 0:\n r = n % BASE\n n //= BASE\n\n chs.append(charset[r])\n\n if len(chs) > 0:\n chs.reverse()\n else:\n chs.append('0')\n\n s = ''...
[ "0.7220351", "0.70059884", "0.6887076", "0.62927896", "0.6291305", "0.62205064", "0.62073284", "0.61941147", "0.6176299", "0.61528087", "0.6137992", "0.6087266", "0.6072454", "0.6028726", "0.59832066", "0.59443367", "0.5895882", "0.58804363", "0.5871919", "0.5861902", "0.5858...
0.85049254
0
Decode a string to an integer, using this base. The ``x`` parameter must be a string as long as the ``bases`` sequence. Returns the decoded integer or raises ``ValueError`` if the length of ``x`` is not equal to the length of ``bases`` or any of the characters in ``x`` aren't valid digits for their position.
def decode(self, x): if len(x) != len(self.bases): raise ValueError( "the length of %r (%d) doesn't match the number of bases (%d)" % ( x, len(x), len(self.bases))) ret = 0 for base, d in zip(self.bases, x): ret = (ret * len(base)) + b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_to_int(string, base):\n if string==\"0\" or base <= 0 : return 0 \n result = 0 \n return result", "def int2base(x: int, base: int, fixed_length: int=None):\n if x < 0:\n sign = -1\n elif x == 0:\n string_repr = digs[0]\n if fixed_length is None:\n return string_r...
[ "0.61489844", "0.5960833", "0.59521884", "0.5633632", "0.56069225", "0.52934", "0.5220636", "0.5193034", "0.5165642", "0.51576704", "0.51355946", "0.5104095", "0.50997156", "0.50545096", "0.50545096", "0.50545096", "0.50545096", "0.50119114", "0.498523", "0.49698025", "0.4967...
0.7865437
0
Hook for printing test info at the end of the run
def pytest_terminal_summary(self, terminalreporter, exitstatus): # pylint: disable=unused-argument terminalreporter.section("Test Information") for test, info in self._info.items(): for datum in info: terminalreporter.write("{}: {}\n".format(test, datum))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_test_end(self, logs=None):", "def print_tests_results(self):\n\n for test in self.test_report:\n for detail in test:\n print detail + ': ', test[detail]", "def after_test(self, test_results):\n pass", "def finished_tests(self):\n self.testing = 0", "def...
[ "0.7061018", "0.7012083", "0.6846902", "0.683092", "0.67475545", "0.6734219", "0.6713046", "0.6688589", "0.6665808", "0.6642811", "0.66352355", "0.65512955", "0.65462345", "0.6542783", "0.6532977", "0.6515521", "0.6494944", "0.6448652", "0.6415064", "0.6410262", "0.64007336",...
0.6952472
2
Fixture to collect test information
def test_info(self, request): def add_info(info): """ Adds information about test """ self._info[get_test_name(request)].append(info) return add_info
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUpFixture(self):\n pass", "def fixtures():", "def _fixture_setup(self):\n pass", "def tests():", "def setUp(self):\n \n \n pass", "def setUp(self):\n \n \n pass", "def setUp(self):\n \n \n pass", "def setUp(self):\n ...
[ "0.78863573", "0.7406759", "0.72761816", "0.70287377", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.69803447", "0.6944923", "0.69162107", "0.68811184", "0.68100774", "0.6783561", "0.6783561", "0.6771368", "...
0.0
-1
Adds information about test
def add_info(info): self._info[get_test_name(request)].append(info)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_info(self, request):\n def add_info(info):\n \"\"\"\n Adds information about test\n \"\"\"\n self._info[get_test_name(request)].append(info)\n return add_info", "def addTest(self, test):\r\n self.tests.append(test)\r\n return", "d...
[ "0.8229106", "0.70418406", "0.65376693", "0.6416931", "0.6405385", "0.6334821", "0.63047326", "0.6282116", "0.6282116", "0.6248777", "0.62369514", "0.6232264", "0.61616373", "0.6148637", "0.6100409", "0.6083263", "0.6083263", "0.6083263", "0.6074645", "0.60481167", "0.6041077...
0.7915905
1
Get the name of test from pytest
def get_test_name(request): return request.node.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_name(self):\r\n parts = []\r\n if self.test.__module__ != '__main__':\r\n parts.append(self.test.__module__)\r\n if hasattr(self.test, 'im_class'):\r\n parts.append(self.test.im_class.__name__)\r\n parts.append(self.test.__name__)\r\n return '.'.joi...
[ "0.7740926", "0.75483805", "0.73176926", "0.7204362", "0.71841866", "0.71463156", "0.7077052", "0.7024453", "0.70059586", "0.7001924", "0.69533515", "0.6859819", "0.6842871", "0.66159713", "0.65816325", "0.6579322", "0.6577945", "0.6569382", "0.656736", "0.6499752", "0.647495...
0.7322088
2
Add plugin to pytest
def pytest_configure(config): config.pluginmanager.register(InfoCollector(), "info_collector")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pytest_addhooks(pluginmanager):\n pluginmanager.add_hookspecs(hooks)", "def test(self, plugin):\n plug = plugin_source.load_plugin(plugin)\n plug.test()", "def test_register():\n plug.manager.register(junit4)", "def pytest_addhooks(pluginmanager):\n from . import newhooks\n\n pluginmana...
[ "0.7234708", "0.721785", "0.7095319", "0.70750463", "0.70336837", "0.69315594", "0.67349714", "0.67028946", "0.66373354", "0.65710366", "0.6470139", "0.64665073", "0.6347658", "0.63464683", "0.6304243", "0.6304148", "0.62766325", "0.62333", "0.6212018", "0.6204601", "0.617703...
0.70905674
3
Function that a set of data and automatically selects an appropriate range to view the values.
def mlp_window_selector(data, num_divs=5): # convert the first aspect of data back into time series # to be analyzed ts_data = pp.db2ts(data[0]) # get mean of data mean_val = ts_data.mean() # get standard deviation of data std_val = ts_data.std() # return window of num_divs standard devi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range_callback(data):\n global D\n D.ranges = data.ranges", "def _select_by_range(self, disc_low, disc_high):\n sqlstmt = \"SELECT h FROM %s WHERE d>=? and d<=?\" % self.VIEW\n pickup = self.cursor.execute(sqlstmt, (disc_low, disc_high,))\n return [h[0] for h in pickup]", "def te...
[ "0.7026572", "0.64478236", "0.6339455", "0.63318616", "0.63155687", "0.62450445", "0.62307733", "0.6224115", "0.6207277", "0.6205756", "0.6181796", "0.61208385", "0.6108447", "0.6085709", "0.60706174", "0.6060498", "0.6060038", "0.60482556", "0.60300577", "0.6028894", "0.6017...
0.0
-1
Function that takes a range of input data defined from in a tuple window and squashes it into a range of 0 to 1.
def mlp_input_mapper(data, window): # get factor to scale data by mult = 1 / (window[1] - window[0]) # return scaled data with minimum value offset return mult * (data - window[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_scale(data, wl, ww, dtype, out_range):\n\n data_new = np.empty(data.shape, dtype=np.double)\n data_new.fill(out_range[1] - 1)\n\n data_new[data <= (wl - ww / 2.0)] = out_range[0]\n data_new[(data > (wl - ww / 2.0)) & (data <= (wl + ww / 2.0))] = \\\n ((data[(data > (wl - ww / 2.0)) & (da...
[ "0.5799192", "0.57435197", "0.5701046", "0.56862307", "0.56761545", "0.56535137", "0.5609219", "0.55961674", "0.5583874", "0.5559925", "0.5514794", "0.55101657", "0.5492606", "0.548217", "0.54627174", "0.5458353", "0.5453263", "0.54485935", "0.54411405", "0.5412793", "0.54080...
0.0
-1
Function that takes a range of input data in a range of 0 to 1 and expands it into a range defined in the tuple window.
def mlp_output_mapper(data, window): # get factor to scale data by mult = window[1] - window[0] # return scaled data offset by minimum value return mult * data + window[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_range(r):\n if isinstance(r, list) or isinstance(r, tuple) and len(r) == 2:\n lower = r[0]\n upper = r[1]\n else:\n lower = r\n upper = r\n lower = int(lower)\n upper = int(upper)\n return range(lower, upper + 1)", "def range(self) -> ty.Tuple[float, float]:\r\n...
[ "0.6836311", "0.6782098", "0.653994", "0.64681834", "0.6448804", "0.6432711", "0.63097966", "0.6284971", "0.62718165", "0.62694746", "0.62667435", "0.6244153", "0.62152034", "0.62103444", "0.6174627", "0.61221653", "0.61018384", "0.61001575", "0.6092767", "0.60758036", "0.606...
0.0
-1
Takes in a tuple of 2 numpy matrices, a tuple of layers, and an integer. Returns tuple with a MLPRegressor model and a tuple. Creates a multilayer perceptron model with a provided number of hidden layers. Trains the model with provided data.
def mlp_model(train, layers=(100,), window_size=5): # generate a window window = mlp_window_selector(train, window_size) # interpolate new data train_x = mlp_input_mapper(train[0], window) train_y = mlp_input_mapper(train[1], window) # generate model model = MLPRegressor(hidden_layer_sizes=t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000,\r\n dataset='mnist.pkl.gz', batch_size=20, n_hidden=500):\r\n datasets = load_data(dataset)\r\n\r\n train_set_x, train_set_y = datasets[0]\r\n valid_set_x, valid_set_y = datasets[1]\r\n test_set_x, test_set_y = data...
[ "0.65499324", "0.64408076", "0.63840145", "0.63513124", "0.62518644", "0.62417245", "0.62325275", "0.6184379", "0.60457563", "0.60316384", "0.6014735", "0.59431326", "0.59126353", "0.58972156", "0.5835209", "0.58220255", "0.5813621", "0.5739834", "0.57342285", "0.57225025", "...
0.7192432
0
Takes in a tuple containing a MLPRegressor object and a tuple as well a string. Returns a numpy matrix. Predicts a future set of values from a given set of values and a trained model.
def mlp_forecast(model_data, x_filename): # extract model and tree from model data model = model_data[0] window = model_data[1] # grab test data from file x = fio.read_from_file(x_filename) x = x.to_numpy() # predict values y_hat = model.predict(x) # interpolate predicted values to r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_model(pfi_fitted_models, x):\n model_params = pickle.load(open(pfi_fitted_models, 'rb'))\n model = MLPClassifier()\n model.set_params(**model_params)\n y = model.predict(x)\n model.predict_proba(x)\n return y", "def run_MLP_model(file_path):\n\n df_train = pd.read_csv(f'{file_path}...
[ "0.568368", "0.5478499", "0.5434221", "0.537375", "0.537277", "0.5282908", "0.5280125", "0.5257493", "0.52564204", "0.52533484", "0.5222095", "0.5199169", "0.5193148", "0.5165295", "0.51566654", "0.5062166", "0.5049715", "0.5043125", "0.5031245", "0.50224423", "0.50197405", ...
0.47919896
53
Returns answer in string format.
def get_ans_str(self): if self.lese_antwort != "": return self.lese_antwort elif isinstance(self.antwort,str): return self.antwort else: return self.antwort[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formula_answer_to_str(self, answer):\r\n return str(answer.values()[0])", "def numerical_answer_to_str(self, answer):\r\n return str(answer.values()[0])", "def get_answer_sets_string(self):\n return self._output", "def __str__(self):\n return f'{self.text}: {self.chs}, correct...
[ "0.759154", "0.745845", "0.6839676", "0.6805988", "0.66036165", "0.65512604", "0.64769435", "0.63597333", "0.63384247", "0.6235071", "0.62252694", "0.61882913", "0.61511284", "0.6109478", "0.60948837", "0.6076179", "0.6057921", "0.6021739", "0.5992071", "0.5947261", "0.593161...
0.0
-1
Creates Withholding for taxes in invoice
def action_move_create_withholding(self): account_move = self.env['account.move'] aitw_obj = self.env['account.invoice.tax.wh'] for invoice_brw in self: if invoice_brw.type not in ('out_invoice', 'out_refund'): continue if not invoice_brw.wh_agent_itbms: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def withholding_tax_amount(self, withholding_tax_amount):\n\n self._withholding_tax_amount = withholding_tax_amount", "def withholding_tax_rate(self, withholding_tax_rate):\n\n self._withholding_tax_rate = withholding_tax_rate", "def create_invoice(self):\n sales_tax = 0.06\n item_s...
[ "0.64049727", "0.6330529", "0.61386544", "0.611488", "0.5884036", "0.56877345", "0.56771636", "0.5668548", "0.56052196", "0.55591106", "0.55289155", "0.55289155", "0.54594743", "0.54070324", "0.5400555", "0.5374065", "0.5350586", "0.53499526", "0.5275051", "0.52569675", "0.52...
0.6966169
0
Reconciles Journal Items from wh_move_id with those in move_id on Invoice
def withholding_reconciliation(self): for inv_brw in self: move_ids = [move.id or False for move in (inv_brw.move_id, inv_brw.wh_move_id)] if not all(move_ids): continue line_ids = [line.id for move2 in (inv_b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_move_create(self):\n inv_obj = self.env['account.invoice']\n context = dict(self._context or {})\n context.update({'wh_src': True})\n ret = self.browse(self.ids[0])\n for line in ret.line_ids:\n if line.move_id:\n raise exceptions.except_orm(\...
[ "0.63243365", "0.61625314", "0.61472505", "0.6111761", "0.60908127", "0.5999309", "0.59442294", "0.594249", "0.58354235", "0.57971066", "0.56660414", "0.5593522", "0.5560802", "0.5486944", "0.5402961", "0.53856784", "0.5363463", "0.53625727", "0.5319842", "0.5210515", "0.5201...
0.55360174
13
Create and setup the base vtk and Qt objects for the application
def setup(): renderer = vtk.vtkRenderer() frame = QtWidgets.QFrame() vtk_widget = QVTKRenderWindowInteractor() interactor = vtk_widget.GetRenderWindow().GetInteractor() render_window = vtk_widget.GetRenderWindow() frame.setAutoFillBackground(True) vtk_widget.GetR...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self):\n raise NotImplementedError(\"\"\"The create method must be overridden to\n build desired vtk objects.\"\"\")", "def __init__(self, background_color=(0, 0, 0)):\n QtWidgets.QMainWindow.__init__(self)\n self.frame = QtWidgets.QFrame()\n self.setCentralWidge...
[ "0.67277646", "0.6394425", "0.6386949", "0.63848686", "0.63642865", "0.63218343", "0.6316782", "0.6250288", "0.6237879", "0.61253744", "0.6118074", "0.6117805", "0.60873276", "0.6083839", "0.606485", "0.6062236", "0.6044137", "0.60299915", "0.6014983", "0.6009766", "0.5957483...
0.70242107
0
Add the right panel with the 3D visualisation
def add_vtk_window_widget(self): base_brain_file = os.path.basename(self.app.BRAIN_FILE) base_mask_file = os.path.basename(self.app.MASK_FILE) object_title = "Brain: {0} (min: {1:.2f}, max: {2:.2f}) Mask: {3}".format(base_brain_file, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_3D_pane(self):\n\t\t\n panel = wx.Panel(self,-1)\n self.interactor3d = wxVTKRenderWindowInteractor(panel, -1, (600,800))\n self.generate_button = wx.Button(panel, label=\"Generate 3D view\")\n self.text_position = wx.StaticText(panel, -1, \"Dose (Gy) \" , wx.Point(0, 0))\n ...
[ "0.7066716", "0.6565009", "0.6263389", "0.6201313", "0.61965835", "0.616014", "0.60445744", "0.6003448", "0.5930823", "0.592739", "0.591829", "0.589529", "0.588953", "0.58845276", "0.5877881", "0.58631164", "0.58577293", "0.5850434", "0.5786609", "0.57590353", "0.5737576", ...
0.52690965
81
Add the sub panel on the left with settings for brain
def add_brain_settings_widget(self): brain_group_box = QtWidgets.QGroupBox("Brain Settings") brain_group_layout = QtWidgets.QGridLayout() brain_group_layout.addWidget(QtWidgets.QLabel("Brain Threshold"), 0, 0) brain_group_layout.addWidget(QtWidgets.QLabel("Brain Opacity"), 1, 0) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_main_panel(self):\n self.panel = wx.Panel(self)\n\n self.init_plot()\n self.canvas = FigCanvas(self.panel, -1, self.fig)\n\n self.control_box = VSControlBox(self.panel, -1, 'Information board')\n\n self.vbox = wx.BoxSizer(wx.VERTICAL)\n self.vbox.Add(self.canvas...
[ "0.68242514", "0.6602312", "0.6473155", "0.63659334", "0.63317436", "0.6184717", "0.61798185", "0.6107248", "0.60519683", "0.6035619", "0.60153145", "0.5994831", "0.5992389", "0.5903108", "0.58874834", "0.5887204", "0.5867474", "0.5858173", "0.5849087", "0.58485144", "0.58424...
0.6382162
3
Add the sub panel on the left with settings for brain mask
def add_mask_settings_widget(self): mask_settings_group_box = QtWidgets.QGroupBox("Mask Settings") mask_settings_layout = QtWidgets.QGridLayout() mask_settings_layout.addWidget(QtWidgets.QLabel("Mask Opacity"), 0, 0) mask_settings_layout.addWidget(QtWidgets.QLabel("Mask Smoothness"), 1, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_band_panel(self):\n return pn.Column(\n pn.Column(\n pn.Row(self.get_controls(), margin = (0, 0, -25, 0)),\n pn.pane.HoloViews(self.get_band_dmap(), linked_axes=False)\n ), \n )", "def get_c...
[ "0.65422624", "0.6476052", "0.62223786", "0.598249", "0.5715778", "0.57083434", "0.56779176", "0.5656965", "0.5568639", "0.55481195", "0.55389494", "0.5529578", "0.54869", "0.54769105", "0.5476717", "0.54420865", "0.5439609", "0.5411751", "0.54111445", "0.5363934", "0.535905"...
0.59215504
4
Add the sub panel on the left with views buttons
def add_views_widget(self): axial_view = QtWidgets.QPushButton("Axial") coronal_view = QtWidgets.QPushButton("Coronal") sagittal_view = QtWidgets.QPushButton("Sagittal") views_box = QtWidgets.QGroupBox("Views") views_box_layout = QtWidgets.QVBoxLayout() views_box_layout.a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_panel_navigation(self, frame_parent):\r\n panel = ttk.Frame(frame_parent)\r\n\r\n tree = ttk.Treeview(panel, selectmode=\"browse\") # \"browse\" mode limits to one selection only\r\n tree.heading(\"#0\", text=\"Category\")\r\n tree.column(\"#0\", width=130)\r\n #tree.b...
[ "0.67460495", "0.6687249", "0.6677883", "0.65024054", "0.6402304", "0.63572675", "0.634558", "0.6296992", "0.6292711", "0.6191439", "0.618178", "0.61724126", "0.6164306", "0.60952884", "0.60929817", "0.6078886", "0.6065144", "0.6039072", "0.60290015", "0.60224766", "0.6014845...
0.6413611
4