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
get box sizes that are wither 2N or 32N, within the limits set by the user
def _get_box_sizes(self, image_info, cat): file_id=0 impath=image_info['image_path'][file_id].strip() ext=image_info['image_ext'][file_id] wcs_data = fitsio.read_header(impath, ext=ext) wcs = eu.wcsutil.WCS(wcs_data) jacob = wcs.get_jacobian(100,100) dudcol, dudrow, dvdcol, dvdrow = jacob det = dvdrow*dudcol - dvdcol*dudrow pixel_scale = np.sqrt(abs(det)) print('found pixel scale:',pixel_scale) box_size = cat['box_size_arcsec']/pixel_scale # clip to range box_size.clip( min=self['min_box_size'], max=self['max_box_size'], out=box_size, ) box_size = box_size.astype('i4') w,=np.where( ( (box_size % 2) != 0 ) ) if w.size > 0: box_size[w] += 1 return box_size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_compute_box_size(self):\n def compute_best_size_for(dim):\n size = ((self.element_space[dim]-1)//self.box_space[dim]) + 1\n size += 2 * self.ghost_space[dim]\n while size % Level.BOX_ALIGNMENTS[dim]:\n size += 1\n return size\n\n r...
[ "0.6898253", "0.67774564", "0.6747777", "0.6713784", "0.6704732", "0.66019756", "0.66019756", "0.65982324", "0.6596363", "0.6499011", "0.64778125", "0.6461232", "0.643119", "0.6366755", "0.6308479", "0.6291537", "0.6291537", "0.6284666", "0.6251369", "0.6221639", "0.6197825",...
0.7289415
0
won't load any data yet because the files are gzipped and just reading the header takes 2.6 G and a long time! This means we need to set magzp and scale later when we read
def _make_image_info_hst(self, flistname): flist=[] magzp_list=[] with open(flistname) as fobj: for line in fobj: ls = line.split() fname = ls[0] magzp = float(ls[1]) #fname=line.strip() flist.append(fname) magzp_list.append(magzp) magzp = np.array(magzp_list) nimage = len(flist) path_len = max([len(f) for f in flist]) try: ext_len = len(self['image_ext']) except: ext_len=None #image_info = meds.util.get_image_info_struct( image_info = get_image_info_struct( nimage, path_len, ext_len=ext_len, ) image_info['position_offset'] = 1 image_info['image_ext'] = self['image_ext'] image_info['weight_ext'] = self['weight_ext'] for i,f in enumerate(flist): image_info['image_id'][i] = i image_info['image_path'][i] = f image_info['weight_path'][i] = f.replace('sci.fits','wht.fits') image_info['magzp'] = magzp image_info['scale'] = self._get_scale_from_magzp(magzp) return image_info
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_datafile(self,path):\n \tlabels, images = [], []\n \twith gzip.GzipFile(path) as f:\n \t for line in f:\n \t vals = line.strip().split()\n \t labels.append(float(vals[0]))\n \t images.append([float(val) for val in vals[1:]])\n \tlab...
[ "0.61328614", "0.6049478", "0.5808387", "0.5781122", "0.569807", "0.5556485", "0.5516141", "0.5501835", "0.54966", "0.54787964", "0.5472631", "0.5433721", "0.54056853", "0.5392633", "0.5383074", "0.5370794", "0.53649384", "0.5350947", "0.53504694", "0.5339291", "0.53373736", ...
0.5289991
25
won't load any data yet because the files are gzipped and just reading the header takes 2.6 G and a long time! This means we need to set magzp and scale later when we read
def _make_image_info_des(self, flistname): flist=[] psfex_flist=[] magzp_list=[] with open(flistname) as fobj: for line in fobj: ls = line.split() fname = ls[0] magzp = float(ls[1]) magzp_list.append(magzp) flist.append(fname) psfex_fname = fname.replace('.fits.fz','_psfcat.psf') psfex_flist.append(psfex_fname) nimage = len(flist) magzp = np.array(magzp_list) path_len = max([len(f) for f in flist]) psfex_path_len = max([len(f) for f in psfex_flist]) try: ext_len = len(self['image_ext']) except: ext_len=None extra_dtype = [ ('psfex_path','U%d' % psfex_path_len), ] #image_info = meds.util.get_image_info_struct( image_info = get_image_info_struct( nimage, path_len, ext_len=ext_len, extra_dtype=extra_dtype, ) image_info['position_offset'] = 1 image_info['image_ext'] = self['image_ext'] image_info['weight_ext'] = self['weight_ext'] for i,f in enumerate(flist): image_info['image_id'][i] = i image_info['image_path'][i] = f image_info['weight_path'][i] = f image_info['psfex_path'][i] = psfex_flist[i] image_info['magzp'] = magzp image_info['scale'] = self._get_scale_from_magzp(magzp) return image_info
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_datafile(self,path):\n \tlabels, images = [], []\n \twith gzip.GzipFile(path) as f:\n \t for line in f:\n \t vals = line.strip().split()\n \t labels.append(float(vals[0]))\n \t images.append([float(val) for val in vals[1:]])\n \tlab...
[ "0.6133056", "0.604979", "0.5808275", "0.57805765", "0.56968015", "0.55559903", "0.55156744", "0.5501627", "0.5496729", "0.54792094", "0.5473201", "0.54323983", "0.5407194", "0.5392547", "0.53821784", "0.5369768", "0.53655523", "0.5352017", "0.5350997", "0.5338158", "0.533610...
0.5056924
69
get the scale factor required to put the image on the reference zero point
def _get_scale_from_magzp(self, magzp): scale = 10.0**( 0.4*(self['magzp_ref']-magzp) ) return scale
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_scale():\r\n\r\n \r\n return 0.5", "def scale(self):\n return self.scale_factor / CONSTANTS.AU", "def scale(self):\n return self._scale", "def auto_scale_factor(self):\r\n return self.gref.auto_scale_factor", "def scale(self):", "def pixel_scale(self):\n return np.ab...
[ "0.7939209", "0.75170743", "0.7390683", "0.7387904", "0.72454107", "0.72146994", "0.71663", "0.7162196", "0.7084686", "0.70655787", "0.6965191", "0.69290656", "0.6879681", "0.6862533", "0.684772", "0.6845276", "0.68248934", "0.6792253", "0.6792253", "0.6774864", "0.67718226",...
0.65182626
38
run fpack on the file
def _compress_meds_file(self, ucfilename, fzfilename): from os.path import basename tup=(basename(ucfilename),basename(fzfilename)) print('compressing file: %s -> %s' % tup) tpath=files.expandpath(fzfilename) if os.path.exists(tpath): os.remove(tpath) tmpdir = os.path.dirname(ucfilename) with StagedOutFile(fzfilename,tmpdir=tmpdir) as sf: cmd = self['fpack_command'] cmd = cmd.format(fname=ucfilename) ret=os.system(cmd) if ret != 0: raise RuntimeError("failed to compress file") print('output is in:',fzfilename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fpack (filename):\n\n try:\n\n # fits check if extension is .fits and not an LDAC fits file\n if filename.split('.')[-1] == 'fits' and '_ldac.fits' not in filename:\n header = read_hdulist(filename, get_data=False, get_header=True,\n ext_name_indices...
[ "0.73205775", "0.65307117", "0.6463891", "0.64161015", "0.63932323", "0.60954076", "0.60115385", "0.6011121", "0.5907196", "0.57618356", "0.57582206", "0.57581705", "0.57459545", "0.5699288", "0.5696721", "0.56722516", "0.56167424", "0.56135565", "0.55333644", "0.55249065", "...
0.63310814
5
get the image info structure Set default scale to 1.0. The other fields are 0 for numbers, or blank for strings
def get_image_info_struct(nimage, path_len, image_id_len=None, wcs_len=None, ext_len=None, extra_dtype=None): dt = get_image_info_dtype( path_len, image_id_len=image_id_len, wcs_len=wcs_len, ext_len=ext_len, extra_dtype=extra_dtype, ) data = np.zeros(nimage, dtype=dt) data['scale'] = 1.0 return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_info(img):\n\tprint(img.format)\n\tprint(img.size)\n\tprint(img.mode)", "def image_data_info(page):\n xObject = page['/Resources']['/XObject'].getObject()\n\n for obj_key in xObject:\n obj = xObject[obj_key]\n if obj['/Subtype'] == '/Image':\n width, height = (obj['/Width...
[ "0.647343", "0.6325045", "0.6177507", "0.61103743", "0.61006016", "0.60990447", "0.60865074", "0.6057824", "0.6057824", "0.6057824", "0.6057824", "0.6057824", "0.59974873", "0.5942097", "0.5923346", "0.58519304", "0.5841813", "0.5808897", "0.57983494", "0.5795056", "0.5779866...
0.65033776
0
get the image_info dtype for the specified path string length and wcs string length
def get_image_info_dtype(path_len, image_id_len=None, wcs_len=None, ext_len=None, extra_dtype=None): path_fmt = 'U%d' % path_len if image_id_len is None: image_id_descr = 'i8' else: image_id_descr = 'U%d' % image_id_len if ext_len is not None: ext_descr = 'U%d' % ext_len else: ext_descr = 'i2' dt=[] for ctype in IMAGE_INFO_TYPES: path_name = '%s_path' % ctype ext_name = '%s_ext' % ctype dt += [ (path_name, path_fmt), (ext_name,ext_descr), ] dt += [ ('image_id', image_id_descr), ('image_flags', 'i8'), ('magzp', 'f4'), ('scale', 'f4'), ('position_offset','f8'), ] if wcs_len is not None: wcs_fmt = 'U%d' % wcs_len dt += [ ('wcs',wcs_fmt), ] if extra_dtype is not None: dt += extra_dtype return dt
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image_info_struct(nimage, path_len,\n image_id_len=None,\n wcs_len=None,\n ext_len=None,\n extra_dtype=None):\n dt = get_image_info_dtype(\n path_len,\n image_id_len=image_id_len,\n w...
[ "0.6820558", "0.5704018", "0.5546598", "0.5516806", "0.5513057", "0.54892457", "0.53587013", "0.5346659", "0.5331653", "0.529922", "0.5295019", "0.52838844", "0.5277544", "0.5265453", "0.5226433", "0.5198636", "0.51947224", "0.5194617", "0.5169112", "0.51395136", "0.50898606"...
0.8044237
0
Move files out of subdirectories in the current working directory.
def move_file(): # print("\n".join(os.listdir(filepath))) # folders = [os.path.join(filepath, fld) for fld in os.listdir(filepath)] # print(filepath + ":\n " + "\n ".join(folders)) folders = filter(os.path.isdir, os.listdir(u".")) # print("Sub-folders: ", u"\n".join(folders)) for folder in folders: files = [os.path.join(folder, fn) for fn in os.listdir(folder)] files = filter(os.path.isfile, files) for fn in files: _, filename = os.path.split(fn) shutil.move(fn, filename) assert 0 == len(os.listdir(folder))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moveFiles(outputDir, files):\n\tfor fn in files:\n\t\tshutil.move(fn, join(outputDir, getFilenameWithoutPath(fn)))", "def move_recursively(src, dst, overwrite=False, changed_only=True):\n if os.path.isdir(src):\n movetree(src, dst, overwrite, changed_only)\n else:\n movefile(src, dst, ove...
[ "0.68817514", "0.6756969", "0.66850746", "0.6610166", "0.6560671", "0.65322196", "0.65059394", "0.643787", "0.6378325", "0.63559556", "0.6313153", "0.62905586", "0.62528837", "0.6242785", "0.62256724", "0.6196293", "0.61216223", "0.611683", "0.61057925", "0.61052036", "0.6077...
0.7259415
0
Find duplications in submitted homework.
def find_duplication(homework): re_id = re.compile(r'(?P<stuid>[0-9]{10,11})') dup_check = dict() with open(homework, 'r') as data: lines = data.readlines() for ln in lines: dt = ln.split() csum, right = dt[0], dt[1] if csum not in dup_check: dup_check[csum] = list() m = re_id.search(right) if m is not None: stu_id = m.group('stuid') dup_check[csum].append(stu_id) dup_check = filter(lambda k, v: len(v) > 1, dup_check.items()) dup_check = [(key, sorted(val)) for key, val in dup_check] return dup_check
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _remove_dupes(recs, input, bad_movies, hist_list=[], feedback_list=[]):\n all_rated = input + bad_movies + hist_list + feedback_list\n nonlocal dupes\n dupes = [x for x in recs if x[0] in input]\n return [x for x in recs if x[0] not in all_rated]", "def find_duplic...
[ "0.6404877", "0.6166872", "0.58831835", "0.5859948", "0.58292764", "0.58159447", "0.57876647", "0.5782457", "0.5769974", "0.5762715", "0.5746975", "0.5736089", "0.5733144", "0.57238513", "0.5710152", "0.5654848", "0.553705", "0.5500801", "0.54478735", "0.5438873", "0.54368997...
0.753223
0
Display the duplication check results.
def display_dup(dup_result): lines = [k + ": " + ", ".join(v) for k, v in dup_result] return lines
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def for_duplicates(self):\n print('++++++++++++ Duplicates Check Start+++++++++++++')\n print('Report for:', self.name)\n if not self.df.empty:\n for column in self.df.columns:\n if self.df.duplicated(column).sum() > 0:\n print('Duplicates found in:...
[ "0.6287719", "0.5866031", "0.58241785", "0.57221144", "0.56531405", "0.56339365", "0.56136125", "0.5593977", "0.55925065", "0.55140984", "0.5512862", "0.5487937", "0.5483856", "0.5471412", "0.5454186", "0.53893715", "0.5378345", "0.53769517", "0.5371023", "0.5360018", "0.5356...
0.67122084
0
Load a CSV file into a dict with the first column as the key.
def load_csv_to_dict(filename): row_len = list() result = dict() with open(filename, 'r') as csvfile: reader = csv.reader(csvfile) for row in reader: key = row[0].strip() values = [v.strip() for v in row[1:]] result[key] = values row_len.append(len(values)) return result, max(row_len)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_to_dict(filename):\n\twith open(filename, 'r') as in_hndl:\n\t\tindict = [i for i in csv.DictReader(in_hndl)]\n\treturn indict[0]", "def save_csv_into_dictionary(csv_file):\n\n dictionary = OrderedDict()\n with open(csv_file, newline='') as file:\n reader = csv.reader(file)\n for row ...
[ "0.79064244", "0.7794513", "0.769313", "0.7455252", "0.73723876", "0.73611784", "0.73122406", "0.7276127", "0.72540885", "0.7231248", "0.7229994", "0.7220004", "0.7188417", "0.7093654", "0.7093654", "0.70798486", "0.70293057", "0.70100296", "0.6991526", "0.69660616", "0.69464...
0.7192429
12
Write a dictionary to a CSV file with the key as the first column.
def write_dict_to_csv(filename, data): with open(filename, 'w') as csvfile: writer = csv.writer(csvfile) keys = sorted(data.keys()) for key in keys: value = data[key] row = [str(key)] + [str(v) for v in value] writer.writerow(row)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WriteDictToCSV(csv_file,csv_columns,dict_data):\n with open('history.csv','wb') as csvfile:\n w = csv.writer(csvfile)\n w.writerows(dict_data.items())\n\n return", "def write_csv(dictionary):\n\n with open(constant.METADATA_FILE, 'a', newline='') as file:\n writer = csv....
[ "0.8167452", "0.80611485", "0.79419845", "0.79068524", "0.7865296", "0.786358", "0.7843565", "0.7672604", "0.7624856", "0.7592206", "0.73616445", "0.733697", "0.7334174", "0.7314796", "0.72985274", "0.7286329", "0.72482544", "0.71879077", "0.7168227", "0.71501637", "0.7062585...
0.77208966
7
Merge CSV files based on keywords.
def merge_csv(csv_files): results = dict() data_all = list() keys = set() for filename in csv_files: data, row_len = load_csv_to_dict(filename) keys |= set(data.keys()) data_all.append((data, row_len)) for key in keys: values = list() for value, row_len in data_all: fill = ["0"]*row_len dt = value[key] if key in value else fill values.extend(dt) results[key] = values return results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_csv_files(filelist):\n data = tables.DictList()\n for file_name in filelist:\n reader = csv.DictReader(open(file_name))\n data += list(reader)\n\n return data", "def merge_csv_files(files: List[str], outfile: str):\n\tlogthis.say('Merging files starts.')\n\tdata: pd.DataFrame = p...
[ "0.6509552", "0.6354343", "0.6310943", "0.6292182", "0.6235866", "0.6196554", "0.6100369", "0.6056441", "0.59984165", "0.59235424", "0.5832123", "0.5764415", "0.5726251", "0.5702031", "0.56843436", "0.56209385", "0.56083906", "0.5602722", "0.560202", "0.5594253", "0.5588563",...
0.604583
8
Steps to fetch data from a repo. Return data is passed to self._present
def _fetch_data(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def fetch_data(self) -> GitHubRepositoryModel:\n result = await self._client.repos.get(self.repository)\n return result.data", "def fetch_repo(data):\n repo = Repository.objects.get(**data)\n\n # create a temporary directory\n tmp_dir = util.tmp_dir('github')\n\n # log\n log.in...
[ "0.70215297", "0.6724511", "0.6645503", "0.6416693", "0.6366239", "0.6360344", "0.63311994", "0.62839985", "0.61965615", "0.61965615", "0.617245", "0.6151739", "0.6135985", "0.61268026", "0.6066018", "0.6021011", "0.6002441", "0.59988475", "0.5984806", "0.5982984", "0.5959993...
0.64857197
3
Create a response model to pass to the presenter
def _create_response_model(self, data): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response_model_ctor(self):\n return self._response_model_ctor", "def create_json_from_model(self):\n json = {\n \"enableAutoReply\": self.enable_auto_reply,\n \"responseSubject\": self.response_subject,\n \"responseBodyPlainText\": self.response_body_plain_text,...
[ "0.70443594", "0.63880855", "0.61683625", "0.61580884", "0.6102591", "0.61025757", "0.60942143", "0.60272694", "0.59198946", "0.5912622", "0.5899994", "0.5891911", "0.58650625", "0.58380055", "0.58380055", "0.58321315", "0.5831333", "0.582527", "0.582527", "0.58120483", "0.57...
0.8459162
0
Transform entity into a response model for the presenter
def _make_presentable(self, bookmark): return Bookmark( id= bookmark.id, name=bookmark.name, url=bookmark.url, date_created=bookmark.date_created )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_response_model(self, data):\n pass", "def return_entity(self, entity, request, environ, start_response,\n response_headers, status=200, status_msg=\"Success\"):\n response_type = self.content_negotiation(\n request, environ, self.EntryTypes)\n if r...
[ "0.6371782", "0.6292882", "0.5778668", "0.57751584", "0.5772281", "0.5670169", "0.5642209", "0.56282586", "0.55987585", "0.5566942", "0.5559241", "0.55523074", "0.5506003", "0.5487401", "0.5487401", "0.545934", "0.54588723", "0.5455508", "0.5450392", "0.5440856", "0.5438918",...
0.0
-1
Hybrid Log Gamma test
def main(): for i in range(11): i = i / 10 print('L * 1000', i, L(i) * 1000)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gamma(x):\n return 0.0", "def lgamma(x):\n return 0.0", "def log_gamma_unnormalised_lpdf(x, alpha, beta):\n return alpha * x - beta * tf.exp(x)", "def guestimate_gamma(x_data, time):\n ga0 = np.clip(np.log(max(x_data[0], 0) / (x_data[-1] + 1e-6)) / time[-1], 1e-3, 1e3)\n return ga0",...
[ "0.6843969", "0.6825065", "0.6679971", "0.66503066", "0.6559735", "0.65503234", "0.65369153", "0.6466907", "0.64395845", "0.6437493", "0.6381946", "0.6371749", "0.63404536", "0.628037", "0.62665665", "0.62616044", "0.62610275", "0.62424546", "0.62359", "0.6202875", "0.6190577...
0.0
-1
takes in a string of columns and places alternating checkers in those columns, starting with 'X' For example, call b.setBoard('012345') to see 'X's and 'O's alternate on the bottom row, or b.setBoard('000000') to see them alternate in the left column. moveString must be a string of integers
def setBoard( self, moveString ): nextCh = 'X' # start by playing 'X' for colString in moveString: col = int(colString) if 0 <= col <= self.__width: self.addMove(col, nextCh) if nextCh == 'X': nextCh = 'O' else: nextCh = 'X'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setBoard( self, moveString ):\n nextCh = 'X' # start by playing 'X'\n for colString in moveString:\n col = int(colString)\n if 0 <= col <= self.width:\n self.addMove(col, nextCh)\n if nextCh == 'X': nextCh = 'O'\n else: nextCh = 'X'", "...
[ "0.83378243", "0.8336306", "0.83127975", "0.82836413", "0.722551", "0.7191393", "0.7191393", "0.7191393", "0.7188351", "0.7188351", "0.71681666", "0.71523356", "0.61226887", "0.6058321", "0.582009", "0.5713693", "0.56568706", "0.5623423", "0.5570228", "0.556483", "0.5557871",...
0.83451086
0
Checks if AutoML can be loaded from a folder
def _check_can_load(self): if self.results_path is not None: # Dir exists and can be loaded if os.path.exists(self.results_path) and os.path.exists( os.path.join(self.results_path, "params.json") ): self.load(self.results_path) self._results_path = self.results_path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_load(cls, filename):\n return False", "def in_folder(self):\n return len(os.path.split(self.file_path)) > 1", "def is_valid_animation(path, verbose=True):\n try:\n if \"idle\" in os.listdir(path) or \"transition\" in os.listdir(path):\n return True\n else:\n ...
[ "0.64446145", "0.61130095", "0.60769767", "0.6070284", "0.6070284", "0.5984742", "0.57872206", "0.5693269", "0.566746", "0.5642804", "0.56116366", "0.5606089", "0.56005824", "0.5568455", "0.5547063", "0.55245954", "0.5513016", "0.54848117", "0.5477921", "0.5474287", "0.545193...
0.62103647
1
Validate X whenever one tries to predict, apply, predict_proba
def _validate_X_predict(self, X): # X = check_array(X, ensure_2d=False) X = np.atleast_2d(X) n_features = X.shape[1] if self.n_features_in_ != n_features: raise ValueError( f"Number of features of the model must match the input. Model n_features_in_ is {self.n_features_in_} and input n_features is {n_features}. Reshape your data." )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_features_in_predict_input(self, result):\n pass", "def predict_proba(self, X):\n raise NotImplementedError()", "def predict_proba(self, X, **kwargs):\n raise NotImplementedError", "def predict_proba(self, X):\n X = _validate_X(X)\n return self.best_estimator_.pred...
[ "0.7027119", "0.689992", "0.6828031", "0.67726386", "0.67685646", "0.67366797", "0.6682446", "0.6593702", "0.65868783", "0.65765643", "0.6547521", "0.6528127", "0.6527484", "0.6483978", "0.64814615", "0.64814615", "0.64814615", "0.6477165", "0.6470081", "0.643283", "0.643283"...
0.63079476
35
Fits the AutoML model with data
def _fit(self, X, y, sample_weight=None, cv=None, sensitive_features=None): if self._fit_level == "finished": print( "This model has already been fitted. You can use predict methods or select a new 'results_path' for a new a 'fit()'." ) return # Validate input and build dataframes X, y, sample_weight, sensitive_features = self._build_dataframe( X, y, sample_weight, sensitive_features ) self.n_rows_in_ = X.shape[0] self.n_features_in_ = X.shape[1] self.n_classes = len(np.unique(y[~pd.isnull(y)])) # Get attributes (__init__ params) self._mode = self._get_mode() self._ml_task = self._get_ml_task() self._results_path = self._get_results_path() self._total_time_limit = self._get_total_time_limit() self._model_time_limit = self._get_model_time_limit() self._algorithms = self._get_algorithms() self._train_ensemble = self._get_train_ensemble() self._stack_models = self._get_stack_models() self._eval_metric = self._get_eval_metric() self._validation_strategy = self._get_validation_strategy() self._verbose = self._get_verbose() self._explain_level = self._get_explain_level() self._golden_features = self._get_golden_features() self._features_selection = self._get_features_selection() self._start_random_models = self._get_start_random_models() self._hill_climbing_steps = self._get_hill_climbing_steps() self._top_models_to_improve = self._get_top_models_to_improve() self._boost_on_errors = self._get_boost_on_errors() self._kmeans_features = self._get_kmeans_features() self._mix_encoding = self._get_mix_encoding() self._max_single_prediction_time = self._get_max_single_prediction_time() self._optuna_time_budget = self._get_optuna_time_budget() self._optuna_init_params = self._get_optuna_init_params() self._optuna_verbose = self._get_optuna_verbose() self._n_jobs = self._get_n_jobs() self._random_state = self._get_random_state() if sensitive_features is not None: self._fairness_metric = self._get_fairness_metric() self._fairness_threshold = self._get_fairness_threshold() self._privileged_groups = self._get_privileged_groups() self._underprivileged_groups = self._get_underprivileged_groups() self._adjust_validation = False self._apply_constraints() if not self._adjust_validation: # if there is no validation adjustement # then we can apply stack_models constraints immediately # if there is validation adjustement # then we will apply contraints after the adjustement self._apply_constraints_stack_models() try: self.load_progress() if self._fit_level == "finished": print( "This model has already been fitted. You can use predict methods or select a new 'results_path' for a new 'fit()'." ) return self._check_can_load() self.verbose_print(f"AutoML directory: {self._results_path}") if self._mode == "Optuna": ttl = int(len(self._algorithms) * self._optuna_time_budget) self.verbose_print("Expected computing time:") self.verbose_print( f"Time for tuning with Optuna: len(algorithms) * optuna_time_budget = {int(len(self._algorithms) * self._optuna_time_budget)} seconds" ) self.verbose_print( f"There is no time limit for ML model training after Optuna tuning (total_time_limit parameter is ignored)." ) self.verbose_print( f"The task is {self._ml_task} with evaluation metric {self._eval_metric}" ) self.verbose_print(f"AutoML will use algorithms: {self._algorithms}") if self._stack_models: self.verbose_print("AutoML will stack models") if self._train_ensemble: self.verbose_print("AutoML will ensemble available models") self._start_time = time.time() if self._time_ctrl is not None: self._start_time -= self._time_ctrl.already_spend() # Automatic Exloratory Data Analysis # I disabled EDA, because it won't be supported # I recomend use pandas_profiling or Sweetviz # if self._explain_level == 2: # EDA.compute(X, y, os.path.join(self._results_path, "EDA")) # Save data self._save_data( X.copy(deep=False), y.copy(deep=False), None if sample_weight is None else sample_weight.copy(deep=False), cv, None if sensitive_features is None else sensitive_features.copy(deep=False), ) tuner = MljarTuner( self._get_tuner_params( self._start_random_models, self._hill_climbing_steps, self._top_models_to_improve, ), self._algorithms, self._ml_task, self._eval_metric, self._validation_strategy, self._explain_level, self._data_info, self._golden_features, self._features_selection, self._train_ensemble, self._stack_models, self._adjust_validation, self._boost_on_errors, self._kmeans_features, self._mix_encoding, self._optuna_time_budget, self._optuna_init_params, self._optuna_verbose, self._n_jobs, self._random_state, self._fairness_metric, self._fairness_threshold, self._privileged_groups, self._underprivileged_groups, ) self.tuner = tuner steps = tuner.steps() self.verbose_print( f'AutoML steps: {[s for s in steps if "update_" not in s]}' ) if self._time_ctrl is None: self._time_ctrl = TimeController( self._start_time, self._total_time_limit, self._model_time_limit, steps, self._algorithms, ) self._time_ctrl.log_time( "prepare_data", "prepare_data", "prepare_data", time.time() - self._start_time, ) for step in steps: self._fit_level = step start = time.time() # self._time_start[step] = start if step in ["stack", "ensemble_stacked"] and not self._stack_models: continue if step == "stack": self.prepare_for_stacking() if "hill_climbing" in step or step in ["ensemble", "stack"]: if len(self._models) == 0: raise AutoMLException( "No models produced. \nPlease check your data or" " submit a Github issue at https://github.com/mljar/mljar-supervised/issues/new." ) generated_params = [] if step in self._all_params: generated_params = self._all_params[step] else: generated_params = tuner.generate_params( step, self._models, self._results_path, self._stacked_models, self._total_time_limit, ) if generated_params is None or not generated_params: if "_update_" not in step: self.verbose_print( f"Skip {step} because no parameters were generated." ) continue if generated_params: if not self._time_ctrl.enough_time_for_step(self._fit_level): self.verbose_print(f"Skip {step} because of the time limit.") continue else: model_str = "models" if len(generated_params) > 1 else "model" self.verbose_print( f"* Step {step} will try to check up to {len(generated_params)} {model_str}" ) for params in generated_params: if params.get("status", "") in ["trained", "skipped", "error"]: self.verbose_print(f"{params['name']}: {params['status']}.") continue try: trained = False if "ensemble" in step: trained = self.ensemble_step( is_stacked=params["is_stacked"] ) else: trained = self.train_model(params) params["status"] = "trained" if trained else "skipped" params["final_loss"] = self._models[-1].get_final_loss() params["train_time"] = self._models[-1].get_train_time() if ( self._adjust_validation and len(self._models) == 1 and step == "adjust_validation" ): self._set_adjusted_validation() except NotTrainedException as e: params["status"] = "error" self.verbose_print( params.get("name") + " not trained. " + str(e) ) except Exception as e: import traceback self._update_errors_report( params.get("name"), str(e) + "\n" + traceback.format_exc() ) params["status"] = "error" self.save_progress(step, generated_params) if not self._models: raise AutoMLException("No models produced.") self._fit_level = "finished" self.save_progress() self.select_and_save_best(show_warnings=True) self.verbose_print( f"AutoML fit time: {np.round(time.time() - self._start_time,2)} seconds" ) self.verbose_print(f"AutoML best model: {self._best_model.get_name()}") if self._fairness_metric is not None: # check if we have fair model has_fair_model = False for m in self._models: if m.is_fair(): has_fair_model = True break if not has_fair_model: self.verbose_print( "AutoML can't construct model that meets your fairness criteria." ) self.verbose_print("What you can do?") self.verbose_print( "1. Please include more samples that are not biased." ) self.verbose_print( "2. Please examine the most unfairly treated samples." ) self.verbose_print("3. Please change fairness threshold.") except Exception as e: raise e return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_model():", "def run(self) -> None:\n self.model = self.trainer.train_model(self.model, self.data)", "def build(self):\n labelled_documents = self.get_labelled_documents_queryset()\n\n self.model = self.build_model(labelled_documents)\n self.save_model()", "def build_mode...
[ "0.6559245", "0.61642045", "0.6133834", "0.60486835", "0.60486835", "0.59964865", "0.59934956", "0.5981591", "0.5929513", "0.58844835", "0.5876345", "0.5875687", "0.58711773", "0.5865653", "0.5842758", "0.5839361", "0.58370984", "0.58153534", "0.5811744", "0.58106077", "0.581...
0.0
-1
Append error message to errors.md file.
def _update_errors_report(self, model_name, error_msg): errors_filename = os.path.join(self._get_results_path(), "errors.md") with open(errors_filename, "a") as fout: self.verbose_print(f"There was an error during {model_name} training.") self.verbose_print(f"Please check {errors_filename} for details.") fout.write(f"## Error for {model_name}\n\n") fout.write(error_msg) link = "https://github.com/mljar/mljar-supervised/issues/new" fout.write( f"\n\nPlease set a GitHub issue with above error message at: {link}" ) fout.write("\n\n")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_error(self, msg):\n self._add_message(msg, self._errors)", "def add_error(self, reference_id, error):\n\n with open('runReport.txt', 'a') as report:\n try:\n report.write(\"\\nError: \" + self.domain + \" \" + reference_id + \": \" + error)\n except Exce...
[ "0.68803924", "0.68077487", "0.6791102", "0.6587171", "0.65130657", "0.6467027", "0.6418997", "0.6406481", "0.63759094", "0.6353462", "0.63198704", "0.6297876", "0.62030095", "0.6134235", "0.61272323", "0.60763824", "0.60648596", "0.605622", "0.6027484", "0.5985176", "0.59834...
0.7012683
0
Gets the current mode
def _get_mode(self): self._validate_mode() return deepcopy(self.mode)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mode(self):\r\n return self._api.get_mode()", "def getmode(self):\n return self.mode", "def get_mode(self):\r\n return self.mode", "def currentMode(self):\n logger.debug(\"Func: currentMode/getter\")\n\n return self._currentsDict[\"currentMode\"]", "def getMode(se...
[ "0.91673493", "0.9092009", "0.9040086", "0.89945453", "0.8909406", "0.8863383", "0.8853852", "0.8764516", "0.86753494", "0.8675129", "0.8675129", "0.8675129", "0.8633829", "0.8633829", "0.8633829", "0.8588385", "0.8558855", "0.85565245", "0.8501583", "0.84935856", "0.84677076...
0.8524049
18
Gets the current ml_task. If "auto" it is determined
def _get_ml_task(self): self._validate_ml_task() if self.ml_task == "auto": classes_number = self.n_classes if classes_number == 2: self._estimator_type = "classifier" # for sk-learn api return BINARY_CLASSIFICATION elif classes_number <= 20: self._estimator_type = "classifier" # for sk-learn api return MULTICLASS_CLASSIFICATION else: self._estimator_type = "regressor" # for sk-learn api return REGRESSION else: return deepcopy(self.ml_task)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_current_task():\r\n return current_task", "def _get_current_task():\r\n return current_task", "def get_current_task(self):\n return self.get_current_step().get_last_task()", "def task(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"task\")", "def task(self):\n...
[ "0.77952605", "0.77952605", "0.75856113", "0.7273964", "0.70522803", "0.70522803", "0.70522803", "0.70522803", "0.70522803", "0.6897995", "0.6803446", "0.6802864", "0.67456496", "0.6690138", "0.6611777", "0.6603375", "0.6532655", "0.6522994", "0.64612824", "0.6443876", "0.636...
0.7787898
2
Gets the current results_path
def _get_results_path(self): # if we already have the results path set, please return it if self._results_path is not None: return self._results_path self._validate_results_path() path = self.results_path if path is None: for i in range(1, 10001): name = f"AutoML_{i}" if not os.path.exists(name): self.create_dir(name) self._results_path = name return name # If it got here, could not create, raise expection raise AutoMLException("Cannot create directory for AutoML results") elif os.path.exists(self.results_path) and os.path.exists( os.path.join(self.results_path, "params.json") ): # AutoML already loaded, return path self._results_path = path return path # Dir does not exist, create it elif not os.path.exists(path): self.create_dir(path) self._results_path = path return path # Dir exists and is empty, use it elif os.path.exists(path) and not len(os.listdir(path)): self._results_path = path return path elif os.path.exists(path) and len(os.listdir(path)): raise AutoMLException( f"Cannot set directory for AutoML. Directory '{path}' is not empty." ) raise AutoMLException("Cannot set directory for AutoML results")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_results(self):\n\n return self._local_results_path", "def get_result_path(self):\n return logPath", "def index_path(self):\n\t\treturn os.path.normpath(self.output + \"/\" + self.resultset_index)", "def remote_results(self):\n\n return self._remote_results_path", "def set_res...
[ "0.7681095", "0.7608964", "0.72525233", "0.71424973", "0.65749073", "0.65520835", "0.6454215", "0.6348574", "0.63169134", "0.6294443", "0.6256191", "0.6253854", "0.62473315", "0.6234381", "0.61912316", "0.61699665", "0.6166557", "0.6160031", "0.61576474", "0.6157143", "0.6109...
0.71246856
4
Gets the current total_time_limit
def _get_total_time_limit(self): self._validate_total_time_limit() if self._get_mode() == "Optuna": return None # there no training limit for model in the Optuna mode # just train and be happy with super models :) return deepcopy(self.total_time_limit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_limit(self) -> float:\n return self._time_limit", "def timelimit(self):\n return self._timelimit", "def get_limit_per_second(self):\n pass", "def time_limit(self):\n return 2503", "def get_current_timeout(cls):\n return cls.current().get_timeout()", "def timeli...
[ "0.83728045", "0.8202624", "0.7112865", "0.70121944", "0.7004678", "0.6932539", "0.67398685", "0.673961", "0.6735408", "0.672106", "0.66873527", "0.6636085", "0.66152275", "0.66026795", "0.65750027", "0.65488905", "0.6538491", "0.6528733", "0.6523565", "0.6522034", "0.6504964...
0.78830844
2
Gets the current model_time_limit
def _get_model_time_limit(self): self._validate_model_time_limit() return deepcopy(self.model_time_limit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timelimit(self):\n return self._timelimit", "def time_limit(self) -> float:\n return self._time_limit", "def _get_total_time_limit(self):\n self._validate_total_time_limit()\n if self._get_mode() == \"Optuna\":\n return None # there no training limit for model in the...
[ "0.808775", "0.7704996", "0.73726135", "0.7298717", "0.72923505", "0.6901317", "0.6841979", "0.66637945", "0.6617291", "0.6602201", "0.6576346", "0.6545491", "0.6522294", "0.6522294", "0.62877345", "0.6281024", "0.62770474", "0.6243926", "0.62277204", "0.62133306", "0.6213330...
0.8786821
0
Gets the current algorithms. If "auto" it is determined
def _get_algorithms(self): self._validate_algorithms() if self.algorithms == "auto": if self._get_mode() == "Explain": return [ "Baseline", "Linear", "Decision Tree", "Random Forest", "Xgboost", "Neural Network", ] if self._get_mode() == "Perform": return [ "Linear", "Random Forest", "LightGBM", "Xgboost", "CatBoost", "Neural Network", ] if self._get_mode() == "Compete": return [ "Decision Tree", "Linear", "Random Forest", "Extra Trees", "LightGBM", "Xgboost", "CatBoost", "Neural Network", "Nearest Neighbors", ] if self._get_mode() == "Optuna": return [ "Random Forest", "Extra Trees", "LightGBM", "Xgboost", "CatBoost", "Neural Network", ] else: return deepcopy(self.algorithms)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def algorithms():\n algorith_paradigms = ['Divide-and-conquer', 'Backtrackig', 'Greedy-Algorithms', 'Dynamic-programming']\n return algorith_paradigms", "def get_algorithm(self):\n return self.alg", "def get_algorithm(self):\n pass", "def algorithms(self):\n if self._algorithms is ...
[ "0.72617215", "0.69703907", "0.6834078", "0.649296", "0.64006877", "0.6347613", "0.62988967", "0.62988967", "0.62693024", "0.62255967", "0.6208306", "0.6183921", "0.6171044", "0.6160205", "0.6155423", "0.6155423", "0.60712767", "0.60712767", "0.6055243", "0.6055243", "0.60232...
0.79699975
0
Gets the current train_ensemble
def _get_train_ensemble(self): self._validate_train_ensemble() return deepcopy(self.train_ensemble)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensemble(self):\n return self._ensemble", "def getTrainSet(self):\r\n return self.fTrainData", "def training_set(self):\n return self._training_set", "def getTrainInstance(self): #NOTE: Probably faster way of doing this than additional 'if' statement every learning iteration\r\n ...
[ "0.82772297", "0.6414114", "0.6375453", "0.63674873", "0.62640953", "0.6179646", "0.6133189", "0.6104231", "0.6051133", "0.59600097", "0.5959593", "0.5959593", "0.59380734", "0.59326303", "0.58842814", "0.58842814", "0.58842814", "0.58842814", "0.58842814", "0.58842814", "0.5...
0.84837633
0
Gets the current stack_models
def _get_stack_models(self): self._validate_stack_models() if self.stack_models == "auto": val = self._get_validation_strategy() if val.get("validation_type", "") == "custom": return False return True if self.mode in ["Compete", "Optuna"] else False else: return deepcopy(self.stack_models)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def models(self):\r\n return self.get_field('model')", "def models(self):\r\n return self.get_field('model')", "def get_models(self):\n self.load()\n return self._models", "def get_models(self):\n return self.P, self.Q", "def models(self):\n return self.config.mode...
[ "0.6803391", "0.6803391", "0.64394", "0.6406779", "0.6275852", "0.6213419", "0.6203647", "0.6106908", "0.60893244", "0.6065379", "0.5988689", "0.5973042", "0.5936472", "0.5927681", "0.5875577", "0.5875577", "0.5875577", "0.5875577", "0.5875577", "0.5875577", "0.5875577", "0...
0.72028995
0
Gets the current eval_metric
def _get_eval_metric(self): self._validate_eval_metric() if isinstance(self.eval_metric, types.FunctionType): UserDefinedEvalMetric().set_metric(self.eval_metric) return "user_defined_metric" if self.eval_metric == "auto": if self._get_ml_task() == BINARY_CLASSIFICATION: return "logloss" elif self._get_ml_task() == MULTICLASS_CLASSIFICATION: return "logloss" elif self._get_ml_task() == REGRESSION: return "rmse" else: return deepcopy(self.eval_metric)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_evaluation_metric(self):\n\t\treturn self.metric", "def _get_eval_metric(self):\n raise NotImplementedError", "def metric(self):\n return self.__metric", "def metric(self):\n return self._metric", "def metric(self):\n\n if not self._metric_cache:\n # Select an...
[ "0.8871039", "0.8542188", "0.78376704", "0.77682865", "0.7014578", "0.6998242", "0.6777106", "0.672844", "0.67167246", "0.6679996", "0.6656904", "0.6603165", "0.65871996", "0.6512036", "0.6506062", "0.64750284", "0.64335555", "0.6335517", "0.6312627", "0.6312022", "0.6312022"...
0.76053345
4
Gets the current validation_strategy
def _get_validation_strategy(self): strat = {} self._validate_validation_strategy() if self.validation_strategy == "auto": if self._get_mode() == "Explain": strat = { "validation_type": "split", "train_ratio": 0.75, "shuffle": True, "stratify": True, } elif self._get_mode() == "Perform": strat = { "validation_type": "kfold", "k_folds": 5, "shuffle": True, "stratify": True, } elif self._get_mode() in ["Compete", "Optuna"]: strat = { "validation_type": "kfold", "k_folds": 10, "shuffle": True, "stratify": True, } if self._get_ml_task() == REGRESSION: if "stratify" in strat: # it's better to always check # before delete (trust me) del strat["stratify"] return strat else: strat = deepcopy(self.validation_strategy) if self._get_ml_task() == REGRESSION: if "stratify" in strat: del strat["stratify"] return strat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_validate(self):\n return self.validate", "def validator(self):\n return self._validator", "def paramValidationPref(self):\n # If the level of the object is below the Preference level,\n # recursively call base (super) classes to get preference at specified level\n ...
[ "0.6838031", "0.6627097", "0.6515644", "0.6456136", "0.6417892", "0.63516897", "0.634212", "0.63212353", "0.6285395", "0.6255339", "0.6221338", "0.62149113", "0.6194205", "0.61286926", "0.60330224", "0.60326296", "0.60178643", "0.5966911", "0.5960197", "0.59587127", "0.582506...
0.67801
1
Gets the current verbose
def _get_verbose(self): self._validate_verbose() return deepcopy(self.verbose)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verbose(self):\n return self.conf.get(\"verbose\")", "def verbose():\n return _verbose", "def verbose(self):\n return self._verbose", "def verbose(self):\n return self._verbose", "def verbose(self):\n return self._verbose", "def verbose(self):\n return self._verb...
[ "0.8428105", "0.8374118", "0.83612645", "0.83612645", "0.83612645", "0.83612645", "0.83353597", "0.8318962", "0.82725775", "0.8234203", "0.772145", "0.7617219", "0.7324933", "0.7297833", "0.7150878", "0.7135847", "0.7123028", "0.71162844", "0.7113516", "0.7033205", "0.7024528...
0.8258136
9
Gets the current explain_level
def _get_explain_level(self): self._validate_explain_level() if self.explain_level == "auto": if self._get_mode() == "Explain": return 2 if self._get_mode() == "Perform": return 1 if self._get_mode() == "Compete": return 0 if self._get_mode() == "Optuna": return 0 else: return deepcopy(self.explain_level)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def help_explain(self):\n print(EXPLAIN)", "def level(self):\n return self.__level", "def level(self):\n return self.__level", "def getLevel(self):\n return _libsbml.ASTBasePlugin_getLevel(self)", "def get_level(self):\n return self.debug_level, self.verbosity", "def le...
[ "0.62678665", "0.59786433", "0.59786433", "0.5973489", "0.5863395", "0.58591205", "0.58441484", "0.58441484", "0.58441484", "0.58441484", "0.5830532", "0.5830532", "0.57422584", "0.55639464", "0.55551803", "0.55497247", "0.5544945", "0.55366", "0.5531055", "0.55061364", "0.54...
0.86530817
0
Gets the current features_selection
def _get_features_selection(self): self._validate_features_selection() if self.features_selection == "auto": if self._get_mode() == "Explain": return False if self._get_mode() == "Perform": return True if self._get_mode() == "Compete": return True if self._get_mode() == "Optuna": return False else: return deepcopy(self.features_selection)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSelection(self):\n return self.selection", "def GetSelection(self):\r\n\r\n return self.selection", "def GetSelection(self):\r\n\r\n return self._current", "def GetSelection(self):\n \n return self.selected", "def get_selected_nodes(self):\n return self._sel...
[ "0.72452754", "0.7188117", "0.71176845", "0.6940054", "0.67970186", "0.6783767", "0.67610663", "0.6721341", "0.66002655", "0.6589361", "0.6549051", "0.6549051", "0.6516982", "0.64433926", "0.6428101", "0.64220285", "0.6418494", "0.6352769", "0.6308269", "0.62836784", "0.62610...
0.7440437
0
Gets the current start_random_models
def _get_start_random_models(self): self._validate_start_random_models() if self.start_random_models == "auto": if self._get_mode() == "Explain": return 1 if self._get_mode() == "Perform": return 5 if self._get_mode() == "Compete": return 10 if self._get_mode() == "Optuna": return 1 # just 1, because it will be tuned by Optuna else: return deepcopy(self.start_random_models)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exploring_starts(self):\n def random_choice(l): return l[np.random.randint(len(l))]\n return map(random_choice, (self.env.states, self.env.moves))", "def get_random_start(self):\n arr = np.zeros(self.dimension)\n n_fit_p = len(self.fit_parameters)\n n_nui_p = len(self.nuisance_para...
[ "0.61098045", "0.5519804", "0.5495816", "0.5439313", "0.5439313", "0.54216105", "0.53990346", "0.53893465", "0.53497064", "0.53497064", "0.5334331", "0.53277075", "0.5320885", "0.5319373", "0.53144366", "0.5306886", "0.52948534", "0.5272874", "0.52695197", "0.5261325", "0.524...
0.80309975
0
Gets the current hill_climbing_steps
def _get_hill_climbing_steps(self): self._validate_hill_climbing_steps() if self.hill_climbing_steps == "auto": if self._get_mode() == "Explain": return 0 if self._get_mode() == "Perform": return 2 if self._get_mode() == "Compete": return 2 if self._get_mode() == "Optuna": return 0 # all tuning is done in Optuna else: return deepcopy(self.hill_climbing_steps)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_steps(self):\n return self.steps", "def get_steps(self):\n return self.steps", "def get_steps(self):\n return self.steps", "def getSteps( self ):\n\n return self.adb.get( 'steps' )", "def getSteps():", "def get_step(self):\n retur...
[ "0.72193843", "0.71010685", "0.70357335", "0.66529846", "0.652234", "0.6352011", "0.6352011", "0.6341539", "0.6029986", "0.600624", "0.59786874", "0.594206", "0.59252524", "0.59252524", "0.59252524", "0.59252524", "0.58734", "0.58724695", "0.58696485", "0.5851444", "0.5811696...
0.7683898
0
Gets the current top_models_to_improve
def _get_top_models_to_improve(self): self._validate_top_models_to_improve() if self.top_models_to_improve == "auto": if self._get_mode() == "Explain": return 0 if self._get_mode() == "Perform": return 2 if self._get_mode() == "Compete": return 3 if self._get_mode() == "Optuna": return 0 else: return deepcopy(self.top_models_to_improve)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_top_models(self, return_scores=True):\n self.greater_score_is_better = is_greater_better(self.scoring_function)\n model_names = list(set([key.split('(')[0] for key in\n self.evaluated_individuals_.keys()]))\n models = OrderedDict({mo...
[ "0.6821835", "0.6430581", "0.629004", "0.62063706", "0.6155155", "0.6126578", "0.5943312", "0.59303916", "0.59013474", "0.5836023", "0.5798655", "0.5795692", "0.56650555", "0.565281", "0.56480753", "0.5645917", "0.56216484", "0.55647224", "0.55647224", "0.55647224", "0.555102...
0.8301511
0
Gets the current boost_on_errors
def _get_boost_on_errors(self): self._validate_boost_on_errors() if self.boost_on_errors == "auto": val = self._get_validation_strategy() if val.get("validation_type", "") == "custom": return False if self._get_mode() == "Explain": return False if self._get_mode() == "Perform": return False if self._get_mode() == "Compete": return True if self._get_mode() == "Optuna": return False else: return deepcopy(self.boost_on_errors)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_raise_on_error():\n global raise_on_error\n return raise_on_error", "def back_err(self):\n return self._derived_properties[\"bkgd_err\"]", "def get_errors(self):\n return {'loss': self.loss.data[0]}", "def getB(self):\n return self.error", "def getErrorHandler(self):\n ...
[ "0.6346581", "0.6290803", "0.61281234", "0.60806453", "0.59473616", "0.5876309", "0.585333", "0.5807219", "0.5801431", "0.5784405", "0.57784134", "0.576894", "0.57465225", "0.57465225", "0.57174766", "0.5715621", "0.5715621", "0.5715621", "0.5680192", "0.56616455", "0.5624751...
0.7447873
0
Gets the current kmeans_features
def _get_kmeans_features(self): self._validate_kmeans_features() if self.kmeans_features == "auto": if self._get_mode() == "Explain": return False if self._get_mode() == "Perform": return False if self._get_mode() == "Compete": return True if self._get_mode() == "Optuna": return False else: return deepcopy(self.kmeans_features)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_features(self):\n return self._features", "def features(self):\n return self._features", "def features(self):\n\n return self._features", "def get_features(self):\n if self.strokes is False:\n print('Isolating strokes')\n self.isolate_strokes()\n ...
[ "0.6775403", "0.6481033", "0.63745344", "0.63635355", "0.62884897", "0.62546325", "0.612313", "0.6063174", "0.5997075", "0.5957198", "0.5954714", "0.5915384", "0.58808947", "0.58574826", "0.58393997", "0.58329165", "0.5800852", "0.57675624", "0.57581013", "0.57575", "0.574253...
0.7356534
0
Gets the current mix_encoding
def _get_mix_encoding(self): self._validate_mix_encoding() if self.mix_encoding == "auto": if self._get_mode() == "Explain": return False if self._get_mode() == "Perform": return False if self._get_mode() == "Compete": return True if self._get_mode() == "Optuna": return False else: return deepcopy(self.mix_encoding)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encoding(self):\n return self.original.encoding", "def encoding(self):\n\n return self._encoding", "def encoding(self):\n return self.get_encoding()", "def encoding(self):\n return self._encoding", "def encoding(self):\n return self._encoding", "def encoding(self):\n ...
[ "0.7560038", "0.75277394", "0.74015206", "0.73925185", "0.73925185", "0.73925185", "0.73925185", "0.7173765", "0.7009836", "0.69050586", "0.6849858", "0.6755228", "0.6746344", "0.6715124", "0.65442663", "0.65063953", "0.64930034", "0.64095986", "0.63821363", "0.63166624", "0....
0.73403645
7
Gets the current max_single_prediction_time
def _get_max_single_prediction_time(self): self._validate_max_single_prediction_time() if self.max_single_prediction_time is None: if self._get_mode() == "Perform": return 0.5 # prediction time should be under 0.5 second return None else: return deepcopy(self.max_single_prediction_time)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_simulated_time(self):\n\n query = \"SELECT MAX(time) FROM patient_signal_values\"\n\n return self.mysql_obj.fetch_value(query)", "def max_time(self):\n #{{{ function to return time of last sample\n\n if self.maxtime == -1:\n return stock.now()\n\n return ...
[ "0.713428", "0.7000223", "0.6750113", "0.67000544", "0.66799814", "0.664459", "0.6637974", "0.65101796", "0.64204127", "0.63254064", "0.63026834", "0.62825453", "0.62509656", "0.6248696", "0.6228762", "0.6212105", "0.61944056", "0.6155345", "0.614388", "0.61273146", "0.611953...
0.903874
0
Gets the current optuna_time_budget
def _get_optuna_time_budget(self): self._validate_optuna_time_budget() if self.optuna_time_budget is None: if self._get_mode() == "Optuna": return 3600 return None else: if self._get_mode() != "Optuna": # use only for mode Optuna return None return deepcopy(self.optuna_time_budget)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def budget(self):\n return self._budget", "def last_optime(self):\n return self._last_optime", "def adoption_time(self):\n return self._adoption_time", "def get_time_step_to_enqueue(self):\n return self.time_step_to_enqueue", "def _get_total_time_limit(self):\n self._vali...
[ "0.6425248", "0.6043277", "0.5918131", "0.57312304", "0.56376636", "0.55601627", "0.55194855", "0.54705125", "0.5403898", "0.53979033", "0.539061", "0.5377435", "0.53700995", "0.53586614", "0.53013504", "0.52734435", "0.52604705", "0.524631", "0.5189846", "0.5182123", "0.5148...
0.8460654
0
Gets the current optuna_init_params
def _get_optuna_init_params(self): self._validate_optuna_init_params() if self._get_mode() != "Optuna": # use only for mode Optuna return {} return deepcopy(self.optuna_init_params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getInitParams(self):\n return {}", "def _get_current_training_params(self):\n params = {}\n params[\"lyap_relu_params\"] = copy.deepcopy(\n self.lyapunov_hybrid_system.lyapunov_relu.state_dict())\n if not self.R_options.fixed_R:\n params[\"R_params\"] = self.R_op...
[ "0.67133015", "0.6513982", "0.64959013", "0.64958394", "0.644193", "0.644193", "0.64085335", "0.6405476", "0.6403037", "0.63784325", "0.63532674", "0.63532674", "0.63532674", "0.63532674", "0.6348272", "0.6348272", "0.6348272", "0.6348272", "0.6346435", "0.6290466", "0.624069...
0.87101316
0
Gets the current optuna_verbose
def _get_optuna_verbose(self): self._validate_optuna_verbose() # use only for mode Optuna if self._get_mode() != "Optuna": return True return deepcopy(self.optuna_verbose)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_verbose(self):\n self._validate_verbose()\n return deepcopy(self.verbose)", "def verbose(self):\n return self.conf.get(\"verbose\")", "def verbose():\n return _verbose", "def verbose(self):\n return self._verbose", "def verbose(self):\n return self._verbose", ...
[ "0.78699535", "0.7726708", "0.7537154", "0.746297", "0.746297", "0.746297", "0.746297", "0.7356259", "0.73098314", "0.7288619", "0.71457535", "0.70966977", "0.7072135", "0.70582813", "0.66449106", "0.65642446", "0.65546435", "0.650735", "0.6440845", "0.6396217", "0.63302183",...
0.8742914
0
Gets the current n_jobs
def _get_n_jobs(self): self._validate_n_jobs() return deepcopy(self.n_jobs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_n_jobs(self):\n return self.n_jobs", "def effective_n_jobs(n_jobs=-1):\n if n_jobs == 1:\n return 1\n\n backend, backend_n_jobs = get_active_backend()\n if n_jobs is None:\n n_jobs = backend_n_jobs\n return backend.effective_n_jobs(n_jobs=n_jobs)", "def get_num_jobs(sel...
[ "0.8941863", "0.80259633", "0.79868776", "0.78013074", "0.78005415", "0.7614501", "0.72230357", "0.71267", "0.70833606", "0.703076", "0.69810003", "0.69787186", "0.6843887", "0.6817876", "0.674785", "0.666808", "0.66524726", "0.6553903", "0.6538402", "0.65348506", "0.6515888"...
0.84748805
1
Gets the current random_state
def _get_random_state(self): self._validate_random_state() return deepcopy(self.random_state)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rand(self):\n return self.State.rand()", "def getstate(self):\n return (self.baseseed, self.counter, self.randbits_remaining)", "def rand(self):\n self.state = (self.a * self.state + self.c)\n return self.state", "def _get_state(self):\n return self.__state", "def _get_st...
[ "0.8123552", "0.7858806", "0.7808915", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "0.7497387", "...
0.8489528
0
Gets the fairness metric
def _get_fairness_metric(self): self._validate_fairness_metric() if self.fairness_metric == "auto": if self._get_ml_task() == BINARY_CLASSIFICATION: return "demographic_parity_ratio" if self._get_ml_task() == REGRESSION: return "group_loss_ratio" if self._get_ml_task() == MULTICLASS_CLASSIFICATION: return "demographic_parity_ratio" else: return deepcopy(self.fairness_metric)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_fairness_threshold(self):\n if self.fairness_threshold == \"auto\":\n if self._get_ml_task() in [\n BINARY_CLASSIFICATION,\n MULTICLASS_CLASSIFICATION,\n ]:\n thresholds = {\n \"demographic_parity_difference\": 0....
[ "0.67016745", "0.5999203", "0.59884006", "0.58963954", "0.56670684", "0.5645477", "0.54838866", "0.5344908", "0.53396153", "0.5330606", "0.53292984", "0.5284739", "0.52752274", "0.5267313", "0.52610236", "0.5256685", "0.52457917", "0.52381456", "0.5232188", "0.52058727", "0.5...
0.68944013
0
Gets the fairness threshold
def _get_fairness_threshold(self): if self.fairness_threshold == "auto": if self._get_ml_task() in [ BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, ]: thresholds = { "demographic_parity_difference": 0.1, "demographic_parity_ratio": 0.8, "equalized_odds_difference": 0.1, "equalized_odds_ratio": 0.8, } return thresholds.get(self._fairness_metric, 0.8) elif self._get_ml_task() == REGRESSION: thresholds = { "group_loss_ratio": 0.8, } if self._fairness_metric == "group_loss_difference": raise AutoMLException( "We can't set default fairness threshold value. Please set `fairness_threshold` value in AutoML constructor." ) return thresholds.get(self._fairness_metric, 0.8) else: return deepcopy(self.fairness_threshold)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def FastConvergenceThreshold(self):\n\t\treturn self._get_attribute('fastConvergenceThreshold')", "def threshold(self) -> float:\n return pulumi.get(self, \"threshold\")", "def reward_threshold(self) -> Optional[float]:", "def get_performance_threshold(self):\n\n if Test.performance_params: ret...
[ "0.6620242", "0.62111634", "0.604016", "0.60012925", "0.59756714", "0.5927428", "0.591201", "0.5910259", "0.5881854", "0.5881854", "0.5880676", "0.58554536", "0.5805405", "0.578478", "0.5761599", "0.5743415", "0.5742673", "0.56985474", "0.5683226", "0.56465083", "0.5641896", ...
0.74255294
0
Gets privileged groups for fair training
def _get_privileged_groups(self): if self.privileged_groups == "auto": return [] else: return deepcopy(self.privileged_groups)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_underprivileged_groups(self):\n if self.underprivileged_groups == \"auto\":\n return []\n else:\n return deepcopy(self.underprivileged_groups)", "def test_get_groups(self):\n group0 = self.test_save('TestGroup0')\n group1 = self.test_save('TestGroup1')\n...
[ "0.7512295", "0.6589516", "0.65174836", "0.6486006", "0.63847315", "0.63510704", "0.63013774", "0.63013774", "0.62872154", "0.628441", "0.6190389", "0.61468303", "0.61449814", "0.61140037", "0.61140037", "0.6090746", "0.6036777", "0.60114354", "0.6006546", "0.59940183", "0.59...
0.7552889
0
Gets underprivileged groups for fair training
def _get_underprivileged_groups(self): if self.underprivileged_groups == "auto": return [] else: return deepcopy(self.underprivileged_groups)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_privileged_groups(self):\n if self.privileged_groups == \"auto\":\n return []\n else:\n return deepcopy(self.privileged_groups)", "def get_groups_using_malware():\n global groups_using_malware\n\n if not groups_using_malware:\n groups_using_malware = rsh....
[ "0.74663794", "0.6593482", "0.6520235", "0.65086764", "0.65086764", "0.6437184", "0.6431571", "0.6334094", "0.61589926", "0.6144109", "0.6134614", "0.6120121", "0.60976017", "0.60939455", "0.60939455", "0.6093541", "0.60102457", "0.60085875", "0.59747267", "0.5969062", "0.596...
0.76907
0
Handle add host request
def __add_host(self, host_form): try: host_object = Host.objects.get( host_name=host_form.cleaned_data['host_name'] ) for field in host_form.cleaned_data: setattr( host_object, field, host_form.cleaned_data[field] ) host_object.save() return HttpResponseRedirect(reverse('log_collector:index')) except errors.ObjectDoesNotExist: return self.form_valid(host_form)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_add_host(request, address):\n\n request.setdefault('headers', {})\n request['headers'].setdefault('Host', address)\n\n return request", "def add_host_entry(ip, hostname, domain):\n host_line = ip+\" \"+hostname+\".\"+domain+\" \"+hostname\n\n # Only add entry if it does not exist alrea...
[ "0.6840379", "0.65409213", "0.65173084", "0.64930916", "0.64499176", "0.6448675", "0.6233369", "0.6211751", "0.6179076", "0.61413676", "0.61369586", "0.6132575", "0.6132081", "0.61151505", "0.60892236", "0.6072281", "0.6072281", "0.6012972", "0.60013103", "0.5987418", "0.5978...
0.64364
6
Download log files from remote machines on local machine via ssh
def __download_via_ssh(cls, request, local_path): hosts = request.POST.getlist('hosts[]') logs = request.POST.getlist('logs[]') if not os.path.exists(local_path): os.makedirs(local_path) for host_name in hosts: host_object = Host.objects.get(host_name=host_name) host_path = os.path.join(local_path, host_name) if not os.path.exists(host_path): os.makedirs(host_path) for log_name in logs: log_object = Log.objects.get(log_name=log_name) help_methods.get_file_via_ssh( getattr(log_object, 'log_path'), host_path, getattr(host_object, 'host_name'), getattr(host_object, 'host_root_user'), getattr(host_object, 'host_root_password') )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PullLogs(ssh, log_files, download_folder):\n for log_file in log_files:\n target_file = os.path.join(download_folder, os.path.basename(log_file))\n ssh.ScpPullFile(log_file, target_file)\n _DisplayPullResult(download_folder)", "def ssh_download_files(data):\n with _ssh_connect() as ssh...
[ "0.73364204", "0.6596629", "0.6111099", "0.60842896", "0.6064838", "0.6026996", "0.60165", "0.59927064", "0.59570765", "0.59108406", "0.59068495", "0.58801275", "0.5834578", "0.57861924", "0.5749585", "0.573902", "0.5687385", "0.56273234", "0.5601198", "0.5537666", "0.5521412...
0.7495217
0
r""" Displays image either individually or in a collated grid.
def visualize(imgobjs, cols=4, collated=True, size=None): ## Separate into list of single instance image objects imgs = [] if isinstance(imgobjs, list): for io in imgobjs: imgs += images._create_img_list(io) else: imgs = images._create_img_list(imgobjs) ## Grid layout settings. Sets N, N_rows, N_cols N = len(imgs) assert N > 0 if not size: size = [0, 0] # H, W for img in imgs: _, _, H, W = get_dimensions(img) size[0] += H size[1] += W size = [int(d/len(imgs)) for d in size] else: assert len(size) == 2 N_cols = cols if cols else 4 if N < 4: N_cols = N N_rows = math.ceil(N/N_cols) print(f"Cols: {N_cols}, Rows: {N_rows}") ## Display Figure figure = plt.figure(figsize=(15, 10)) for i in range(N): dims = images.get_dimensions(imgs[i])[1:] title = f"[Image {i+1}/{N}]" if isinstance(imgs[i], str): title = f"[Image {i+1}/{N}] {files.get_filename(imgs[i])}" title += f"\n shape{dims}" img = images.to_np(imgs[i], size=size, color='rgb') subplt = figure.add_subplot(N_rows, N_cols, i+1) subplt.set_title(title, fontsize=10) subplt.axis('off') plt.imshow(img) figure.tight_layout() # plt.subplots_adjust(wspace=.25, hspace=.5) plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_images_in_grid(imgs, row, col):\n if len(imgs) != (row * col):\n raise ValueError(f\"Invalid imgs len:{len(imgs)} col:{row} row:{col}\")\n\n for i, img in enumerate(imgs):\n plot_num = i + 1\n plt.subplot(row, col, plot_num)\n plt.tick_params(labelbottom=False) # remo...
[ "0.75970733", "0.70164585", "0.69525635", "0.6862031", "0.6858415", "0.6740404", "0.67095673", "0.67095673", "0.6658414", "0.6656997", "0.6640771", "0.6611372", "0.6593967", "0.6576421", "0.65030444", "0.64479935", "0.6447659", "0.6405609", "0.63985646", "0.63723314", "0.6371...
0.68058664
5
This function calculates correlation
def correlation(C): if type(C) is not np.ndarray: raise TypeError('C must be a numpy.ndarray') if len(C.shape) < 2 or C.shape[0] is not C.shape[1]: raise ValueError('C must be a 2D square matrix') return C / np.sqrt(np.outer(np.diagonal(C), np.diagonal(C)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_correlation(data):\n pass", "def correlation(self, other):\n dates=self.get_dates(other.get_dates())\n #print(len(self.get_values(dates)))\n #print(len(other.get_values(dates)))\n #print(self.get_values(dates))\n r,p=stats.pearsonr(self.get_values(dates), other...
[ "0.79405046", "0.75999177", "0.7460216", "0.7436758", "0.7395434", "0.7368859", "0.7285379", "0.7255133", "0.72522086", "0.7240516", "0.7132481", "0.71304506", "0.71147674", "0.7075051", "0.7072566", "0.70674735", "0.7047367", "0.70030606", "0.7002301", "0.69837224", "0.69723...
0.66404015
49
Creates a new user and adds it to the database. Returns user instance
def register(cls, username, email, password): hashed_password = bcrypt.generate_password_hash(password).decode("UTF-8") user = User(username=username, email=email, password=hashed_password) db.session.add(user) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user(self, **kwargs):\n kwargs = self._prepare_create_user_args(**kwargs)\n user = self.user_model(**kwargs)\n # noinspection PyUnresolvedReferences\n return self.save(user)", "def create_user(self, **kwargs):\n\n user = self.user_model(**self._prepare_create_user_ar...
[ "0.82439464", "0.82260287", "0.8174223", "0.81366533", "0.7910809", "0.7828572", "0.78101397", "0.7780627", "0.77802235", "0.7757555", "0.7754437", "0.7749895", "0.7744491", "0.77402997", "0.7723939", "0.77193147", "0.76944625", "0.7688455", "0.7675639", "0.7663784", "0.76571...
0.7531111
69
create and eventually load model
def create_model(model_class, model_params=None, model_name='model'): model_params = {} if model_params is None else model_params model = model_class(**model_params) if special_parameters.load_model: # recover from checkpoint _load_model(model, model_name) # configure usage on GPU if use_gpu(): model.to(first_device()) model = torch.nn.DataParallel(model, device_ids=all_devices()) # print info about devices print_info('Device(s)): ' + str(device_description())) return model
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_model(self):\n pass", "def create_model(self):\n pass", "def load_model(self):\n pass", "def load_model(self) -> Any:", "def create_model(self):\n try:\n self.model = PPO2.load(self.save_path)\n self.model.set_env(self.env)\n print(\"L...
[ "0.7996416", "0.7996416", "0.7820359", "0.7744954", "0.76674736", "0.75198305", "0.7464868", "0.7434571", "0.7401831", "0.7381503", "0.73702586", "0.7361736", "0.7338781", "0.73340213", "0.73315054", "0.7304617", "0.7300003", "0.72266036", "0.71483904", "0.70854926", "0.70715...
0.0
-1
create and eventually load optimizer
def create_optimizer(parameters, optimizer_class, optim_params, model_name='model'): opt = optimizer_class(parameters, **optim_params) if special_parameters.load_model: _load_optimizer(opt, model_name) return opt
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_optimizer(self, context, optimizer, host):\n pass", "def _inst_optimizer(self):\n optimizer = Optimizers(self.m_cfg['configs']['lr_politics']['optimizer']).value\n lr_schedule = self.m_cfg['configs']['lr_politics']['lr']\n opt = optimizer(learning_rate=lr_schedule)\n ...
[ "0.7574701", "0.7027126", "0.69701713", "0.6691302", "0.65252584", "0.6491573", "0.6486863", "0.64255583", "0.6424441", "0.6415458", "0.6415458", "0.6378634", "0.63784504", "0.6371093", "0.63059115", "0.62917596", "0.62874264", "0.62415004", "0.62381065", "0.6213669", "0.6209...
0.6705017
3
change state of the model
def load_checkpoint(model, model_name='model', validation_id=None): path = output_path(_checkpoint_path.format(model_name), validation_id=validation_id, have_validation=True) _load_model(model.module if type(model) is torch.nn.DataParallel else model, model_name, path=path, reload=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_state( self ):", "def __change_state(self, state):\n self.state = state", "def _change_state(self, state):\r\n self.table_entry.state = state\r\n self.creator_admin.save_model(self.request, self.table_entry, None, True)", "def set_state(self):\n self.able = not self.able\n...
[ "0.7737057", "0.75527465", "0.7345793", "0.7311264", "0.72797084", "0.71178675", "0.70558363", "0.7049051", "0.70343417", "0.701413", "0.6992956", "0.69799733", "0.69711614", "0.6911453", "0.6911453", "0.6906396", "0.6853698", "0.68437946", "0.6841781", "0.67774165", "0.67704...
0.0
-1
save checkpoint (optimizer and model)
def save_checkpoint(model, optimizer=None, model_name='model', validation_id=None): path = output_path(_checkpoint_path.format(model_name), validation_id=validation_id, have_validation=True) print_debug('Saving checkpoint: ' + path) model = model.module if type(model) is torch.nn.DataParallel else model checkpoint = { 'model_state_dict': model.state_dict() } if optimizer is not None: checkpoint['optimizer_state_dict'] = optimizer.state_dict() torch.save(checkpoint, path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model_checkpoint(model, optimizer, global_step, epoch_info, file_name):\n output = {\n \"model\" : model.state_dict(),\n \"optimizer\" : optimizer.state_dict(),\n \"global_step\" : global_step + 1,\n \"epoch_info\" : epoch_info\n }\...
[ "0.81574863", "0.81427485", "0.7992224", "0.7981823", "0.79559743", "0.7939416", "0.78992295", "0.7896152", "0.7881963", "0.78608304", "0.78405166", "0.77503026", "0.77258694", "0.77220285", "0.7713433", "0.76902556", "0.76812625", "0.76755613", "0.7660106", "0.76497287", "0....
0.7845735
10
Thank you stack overflow
def parseNumList(input): m = re.match(r'(\d+)(?:-(\d+))?(?:-(\d+))?$', input) # ^ (or use .split('-'). anyway you like.) if not m: raise ArgumentTypeError("'" + input + "' is not a range of number. Expected forms like '1-5' or '2' or '10-15-2'.") start = int(m.group(1)) end = int(m.group(2)) if m.group(3): increment = int(m.group(3)) else: increment = 1 return list(range(start, end+1, increment))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exo2():", "def substantiate():", "def sth():", "def degibber(self):", "def cx():", "def mezclar_bolsa(self):", "def regular(self):", "def reckon(self):", "def result(self):", "def result(self):", "def falcon():", "def healthcare():", "def exercise_b2_106():\r\n pass", "def exercise...
[ "0.64075494", "0.6128703", "0.60941494", "0.60059685", "0.592511", "0.5874032", "0.5867482", "0.58433014", "0.58196574", "0.58196574", "0.56822956", "0.5674214", "0.5626368", "0.56027365", "0.5581712", "0.5579045", "0.55690277", "0.5562525", "0.55460745", "0.5500938", "0.5495...
0.0
-1
Build a hierarchy of levels for Sunburst or Treemap charts. Levels are given starting from the bottom to the top of the hierarchy, ie the last level corresponds to the root.
def build_hierarchical_dataframe(df, levels, value_column, color_columns=None): df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color']) for i, level in enumerate(levels): df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color']) dfg = df.groupby(levels[i:]).sum() dfg = dfg.reset_index() df_tree['id'] = dfg[level].copy() if i < len(levels) - 1: df_tree['parent'] = dfg[levels[i+1]].copy() else: df_tree['parent'] = 'total' df_tree['value'] = dfg[value_column] df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]] df_all_trees = df_all_trees.append(df_tree, ignore_index=True) total = pd.Series(dict(id='total', parent='', value=df[value_column].sum(), color=df[color_columns[0]].sum() / df[color_columns[1]].sum())) df_all_trees = df_all_trees.append(total, ignore_index=True) return df_all_trees
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_levels(self):\r\n level = (self.root,)\r\n while level:\r\n yield level\r\n level = tuple(child for node in level for child in node.children)", "def represent_tree_levels(self, levels):\r\n prev_node_end = 0 \r\n level_string = []\r\n for leve...
[ "0.69105655", "0.67230135", "0.6641817", "0.6612042", "0.6433254", "0.64241004", "0.6208278", "0.6171888", "0.60765696", "0.6048084", "0.60298026", "0.60158795", "0.600957", "0.5995847", "0.59677976", "0.59607244", "0.59351313", "0.5911113", "0.590964", "0.5883543", "0.586778...
0.6078447
8
Make an hashable representation of an object for hashlib
def hashable(obj): return bytes(str(obj), "utf-8")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash(obj):\n \n import hashlib\n import pickle\n \n sha = hashlib.sha256()\n sha.update(pickle.dumps(obj))\n \n return sha.hexdigest()", "def hash_obj(self, obj):\r\n md5er = hashlib.md5()\r\n update_hash(md5er, obj)\r\n return md5er.hexdigest()", "def make_hash...
[ "0.7611977", "0.73950815", "0.72174555", "0.72113204", "0.71887934", "0.7181167", "0.7116037", "0.7108791", "0.701039", "0.70093346", "0.6961172", "0.691401", "0.6912288", "0.6907212", "0.6874116", "0.683543", "0.6820438", "0.67326635", "0.67163974", "0.6707556", "0.66794527"...
0.8125466
0
Generate a hash from a dictionary
def hash_dict(dct): h = hashlib.md5() def update(d): for k, v in d.items(): h.update(hashable(k)) if isinstance(v, dict): update(v) else: h.update(hashable(v)) update(dct) return h.digest()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hash(dictionary):\n dhash = hashlib.md5()\n # We need to sort arguments so {'a': 1, 'b': 2} is\n # the same as {'b': 2, 'a': 1}\n encoded = json.dumps(dictionary, sort_keys=True).encode()\n dhash.update(encoded)\n return dhash.hexdigest()", "def dict_hash(dictionary) -> str:\n dhash ...
[ "0.78616196", "0.77828234", "0.7741928", "0.7730784", "0.7210692", "0.7073175", "0.6808858", "0.68039656", "0.67542607", "0.6678936", "0.6636507", "0.6627023", "0.66170514", "0.6524575", "0.6503319", "0.6502774", "0.64773655", "0.64493966", "0.64259434", "0.6421355", "0.64005...
0.67284095
9
Ensure row data is valid This currently just checks that 2D arrays match the variable components.
def validate_row(row): subkeys = [INDEP, DEP] for subkey in subkeys: for k, v in row[subkey].items(): if v is None: continue if np.ndim(v) > 1: assert np.ndim(v) == 2 if 1 not in np.shape(v): assert isinstance(k, variable.Variable) assert k.components is not None assert len(k.components) in np.shape(v)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_data(self, row, col, value):\n\n return True", "def check_row(row):\n \n if len(row) != _ncols:\n raise ValueError(\"Row contains {0} columns, expected {1}!\\n\\n{2}\\n\".format(len(row), _ncols, row))", "def validate(self, row):\n raise NotImplementedError", "def _val...
[ "0.69890326", "0.6909129", "0.6653121", "0.6620799", "0.6608853", "0.6602894", "0.65480334", "0.6546582", "0.65440375", "0.6527276", "0.649017", "0.64542824", "0.6438385", "0.6417175", "0.6406108", "0.6311875", "0.6278405", "0.6260668", "0.6255064", "0.6238612", "0.62377685",...
0.7375959
0
Convert any size1 arrays to scalars
def scalarise(dct): d = dct.copy() for subkey in [DEP, INDEP]: for k, v in d[subkey].items(): if isinstance(v, np.ndarray) and np.size(v) == 1: dct[subkey][k] = v.item()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scalararray(inp) -> np.ndarray:\n return np.array([None, inp], dtype=object)[[1]].reshape([])", "async def infer_shape_array_to_scalar(track, ary):\n shp = await ary['shape']\n if shp == ():\n return NOSHAPE\n else:\n raise MyiaTypeError(\n 'array_to_scalar only works on ...
[ "0.6902022", "0.63372874", "0.6325084", "0.62974435", "0.62791", "0.62652755", "0.62318766", "0.62222445", "0.609567", "0.59744406", "0.59497917", "0.5910324", "0.5909021", "0.5878803", "0.58734983", "0.5865044", "0.586246", "0.5857849", "0.58351564", "0.5832479", "0.58043796...
0.5335528
73
Add a new entry
def add( self, indep, key=None, value=None, dep=None, keys=None, values=None, **kwargs ): if key is not None and value is not None: if isinstance(key, str): self.add_value(indep, key, value) elif isinstance(key, list): self.add_array(indep, key, value) elif keys is not None and values is not None: self.add_array(indep, keys, values) elif dep is not None: self.add_dict(indep, dep) elif isinstance(key, dict): self.add_dict(indep, key) elif len(kwargs) > 0: self.add_dict(indep, kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_new_entry(self):\n clear_screen()\n new_entry = Entry.create()\n if new_entry is None:\n print(\"Add new entry cancelled. Returning to main menu...\")\n time.sleep(1)\n return None\n self.entries.append(new_entry)\n with open(self.file_na...
[ "0.8038067", "0.78797853", "0.7829428", "0.762765", "0.761063", "0.75863564", "0.75329536", "0.7498819", "0.7392129", "0.7390942", "0.72157484", "0.72009754", "0.7183276", "0.71024626", "0.7099431", "0.7096168", "0.70957315", "0.70942044", "0.70942044", "0.70640934", "0.70452...
0.0
-1
Add a single value or vector
def add_value(self, indep, key, value): self.add_dict(indep, {key: value})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, value):", "def add(self, value):\n pass", "def __add__(self, other):\n # other is a scalar\n if isinstance(other, (int, float, complex, Fraction)) and not isinstance(other, bool):\n return Vector([i + other for i in self.data], self.column)\n # other is a Ve...
[ "0.77882046", "0.7528879", "0.71992666", "0.7022837", "0.68144745", "0.68144", "0.6740295", "0.66997826", "0.669777", "0.6694546", "0.6663471", "0.6647989", "0.66343087", "0.6605468", "0.6603293", "0.6592215", "0.65901595", "0.6578818", "0.65574723", "0.6531693", "0.65271676"...
0.0
-1
Add a dictionary of dependent data
def add_dict(self, indep, dep): dfull = {IND: len(self), INDEP: indep.copy(), DEP: dep} validate_row(dfull) check_objects(dfull) if settings.CONVERT_SCALAR_ARRAYS: scalarise(dfull) if settings.PRINT_UPDATES: print(self.show([dfull])) self.append(dfull) self._combine(dfull)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(\n self, indep, key=None, value=None, dep=None, keys=None, values=None, **kwargs\n ):\n if key is not None and value is not None:\n if isinstance(key, str):\n self.add_value(indep, key, value)\n elif isinstance(key, list):\n self.add_arra...
[ "0.6675702", "0.64973605", "0.6014381", "0.60071164", "0.5916942", "0.58490884", "0.5743055", "0.57284117", "0.5649685", "0.5642036", "0.5622459", "0.5599008", "0.5532404", "0.55121297", "0.5506236", "0.55047566", "0.5473821", "0.5455027", "0.5451647", "0.5436743", "0.5422243...
0.69769204
0
Add an array of values
def add_array(self, indep, keys, values): if np.ndim(values) > 1: values = orient(values, keys) dep = {k: v for k, v in zip(keys, values)} self.add_dict(indep, dep)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_values(self, *values, replace=False):\n\n if replace: self.reset_values()\n for value in values: self.values = np.append(self.values, value)", "def add_all(self, *values):\n for value in values:\n self.add(value)", "def _addToArray(self, num, arr):\r\n return [i +...
[ "0.76679605", "0.74897724", "0.7482708", "0.74698025", "0.6868423", "0.68615234", "0.67837113", "0.6779977", "0.67769617", "0.6654942", "0.66449934", "0.6613038", "0.6609851", "0.6605651", "0.65964", "0.6575036", "0.6555835", "0.6468301", "0.6383492", "0.6353225", "0.63494134...
0.6270565
23
Return a generator for entries that all include the keys
def filter(self, keys, lst=None, func="all"): f = all if func == "all" else any if lst is None: lst = self if DEP in lst[0] and INDEP in lst[0]: filt_dep = True else: filt_dep = False def filt_func(d): if filt_dep: return f([k in d[INDEP] or k in d[DEP] for k in listify(keys)]) else: return f([k in d for k in listify(keys)]) return filter(filt_func, lst)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterentries(self):\n for key in self.iterkeys():\n yield self.get(key)", "def __iter__(self) -> Generator:\n for k in self.raw.keys():\n yield k", "def __iter__(self):\n for bucket in self._table:\n if bucket is not None:\n for key in buc...
[ "0.7377886", "0.69465625", "0.68848234", "0.6851275", "0.6776351", "0.6718517", "0.669439", "0.6664863", "0.6648368", "0.6597698", "0.6597698", "0.65608925", "0.65233594", "0.64917487", "0.6451746", "0.6446408", "0.6437362", "0.6426836", "0.6422858", "0.6407071", "0.63981986"...
0.0
-1
Return a list of entries that all include the keys
def filtered(self, keys, lst=None, func="all"): lst = self if lst is None else lst if len(lst) == 0: raise ValueError("No rows in list") return [row for row in self.filter(keys, lst, func=func)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_keys(self):\n r = []\n with self.lock:\n for key in self.keys():\n if self.get(key):\n r.append(key)\n\n return r", "def filter_by_keys(self, keys):\n return list(filter(lambda item: item.keyword in set(keys), self._metadata...
[ "0.69771874", "0.6651784", "0.6631111", "0.6531024", "0.65281665", "0.65107197", "0.64283806", "0.64203656", "0.64011246", "0.63802695", "0.6379789", "0.63782895", "0.63735026", "0.63570124", "0.6356654", "0.63414973", "0.6328313", "0.62799704", "0.6264695", "0.6261566", "0.6...
0.6046809
37
Return a generator for entries that all contain keyvalue pairs
def iwhere(self, dct=None, lst=None, **kwargs): dct = {} if dct is None else dct m = dct.copy() m.update(kwargs) if lst is None: lst = self if DEP in lst[0] and INDEP in lst[0]: filt_dep = True else: filt_dep = False def filt_func(d): if filt_dep: return all( [v == d[INDEP].get(k, d[DEP].get(k, None)) for k, v in m.items()] ) else: return all([v == d.get(k, None) for k, v in m.items()]) return filter(filt_func, lst)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterentries(self):\n for key in self.iterkeys():\n yield self.get(key)", "def iteritems(self):\n return iter((kvp.key, kvp.value) for kvp in self.keyvaluepair_set.all())", "def exact_key_items(self):\n for key_node, value in self.get_tree_entries():\n for key in s...
[ "0.698165", "0.693192", "0.66643286", "0.665048", "0.6484602", "0.6445664", "0.641337", "0.6401473", "0.6376863", "0.63687515", "0.63678294", "0.63492215", "0.6311998", "0.6230821", "0.6206421", "0.61832714", "0.6166452", "0.6166452", "0.61628634", "0.6138833", "0.61117566", ...
0.0
-1
Return a list of entries that all contain keyvalue pairs
def where(self, dct=None, lst=None, **kwargs): return [row for row in self.iwhere(dct, lst, **kwargs)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def items(self):\n return [(kvp.key, kvp.value) for kvp in self.keyvaluepair_set.all()]", "def values(self):\n return [kvp.value for kvp in self.keyvaluepair_set.all()]", "def items(self):\n return [(entry.key, entry.value) for entry in self.table\n if entry.value is not Non...
[ "0.7040385", "0.6558992", "0.6447182", "0.6341448", "0.63186115", "0.6311516", "0.6185393", "0.6151298", "0.6077109", "0.60603917", "0.6041254", "0.6039591", "0.60185647", "0.6014903", "0.5886663", "0.5880148", "0.5867619", "0.5864501", "0.58568406", "0.58568406", "0.58568406...
0.0
-1
A minimal list of data in the Box
def minimal(self): combined = self._combined out = [] for k, d in combined.items(): dct = d[INDEP].copy() dct.update(d[DEP]) out.append(dct) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.data = []\n self.min = None", "def __init__(self):\n self.data = []\n self.min = []\n self.data_ptr = -1\n self.min_ptr = -1", "def __init__(self):\n self.items = []\n self.min = []", "def __init__(self):\n self.data = ...
[ "0.6248323", "0.60343033", "0.58595824", "0.5818633", "0.5777445", "0.57357603", "0.5732781", "0.57044137", "0.5676265", "0.56664705", "0.5627507", "0.55881584", "0.558191", "0.5553013", "0.5534371", "0.55328286", "0.5518715", "0.54862744", "0.5479372", "0.54552704", "0.54142...
0.0
-1
Return a list of dictionaries that only contain values for keys
def exclusively(self, keys, lst=None): minimal = self.minimal() if lst is None else lst def make_exclusive(d, keys): dct = {} for k in keys: if k in d: dct[k] = d[k] else: dct[k] = -999 return dct lst = [] for d in minimal: dct = make_exclusive(d, keys) if len(dct) > 0: lst.append(dct) return lst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dict_filter(indict, key_list):\n \n return dict((key, value) for key, value in list(indict.items()) if key in key_list)", "def _filter_keys(item, keys):\n return dict((k, v) for k, v in item.iteritems() if k in keys)", "def exclude(m, keys):\n return {k: v for k, v in m.items() if k not in keys...
[ "0.7157758", "0.6764101", "0.67270654", "0.6699573", "0.6676822", "0.6673541", "0.6655425", "0.66365665", "0.66270673", "0.6611581", "0.6571578", "0.65568775", "0.6545871", "0.6436229", "0.6432588", "0.6381771", "0.63771033", "0.6347461", "0.63027394", "0.62880474", "0.628692...
0.72772044
0
List Box data, merging rows with common independent values
def combined(self): d = self._combined return [c for key, c in d.items()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _merge(self, box_list):\n if isinstance(box_list, self.__class__):\n box_list = [box_list]\n for box in box_list:\n for row in box:\n row[IND] = len(self)\n self.append(row)\n self._combine(row)", "def _combine_omnipage_cell_lis...
[ "0.6294544", "0.5439905", "0.5388952", "0.5262811", "0.51284385", "0.50952107", "0.5083202", "0.50720966", "0.5040125", "0.49990922", "0.49892396", "0.49385926", "0.49356857", "0.49298894", "0.48937234", "0.4881302", "0.48691523", "0.4845252", "0.4821734", "0.48183888", "0.48...
0.0
-1
Perform a merge operation
def _merge(self, box_list): if isinstance(box_list, self.__class__): box_list = [box_list] for box in box_list: for row in box: row[IND] = len(self) self.append(row) self._combine(row)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(): #Status: WIP\r\n pass", "def _merge(self):\n raise NotImplementedError", "def on_merge(self, to_be_merged, merge_result, context):\n pass", "def mergeWith(self, others):", "def merge(*args):\n from ..operators.observable.merge import merge_\n return merge_(*args)"...
[ "0.8324286", "0.775882", "0.7348654", "0.73391783", "0.711605", "0.6975439", "0.6975439", "0.6975439", "0.68910533", "0.6854348", "0.6818201", "0.67674536", "0.6687539", "0.6674524", "0.6658785", "0.6657529", "0.66195583", "0.65894455", "0.6566261", "0.65008974", "0.6500515",...
0.0
-1
Merge this Box with one or more other Box instances
def merge(self, box, in_place=True): if in_place: self._merge(box) else: base = self.copy() base._merge(box) return base
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _merge(self, box_list):\n if isinstance(box_list, self.__class__):\n box_list = [box_list]\n for box in box_list:\n for row in box:\n row[IND] = len(self)\n self.append(row)\n self._combine(row)", "def merge(self, other):\n\n ...
[ "0.68560404", "0.6515574", "0.64632297", "0.63198626", "0.6211465", "0.62063205", "0.6064046", "0.5991924", "0.5917754", "0.5910379", "0.5859801", "0.58339703", "0.58313894", "0.57778674", "0.5742428", "0.57081246", "0.5687884", "0.56496143", "0.563442", "0.56266993", "0.5626...
0.7087718
0
List the dependent data for each key where all keys are present
def vectors(self, keys, dct=None, labels="str", combine=True, indep_keys=None): keys = listify(keys) combined = self.combined() if combine else self filtered = self.filtered(keys, lst=combined) labels = "dict" if indep_keys is not None else labels if dct is not None: filtered = self.where(dct, filtered) out = {k: [] for k in keys} label_list = [] for dct in filtered: indep = dct[INDEP].copy() keys_to_find = [] for k in keys: if k in indep: out[k].append(indep.pop(k)) else: keys_to_find.append(k) if labels == "str": label = dict_to_str(indep, val_sep="=", key_sep=", ") else: label = indep label_list.append(label) dep = dct[DEP] for k in keys_to_find: out[k].append(dep[k]) lst_out = [out[k] for k in keys] if labels is not None and labels is not False: if indep_keys is None: lst_out.append(label_list) else: for k in indep_keys: lst_out.append([d[k] for d in label_list]) return tuple(lst_out)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys(self, dependent=True, independent=False):\n out = set()\n for row in self:\n if independent:\n out.update(row[INDEP].keys())\n if dependent:\n out.update(row[DEP].keys())\n return out", "def deps_for(nodes, key):\n\n def _deps(k...
[ "0.6234829", "0.60996187", "0.56604636", "0.56510067", "0.55388093", "0.55388093", "0.5499287", "0.54292846", "0.5428409", "0.5426958", "0.54142815", "0.53891647", "0.5372534", "0.5372534", "0.5371351", "0.53623796", "0.53498656", "0.5321484", "0.5321484", "0.5317146", "0.530...
0.49673614
50
Return lists of values grouped by other independent variables
def grouped(self, keys, labels="dict", as_dicts=False): # TODO: This seems method unnecessarily complex combined = self.combined() filtered = self.filtered(keys, lst=combined) out = {} for dct in filtered: d_labels = dct[INDEP].copy() d = {} keys_copy = keys.copy() for k in keys: if k in d_labels: d[k] = d_labels.pop(k) elif k in dct[DEP]: d[k] = dct[DEP][k] hsh = hash_dict(d_labels) if hsh not in out: f_labels = dict_to_str(d_labels) if labels == "str" else d_labels out[hsh] = {"labels": f_labels, "values": {k: [] for k in keys_copy}} d_values = out[hsh]["values"] for k in keys_copy: d_values[k].append(d[k]) if as_dicts: return list(out.values()) else: lst = [] for group in out.values(): row = [v for v in group["values"].values()] row.append(group["labels"]) lst.append(row) return lst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_variable_groups(all_inputs):\n row_length = len(all_inputs[0])\n for single_input in all_inputs[1:]:\n if len(single_input) != row_length:\n raise ValueError(\n \"Please make sure the length is the same if you want to input multiple values when the type of variables i...
[ "0.6295473", "0.6200967", "0.57439184", "0.5688238", "0.56285703", "0.55854857", "0.55849904", "0.5516372", "0.5502717", "0.5489601", "0.5482229", "0.5476639", "0.54517305", "0.545083", "0.54401696", "0.54284453", "0.5395837", "0.539547", "0.53786176", "0.5318466", "0.5317963...
0.0
-1
Return a dictionary of values for the key, by index
def find(self, key, lst=None): lst = self if lst is None else lst out = {} for row in lst: if key in row[DEP]: out[row[IND]] = row[DEP][key] elif key in row[INDEP]: out[row[IND]] = row[INDEP][key] return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __indicesToValues(self, mappings, indices):\n values = collections.OrderedDict()\n\n i = 0\n for key, _ in mappings.items():\n values[key] = mappings[key](indices[i])\n\n i = i + 1\n\n return values", "def key_dict_values (self):\r\n\r\n if self.using_...
[ "0.63526154", "0.6277658", "0.61653423", "0.61640495", "0.6143637", "0.6119429", "0.61189026", "0.61189026", "0.6102903", "0.6055466", "0.59926194", "0.59890264", "0.5900034", "0.5844392", "0.5840268", "0.58324164", "0.5820689", "0.5770119", "0.5755432", "0.5730282", "0.57258...
0.0
-1
Return unique key values
def unique(self, key, lst=None): d = self.find(key, lst) vals = set(d.values()) return sorted(list(vals))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_values(self):\n for key in self.metadb.unique_values():\n yield key, self.datadb[key]", "def distinct(self, key):\n return self.database.command({'distinct': self.name,\n 'key': key})['values']", "def _findUniqueMappingKeys(mapping):\n\n ...
[ "0.72342044", "0.7174483", "0.68495494", "0.67468446", "0.66601634", "0.6650714", "0.6622684", "0.6563308", "0.64356095", "0.64118284", "0.6411825", "0.6408245", "0.6370248", "0.6339864", "0.6293389", "0.6292799", "0.62809783", "0.6236327", "0.62303406", "0.6222865", "0.61984...
0.7189072
1
Return unique combinations of keys in the box
def combinations(self, key_list, lst=None): lst = self.filtered(key_list, lst) tups = [tuple([d[INDEP].get(k, d[DEP].get(k)) for k in key_list]) for d in lst] s = set(tups) l = list(s) l.sort() return [{k: v for k, v in zip(key_list, vals)} for vals in l]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keysAll():", "def generate_keys(self):\n self.keys = []\n key = string_to_bit_array(self.passwd)\n key = self.permutation(key, CP_1) # Perform initial permutation on the key\n g, d = split_into_n(key, 28) # Split into g (LEFT) & d (RIGHT)\n for i in range(16): # Apply th...
[ "0.62023306", "0.6162631", "0.59184194", "0.5876387", "0.5797509", "0.57924527", "0.5776189", "0.57255995", "0.57103395", "0.5674353", "0.5673763", "0.56703126", "0.56365746", "0.5633007", "0.56194043", "0.5603916", "0.55916125", "0.55871516", "0.5582946", "0.55571777", "0.55...
0.57542413
7
Return the value for a key at a given index
def item(self, index, key): row = self[index] if key in row[DEP]: return row[DEP][key] elif key in row[INDEP]: return row[INDEP][key] else: raise KeyError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value_for_index(self, index):\r\n return self[self.keyOrder[index]]", "def get_value_by_index(self, index):\n return self['value'][index]", "def __getitem__(self, index):\n return self._value_at(index)", "def __getitem__(self, index):\n return self._value_at(index)", "def ge...
[ "0.8506093", "0.75719273", "0.73860204", "0.73860204", "0.73637843", "0.72136736", "0.7130539", "0.7129745", "0.7118838", "0.71075356", "0.71021324", "0.7093473", "0.70449865", "0.69830865", "0.69765884", "0.6959366", "0.6956402", "0.6931386", "0.6903598", "0.68861365", "0.68...
0.0
-1
Allow easier access to data
def __getitem__(self, keys): if isinstance(keys, int): return super().__getitem__(keys) elif isinstance(keys, list): return self.vectors(keys) elif isinstance(keys, str): return self.find(keys) elif isinstance(keys, tuple): return self.item(keys[0], keys[1]) elif isinstance(keys, slice): return super().__getitem__(keys)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data(self):", "def data(self):", "def get_data(self):\r\n pass", "def get_data():\n pass", "def get_data(self):\n pass", "def get_data(self):\n pass", "def _get_data(self):\n raise NotImplementedError()", "def get_data():\n return", "def fetch_data(self...
[ "0.787504", "0.77359474", "0.7700366", "0.7674823", "0.7586071", "0.7586071", "0.72750527", "0.72719157", "0.7201379", "0.7178601", "0.7178601", "0.7178601", "0.71383196", "0.71383196", "0.70190066", "0.6975672", "0.69423085", "0.6939048", "0.693423", "0.6889714", "0.672735",...
0.0
-1
Format box contents in a concise way
def show(self, lst=None): def f(v): if np.size(v) == 1: return str(v) elif np.size(v) > 3: return str(np.shape(v)) elif np.ndim(v) > 1: return str(np.shape(v)) else: return str(v) def buffer(l, m, n=25): end = len(l) - 1 buffered = [] for i in range(m): if i > end: buffered.append("".ljust(n)) else: buffered.append(l[i].ljust(n)) return buffered lst = self if lst is None else lst out = [IND.ljust(7) + INDEP.ljust(60) + DEP.ljust(60)] for row in lst: ind = [str(row[IND])] dep = [k + ": " + f(v) for k, v in row[DEP].items()] indep = [k + ": " + f(v) for k, v in row[INDEP].items()] m = max(len(dep), len(indep), 1) ind = buffer(ind, m, 7) dep = buffer(dep, m, 60) indep = buffer(indep, m, 60) for a, b, c in zip(ind, indep, dep): out.append(a + b + c) out.append("") return "\n".join(out)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_box(box, box_style, border_visible, border_color, border_style,\n border_width, border_radius, padding, margin):\n box.box_style = box_style\n box.padding = padding\n box.margin = margin\n if border_visible:\n box.border_color = border_color\n box.border_style = b...
[ "0.638623", "0.6335261", "0.62239504", "0.6142633", "0.612802", "0.6116231", "0.61149377", "0.61149377", "0.61149377", "0.61149377", "0.61149377", "0.61149377", "0.6066256", "0.6044949", "0.60073614", "0.60017395", "0.60017395", "0.5998201", "0.59273905", "0.58198524", "0.581...
0.0
-1
Return a set of the keys in the Box
def keys(self, dependent=True, independent=False): out = set() for row in self: if independent: out.update(row[INDEP].keys()) if dependent: out.update(row[DEP].keys()) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys():", "def keys(self):\r\n return [k for k in self]", "def keys(self):\n return [ x for x in self ]", "def get_keys(self):\r\n return self._keys", "def keys(self):\n\n return self.keys_set", "def keysAll():", "def keys(self) -> List:\n pass", "def keys(self):\n ...
[ "0.7376837", "0.7284792", "0.7275277", "0.7271223", "0.7257253", "0.7218919", "0.72185975", "0.71058506", "0.70899194", "0.7057549", "0.70277166", "0.7014823", "0.70009017", "0.70009017", "0.69692326", "0.69683117", "0.6958609", "0.69498646", "0.6940273", "0.69003475", "0.689...
0.0
-1
The set methods must raise a ComponentsErrorEx in case of wrong mode
def test_wrong_mode(self): self.assertRaises(ComponentErrorsEx, self.dp.setRewindingMode, 'FOO')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modifyNotValuableComponents(self):\n # Nothing to do\n pass", "def set_comms_mode(self):", "def magic_xmode(self,parameter_s = ''):\n\n new_mode = parameter_s.strip().capitalize()\n try:\n self.InteractiveTB.set_mode(mode = new_mode)\n print 'Exception repo...
[ "0.58727384", "0.5831983", "0.57986915", "0.5704553", "0.56496924", "0.5616517", "0.5566472", "0.55448025", "0.54887784", "0.54351026", "0.54308224", "0.54267853", "0.54206556", "0.5400841", "0.5366232", "0.5362594", "0.5343893", "0.53403306", "0.53249055", "0.5301672", "0.52...
0.6587823
0
The argument of set must be returned by get in case of right mode
def test_right_mode(self): self.dp.setRewindingMode('AUTO') self.assertEqual(self.dp.getRewindingMode(), 'AUTO') self.dp.setRewindingMode('MANUAL')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set():", "def set():\n pass", "def test_set_with_get(self):\n storage = Storage()\n storage.set('1', 1)\n self.assertEqual(1, storage.set('1', 2, get=True), \"Should return previous value\")\n self.assertEqual(2, storage.get('1'), 'Should get new value')\n self.assertE...
[ "0.7555395", "0.7233269", "0.67569464", "0.65880513", "0.6474774", "0.6362361", "0.6110508", "0.6036238", "0.59842014", "0.5927305", "0.5922558", "0.58916026", "0.58916026", "0.58498436", "0.584614", "0.5840852", "0.5804425", "0.57713145", "0.5760654", "0.57327175", "0.572902...
0.0
-1
collect docker logs from servers $ command is $ log_collector.py
def main(): global tar_file_descr help_msg = 'Usage: log_collector.py <all | host1[,host2,host3...]>' hosts = [] if len(sys.argv) == 2: if '-h' == sys.argv[1] or '--help' == sys.argv[1]: print(help_msg) sys.exit(0) elif 'all' == sys.argv[1]: # get logs from all hosts hosts = [] host_objs = CLIENT.host_get_all() for host_obj in host_objs: hosts.append(host_obj.name) else: # get logs from specified hosts hostnames = sys.argv[1].split(',') for host in hostnames: if host not in hosts: hosts.append(host) else: print(help_msg) sys.exit(1) # open tar file for storing logs fd, tar_path = tempfile.mkstemp(prefix='kolla_support_logs_', suffix='.tgz') os.close(fd) # avoid fd leak with tarfile.open(tar_path, 'w:gz') as tar_file_descr: # clear out old logs if os.path.exists(LOGDIR): shutil.rmtree(LOGDIR) os.mkdir(LOGDIR) # gather logs from selected hosts try: for host in hosts: get_logs_from_host(host) # tar up all the container logs tar_file_descr.add(LOGDIR, arcname='container_logs') finally: # remove uncompressed logs if os.path.exists(LOGDIR): shutil.rmtree(LOGDIR) # gather dump output from kolla-cli dump_kolla_info() print('Log collection complete. Logs are at %s' % tar_path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docker_logs():\n local('docker logs {} -f'.format(project_name))", "def do_logs(cs, args):\n opts = {}\n opts['id'] = args.container\n opts['stdout'] = args.stdout\n opts['stderr'] = args.stderr\n opts['since'] = args.since\n opts['timestamps'] = args.timestamps\n opts['tail'] = args....
[ "0.73023754", "0.66543895", "0.6469975", "0.6311792", "0.6195516", "0.619132", "0.6190507", "0.618653", "0.6127707", "0.6075922", "0.60741675", "0.60354525", "0.60254896", "0.59426993", "0.59426993", "0.59009355", "0.58668494", "0.58238095", "0.58153385", "0.57909554", "0.577...
0.6732043
1
Load in all images from a folder
def load_svhn_images(folder_path): images = [] for file in os.listdir(folder_path): if file.endswith(".png"): image = Image.open(file) image.load() # Load image data as 1 dimensional array # We're using float32 to save on memory space feature = np.array(image, dtype=np.float32) images.append(feature) return images
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_images(self, folder):\n cwd = os.getcwd()\n dir = cwd + '/' + folder\n files = os.listdir(dir)\n for file in files:\n img = pygame.image.load(dir + '/' + file)\n self.images.append(img)", "def load_images_from_folder(folder):\n images = []\n for fi...
[ "0.8685325", "0.8239608", "0.81866777", "0.7909743", "0.78601134", "0.776808", "0.7751472", "0.773561", "0.76567906", "0.75322235", "0.75300574", "0.74120563", "0.7395588", "0.7363391", "0.7355561", "0.72881615", "0.72234184", "0.71718514", "0.71616906", "0.71594054", "0.7157...
0.6842482
43
Read in labels from digitStruct.mat file to create a dict of image file name and corresponding labels
def read_labels(digitstruct_file): labels = dict() for dsObj in tdqm(yieldNextDigitStruct(digitstruct_file), ncols=50): image_labels = [] for bbox in dsObj.bboxList: image_labels.append(bbox.label) labels[dsObj.name] = image_labels return labels
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_imagenet_as_dict(self):\n real_file_path = os.path.realpath(self.map_file)\n if not os.path.exists(real_file_path):\n raise IOError(\"map file {} not exists\".format(self.map_file))\n\n label_dict = {}\n with open(real_file_path) as fp:\n line = fp.readlin...
[ "0.7442581", "0.67145514", "0.6680717", "0.66700083", "0.6651974", "0.6599294", "0.65706545", "0.6568262", "0.65624034", "0.65466106", "0.6527709", "0.65229243", "0.65100825", "0.6500305", "0.649048", "0.6466592", "0.6466018", "0.6442053", "0.6429563", "0.6409631", "0.6398935...
0.8415674
0
ref CLRS pg326, solution to the basic supply chain problem using the book notation for variables name
def fastestWay( a, t, e, x, n ): import pdb;pdb.set_trace() f1.append( ( e[0] , 1 ) ) f2.append( ( e[1] , 2 ) ) for i in xrange(n): f11 = f1[i][0]+a[0][i] f12 = f2[i][0]+a[1][i]+t[1][i+1] f22 = f2[i][0]+a[1][i] f21 = f1[i][0]+a[0][i]+t[0][i+1] f1.append( ( min( f11, f12 ), 1 ) if f11 < f12 else ( min( f11, f12 ), 2 ) ) f2.append( ( min( f21, f22 ), 2 ) if f22 < f21 else ( min( f22, f21 ), 1 ) ) f1x, f2x = f1[n][0]+x[0], f2[n][0]+x[1] return ( min( f1x, f2x ) , f1 ) if f1x < f2x else ( min( f1x, f2x ), f2 )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exercise_b2_39():\r\n pass", "def exercise_b2_113():\r\n pass", "def exercise_b2_93():\r\n pass", "def exercise_b2_98():\r\n pass", "def exercise_b2_27():\r\n pass", "def exercise_b2_106():\r\n pass", "def exercise_b2_53():\r\n pass", "def exercise_b2_43():\r\n pass", "d...
[ "0.5789567", "0.5612758", "0.56002617", "0.5582453", "0.5527549", "0.5454671", "0.5450963", "0.5440792", "0.5437476", "0.54072136", "0.5388782", "0.53822136", "0.53622717", "0.5361482", "0.53562933", "0.5325314", "0.5280684", "0.52761763", "0.5207379", "0.5178423", "0.5170255...
0.0
-1
Evaluate the given python code
async def evaluate(ctx, *, command): if match := re.fullmatch(r"(?:\n*)?`(?:``(?:py(?:thon)?\n)?((?:.|\n)*)``|(.*))`", command, re.DOTALL): code = match.group(1) if match.group(1) else match.group(2) str_obj = io.StringIO() # Retrieves a stream of data try: with contextlib.redirect_stdout(str_obj): exec(code) except Exception as e: return await ctx.send(f"""❌ Your code completed with execution code 1 ``` {e.__class__.__name__}: {e} ```""") return await ctx.send(f"""✅ Your code completed with execution code 0 ``` {str_obj.getvalue()} ```""") embed = discord.Embed(description="Error: Invalid format", color=0xED2525) return await ctx.send(embed=embed)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluateCode(lang, code):", "def process_python(data, code):\n\tx=data\n\treturn eval(code)", "async def evaluate(self, ctx, *, code):\n # [p]evaluate <code>\n\n code = code.strip('` ')\n python = '```py\\n{}\\n```'\n result = None\n\n global_vars = globals().copy()\n ...
[ "0.81394625", "0.7703716", "0.75885594", "0.73609924", "0.69410247", "0.6835199", "0.68233687", "0.6816809", "0.6794713", "0.67543906", "0.6748919", "0.66606015", "0.6600024", "0.65660536", "0.6557946", "0.6557946", "0.6557946", "0.6556634", "0.6536984", "0.6512488", "0.64603...
0.63693184
24
Placeholder function This does not rotate the side chains. Only replaces the residues.
def get_neighbour_state(protein_pdb, name, dunbrack_library, buried_residues): new_file=open(name, "a") #chosen_residues = [i for i in buried_residues if get_current_residue(protein_pdb, i) in allowed_residues] residue_to_mutate=rd.choice(buried_residues) current_residue = get_current_residue(protein_pdb, residue_to_mutate) new_residue = rd.choice([i for i in allowed_residues if i!=current_residue]) protein_lines = list(parser.parse_file(protein_pdb)) residue_lines = list(parser.parse_file(residue_path.format(new_residue))) backbone_dictionary = mut.get_backbone_dictionary(mut.get_backbone(protein_lines)) phi = round_to_tens(ra.get_phi(residue_to_mutate, backbone_dictionary)) psi = round_to_tens(ra.get_psi(residue_to_mutate, backbone_dictionary)) main_key = new_residue, phi, psi choices = dunbrack_library[main_key] weighted_choices = [(i, choices[i]) for i in choices] choice = weighted_choice(weighted_choices) new_lines = mut.rotate_to_chis(choice, residue_lines) new_protein = mut.mutate(protein_lines, residue_to_mutate, new_lines) for l in new_protein: line = parser.pdb_format(l) print(line, file=new_file) new_file.close() return name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fill_input(self):\n for sc in self.initial:\n if sc not in self.litter:\n self.litter[sc] = [0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0.]\n for sc in self.litter:\n if sc not in self.initial:\n self.initia...
[ "0.5215274", "0.5188521", "0.5135618", "0.5071695", "0.50464606", "0.50296235", "0.49938515", "0.49912375", "0.49813616", "0.497628", "0.4964148", "0.49436188", "0.49054703", "0.48990193", "0.48943797", "0.48934063", "0.4865207", "0.48245913", "0.48215088", "0.4818732", "0.47...
0.0
-1
Construct a heap from a list of elements with priorities. Each element of the list must be in the form (Item, Priority).
def construct_heap(self, elems): for e in elems: self.n += 1 self.A.append(e) self.pos[e[0]] = self.n for i in range(self.n // 2, 0, -1): self.combine(i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heap_sort(list):\n pass", "def build_heap(self, items):\n for key in items:\n self.insert(key)", "def __init__(self, list = []):\n # initialize empty heap\n self.heap = []\n\n # initialize heap with provided list\n for element in list:\n self.add(...
[ "0.6715845", "0.6644555", "0.66232336", "0.6562983", "0.6562983", "0.6440951", "0.64229244", "0.64208883", "0.64108974", "0.63691944", "0.6351629", "0.63361603", "0.632387", "0.6306449", "0.6306449", "0.62739", "0.62633675", "0.62222654", "0.6173713", "0.6163355", "0.61413926...
0.6710219
1
Gets the first item of the heap (but doesn't remove it).
def get_first(self): return self.A[1][0] if self.n > 0 else None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def peek_first(self):\n if len(self._heap) == 0:\n return None\n else:\n return self._heap[0]", "def front(self):\n if self.size() < 1:\n return None\n else:\n # TODO: Return min item from heap, if any\n ...", "def min(self):\r\...
[ "0.82751524", "0.82521206", "0.8044901", "0.8024893", "0.8007148", "0.79513764", "0.7847617", "0.7768226", "0.7648149", "0.76431507", "0.7619455", "0.7604687", "0.75944394", "0.7558453", "0.7549099", "0.7532435", "0.74502736", "0.74292153", "0.74141717", "0.7407734", "0.73781...
0.0
-1
Gets the first item of the heap and removes it.
def delete_first(self): if self.n == 0: return None first = self.A[1] self.n -= 1 last = self.A.pop() if self.n > 0: self.A[1] = last self.pos[last[0]] = 1 self.combine(1) return first[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_min(self):\r\n # Should raise an exception of size is 0...\r\n if self._size == 0: raise KeyError # Can't remove from an empty heap\r\n result = self._data[0] # remember the smallest\r\n self._data[0] = None # None is so we don't have a reference.\r\n ...
[ "0.81402564", "0.80196005", "0.7973454", "0.78661436", "0.78423417", "0.77942383", "0.7791049", "0.7773328", "0.7764015", "0.7732128", "0.7705265", "0.76195896", "0.7605436", "0.75960815", "0.7542752", "0.75387627", "0.7532565", "0.7510987", "0.7498476", "0.74903107", "0.7478...
0.68407655
82
Inserts the element elem with priority prio.
def insert(self, elem, prio): self.n += 1 self.A.append( (e,w) ) self.pos[e] = self.n i = self.n p = i // 2 self.insert_loop(i, p)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_priority(self, elem, prio):\n pos = self.pos[elem]\n currPrio = self.A[pos][1]\n self.A[pos] = (elem, prio)\n if self.cmpFn(prio, currPrio):\n self.insert_loop(pos, pos // 2) # Up heapify\n else:\n self.combine(pos) # Down heapify", "def enque...
[ "0.74379945", "0.73325443", "0.71752936", "0.69993013", "0.65939367", "0.65610933", "0.65355706", "0.6510952", "0.6450642", "0.6369028", "0.63523465", "0.62270975", "0.622298", "0.6217232", "0.6212362", "0.6154356", "0.6117256", "0.61147964", "0.6046682", "0.5996028", "0.5992...
0.83393705
0