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
Criteria for stopping iteration.
def _stop_iter(self, query_i, n_pool): stop_iter = False n_train = self.X.shape[0] - n_pool # if the pool is empty, always stop if n_pool == 0: stop_iter = True # If we are exceeding the number of papers, stop. if self.n_papers is not None and n_train >= se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop(self):\n return not self.iteration < self.options['max_iters']", "def stopCond(self):\n\t\treturn False", "def should_stop(*criteria):\n\n def helper(trial_id, result):\n return any(criterion(trial_id, result) for criterion in criteria)\n\n return helper", "def stopCondI(self):\n...
[ "0.7423715", "0.7084987", "0.7042681", "0.6928777", "0.6833409", "0.6818014", "0.68119025", "0.6751196", "0.66932696", "0.6586137", "0.64937603", "0.649263", "0.6456829", "0.6421607", "0.641618", "0.64111954", "0.6396138", "0.6380538", "0.6276907", "0.6244494", "0.6212471", ...
0.6846223
4
Get the batch size for the next query.
def _next_n_instances(self): # Could be merged with _stop_iter someday. n_instances = self.n_instances n_pool = self.n_pool() n_instances = min(n_instances, n_pool) if self.n_papers is not None: papers_left = self.n_papers - len(self.train_idx) n_instances = min...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_size(self):\n return self.size", "def get_num_batches(self,batch_size):\r\n \r\n return len(self) // batch_size", "def batch_size(self) -> pulumi.Output[Optional[int]]:\n return pulumi.get(self, \"batch_size\")", "def batch_size(self):\n return self._batch_size", ...
[ "0.81027097", "0.78576046", "0.78571665", "0.7832846", "0.7832846", "0.7832846", "0.7832846", "0.7786923", "0.77270097", "0.75561064", "0.75124234", "0.75124234", "0.75124234", "0.75124234", "0.7439003", "0.74005985", "0.7347365", "0.7278508", "0.7205241", "0.71802837", "0.71...
0.0
-1
Do the systematic review, writing the results to the log file.
def review(self, *args, **kwargs): with open_logger(self.log_file) as logger: self._do_review(logger, *args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_execute_review_7(self):\n review.execute_review(self.alchemist, self.test_dir,\n self.review_test_dir.name,\n s_report=True)\n\n self.assertTrue(self.review_test_dir.is_dir())\n\n summary_report_file = self.review_test_dir.join...
[ "0.61790246", "0.5947005", "0.5930345", "0.58846945", "0.58361524", "0.58097017", "0.5804036", "0.57742125", "0.5749535", "0.57159483", "0.5710579", "0.56914544", "0.5666339", "0.56594294", "0.56581706", "0.56380177", "0.56280166", "0.5621518", "0.5610359", "0.5588208", "0.55...
0.74211633
0
Store the modeling probabilities of the training indices and pool indices.
def log_probabilities(self, logger): if not self.model_trained: return pool_idx = get_pool_idx(self.X, self.train_idx) # Log the probabilities of samples in the pool being included. pred_proba = self.query_kwargs.get('pred_proba', np.array([])) if len(pred_proba) ==...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_model_priors(self):\n if self._alpha_model_priors:\n return self._alpha_model_priors\n # sample the variables from their corresponding distributions\n params = self._get_prior_params()\n self._alpha_model_priors = self._params2probs(params)\n return self._alph...
[ "0.59170127", "0.5789052", "0.57289195", "0.56182903", "0.5610642", "0.55878043", "0.5582896", "0.55705065", "0.5549928", "0.55463755", "0.55449104", "0.5467885", "0.5467032", "0.5466981", "0.5424368", "0.5424073", "0.54098153", "0.540481", "0.5403072", "0.5368679", "0.536290...
0.5727868
3
Query new results. Arguments
def query(self, n_instances): pool_idx = get_pool_idx(self.X, self.train_idx) n_instances = min(n_instances, len(pool_idx)) # If the model is not trained, choose random papers. if not self.model_trained: query_idx, _ = random_sampling( None, X=self.X, pool_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query(self, query):", "def query(self):", "def query(self, **kwargs):", "def getResults():", "def query(self):\n pass", "def query3() :", "def query(self):\r\n raise NotImplementedError", "def make_query(self):", "def handleQuery(self,query):\n results = None\n retur...
[ "0.74949664", "0.7399993", "0.7161957", "0.7090081", "0.70410615", "0.6995077", "0.6984289", "0.6901557", "0.68639374", "0.68178564", "0.67510515", "0.67510515", "0.67510515", "0.67510515", "0.67072624", "0.66799235", "0.6649144", "0.66070473", "0.6582485", "0.6541874", "0.65...
0.0
-1
Classify new papers and update the training indices. It automaticaly updates the logger.
def classify(self, query_idx, inclusions, logger, method=None): query_idx = np.array(query_idx, dtype=np.int) self.y[query_idx] = inclusions query_idx = query_idx[np.isin(query_idx, self.train_idx, invert=True)] self.train_idx = np.append(self.train_idx, query_idx) if method is N...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _post_transform(self):\n # Reclassify strategy post __init__, if needed.\n for (reclassifier, args, kwargs) in self._reclassifiers:\n self.classifier = reclassifier(self.classifier, *args, **kwargs)", "def retrain(self):\n thread = Thread(target=self.trainer.train_classifier)\...
[ "0.62899023", "0.6182903", "0.6178355", "0.6010451", "0.6003386", "0.5865571", "0.58127713", "0.5769165", "0.57532126", "0.5748436", "0.57469964", "0.5731243", "0.5724421", "0.57043916", "0.5671151", "0.565839", "0.565839", "0.56482285", "0.56076175", "0.55607945", "0.5546083...
0.51585597
64
Dump the self object to a pickle fill (using dill). Keras models Cannot be dumped, so they are written to a separate h5 file. The model is briefly popped out of the object to allow the rest to be written to a file. Do not rely on this method for long term storage of the class, since library changes could easily break i...
def save(self, pickle_fp): if isinstance(self.model, KerasClassifier) and self.model_trained: model_fp = os.path.splitext(pickle_fp)[0]+".h5" self.model.model.save(model_fp) current_model = self.model.__dict__.pop("model", None) with open(pickle_fp, "wb") as fp: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumpme(self) :\n fileName = \"./data/oP4_ModelBuilder.dump\"\n with open(fileName,\"wb\") as dumpedFile:\n oPickler = pickle.Pickler(dumpedFile)\n oPickler.dump(self)", "def dump_me(self, fileName=None) :\n if fileName is None :\n fileName = \"./data/oP4_ModelBuilder.du...
[ "0.7791074", "0.7213516", "0.70645314", "0.700601", "0.6976124", "0.6913192", "0.68760085", "0.67957646", "0.6676232", "0.66475046", "0.6638419", "0.66007686", "0.6592473", "0.6590952", "0.65060467", "0.65038276", "0.6476411", "0.64687264", "0.6468542", "0.64482504", "0.64430...
0.72972
1
Create a BaseReview object from a pickle file, and optiona h5 file.
def load(cls, pickle_fp): with open(pickle_fp, "rb") as fp: my_instance = dill.load(fp) try: model_fp = os.path.splitext(pickle_fp)[0]+".h5" current_model = load_model(model_fp) setattr(my_instance.model, "model", current_model) except Exception: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_hdf5_with_structure(file):\n n_classes = 80\n n_boxes = 5\n anchors = [[0.738768, 0.874946], [2.42204, 2.65704], [4.30971, 7.04493], [10.246, 4.59428], [12.6868, 11.8741]]\n\n yolov2 = YOLOv2(n_classes=n_classes, n_boxes=n_boxes)\n chainer.serializers.load_hdf5(file, yolov2)\n model = YO...
[ "0.63541585", "0.6183295", "0.60280734", "0.60085624", "0.5933018", "0.59211874", "0.59164983", "0.5908618", "0.5876573", "0.5753792", "0.5744421", "0.5674579", "0.56636107", "0.5659608", "0.5636618", "0.5631149", "0.56228226", "0.5595656", "0.5590055", "0.558378", "0.5551614...
0.6273821
1
Iterate through given lines iterator (file object or list of lines) and return ngram frequencies. The return value is a dict mapping the length of the ngram to a collections.Counter object of ngram tuple and number of times that ngram occurred. Returned dict includes ngrams of length min_length to max_length.
def count_ngrams(lines, min_length=2, max_length=4): lengths = range(min_length, max_length + 1) ngrams = {length: collections.Counter() for length in lengths} queue = collections.deque(maxlen=max_length) # Helper function to add n-grams at start of current queue to dict def add_queue(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_ngrams(self, lines, min_length=2, max_length=4):\n self.lengths = range(min_length, max_length + 1)\n self.ngrams = {length: collections.Counter() for length in lengths}\n self.queue = collections.deque(maxlen=max_length)", "def count_ngrams(lines, min_length=1, max_length=4):\n ...
[ "0.7684961", "0.76285505", "0.73904157", "0.680265", "0.67729276", "0.67621726", "0.6700955", "0.6661531", "0.66487426", "0.659852", "0.6427865", "0.6388674", "0.63881356", "0.6381354", "0.63468874", "0.63448745", "0.6335181", "0.6334952", "0.63114697", "0.6289899", "0.628243...
0.78236645
0
Print num most common ngrams of each length in ngrams dict.
def print_most_frequent(ngrams, num=10): for n in sorted(ngrams): print('----- {} most common {}-grams -----'.format(num, n)) for gram, count in ngrams[n].most_common(num): print('{0}: {1}'.format(' '.join(gram), count)) print('')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_most_frequent(ngrams, num=10):\n for n in sorted(ngrams):\n print('----- {} most common {}-grams -----'.format(num, n))\n for gram, count in ngrams[n].most_common(num):\n print('{0}: {1}'.format(' '.join(gram), count))\n print('')", "def print_most_frequent(ngrams, nu...
[ "0.7917998", "0.7917998", "0.78814054", "0.6923355", "0.6922116", "0.68079823", "0.6791706", "0.66620773", "0.66228896", "0.66145474", "0.65648675", "0.65646476", "0.65196806", "0.64935213", "0.64934427", "0.6422141", "0.63786787", "0.6375176", "0.63624406", "0.63562405", "0....
0.7915075
2
Gets the loss function corresponding to a given dataset type.
def get_loss_func(args: Namespace) -> nn.Module: if args.dataset_type == 'classification': return nn.BCEWithLogitsLoss(reduction='none') if args.dataset_type == 'regression': return nn.MSELoss(reduction='none') if args.dataset_type == 'multiclass': return nn.CrossEntropyLoss(reduct...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_loss_fn(kind):\n if kind == 'classic':\n loss_fn = classic_gan_losses\n elif kind == 'nonsaturating':\n loss_fn = nonsaturating_gan_losses\n elif kind == 'wasserstein':\n loss_fn = wasserstein_gan_losses\n elif kind == 'hinge':\n loss_fn = hinge_gan_losses\n retur...
[ "0.69792575", "0.66915447", "0.6646129", "0.65072674", "0.6405765", "0.6325996", "0.6304869", "0.6197979", "0.6126718", "0.60966563", "0.6041246", "0.60170287", "0.5949288", "0.59453076", "0.5903173", "0.5843568", "0.5805806", "0.57782596", "0.5755673", "0.5743353", "0.572834...
0.7877732
0
Computes the area under the precisionrecall curve.
def prc_auc(targets: List[int], preds: List[float]) -> float: precision, recall, _ = precision_recall_curve(targets, preds) return auc(recall, precision)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pr_auc_score(precision: list, recall: list) -> float:\n return quadrature_calculator(recall, precision)", "def compute_ap(recall, precision):\r\n # correct AP calculation\r\n # first append sentinel values at the end\r\n mrec = np.concatenate(([0.0], recall, [1.0]))\r\n mpre = np.concatenate((...
[ "0.8208191", "0.79268074", "0.79202956", "0.790217", "0.790217", "0.78619045", "0.7840341", "0.75207496", "0.74233323", "0.7329511", "0.73156524", "0.708228", "0.7062399", "0.7015234", "0.6936933", "0.68373823", "0.6776866", "0.6753741", "0.6667789", "0.6637576", "0.6547334",...
0.67768353
18
Computes the binary cross entropy loss.
def bce(targets: List[int], preds: List[float]) -> float: # Don't use logits because the sigmoid is added in all places except training itself bce_func = nn.BCELoss(reduction='mean') loss = bce_func(target=torch.Tensor(targets), input=torch.Tensor(preds)).item() return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy_loss():\n return nn.CrossEntropyLoss()", "def loss(params: hk.Params, batch, label) -> jnp.ndarray:\r\n logits = net.apply(params, batch)\r\n labels = jax.nn.one_hot(label, n_classes)\r\n\r\n # Cross Entropy Loss\r\n softmax_xent = -jnp.sum(labels * jax.nn.log_sof...
[ "0.7384956", "0.72135675", "0.7202387", "0.71932334", "0.7134016", "0.7110316", "0.7096747", "0.7090291", "0.7071187", "0.70564115", "0.70500225", "0.70351887", "0.70307016", "0.7015496", "0.7005843", "0.69974864", "0.69865453", "0.6962184", "0.69306517", "0.6922937", "0.6922...
0.0
-1
Computes the root mean squared error.
def rmse(targets: List[float], preds: List[float]) -> float: return math.sqrt(mean_squared_error(targets, preds))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_mean_square_value( values ):\n return ma.sqrt(mean_square_value( values ))", "def root_mean_squared_error(y_true, y_pred):\n return sm.mean_squared_error(y_true, y_pred)**0.5", "def calculate_mean_squared_error(self, X, y):\n mserror = 0\n results = self.predict(X)\n \n ...
[ "0.77393866", "0.77087796", "0.7546213", "0.7337281", "0.7269891", "0.72614455", "0.71631855", "0.70493966", "0.70324105", "0.7016762", "0.69637465", "0.69637465", "0.6903186", "0.6900173", "0.6889149", "0.68360126", "0.67661434", "0.6695583", "0.66910034", "0.66206324", "0.6...
0.6070493
79
Computes the mean squared error.
def mse(targets: List[float], preds: List[float]) -> float: return mean_squared_error(targets, preds)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mean_squared_error(self):\n return self.mean_squared_error", "def MeanSqError(self):\r\n\t\treturn self.mse", "def calculate_mean_squared_error(self, X, y):\n mserror = 0\n results = self.predict(X)\n \n mserror = mean_squared_error(results,y)\n #print(error)\n...
[ "0.7910049", "0.786699", "0.7856702", "0.76039386", "0.7533882", "0.75234455", "0.7485703", "0.7363655", "0.7363655", "0.73202103", "0.72061354", "0.71649987", "0.7156808", "0.7155941", "0.71348286", "0.7101078", "0.7057301", "0.7050769", "0.70165884", "0.70116955", "0.700511...
0.6454481
65
Computes the accuracy of a binary prediction task using a given threshold for generating hard predictions. Alternatively, computes accuracy for a multiclass prediction task by picking the largest probability.
def accuracy(targets: List[int], preds: Union[List[float], List[List[float]]], threshold: float = 0.5) -> float: if type(preds[0]) == list: # multiclass hard_preds = [p.index(max(p)) for p in preds] else: hard_preds = [1 if p > threshold else 0 for p in preds] # binary prediction...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accuracy(targets: List[int],\n preds: Union[List[float], List[List[float]]],\n threshold: float = 0.5) -> float:\n if type(preds[0]) == list: # multiclass\n hard_preds = [p.index(max(p)) for p in preds]\n else:\n hard_preds = [1 if p > threshold else 0 for p in pred...
[ "0.7709991", "0.7511051", "0.7276398", "0.70488864", "0.70320666", "0.69131315", "0.6908888", "0.68309194", "0.6726362", "0.67168456", "0.6644039", "0.6570016", "0.64819574", "0.6433799", "0.643102", "0.64011323", "0.6399237", "0.6395455", "0.6382157", "0.63656", "0.63620985"...
0.7749667
0
r""" Gets the metric function corresponding to a given metric name.
def get_metric_func(metric: str) -> Callable[[Union[List[int], List[float]], List[float]], float]: if metric == 'auc': return roc_auc_score if metric == 'prc-auc': return prc_auc if metric == 'rmse': return rmse if metric ==...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_metric(name):\n return metric_name_to_function_mapping[name.lower()]", "def construct_metric_function(metric_name):\n if(metric_name == \"mse\"):\n def metric_function(result, expected):\n return np.mean((result - expected)**2)\n elif(metric_name == \"logmse\"):\n def me...
[ "0.910969", "0.77268726", "0.7667506", "0.7647726", "0.7494643", "0.7159785", "0.713283", "0.71106905", "0.6959369", "0.6953757", "0.69468874", "0.6902535", "0.68461233", "0.67745537", "0.6526225", "0.64843935", "0.648322", "0.6450256", "0.6431166", "0.6429967", "0.6428994", ...
0.6975668
8
Builds a PyTorch Optimizer.
def build_optimizer(model: nn.Module, args: Namespace) -> Optimizer: params = [{'params': model.parameters(), 'lr': args.init_lr, 'weight_decay': 0}] return Adam(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_optimizer(cfg: CfgNode, model: torch.nn.Module) -> torch.optim.Optimizer:\n norm_module_types = (\n torch.nn.BatchNorm1d,\n torch.nn.BatchNorm2d,\n torch.nn.BatchNorm3d,\n torch.nn.SyncBatchNorm,\n # NaiveSyncBatchNorm inherits from BatchNorm2d\n torch.nn.Grou...
[ "0.6598968", "0.6491794", "0.64786536", "0.6437391", "0.63047016", "0.61300355", "0.60748035", "0.6072925", "0.598902", "0.5971825", "0.59371614", "0.5908207", "0.5907911", "0.5886632", "0.5873024", "0.58706564", "0.5867648", "0.58661216", "0.5852822", "0.5833402", "0.579277"...
0.66013163
0
Builds a PyTorch learning rate scheduler.
def build_lr_scheduler(optimizer: Optimizer, args: Namespace, total_epochs: List[int] = None) -> _LRScheduler: # Learning rate scheduler return NoamLR( optimizer=optimizer, warmup_epochs=[args.warmup_epochs], total_epochs=total_epochs or [args.epochs] * args.num_lr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scheduler_creator(optimizer, config):\n return torch.optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.9)", "def make_lr_scheduler(lr: float, final_lr: float, n_epochs: int,\n verbose: int = 1) -> keras.callbacks.LearningRateScheduler:\n schedule = build_schedule(lr, final_...
[ "0.7930454", "0.7270104", "0.72256047", "0.7176108", "0.7084193", "0.70634633", "0.7060095", "0.70600694", "0.7007854", "0.69914424", "0.6941896", "0.6919559", "0.69080704", "0.6861845", "0.6807765", "0.67986774", "0.6795805", "0.6786529", "0.67793083", "0.67793083", "0.67736...
0.7315069
1
Creates a logger with a stream handler and two file handlers. If a logger with that name already exists, simply returns that logger. Otherwise, creates a new logger with a stream handler and two file handlers.
def create_logger(name: str, save_dir: str = None, quiet: bool = False) -> logging.Logger: logger = logging.getLogger(name) if logging.getLogger().hasHandlers(): return logger logger.setLevel(logging.DEBUG) logger.propagate = False # Set logger depending on desired verbosity ch = logg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __setup_logger(name, log_file, level=logging.WARNING, stream=True):\n log_format = logging.Formatter(\"%(asctime)s%(filename)s:%(lineno)-3d %(levelname)s %(message)s\")\n handler = logging.FileHandler(log_file)\n handler.setFormatter(log_format)\n logger = logging.getLogger(name)\n logger.setLev...
[ "0.7125156", "0.7065868", "0.6974587", "0.6957499", "0.6952148", "0.69312686", "0.6926563", "0.6917995", "0.69075334", "0.68784463", "0.6871594", "0.68691444", "0.6823084", "0.6764146", "0.6764044", "0.67270124", "0.6704542", "0.6696608", "0.6681141", "0.6659349", "0.66585976...
0.0
-1
Creates a decorator which wraps a function with a timer that prints the elapsed time.
def timeit(logger_name: str = None) -> Callable[[Callable], Callable]: def timeit_decorator(func: Callable) -> Callable: """ A decorator which wraps a function with a timer that prints the elapsed time. :param func: The function to wrap with the timer. :return: The function wrapped ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timer(func):\n # Define the wrapper function to return\n def wrapper(*args, **kwargs):\n # When wrapper() is called, get the current time\n t_start = time.time()\n # Call the decorated function and store the result.\n result = func(*args, **kwargs)\n # Get the total tim...
[ "0.84483165", "0.8391495", "0.8373669", "0.8339237", "0.8316612", "0.83098954", "0.8305105", "0.82810265", "0.8230387", "0.8219265", "0.82177997", "0.82145774", "0.8152734", "0.8150772", "0.81464463", "0.8136319", "0.8111675", "0.80838996", "0.80740786", "0.8045458", "0.80407...
0.7549364
47
A decorator which wraps a function with a timer that prints the elapsed time.
def timeit_decorator(func: Callable) -> Callable: @wraps(func) def wrap(*args, **kwargs) -> Any: start_time = time() result = func(*args, **kwargs) delta = timedelta(seconds=round(time() - start_time)) info = logging.getLogger(logger_name).info if logger_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timer(func):\n @functools.wraps(func)\n def wrapper_timer(*args, **kwargs):\n start_time = time.perf_counter() # 1\n value = func(*args, **kwargs)\n end_time = time.perf_counter() # 2\n run_time = end_time - start_time # 3\n print(\"Finished %r in %.2f second...
[ "0.8689927", "0.8666836", "0.8623536", "0.8599843", "0.8591458", "0.8586241", "0.85732555", "0.85592", "0.8522706", "0.8495865", "0.84780055", "0.84351856", "0.8411354", "0.8371723", "0.8371062", "0.83656925", "0.8350421", "0.83410996", "0.8325918", "0.8323737", "0.83208853",...
0.82745314
22
Saves indices of train/val/test split as a pickle file.
def save_smiles_splits(data_path: str, save_dir: str, train_data: MoleculeDataset = None, val_data: MoleculeDataset = None, test_data: MoleculeDataset = None, smiles_column: str = None) -> None: makedi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_data_pickle(self, save_full=False):\n self.train.to_pickle('../input/train_mod.pkl')\n self.test.to_pickle('../input/test_mod.pkl')\n if save_full:\n self.train_full.to_pickle('../input/train_full_mod.pkl')", "def save(self):\n self.index.saveIndex(c.index_path('hn...
[ "0.7013285", "0.67831415", "0.6779987", "0.65789247", "0.654272", "0.6487896", "0.64315325", "0.63751334", "0.63432413", "0.6321943", "0.6304024", "0.62897426", "0.6219592", "0.6187037", "0.6165541", "0.6163556", "0.6160431", "0.6127079", "0.61217314", "0.61151314", "0.611184...
0.60685545
23
[load data from bhav csv to redis]
def load_bhav_data_csv(self, filepath: str) -> None: # create redis pipeline pipeline = self.redis.pipeline(transaction=True) pipeline.flushdb() total_items_counter = 0 with open(filepath, "r") as csv_file: csv_dict_reader = csv.DictReader(csv_file) for ro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _from_redis(self):\n\n # OSM ways and nodes tables\n logging.info(\"Loading OSM ways from redis\")\n self._ways = self._gdf_from_redis(self._bbid + \"_ways\", geometry='geometry')\n if self._ways is None:\n raise Exception(\"No ways data found for this bbid, please provid...
[ "0.58576435", "0.5733669", "0.5632679", "0.55542535", "0.55144584", "0.55141103", "0.5494096", "0.54575187", "0.54455847", "0.5430424", "0.5416055", "0.53992265", "0.53853184", "0.5379547", "0.5354384", "0.5348096", "0.5341777", "0.5267653", "0.524234", "0.52345383", "0.52292...
0.7339843
0
Basic class to hold all nodes (EDU, span and multinuc) in structure.py and while importing
def __init__(self, id, left, right, parent, depth, kind, text, relname, relkind): self.id = id self.parent = parent self.left = left self.right = right self.depth = depth self.kind = kind #edu, multinuc or span node self.text = text #text of an edu node; empty for spans/multinucs self.token_count = tex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodes(self):\n assert False, \"Deriving class must implement\"", "def __init__(self):\n self.__rtags = []\n self.__nodedata = []\n self.__ltags = []", "def __init__(self):\n\n self.nodes = {}", "def create_nodes(self):", "def make_node_structure() -> Node:\n\n agri...
[ "0.70108145", "0.6721174", "0.66377604", "0.65262586", "0.65144575", "0.6506719", "0.6456148", "0.6346076", "0.63397604", "0.6275238", "0.62532413", "0.62516546", "0.6242827", "0.6235224", "0.62059623", "0.62059623", "0.61690557", "0.6159077", "0.61546004", "0.61546004", "0.6...
0.6078994
24
Calculate leftmost and rightmost EDU covered by a NODE object. For EDUs this is the number of the EDU itself. For spans and multinucs, the leftmost and rightmost child dominated by the NODE is found recursively.
def get_left_right(node_id, nodes, min_left, max_right, rel_hash): if nodes[node_id].parent != "0" and node_id != "0": parent = nodes[nodes[node_id].parent] if min_left > nodes[node_id].left or min_left == 0: if nodes[node_id].left != 0: min_left = nodes[node_id].left if max_right < nodes[node_id].right o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seek_other_edu_child(nodes, source, exclude, block):\n\n\tif source == \"0\":\n\t\treturn None\n\telse:\n\t\t# Check if this is already an EDU\n\t\tif nodes[source].kind == \"edu\" and source != exclude and source not in block:\n\t\t\treturn source\n\t\t# Loop through children of this node\n\t\tchildren_to_sea...
[ "0.5860568", "0.5693576", "0.5579388", "0.5482322", "0.5477497", "0.54100263", "0.53967714", "0.5380833", "0.53417313", "0.5325051", "0.5318995", "0.53092885", "0.53054154", "0.52957404", "0.5271932", "0.5268153", "0.5241536", "0.52332026", "0.5216023", "0.5214999", "0.520802...
0.0
-1
Calculate graphical nesting depth of a node based on the node list graph. Note that RST parentage without span/multinuc does NOT increase depth.
def get_depth(orig_node, probe_node, nodes): if probe_node.parent != "0": parent = nodes[probe_node.parent] if parent.kind != "edu" and (probe_node.relname == "span" or parent.kind == "multinuc" and probe_node.relkind =="multinuc"): orig_node.depth += 1 orig_node.sortdepth +=1 elif parent.kind == "edu": ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth(self) -> int:\n depth = 0\n node = self\n while node:\n depth += 1\n node = node.parent\n return depth", "def calc_node_depth(depth, node):\n if not isinstance(node, nodes.section):\n return depth - 1\n return calc_node_depth(de...
[ "0.74546146", "0.7447791", "0.69374293", "0.6874434", "0.68480796", "0.6824657", "0.6742659", "0.6724265", "0.6723599", "0.66920894", "0.66682816", "0.6621942", "0.66207385", "0.65966225", "0.6592965", "0.65864", "0.65864", "0.65864", "0.6573537", "0.6548355", "0.65387446", ...
0.70795107
2
Recursive function to find some child of a node which is an EDU and does not have the excluded ID
def seek_other_edu_child(nodes, source, exclude, block): if source == "0": return None else: # Check if this is already an EDU if nodes[source].kind == "edu" and source != exclude and source not in block: return source # Loop through children of this node children_to_search = [child for child in nodes[s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getedunode(tree):\n # Post-order depth-first traversal\n post_nodelist = postorder_DFT(tree, [])\n # EDU list\n edulist = []\n for node in post_nodelist:\n if (node.lnode is None) and (node.rnode is None):\n edulist.append(node)\n return edulist", "def find_child(self, dat...
[ "0.5483303", "0.5378936", "0.5361327", "0.53357214", "0.5319795", "0.5279911", "0.5267122", "0.52607787", "0.523028", "0.5167194", "0.5160421", "0.51143736", "0.50915647", "0.5079196", "0.5073051", "0.506199", "0.5061287", "0.5005479", "0.49868023", "0.49814376", "0.4978803",...
0.68042105
0
add mode to operation with the needed resource for the mode. if it is a new mode number, create it. save the resource in all_resources list.
def add_mode(self, mode_number, resource, start, dur): # save all needed resources for every mode in all_resources dictionary if resource not in self.all_resources: self.all_resources[resource] = [mode_number] else: self.all_resources[resource].append(mode_number) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_resource(self, resource, resource_start, resource_dur):\n self.resources.append(resource)\n resource.add_mode(self.op_number, self.mode_number, resource_start, resource_dur)", "def append(self, mode):\n _logger().log(5, 'adding mode %r', mode.name)\n self._modes[mode.name] = m...
[ "0.66186523", "0.6348235", "0.60964996", "0.6094024", "0.59525174", "0.586816", "0.5593441", "0.558757", "0.5558178", "0.5470928", "0.5463765", "0.53962845", "0.5395574", "0.53228295", "0.52790344", "0.52721536", "0.52546984", "0.5246441", "0.52185845", "0.5198046", "0.519473...
0.8622642
0
return the shortest mode time of this operation
def get_min_tim(self): return self.get_shortest_mode().tim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_shortest_mode(self):\n return min(self.modes, key=lambda mode: mode.tim)", "def get_shortest_process_time_first_solution(self):\n return self._generate_solution_w_processing_time_criteria(lpt=False)", "def mode(self) -> int:", "def time_to_target_training(self) -> str:\r\n # TODO...
[ "0.78087085", "0.62259907", "0.61925405", "0.6189033", "0.57382995", "0.5646981", "0.56381065", "0.56044364", "0.55671227", "0.55077654", "0.5501123", "0.54985255", "0.5491473", "0.54790676", "0.5473112", "0.5470916", "0.5427246", "0.54196316", "0.54119617", "0.53837466", "0....
0.6083795
4
return the shortest mode of this operation
def get_shortest_mode(self): return min(self.modes, key=lambda mode: mode.tim)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mode(self) -> int:", "def mode(self):\n mode = max(self.data, key=self.data.count)\n return mode", "def mode(y):\n if len(y)==0:\n return -1\n else:\n return stats.mode(y.flatten())[0][0]", "def mode(self):\n return self._summarize(lambda c: c.mode)", "def mode(...
[ "0.6880954", "0.6422389", "0.6374043", "0.6300473", "0.6297785", "0.6273692", "0.62567586", "0.61943084", "0.6140916", "0.61289376", "0.6082044", "0.60252184", "0.5934511", "0.59279275", "0.58770746", "0.58483845", "0.58428395", "0.5790417", "0.57883215", "0.5787133", "0.5763...
0.7509745
0
Test that a given password policy is valid according to the first stars' rules.
def test_validate_first_star_policy(policy: str, expected: bool): assert day2.validate_first_star_policy(policy) == expected
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_pwd_policy1(processed):\n policy, letter, pwd = processed\n return pwd.count(letter) in policy", "def check_pwd_policy2(processed):\n policy, letter, pwd = processed\n idx1 = policy[0] - 1\n idx2 = policy[-1] - 1\n return (pwd[idx1] == letter) ^ (pwd[idx2] == letter)", "def test_val...
[ "0.7051201", "0.70007664", "0.69529474", "0.68343574", "0.66242343", "0.6584886", "0.6536774", "0.6471579", "0.64339715", "0.64224905", "0.63708144", "0.6358362", "0.6347376", "0.63193583", "0.6316809", "0.63018954", "0.6277832", "0.6274736", "0.6211703", "0.61495656", "0.613...
0.65974146
5
Test that a given password policy is valid according to the second stars' rules.
def test_validate_second_star_policy(policy: str, expected: bool): assert day2.validate_second_star_policy(policy) == expected
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_pwd_policy2(processed):\n policy, letter, pwd = processed\n idx1 = policy[0] - 1\n idx2 = policy[-1] - 1\n return (pwd[idx1] == letter) ^ (pwd[idx2] == letter)", "def check_pwd_policy1(processed):\n policy, letter, pwd = processed\n return pwd.count(letter) in policy", "def test_che...
[ "0.7291398", "0.69760734", "0.6725762", "0.6681516", "0.6674957", "0.660869", "0.659909", "0.6551593", "0.64916486", "0.64302176", "0.6377811", "0.63685375", "0.6358652", "0.6352963", "0.6323817", "0.62727654", "0.6260491", "0.6254762", "0.6252222", "0.6249409", "0.6229831", ...
0.7226481
1
Validating first star logic.
def test_first_star(): assert day2.first_star("answers/day2.txt") == 536
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_first_star_policy(policy: str, expected: bool):\n assert day2.validate_first_star_policy(policy) == expected", "def test_star_input_edge(self):\n with self.assertRaises(ValidationError):\n Node('a') | '*' * Node('b')", "def validated(x, y, playing_field):\n # user_inpu...
[ "0.62573826", "0.6015902", "0.5841441", "0.58148", "0.5708039", "0.56161535", "0.56038105", "0.5587095", "0.5488158", "0.5458838", "0.5451227", "0.5438884", "0.54214257", "0.54000455", "0.5394055", "0.5387463", "0.5336903", "0.53057957", "0.5302249", "0.5290213", "0.52855545"...
0.594904
2
Validating second star logic.
def test_second_star(): assert day2.second_star("answers/day2.txt") == 558
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_second_star_policy(policy: str, expected: bool):\n assert day2.validate_second_star_policy(policy) == expected", "def second_star():\n contents = read_file('Day5.txt')\n answer = 0\n for line in contents:\n line = line.lower().strip()\n if line:\n if is_nice...
[ "0.621566", "0.58884156", "0.58762884", "0.58503526", "0.5788506", "0.5668393", "0.5585831", "0.5523089", "0.5478568", "0.53456324", "0.53296465", "0.5269895", "0.52459335", "0.52417326", "0.52202207", "0.5220058", "0.5152928", "0.5149961", "0.5147231", "0.51171714", "0.50622...
0.640009
0
Perform watcher file processing.
def process(self, source_path: pathlib.Path) -> bool:
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_inner(self):\n for event in self.inotify.event_gen():\n self.process_inotify_event(event)", "def watch(self):\n wm = pyinotify.WatchManager()\n self.notifier = pyinotify.Notifier(wm, default_proc_fun=self.callback)\n wm.add_watch(self.directory, pyinotify.ALL_EVENTS...
[ "0.70513415", "0.6680843", "0.65420145", "0.6517955", "0.6501063", "0.6454107", "0.6385379", "0.6361445", "0.6250041", "0.6130749", "0.6056197", "0.6050279", "0.6041683", "0.6030061", "0.6027182", "0.602698", "0.60107094", "0.6003464", "0.59958637", "0.5989735", "0.5976158", ...
0.0
-1
matplotlib drawing calculation is placed on the main thread
def __init__(self, my_graph: VehicleRoutingProblemGraph, path_queue: MPQueue): self.my_graph = my_graph self.nodes = my_graph.graph_nodes self.warehouse_index = my_graph.warehouse_index self.figure = plt.figure(figsize=(10, 10)) self.figure_ax = self.figure.add_subplot(1, 1,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _UpdatePlot( self ):\n self._BusyDoOp( self._UpdatePlotImpl )", "def draw(self):\n self.figure.canvas.draw_idle()", "def update_plot():\n pass", "def _draw_plot(self, *args, **kw):\n # Simple compatibility with new-style rendering loop\n return self._draw_component(*args, *...
[ "0.705849", "0.6541566", "0.65349054", "0.6453805", "0.6431387", "0.64163357", "0.6313994", "0.6263978", "0.62334746", "0.6220941", "0.6211828", "0.6152641", "0.6143445", "0.6112018", "0.61107785", "0.6060346", "0.6058377", "0.6058377", "0.6058377", "0.6058377", "0.6058377", ...
0.0
-1
A simple stream that people can go to if they don't want the cover
def show_entries_stream(): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stream():\n while True:\n yield random_point()", "def simple_sink(riter):\n for r in riter:\n pass", "def squares_streaming_get():\n \n return 'do some magic!'", "def _shellntube_streams(ci, hi, co, ho, inside_heating) -> 's_tube, s_shell':\n # Mean temperatures\n ...
[ "0.55892956", "0.5108561", "0.50826603", "0.4991568", "0.49519446", "0.4922918", "0.49007618", "0.48703817", "0.4864487", "0.48634946", "0.48508486", "0.4842412", "0.48410597", "0.48073727", "0.47974712", "0.47949654", "0.47821027", "0.47718576", "0.4714481", "0.47020382", "0...
0.47982118
14
The form for usersubmission
def add(): if request.method == 'GET': return render_template('add.html') elif request.method == 'POST': data = {} for key in ('h', 'name', 'summary', 'content', 'published', 'updated', 'category', 'slug', 'location', 'in-reply-to', 'repost-of', 'syndication'): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_new_user_form():\r\n return render_template('user-form.html')", "def get_form(self, request, obj=None, **kwargs):\n if not request.user.is_superuser:\n self.exclude = ('all_app', 'faculty', 'university')\n return super(EventAdmin, self).get_form(request, obj, **kwargs)", "d...
[ "0.6263477", "0.62467223", "0.6116627", "0.6109392", "0.5984667", "0.5972683", "0.5927222", "0.5920144", "0.5913554", "0.5904998", "0.5902618", "0.58941036", "0.5888082", "0.5873177", "0.58381027", "0.58379877", "0.5808009", "0.5799861", "0.5794488", "0.57927954", "0.5783674"...
0.0
-1
send a facebook mention to brid.gy
def bridgy_facebook(location): r = send_mention( 'http://' + DOMAIN_NAME + '/e/' + location, 'https://brid.gy/publish/facebook', endpoint='https://brid.gy/publish/webmention' ) syndication = r.json() data = get_bare_file('data/' + location.split('/e/')[1]+".md") if data['synd...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mention(cls, user, message, mentioned):\r\n pass", "def mention(cls, user, message, mentioned):\n pass", "def mention(bot, msg):\n\n if msg.command != \"PRIVMSG\":\n return\n\n message = msg.args[1]\n\n if bot.nickname.lower() in message.lower():\n bot.privmsg(msg.sende...
[ "0.73215884", "0.7082053", "0.6940993", "0.6741948", "0.6741948", "0.6630014", "0.6628618", "0.63822174", "0.63569945", "0.6176679", "0.6036334", "0.6035452", "0.6011657", "0.6006672", "0.5999936", "0.59963334", "0.59394795", "0.5885627", "0.58747804", "0.5873047", "0.5867479...
0.700899
2
send a twitter mention to brid.gy
def bridgy_twitter(location): r = send_mention( 'http://' + DOMAIN_NAME +'/e/' + location, 'https://brid.gy/publish/twitter', endpoint='https://brid.gy/publish/webmention' ) location = 'http://' + DOMAIN_NAME +'/e/' + location syndication = r.json() app.logger.info(syndicatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mention(cls, user, message, mentioned):\r\n pass", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_twee...
[ "0.70912", "0.6978928", "0.6978928", "0.6978928", "0.6951119", "0.6886675", "0.68542016", "0.67850006", "0.67706645", "0.67391354", "0.6737515", "0.66903025", "0.66903025", "0.66689706", "0.6652939", "0.66358626", "0.65524536", "0.6468319", "0.6412316", "0.6400552", "0.639498...
0.73339784
0
The form for usersubmission
def edit(year, month, day, name): if request.method == "GET": try: file_name = "data/{year}/{month}/{day}/{name}".format(year=year, month=month, day=day, name=name) entry = get_bare_file(file_name+".md") return render_template('edit_entry.html', entry=entry) excep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_new_user_form():\r\n return render_template('user-form.html')", "def get_form(self, request, obj=None, **kwargs):\n if not request.user.is_superuser:\n self.exclude = ('all_app', 'faculty', 'university')\n return super(EventAdmin, self).get_form(request, obj, **kwargs)", "d...
[ "0.6263477", "0.62467223", "0.6116627", "0.6109392", "0.5984667", "0.5972683", "0.5927222", "0.5920144", "0.5913554", "0.5904998", "0.5902618", "0.58941036", "0.5888082", "0.5873177", "0.58381027", "0.58379877", "0.5808009", "0.5799861", "0.5794488", "0.57927954", "0.5783674"...
0.0
-1
do not useold image fetcher
def image_fetcher_depricated(year, month, day, name): entry = 'data/{year}/{month}/{day}/image/{name}'.format(year=year, month=month, day=day, type=type, name=name) img = open(entry) return send_file(img)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image_url():", "def getimgs():", "def __init__(self, do, token, url, agent):\n super(Image, self).__init__(token, agent)\n self.do = do\n self.uri = \"%s/images\" % url", "def still_image_url(self) -> str:\n\t\treturn 'grab.jpg?oid={0}'.format(self._oid)", "def _collect_img_lin...
[ "0.6818959", "0.6404207", "0.6400739", "0.6391003", "0.63238287", "0.6299582", "0.62419873", "0.6237364", "0.6231113", "0.6231113", "0.6231113", "0.618493", "0.61705214", "0.6151717", "0.61488676", "0.6111828", "0.6104901", "0.610253", "0.60901284", "0.60603756", "0.60417", ...
0.6506369
1
Retruns a specific image
def image_fetcher(year, month, day, name): entry = 'data/{year}/{month}/{day}/{name}'.format(year=year, month=month, day=day, type=type, name=name) img = open(entry) return send_file(img)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image():\n return models.Image.objects.all()[0]", "def image(images):\n return images[0]", "def find_image(image_name):\n imgs = pyrax.images\n image = imgs.list(name=image_name)[0]\n\n # print image.id\n return image.id", "def getimage(self):", "def get_image(name):\r\n re...
[ "0.76873296", "0.765822", "0.7631487", "0.7448282", "0.7415756", "0.74112177", "0.73277974", "0.7296218", "0.7275346", "0.72068703", "0.71624905", "0.7159558", "0.71435326", "0.7122024", "0.70562947", "0.70373076", "0.6992159", "0.6966353", "0.69376457", "0.6932622", "0.69326...
0.0
-1
Get a specific article
def profile(year, month, day, name): # try: file_name = "data/{year}/{month}/{day}/{name}".format(year=year, month=month, day=day, name=name) entry = file_parser(file_name+".md") if os.path.exists(file_name+".jpg"): entry['photo'] = file_name+".jpg" # get the actual file if os.path.exists(f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_article(db:Session, article_id:int):\n return db.query(ArticleModel).filter(ArticleModel.id==article_id).first()", "def get_article_by_id(article_id):\n return Article.query.get(article_id)", "def get_article(self):\n return self.article", "def get(self, request, article_id):\n ...
[ "0.7763395", "0.7667685", "0.7576817", "0.7560458", "0.7468", "0.7383548", "0.7382232", "0.737928", "0.7265432", "0.7253783", "0.7233034", "0.7200886", "0.7132556", "0.7104579", "0.7063947", "0.7048938", "0.6999229", "0.6934305", "0.69313765", "0.6929903", "0.68586516", "0....
0.0
-1
Get all entries with a specific tag
def tag_search(category): entries = [] cur = g.db.execute( """ SELECT entries.location FROM categories INNER JOIN entries ON entries.slug = categories.slug AND entries.published = categories.published WHERE categories.category='{category}' ORDER BY e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self, request, tag=None):\n tags = Tag.objects\n if tag:\n t = tags.get(slug=tag)\n return t.entry_set.all()\n else:\n return tags.all()", "def get_by_tag(cls, tag):\n out = []\n \n tags = Tag.expand_implied_by([tag])\n \n...
[ "0.76238847", "0.7188237", "0.70322627", "0.6862757", "0.6648483", "0.6627843", "0.6623797", "0.6607655", "0.6574117", "0.6476807", "0.64688516", "0.642729", "0.6408273", "0.6354254", "0.6260153", "0.62032044", "0.61752635", "0.61474246", "0.61444974", "0.6141642", "0.6108973...
0.5662253
69
Gets all entries posted during a specific year
def time_search_year(year): entries = [] cur = g.db.execute( """ SELECT entries.location FROM entries WHERE CAST(strftime('%Y',entries.published)AS INT) = {year} ORDER BY entries.published DESC """.format(year=int(year))) for (row,) in cur.fetchall(): if os.p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_year_filtering(self):\n # Get a valid date\n entry = Entry.objects.get(id=1)\n params = {\"year\": entry.publication_date.year}\n\n self._test_filtering(**params)", "def get_year(cls, year):\n try:\n qs = cls.query.get_year(year=year)\n records = ...
[ "0.65764904", "0.6450242", "0.6227139", "0.61741126", "0.6167132", "0.6156517", "0.6050582", "0.59865075", "0.5983737", "0.5917482", "0.59003574", "0.5878821", "0.58784777", "0.58771783", "0.5831988", "0.58086705", "0.5777024", "0.5765258", "0.5722472", "0.5717026", "0.570293...
0.6742848
0
Gets all entries posted during a specific month
def time_search_month(year, month): entries = [] cur = g.db.execute( """ SELECT entries.location FROM entries WHERE CAST(strftime('%Y',entries.published)AS INT) = {year} AND CAST(strftime('%m',entries.published)AS INT) = {month} ORDER BY entries.published DESC """...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_overview(items, month_long):\n events = []\n for item in items:\n dt = datetime.strptime(item['Date'], '%m/%d/%Y')\n if filters.month_l_filter(dt.month) == month_long:\n events.append(item)\n return events", "def events_in_month(request, year, month):\n month = date...
[ "0.6802178", "0.65576446", "0.6284594", "0.61810654", "0.60744697", "0.596643", "0.5957704", "0.59408075", "0.5850851", "0.5822639", "0.58131397", "0.5804216", "0.57973576", "0.57808834", "0.577851", "0.57757276", "0.5738202", "0.5736317", "0.5650376", "0.56443286", "0.562900...
0.6839035
0
Gets all notes posted on a specific day
def time_search(year, month, day): entries = [] cur = g.db.execute( """ SELECT entries.location FROM entries WHERE CAST(strftime('%Y',entries.published)AS INT) = {year} AND CAST(strftime('%m',entries.published)AS INT) = {month} AND CAST(strftime('%d',entries.published)AS ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listNotes() -> list:\n list_of_notes = []\n for note in Note.objects.all():\n list_of_notes.append({\n 'uuid': note.uuid, 'title': note.title,\n 'author': note.author, 'body': note.body, 'created_at': localtime(note.created_at)\n })\n return list_of_notes", "def g...
[ "0.6171667", "0.594842", "0.586288", "0.5821953", "0.5818426", "0.57180774", "0.569837", "0.56322014", "0.5596916", "0.55466056", "0.55430853", "0.5511877", "0.55023056", "0.54997116", "0.54934806", "0.54756266", "0.5472813", "0.5470666", "0.5444636", "0.5443676", "0.54208875...
0.4996292
57
Gets all the articles
def articles(): entries = [] cur = g.db.execute( """ SELECT entries.location FROM categories INNER JOIN entries ON entries.slug = categories.slug AND entries.published = categories.published WHERE categories.category='{category}' ORDER BY entries.pub...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_articles(db:Session):\n return db.query(ArticleModel).all()", "def articles(self):\n return self.get_queryset().filter(content_type__model='article').order_by('-articles__published_at')", "def articles(self):\n return articles.Articles(self)", "def articles(self):\r\n retu...
[ "0.8152243", "0.79722065", "0.7871781", "0.7833883", "0.769121", "0.75862175", "0.75804", "0.7577904", "0.74154687", "0.7402131", "0.7390644", "0.73225033", "0.732051", "0.73135287", "0.7283619", "0.712267", "0.7118482", "0.7115349", "0.70855975", "0.70765924", "0.7034778", ...
0.63388735
51
Solves the Constrained Optimization Problem Given the gradients, compute the alphas for the COP and returns them in a list.
def solve(self, gradients): return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_gradients(self, loss, params):\n # check asserts\n assert isinstance(params, list), '\"params\" should be a list type.'\n \n # compute gradients\n grads = T.grad(loss, params)\n if self.clipnorm is not None:\n grad_l2norm = T.sqrt(sum([T.sum(T.square...
[ "0.59999377", "0.58975494", "0.5767106", "0.56787324", "0.5576172", "0.5534451", "0.55323696", "0.5529321", "0.5500675", "0.54990476", "0.53855956", "0.5367587", "0.5359784", "0.53419304", "0.5329323", "0.5328156", "0.53161484", "0.5316089", "0.5308615", "0.52978164", "0.5271...
0.6094127
0
trend_filter(y, lambda = 0, order = 3) finds the solution of the l1 trend estimation problem minimize (1/2)||yx||^2+lambda||Dx||_1, with variable x, and problem data y and lambda, with lambda >0. D is the second difference matrix, with rows [0... 1 2 1 ...0] and the dual problem minimize (1/2)||D'z||^2y'D'z subject to ...
def trend_filter(y, lambd = 0, order = 3): # PARAMETERS alpha = 0.01 #backtracking linesearch parameter (0,0.5] beta = 0.5 # backtracking linesearch parameter (0,1) mu = 2 # IPM parameter: t update max_iter = 40 # IPM parameter: max iteration of IPM max_ls_iter = 20 # IPM parameter: max ite...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trend_filter(rets_data, lambda_value):\r\n #USING CVXPY convex optimiser\r\n n_periods = rets_data.shape[0]\r\n rets = rets_data.to_numpy()\r\n\r\n D_full = np.diag([1]*n_periods) - np.diag([1]*(n_periods-1), 1)\r\n D = D_full[0:n_periods-1,]\r\n beta = cp.Variable(n_periods)\r\n lambd = c...
[ "0.6355593", "0.5376776", "0.5302288", "0.5244712", "0.5239487", "0.52225435", "0.52082145", "0.5153994", "0.51186603", "0.50843084", "0.50812143", "0.5067192", "0.50605345", "0.5042903", "0.50331384", "0.50325465", "0.5032164", "0.5014226", "0.5008059", "0.50057834", "0.5000...
0.70413655
0
Queryparam has been validated already in viewset.
def get_first_henkilo_id(self, request): first_henkilo_id_query_param = request.query_params.get('first_henkilo_id', None) if first_henkilo_id_query_param: return int(first_henkilo_id_query_param) return Henkilo.objects.order_by('id').first().id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_uncased(request) -> bool:\n return request.param", "def validate_query_parameters(self, request):\n offset = int(request.args.get('offset')) if request and request.args and request.args.get('offset') and int(request.args.get('offset')) >= s.DEFAULT_OFFSET else s.DEFAULT_OFFSET\n limit = int...
[ "0.60713315", "0.60189056", "0.5962308", "0.58810705", "0.58765966", "0.57403684", "0.56542885", "0.5599119", "0.5591286", "0.5568316", "0.5553265", "0.554064", "0.55194914", "0.55155915", "0.5469805", "0.54584163", "0.5457921", "0.5456958", "0.5453995", "0.54387724", "0.5435...
0.0
-1
Queryparam has been validated already in viewset.
def get_middle_henkilo_id(self, request): middle_henkilo_id_query_param = request.query_params.get('middle_henkilo_id', None) if middle_henkilo_id_query_param: return int(middle_henkilo_id_query_param) number_of_henkilot = Henkilo.objects.all().count() return Henkilo.objects....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_uncased(request) -> bool:\n return request.param", "def validate_query_parameters(self, request):\n offset = int(request.args.get('offset')) if request and request.args and request.args.get('offset') and int(request.args.get('offset')) >= s.DEFAULT_OFFSET else s.DEFAULT_OFFSET\n limit = int...
[ "0.60713315", "0.60189056", "0.5962308", "0.58810705", "0.58765966", "0.57403684", "0.56542885", "0.5599119", "0.5591286", "0.5568316", "0.5553265", "0.554064", "0.55194914", "0.55155915", "0.5469805", "0.54584163", "0.5457921", "0.5456958", "0.5453995", "0.54387724", "0.5435...
0.0
-1
Queryparam has been validated already in viewset.
def get_last_henkilo_id(self, request): last_henkilo_id_query_param = request.query_params.get('last_henkilo_id', None) if last_henkilo_id_query_param: return int(last_henkilo_id_query_param) return Henkilo.objects.order_by('id').last().id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_uncased(request) -> bool:\n return request.param", "def validate_query_parameters(self, request):\n offset = int(request.args.get('offset')) if request and request.args and request.args.get('offset') and int(request.args.get('offset')) >= s.DEFAULT_OFFSET else s.DEFAULT_OFFSET\n limit = int...
[ "0.6072184", "0.6019939", "0.5962187", "0.58808744", "0.5878552", "0.57399905", "0.56531805", "0.55975413", "0.55913526", "0.55692446", "0.5553373", "0.5540714", "0.55195963", "0.55180955", "0.5470363", "0.54580545", "0.54577744", "0.54568714", "0.5454361", "0.5438603", "0.54...
0.0
-1
to insult users all day
def random_line(insult_file=None): if insult_file is None: insult_file = os.path.join( os.path.dirname(os.path.dirname(__file__)), "data", "insult.txt" ) with open(insult_file) as file_used: return random.choice(list(file_used))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_users():", "def getInterestedUsers():", "def get_all_new_users_daily(self,bid):\n new_user_1 = self.get_new_users_daily(bid, 1)\n new_user_2 = self.get_new_users_daily(bid, 2)\n new_user_3 = self.get_new_users_daily(bid, 3)\n\n return new_user_1, new_user_2, new_user_3",...
[ "0.6262797", "0.6203186", "0.6154567", "0.6069123", "0.5963024", "0.5952803", "0.5928193", "0.5884175", "0.5874557", "0.5835612", "0.58258915", "0.58171296", "0.58108026", "0.573466", "0.5732753", "0.5732753", "0.57299584", "0.5710283", "0.56925666", "0.567253", "0.565665", ...
0.0
-1
Random selective quotes from file
def random_text(random_file=None): if random_file is None: random_file = os.path.join( os.path.dirname(os.path.dirname(__file__)), "data", "random.txt" ) with open(random_file) as file_used: return random.choice(list(file_used))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random_quote():\n with open (\"./data/quotes.txt\", \"r\") as quotes:\n\n all_quotes = quotes.read().rstrip(\"\\n\").split(\"\\n\\n\")\n\n quote = choice(all_quotes)\n\n return quote", "def random_quote(filename):\n \n quote = random_line(filename)\n \n divided = quote...
[ "0.813469", "0.7787899", "0.6865903", "0.6492678", "0.6473098", "0.64693314", "0.6153933", "0.6134979", "0.61297226", "0.61270857", "0.6110029", "0.587855", "0.5870533", "0.58220625", "0.58119226", "0.57385314", "0.57091135", "0.5683618", "0.56619537", "0.562516", "0.562516",...
0.6737097
3
Handles the submitted form data.
def form_valid(self, form): # Call check_code function on code value result = self.check_code(form.cleaned_data['code']) # Stote the check result in the session self.request.session['result'] = result return super(CheckView, self).form_valid(form)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_submit(self, request: http.Request):\n self._on_form_submit(request)", "def process_form_submit(self, request, form, child, parent=None):\n raise NotImplementedError", "def process_form_submission(self, form):\n return self.lookup_response_class.process_form_submission(self, form)...
[ "0.6974192", "0.6582204", "0.6576746", "0.6523889", "0.6475016", "0.6466408", "0.64635605", "0.63372046", "0.626275", "0.624975", "0.6224416", "0.62055326", "0.6203875", "0.6187705", "0.60232145", "0.6021203", "0.6005187", "0.5974231", "0.59678084", "0.59366876", "0.59298766"...
0.0
-1
Checks the validity of the entered code.
def check_code(self, code): try: # Check if the code is valid voucher = Voucher.objects.get(code=code) # Check if the valid code in not completely redeemed if voucher.still_valid(): message = "Voucher code is valid, your discount = %s" \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def check(self, code):\n await self.bot.reply(self.bot.check_code(code))", "def validatePersonalCode(self):\n\n #ophalen personal Code\n self.__personalCode = self._entryPersonalCode.get()\n\n # Ophalen telegram chat id\n telegramChatCode = self.__combinedHandler.database...
[ "0.67799574", "0.6734154", "0.6695042", "0.6655037", "0.6333351", "0.63087815", "0.62584674", "0.62457037", "0.62156796", "0.6201715", "0.6188982", "0.6172995", "0.608717", "0.60851085", "0.6048696", "0.60325396", "0.60296214", "0.6020803", "0.5997786", "0.5964876", "0.589648...
0.622897
8
This view renders the result page.
def result_view(request): if 'result' in request.session: result = request.session['result'] del request.session['result'] return render(request, 'vouchers/result.html', result) else: return render( request, 'vouchers/result.html', { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result_page():\n results = session.get('results')\n points = 0\n if results:\n for k,p in results.items():\n points += p['points']\n return render_template('results.html', results=results, points=points),", "def view_result_main(request):\n\n\tcontext_dict = {\n\t\t'title': 'All...
[ "0.75926405", "0.7581213", "0.70540375", "0.6948903", "0.6946917", "0.67839175", "0.6779317", "0.6660886", "0.66551244", "0.65993315", "0.65891284", "0.6498301", "0.6479243", "0.64750475", "0.644704", "0.64124334", "0.64058757", "0.6405306", "0.63905185", "0.6385766", "0.6370...
0.6458031
14
load user set to infer
def infer_user(self, user_list): return self._reader_user(user_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_users(self):\n for user_type in self.user_types:\n url_string = \"%s_url\" % user_type\n try:\n url = self.lookup(url_string)\n users = self._fetcher.get_entities(url)\n except AttributeError as ate:\n logger.err(str(ate)...
[ "0.6582234", "0.65506274", "0.6489083", "0.6314274", "0.61091995", "0.6056854", "0.6038887", "0.59855795", "0.59265786", "0.5880454", "0.58561164", "0.58477676", "0.5836678", "0.5781124", "0.5743069", "0.5725334", "0.5697299", "0.5689627", "0.5688545", "0.5686071", "0.5635849...
0.6066042
5
returns an array, user by lesson_id, shows the rating (1, 0, or 1) of each lesson in the db
def get_reviews(self): #TODO implement: #convert self.reviews from sparse matrix to full matrix for all lessons to consider return review_matrix_format(self.reviews)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lessons(course_id, lesson=None):\n lesson_list = []\n if lesson is None:\n lesson_list = Lesson.objects.filter(\n id__in=get_root_lesson_ids(course_id))\n else:\n lesson_list = lesson.get_children()\n result = []\n for lesson_item in lesson_list:\n result.appe...
[ "0.65115535", "0.6501137", "0.61067045", "0.6089912", "0.58528054", "0.58528054", "0.58339953", "0.5827833", "0.5819867", "0.5710632", "0.57026136", "0.56760013", "0.5601005", "0.5598514", "0.55157816", "0.54804313", "0.5399529", "0.5360638", "0.5359145", "0.532016", "0.53066...
0.0
-1
pulls together rec_like and rec_tag
def get_rec(self): #to address cold start problem: checks if user activity is above 5 or so lessons # if yes returns recs based on user2user_similarity # else returns recs based on item2item_similarity pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _preprocess(self, tagged: List[Tuple]) -> Tuple:\n ori = \" \".join([tag[0] for tag in tagged])\n tags = [tag[1] for tag in tagged]\n # Mapping into general tagset\n tags = [self._map[tag] if tag in self._map else \"X\" for tag in tags]\n return \" \".join(tags), ori", "def...
[ "0.55445415", "0.55313987", "0.528904", "0.5221912", "0.52126116", "0.51127034", "0.50930154", "0.49235138", "0.49225008", "0.4895689", "0.48915234", "0.48656592", "0.4856539", "0.48085538", "0.47729358", "0.47710878", "0.47666168", "0.47644943", "0.4742423", "0.47146454", "0...
0.44885886
52
Looks at all tag lists and concats into a matrix outputs
def make_tag_matrix(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_movie_tag_matrix(self):\n data_frame = genre_tag.get_genre_data()\n tag_df = data_frame.reset_index()\n unique_tags = tag_df.tag.unique()\n idf_data = tag_df.groupby(['movieid'])['tag'].apply(set)\n tf_df = tag_df.groupby(['movieid'])['tag'].apply(lambda x: ','.join(x)).r...
[ "0.5701825", "0.5668501", "0.5660716", "0.5623673", "0.5541165", "0.5530826", "0.54011905", "0.5388603", "0.5365625", "0.52665615", "0.5246975", "0.52286", "0.52226275", "0.5177595", "0.5173128", "0.5165793", "0.5156149", "0.5126925", "0.5114938", "0.5112256", "0.50849825", ...
0.67757803
0
This method will be called inside Predictor._build
def init_after_linking_before_calc_loss(self): # Initialize omega as zeros with tf.name_scope('Omega'): for v in self.variables: name = v.name.split(':')[0] + '-omega' shape = v.shape.as_list() shadow = tf.Variable(np.zeros(shape, dtype=np.float32), tra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_predictor(self):\n try: \n predict_fn = tf.contrib.predictor.from_saved_model(self.saved_path)\n except OSError as err: \n print(f\"OSError: {err}\")\n self._predict_fn = predict_fn", "def build(self):\n if self.predictor_constructor is None:\n ...
[ "0.68596494", "0.679768", "0.6660207", "0.6646666", "0.66387475", "0.6568608", "0.6543353", "0.65379524", "0.6514869", "0.63524556", "0.6263757", "0.6244975", "0.6244975", "0.6244975", "0.61311406", "0.61311406", "0.61311406", "0.60836375", "0.60742414", "0.60555977", "0.6050...
0.0
-1
Removes the filename extension
def clean_filename(file): return file.split('.')[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_extension(filename):\n return filename.rsplit('.',1)[-2]", "def filename_strip_ext(filename):\n base = os.path.basename(filename)\n # Strip file extension\n return os.path.splitext(base)[0]", "def clear_ext(x):\r\n return os.path.splitext(os.path.basename(x))[0]", "def remove_extensi...
[ "0.8577537", "0.8402366", "0.82835704", "0.7953714", "0.75720996", "0.74829245", "0.74663013", "0.7405754", "0.7345079", "0.73050994", "0.7301551", "0.7291763", "0.7096758", "0.7093853", "0.7092374", "0.7085213", "0.70423526", "0.70324636", "0.69982874", "0.6982967", "0.69548...
0.7704698
4
Removes the path and returns the python file
def clean_file_path(path): return path.split("/")[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_file(self, path):\n pass", "def remove(path):", "def remove_file(path: str) -> None:\n\tremove(path)", "def _get_path(): # THIS IS JUST FOR GETTING THE FILE\n return os.path.dirname(os.path.abspath(__file__)) + '/'", "def _get_del_file(self):\r\n loc = os.path.dirname(__file__)\r\n...
[ "0.66349816", "0.64937687", "0.63730115", "0.6300892", "0.60541576", "0.6024049", "0.60169226", "0.5997687", "0.59973174", "0.59590966", "0.58958644", "0.5885196", "0.5841729", "0.57928824", "0.5792836", "0.5774065", "0.57645756", "0.57599556", "0.5758383", "0.5725633", "0.56...
0.61143523
4
Puts all imports in a standard format If import is "import a, b, c" then method will put a, b, and c in separate entries. If import is "from a import b" then method will put a.b into the list. This is also true for "from _ as _". Also removes "as _" at the end of imports so there is no ambiguity.
def clean_imports(import_list): mod_lst = [] while import_list: if ',' in import_list[0]: if import_list[0][0:6] == 'import': temp_ = import_list[0][6:].split(',') for i in temp_: import_list.append('import ' + i) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_import_list(self):\n imports = []\n brackets = False\n continue_kw = [\",\", \";\", \"\\n\", ')'] \\\n + list(set(keyword.kwlist) - set(['as']))\n while True:\n defunct = False\n token_type, tok = self.next()\n if tok == '(': # pyt...
[ "0.63375807", "0.6333035", "0.6242245", "0.6186043", "0.6157611", "0.5983975", "0.59371877", "0.584444", "0.5828029", "0.5757452", "0.57384795", "0.5724127", "0.5671354", "0.56650764", "0.56525475", "0.56257075", "0.56121284", "0.5602591", "0.5598451", "0.558749", "0.5533677"...
0.72232276
0
Draw the default networkx graph
def draw_graph_default(graph): nx.draw_networkx(graph, with_labels=True) plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self):\n nx.draw_networkx(self.rc)", "def draw(self):\n\t\tnx_graph = self.parse_graph()\n\t\tpos = nx.spring_layout(nx_graph, k=0.15, iterations=20) # to spread out the nodes\n\n\t\tnx.draw(nx_graph, pos, edge_color=\"black\", width=1, linewidths=1, node_size=500, node_color=\"pink\", alpha=0.9,...
[ "0.7919437", "0.7764581", "0.74634933", "0.7393788", "0.72745425", "0.7213948", "0.71052366", "0.7100083", "0.7098655", "0.7086878", "0.70481366", "0.7043933", "0.7035017", "0.7025723", "0.70026743", "0.69983006", "0.6953662", "0.69463474", "0.6936123", "0.6900292", "0.689664...
0.8451594
0
Gathers all imports that will be nodes for the graph Takes a file as input and from there processes the file so that the output is a list of all the possible nodes as well as their paths. An example of this would be having numpy and linspace as the two nodes in the graph and it would be displayed in the list as numpy.l...
def gather_nodes(filename): # process the file with open(filename) as f: content = f.readlines() # remove any extra whitespace from both ends content = [i.lstrip().rstrip() for i in content] # gather just the import lines all_imports = [line for line in content if line[0:6] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _imports_into_edges(self, filepath):\n edgelist = []\n for imp in self.get_imports(self.sourcepath / filepath):\n internal_file = False\n for _intern in self.internal:\n if imp in _intern:\n imp = _intern\n internal_file =...
[ "0.6789332", "0.6467016", "0.6419514", "0.6361303", "0.62989897", "0.62435204", "0.6131774", "0.6125948", "0.6103109", "0.61010754", "0.606573", "0.6044264", "0.60404086", "0.6021456", "0.5990777", "0.5990201", "0.59765095", "0.5975766", "0.5964688", "0.59557897", "0.5954681"...
0.7581742
0
Shows the subgraph for a larger graph given a node
def find_subgraph(node, graph, draw_graph=True, save_graph=False): try: stack = [node] # the list that stores the nodes result = [] while stack: for i in graph.edges(): if stack[0] == i[0]: result.append(i) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_subgraph(dfs_codes, nsupport, mapper):\n\tglobal __subgraph_count\n\n\tg = build_graph(dfs_codes)\n\tg.id = __subgraph_count\n\t__subgraph_count += 1\n\tg.gprint(nsupport, mapper)", "def subgraph(self, nodes, relabel_nodes=False, output_device=None):\n raise NotImplementedError(\"subgraph is not ...
[ "0.7301972", "0.6598186", "0.63544494", "0.62744796", "0.61380094", "0.61063725", "0.6105426", "0.6053016", "0.60113496", "0.5997531", "0.59646", "0.592048", "0.59149975", "0.5900671", "0.58850497", "0.5816168", "0.58097136", "0.5761132", "0.57183117", "0.5716836", "0.5711385...
0.63512534
3
Initializes all of the solar balloon paramaters from the configuration file
def __init__(self): self.Cp_air0 = config_earth.earth_properties['Cp_air0'] self.Rsp_air = config_earth.earth_properties['Rsp_air'] self.d = config_earth.balloon_properties['d'] self.vol = math.pi*4/3*pow((self.d/2),3) #volume m^3 self.surfArea = math.pi*self.d*self.d #m^2 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n parameters_list = []\n self.config_dict = self.open_config(parameters_list)\n\n # Define defaults\n self.disc_gt = 0.0\n self.disc_out = 0.0", "def initialize_from_config(self):", "def init_paramters(self):\r\n carb_bg_ratio = 5.0\r\n time_...
[ "0.7029802", "0.69844484", "0.6812171", "0.6751648", "0.66976595", "0.6690056", "0.6597369", "0.6546408", "0.6540872", "0.6471854", "0.6458956", "0.64426816", "0.6412605", "0.6407238", "0.6389184", "0.6376305", "0.63616675", "0.6349205", "0.6337389", "0.6309028", "0.62985814"...
0.5736964
85
Solves for the acceleration of the solar balloon after one timestep (dt).
def get_acceleration(self,v,el,T_s,T_i): rad = radiation.Radiation() T_atm = rad.getTemp(el) p_atm = rad.getPressure(el) rho_atm = rad.getDensity(el) g = rad.getGravity(el) rho_int = p_atm/(self.Rsp_air*T_i) # Internal air density Cd = .5 # Drag Coefficient ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compute_solar_torque(self):\n pass", "def _compute_solar_torque(self, curr_date):\n if self._to_add[2]:\n ratio = self.SolarModel.getLightingRatio(self.satPos_i,\n self.in_frame,\n ...
[ "0.649618", "0.6377058", "0.6359698", "0.6304003", "0.6289423", "0.6237533", "0.6192884", "0.61170363", "0.6093549", "0.59930485", "0.59744334", "0.5855127", "0.5833025", "0.581694", "0.58068776", "0.58037525", "0.5798679", "0.577992", "0.5759873", "0.5751409", "0.5731897", ...
0.5282246
89
Calculates the heat lost to the atmosphere due to venting
def get_convection_vent(self,T_i,el): rad = radiation.Radiation() T_atm = rad.getTemp(el) Q_vent = self.mdot*self.Cp_air0*(T_i-T_atm) # Convection due to released air return Q_vent
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_specific_heat() -> float:\n return 1006.0", "def latent_heat_vapourisation(self, tair):\n return (2.501 - 0.00237 * tair) * 1E06", "def heat_vaporization_func(ts):\n heat_vaporization = np.copy(ts).astype(np.float64)\n heat_vaporization -= 273.15\n heat_vaporization *= -0.00236\n ...
[ "0.675507", "0.67306167", "0.66207224", "0.6586132", "0.6439479", "0.6297951", "0.6184606", "0.6020195", "0.60081536", "0.5985208", "0.5977517", "0.5945306", "0.59036654", "0.5817668", "0.5811003", "0.5787394", "0.5785562", "0.5778563", "0.577548", "0.57427275", "0.57321167",...
0.0
-1
This function numerically integrates and solves for the change in Surface Temperature, Internal Temperature, and accelleration after a timestep, dt.
def solveVerticalTrajectory(self,t,T_s,T_i,el,v,coord,alt_sp,v_sp): bal = sphere_balloon.Sphere_Balloon() rad = radiation.Radiation() T_atm = rad.getTemp(el) p_atm = rad.getPressure(el) rho_atm = rad.getDensity(el) rho_int = p_atm/(self.Rsp_air*T_i) tm_air = rh...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def integrate(self, t):", "def integrate(self, dt):\n f = lambda t, y: self.Cm * (np.dot(self.phi, self.activation(y)) + np.dot(self.phi_input, self.activation(self.input)) - self.Gm * y)\n self.Vm = rk4(self.t, self.Vm, self.t + dt, f)", "def integrate(self,u,x,Dt,t,bc):\n time=t[0]\n ...
[ "0.6706245", "0.6486735", "0.6309741", "0.6008843", "0.5961436", "0.59156555", "0.59101975", "0.58531034", "0.5830414", "0.57806593", "0.57762706", "0.57742494", "0.5737409", "0.5728699", "0.5717309", "0.5674229", "0.56673443", "0.56612766", "0.56010914", "0.5593082", "0.5589...
0.0
-1
Creates input list then lowers it and also checks it is only letters >>> create_input_list("Japan, South Africa, pakistan") ["japan", "south africa", "pakistan"]
def create_input_list(prompt): list_countries = input(prompt).split(", ") list_countries = [x.lower() for x in list_countries] return list_countries
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keep_lowercase(str_list):", "def separate_list_input(input_: str) -> List[str]:\n no_commas = input_.replace(\",\", \" \")\n # Each string is naturally unicode, this causes problems with M2Crypto SANs\n # TODO: check if above is still true when M2Crypto is gone ^\n return [str(string) for string ...
[ "0.6320133", "0.6278571", "0.62713885", "0.6207304", "0.6195942", "0.6000138", "0.59812003", "0.57564145", "0.57519066", "0.5724541", "0.57224125", "0.5715764", "0.56915665", "0.56763303", "0.56632733", "0.56419736", "0.5632977", "0.5510618", "0.55077595", "0.55041385", "0.55...
0.7727037
0
Checks that user inputted country is in list of accepted country names. If not, they must retry entering whole list. >>> check_country(["japan", "singapore", "india"]) ['japan', 'singapore', 'india'] >>> check_country(["space", "singapore", "india"]) Please make sure you entered the correct country names
def check_country(input_list): country_list = open("countries.txt").read().splitlines() country_list = [x.lower() for x in country_list] while True: if not all(x in country_list for x in input_list): print("Please make sure you entered the correct country names") input_list...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validateCountry(self, country_name):\n if country_name in self.travel_db.countries:\n return True\n else:\n return False", "def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is T...
[ "0.7024101", "0.62138045", "0.617862", "0.6122707", "0.60352933", "0.6022922", "0.59852684", "0.5973596", "0.58436495", "0.5806124", "0.5785807", "0.56680405", "0.56628275", "0.5576247", "0.5553671", "0.55498075", "0.5516413", "0.54437375", "0.5365109", "0.5342215", "0.533820...
0.80790645
0
Remove all data from the store.
def _flush(self): self._d = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clearStore(self):\n os.remove(self.uid+\".pcl\")\n self.items = []", "def clear(self) -> None:\n self._store.clear()", "def delete_all(self):\n with self.__lock:\n self.__data = dict()\n self.flush()", "def clear(self):\n self._store = {}", "def ...
[ "0.8036393", "0.7998368", "0.76195455", "0.7605767", "0.75947237", "0.75761205", "0.75194293", "0.73634166", "0.73634166", "0.7221763", "0.721937", "0.72149134", "0.72149134", "0.72149134", "0.72045106", "0.72045106", "0.7147735", "0.7115014", "0.70909494", "0.70770454", "0.7...
0.0
-1
Reads size bytes starting at address addr.
def read(self, addr, size): ret = [] while size > 0: block = self._load_block(addr) offset = addr - block.base n_read = self.block_size - offset less = size if size < n_read else n_read end = offset + less addr += n_read ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readfrom_mem(self, addr: int, memaddr: int, *,\n addrsize: int = 8) -> bytes:\n ...", "def read(self, address, size):\n raise NotImplementedError", "def readfrom(self, addr: int, nbytes: int, stop: bool = True, /) -> bytes:", "def readfrom(self, addr: int, nbytes: int, s...
[ "0.6851219", "0.68218774", "0.6637429", "0.6637429", "0.6631976", "0.6631976", "0.6520704", "0.6493475", "0.6399684", "0.63633966", "0.6283843", "0.6088414", "0.5990933", "0.5990505", "0.5987748", "0.58066106", "0.58066106", "0.5712665", "0.56835836", "0.56835836", "0.5652267...
0.6384394
9
Returns the block containing addr. If the block is not present, it calls read on the next level store.
def _load_block(self, addr): ret_block = None tag, set_index, offset = self._decompose(addr) if set_index not in self._d: self._d[set_index] = [] block_list = self._d[set_index] for tag_, block in block_list: if tag == tag_: self._track(a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self, addr: str) -> dict:\n for block in self.__mem:\n if block['address'] == addr:\n return block\n\n return {}", "def getBlock(self, addr: ghidra.program.model.address.Address) -> ghidra.program.model.mem.MemoryBlock:\n ...", "def get_block(self, chunk,...
[ "0.71545273", "0.6975174", "0.66679907", "0.65838784", "0.6459256", "0.634004", "0.633193", "0.63195604", "0.6292701", "0.6288051", "0.6278899", "0.62583405", "0.6253954", "0.6194434", "0.61794126", "0.60847723", "0.6075524", "0.6063847", "0.6043325", "0.6032997", "0.5892681"...
0.76011753
0
Writes the block containing addr.
def _write_block(self, addr, block, direct=True): self._track(addr, read=False) tag, set_index, offset = self._decompose(addr) if set_index not in self._d: self._d[set_index] = [] block_list = self._d[set_index] inserted = False for i, entry in enumerate(bloc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_block_data(self, addr, reg, data):\n raise NotImplementedError()", "def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int:", "def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int:", "def writeto_mem(self, addr: int, memaddr: int, buf: bytes, /, *, addrsize: i...
[ "0.6783767", "0.658146", "0.658146", "0.6315466", "0.6315466", "0.621557", "0.6205037", "0.61565256", "0.61290956", "0.602502", "0.6000028", "0.59711957", "0.58247846", "0.5681205", "0.56791246", "0.566333", "0.5585867", "0.55725205", "0.5468893", "0.5438787", "0.5419565", ...
0.6955682
0
Setup method for Grids REST API. Sets up any database connections or other prerequisites.
def setup(config, *args, **kwargs): cfg_rest = config.get('rest',{}).get('grids',{}) db_cfg = cfg_rest.get('database',{}) # add indexes db = pymongo.MongoClient(**db_cfg).grids if 'grid_id_index' not in db.grids.index_information(): db.grids.create_index('grid_id', name='grid_id_index', uni...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup():\n global connection\n connection = MySQLdb.connect(host=config.get('mysql.host'),\n user=config.get('mysql.user'),\n passwd=config.get('mysql.password'),\n db=config.get('mysql.db'),\n ...
[ "0.69929224", "0.68753135", "0.6732736", "0.6715896", "0.66752124", "0.6565553", "0.64716566", "0.64533854", "0.6439636", "0.64312804", "0.632284", "0.6285714", "0.6282729", "0.62525094", "0.62398857", "0.6237679", "0.6235256", "0.6223723", "0.620033", "0.6194059", "0.6190396...
0.7135885
0
Create a grid entry. Body should contain the grid data.
async def post(self): data = json.loads(self.request.body) # validate first req_fields = { 'host': str, 'queues': dict, # dict of {name: type} 'version': str, # iceprod version } for k in req_fields: if k not in data: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self):\n datagrid_json = self.__as_json()\n response = GsSession.current._post(f'{API}', datagrid_json, request_headers=DATAGRID_HEADERS)\n self.id_ = response['id']\n return response['id']", "def create_grid(\n row_data,\n col_data,\n render,\n header_render=No...
[ "0.63832945", "0.6113222", "0.5987569", "0.5934161", "0.58286816", "0.57821673", "0.5721392", "0.56991607", "0.5548872", "0.5527275", "0.5453448", "0.54232657", "0.5329636", "0.53027296", "0.52848643", "0.52826846", "0.5275693", "0.5272135", "0.5250522", "0.5212492", "0.52014...
0.6047381
2
Get a grid entry.
async def get(self, grid_id): ret = await self.db.grids.find_one({'grid_id':grid_id}, projection={'_id':False}) if not ret: self.send_error(404, reason="Grid not found") else: self.write(ret) self.finish()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getObject(self, row, column, gameGrid=None):\n if not gameGrid:\n gameGrid = self.gameGrid\n return gameGrid.getItem(row, column)", "def get_tile(self, row, col):\n # replace with your code\n return self._grid[row][col]", "def get_tile(self, row, col):\n # repl...
[ "0.67409325", "0.6644148", "0.6644148", "0.6644148", "0.66041654", "0.65990686", "0.65252686", "0.6521284", "0.64955336", "0.64949054", "0.6484982", "0.645304", "0.6406731", "0.6405405", "0.6397506", "0.6296497", "0.6248816", "0.622451", "0.6198434", "0.61945254", "0.6157268"...
0.60561895
31
Update a grid entry. Body should contain the grid data to update. Note that this will perform a merge (not replace).
async def patch(self, grid_id): data = json.loads(self.request.body) if not data: raise tornado.web.HTTPError(400, reason='Missing update data') data['last_update'] = nowstr() ret = await self.db.grids.find_one_and_update({'grid_id':grid_id}, {'$set':data}, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_grid_from_sail_form(self, post_url: str,\n grid_component: Dict[str, Any], new_grid_save_value: Dict[str, Any],\n context: Dict[str, Any], uuid: str,\n context_label: str = None) -> Dict[str, Any]:\n ...
[ "0.67547053", "0.61716086", "0.5904463", "0.5894299", "0.57934475", "0.57144254", "0.5703705", "0.5615451", "0.5613429", "0.55766696", "0.55619353", "0.5559711", "0.5554974", "0.554294", "0.554294", "0.554294", "0.5521593", "0.5515253", "0.55052656", "0.5440518", "0.54231566"...
0.677131
0
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
def problem001(): sum = 0 for i in range(199): i += 1 if i % 3 == 0: continue sum += i*5; for i in range(333): i += 1 sum += i*3 print sum sum = 0 for i in range(999): i += 1 if (i % 3 == 0 or i % 5 == 0): sum += i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_multiples():\n total = 0\n for num in range(1, 1000):\n if (num % 3 == 0) or (num % 5 == 0):\n total += num\n\n print(f'The sum of all the multiples of 3 or 5 below 1000 is {total}')", "def solution(number):\n\n # a is a list with all the numbers below input that are multip...
[ "0.82147884", "0.7788971", "0.7612773", "0.7455339", "0.74550974", "0.74235207", "0.73565894", "0.72924805", "0.72099274", "0.7201937", "0.70250535", "0.69877464", "0.6947098", "0.6837768", "0.679315", "0.6704152", "0.6686552", "0.66411054", "0.65642345", "0.6530224", "0.6527...
0.66348326
18
Removes all columns which are not specified in `keys`.
def Select(*keys): return "Select" >> beam.Map(lambda r: {k: r[k] for k in keys})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Exclude(*keys):\n\n def exclude(row):\n res = dict(row)\n for k in keys:\n if k in res:\n del res[k]\n return res\n\n return \"Exclude\" >> beam.Map(exclude)", "def without_keys(keys):\n keys = frozenset(keys) # frozenset has efficient membership looku...
[ "0.7022799", "0.6966787", "0.68818176", "0.6812999", "0.67250943", "0.6723081", "0.6531266", "0.6515434", "0.6509199", "0.6397996", "0.63302153", "0.6316725", "0.6282017", "0.6246277", "0.61427736", "0.6127576", "0.6122944", "0.6118806", "0.61032057", "0.6085544", "0.6084486"...
0.0
-1
Transforms each element into a tuple of values of the specified columns.
def Project(*keys): return "Project" >> beam.Map(lambda r: tuple(r[k] for k in keys))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _cast_tuple(self, values):\n result = []\n for i, value in enumerate(values):\n if i < len(self.field_types):\n result.append(self._cast_field(self.field_types[i], value))\n else:\n result.append(self._cast_field(self.field_types[-1], value))\n\...
[ "0.65079427", "0.63305724", "0.6140769", "0.5979621", "0.5979621", "0.5976118", "0.59521776", "0.5908647", "0.5847509", "0.58461934", "0.57880825", "0.5767294", "0.5744904", "0.57438934", "0.5733557", "0.57249486", "0.57071495", "0.5699786", "0.5682344", "0.5674965", "0.56714...
0.0
-1
Transforms each element `V` into a tuple `(K, V)`. `K` is the projection of `V` by `keys`, which is equal to the tuple produced by the `Project` transform.
def IndexBy(*keys): return "IndexBy" >> beam.Map(lambda r: (tuple(r[k] for k in keys), r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Project(*keys):\n return \"Project\" >> beam.Map(lambda r: tuple(r[k] for k in keys))", "def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:\n my_tuple = (k, v*v)\n\n return my_tuple", "def to_tuple(self) -> Tuple[Any]:\n return tuple(self[k] for k in self.keys())", "def to_tupl...
[ "0.72535384", "0.53463095", "0.5257933", "0.5257933", "0.5147331", "0.5128732", "0.51225805", "0.50841254", "0.50720644", "0.5030997", "0.5024805", "0.49972284", "0.4976981", "0.49555498", "0.49529418", "0.49438566", "0.49248445", "0.49203864", "0.49174932", "0.49004233", "0....
0.55218637
1
Transforms each element into its JSON representation.
def Stringify(): def s(obj): return json.dumps(obj, default=_decimal_default_proc) return "Stringify" >> beam.Map(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json(self):\n json_data = {}\n\n for item in self.iteritems():\n try:\n value = item.get_value(json_serializable=True)\n except TypeError:\n value = \"NOT_SERIALIZABLE\"\n item_data = {\n \"tags\": list(item.tags),\n ...
[ "0.6305879", "0.62712574", "0.6240611", "0.6213249", "0.6124335", "0.60327363", "0.6011286", "0.6004764", "0.59867555", "0.5962364", "0.59534264", "0.59221894", "0.5912321", "0.5834149", "0.58307153", "0.581057", "0.5806687", "0.5776294", "0.5775614", "0.57222897", "0.5702084...
0.0
-1
Transforms each element `V` into a tuple `(K, V)`. The difference between `IndexBySingle(key)` and `IndexBy(key)` with a single
def IndexBySingle(key): return "IndexBySingle" >> beam.Map(lambda r: (r[key], r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self, x):\r\n return tuple(x)", "def IndexBy(*keys):\n return \"IndexBy\" >> beam.Map(lambda r: (tuple(r[k] for k in keys), r))", "def __getitem__(self, key):\n return tuple(self._mapping[key])", "def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:\n my_tuple = (k, v*v)\...
[ "0.60922354", "0.60166097", "0.57944596", "0.57863474", "0.57379335", "0.57327056", "0.5623573", "0.54659075", "0.5372417", "0.53676397", "0.5335588", "0.5312971", "0.52960134", "0.52922773", "0.52922773", "0.5284726", "0.52737004", "0.52715224", "0.52523285", "0.5218947", "0...
0.64144003
0
Rename columns according to `from_to_key_mapping`.
def RenameFromTo(from_to_key_mapping): def rename(row): res = dict(row) for k1, k2 in from_to_key_mapping.items(): if k1 in res: v = res.pop(k1) res[k2] = v return res return "Rename" >> beam.Map(rename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rename_columns(columns, mapper, keep_original):\n for name, rename in mapper.items():\n if name in columns:\n columns[rename] = org_copy.deepcopy(columns[name])\n if 'parent' in columns[name]:\n parents = columns[name]['pare...
[ "0.6434023", "0.6402961", "0.6393669", "0.60778624", "0.59697354", "0.59653217", "0.59624434", "0.593743", "0.592301", "0.5879087", "0.57664126", "0.5764425", "0.5706599", "0.56312495", "0.5626173", "0.56260186", "0.5605588", "0.5603266", "0.5598767", "0.55849487", "0.5567215...
0.7920267
0
Removes all columns specified in `keys`.
def Exclude(*keys): def exclude(row): res = dict(row) for k in keys: if k in res: del res[k] return res return "Exclude" >> beam.Map(exclude)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_keys(data: dict, keys: list[str]) -> None:\n for k in keys:\n _ = data.pop(k, None)", "def test_remove_columns(self):\n table = Table('table1', key=['col1', 'col2'])[\n Column('col1'),\n Column('col2'),\n Column('col3'),\n Column('col4'),\n ...
[ "0.69095963", "0.67963606", "0.6593253", "0.65468407", "0.64374053", "0.6426602", "0.64252466", "0.638177", "0.6309895", "0.6266435", "0.62295073", "0.6203699", "0.6192911", "0.61525863", "0.61403596", "0.61019945", "0.61008245", "0.6067795", "0.60659325", "0.60348725", "0.60...
0.65369344
4
Filters over an assembly file and gives the IDA pro comments Requires a UTF8 set of strings.
def filter_comments(asm_utf): comments = [] # removes nones a = filter(lambda x: x != None, asm_utf) # splits on comment token comments = [re.split(";", line) for line in a] # takes only those that have a comment token comments = list(filter(lambda x: len(x) > 1, comments)) # strips the ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_process_asm_file(assembly_file):\r\n line_counter = 0\r\n marker_dictionary = load_constants()\r\n commands_list = list()\r\n for command in assembly_file.readlines():\r\n command = command.split(\"/\")[0] # getting rid of comments\r\n command = \"\".join(command.split()) # gett...
[ "0.5961627", "0.56810504", "0.5566075", "0.5412007", "0.54119974", "0.5345376", "0.53153485", "0.52601546", "0.5240575", "0.52389747", "0.5202761", "0.520113", "0.5141318", "0.51237476", "0.5102175", "0.50320864", "0.50298184", "0.5020066", "0.50187165", "0.49976897", "0.4995...
0.66711164
0
Extracts the comments from the file and saves them in the document `doc`
def save_comments(doc): global collection if doc.get('ida_comments', ''): print('Comments already extracted for document [%s], skipping.' % doc['id']) else: print('Saving comments for document [%s].' % doc['id']) asm = open_asm(doc['id']) #asm = [to_ut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_comments(comments_file, output_filename=direc+\"/comments.txt\"):\r\n if not os.path.exists(output_filename.split(\"/\")[0]):\r\n os.makedirs(output_filename.split(\"/\")[0])\r\n\r\n print(\"Extracting comments from \" + comments_file + \"...\")\r\n comments_dict = {}\r\n with open(o...
[ "0.70212615", "0.6491964", "0.6416174", "0.6369594", "0.63566494", "0.6265086", "0.60980767", "0.60809886", "0.59321374", "0.59143645", "0.5802501", "0.57628584", "0.56938124", "0.56853855", "0.5670586", "0.5666101", "0.56338197", "0.5611259", "0.5610039", "0.56060696", "0.55...
0.6811905
1
Saves the comments of the dataset into the database. This one operates based on the files that are in your directory.
def save_local_files(name_file): global collection name_file = name_file.split('.')[0] document = collection.find({'id': name_file}) if document.count() > 0 and document[0].get('ida_comments', ''): print('Comments already extracted for document [%s], skipping.' % document[0]['id']...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_comments(doc):\n global collection\n if doc.get('ida_comments', ''):\n print('Comments already extracted for document [%s], skipping.' %\n doc['id'])\n else:\n print('Saving comments for document [%s].' % doc['id'])\n asm = open_asm(doc['id'])\n ...
[ "0.6435595", "0.6312839", "0.61528647", "0.609396", "0.6069065", "0.59417987", "0.5806655", "0.5718646", "0.5655849", "0.5637166", "0.5607151", "0.55327106", "0.5474431", "0.54364747", "0.5433956", "0.54319423", "0.5426752", "0.54210436", "0.54060376", "0.5382915", "0.5359376...
0.65737236
0
Inserts comments extracted from the asm files into
def main(): global collection #args = argparse.ArgumentParser() #args.add_argument('directory', help='Directory in which the files' #'are stored.') #args.add_argument('collection', help='The collection to use.') #parser = args.parse_args() collection = get_collection() #documents...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def annotate_intermediary(source_basename, content, fout, fmap):\n is_code = n = 0\n for line in content.split('\\n'):\n if not line:\n continue\n # cc65 outputs source code as three commented lines.\n if line[0] == ';':\n is_code += 1\n else:\n is_code = 0\n # cc65 disables debugin...
[ "0.6549055", "0.6441383", "0.62813497", "0.6251216", "0.5962545", "0.5902105", "0.582003", "0.58094764", "0.5738692", "0.5697942", "0.5670495", "0.56655765", "0.5625153", "0.56247824", "0.5623356", "0.5605149", "0.5599688", "0.55308825", "0.5508571", "0.54907787", "0.54617465...
0.0
-1
Launch the media player with stream uri.
def launch_player(stream_uri): cmd = [ config.get('player', 'launch_cmd'), '"%s"' % stream_uri, ] + ['--{}'.format(p) for p in config.get('player', 'parameters').split(',')] subprocess.call(' '.join(cmd), shell=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(self, uri):\n try:\n self.player.OpenUri(uri)\n except AttributeError as ex:\n raise UnsupportedOperation(\n f'{self.name} does not support opening URIs') from ex", "def play(self, stream_url):\n print(\"Ready to play \" + stream_url)\n se...
[ "0.7129495", "0.71098995", "0.6763526", "0.64070755", "0.6260351", "0.624757", "0.6157602", "0.6134986", "0.6100802", "0.60167456", "0.5987899", "0.5957909", "0.5939217", "0.5891497", "0.584083", "0.58141446", "0.580812", "0.5790475", "0.57633907", "0.57625705", "0.57599914",...
0.7956524
0
Get absolute path to resource, works for dev and for PyInstaller
def resource_path(relative_path): try: # PyInstaller creates a temp folder and stores path in _MEIPASS base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") return os.path.join(base_path, relative_path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep", "def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa...
[ "0.83704215", "0.8281178", "0.8249269", "0.81396633", "0.8114569", "0.80989784", "0.8094434", "0.80801415", "0.8068151", "0.8067846", "0.8057441", "0.8054995", "0.80453163", "0.80453163", "0.80453163", "0.80453163", "0.80453163", "0.80453163", "0.80453163", "0.80453163", "0.8...
0.8062881
16
I Check if a value is in a table, if yes I return its id
def check_product(self, id_target, table_target, column_target, product_target): query = (f"SELECT {id_target} FROM {table_target} WHERE {column_target} LIKE '{product_target}'") self.mycursor.execute(query) result = self.mycursor.fetchall() if len(result) < 1: retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_for_id(id,table):\n # Implement this function\n for row in range(1, len(table)):\n for col in range(len(table[0])):\n if id in table[row][col]:\n return table[row]", "def user_ID_must_exist(cls, value):\n conn = psycopg2.connect(user=SAVER_USERNAME, password=...
[ "0.6984841", "0.6446453", "0.6328465", "0.6215953", "0.61167955", "0.6082369", "0.60548675", "0.5966901", "0.5876553", "0.5855586", "0.5839128", "0.58231413", "0.58118683", "0.5775474", "0.57751864", "0.57374597", "0.5725339", "0.57164854", "0.5714626", "0.5691065", "0.568748...
0.573905
15