query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns GSoCProfile or GCIProfile which corresponds to the specified entity.
def _getProfileForRole(entity, profile_model): if isinstance(entity, profile_model): return entity if isinstance(entity, OrgAdmin) or isinstance(entity, Mentor): key_name = entity.program.key().name() + '/' + entity.user.key().name() else: key_name = entity.key().name() parent = entity.user ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getProfileFromUser(self):\n # Make sure user is authenticated\n user = endpoints.get_current_user()\n if not user:\n raise endpoints.UnauthorizedException('Authorization required')\n # Get Profile from datastore\n user_id = user.email()\n p_key = ndb.Key(Pr...
[ "0.60517067", "0.5931097", "0.5920047", "0.57531446", "0.5752912", "0.57454103", "0.5593141", "0.5578978", "0.5446997", "0.54374474", "0.5414628", "0.5366052", "0.5310331", "0.53044224", "0.5297717", "0.528342", "0.5280851", "0.5238035", "0.5170172", "0.5164785", "0.51386154"...
0.67691934
0
Returns Key instance of the Profile which corresponds to the Role which is represented by the specified Key.
def _getProfileKeyForRoleKey(key, profile_model): entity = db.get(key) profile = _getProfileForRole(entity, profile_model) return profile.key()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_key(self, role):\n\n for key, role_name in self.assignable_roles[0].items():\n if role_name == role.name:\n return key", "def get_key(self, key):\n ret = None\n qkey = key.__qualname__\n ret = self.get(qkey)\n if not ret:\n # check a...
[ "0.66111445", "0.58805066", "0.58505315", "0.5831204", "0.5803281", "0.5803281", "0.57678306", "0.5754127", "0.56673247", "0.56673247", "0.5639647", "0.5624423", "0.56116235", "0.56116235", "0.56116235", "0.56116235", "0.56116235", "0.56116235", "0.56116235", "0.56116235", "0...
0.828253
0
Iterates through the entities and updates the references.
def _process(self, start_key, batch_size): query = self.MODEL.all() if start_key: query.filter('__key__ > ', start_key) try: entities = query.fetch(batch_size) if not entities: # all entities has already been processed return for entity in entities: for fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_entities(self):\n raise NotImplementedError()", "def updateAllEntities():\n entityKeys=list(registeredEntities.keys())\n for currKey in entityKeys:\n try:\n currEntity=registeredEntities[currKey]\n currEntity.update()\n except KeyError:\n #th...
[ "0.6931095", "0.65709054", "0.6287238", "0.61648846", "0.60134435", "0.5991761", "0.59900665", "0.591261", "0.58126783", "0.5805775", "0.5740838", "0.5702715", "0.56896293", "0.5662672", "0.5657498", "0.56457126", "0.5643056", "0.5629276", "0.56268924", "0.55490804", "0.55468...
0.54959655
24
Starts a task which updates references for a particular model.
def updateReferencesForModel(model): if model == 'student_proposal': updater = ReferenceUpdater(StudentProposal, GSoCProfile, ['scope', 'mentor'], ['possible_mentors']) elif model == 'student_project': updater = ReferenceUpdater(StudentProject, GSoCProfile, ['mentor', 'student'], ['addition...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, task_model):\n raise NotImplementedError()", "def task_update(self):\n try:\n self.task_stop()\n except:\n pass\n self.update()\n self.task_start()", "async def update_model(model_updates):\n async for model_update in model_updates:\n...
[ "0.6739131", "0.57978827", "0.5764734", "0.57161385", "0.56552994", "0.555894", "0.5534376", "0.5498616", "0.53723985", "0.5328883", "0.52869743", "0.5229465", "0.52287436", "0.5193433", "0.518396", "0.51796234", "0.50973964", "0.5076054", "0.50661147", "0.5063656", "0.505143...
0.5769493
2
Starts a bunch of iterative tasks which update references in StudentProjects.
def updateStudentProjectReferences(request): return updateReferencesForModel('student_project')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_all_tasks(self) -> None:\n for task in self.tasks:\n task.update()", "def _update_projects_watch(self, new_projects_list):\n persistent_update_project = retry_children_watch_coroutine(\n '/appscale/projects', self.update_projects\n )\n main_io_loop = IOLoop.instance()\...
[ "0.589292", "0.58421355", "0.5682374", "0.5677322", "0.56522554", "0.5562921", "0.55216223", "0.5498498", "0.5461224", "0.5419146", "0.5413647", "0.5395407", "0.5332223", "0.5322703", "0.5321278", "0.52861494", "0.52130514", "0.5199185", "0.51861364", "0.51582754", "0.5149266...
0.54775155
8
Starts a bunch of iterative tasks which update references in StudentProposals.
def updateStudentProposalReferences(request): return updateReferencesForModel('student_proposal')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_all_tasks(self) -> None:\n for task in self.tasks:\n task.update()", "def _stage1(self):\n self.start_progress()\n tasks = list(self._chain_dict(self._model.adjust_tasks))\n if len(tasks) == 0:\n self._stage2(self._no_adjustments_case())\n else...
[ "0.5717533", "0.54796076", "0.54364556", "0.53478354", "0.5293635", "0.51366085", "0.5125454", "0.5119872", "0.51075053", "0.5100745", "0.5065694", "0.5057105", "0.5049609", "0.50482255", "0.5044344", "0.5037738", "0.5019423", "0.5008759", "0.50071543", "0.5003686", "0.500107...
0.54240596
3
Starts a bunch of iterative tasks which update references to various roles.
def updateReferences(request): # updates student proposals updateReferencesForModel('student_proposal') # updates student projects updateReferencesForModel('student_project') return http.HttpResponse("Ok")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def actualize(self):\r\n for guild, settings in self.bot.settings.items():\r\n # Grab the roles and their requirements\r\n guild = self.bot.get_guild(guild)\r\n base_member = settings.get(\"rank_basic_member_role_id\")\r\n base_member = guild.get_role(base_m...
[ "0.5954693", "0.5937825", "0.585267", "0.58371156", "0.58321106", "0.5830262", "0.5742774", "0.5681948", "0.5625343", "0.561437", "0.5614087", "0.5601306", "0.5526887", "0.55241233", "0.5524092", "0.5454957", "0.5360223", "0.53481555", "0.5344117", "0.5330294", "0.53005415", ...
0.0
-1
Creates a new IntMachine running given input Intcode progam.
def __init__( self, program: Iterable[int], noun: Optional[int] = None, verb: Optional[int] = None, fn_get_input: Optional[Callable[[], int]] = None, fn_set_output: Optional[Callable[[int], None]] = None ): self._program: List[i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _interactive_input_fn(hparams, decode_hp):\n num_samples = decode_hp.num_samples if decode_hp.num_samples > 0 else 1\n decode_length = decode_hp.extra_length\n input_type = \"text\"\n p_hparams = hparams.problem_hparams\n has_input = \"inputs\" in p_hparams.modality\n vocabulary = p_hparams.vocabulary[\"...
[ "0.57619214", "0.5523791", "0.5497577", "0.5425302", "0.5412043", "0.51995695", "0.51851875", "0.5182559", "0.5148229", "0.512977", "0.5129548", "0.5096928", "0.5052561", "0.5028506", "0.5015094", "0.4980892", "0.49586543", "0.49470448", "0.49391463", "0.49381799", "0.4921976...
0.5506527
2
Standard input method if none provided.
def get_raw_input() -> int: return int(input("> "))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createStandardInput(self):\n\t\traise NotImplementedError(\"\")", "def sysinput(rockstate):\n raise NotImplementedError", "def input_helper(prompt):\n if version_info[0] == 2:\n # python2 input is scary - we want raw_input\n return raw_input(prompt)\n else:\n return input(prom...
[ "0.70983446", "0.7037133", "0.70268506", "0.70225686", "0.70193917", "0.69750947", "0.69259167", "0.6899299", "0.67370933", "0.6504721", "0.64968175", "0.6495343", "0.63925487", "0.63925487", "0.63355005", "0.63202924", "0.6318242", "0.6313571", "0.6311044", "0.62952733", "0....
0.6201655
27
Standard output method if none provided.
def set_raw_output(val: int) -> None: print(val)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def standard_output(self) -> global___Statement.StandardOutput:", "def print_out():\n pass", "def printOutput(self):\n pass", "def __call__(self, *args, **kwargs):\n kwargs.setdefault(\"print_output\", self.PRINT_OUTPUT)\n kwargs.setdefault(\"return_output\", self.RETURN_OUTPUT)\n...
[ "0.7402091", "0.72167224", "0.6968697", "0.6889925", "0.687557", "0.6834578", "0.66962534", "0.66657144", "0.6642879", "0.65625054", "0.6447009", "0.6412474", "0.6398471", "0.6375641", "0.62936854", "0.6277434", "0.62161696", "0.61924154", "0.6149526", "0.6132663", "0.6124538...
0.0
-1
Entend memory to be at least this long by padding with zeros.
def _extend(self, newlen: int) -> None: diff = newlen - len(self) if diff > 0: self.extend([0] * diff)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dec_size(self):\r\n self.__length -= 1", "def zero_pad(data):\n N = len(data)\n pow_2 = np.ceil(np.log2(N))\n return np.pad(data,(0,int((2**pow_2)-N)),'constant')", "def getSizeOfZeroFill(self) -> int:\n ...", "def len_unpadded(self) -> int:", "def __pad(self, data):\n ret...
[ "0.6212953", "0.6161777", "0.61475414", "0.5942525", "0.58954096", "0.58908606", "0.57974887", "0.57881296", "0.5772151", "0.5764062", "0.5752971", "0.56805044", "0.56183845", "0.55799264", "0.5576856", "0.5575887", "0.5575213", "0.5573375", "0.5572014", "0.555359", "0.551463...
0.55716133
19
Function to concatenate dictionaries
def _join_dicts(dicts): if dicts is None: # pragma: no cover return assembled_dict = {k: v for D in dicts for k, v in D.items()} return assembled_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concatDic(dic1, dic2):\n pass", "def concat_dicts(self, dict1, dict2):\n result = dict()\n for key, value in dict1.items():\n if len(value.shape) == 1:\n result[key] = np.concatenate([value, dict2[key]])\n else:\n result[key] = np.vstack([v...
[ "0.78326815", "0.76263916", "0.7547149", "0.7144526", "0.7144526", "0.7033631", "0.70007455", "0.6978834", "0.68688685", "0.67944866", "0.6774909", "0.67653054", "0.6748235", "0.6728825", "0.67226535", "0.6719533", "0.6710105", "0.6710105", "0.6710105", "0.6700148", "0.669384...
0.71008927
5
1. Convert ifg phase data into numpy binary files. 2. Save the preread_ifgs dict with information about the ifgs that are later used for fast loading of Ifg files in IfgPart class
def _create_ifg_dict(dest_tifs, params): ifgs_dict = {} nifgs = len(dest_tifs) process_tifs = mpiops.array_split(dest_tifs) for d in process_tifs: ifg = shared._prep_ifg(d, params) ifgs_dict[d] = PrereadIfg(path=d, nan_fraction=ifg.nan_fraction, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_ifgs(ifg_paths, params, rows, cols):\n\n if mpiops.size > 1: # turn of multiprocessing during mpi jobs\n params[cf.PARALLEL] = False\n outdir = params[cf.TMPDIR]\n if not os.path.exists(outdir):\n shared.mkdir_p(outdir)\n\n tiles = mpiops.run_once(get_tiles, ifg_paths[0], row...
[ "0.6318846", "0.59935594", "0.58033705", "0.557617", "0.5541329", "0.548497", "0.54715943", "0.54680747", "0.54556257", "0.5448563", "0.5441124", "0.543736", "0.54259264", "0.5376901", "0.53260976", "0.5311196", "0.5308559", "0.5306656", "0.52739114", "0.524727", "0.52424717"...
0.69364214
0
MPI wrapper function for MST calculation
def _mst_calc(dest_tifs, params, tiles, preread_ifgs): process_tiles = mpiops.array_split(tiles) log.info('Calculating minimum spanning tree matrix') def _save_mst_tile(tile, i, preread_ifgs): """ Convenient inner loop for mst tile saving """ mst_tile = mst.mst_multiprocessi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_mediation(task):\n\tatlas = 'power'\n\tproject='hcp'\n\tknown_membership,network_names,num_nodes,name_int_dict = network_labels(atlas)\n\tsubjects = np.load('%s/dynamic_mod/results/%s_%s_%s_subs_fz.npy' %(homedir,'hcp',task,atlas))\n\tstatic_results = graph_metrics(subjects,task,atlas,run_version='fz')\n...
[ "0.5712891", "0.56743956", "0.5644941", "0.56176066", "0.5497657", "0.5445917", "0.53922945", "0.53776425", "0.53776425", "0.5272448", "0.5257341", "0.52249587", "0.5215293", "0.52147806", "0.51855075", "0.51734966", "0.51608145", "0.5157823", "0.51528966", "0.5091743", "0.50...
0.6318238
0
Convenient inner loop for mst tile saving
def _save_mst_tile(tile, i, preread_ifgs): mst_tile = mst.mst_multiprocessing(tile, dest_tifs, preread_ifgs, params) # locally save the mst_mat mst_file_process_n = join(params[cf.TMPDIR], 'mst_mat_{}.npy'.format(i)) np.save(file=mst_file_process_n, arr=mst_tile)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveTiles(z, x, y, ntiles, mapname, image, suffix = 'png', imgtype = None):\n for dx in range(0, ntiles):\n tilex = x*ntiles + dx\n ensureDirExists(getTileDir(mapname, z, tilex))\n for dy in range(0, ntiles): \n tiley = y*ntiles + dy\n offsetx = BORDER_WIDTH + d...
[ "0.7104713", "0.6770546", "0.66476554", "0.6564062", "0.6432503", "0.63820964", "0.63444513", "0.62283266", "0.62283266", "0.6224158", "0.6180002", "0.6177511", "0.61530757", "0.61273086", "0.61271673", "0.61231756", "0.60986423", "0.6098325", "0.6088457", "0.60603994", "0.60...
0.73028386
0
Wrapper for reference pixel calculation
def _ref_pixel_calc(ifg_paths: List[str], params: dict) -> Tuple[int, int]: lon = params[cf.REFX] lat = params[cf.REFY] ifg = Ifg(ifg_paths[0]) ifg.open(readonly=True) # assume all interferograms have same projection and will share the same transform transform = ifg.dataset.GetGeoTransform() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def referencepixel(self, *args, **kwargs):\n return _coordsys.coordsys_referencepixel(self, *args, **kwargs)", "def calc(self, *args, **kwargs):\n return _image.image_calc(self, *args, **kwargs)", "def pixel(self, x: int, y: int, colour: int, /) -> None:", "def pixel_ref(self):\n return ...
[ "0.70273024", "0.6470538", "0.6387868", "0.6360936", "0.6305052", "0.6197508", "0.6159541", "0.6128455", "0.6084345", "0.6061778", "0.60592145", "0.5950711", "0.5843533", "0.5832167", "0.58209383", "0.5817011", "0.5734207", "0.57130796", "0.5680172", "0.5634101", "0.56332415"...
0.6673501
1
MPI wrapper for orbital fit correction
def _orb_fit_calc(multi_paths: List[MultiplePaths], params, preread_ifgs=None) -> None: if not params[cf.ORBITAL_FIT]: log.info('Orbital correction not required!') print('Orbital correction not required!') return log.info('Calculating orbital correction') ifg_paths = [p.sampled_path...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_MPI_Parallel_Interface(comm):\n\n def printMPI(msg):\n for i in range(comm.Get_size()):\n comm.barrier()\n if comm.Get_rank() == i:\n print(\"Proc {}: {}\".format(i, msg))\n\n n = 10\n\n par = MPI_Objective_Interface(mp.Extended_Rosenbrock, nb_domain_gr...
[ "0.5844359", "0.5622064", "0.55996203", "0.5493118", "0.5468938", "0.5443779", "0.54386663", "0.53946644", "0.5390193", "0.53538936", "0.5300762", "0.52867675", "0.5278852", "0.5252904", "0.52269447", "0.5218884", "0.52153146", "0.52118087", "0.5195961", "0.5157866", "0.51551...
0.54099774
7
Wrapper for reference phase estimation.
def _ref_phase_estimation(ifg_paths, params, refpx, refpy): log.info("Calculating reference phase and correcting each interferogram") if len(ifg_paths) < 2: raise rpe.ReferencePhaseError( "At least two interferograms required for reference phase correction ({len_ifg_paths} " "pro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetReferencePhase (self, miips_settings=None) :\n\t\tif miips_settings is None :\n\t\t\tmiips_settings = self.GetSettings()\n\t\t\n\t\t# Retrieve the basis type\n\t\tpolynomial_basis = self.polynomial_bases[ miips_settings[\"polynomial_basis\"] ]\n\t\t\n\t\t# Arguments of the basis \n\t\tX = np.linspace(-1., 1...
[ "0.7015458", "0.6582434", "0.6338043", "0.6205949", "0.5983391", "0.58729506", "0.58365", "0.5791588", "0.5786385", "0.5780738", "0.5776022", "0.57702374", "0.57702374", "0.5757595", "0.5725867", "0.5724824", "0.5707285", "0.5639593", "0.5624812", "0.5580624", "0.557016", "...
0.6133667
4
Top level function to perform PyRate workflow on given interferograms
def main(params): mpi_vs_multiprocess_logging("process", params) ifg_paths = [] for ifg_path in params[cf.INTERFEROGRAM_FILES]: ifg_paths.append(ifg_path.sampled_path) rows, cols = params["rows"], params["cols"] return process_ifgs(ifg_paths, params, rows, cols)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def func(args):\n\n classifier_stat_list = []\n cf_frames = []\n confidences_list = []\n intents_in_results = pd.Series(dtype='float')\n\n classifier_num = len(args.classifiers_results)\n\n # Prepare labels for each curve\n labels = [os.path.splitext(os.path.basename(file_path))[0]\n ...
[ "0.5867609", "0.5741518", "0.5724703", "0.57064086", "0.56842136", "0.5653325", "0.5587649", "0.5583598", "0.5509468", "0.5485103", "0.5458944", "0.5457116", "0.5422393", "0.5393152", "0.5389847", "0.5385744", "0.53734523", "0.53389794", "0.53318554", "0.52802575", "0.5274898...
0.0
-1
Top level function to perform PyRate workflow on given interferograms
def process_ifgs(ifg_paths, params, rows, cols): if mpiops.size > 1: # turn of multiprocessing during mpi jobs params[cf.PARALLEL] = False outdir = params[cf.TMPDIR] if not os.path.exists(outdir): shared.mkdir_p(outdir) tiles = mpiops.run_once(get_tiles, ifg_paths[0], rows, cols) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def func(args):\n\n classifier_stat_list = []\n cf_frames = []\n confidences_list = []\n intents_in_results = pd.Series(dtype='float')\n\n classifier_num = len(args.classifiers_results)\n\n # Prepare labels for each curve\n labels = [os.path.splitext(os.path.basename(file_path))[0]\n ...
[ "0.5867609", "0.5741518", "0.5724703", "0.57064086", "0.56842136", "0.5653325", "0.5587649", "0.5583598", "0.5509468", "0.5485103", "0.5458944", "0.5457116", "0.5422393", "0.5393152", "0.5389847", "0.5385744", "0.53734523", "0.53389794", "0.53318554", "0.52802575", "0.5274898...
0.0
-1
MPI wrapper for stacking calculation
def _stack_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): process_tiles = mpiops.array_split(tiles) log.info('Calculating rate map from stacking') output_dir = params[cf.TMPDIR] for t in process_tiles: log.info('Stacking of tile {}'.format(t.index)) ifg_parts = [shared.IfgPart(p, t,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gather_ps(rank, size, comm, k_allmodels, P21_allmodels, PHII_allmodels,\n first_snap_allmodels, last_snap_allmodels):\n\n def generate_tag(rank):\n tag = int(rank*100)\n\n return tag\n\n # Rank 0 will gather the wavenumber bins/power spectra from all other\n # ranks. \n i...
[ "0.56406677", "0.54841715", "0.5319267", "0.53158826", "0.52270633", "0.52124757", "0.5178584", "0.51732755", "0.51422054", "0.5141755", "0.5132032", "0.51277685", "0.5125442", "0.51210636", "0.5116323", "0.50880647", "0.508449", "0.5058797", "0.505715", "0.5034772", "0.50324...
0.515047
8
MPI wrapper for maxvar and vcmt computation
def _maxvar_vcm_calc(ifg_paths, params, preread_ifgs): log.info('Calculating the temporal variance-covariance matrix') process_indices = mpiops.array_split(range(len(ifg_paths))) def _get_r_dist(ifg_path): """ Get RDIst class object """ ifg = Ifg(ifg_path) ifg.open()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_max_and_argmax(node):\r\n if node.op == T._max_and_argmax:\r\n if len(node.outputs[1].clients) == 0:\r\n #MaxAndArgmax support variable axis,\r\n #but CAReduce support only constant axis.\r\n if node.inputs[1].data is None:\r\n axis = None\r\n ...
[ "0.6341681", "0.61969894", "0.6065083", "0.60228604", "0.60162735", "0.596405", "0.5831983", "0.58185774", "0.57805014", "0.57521695", "0.57240343", "0.57173043", "0.56774616", "0.5617856", "0.5602376", "0.5560389", "0.55562276", "0.5540691", "0.5516906", "0.549255", "0.54219...
0.80074286
0
Get RDIst class object
def _get_r_dist(ifg_path): ifg = Ifg(ifg_path) ifg.open() r_dist = vcm_module.RDist(ifg)() ifg.close() return r_dist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_instance(self):", "def _get_instance(self):", "def get_class(self):\n\t\treturn self.CLASS", "def GetInstance():\n pass", "def getClassObject(self):\n return self.device()", "def get_object(cls):\n values = cls._METHOD(get_object(TOP_OBJECT))\n return StratisdConstants....
[ "0.6729752", "0.6729752", "0.65443677", "0.6543258", "0.6500587", "0.6476979", "0.6384267", "0.63405716", "0.6319236", "0.6222948", "0.6133858", "0.590584", "0.58932704", "0.58908397", "0.58358616", "0.5834195", "0.58051187", "0.58033943", "0.5774452", "0.57590514", "0.575060...
0.0
-1
MPI wrapper for time series calculation.
def _timeseries_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): if params[cf.TIME_SERIES_CAL] == 0: log.info('Time Series Calculation not required') return if params[cf.TIME_SERIES_METHOD] == 1: log.info('Calculating time series using Laplacian Smoothing method') elif params[cf....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_trajectory():\n pass", "def mpi_schedule_job_array(csvstore, job_array, mpi_service=MPIService()):\n param_array = job_array.param_array\n job = job_array.job\n try:\n if mpi_service.rank == 0:\n # master\n results = []\n nb_completed_tasks = 0\n ...
[ "0.56803995", "0.56590575", "0.53260535", "0.5320121", "0.52309686", "0.5216873", "0.52014816", "0.51989406", "0.5178184", "0.51628107", "0.5117995", "0.5109982", "0.50846106", "0.50473", "0.5044743", "0.50315577", "0.49988696", "0.4984488", "0.49706215", "0.49481472", "0.493...
0.622448
0
Performs forward propagation over a pooling layer of a neural network A_prev is a numpy.ndarray of shape (m, h_prev, w_prev, c_prev) containing the output of the previous layer m is the number of examples h_prev is the height of the previous layer w_prev is the width of the previous layer c_prev is the number of channe...
def pool_forward(A_prev, kernel_shape, stride=(1, 1), mode='max'): sh, sw = stride kh, kw = kernel_shape m, h_prev, w_prev, c_prev = A_prev.shape if mode == 'max': pool = np.max else: pool = np.average pixy = (((h_prev - kh) // sh) + 1) pixx = (((w_prev - kw) // sw) + 1) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pool_forward(A_prev, kernel_shape, stride=(1, 1), mode='max'):\n\n m = A_prev.shape[0]\n image_h = A_prev.shape[1]\n image_w = A_prev.shape[2]\n nc = A_prev.shape[3]\n filter_h = kernel_shape[0]\n filter_w = kernel_shape[1]\n s1 = stride[0]\n s2 = stride[1]\n n_dim1 = int((image_h - ...
[ "0.74333364", "0.72409993", "0.70541304", "0.68746275", "0.68447983", "0.6832156", "0.6613929", "0.6610399", "0.65891165", "0.6552982", "0.65083486", "0.6470873", "0.6430382", "0.6384204", "0.63692904", "0.63500184", "0.6325443", "0.6323297", "0.6311723", "0.62989324", "0.628...
0.70796555
2
Decorate routes to require login.
def login_required(f): @wraps(f) def decorated_function(*args, **kwargs): if session.get("user_id") is None: return redirect("/login") return f(*args, **kwargs) return decorated_function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_logged_in():\n def handler(f, *args, **kwargs):\n if args[0].current_user is not None:\n return f(*args, **kwargs)\n else:\n raise HTTPFound(args[0].route_url('user.login', _query={'redirect': encode_route(args[0])}))\n return decorator(handler)", "def login_...
[ "0.7091533", "0.6892078", "0.68879133", "0.6886881", "0.6870711", "0.6868814", "0.6861688", "0.68355834", "0.68217534", "0.68217534", "0.68066365", "0.6799305", "0.6781187", "0.67807055", "0.67787105", "0.67541313", "0.67410886", "0.6710316", "0.6700641", "0.6659009", "0.6634...
0.65288085
39
Nodes contains the list of Node IDs
def nodes(self): return self._nodes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n if not nodes:\n nodes = self.nodes\n if isinstance(nodes[0], integer_types):\n node_ids = [node for node in nodes]\n else:\n node_ids = [node.nid for node in nodes]\n assert 0 not...
[ "0.83000004", "0.8131124", "0.797375", "0.7874567", "0.7622371", "0.76150525", "0.76021403", "0.7440475", "0.72694916", "0.72609204", "0.7224216", "0.7205625", "0.71716934", "0.7168971", "0.7166156", "0.7128564", "0.7105078", "0.7098094", "0.7096057", "0.7057704", "0.7051385"...
0.709314
21
Elements contains the list of Node IDs
def els(self): return self._els
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_ids(self):\n return [self.node_id]", "def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n if not nodes:\n nodes = self.nodes\n if isinstance(nodes[0], integer_types):\n node_ids = [node for node in nodes]\n else:\n node_...
[ "0.7360851", "0.7293044", "0.69521904", "0.6883702", "0.6718082", "0.6672819", "0.6615255", "0.6561446", "0.6528296", "0.6508696", "0.64987046", "0.6453324", "0.6450563", "0.64014673", "0.63438755", "0.62822205", "0.62575054", "0.62286055", "0.62051105", "0.619053", "0.617895...
0.0
-1
Elements with the associated face orientations are specified as Nx2 numpy array, with the first column being the element Id, and the second column the chosen face orientation
def surfacePairs(self): return self._els
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetElementsFaceNumberingTet(self):\n\n if isinstance(self.face_to_element,np.ndarray):\n if self.face_to_element.shape[0] > 1:\n return self.face_to_element\n\n assert self.elements is not None\n\n # GET ALL FACES FROM ELEMENT CONNECTIVITY\n if self.all_fac...
[ "0.6492938", "0.6433311", "0.6385231", "0.6308946", "0.60947216", "0.6033617", "0.6026896", "0.5914788", "0.57787204", "0.5756701", "0.5699518", "0.56663305", "0.5603247", "0.5529283", "0.54977447", "0.54731786", "0.54153985", "0.5397718", "0.5385123", "0.53754866", "0.537321...
0.0
-1
Nodes contains the list of Node IDs
def nodeset(self): return self._nodeset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n if not nodes:\n nodes = self.nodes\n if isinstance(nodes[0], integer_types):\n node_ids = [node for node in nodes]\n else:\n node_ids = [node.nid for node in nodes]\n assert 0 not...
[ "0.83000004", "0.8131124", "0.797375", "0.7874567", "0.7622371", "0.76150525", "0.76021403", "0.7440475", "0.72694916", "0.72609204", "0.7224216", "0.7205625", "0.71716934", "0.7168971", "0.7166156", "0.7128564", "0.7105078", "0.7098094", "0.7096057", "0.709314", "0.709314", ...
0.0
-1
Sets the number of simulation threads to use in Calculix
def setNumThreads(cls, numThreads: int): cls.NUMTHREADS = numThreads
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setNumThreads(self, num):\r\n self.threads = num", "def setNumThreads(self, num):\r\n # implement ThreadPool interface\r\n assert not self.prepared, \"You can't change number of threads for working server\"\r\n self.threads = num", "def setNThreads(self,n):\n assert(n>0)\n ...
[ "0.8256052", "0.7567058", "0.75560105", "0.7523079", "0.71850544", "0.71713644", "0.7045087", "0.6716871", "0.6572469", "0.6557934", "0.6522405", "0.64511395", "0.63847023", "0.63694143", "0.6355767", "0.62587845", "0.625188", "0.625188", "0.62317884", "0.6220977", "0.6196904...
0.7770937
1
Returns the number of threads used
def getNumThreads(cls) -> int: return cls.NUMTHREADS
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getThreads():\r\n return multiprocessing.cpu_count()", "def nThreads(self):\n return self._c_param.n_threads", "def getThreads():\n if sys.platform == 'win32':\n return int(os.environ['NUMBER_OF_PROCESSORS'])\n else:\n return int(os.popen('grep -c cores /proc/cpuinfo').read())...
[ "0.87160325", "0.8365115", "0.80756944", "0.8064238", "0.80488205", "0.80468506", "0.80122787", "0.796875", "0.79343176", "0.79194176", "0.7910496", "0.78782344", "0.78163666", "0.76584685", "0.76553136", "0.76175404", "0.76108193", "0.7597156", "0.7580023", "0.7564992", "0.7...
0.86468875
1
Sets the path for the Calculix executable. Necessary when using Windows where there is not a default installation proceedure for Calculix
def setCalculixPath(cls, calculixPath: str) -> None: if os.path.isdir(calculixPath) : cls.CALCULIX_PATH = calculixPath
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_vernissagecmd_path(path):\n\n global vernissagecmd_path # Allows us to change the global value of the path.\n if path == 'default': # Change the file path back to the default value.\n vernissagecmd_path = default_vernissagecmd_path\n print('VernissageCmd.exe path changed to {path}'.fo...
[ "0.59972835", "0.57588685", "0.57472515", "0.56947476", "0.55666745", "0.54746413", "0.5436197", "0.54127634", "0.5398966", "0.5395865", "0.5377132", "0.5316808", "0.52898544", "0.5277046", "0.5276305", "0.5267065", "0.52460194", "0.5244962", "0.5238546", "0.52273226", "0.522...
0.7140539
0
Sets if the output from Calculix should be verbose i.e. printed to the console
def setVerboseOuput(cls, state: bool) -> None: cls.VERBOSE_OUTPUT = state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _verbose(self,text):\n if self.verbose:\n print(text)", "def verbose():\n GLOBAL['VERBOSE'] = True", "def enable_verbose(self):\n self.verbose = True", "def do_verbose(self, arg):\n global verbose\n if verbose == 1:\n verbose = 0\n # prtin a...
[ "0.7576609", "0.75671554", "0.7325032", "0.72009075", "0.7171362", "0.71610594", "0.71219254", "0.710803", "0.70517606", "0.7015005", "0.6994801", "0.69857395", "0.69782174", "0.6964244", "0.69489235", "0.69267154", "0.6889459", "0.6883595", "0.6871422", "0.6870989", "0.68132...
0.7289895
3
Creates node sets for any RBE connectors used in the simulation
def prepareConnectors(self): # Kinematic Connectors require creating node sets # These are created and added to the node set collection prior to writing numConnectors = 1 for connector in self.connectors: # Node are created and are an attribute of a Connector se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_nodes(self):", "def gen_nodes(self):\n self.nodes = []\n for i in range(self.num_nodes):\n self.nodes.append(Node(self.fk))", "def create_exporters(self):\n for node_cfg in self.node_cfg_list:\n self.create_node(node_cfg)", "def create_nodes(self):\n ...
[ "0.6607326", "0.6201226", "0.61612624", "0.6156707", "0.6078838", "0.6066718", "0.6010416", "0.598341", "0.58685356", "0.5867943", "0.5858527", "0.5854881", "0.5841058", "0.58386105", "0.5774203", "0.5754194", "0.5719591", "0.568923", "0.5685475", "0.56728554", "0.56583863", ...
0.70691216
0
Writes the input deck for the simulation
def writeInput(self) -> str: self.init() self.prepareConnectors() self.writeHeaders() self.writeMesh() self.writeNodeSets() self.writeElementSets() self.writeKinematicConnectors() self.writeMPCs() self.writeMaterials() self.writeMaterial...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, location: str):\n with open(location, \"w\") as f:\n f.write(self.get_deck())", "def write_data_card(spec, data_card, channels, path):\n with open(path, \"w\") as f:\n f.write(f\"imax {str(size(data_card.bins))}\" + \"\\n\")\n f.write(\n \"jmax \"\n ...
[ "0.64848584", "0.61496377", "0.59714556", "0.59345895", "0.5903547", "0.5831078", "0.5801172", "0.57777035", "0.56310844", "0.557189", "0.5561565", "0.5543363", "0.5537963", "0.55217195", "0.5507108", "0.54969305", "0.54969305", "0.54969305", "0.54965746", "0.54940253", "0.54...
0.5011826
64
Routine checks that the analysis has been correctly generated
def checkAnalysis(self) -> bool: if len(self.materials) == 0: raise AnalysisError('No material models have been assigned to the analysis') for material in self.materials: if not material.isValid(): raise AnalysisError('Material ({:s}) is not valid'.format(materi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_analysis(self, analysis, ecosystem, package, version):\n try:\n assert analysis is not None, \"Analysis not available\"\n assert \"result\" in analysis, \"Can not find the 'result' node.\"\n result = analysis[\"result\"]\n self.check_recommendation_part(...
[ "0.66156864", "0.6456809", "0.64475083", "0.6370584", "0.6334549", "0.63327205", "0.627546", "0.6254273", "0.61636823", "0.61520344", "0.6151861", "0.6145502", "0.61336225", "0.6127267", "0.6127267", "0.6127267", "0.6127267", "0.61148167", "0.6100177", "0.60883856", "0.608783...
0.6097213
19
Returns the results obtained after running an analysis
def results(self) -> ResultProcessor: if self.isAnalysisCompleted(): return ResultProcessor('input') else: raise ValueError('Results were not available')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getResults():", "def getTestResults():", "def _process_results(self):\n self.portfolio.create_backtest_result_dataframe()\n stats = self._show_stats()\n return stats", "def results(self):\n pass", "def results(self):\r\n pass", "def return_results(self):\n\n ...
[ "0.76782405", "0.7111066", "0.7080622", "0.6936419", "0.68742526", "0.68452024", "0.6749717", "0.67244124", "0.6706752", "0.66855854", "0.667995", "0.6626502", "0.6617574", "0.6617118", "0.6613596", "0.66079456", "0.6602328", "0.65929186", "0.6563379", "0.65618026", "0.654714...
0.65645134
18
Returns if the analysis was completed successfully.
def isAnalysisCompleted(self) -> bool: return self._analysisCompleted
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_result(self):\n return len(self.__analysis_items) > 0", "def successful(self) -> bool:\n\n return self._successful", "def has_success(self) -> bool:\n return self._has_success", "def is_successful(self) -> bool:\n return bool(self.result_state and self.result_state.is_succ...
[ "0.7395358", "0.7370877", "0.7368734", "0.7324297", "0.7295538", "0.7222038", "0.71889675", "0.71834224", "0.71548474", "0.71323526", "0.7120799", "0.70954716", "0.7075373", "0.7017168", "0.701042", "0.7007025", "0.7000122", "0.698778", "0.6979704", "0.6962313", "0.69311875",...
0.80789053
0
Clears any files generated from the analysis
def clearAnalysis(self, includeResults:bool = False) -> None: filename = 'input' # Base filename for the analysis files = [filename + '.inp', filename + '.cvg', filename + '.sta'] if includeResults: files.append(filename + '.frd') file...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_files(self):\n self.filenames.clear()", "def clean():\n clean_files()", "def clear(self):\r\n shutil.rmtree(self._output_dir, ignore_errors=True)", "def clear_local_output_directory():\n output_path = '../output/*'\n files = glob.glob(output_path)\n for single_...
[ "0.7968305", "0.77191716", "0.7537249", "0.7515307", "0.7513296", "0.7491484", "0.7484085", "0.7410033", "0.734755", "0.7287088", "0.72671735", "0.72499853", "0.7249866", "0.7248436", "0.72048616", "0.7182686", "0.7161519", "0.71290827", "0.7113421", "0.7099185", "0.70814157"...
0.778449
1
Performs preanalysis checks on the model and submits the job for Calculix to perform.
def run(self): # Reset analysis status self._analysisCompleted = False print('{:=^60}\n'.format(' RUNNING PRE-ANALYSIS CHECKS ')) self.checkAnalysis() print('{:=^60}\n'.format(' WRITING INPUT FILE ')) inputDeckContents = self.writeInput() inputDeckPath = os.pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(self):\n\t\tif self.update_check() or self.force_update:\n\t\t\tself.district_check() #pull all local data and regions\n\t\t\tself.fix() #fix data anomalies - e.g add in Bucks.\n\t\t\tself.save_all() #store a copy of the data\n\t\t\tself.ingest() #add data to models\n\t\t\tself.update_totals() #calcula...
[ "0.60384953", "0.6016247", "0.60156345", "0.59840256", "0.59757525", "0.5951607", "0.59254736", "0.59193635", "0.5880545", "0.58239514", "0.58234215", "0.5755604", "0.57518536", "0.5748295", "0.5726689", "0.5719881", "0.5683315", "0.5667691", "0.5627192", "0.56015015", "0.560...
0.57189363
16
crawl targeted twitter account, save tweets to csv
def crawlAccount(target): # connect Twitter api twitter = connectTwitter() try: user_timeline = twitter.get_user_timeline(screen_name=target, count=200, include_rts=False, exclude_replies=False) except TwythonError: sys.exit('Received 404 for %s. Account does not exist or is banned.' % target) user_timelin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_twitter_sentiment():\r\n # Open/create a file to append data to\r\n csvFile = open(NAME+'_posts.csv', 'a')\r\n # Use csv writer\r\n csvWriter = csv.writer(csvFile)\r\n # Calling the user function with current parameters\r\n results = twitter.user_timeline(id=NAME, count=TWEET_COUNT)\r...
[ "0.70010406", "0.67850053", "0.6734272", "0.66105545", "0.6591761", "0.64855397", "0.64794904", "0.6473131", "0.64262015", "0.64123046", "0.63488454", "0.6339719", "0.6291743", "0.6237709", "0.621407", "0.62131447", "0.61392415", "0.6134089", "0.6120575", "0.60954064", "0.606...
0.7076422
0
setting up (once) the database_handler object
def setUpClass(cls): cls.database_connection = DatabaseHandler(database_path) cls.database_connection.connect() processing.create_table_if_not_exist(cls.database_connection, table_name) cls.database_connection.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_handler():\n\n pass", "def init_database(self):\n # init_database(self.engine)", "def __init__(self):\n self._connection = get_db_connection()", "def init_database(self):\n init_database(self.engine)", "def __post_init__(self):\n self.dbase = databases.Database(\n ...
[ "0.78314054", "0.7627274", "0.7559624", "0.754649", "0.75244814", "0.7467165", "0.74635506", "0.74344593", "0.73077554", "0.7241103", "0.7236283", "0.72287995", "0.72168446", "0.7195054", "0.71664596", "0.7162537", "0.7154164", "0.7145977", "0.71009624", "0.7090436", "0.70133...
0.69591
23
adding an assertion for testing dataframe equality setting up a database_handler object with the dummy database path and connecting it
def setUp(self): self.addTypeEqualityFunc(pandas.DataFrame, self.assertDataframeEqual) self.database_connection.connect()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_build_dataframe(self):\n insert_good_data()\n dataframe = get_dataframe()\n # 1 2 3\n self.assertIs(type(dataframe['Total'][0]), numpy.float64)\n self.assertIs(type(dataframe['InvoiceDate'][0]), str)\n self.assertIs(type(dataframe['Count'][0]), numpy.int64)\n ...
[ "0.71694195", "0.69254637", "0.6790876", "0.6677135", "0.6648234", "0.6580347", "0.650768", "0.6470732", "0.6430044", "0.6362951", "0.6330373", "0.632379", "0.6319858", "0.6303485", "0.6296251", "0.6263661", "0.6252208", "0.6215653", "0.6214677", "0.6211742", "0.62074625", ...
0.7636546
0
tearing down the table, and closing the connection
def tearDown(self): # in case one of the methods closed the connection self.database_connection.connect() self.database_connection.clear_table('''DELETE FROM ''' + table_name) self.database_connection.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __close_table(self):\r\n self.talkdb.close()", "def close(self): # XXX This should stop everything else from working but currently doesn't!\r\n if self._closed:\r\n raise Error('The connection to the database has already been closed.')\r\n self.rollback()\r\n for table ...
[ "0.7777105", "0.7532934", "0.7225821", "0.71760124", "0.683726", "0.6809468", "0.67966264", "0.6765855", "0.67586", "0.6750372", "0.66682756", "0.66682756", "0.66682756", "0.6660634", "0.6641654", "0.6626848", "0.66202575", "0.6592834", "0.65923333", "0.65890336", "0.6573911"...
0.7154105
4
data is getting here after already tested in main (path, type, table_name) 1. testing process_file process for json, establishing, creating, reading file, sorting, inserting 2. testing correct amount in database of first insertion (4) 3. testing process_file process for csv, establishing, creating, reading file, sortin...
def test_process_file(self): # 1 self.assertEqual(get_file_reply(files[0][0], files[0][1]), "Inserted 4 Records") results = self.database_connection.select('''SELECT COUNT(*) FROM ''' + table_name)[0][0] # 2 self.assertEqual(results, 4) # csv, renewing connection ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_data_to_database(self, database_type, data):\n\n if database_type == \"render\":\n connection = sqlite3.connect(self.filepath_render_database)\n pointer = connection.cursor()\n pointer.executemany(\"\"\"\n INSERT INTO render_information\...
[ "0.67387795", "0.65439796", "0.64619803", "0.64615047", "0.6430858", "0.6424109", "0.6397895", "0.63515615", "0.63336784", "0.6242904", "0.61867195", "0.616004", "0.6157133", "0.61454034", "0.61321026", "0.61135757", "0.60946494", "0.6084579", "0.60293835", "0.6022912", "0.60...
0.6500793
2
1.2.3 checking data type is correct 4. testing sum of columns is correct 5. (added assertion) testing dataframes are the same, one manufactured 6. clearing the database and inserting altered data CustomerId duplicate, checking difference in Count (34) 7. testing raising an exception of AssertionError with dataframe and...
def test_build_dataframe(self): insert_good_data() dataframe = get_dataframe() # 1 2 3 self.assertIs(type(dataframe['Total'][0]), numpy.float64) self.assertIs(type(dataframe['InvoiceDate'][0]), str) self.assertIs(type(dataframe['Count'][0]), numpy.int64) # 4 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_dataframe(dataframe):\n results = True\n rows = dataframe.shape[0]\n column_names = sorted(dataframe.columns)\n column_datatypes = list(dataframe[column_names].dtypes)\n\n # Checks columns match those specified in #1\n if column_names != DATA_COLUMNS:\n raise ValueError(\"D...
[ "0.7033019", "0.6735344", "0.66333157", "0.644243", "0.6424497", "0.6372388", "0.63426524", "0.6339254", "0.62987274", "0.62735826", "0.62442666", "0.6217152", "0.6199997", "0.617955", "0.61647725", "0.61497754", "0.6148181", "0.6148095", "0.6096861", "0.60874194", "0.6004757...
0.78982604
0
1. testing the build_graph method returns the correct string, and waiting for file to open (less than 1 sec)
def test_build_graph(self): insert_good_data() dataframe = get_dataframe() results = processing.build_graph(dataframe, figure_path, False) # 1 self.assertEqual(results, "Updated html File and Opened it")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testGraphExtract(self):\n graph = Graph2()\n graph.parseFile(TESTFILE)", "async def get_graph_for_file(\n file_name: str,\n score: int = 0,\n par_length: int = 0,\n co_occ: int = 0,\n target_collection: List[str] = Query([]),\n):\n database = get_db()\n query_graph_result =...
[ "0.6007912", "0.59982365", "0.5962933", "0.5850433", "0.5817421", "0.57249165", "0.57078034", "0.568576", "0.5582051", "0.55256677", "0.55047196", "0.54700655", "0.54588395", "0.54585487", "0.5439813", "0.5436548", "0.54200363", "0.54097277", "0.5380385", "0.5369311", "0.5364...
0.6569553
0
adding assertion test to this class
def assertDataframeEqual(self, df1, df2, msg='Dataframes are NOT equal'): try: pandas.testing.assert_frame_equal(df1, df2) except AssertionError as e: raise self.failureException(msg) from e
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assertion_passed(self, func):", "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def _Assert(self, t):\n self.RaiseError(t, \"Assert not supported\")", "def test_assert_truth(self):\n\n # Confused? This video should help:\n ...
[ "0.7113474", "0.7074918", "0.7074918", "0.7074918", "0.7074918", "0.7074918", "0.7011479", "0.6953643", "0.69323", "0.6802398", "0.67889684", "0.67889684", "0.67889684", "0.6664128", "0.6663575", "0.66216046", "0.6594647", "0.65849733", "0.6583794", "0.6566348", "0.6565654", ...
0.0
-1
dropping table at the end of all tests
def tearDownClass(cls): cls.database_connection.connect() cls.database_connection.clear_table('''DROP TABLE ''' + table_name) cls.database_connection.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.database.truncate_all_tables()", "def tearDown(self):\n drop_all_tables()\n create_all()", "def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.s...
[ "0.7847522", "0.77294594", "0.76650023", "0.76413673", "0.76413673", "0.76196283", "0.7617512", "0.7613479", "0.7605289", "0.7605084", "0.7603006", "0.7583381", "0.7562543", "0.7504366", "0.7504366", "0.7504366", "0.7504366", "0.7504366", "0.7504366", "0.7504366", "0.7504366"...
0.738027
35
creating a duplicate dataframe for testing
def get_equal_dataframe() -> pandas.DataFrame: data = { 'InvoiceDate': ['2009-01', '2012-01'], 'Count': [4, 4], 'Total': [8198.79, 5323.15] } return pandas.DataFrame(data, columns=['InvoiceDate', 'Count', 'Total'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_from_dataframe(self):\n self.insert()\n data = self.tbl.select()\n data.index.name = None\n tbl = Table.create(':memory:', \"Foo_2\", data, verbose=True,\n primary_key='id', autoincrement=True)\n self.check(self.idata, tbl.select())", "...
[ "0.7096513", "0.68160087", "0.674574", "0.6648187", "0.6643554", "0.6559037", "0.6534431", "0.6526871", "0.6524183", "0.65222037", "0.6514919", "0.6492036", "0.64886624", "0.6478896", "0.6473863", "0.64581394", "0.64479345", "0.6443508", "0.64392173", "0.64355046", "0.6425424...
0.63564044
24
creating a connection, creating table if needed, reading file, ordering columns, and inserting it
def get_file_reply(file_path: str, file_type: str): database_connection = processing.establish_connection(database_path) processing.create_table_if_not_exist(database_connection, table_name) insert_many_query = processing.get_insert_many_query(table_name) dataframe = None try: if "json" in f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_connection(db_file):\n try:\n conn = sqlite3.connect(db_file)\n cur = conn.cursor()\n\n # Create a new SQLite table\n cur.execute(\"CREATE TABLE {tn} ({r1}, {r2}, {time} {ft})\"\n .format(tn=TABLE_NAME, r1=INPUT_COLUMN, r2=OUTPUT_COLUMN,\n ...
[ "0.69324505", "0.6774582", "0.67507434", "0.6734306", "0.66502136", "0.66429377", "0.66239434", "0.6623156", "0.6599766", "0.6592246", "0.65591776", "0.6539219", "0.65329206", "0.65138304", "0.64928627", "0.64893234", "0.6469165", "0.6468972", "0.6460597", "0.64557076", "0.64...
0.0
-1
creating a connection, extracting from database and getting dataframe, and after working it, returning merged dataframe
def get_dataframe() -> pandas.DataFrame: database_connection = processing.establish_connection(database_path) dataframe = database_connection.to_dataframe(['CustomerId', 'InvoiceDate', 'Total'], table_name) database_connection.close() dataframe = processing.get_invoice_date_fixed(dataframe) analyze_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dataframe(connection: sqlite3.Connection) -> pd.DataFrame:\n dataframe = pd.read_sql_query(f\"\"\"\n SELECT\n combined_jobs.id, combined_jobs.company, combined_jobs.link, combined_jobs.location,\n combined_jobs.date, combined_jobs.content, combined_jobs.title, location_ca...
[ "0.71510464", "0.6742855", "0.67427015", "0.672365", "0.6603794", "0.6562777", "0.6477388", "0.6425082", "0.6340942", "0.6312744", "0.6285037", "0.6247587", "0.6245854", "0.6236883", "0.6234288", "0.6230843", "0.619917", "0.613783", "0.6135698", "0.612881", "0.61173105", "0...
0.6164279
17
inserting good data into the database prior to dataframe request
def insert_good_data(): get_file_reply(files[0][0], files[0][1]) get_file_reply(files[1][0], files[1][1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_inserted_data(client):\n data = pd.read_csv(\"housing.csv\")\n data = format_data_housing(data)\n House.insert_from_pd(data)\n houses: DataFrame = pd.read_sql(\"SELECT * FROM house\", db.engine)\n assert len(houses) == data.shape[0]\n houses = house_results_to_dataframe(houses)\n asse...
[ "0.678737", "0.6730259", "0.67274314", "0.66890144", "0.66151464", "0.6559837", "0.64792013", "0.6421191", "0.6408326", "0.63489366", "0.63218206", "0.6304754", "0.6295192", "0.6289917", "0.6281531", "0.6279984", "0.6276843", "0.6270269", "0.6228473", "0.621875", "0.61913466"...
0.0
-1
inserting bad data into the database prior to dataframe request
def insert_bad_data(): get_file_reply(files[2][0], files[2][1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addMissingData():\n\n conn = sqlite3.connect(\"./transactions.db\")\n\n person = pd.read_sql(\n \"\"\"\n select * from person;\n \"\"\",\n conn,\n )\n\n record = pd.read_sql(\n \"\"\"\n select * from record;\n \"\"\",\n conn,\n )\n\n tracked = set([_id ...
[ "0.66893804", "0.6497551", "0.6349632", "0.6349105", "0.6324138", "0.61940855", "0.61221445", "0.6109089", "0.6084575", "0.6075451", "0.606424", "0.6051254", "0.59059036", "0.58634156", "0.58618003", "0.5821349", "0.5786034", "0.5778522", "0.5776547", "0.5775964", "0.5763927"...
0.0
-1
clearing the table and inserting the 'bad' data
def get_alter_dataframe(database_connection: DatabaseHandler) -> pandas.DataFrame: # clearing for bad insertion database_connection.clear_table('''DELETE FROM ''' + table_name) insert_bad_data() return get_dataframe()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_cleaning():\n conn = get_connect()\n conn.execute(\"DELETE FROM championMatchData WHERE kills < 2 AND deaths < 2 AND assists < 2\")\n conn.commit()\n conn.close()\n return", "def cleanup(self) -> None:\n self.min_insert_size = -1 # ensure everything gets flushed\n self.inser...
[ "0.6611473", "0.6526312", "0.6474836", "0.6459992", "0.6391733", "0.63897455", "0.63642263", "0.6357135", "0.6306425", "0.6286085", "0.6278254", "0.62574065", "0.60844815", "0.607679", "0.60704106", "0.60607165", "0.60444313", "0.6043645", "0.60232717", "0.6022161", "0.599655...
0.0
-1
computes fraction of poi with give messages type and total of that message type
def computeFraction(poi_messages, all_messages): fraction = 0. if all_messages != "NaN": fraction = float(poi_messages)/float(all_messages) else: fraction = 0 return fraction
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def computeFraction( poi_messages, all_messages ):\n\n\n ### you fill in this code, so that it returns either\n ### the fraction of all messages to this person that come from POIs\n ### or\n ### the fraction of all messages from this person that are sent to POIs\n ### the same code can b...
[ "0.7224581", "0.7168596", "0.7146333", "0.7096382", "0.7049188", "0.6986391", "0.69323903", "0.6917504", "0.6886109", "0.60604805", "0.5660145", "0.5508525", "0.5426048", "0.53619677", "0.53383446", "0.5319203", "0.5312553", "0.5309126", "0.5298099", "0.52928567", "0.52516794...
0.7001343
5
Attempt to coerce `val` into a numeric type, or a string stripped of whitespace.
def cast(val): for func in [int, float, lambda x: x.strip(), lambda x: x]: try: return func(val) except ValueError: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_int_or_float(val):\n if type(val) == str:\n ret_val = float(val) if '.' in val else int(val)\n return ret_val\n return val", "def parse_numeric(val):\n try: return int(val)\n except: pass\n\n try: return float(val)\n except: pass\n\n return val", "def _convert_val_to_n...
[ "0.73402566", "0.7304908", "0.70569414", "0.6962173", "0.6891436", "0.685007", "0.6784463", "0.66131794", "0.6608134", "0.6539546", "0.6484636", "0.64712876", "0.6459049", "0.6445312", "0.63889277", "0.63889277", "0.63718385", "0.6369737", "0.63425106", "0.6337671", "0.629779...
0.6828669
6
Create a (potentially existing) directory without errors. Raise OSError if directory can't be created. If clobber is True, remove dirpath if it exists.
def mkdir(dirpath, clobber=False): if clobber: shutil.rmtree(dirpath, ignore_errors=True) try: os.mkdir(dirpath) except OSError: pass if not path.exists(dirpath): raise OSError('Failed to create %s' % dirpath) return dirpath
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makedirectory(path):\n\n exist_ok = True\n if not exist_ok and os.path.isdir(path):\n with contextlib.suppress(OSError):\n Path.mkdir(path, parents=True)", "def mkDir(path):\n if not os.path.exists(path):\n try:\n os.makedirs(path)\n except OSError:\n ...
[ "0.7061584", "0.70569605", "0.70226943", "0.7006338", "0.699954", "0.6977039", "0.6966338", "0.6966338", "0.6966338", "0.6966338", "0.69507277", "0.6921338", "0.68780476", "0.68686837", "0.6837868", "0.6795552", "0.67695946", "0.67676157", "0.67505884", "0.6743762", "0.672953...
0.85963845
0
Copy fname from package data to outdir/subdir (creating dir if necessary), and return the path to the copy of fname relative to outdir.
def make_local_copy(outdir, subdir, fname): destdir = path.join(outdir, subdir) mkdir(destdir) shutil.copyfile(package_data(fname), path.join(destdir, fname)) return path.join(subdir, fname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def package_dest_path(self, package):\n\n if self.destdir is None:\n return self.package_final_path(package)\n else:\n return os.path.join(\n self.destdir,\n self.package_install_space(package).lstrip(os.sep))", "def create_file_path(fname, direc=...
[ "0.62651706", "0.6082093", "0.60650736", "0.6050992", "0.5938889", "0.58145124", "0.5783093", "0.5764241", "0.57486904", "0.57103425", "0.57036674", "0.5678299", "0.56111586", "0.56056064", "0.5599549", "0.5561045", "0.5521641", "0.54854083", "0.5484105", "0.5466086", "0.5459...
0.7523176
0
Produce a string with date and time information for a report
def timestamp_now(): return datetime.now().strftime("%A, %B %d, %Y, %I:%M %p")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _printable(self):\n toPrint = \"Time Info header. \"\n toPrint += \"timestamp: \" + str(self.datetime) + \" \"\n\n return toPrint", "def get_time_string(self):\n return f\"{self.year} {self.month:02} \" \\\n f\"{self.start_day:02} {self.start_hour:02} 00 {self.get_durat...
[ "0.6874049", "0.6570977", "0.6555926", "0.6487434", "0.6411186", "0.64016986", "0.6372366", "0.6368585", "0.6361905", "0.6336149", "0.621202", "0.62100637", "0.6179392", "0.61576116", "0.6127666", "0.61024475", "0.60803306", "0.60774654", "0.6076919", "0.60626364", "0.6061876...
0.0
-1
Given a course code, requests the correspnding course page
def get_coursepage(code): url = 'http://gla.ac.uk/coursecatalogue/course/?code=' + code print url coursepage = requests.get(url) return coursepage
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_course_page(self):\n\n print(\"Course URL: {}\".format(self.course_url))\n try:\n self.course_page = BeautifulSoup(requests.get(self.course_url).text, \"lxml\")\n except requests.ConnectionError as e:\n print(\"Error Connecting!\\n\", e)\n sys.exit(1)\n...
[ "0.7398104", "0.6673765", "0.66678524", "0.64198714", "0.6413772", "0.63720846", "0.6232175", "0.61700314", "0.6150578", "0.6142026", "0.61378634", "0.60246366", "0.6009835", "0.5975768", "0.5974896", "0.59581447", "0.5909168", "0.58898294", "0.58715636", "0.5865942", "0.5853...
0.857764
0
Given a course code, requests the corresponding page and returns only the name of that course. This is used to generate a list of courses which I have opted to disclude with only their course codes
def get_course_title_only(code): coursepage = get_coursepage(code) soup = BeautifulSoup(coursepage.content, 'lxml') title = [soup.find_all('h1')[2].string][0] return title
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_coursepage(code):\n url = 'http://gla.ac.uk/coursecatalogue/course/?code=' + code\n print url\n coursepage = requests.get(url)\n return coursepage", "def get_course_page(self):\n\n print(\"Course URL: {}\".format(self.course_url))\n try:\n self.course_page = Beautiful...
[ "0.7957394", "0.65620685", "0.6373555", "0.6254304", "0.6069474", "0.60259366", "0.6012922", "0.6005837", "0.58794546", "0.585379", "0.5835477", "0.5812423", "0.5765354", "0.57308453", "0.56890464", "0.5684061", "0.5674316", "0.5661891", "0.56544876", "0.5581465", "0.5581465"...
0.65289664
2
Creates a dictionary with a headingvalue pair, which is the structure of all the sections in the courses dictionary
def new_dict(heading, value): value = value.replace('%', '\%').replace('&', '\&').replace(u'\xa0', ' ') # Currently encoding is causeing me problems - the quick fix below removes # all the characters that have broken the code so far. This solution is not # likely to work if more courses were added v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _section_course_info(course_key, access):\r\n course = get_course_by_id(course_key, depth=None)\r\n\r\n section_data = {\r\n 'section_key': 'course_info',\r\n 'section_display_name': _('Course Info'),\r\n 'access': access,\r\n 'course_id': course_key,\r\n 'course_displa...
[ "0.7070789", "0.60182756", "0.6016982", "0.5990312", "0.5969372", "0.59540147", "0.59495693", "0.59283185", "0.58511907", "0.58379775", "0.58187705", "0.5808631", "0.5805773", "0.58040214", "0.5761286", "0.57347447", "0.5731346", "0.5700729", "0.5679609", "0.5641057", "0.5584...
0.64286023
1
Each course page has a small info section at the beginning, which I had to extract and formulate in a different way to the main sections. This function constructs the dictionary entries for he course when given a string with all the details required for the info section
def get_info_list(info_string, course): info_list = [] split_on_newline = info_string.split("\n") for elem in split_on_newline: split = elem.split(": ") for s in split: info_list.append(s) info_list = info_list[1:-1] info_tags = [ 'session', 'school', 'credits', '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _section_course_info(course_key, access):\r\n course = get_course_by_id(course_key, depth=None)\r\n\r\n section_data = {\r\n 'section_key': 'course_info',\r\n 'section_display_name': _('Course Info'),\r\n 'access': access,\r\n 'course_id': course_key,\r\n 'course_displa...
[ "0.698141", "0.6433248", "0.61811566", "0.608286", "0.6082416", "0.6056426", "0.6050662", "0.6001302", "0.5982004", "0.59207666", "0.58908296", "0.5850639", "0.5830395", "0.5818191", "0.5790374", "0.577954", "0.57718724", "0.5770274", "0.57416594", "0.57249576", "0.57086146",...
0.7118217
0
Given a course page, takes the context and parses it to extract all the useful information and construct a dictionary with the information corresponding to assigned names ready to be written into the TeX file
def bsoup(coursepage): soup = BeautifulSoup(coursepage.content, 'lxml') h1 = soup.find_all('h1')[2] html = h1.find_next_siblings() all_strings = [h1.string] for div in html: try: text = div.get_text() except: text = div.string if text is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __title_context_dict(data):\n d = {}\n if isinstance(data, str):\n raw_data = __load_data(data)['data']\n else:\n raw_data = data['data']\n for i in range(len(raw_data)):\n title = raw_data[i]['title']\n paragraphs = raw_data[i]['paragraphs']\n text = []\n ...
[ "0.56877637", "0.56606907", "0.5630893", "0.53998905", "0.53966093", "0.5361915", "0.5360787", "0.5359631", "0.5314254", "0.52851605", "0.5281027", "0.5259862", "0.52557594", "0.52467847", "0.5240469", "0.5206612", "0.5163807", "0.5151245", "0.51210815", "0.5102797", "0.51018...
0.52513224
13
Given a list of course codes, ge5t their corresponding titles and format them in a bulletted TeX list. This is used to indicate in the abstract which courses have been deliberately discluded from the document
def create_not_included_list(codes): string = '\\begin{itemize}\n' for code in codes: title = get_course_title_only(code) string += '\\item{' + title + '}\n' string += '\\end{itemize}\n' return string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_to_latex(codelist, unwanted_courses):\n # TODO: investigate a way to add large amounts of text outside of the\n # function\n abstract01 = \"I created this document to practice parsing html and using\\\n tools like Beautiful Soup which I've previously had little experience\\\n in. A...
[ "0.61776614", "0.61535215", "0.5460157", "0.53928626", "0.5347271", "0.5328471", "0.5140035", "0.5117348", "0.51146877", "0.5056962", "0.5048898", "0.50328934", "0.50134706", "0.50019485", "0.49917555", "0.49796224", "0.49568665", "0.4950176", "0.49257633", "0.49147525", "0.4...
0.66535985
0
Constructs the entire TeX document from all the courses with key document details (like author and table of contents)
def write_to_latex(codelist, unwanted_courses): # TODO: investigate a way to add large amounts of text outside of the # function abstract01 = "I created this document to practice parsing html and using\ tools like Beautiful Soup which I've previously had little experience\ in. As a result, i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess_courses_corpus():\n soup = None\n with open('courses_corpus.html', 'r') as infile:\n content = infile.read()\n\n soup = BeautifulSoup(content, 'html.parser')\n\n docid = 0\n data = {}\n data['documents'] = []\n\n main_table = soup.find_all(\"div\", attrs={'class': 'course...
[ "0.67228544", "0.64569527", "0.5929274", "0.5925268", "0.5916192", "0.564219", "0.5635638", "0.5593578", "0.55859154", "0.5570419", "0.5569982", "0.55561346", "0.55053335", "0.5473243", "0.5456045", "0.54416245", "0.5440941", "0.5430982", "0.54077095", "0.5400782", "0.5395573...
0.5822862
5
Provides the special treatment that the info section requires
def latex_info(info): return '\\textbf{' + info['heading'] + '} ' + info['value'] + ' \\break\n'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_info(self, info):\r\n pass", "def ExtraInfo(self) -> object:", "def manage_info():", "def _get_information(self):\n pass", "def process_info(self, info):\n return info", "def info() -> None:", "def info(self):", "def info(self):", "def info(self, *args, **kwargs):", "...
[ "0.7103027", "0.69999164", "0.6913003", "0.66993517", "0.6696078", "0.649746", "0.6492575", "0.6492575", "0.6453869", "0.64022076", "0.6401089", "0.6384137", "0.63549614", "0.6325025", "0.6280559", "0.62133276", "0.62043655", "0.6174107", "0.6174107", "0.6089512", "0.6064964"...
0.0
-1
Creates a TeX formatted string for a given subsubsection
def latex_subsection(section): string = '\\subsubsection*{' + section['heading'] + '}\n' string += section['value'] + '\n' return string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sub(string, subscript):\n return string + \"<sub>\" + subscript + \"</sub>\"", "def _build_sub(self) -> str:\n return dedent(\n \"\"\"\n @SP\n M=M-1\n A=M\n D=M\n @SP\n M=M-1\n A=M\n M=M-D\n ...
[ "0.65773475", "0.63128084", "0.62126887", "0.6208371", "0.61632997", "0.6140767", "0.6039124", "0.6012975", "0.5978812", "0.5934507", "0.58059335", "0.5795126", "0.569796", "0.5690162", "0.5618066", "0.5618066", "0.5604984", "0.5596953", "0.5590398", "0.55688125", "0.55626035...
0.75560915
0
Creates a TeX formatted string for a course
def latex_course(course): basic_info_list = [ 'session', 'school', 'credits', 'level', 'offered', 'visiting_students', 'erasmus_students' ] generic_subsection_list = [ 'description', 'timetable', 'requirements_of_entry', 'excluded_courses', 'co_requisites', 'assessment_weight...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tex(unwanted_courses, wanted_courses=None):\n page = requests.get(\n 'http://gla.ac.uk/coursecatalogue/courselist/' +\n '?code=REG30200000&name=School+of+Computing+Science')\n tree = html.fromstring(page.content)\n spans = tree.xpath('//span/text()')\n codes = []\n if wanted...
[ "0.6946371", "0.6540668", "0.63720375", "0.62898386", "0.6107234", "0.6071788", "0.5923579", "0.585324", "0.5844796", "0.58082366", "0.5749922", "0.5556818", "0.54912657", "0.53892386", "0.5379833", "0.53704685", "0.53665537", "0.5356205", "0.53560764", "0.5349088", "0.533566...
0.7629145
0
Creates the TeX document from the Computer Science Course Catalog
def create_tex(unwanted_courses, wanted_courses=None): page = requests.get( 'http://gla.ac.uk/coursecatalogue/courselist/' + '?code=REG30200000&name=School+of+Computing+Science') tree = html.fromstring(page.content) spans = tree.xpath('//span/text()') codes = [] if wanted_courses is ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeCourse( xmlFile, genPath, importPaths, commonFiles, rendererContent=True):\n\ttry:\n\n\t\t# parse the command line\n\t\tConfig.add_option('--verbose', help='Set verbosity to maximum', dest='verbosity', default=0, action='store_const', const=2)\n\t\tConfig.add_option('-v', '--verbosity', help='Set the verbo...
[ "0.6260808", "0.6079598", "0.5850458", "0.5665877", "0.55810404", "0.55767274", "0.5510529", "0.55077094", "0.550131", "0.5462771", "0.53828937", "0.537524", "0.53713846", "0.5369341", "0.533082", "0.52978146", "0.52650625", "0.52579224", "0.5252961", "0.52399004", "0.5219007...
0.64500177
0
Generates a TeX document and then runs the pdflatex command to create a PDF from the TeX
def pdflatex(unwanted_courses): create_tex(unwanted_courses) cmd = ['pdflatex', '-interaction', 'nonstopmode', 'courses.tex'] proc = subprocess.Popen(cmd) proc.communicate() return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pdf():\n env.file_ext = \".pdf\"\n local(\"pandoc {input_files} -o {output_file}{file_ext} -H {preamble_file} --template {template_file} --bibliography={bib_file} --csl={csl_file} -V fontsize=12pt -V papersize=a4paper -V documentclass:report -N --latex-engine=xelatex\".format(**env))", "def compile_lat...
[ "0.7378825", "0.71747476", "0.7139049", "0.70846206", "0.6956496", "0.6915404", "0.69058365", "0.68944186", "0.67462385", "0.66899025", "0.66854495", "0.66612506", "0.65569717", "0.6552778", "0.65360767", "0.64799696", "0.6461581", "0.6451979", "0.6432288", "0.63957024", "0.6...
0.7367564
1
Propagate changes made to models into database schema.
def migrate_db(): Base.metadata.create_all(ENGINE)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate(self):\n\tpass", "def setup_schema(self):\n models.Base.metadata.create_all(self.session.bind)", "def update_model(self):\n pass", "def model_update(self, db):\n db.session.commit()", "def post_migrations(self):", "def update_model(self):\n pass # TODO: Implement ...
[ "0.6670259", "0.6642882", "0.66169477", "0.6522209", "0.6405807", "0.6354266", "0.62821496", "0.6278887", "0.6274175", "0.6015691", "0.59840304", "0.5931382", "0.5882499", "0.58795726", "0.58661336", "0.58658046", "0.5792609", "0.57480407", "0.57398003", "0.57097906", "0.5685...
0.0
-1
Database connection context manager.
def session_scope(expire=True): if not isinstance(expire, bool): raise ValueError(f'Expire attr must be bool. Got {type(expire)}') session = Session() session.expire_on_commit = expire try: yield session session.commit() except: session.rollback() raise f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _db_connection(self):\n pass", "def obtainDatabaseConnection(self):\n\t\tself.databaseConnector = DatabaseConnector()", "def db_session_context(db_name):\n try:\n db = psycopg2.connect(database=db_name)\n yield db\n finally:\n db.close()", "def __enter__(self) -> sqlite3...
[ "0.7842984", "0.77469206", "0.7391354", "0.7299444", "0.7295811", "0.7281722", "0.7276145", "0.7275543", "0.72531223", "0.72529674", "0.72500235", "0.7196104", "0.71822184", "0.71411437", "0.71265644", "0.7103985", "0.70446414", "0.7011069", "0.69964695", "0.6982708", "0.6979...
0.0
-1
Tests http request construction.
def test_search(self): req = http.make_request('http://xxx', 'GET', None, None) self.assertIsNone(req.data) req = http.make_request('http://xxx', 'GET', 'ignored', None) self.assertIsNone(req.data) req = http.make_request('http://xxx', 'DELETE', None, None) self.assertI...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n response = requests.get('http://jsonplaceholder.typicode.com/todos')\n assert response.ok", "def createRequest(test, url, headers=None):\n request = HTTPRequest(url=url)\n if headers: request.headers=headers\n test.record(request, HTTPRequest.getHttpMethodFilter())\n retur...
[ "0.69102174", "0.6897086", "0.67407787", "0.67172885", "0.668804", "0.668527", "0.66408455", "0.66260934", "0.65981567", "0.6573342", "0.65649724", "0.6560071", "0.6523077", "0.651958", "0.65011233", "0.6492675", "0.6482599", "0.64548385", "0.64541405", "0.6449433", "0.644555...
0.65178454
14
Given a sparse matrix, set all pixels in missing (invalid) bins to 0.
def erase_missing(signal, valid_rows, valid_cols, sym_upper=True): if sym_upper and sp.issparse(signal): if np.any(valid_rows != valid_cols): raise ValueError( "Valid rows and columns must be identical with sym_upper=True" ) if signal.shape[0] != signal.shape[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setZeroes(self, matrix: List[List[int]]) -> None:\n m = len(matrix)\n n = len(matrix[0])\n rows = set()\n columns = set()\n for i in range(m):\n for j in range(n):\n if not matrix[i][j]:\n rows.add(i)\n columns.a...
[ "0.69846714", "0.69818574", "0.69084895", "0.68822354", "0.68314415", "0.68032897", "0.6796617", "0.6766385", "0.67445296", "0.6728862", "0.6650272", "0.66448796", "0.66283685", "0.66217226", "0.6617057", "0.6614921", "0.65993714", "0.6568216", "0.6566557", "0.65331614", "0.6...
0.6212842
41
Set the nth diagonal of a symmetric 2D numpy array to a fixed value. Operates in place.
def set_mat_diag(mat, diag=0, val=0): m = mat.shape[0] step = m + 1 start = diag end = m ** 2 - diag * m mat.flat[start:end:step] = val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_diagonal(self, value = 0):\n for d in range(self.size):\n self.write(d, d, value)", "def set_diag(M,d,idx=0):\n n, m = shape_mat(M)\n if idx >= 0:\n for i, di in enumerate( d ):\n M[i][i+idx] = di\n else:\n for i, di in enumerate( d ):\n M[i-...
[ "0.7125442", "0.69381803", "0.66931725", "0.6662349", "0.6404038", "0.6235831", "0.6171781", "0.6152024", "0.60630727", "0.5889371", "0.57974076", "0.5756528", "0.57523865", "0.5675084", "0.5653157", "0.5643824", "0.55920154", "0.5581051", "0.55746204", "0.5569762", "0.554835...
0.6709417
2
Trim an upper triangle sparse matrix so that only the first n diagonals are kept.
def diag_trim(mat, n): if sp.issparse(mat): if mat.format != "csr": raise ValueError("input type must be scipy.sparse.csr_matrix") # Trim diagonals by removing all elements further than n in the # upper triangle trimmed = sp.tril(mat, n, format="csr") trimmed = sp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trim_whitespace(matrix, details, min_gap):\r\n if details == -1:\r\n row = matrix[0, ]\r\n else:\r\n row = matrix[matrix.shape[0] - 1, ]\r\n\r\n min_left = np.argmin(row)\r\n min_right = np.argmin(row[::-1])\r\n\r\n if min_left > min_gap:\r\n ...
[ "0.64127666", "0.58649224", "0.57881296", "0.5781573", "0.5728801", "0.57002896", "0.5696073", "0.568997", "0.5671774", "0.566362", "0.566362", "0.566362", "0.56233585", "0.5622041", "0.5614353", "0.55710584", "0.55435014", "0.5482823", "0.5455417", "0.54416484", "0.54353005"...
0.7814169
0
Computes genomic distance law by averaging over each diagonal in the upper triangle matrix. If a list of detectable bins is provided, pixels in missing bins will be excluded from the averages. A maximum distance can be specified to define how many diagonals should be computed.
def distance_law( matrix, detectable_bins=None, max_dist=None, smooth=True, fun=np.nanmean ): mat_n = matrix.shape[0] if max_dist is None: max_dist = mat_n n_diags = min(mat_n, max_dist + 1) dist = np.zeros(mat_n) if detectable_bins is None: detectable_bins = np.array(range(mat_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_diag(max_lines):\r\n dsum = 1 # sum of diagonals\r\n cpt = 1 # number of lines processed\r\n val = 1 # value of the current place in the square\r\n inc = 0 # the increment between number for one line\r\n \r\n while cpt < max_lines:\r\n cpt += 2\r\n inc += 2\r\n \r\n ...
[ "0.5350398", "0.52518773", "0.5155675", "0.5135908", "0.50542927", "0.502655", "0.5009027", "0.5004774", "0.4977624", "0.49264264", "0.48782477", "0.48724344", "0.4847657", "0.4825151", "0.48010293", "0.4734856", "0.47299528", "0.47192916", "0.47074535", "0.46959183", "0.4675...
0.6471979
0
Returns lists of detectable indices after excluding low interacting bins based on the proportion of zero pixel values in the matrix bins.
def get_detectable_bins(mat, n_mads=3, inter=False): matrix = mat.copy() matrix.eliminate_zeros() def mad(x): return ss.median_abs_deviation(x, nan_policy="omit") if not inter: if matrix.shape[0] != matrix.shape[1]: raise ValueError("Intrachromosomal matrices must be symmetric.") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vir_indices(self):\n indices = []\n for index,item in enumerate(self):\n if item==0:\n indices.append(index)\n return indices", "def get_agent_indices(array):\t\n\tagent_indices = np.argwhere(array != 0)\n\treturn agent_indices", "def pick_nonzero_bin(binning,...
[ "0.6325455", "0.63100487", "0.6245059", "0.6240828", "0.62382156", "0.622966", "0.6220698", "0.62201536", "0.6188076", "0.6029027", "0.59354", "0.5917809", "0.59095675", "0.5891025", "0.5851099", "0.58345515", "0.5804097", "0.5793994", "0.5785157", "0.5784481", "0.5775276", ...
0.57897145
18
Detrends a HiC matrix by the distance law. The input matrix should have been normalised beforehandand.
def detrend( matrix, detectable_bins=None, max_dist=None, smooth=False, fun=np.nanmean, max_val=10, ): matrix = matrix.tocsr() y = distance_law( matrix, detectable_bins=detectable_bins, max_dist=max_dist, smooth=smooth, fun=fun, ) y[np.isna...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def det(A):\n # Section 1: Establish n parameter and copy A\n n = len(A)\n AM = A[:]\n\n # Section 2: Row manipulate A into an upper triangle matrix\n for fd in range(n): # fd stands for focus diagonal\n if AM[fd][fd] == 0:\n AM[fd][fd] = 1.0e-18 # Cheating by adding zero + ~zero...
[ "0.58057857", "0.5708356", "0.5658325", "0.56237066", "0.5622826", "0.5600156", "0.5581219", "0.5456089", "0.54544467", "0.54441947", "0.54128253", "0.53995603", "0.5385993", "0.5369172", "0.53661954", "0.5349746", "0.5349005", "0.5301684", "0.52880996", "0.5278491", "0.52762...
0.515411
32
Z transformation for HiC matrices.
def ztransform(matrix): mat = matrix.copy() mu = np.mean(mat.data) sd = np.std(mat.data) mat.data -= mu mat.data /= sd return mat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self,Zin):\r\n self.Z = np.zeros((self.Nc,))\r\n for ii in range(0,self.Nc):\r\n self.Z[ii] = np.dot(self.W[:,ii],Zin[self.ind[ii,:]])\r\n \r\n return self.Z", "def zoisite():\n\n rho = 3343.\n\n C = np.zeros((6,6), dtype=float)\n C[0,0] = 279.8; ...
[ "0.657526", "0.65030193", "0.6374585", "0.6241165", "0.6134121", "0.6029814", "0.6002619", "0.5971881", "0.59294695", "0.59294695", "0.5912561", "0.59013504", "0.5897728", "0.5878301", "0.5842042", "0.57775015", "0.5770409", "0.5757381", "0.57313776", "0.5728551", "0.5725833"...
0.55584866
36
Compute the sum of matrices bins (i.e. rows or columns) using only the upper triangle, assuming symmetrical matrices.
def sum_mat_bins(mat): # Equivalaent to row or col sum on a full matrix # Note: mat.sum returns a 'matrix' object. A1 extracts the 1D flat array # from the matrix return mat.sum(axis=0).A1 + mat.sum(axis=1).A1 - mat.diagonal(0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row_col_sums(i, b_j, bins, C, n_u):\n s= C[i][i]*n_u[i]*n_u[i]\n for j in range(bins[b_j], bins[b_j+1]):\n if i != j:\n s+= (C[i][j] + C[j][i])*n_u[i]*n_u[j]\n return s", "def block_sum(i, bins, C, n_u):\n s= 0.0\n for j in range(bins[i], bins[i+1]):\n for k in range(b...
[ "0.7041019", "0.6156732", "0.6129798", "0.5976102", "0.59643245", "0.5771837", "0.57445884", "0.5654173", "0.5501301", "0.5317589", "0.5288595", "0.52820784", "0.5261982", "0.5255658", "0.52305037", "0.5229471", "0.52255195", "0.5207664", "0.5206341", "0.5196019", "0.5180939"...
0.7172675
0
Bootstrap sampling of contacts in a sparse HiC map.
def subsample_contacts(M, n_contacts): S = M.data.copy() # Match cell idx to cumulative number of contacts cum_counts = np.cumsum(S) # Total number of contacts to sample tot_contacts = int(cum_counts[-1]) # Sample desired number of contacts from the range(0, n_contacts) array sampled_conta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bootstrap(X):\n return X[np.random.choice(list(range(X.shape[0])), size=X.shape[0]), :]", "def bootstrapping(datasample):\r\n \r\n datasample=df_to_array(datasample)\r\n \r\n boots_indexs=np.random.randint(len(datasample),size=(1,len(datasample)))\r\n \r\n whole_indexs=list(range(len(dat...
[ "0.60307676", "0.5836601", "0.57376236", "0.56982666", "0.5689801", "0.5620543", "0.5541793", "0.5484117", "0.54839253", "0.5435804", "0.54210573", "0.53805405", "0.5368052", "0.5355705", "0.5346038", "0.5340237", "0.5306805", "0.53025925", "0.5296711", "0.5295456", "0.528197...
0.59620684
1
Adds a frame around input mask, given a kernel. The goal of this frame is define margins around the matrix where the kernel will not perform convolution (denoted by 1). If the matrix is upper symmetric, a margin of half the kernel's width is added below the diagonal and a maximum distance from the diagonal above which ...
def frame_missing_mask(mask, kernel_shape, sym_upper=False, max_dist=None): if mask.dtype != bool: raise ValueError("Mask must contain boolean values") if not sp.issparse(mask): raise ValueError("Mask must be a sparse matrix") framed_mask = mask.copy() ms, ns = mask.shape mk, nk = k...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slidekernelthroughdiagonal(kernel, matrix):\n size_kernel = kernel.shape[0]\n size_matrix = matrix.shape[0]\n result = np.zeros([size_matrix])\n for i in range(size_matrix):\n # Calculate zero padding needed\n padding_b = -min(i - int(size_kernel/2), 0)\n padding_a = -min(size_matrix - int(i + siz...
[ "0.56605875", "0.5587884", "0.5477105", "0.5454366", "0.5391526", "0.5310862", "0.52129424", "0.509257", "0.50285244", "0.5000354", "0.49889517", "0.49485168", "0.49176568", "0.48939496", "0.48860693", "0.4881778", "0.4866566", "0.48574573", "0.4845596", "0.48219603", "0.4799...
0.5740741
0
Ensure all elements defined as missing by the mask are set to zero in the signal. If this is not the case, raises an error.
def check_missing_mask(signal, mask): if sp.issparse(mask): # Check if there are nonzero values in the signal reported as missing # by the mask missing_with_signal = np.nonzero( abs(signal[mask.nonzero()[0], mask.nonzero()[1]]) > 0 )[0] if len(missing_with_signal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applymask(self,mask):\n self.spec[mask==0]=np.nan", "def _check_missing_value_mask(self, missing_mask):\n if not missing_mask.any():\n raise ValueError(\"Input matrix is not missing any values\")\n if missing_mask.all():\n raise ValueError(\"Input matrix must have s...
[ "0.7038222", "0.6567302", "0.63071376", "0.6267162", "0.6249988", "0.6000625", "0.5920129", "0.5898875", "0.5888325", "0.5880828", "0.5875885", "0.58599186", "0.5855308", "0.5855247", "0.5853476", "0.5831566", "0.5795374", "0.5774761", "0.5770358", "0.57691586", "0.5761126", ...
0.6792724
1
Given lists of valid rows and columns, generate a sparse matrix mask with missing pixels denoted as 1 and valid pixels as 0. If a max_dist is provided, upper symmetric matrices will only be flagged up to max_dist pixels from the diagonal.
def make_missing_mask( shape, valid_rows, valid_cols, max_dist=None, sym_upper=False ): # Error if the matrix upper symmetric but shape is rectangle or missing # rows and cols are different sm, sn = shape if sym_upper and (sm != sn or len(valid_rows) != len(valid_cols)): raise ValueError("Re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def frame_missing_mask(mask, kernel_shape, sym_upper=False, max_dist=None):\n if mask.dtype != bool:\n raise ValueError(\"Mask must contain boolean values\")\n if not sp.issparse(mask):\n raise ValueError(\"Mask must be a sparse matrix\")\n\n framed_mask = mask.copy()\n ms, ns = mask.shap...
[ "0.5894775", "0.58664924", "0.5579", "0.55251396", "0.545152", "0.53834623", "0.53789914", "0.5377302", "0.53023285", "0.5288333", "0.51945496", "0.51902205", "0.5188426", "0.51522386", "0.5135295", "0.5130921", "0.5122746", "0.51174325", "0.51109743", "0.508941", "0.5082233"...
0.7036244
0
Adds margin of zeros around an input sparse matrix.
def zero_pad_sparse(mat, margin_h, margin_v, fmt="coo"): sm, sn = mat.shape padded_mat = mat.copy() # Up and down margins initialized with zeros and filled as needed margin_h_0 = sp.csr_matrix((sm, margin_h), dtype=mat.dtype) margin_v_0 = sp.csr_matrix((margin_v, sn + 2 * margin_h), dtype=mat.dtype...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _pad_with_zeros(self, X, margin):\n newX = np.zeros((X.shape[0] + 2 * margin, X.shape[1] + 2 * margin, X.shape[2]))\n x_offset = margin\n y_offset = margin\n newX[x_offset:X.shape[0] + x_offset, y_offset:X.shape[1] + y_offset, :] = X\n return newX", "def OffsetSparseMatrix(...
[ "0.6846492", "0.6157045", "0.6157045", "0.6109819", "0.59839016", "0.59775317", "0.59726745", "0.59028137", "0.5901642", "0.5830433", "0.57942516", "0.57754564", "0.5743076", "0.57350683", "0.57294387", "0.57047725", "0.5701384", "0.5644425", "0.5624889", "0.56114304", "0.560...
0.7736398
0
Crop a kernel matrix to target size horizontally and vertically. If the target size is even, the target size is adjusted to the next integer up.
def crop_kernel(kernel, target_size): # Use list for mutability target = [d for d in target_size] adjusted = False for dim in range(len(target)): if not target[dim] % 2: target[dim] += 1 adjusted = True if adjusted: sys.stderr.write( "WARNING: Crop...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crop_to_target(x, target):\n\n if target.ndim==3:\n t_h, t_w = target.shape[1], target.shape[2]\n elif target.ndim==4:\n t_h, t_w = target.shape[2], target.shape[3]\n cr = int((x.shape[2] - t_h) / 2)\n cc = int((x.shape[3] - t_w) / 2)\n x_cropped = x[:, :, cr:cr + t_h, cc:cc + t_w]...
[ "0.657598", "0.62372273", "0.6060326", "0.58836097", "0.56814396", "0.5558945", "0.5557947", "0.55271006", "0.54924375", "0.5463341", "0.54487395", "0.5447843", "0.5445061", "0.544338", "0.54312927", "0.54123294", "0.54112655", "0.5396363", "0.5391804", "0.53821915", "0.53773...
0.78084946
0
Resize a kernel matrix based on the resolution at which it was defined and the signal resolution. E.g. if a kernel matrix was generated for 10kb and the input signal is 20kb, kernel size will be divided by two. If the kernel is enlarged, pixels are interpolated with a spline of degree 1. Alternatively, a resize factor ...
def resize_kernel( kernel, kernel_res=None, signal_res=None, factor=None, min_size=7, quiet=False, ): km, kn = kernel.shape if km != kn: raise ValueError("kernel must be square.") if not (km % 2) or not (kn % 2): raise ValueError("kernel size must be odd.") if fa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shrink_kernel(self, kernel, up_scale):\n up_scale = torch.tensor(up_scale).float()\n # boundary padding based on the scaling law\n pad_in = (torch.ceil(up_scale**2).int())*((kernel.shape[2]-1)//2)\n pad_h = (torch.ceil(up_scale).int())*((kernel.shape[3]-1)//2)\n pad_w = (torc...
[ "0.6673881", "0.64376324", "0.63498217", "0.6145752", "0.60997856", "0.6078737", "0.5899416", "0.5899416", "0.5854729", "0.5854729", "0.580574", "0.58015907", "0.57691246", "0.57011503", "0.56532955", "0.55739254", "0.5490137", "0.5478357", "0.5461603", "0.5452446", "0.529977...
0.7894084
0
Performs truncated SVD on an input kernel, returning the singular vectors necessary to retain a given proportion of information contained in the kernel.
def factorise_kernel(kernel, prop_info=0.999): u, sigma, v = la.svd(kernel) total_info = np.sum(sigma ** 2) # Compute min. number of singular vectors to retain enough info keep_k = np.flatnonzero(np.cumsum(sigma ** 2) > prop_info * total_info)[0] + 1 if keep_k > np.floor(min(kernel.shape) / 2): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def truncated_svd(A,k=None):", "def svd_shrink(X, tau):\n U,s,V = np.linalg.svd(X, full_matrices=False)\n return np.dot(U, np.dot(np.diag(shrink(s, tau)), V))", "def reduce_svd(embeddings, seed=0):\n svd = TruncatedSVD(n_components=2, n_iter=10, random_state=seed)\n return svd.fit_transform(embeddi...
[ "0.7064768", "0.6497113", "0.647693", "0.63251233", "0.6254241", "0.6164676", "0.61603194", "0.60960335", "0.60589564", "0.5987382", "0.59055364", "0.58650464", "0.57826054", "0.57542855", "0.573676", "0.56839186", "0.5663144", "0.5609878", "0.5581168", "0.5574882", "0.557263...
0.6894022
1
Given an array of valid indices, return the corrsesponding array of missing indices.
def valid_to_missing(valid, size): missing = np.ones(size, dtype=bool) try: missing[valid] = False # In case there is no valid index except IndexError: pass missing = np.flatnonzero(missing) return missing
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def non_masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask-1,order='C'))[0]", "def _get_nan_indices(*tensors: Tensor) ->Tensor:\n if len(tensors) == 0:\n raise ValueError('Must pass at least one tensor as argument')\n sentinel = tensors[0]\n nan_idxs = torch.zeros(len(sentinel), dtype=torch...
[ "0.6300259", "0.6108775", "0.6091231", "0.60477185", "0.6002121", "0.5978218", "0.59119964", "0.58613497", "0.58460724", "0.5842929", "0.57560515", "0.5704897", "0.5615569", "0.55952543", "0.55720913", "0.55479383", "0.5543988", "0.55328596", "0.5526036", "0.55213183", "0.547...
0.610664
2
r"""Get absolute path and set attributes.
def _init_before_open(self, read_meth='read', open_as_binary=True, **kwargs): super(FileComm, self)._init_before_open(**kwargs) # Process file class keywords if not hasattr(self, '_fd'): self._fd = None if read_meth not in ['read', 'readline']: raise ValueError("r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_path(self):\n raise NotImplementedError(\"This asset does not support absolute paths\")", "def abspath(self):\n if self.__abspath is None:\n self.__abspath = pbxpath.abspath(self)\n return self.__abspath", "def _get_absolute(self, path: Path) -> Path:\n return pat...
[ "0.68317145", "0.66353893", "0.6506451", "0.6336473", "0.62895834", "0.6220344", "0.6210958", "0.6178998", "0.61444104", "0.6140882", "0.61189973", "0.60873955", "0.604279", "0.60294616", "0.60294616", "0.60211664", "0.6019854", "0.60156524", "0.5973667", "0.59265673", "0.592...
0.0
-1
r"""Method to return a dictionary of testing options for this class.
def get_testing_options(cls, read_meth='read', open_as_binary=True, **kwargs): out = super(FileComm, cls).get_testing_options(**kwargs) out['kwargs']['read_meth'] = read_meth out['kwargs']['open_as_binary'] = open_as_binary if (read_meth == 'read') and isinstance(out['recv'][0], backward...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_testing_options(cls):\n return [{'error': [(1, NotImplementedError)],\n 'kwargs': {'initial_state': {'a': int(1)}}}]", "def get_testing_options(cls, **kwargs):\n msg = ['test', 1.0]\n count = 3\n objects = [msg for _ in range(count)]\n out = {'kwargs': {...
[ "0.79496187", "0.7280603", "0.7255419", "0.70370495", "0.6979806", "0.69656146", "0.6909307", "0.6908418", "0.6870743", "0.68551254", "0.6849841", "0.68234015", "0.6817497", "0.67941236", "0.67408985", "0.6725303", "0.6684944", "0.6684944", "0.6684944", "0.6684944", "0.668494...
0.0
-1
r"""Determine if the necessary libraries are installed for this communication class.
def is_installed(cls, language=None): # Filesystem is implied return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_installed(self):\n return self._system.is_library(os.path.join(self.get_install_path(), \"lib/libG4event\")) or \\\n self._system.is_library(os.path.join(self.get_install_path(), \"lib64/libG4event\"))", "def check_requirements():\n process_output = subprocess.check_output([sys.execu...
[ "0.77119476", "0.7107023", "0.70856094", "0.69626397", "0.69026285", "0.68549293", "0.68545127", "0.6821311", "0.6820046", "0.68049216", "0.6733924", "0.6677433", "0.6667949", "0.6651116", "0.65795135", "0.65275687", "0.6507767", "0.6464986", "0.6459156", "0.6447705", "0.6422...
0.57553107
84
r"""Close a registry entry.
def close_registry_entry(cls, value): out = False if not value.closed: # pragma: debug value.close() out = True return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\n self.__exit__(None, None, None)", "def close(self):\n self.__exit__(None, None, None)", "def close(self):\n \n self.__exit__(None, None, None)\n return", "def __del__(self):\n for key_path_prefix, registry_file in iter(self._registry_files.items()):\n ...
[ "0.62410325", "0.62410325", "0.6005659", "0.6003081", "0.59938776", "0.5955254", "0.592907", "0.58687013", "0.57975334", "0.5778289", "0.5778289", "0.5778289", "0.5778289", "0.5778289", "0.57693046", "0.57626265", "0.5747791", "0.5740424", "0.5720488", "0.5720488", "0.5716972...
0.73456883
0
r"""Initialize communication with new queue.
def new_comm_kwargs(cls, *args, **kwargs): kwargs.setdefault('address', 'file.txt') return args, kwargs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_init(self, queue=None, **kwargs):\n self.queue = queue if queue else Queue()", "def setup_queue(self):\n self.logger.info('declaring queue %s', self.queue)\n if self.otq:\n self._channel.queue_declare(self.on_queue_declareok, self.queue, auto_delete=True)\n else:\n ...
[ "0.74446756", "0.71945274", "0.6970091", "0.6969268", "0.6967559", "0.6944674", "0.6944674", "0.69317365", "0.6866296", "0.67447776", "0.6695959", "0.6673099", "0.6663105", "0.6660289", "0.66565484", "0.66547716", "0.6641651", "0.662688", "0.662688", "0.662688", "0.662688", ...
0.0
-1
r"""Get keyword arguments to initialize communication with opposite comm object.
def opp_comm_kwargs(self): kwargs = super(FileComm, self).opp_comm_kwargs() kwargs['newline'] = self.newline kwargs['open_as_binary'] = self.open_as_binary kwargs['is_series'] = self.is_series return kwargs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_comm_kwargs(cls, *args, **kwargs):\n kwargs.setdefault('address', 'file.txt')\n return args, kwargs", "def driver_kwargs(self):\n out = super(TestCisRpcServer, self).driver_kwargs\n out['comm'] = 'ClientComm'\n return out", "def driver_kwargs(self):\n out = sup...
[ "0.6724078", "0.65556204", "0.64141464", "0.6366962", "0.611054", "0.6110213", "0.60796076", "0.59395605", "0.5830559", "0.58100736", "0.5667532", "0.5665083", "0.5630391", "0.5616168", "0.5616114", "0.5589997", "0.5575281", "0.55713445", "0.5564068", "0.5554116", "0.5552634"...
0.6149904
4
r"""Record the current position in the file/series.
def record_position(self): _rec_pos = self.fd.tell() _rec_ind = self._series_index return _rec_pos, _rec_ind
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_position(self, file_pos, series_index=None):\n if series_index is None:\n series_index = self._series_index\n self.advance_in_series(series_index)\n self.advance_in_file(file_pos)", "def record(self, pos):\n self.lasts += (datetime.now(), pos),\n if len(se...
[ "0.66489357", "0.66329324", "0.6479423", "0.64465714", "0.61586374", "0.61237216", "0.6114697", "0.610729", "0.6095362", "0.60406315", "0.5951866", "0.59466505", "0.5869703", "0.58657867", "0.58627445", "0.58404976", "0.5832795", "0.58294195", "0.5811629", "0.5791412", "0.575...
0.7691817
0