query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Parse number from string with automatic type detection. Parses input string and converts to a number using automatic type detection. If the number contains any fractional parts, then the number will be converted to float, otherwise the number will be converted to an int.
def parse_number_auto_dtype(x: str) -> Union[int, float]: value: Union[int, float] = float(x) if value.is_integer(): value = int(value) return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parseNumber(self, str):\r\n\t\tif (str.count(\".\") == 0):\r\n\t\t\treturn int(str)\r\n\t\tif (str.count(\".\") == 1):\r\n\t\t\treturn float(str)\r\n\t\treturn str", "def str2num(s):\r\n try:\r\n return int(s)\r\n except ValueError:\r\n return float(s)", "def str_to_num(s):\n\n meth...
[ "0.806247", "0.7663109", "0.76058894", "0.7603773", "0.7543853", "0.75322175", "0.74632233", "0.7321434", "0.72316444", "0.7026305", "0.7019086", "0.7009801", "0.6992993", "0.69265276", "0.690676", "0.6881941", "0.68817985", "0.68067026", "0.67965007", "0.6696791", "0.6664161...
0.73269945
7
Return ``self == value``.
def __eq__(self, value: object) -> bool: if not isinstance(value, _GENERIC_ALIAS_TYPE): return NotImplemented return ( self.__origin__ == value.__origin__ and self.__args__ == value.__args__ and self.__unpacked__ == getattr( value, "__unpac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return self.value == other.value", "def __eq__(self, other):\n return self.value == other or self.value == other.value", "def __eq__(self, other):\n if other is None:\n return False\n if self.value == other.value:\n return True\n ...
[ "0.81785744", "0.81545824", "0.7910936", "0.77516854", "0.7656241", "0.7656241", "0.76422757", "0.7580233", "0.7384331", "0.7323974", "0.72412944", "0.72412944", "0.7133235", "0.70649093", "0.7051817", "0.70497334", "0.70427805", "0.70339525", "0.70094466", "0.6975119", "0.69...
0.6931704
23
Convert the string form of the symmetry operation into the form of a mathematical function that can be directly applied to a vector to transform a point to a symmetry related point.
def __set_operation_function(self): if self.operation_function is not None: return self.operation_function else: self.operation_function = symm_eval
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_fn(fn_string, symbols):\n fn_string = fn_string.replace('^', '**')\n fn = lambdify([sympy.symbols(symbols)], fn_string, 'numpy')\n return fn", "def matrix_sym_op(x):\n return (x + tf.transpose(x))/2", "def convertStoichiometryMath(self):\n return _libsbml.Model_convertStoichiomet...
[ "0.64556384", "0.5763819", "0.5679932", "0.5665814", "0.5638721", "0.55064327", "0.5426737", "0.54216206", "0.5392853", "0.53914815", "0.53572667", "0.53297466", "0.5317339", "0.5299851", "0.5280908", "0.527228", "0.52579755", "0.52576876", "0.52001554", "0.513768", "0.513490...
0.47996485
70
Loads the model weights once, so it can be reused for several images sequentially.
def load_model(weight_file, img_w, img_h): model, input_data, y_pred = OCRModel( img_w, img_h, NUMBER_GENERATOR_OUPUT_SIZE, ABSOLUTE_MAX_STRING_LEN).build() test_func = K.function([input_data], [y_pred]) model.load_weights(weight_file) return model, test_func
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()", "def load_model_weights(self):\n raise NotImplementedError", "def load_model(self, ):\n ...
[ "0.74412036", "0.74169856", "0.72789735", "0.7261369", "0.7261095", "0.7220132", "0.718703", "0.71257687", "0.70274734", "0.7009838", "0.6920951", "0.691932", "0.6899038", "0.687305", "0.6852795", "0.6798096", "0.6764068", "0.67364603", "0.67252874", "0.67067325", "0.66952705...
0.0
-1
Given images and a model, return the results of the model prediction on those images.
def evaluate_batch(model, images, test_func, img_w, img_h): if len(images) == 1: return [evaluate(model, images[0], test_func, img_w, img_h)] size = len(images) # For some reason, it fails for a single value labels = np.ones([size, ABSOLUTE_MAX_STRING_LEN]) input_length = np.zeros([size, 1]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(model, images):\n return model.predict_classes(images)", "def model_predict(img, model, preprocess_func):\n img = img.resize((224, 224)) # Each model expects shape: (224, 224, 3)\n x = image.img_to_array(img)\n x = np.expand_dims(x, axis=0)\n\n x = preprocess_func(x)\n preds = model.p...
[ "0.7901662", "0.7528717", "0.72941136", "0.72903866", "0.7132775", "0.70108235", "0.6991459", "0.6991264", "0.69582474", "0.6955385", "0.6889948", "0.6857865", "0.685432", "0.67916816", "0.67916816", "0.6787396", "0.6769087", "0.6752149", "0.67412907", "0.6697111", "0.6690872...
0.66428125
28
read an object from json file
def read_object_from_file(file_name): if os.path.exists(file_name) is False: print ("Error read path: [%s]" % file_name) return None with open(file_name, 'r') as f: try: obj = json.load(f) except Exception: print ("Error json: [%s]" % f.read()[0:10]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_json(fpath):\n with open(fpath, 'r') as f:\n obj = json.load(f)\n return obj", "def read_json(fn):\n with open(fn) as f:\n return json.load(f, object_hook=_operator_object_hook)", "def convert_json_to_object(file_content):\n object = json.loads(file_content)\n print(object...
[ "0.79075253", "0.7820032", "0.778218", "0.76092285", "0.75858706", "0.75614053", "0.7538552", "0.7453517", "0.7453517", "0.7428007", "0.7397801", "0.7393363", "0.73734057", "0.73734057", "0.73653334", "0.73588914", "0.7321864", "0.7318475", "0.73151296", "0.7285039", "0.72725...
0.77815557
3
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if self._exclude_from_weight_decay:\n for r in self._exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, param_name):\n ...
[ "0.70423925", "0.70372206", "0.6972458", "0.6972458", "0.6972458", "0.6972458", "0.61478865", "0.61143965", "0.60728186", "0.5874968", "0.57316977", "0.5686603", "0.5607701", "0.5540735", "0.5532297", "0.5527218", "0.5491086", "0.5461098", "0.5446388", "0.54453504", "0.544086...
0.70576096
3
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if self._exclude_from_weight_decay:\n for r in self._exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, param_name):\n ...
[ "0.70423925", "0.70372206", "0.6972458", "0.6972458", "0.6972458", "0.6972458", "0.61478865", "0.61143965", "0.60728186", "0.5874968", "0.57316977", "0.5686603", "0.5607701", "0.5540735", "0.5532297", "0.5527218", "0.5491086", "0.5461098", "0.5446388", "0.54453504", "0.544086...
0.70576096
2
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if self._exclude_from_weight_decay:\n for r in self._exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, param_name):\n ...
[ "0.70423925", "0.70372206", "0.6972458", "0.6972458", "0.6972458", "0.6972458", "0.61478865", "0.61143965", "0.60728186", "0.5874968", "0.57316977", "0.5686603", "0.5607701", "0.5540735", "0.5532297", "0.5527218", "0.5491086", "0.5461098", "0.5446388", "0.54453504", "0.544086...
0.70576096
0
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if self._exclude_from_weight_decay:\n for r in self._exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, param_name):\n ...
[ "0.70423925", "0.70372206", "0.6972458", "0.6972458", "0.6972458", "0.6972458", "0.61478865", "0.61143965", "0.60728186", "0.5874968", "0.57316977", "0.5686603", "0.5607701", "0.5540735", "0.5532297", "0.5527218", "0.5491086", "0.5461098", "0.5446388", "0.54453504", "0.544086...
0.70576096
1
Returns a 'allbatteriesinlcuded' feature generator from a given path (folder)
def load(path: str): lprint(f"Loading feature generator from: {path}") with open(join(path, "feature_generation.json"), "r") as json_file: frozen = json_file.read() thawed = jsonpickle.decode(frozen) thawed._load_internals(path) return thawed
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_features(feature_path):\n if not os.path.exists(os.path.join(feature_path, f\"0_features.npy\")): \n raise ValueError(f\"The provided location {feature_path} does not contain any representation files\")\n\n ds_list, chunk_id = [], 0\n while os.path.exists(os.path.join(feature_path, f\"{chu...
[ "0.56279373", "0.5607112", "0.55230314", "0.5483209", "0.53291225", "0.53291225", "0.53084856", "0.5268843", "0.5251109", "0.52350736", "0.52210736", "0.5193332", "0.5169473", "0.5160666", "0.5146863", "0.51414", "0.5139911", "0.5139759", "0.51297855", "0.5125928", "0.5121712...
0.5089232
22
Tensorflow for monitoring trained policy
def main(_): args = HParams spec = cluster_spec(args.num_workers, 1) cluster = tf.train.ClusterSpec(spec).as_cluster_def() def shutdown(signal, frame): logger.warn('Received signal %s: exiting', signal) sys.exit(128+signal) signal.signal(signal.SIGHUP, shutdown) signal.signal(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, env, task, visualise,record = False):\n\n self.env = env\n self.task = task\n worker_device = \"/job:worker/task:{}/cpu:0\".format(task)\n with tf.device(tf.train.replica_device_setter(1, worker_device=worker_device)):\n with tf.variable_scope(\"global\"):\...
[ "0.67439765", "0.66909194", "0.6592112", "0.6452863", "0.6382239", "0.6316095", "0.630651", "0.6278101", "0.62772006", "0.6261835", "0.62309563", "0.62138945", "0.6196782", "0.61940974", "0.61904985", "0.61813486", "0.6171826", "0.6158264", "0.6102216", "0.6101969", "0.608815...
0.0
-1
Given the current state sample an action from the policy network. Return a the index of the action [0..N).
def take_action(self, state): action = self.tf_sess.run(self.sample, feed_dict={self.X: state.reshape(1, len(state))}) return action
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_action(self, state):\n\t\treturn sample(range(0, self.action_space), 1)[0]", "def get_action(self, state):\n if np.random.rand() <= self.epsilon:\n action_idx = random.randrange(self.action_size)\n else:\n \n # Use all traces for RNN\n #q = self.model.pr...
[ "0.7715992", "0.76681644", "0.74845713", "0.7317097", "0.71172917", "0.7105228", "0.70912486", "0.7057842", "0.70544374", "0.70031416", "0.69955885", "0.6986513", "0.6960665", "0.6937768", "0.6922736", "0.69145274", "0.690203", "0.68946403", "0.68931156", "0.684575", "0.68448...
0.65601355
39
Given the rewards for an epsiode discount them by gamma. Next since we are sending them into the neural network they should have a zero mean and unit variance. Return the new list of discounted and normalized rewards.
def discount_rewards_and_normalize(self, rewards): discounted_rewards = np.empty(len(rewards)) cumulative_rewards = 0 for step in reversed(range(len(rewards))): cumulative_rewards = rewards[step] + cumulative_rewards * self.gamma discounted_rewards[step] = cumulative_rew...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_discounted_rewards(self, rewards):\n discounted_rewards = []\n for t in range(len(rewards)):\n Gt = 0\n pw = 0\n for r in rewards[t:]:\n Gt = Gt + self.gamma ** pw * r\n pw = pw + 1\n discounted_rewards.append(Gt)\n...
[ "0.78813607", "0.7818528", "0.77405256", "0.75703305", "0.7485824", "0.7371996", "0.7272344", "0.7100034", "0.7099121", "0.7018618", "0.6907162", "0.6857457", "0.67791605", "0.6755919", "0.67452127", "0.6703027", "0.66754395", "0.6652472", "0.6647539", "0.6635979", "0.6612237...
0.77522385
2
QRectF.contains(QPointF) > bool QRectF.contains(QRectF) > bool QRectF.contains(float, float) > bool
def contains(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __contains__(self, item: 'BoundingBox2D') -> bool:\n top_left_inside = item.xmin >= self.xmin and item.ymin >= self.ymin\n bottom_right_inside = item.xmax <= self.xmax and item.ymax <= self.ymax\n return top_left_inside and bottom_right_inside", "def contains(self, Union, QPointF=None, Q...
[ "0.7023224", "0.6964382", "0.6639134", "0.6616067", "0.6616067", "0.66096723", "0.6598423", "0.6598423", "0.65199876", "0.64801264", "0.6476461", "0.6441724", "0.64372414", "0.6389606", "0.63867176", "0.6375359", "0.6365074", "0.6354819", "0.63270384", "0.62823135", "0.623226...
0.0
-1
x.__nonzero__() x != 0
def __nonzero__(self): # real signature unknown; restored from __doc__ pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __nonzero__(self):\n for e in self:\n if e != 0:\n return True\n return False", "def __nonzero__(self):\n return self.value.__nonzero__()", "def __nonzero__(self):\n return self.__nonzero", "def __nonzero__(self):\n return self.__nonzero", "def _...
[ "0.77507436", "0.76362675", "0.74977964", "0.74977964", "0.749715", "0.7277969", "0.71057385", "0.70980686", "0.7076215", "0.7038673", "0.7013006", "0.69773006", "0.6971467", "0.69356734", "0.6927782", "0.6920768", "0.690163", "0.6892301", "0.6864851", "0.6852248", "0.6836008...
0.62630165
66
0 is not the successor of any natural number.
def rule_axiom_1(self, idx: int, line: Statement) -> None: self.at_most_refs(line, 0, 'axiom 1') if line.formula != self.AXIOMS[1].formula: raise InvalidRule('not axiom 1')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sgn(x) -> int:\n if x > 0:\n return 1\n if x < 0:\n return -1\n return 0", "def torch_isnotfinite(x):\n not_inf = ((x + 1) != x)\n not_nan = (x == x)\n return 1 - (not_inf & not_nan)", "def sign(n):\n return (n > 0) - (n < 0)", "def p(x):\n if x<0 or x>1:\n re...
[ "0.6770732", "0.6713736", "0.6497921", "0.64779", "0.64756936", "0.6468263", "0.6449532", "0.6415817", "0.63191956", "0.6266652", "0.6248801", "0.6143978", "0.613796", "0.61341465", "0.6131532", "0.6102842", "0.6058444", "0.6043784", "0.60304385", "0.6026586", "0.59800816", ...
0.0
-1
Any natural number multiplied by 0 is 0.
def rule_axiom_4(self, idx: int, line: Statement) -> None: self.at_most_refs(line, 0, 'axiom 4') if line.formula != self.AXIOMS[4].formula: raise InvalidRule('not axiom 4')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zero(x):\n # TODO: get dtype from Expr and Matrix:\n return x * 0", "def zero(*_, **__) -> None:\n return", "def zeros(num):\n if num < 1:\n raise IndexError('num must be >= 1.')\n return Vector.fromSequence([0] * num)", "def test_zero(self):\n\n input_ = 0\n ...
[ "0.71559536", "0.6750768", "0.6670707", "0.6597194", "0.65920085", "0.65668356", "0.65656066", "0.64535195", "0.6385685", "0.636736", "0.6346667", "0.6336748", "0.6290091", "0.6273333", "0.62724316", "0.62715787", "0.6188883", "0.6168746", "0.61516285", "0.6133803", "0.608595...
0.0
-1
Creates a new instance of TrackwayDirectionStage.
def __init__(self, key, owner, **kwargs): super(TrackwayDirectionStage, self).__init__( key, owner, label='Trackway Direction', **kwargs) self._paths = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n super().__init__()\n self.waypoint_vector = [-1, 10]", "def _build_directions(self):\n d = {'start': self.get_start(), 'end': self.get_end(), 'duration': self.get_duration(),\n 'mode': self.get_primary_mode(), 'price_range': self.get_price_range(), 'legs': s...
[ "0.5205769", "0.5060475", "0.49711707", "0.4937936", "0.4937936", "0.48164803", "0.46623772", "0.46488953", "0.46384993", "0.46002585", "0.45988762", "0.4572386", "0.45723125", "0.45568055", "0.45305637", "0.45285165", "0.4508893", "0.44773376", "0.4474872", "0.4455077", "0.4...
0.6856049
0
Creates a new textmessage SpamFilter trained on the given text messages and their associated labels. Performs any necessary preprocessing before training the SpamFilter's Naive Bayes Classifier. As part of this process, trains and stores the CountVectorizer used in the feature extraction process.
def __init__(self, text_train, labels_train): self.vectorizer = CountVectorizer(stop_words='english') self.features = self.vectorizer.fit_transform(text_train) self.nbc = MultinomialNB().fit(self.features, labels_train)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_model(self, text, labels):\n clf = svm.SVR()\n count_vect = CountVectorizer()\n tfidf_transformer = TfidfTransformer()\n counts = count_vect.fit_transform(text)\n tfidf = tfidf_transformer.fit_transform(counts)\n clf.fit(tfidf, labels)\n\n return clf, coun...
[ "0.59928596", "0.5991479", "0.58972853", "0.5896386", "0.5881257", "0.58270174", "0.5791569", "0.57531697", "0.56607693", "0.5642098", "0.56038517", "0.55683374", "0.5556388", "0.5550796", "0.5503383", "0.54590356", "0.53853714", "0.53828907", "0.5378921", "0.5342874", "0.534...
0.624333
0
Takes a path to the raw data file (a csv spreadsheet) and creates a new Pandas DataFrame from it with only the message texts and labels as the remaining columns.
def load_and_sanitize (data_file): data = pd.read_csv(data_file, encoding="latin-1") data = data.drop(columns=['Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4']) data = data.rename(columns={"v1": "class", "v2": "text"}) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(txt_path: str = RAW_TXT) -> pd.DataFrame:\n df = pd.read_csv(txt_path)[INDICES]\n return df", "def load_raw_data(path: str) -> pd.DataFrame:\n data = []\n with open(path) as file:\n for line in file:\n data.append(line)\n data_df = pd.DataFrame(data, columns = {'twe...
[ "0.71791464", "0.70036703", "0.69079787", "0.66350573", "0.6587034", "0.6573408", "0.65146476", "0.6495639", "0.649103", "0.6491012", "0.6479905", "0.6461631", "0.6417438", "0.63850695", "0.63770866", "0.6361787", "0.6361787", "0.6361787", "0.63617593", "0.6361643", "0.630978...
0.5878654
76
Return boxes with a confidence >= `min_score`
def filter_boxes(min_score, boxes, scores, classes): n = len(classes) idxs = [] for i in range(n): if scores[i] >= min_score: idxs.append(i) filtered_boxes = boxes[idxs, ...] filtered_scores = scores[idxs, ...] filtered_classes = classes[idxs, ...] return filtered_bo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_boxes(self, min_score, boxes, scores, classes):\n n = len(classes)\n idxs = []\n for i in range(n):\n if scores[i] >= min_score:\n idxs.append(i)\n \n filtered_boxes = boxes[idxs, ...]\n filtered_scores = scores[idxs, ...]\n filt...
[ "0.7317321", "0.72855526", "0.72492224", "0.72279024", "0.6647105", "0.6314491", "0.63112724", "0.61915874", "0.6165219", "0.61569124", "0.6156313", "0.61135215", "0.6062302", "0.5995685", "0.59620845", "0.5960607", "0.5950879", "0.59485", "0.5940718", "0.5940718", "0.5936835...
0.72886777
1
Draw bounding boxes on the image
def draw_boxes(image, boxes, classes, thickness=4): draw = ImageDraw.Draw(image) for i in range(len(boxes)): bot, left, top, right = boxes[i, ...] class_id = int(classes[i]) color = 'blueviolet' draw.line([(left, top), (left, bot), (right, bot), (right, top), (left, top)], width=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_bounding_boxes(self, image_path):\n img = cv.imread(image_path, cv.IMREAD_ANYDEPTH)\n bboxes = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)\n unique, counts = np.unique(img, return_counts=True)\n for uni in unique:\n if uni == 0:\n continu...
[ "0.80207103", "0.7730494", "0.7663894", "0.75815976", "0.75812364", "0.7569874", "0.7564505", "0.7560773", "0.74707085", "0.74676245", "0.7462541", "0.7429634", "0.7386207", "0.73359627", "0.73075604", "0.73066705", "0.73026776", "0.72940755", "0.7275691", "0.72722554", "0.72...
0.0
-1
Loads a frozen inference graph
def load_graph(graph_file): graph = tf.Graph() with graph.as_default(): od_graph_def = tf.compat.v1.GraphDef() with tf.io.gfile.GFile(graph_file, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_frozen_graph(frozen_graph_path, graph=None, session=None):\n from diplomacy_research.utils.tensorflow import tf, tf_logging\n\n # Making sure the path exists\n if not os.path.exists(frozen_graph_path):\n LOGGER.error('The frozen graph %s does not exist.', frozen_graph_path)\n raise ...
[ "0.7145618", "0.71300054", "0.6952633", "0.64996564", "0.6480352", "0.64554673", "0.6437847", "0.6419772", "0.6419772", "0.63925844", "0.638914", "0.63779676", "0.6364601", "0.6306616", "0.6300151", "0.627973", "0.6269959", "0.6266776", "0.6258529", "0.62003803", "0.6152927",...
0.60229445
30
Return dict representing this Logger's state.
def __getstate__(self): state = self.__dict__.copy() state['_logger'] = None # Contains an unpickleable lock. return state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getstate__(self):\n state = dict(self.__dict__)\n del state['logger']\n return state", "def save_state(self):\n return {'log_formatstr': self.log_formatstr,\n 'backend_interval': self.backend_interval}", "def get_state(self):\n\n # TODO: Assemble a dictionary...
[ "0.81866395", "0.7860514", "0.76662624", "0.7611011", "0.74871504", "0.7330996", "0.7326406", "0.7326406", "0.72727907", "0.7172149", "0.7114898", "0.71087533", "0.7103719", "0.7102913", "0.7094033", "0.7051571", "0.70221627", "0.7014673", "0.6977747", "0.69748193", "0.697239...
0.70902884
15
Restore this Logger's state.
def __setstate__(self, state): self.__dict__ = state self._logger = logging.getLogger(self._name) self.level = self._level
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revert_logging(self):\n if self._previous_action_logging_setting is not None:\n self.action_logging_enabled = self._previous_action_logging_setting\n self._previous_action_logging_setting = None\n return", "def restore_state(self, state: ale_py.ALEState):\n self.ale...
[ "0.69087595", "0.6845371", "0.6712689", "0.66738003", "0.6513239", "0.6494111", "0.6493251", "0.6451605", "0.6426061", "0.6292491", "0.6276428", "0.6251882", "0.6245137", "0.6231107", "0.6206482", "0.61979216", "0.6178583", "0.6161093", "0.61551374", "0.61468834", "0.6117147"...
0.56713307
98
The View function for the about page.
def about(request): return render(request, 'wantedly_app/about.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def about():\n return render_template('about.html', title='About')", "def about_view(request):\n return {'message': 'Info about us.'}", "def about_page(request):\r\n return render(request, 'ez_main/about_page.html')", "def about():\n\n\treturn render_template(\"about.html\")", "def aboutus(requ...
[ "0.80002", "0.799056", "0.79731536", "0.79608667", "0.7933555", "0.7901159", "0.7897344", "0.7870512", "0.7863864", "0.7857774", "0.78450185", "0.784392", "0.782511", "0.7823544", "0.7823544", "0.7819948", "0.7809141", "0.78086245", "0.7805979", "0.7798565", "0.7795315", "0...
0.77838695
21
Returns the current publish dir for the task.
def GetPublishCurrentDirForTask(cls, task): if not PipelineConfig.Instance().pipeline_publish_dir(): return '' out_dir = cls.GetOutDirForTask(task) if not out_dir: return '' out_dir = out_dir.replace(cls.GetOutSubDir(), PipelineConfig.Instance().pipeline_publish_dir()) return os.path.join(os.path.d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetPublishDirForTask(cls, task):\n if not PipelineConfig.Instance().pipeline_publish_dir(): return ''\n\n out_dir = cls.GetOutDirForTask(task)\n if not out_dir: return ''\n return out_dir.replace(cls.GetOutSubDir(), PipelineConfig.Instance().pipeline_publish_dir())", "def get_dir(self):\n ...
[ "0.8311917", "0.66121066", "0.6603187", "0.6539092", "0.65207803", "0.6476241", "0.6405742", "0.639465", "0.6389074", "0.6347666", "0.6347057", "0.6316912", "0.62855846", "0.6264913", "0.6236826", "0.6235748", "0.6203303", "0.6187073", "0.61870384", "0.61644363", "0.61621976"...
0.87881327
0
Check whether the matrix is Toeplitz using our routine.
def isToeplitz(mat): for j in range(row): if not checkDiag(mat, 0, j): return False for i in range(1, col): if not checkDiag(mat, i, 0): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_invertible(matrix: np.ndarray) -> bool:\n return matrix.shape[0] == matrix.shape[1] and np.linalg.det(matrix) != 0", "def check_matrix(self, matrix):\n for i in range(self.size):\n if (matrix[0][i] + matrix[-1][i] == i % 2 or matrix[0][i] + matrix[-1][i] == (i + 1) % 2) and (\n ...
[ "0.62021834", "0.6143656", "0.6061478", "0.58724177", "0.5847098", "0.5835416", "0.579894", "0.57757217", "0.5651579", "0.564704", "0.56339616", "0.5586131", "0.5580269", "0.55736345", "0.55596083", "0.5545253", "0.5520429", "0.5501175", "0.5497774", "0.5475992", "0.546678", ...
0.8034812
0
Compute the width of a bounding box.
def width_of_box(box: ndarray) -> float: (w, _) = dimensions_of_box(box) return w
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getWidth(self):\n return _libsbml.BoundingBox_getWidth(self)", "def width(self) -> int:\r\n return self.rect_uv.w", "def _get_pad_width(self, bbox):\r\n if isinstance(bbox, shapely.geometry.polygon.Polygon):\r\n bbox = bbox.bounds\r\n elif isinstance(bbox, tuple):\r\n...
[ "0.78384995", "0.7405333", "0.72103524", "0.71854645", "0.71309066", "0.698792", "0.69232786", "0.69125646", "0.68847704", "0.68847704", "0.681629", "0.6795641", "0.67908436", "0.67605865", "0.6724223", "0.67201644", "0.6717353", "0.66922086", "0.6662561", "0.6651283", "0.663...
0.7852812
0
Strip and redirect requests with certain trailing characters left by bad URL parsers.
def redirect_trailing(view): IGNORE_CHARS = ",./" def wrapped(request, *args, **kwargs): if request.META['PATH_INFO'][-1] in IGNORE_CHARS: return HttpResponseRedirect(request.META['PATH_INFO'].rstrip(IGNORE_CHARS)) return view(request, *args, **kwargs) return wrapped
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_drop_trailing_questionmark():\n assert normalize_url(\"http://example.com/?\") == \"http://example.com/\"\n assert normalize_url(\"http://example.com?\") == \"http://example.com/\"\n assert normalize_url(\"http://example.com/a?\") == \"http://example.com/a\"\n assert normalize_url(\"http://exa...
[ "0.6716417", "0.65329564", "0.6438808", "0.6175929", "0.6159155", "0.61399084", "0.60827553", "0.6058008", "0.60463554", "0.6016129", "0.6008326", "0.59506243", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.58958346", "0....
0.6691305
1
Given xyz coordinates & dimensions of array, returns the vector index
def ravel_index(x, dims): i = 0 for dim, j in zip(dims, x): i *= dim i += j return i
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _index(tensor_3d, tensor_2d):\n x, y, z = tensor_3d.size()\n t = tensor_3d.reshape(x * y, z)\n tt = tensor_2d.reshape(x * y)\n v = t[torch.arange(x * y), tt]\n v = v.reshape(x, y)\n return v", "def get_ind(self,*q):\n try:\n if( len(q) == 1 ):\n x = q[0][:,0...
[ "0.6535142", "0.6418414", "0.63375473", "0.62212586", "0.60786873", "0.6034432", "0.6029652", "0.60194445", "0.6014285", "0.5993988", "0.5975879", "0.59538525", "0.59294975", "0.5920307", "0.5894706", "0.58881086", "0.58801156", "0.5853542", "0.5853542", "0.58395815", "0.5832...
0.6307502
3
Returns an OptionParser object with all the default options.
def MakeOpts(): parser = ArgumentParser() parser.add_argument("-o", "--host", dest="host", default="hldbv02", help="The hostname for the MySQL database") parser.add_argument('-d', '--debug', action='store_true', default=False, help='debug mode, store results ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_default_options():\n parser = OptionParser()\n add_option_group(parser)\n options, args = parser.parse_args([])\n return options", "def initCmdLineParser():\n\n # Init parser and all general flags\n logging.debug(\"initiating command line option parser\")\n usage = \"usage: %prog [options...
[ "0.84064525", "0.7035872", "0.69315475", "0.6762891", "0.6612723", "0.65971667", "0.657549", "0.65095645", "0.65095645", "0.63397056", "0.6329244", "0.63176024", "0.6288814", "0.6283019", "0.6267587", "0.6220962", "0.6210075", "0.6204305", "0.6200668", "0.619317", "0.61901367...
0.0
-1
Returns all unique paths for files associated with the supplied packages ```package``` The package to be scanned ```absolute_path``` if set to True, returns the absolute path instead of a path relative to the repository root
def find_files_for_package(self, package, absolute_path=False): package_files = [] for p in package.package_versions: package_files.extend(self.find_files_for_packageversion(p, absolute_path)) return package_files
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files_for_packageversion(self, packageversion, absolute_path=False):\n package_files = []\n for attr in ('binary_packages', 'source_packages'):\n if hasattr(packageversion, attr):\n for bp in getattr(packageversion, attr):\n for files in bp.packag...
[ "0.65744954", "0.6538738", "0.6327214", "0.60860723", "0.6070535", "0.5906358", "0.5833705", "0.5832187", "0.58272886", "0.58078057", "0.5749993", "0.57397157", "0.57397157", "0.57397157", "0.5738294", "0.56959873", "0.565308", "0.563047", "0.56227636", "0.56075794", "0.55792...
0.7131917
0
Looks at a filename's extension and decides whether to accept it. We only want package files to be uploaded, after all. It returns a boolean of whether to accept the file or not. ``filename`` File to test.
def allowed_upload(self, filename): for suffix in ['.changes', '.dsc', '.tar.gz', '.diff.gz', '.deb', '.udeb', '.tar.bz2', ".tar.xz"]: if filename.endswith(suffix): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_file(filename):\n \n if not '.' in filename:\n return False\n \n ext = filename.rsplit('.', 1)[1]\n \n if ext.lower() in ALLOWED_FILE_EXTENSIONS:\n return True\n else:\n return False", "def allowed_file(filename: str) -> bool:\n if filename is None or file...
[ "0.82098633", "0.7922775", "0.790487", "0.787731", "0.7795147", "0.7711532", "0.7709475", "0.7709475", "0.77041215", "0.77041215", "0.76879025", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76...
0.74530524
36
Split a date string into units and epoch
def split_date_string(date_string: str): try: units,_,epoch = date_string.split(None, 2) except ValueError: raise ValueError(f'Invalid format: {date_string}') else: return (units.lower(), parse(epoch))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_date_string(date_string: str):\n # try parsing the original date string as a date\n try:\n epoch = parse(date_string)\n except ValueError:\n pass\n else:\n # return the epoch (as list)\n return (datetime_to_list(epoch), 0.0)\n # split the date string into units ...
[ "0.725681", "0.72525626", "0.6715245", "0.64701724", "0.6382786", "0.619452", "0.61797726", "0.6074394", "0.6071968", "0.60437346", "0.601686", "0.6001186", "0.59548134", "0.5884169", "0.5833305", "0.58276343", "0.5821117", "0.581139", "0.5810008", "0.5795588", "0.57780796", ...
0.7802953
1
Convert a ``numpy`` ``datetime`` array to seconds since ``epoch``
def convert_datetime( date: float | np.ndarray, epoch: str | tuple | list | np.datetime64 = _unix_epoch ): # convert epoch to datetime variables if isinstance(epoch, (tuple, list)): epoch = np.datetime64(datetime.datetime(*epoch)) elif isinstance(epoch, str): epoch = np.d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ts_to_epoch_seconds(t) -> float:\n return t.astype(int) / 1e9", "def epoch2datetime(t):\n return datetime.fromtimestamp(t/1000.0)", "def seconds_since_epoch(date_time, epoch=None):\n return microseconds_since_epoch(date_time) / 10.0**6", "def epoch_seconds(date):\n td = date - epoch\n retu...
[ "0.7119384", "0.70471823", "0.67733616", "0.6677283", "0.6677283", "0.66770333", "0.65791225", "0.6510859", "0.64249825", "0.62467736", "0.62348825", "0.62348825", "0.61904925", "0.6188793", "0.6172504", "0.5990658", "0.5972928", "0.5956192", "0.59386444", "0.59345615", "0.59...
0.72007585
1
Counts the number of leap seconds between a given GPS time and UTC
def count_leap_seconds( GPS_Time: np.ndarray | float, truncate: bool = True ): # get the valid leap seconds leaps = get_leap_seconds(truncate=truncate) # number of leap seconds prior to GPS_Time n_leaps = np.zeros_like(GPS_Time,dtype=np.float64) for i,leap in enumerate(leaps): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def utctoweekseconds(utc, leapseconds=18):\n datetimeformat = \"%Y-%m-%d %H:%M:%S\"\n epoch = datetime.datetime.strptime(\"1980-01-06 00:00:00\", datetimeformat)\n tdiff = utc - epoch + datetime.timedelta(seconds=leapseconds)\n gpsweek = tdiff.days // 7\n gpsdays = tdiff.days - 7 * gpsweek\n gpss...
[ "0.652139", "0.58384943", "0.57290035", "0.56942356", "0.56746274", "0.5595739", "0.55098593", "0.5501737", "0.53909945", "0.5376595", "0.5324631", "0.5324156", "0.5290026", "0.5261761", "0.5184121", "0.5171609", "0.51585203", "0.5151989", "0.51178706", "0.5116599", "0.505507...
0.7145605
1
Binary to onehot conversion
def bin2ohot(din, dout): IN_W = len(din) OUT_W = 2**IN_W @always_comb def _conv(): for i in range(OUT_W): if din == i: dout[i] = 1 else: dout[i] = 0 return instances()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_to_one_hot(arr: np.ndarray) -> np.ndarray:\n res = np.zeros((arr.shape[0], 2))\n res[np.where(arr == 1)[0], 0] = 1\n res[np.where(arr == 0)[0], 1] = 1\n return res", "def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerat...
[ "0.8336464", "0.8243893", "0.8077957", "0.8006649", "0.792823", "0.79020256", "0.7887456", "0.7865496", "0.78533834", "0.7835221", "0.7825861", "0.7818072", "0.7791989", "0.7786955", "0.77542466", "0.77538735", "0.77049476", "0.7704875", "0.76757723", "0.76493716", "0.7637535...
0.0
-1
Test each hospital has ranked only residents that have ranked it. If not, check that a warning is caught and the hospital has forgotten any such residents.
def test_check_inputs_hospital_prefs_all_reciprocated(game): hospital = game.hospitals[0] resident = hospital.prefs[0] resident._forget(hospital) with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_prefs_all_reciprocated("hospitals") assert len(record) == 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_prefs(self):\n\n errors = []\n for hospital in self.hospitals:\n residents_that_ranked = [\n res for res in self.residents if hospital in res.prefs\n ]\n if set(hospital.prefs) != set(residents_that_ranked):\n errors.a...
[ "0.65927255", "0.62228805", "0.6033156", "0.5816217", "0.57702166", "0.5740605", "0.569085", "0.56001204", "0.552595", "0.5460149", "0.54297745", "0.53983676", "0.5360775", "0.5351841", "0.5335599", "0.5331168", "0.528455", "0.5271201", "0.52700424", "0.52670234", "0.5262435"...
0.5287138
16
Test each hospital has ranked all residents that have ranked it. If not, check that a warning is caught and any such resident has forgotten the hospital.
def test_check_inputs_hospital_reciprocated_all_prefs(game): hospital = game.hospitals[0] resident = hospital.prefs[0] hospital._forget(resident) with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_reciprocated_all_prefs( "hospitals", "residents" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_prefs(self):\n\n errors = []\n for hospital in self.hospitals:\n residents_that_ranked = [\n res for res in self.residents if hospital in res.prefs\n ]\n if set(hospital.prefs) != set(residents_that_ranked):\n errors.a...
[ "0.6707456", "0.6244367", "0.6030781", "0.5817202", "0.57967025", "0.56785023", "0.5596258", "0.554864", "0.5504701", "0.5493291", "0.54924923", "0.5488279", "0.5485713", "0.54585725", "0.5428704", "0.5420342", "0.5397366", "0.5381196", "0.53527856", "0.53451216", "0.53155655...
0.58555126
3
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Greens): if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] print("Normalized confusion matrix") else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8192804", "0.8094402", "0.80277497", "0.80176693", "0.7992383", "0.7989708", "0.7979215", "0.79741204", "0.7959607", "0.7955097", "0.79358983", "0.79329205", "0.7932711", "0.79295874", "0.79247147", "0.79228914", "0.792216", "0.79215133", "0.7921201", "0.7920765", "0.79161...
0.785076
44
Tests that the output html is generated correclty by the clustering function
def test_output_html(tmp_path): # This will be the file to temporary_file = os.path.join(tmp_path, 'test-cluster.html') # Run clustering on small dummy data (see test_clustering.py) cluster = TextClustering(embedding_random_state=42, reducer_random_state=43, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_html_output(self):\n pass", "def cluster_classification_tex(f,browsing_matrix,diversifying_matrix, weblog,session_data_threshold,cluster_type,classification_column_diversity,classification_wanted_transaction):\n divpat_classification_wanted_transaction = classification_wanted_transaction\n ...
[ "0.68014586", "0.64515656", "0.6283319", "0.6218219", "0.61491203", "0.6064487", "0.5956804", "0.5843667", "0.5821508", "0.5812067", "0.5782588", "0.5746487", "0.572244", "0.5716077", "0.57043064", "0.5677167", "0.5629126", "0.5620701", "0.5605728", "0.5572866", "0.5569146", ...
0.7976958
0
Does a single timestep. x is input at single timestep, with shape [B, input_size] h_mask has shape (1, hidden_size) w_rnn_mask has shape (hidden_size, hidden_size)
def __call__(self, x, state, h_mask=None, w_rnn_mask=None): self._initialize(x) h, syn_x, syn_u = state # Update STP state if self.synapse_config == 'static': h_post = h else: syn_x += self.dynamic_synapse*(self.alpha_std*(1-syn_x) - self.dt_sec*syn_u*syn...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward_multistep(self, x, h=None):\n rnn_out, _ = self.rnn(x, h)\n out = self.nonlin(rnn_out)\n out = self.out(out)\n return out", "def recurrent(self, x, h_0, w_ih, w_hh, b_ih, b_hh):\n time_step = x.shape[0]\n outputs = []\n t = 0\n h = h_0\n ...
[ "0.6626418", "0.6523465", "0.6475527", "0.6467861", "0.63915914", "0.6248351", "0.62410563", "0.6223673", "0.61891216", "0.61472535", "0.5977498", "0.5958096", "0.5928593", "0.5924435", "0.5900401", "0.58467704", "0.5833496", "0.5816832", "0.57625586", "0.5760914", "0.5746896...
0.6954587
0
Cleans text including removal of whitespace, punctuation, accented characters, special characters and transforming to lowercase. Assumes input text is string. Returns clean string.
def normalize_document(doc:str, rm_sw:bool=True, rm_symb:bool=True, lemmatize:bool=True) -> str: stop_words_es = load_stopwords() # lower case and remove special characters\whitespaces if rm_symb: # Remove accents doc = unicodedata.normalize(u'NFKD', doc)\ .encode('ascii'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_text(text):\n text = re.sub(r\"[^A-Za-z0-9(),!?\\'\\`]\", \" \", text)\n text = re.sub(r\"\\'s\", \" \\'s\", text)\n text = re.sub(r\"\\'ve\", \" \\'ve\", text)\n text = re.sub(r\"n\\'t\", \" n\\'t\", text)\n text = re.sub(r\"\\'re\", \" \\'re\", text)\n text = r...
[ "0.8544424", "0.8435103", "0.82290757", "0.80813605", "0.8073183", "0.8063899", "0.80336934", "0.8000144", "0.79784954", "0.7964097", "0.7964097", "0.7964097", "0.7964097", "0.7964097", "0.7964097", "0.77424794", "0.772857", "0.77225435", "0.7708242", "0.76745415", "0.7620131...
0.0
-1
Initialize this prefix tree node with the given character value, an empty structure of children nodes, and a boolean terminal property.
def __init__(self, character=None): # Character that this node represents self.character = character # Data structure to associate character keys to children node values self.children = PrefixTreeNode.CHILDREN_TYPE() # TODO: changes this later to be more modular # we need...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.end_of_ngram = False #Flag marking whether this node is the end of an n-gram.\n self.value = None #Provided that the node marks the end of an n-gram, this refers to the value mapped by this n-gram.\n self.children = dict() #A dictionary which maps the next elements i...
[ "0.6665235", "0.6543156", "0.6469666", "0.6381798", "0.6364745", "0.6266195", "0.61163795", "0.59772074", "0.5968809", "0.5961764", "0.587357", "0.58718324", "0.5849852", "0.5834361", "0.57998735", "0.57780296", "0.5742961", "0.5738601", "0.57318425", "0.5730069", "0.57175416...
0.8080057
0
Return this prefix tree node's child node that represents the given character if it is amongst its children, or raise ValueError if not.
def get_child(self, character): if self.has_child(character): index = self._get_index(character.upper()) return self.children[index] else: raise ValueError(f'No child exists for character {character!r}')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_child(self, character, child_node):\n # make sure character is uppercase\n character = character.upper()\n # TODO: Should I consider check if char is english letter?\n if not character.isalpha():\n raise ValueError(f'Child can only be English letters!')\n\n if ...
[ "0.6411065", "0.6123256", "0.59505016", "0.5816716", "0.5716883", "0.55713284", "0.5504385", "0.5464852", "0.5397857", "0.5277082", "0.52383786", "0.51611114", "0.5122005", "0.50697345", "0.5056239", "0.5043961", "0.5043162", "0.5042223", "0.5009303", "0.49876723", "0.4982551...
0.6819031
0
Return a code representation of this prefix tree node.
def __repr__(self): return f'PrefixTreeNode({self.character!r})'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prefix(self):\n return str(self.data)", "def print_prefix(self):\n if self.is_empty():\n return \"\"\n else:\n ch = str(self.root_value())\n if self.is_leaf():\n return ch\n else:\n if self.has_left():\n ...
[ "0.6528944", "0.6526481", "0.6429511", "0.6429511", "0.62779075", "0.62705106", "0.62266624", "0.6158443", "0.60770893", "0.6044291", "0.60248667", "0.59881675", "0.59881675", "0.59881675", "0.59881675", "0.59868693", "0.5969311", "0.59661835", "0.5922735", "0.5877203", "0.58...
0.7174368
0
Return a string view of this prefix tree node.
def __str__(self): return f'({self.character})'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_prefix(self):\n if self.is_empty():\n return \"\"\n else:\n ch = str(self.root_value())\n if self.is_leaf():\n return ch\n else:\n if self.has_left():\n if self.has_right():\n ...
[ "0.78688645", "0.77090394", "0.76721746", "0.72109437", "0.69245", "0.6888956", "0.68463635", "0.68463635", "0.68463635", "0.6803383", "0.6798295", "0.6796307", "0.6789594", "0.67809397", "0.67643434", "0.67530656", "0.6752193", "0.6741303", "0.6741303", "0.6739444", "0.67361...
0.0
-1
Return a index position of character where it should be placed in list of children.
def _get_index(self, character): OFFSET = 65 # ascii value of 'A' since the first element should be 'A' index = ord(character) - OFFSET return index
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def indexOfChild(self, child):\n self.__initChild()\n return self.__child.index(child)", "def get_index(self, child):\n for _index, item in enumerate(self.children):\n if item == child:\n return _index\n\n return -1", "def get_parent_index(self, child):\n ...
[ "0.7009422", "0.700826", "0.66675276", "0.6638552", "0.6634376", "0.65657616", "0.65270454", "0.64948785", "0.6494254", "0.64940816", "0.6444423", "0.6420129", "0.6409724", "0.640417", "0.6361441", "0.63218945", "0.6315875", "0.6286927", "0.6285693", "0.62847406", "0.62767726...
0.673267
2
Initialize the MixedDataset object
def __init__(self, mode='train_with_val', datasets=None, options=_DEFAULT_DS_TRAIN_OPTIONS): # Only options supported in this initial implementation assert (mode in ['train_noval', 'val', 'train_with_val', 'test']) self.mode = mode self.opts = options # Combine dataset fields ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, dataset: Dataset):\n self.dataset = dataset", "def __init__(self):\n self.__dataset = None", "def __init__(self, dataset):\n self._dataset = dataset", "def __init__(self, **kwargs):\n DataLoader.__init__(self, **kwargs)", "def __init__(self, config):\n ...
[ "0.7411658", "0.72885245", "0.71571064", "0.7053392", "0.68904114", "0.6724314", "0.6659843", "0.6644623", "0.6643797", "0.66090095", "0.66068286", "0.65960044", "0.65706927", "0.65495265", "0.6547606", "0.6535818", "0.65315616", "0.6527384", "0.64903736", "0.64691925", "0.64...
0.0
-1
Returns a reference to the object that is used to communicate with the local database.
def get_database(self): return self.database
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_db(self):\n return DB(\n ClientStorage.ClientStorage((self.server, self.port))\n )", "def _get_current_object(self):\n if not hasattr(self.__local, '__release_local__'):\n return self.__local()\n try:\n return getattr(self.__local, self.__name...
[ "0.6918891", "0.6724008", "0.6724008", "0.6723868", "0.6684718", "0.6680489", "0.6670846", "0.65912634", "0.65845156", "0.65604097", "0.65604097", "0.6549198", "0.65159595", "0.64362836", "0.6411684", "0.6393103", "0.639274", "0.6376347", "0.63745874", "0.63585603", "0.635642...
0.65099496
13
Returns the id received from the storage.
def get_id(self): return self.id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getID(self):\n return str(self._storage_id)", "def storage_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"storage_id\")", "def storage_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"storage_id\")", "def storage_id(self) -> pulumi.Input[str]:\n return p...
[ "0.8605927", "0.7899234", "0.76329434", "0.76329434", "0.7469452", "0.73761845", "0.7328387", "0.7303304", "0.72675776", "0.7265474", "0.7242328", "0.7242328", "0.7242328", "0.7242328", "0.7242328", "0.7242328", "0.7217709", "0.7217658", "0.7214174", "0.7199182", "0.71714056"...
0.7169344
35
Sets the id received from the storage.
def set_id(self, id): self.id = id print("self id = " + str(self.id))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_id(self, id):\n self.data['id'] = id", "def id(self, _id):\n self.metadata[\"id\"] = _id", "def set_id(self, id):\n self.__id = id", "def set_id(self, id_):\n\n self.id_ = id_", "def id(self, id):\n \n self._id = id", "def id(self, id):\n \n ...
[ "0.77089494", "0.76720566", "0.7640065", "0.7606066", "0.75123215", "0.75123215", "0.75123215", "0.75123215", "0.75123215", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", "0.74815494", ...
0.0
-1
Status of the job.
async def status(self) -> JobStatus: async with self._redis.pipeline(transaction=True) as tr: tr.exists(result_key_prefix + self.job_id) # type: ignore[unused-coroutine] tr.exists(in_progress_key_prefix + self.job_id) # type: ignore[unused-coroutine] tr.zscore(self._queue_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status(self):\n return self.job_proto.status", "def status(self) -> str:\n return self._check_job_status()", "def status(self) -> pulumi.Output['outputs.JobStatus']:\n return pulumi.get(self, \"status\")", "def get_status(self):\n\t\treturn call_sdk_function('PrlJob_GetStatus', self....
[ "0.8967504", "0.87950474", "0.83233553", "0.82600874", "0.8072488", "0.7965151", "0.79399073", "0.79399073", "0.7886714", "0.7858171", "0.7853358", "0.7853358", "0.78377676", "0.78345966", "0.78289896", "0.78206897", "0.78206897", "0.78206897", "0.78206897", "0.78206897", "0....
0.79390967
8
Change the canvas's scrollregion to reflect a change made to ``Gyro.circ_pad`` or the radius.
def update_scroll_region(self): self.configure(scrollregion=(-self._radius - self.circ_pad, -self._radius - self.circ_pad, self._radius + self.circ_pad, self._radius + self.circ_pad))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __reconfig__(self, event):\r\n x, y = event.width//2, event.height//2\r\n self.canvas.config(scrollregion=(-x, -y, x, y))", "def set_scrollregion(self, event=None):\n self.canvas.configure(scrollregion=self.canvas.bbox('all'))", "def on_configure(self, event):\n self.testCanvas....
[ "0.6519079", "0.6516638", "0.60711473", "0.60119116", "0.5765868", "0.57313836", "0.56846607", "0.55534095", "0.5489553", "0.5466302", "0.54653174", "0.544385", "0.54332244", "0.54172426", "0.54033566", "0.53885525", "0.5371049", "0.5363052", "0.53378415", "0.5244353", "0.523...
0.7807882
0
Wrapper around ``tkinter.Canvas.create_oval`` to make constructing circles more intuitive.
def create_circle(self, x, y, r, **kwargs): return self.create_oval(*self.circ_to_oval(x, y, r), **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_oval(centerx, centery, radiusx, radiusy):\r\n global _canvas\r\n global _current_color\r\n if _canvas == None:\r\n raise RuntimeError(\"Canvas is not open yet.\")\r\n else:\r\n oval = Ellipse(radiusx * 2, radiusy * 2, Point(centerx, centery))\r\n _set_not_filled(oval)\r\n ...
[ "0.740658", "0.70530504", "0.69541764", "0.66446006", "0.6630347", "0.65782756", "0.65251106", "0.64284277", "0.639205", "0.6383982", "0.6344532", "0.6344419", "0.63228714", "0.6318555", "0.6304312", "0.6300076", "0.6299974", "0.62963027", "0.6232296", "0.62321067", "0.623210...
0.7324109
1
Wait until the given networktables instance successfully connects and then populate the listboxes with data. This should be called after the ``NTBrowser`` is constructed if the networktables instance containing the root table is suspected to be disconnected.
def reload_when_connected(self, inst, poll_ms=500): if inst.isConnected(): self.reload() else: self.after(poll_ms, utils.named_partial(self.reload_when_connected, inst, poll_ms))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_boxdb(self):\n self.tables = self.list_tables()\n for table in self.tables:\n self.mylist.insert(END, table[0])\n self.mylist.bind('<Double-1>', lambda x: self.select_table())", "def _populate(self, table):\n # Repopulating the listboxes will reset the scroll.\n ...
[ "0.5657485", "0.55829924", "0.5064517", "0.50618094", "0.5032641", "0.4853179", "0.485243", "0.4843599", "0.47780308", "0.4739779", "0.4710635", "0.46127602", "0.4594483", "0.45716617", "0.45681164", "0.45410395", "0.454007", "0.4516985", "0.44975692", "0.44831657", "0.447321...
0.0
-1
Internal method used as the callback for ">" events on the listboxes. This method enables or disabled the entry as appropriate to the new data selection and sets ``NTBrowser._curr_indices``.
def _listbox_select_callback(self, _): self._curr_indices = self.key_listbox.curselection() or self.value_listbox.curselection() if self._curr_indices: kind = None for idx in self._curr_indices: # Break if any one of the selected rows is a table. i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable_selected(self, window, values, branch_log_dict, key_event):\n utils.convert_to_numeric(values)\n if(values[key_event] in branch_log_dict[key_event]):#if there is branching for the chosen option\n for element_key in branch_log_dict[key_event][values[key_event]]:\n ...
[ "0.56618375", "0.5659626", "0.5594502", "0.55678624", "0.55105686", "0.54801536", "0.5462772", "0.5423531", "0.5406913", "0.5393726", "0.53336704", "0.5322919", "0.5308489", "0.5301149", "0.5258873", "0.5217732", "0.5205504", "0.5205093", "0.51920545", "0.5189554", "0.5184486...
0.6361306
0
View responding to AJAX request for list of all ingredients currently stored in database.
def get_ingredients(request): items = Ingredient.objects.all().order_by('name') # return list of {item.name: item.pk} context = [] for item in items: context.append({item.name: item.pk}) return HttpResponse(json.dumps(context), content_type='application/json')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _show_ingredient_list(self):\n if self._ingredients_view:\n self._ingredients_view.destroy()\n\n username = self.food_service.get_user().get_username()\n ingredients = self.food_service.list_added_ingredients(username, expire=True)\n self._ingredients_view = IngredientsVi...
[ "0.71443564", "0.6621847", "0.6533707", "0.6456862", "0.63419956", "0.62605214", "0.6260338", "0.6219494", "0.61849874", "0.61646134", "0.61379063", "0.6126435", "0.608624", "0.60640466", "0.60598683", "0.6016408", "0.6010413", "0.5991127", "0.59910214", "0.59663296", "0.5936...
0.72881126
0
Convert number permission notation to symbolic notation.
def num_to_symb(num): num = str(num) if len(num) == 3: group = (num[0], num[1], num[2]) symbolic = "" for key, value in notation.items(): for g in group: if int(g) > 8 or int(g) < 0: symbolic = "Invalid Numerical Representation!" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_octal_from_file_permission(rwx: str) -> str:\n octals = {'r': 4, 'w': 2, 'x': 1, '-': 0}\n chars = []\n temp = []\n \n for i in range(len(rwx)):\n val = octals.get(rwx[i])\n temp.append(val)\n if len(temp) == 3:\n chars.append(list(t for t in temp))\n ...
[ "0.53374124", "0.527418", "0.5249602", "0.520306", "0.5150457", "0.5133376", "0.51284754", "0.5085775", "0.5078872", "0.50376916", "0.5032838", "0.50220686", "0.50122875", "0.4994668", "0.4976482", "0.49640882", "0.49295864", "0.4921475", "0.48928908", "0.48783267", "0.486434...
0.6568608
0
Initialize the object from a dictionary of values
def __json_init__(cls, **kwargs): return cls(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, keys, values):\n self.keys = keys\n self.values = values", "def from_dict(cls, dictionary: Dict[str, Any]):\n return cls(**dictionary)", "def from_dict(cls, dct):\n pass", "def from_dict(cls, data):\n return cls(**data)", "def from_dict(cls, data):\r\n ...
[ "0.7609474", "0.74423563", "0.7432553", "0.7426584", "0.7413911", "0.74106115", "0.73779005", "0.7373955", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "0.73540986", "...
0.0
-1
Retrieve the current values of the RAMSTKMode data model attributes.
def get_attributes(self): _attributes = { 'function_id': self.function_id, 'hardware_id': self.hardware_id, 'mode_id': self.mode_id, 'critical_item': self.critical_item, 'description': self.description, 'design_provisions': self.design_prov...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def device_state_attributes(self):\n # TODO: convert RH from Elk to AH ?\n #if self.current_humidity > 0:\n # humidity = self.current_humidity\n data = {\n 'hidden': self._hidden,\n 'temp_unit' : self.temperature_unit,\n }\n if self._device.tem...
[ "0.61570674", "0.6085479", "0.6055138", "0.6028234", "0.60274136", "0.60102427", "0.59539336", "0.5916759", "0.5916759", "0.58789027", "0.58387506", "0.58357614", "0.58318275", "0.58289427", "0.57944816", "0.57702005", "0.57553905", "0.5739991", "0.57087195", "0.5681874", "0....
0.54526293
57
translates x by subtracting its mean from every observation (so that the result has a mean = 0)
def dev_mean(x): x_bar = mean(x) return [x_i - x_bar for x_i in x]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def de_mean(x):\n x_bar = mean(x)\n return [ x_i - x_bar for x_i in x]", "def de_mean(x):\n x_bar = mean(x)\n return [x_i - x_bar for x_i in x]", "def de_mean(x):\n x_bar = mean(x)\n return [x_i - x_bar for x_i in x]", "def de_mean(x):\n x_bar = mean(x)\n return [x_i - x_bar for x_i i...
[ "0.81177664", "0.80826604", "0.80826604", "0.80826604", "0.7419382", "0.71917254", "0.70956707", "0.6826369", "0.6820255", "0.6728887", "0.6728887", "0.6612345", "0.6566342", "0.6563226", "0.6550982", "0.6509516", "0.6455834", "0.63640994", "0.63588613", "0.6349324", "0.63412...
0.68667185
7
BCE summed over the voxels intensities.
def bce_on_intensities(x, recon_x, scale_b): bce = torch.sum( F.binary_cross_entropy(recon_x, x) / scale_b.exp() + 2 * scale_b) return bce
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _vce(self):\n sum = 0.0\n for sail in self.sails:\n cl2 = sail.cl(self.awa)**2\n cd2 = sail.cd(self.awa)**2\n sum += sail.area * sail.vce * sail.bk * np.sqrt(cl2+cd2)\n self._area()\n deltaCH = 0 if self.sails[1].up!=True else (1-self.ftj)*0.05*self....
[ "0.63061666", "0.5997975", "0.588063", "0.5665232", "0.564657", "0.56458056", "0.55187875", "0.5485349", "0.5484678", "0.5478399", "0.5470462", "0.5465121", "0.54145944", "0.54053366", "0.5383228", "0.53753585", "0.5371241", "0.5369686", "0.5359706", "0.5344592", "0.5335335",...
0.55135
7
Gets and sets the vppOrganizationName
def vpp_organization_name(self): if "vppOrganizationName" in self._prop_dict: return self._prop_dict["vppOrganizationName"] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def organization_name(self):\n if self.organization is not None:\n return self.organization.name\n\n return ''", "def organization(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"organization\")", "def getOrganization(self):\n return _libsbml.ModelCreato...
[ "0.684137", "0.6185486", "0.61104095", "0.60688007", "0.6068101", "0.6055266", "0.59143037", "0.5851724", "0.5840031", "0.58396685", "0.58396685", "0.58298886", "0.5803846", "0.5779328", "0.5779328", "0.56808895", "0.56748295", "0.56549084", "0.5612998", "0.5557546", "0.54901...
0.83878106
0
Gets and sets the seller
def seller(self): if "seller" in self._prop_dict: return self._prop_dict["seller"] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seller(self, seller):\n\n self._seller = seller", "def get_contact_seller(self):\n return self.contact.seller", "def buyer(self, buyer):\n\n self._buyer = buyer", "def seller_from_user(context: Dict[str, Any]) -> Optional[Seller]:\n user: User = context[\"user\"]\n if user.is_a...
[ "0.8109366", "0.698005", "0.62128127", "0.6178388", "0.6039728", "0.6028439", "0.5871527", "0.57780135", "0.5721163", "0.56939894", "0.56875074", "0.5485203", "0.5411141", "0.53689885", "0.5301218", "0.5298088", "0.5297234", "0.52722865", "0.52558464", "0.5248467", "0.5244013...
0.83205086
0
Gets and sets the totalLicenseCount
def total_license_count(self): if "totalLicenseCount" in self._prop_dict: return self._prop_dict["totalLicenseCount"] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def used_license_count(self):\n if \"usedLicenseCount\" in self._prop_dict:\n return self._prop_dict[\"usedLicenseCount\"]\n else:\n return None", "def license_count(self) -> pulumi.Output[Optional[int]]:\n return pulumi.get(self, \"license_count\")", "def license_cou...
[ "0.75288534", "0.7378034", "0.7028874", "0.7028874", "0.6017668", "0.590693", "0.5812739", "0.5784844", "0.57754", "0.5763398", "0.57567894", "0.57275337", "0.56986785", "0.5680325", "0.5677107", "0.5677107", "0.5677107", "0.5677107", "0.5677107", "0.5677107", "0.5677107", ...
0.81494826
0
Density of gas assuming ideal gas law in kg/m^3.
def density(self): return (1e-3*self.molar_mass) * self.pressure / (gas_constant * self.temperature) # kg/m^3
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fGasDensity(GasGravity, Temperature, Pressure):\n\tGasConstant = 8.314\n\tPress = Pressure / 145.038 # MPa\n\tTemp = Temperature + 273.16 # Deg K\n\tPr = Press / (4.892 - (0.4048 * GasGravity))\n\tTr = Temp / (94.72 + (170.75 * GasGravity))\n\tA = 0.03 + 0.00527 * ((3.5 - Tr)**3)\n\tB = (0.642 * Tr) - (0.007 *...
[ "0.74058163", "0.7005451", "0.68938565", "0.6806513", "0.6706316", "0.6634284", "0.6574425", "0.65566623", "0.651678", "0.6436798", "0.63436514", "0.633899", "0.6326834", "0.6320278", "0.63081455", "0.6297625", "0.62733966", "0.62247926", "0.6177332", "0.61762756", "0.6155900...
0.81784177
0
Vapour pressure in Pascals.
def vapour_pressure(self): return self.relative_humidity * self.solvent.equilibrium_vapour_pressure(self.temperature)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PPV(self):\n return _div(self.TP, self.TP + self.FP)", "def vaporPressure(temp: float) -> float:\n exponent = (17.27*temp)/(temp + 237.3)\n vp = 611*np.exp(exponent)\n\n return vp", "def VaporPressure(dwpt):\n\n return 611.2*exp(17.67*dwpt/(243.5+dwpt))", "def volt_to_pressure(volt):\n...
[ "0.7080288", "0.69284487", "0.68418944", "0.6743915", "0.66257185", "0.6582194", "0.6576109", "0.6573769", "0.6532861", "0.65210193", "0.65180355", "0.64524937", "0.64445084", "0.63541234", "0.6329281", "0.6282231", "0.62752527", "0.62735087", "0.62735087", "0.62735087", "0.6...
0.80786455
0
calcule la puissance de x ^ n
def puissance(x: float, n: int) -> float: resultat: float = 1 signe: int = 1 if n != 0: if n <= 0: n = -n signe = -1 for cpt in range(1, n + 1): resultat = resultat * x if signe < 0: resultat = 1 / resultat return resultat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pseudo(x,N) :\n\treturn (x**2+1)%N", "def power(x, n):\n power = 1\n for i in range(abs(n)):\n power = multiply(power, x) \n return power", "def __pow__(self,n):\r\n\t\t\r\n\t\t# take power\r\n\t\tp = self.power(n)\r\n\t\t\r\n\t\treturn p", "def power(x, n):\n value = 1\n for i in ...
[ "0.76149625", "0.73387146", "0.7324877", "0.7267193", "0.72311145", "0.71934336", "0.7170515", "0.707581", "0.69598484", "0.69359", "0.69332993", "0.6889131", "0.6868321", "0.68481904", "0.6832225", "0.6832225", "0.6831433", "0.6818101", "0.67940444", "0.67862517", "0.6785801...
0.71249187
7
Create a LogEntry from the given dictionary.
def from_data(data_dict, intrusion=None): # Data is verified in the ctor and setters return LogEntry(vin=data_dict[LogEntry.VIN_FIELD], app_id=data_dict[LogEntry.APP_ID_FIELD], level=data_dict[LogEntry.LEVEL_FIELD], log_message=data_dict[LogEntry.LOG_MESSAGE_FIELD], gps_position=data_dict[LogEntry.GPS_POSITI...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dict(self, dict_entry, line_length=80):\r\n try:\r\n # Set the entry object's attributes to the corresponding\r\n # values in the dictionary entry. Type conversions need to\r\n # be done for non-string attributes.\r\n for key in dict_entry:\r\n ...
[ "0.6882139", "0.68295366", "0.6646199", "0.6632009", "0.634357", "0.6288146", "0.6288146", "0.62512225", "0.6236364", "0.6207709", "0.61589706", "0.6122494", "0.5947414", "0.59346", "0.5900016", "0.5896469", "0.58897763", "0.58897763", "0.58897763", "0.58897763", "0.58897763"...
0.7672826
0
Dot product of vectors x and y
def dot(x,y): return sum([xi*yi for (xi,yi) in zip(x,y)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))", "def vector_dot(x, y):\n\n if(len(x) != len(y)):\n raise ValueError(\"vector lengths differ\")\n else:\n # return x1*y1+x2*y2+...xn*yn\n return sum([x[i] * y[i] for i in range(len(x))])", "def dot(x, y):\n res = x[0...
[ "0.8719347", "0.85587317", "0.81081426", "0.79403627", "0.7918046", "0.78332645", "0.7820983", "0.78134316", "0.7771925", "0.77611864", "0.7745346", "0.7739358", "0.76962656", "0.7687426", "0.7682485", "0.7668282", "0.7629572", "0.76284784", "0.7628374", "0.7611728", "0.75885...
0.83901334
2
Get only the necessary fields of a tweet returns a Tweet with the needed attributes as a dict
def get_tweet_attributes(self, tw): tw_dict = {} tw_dict['created_at'] = tw['created_at'] tw_dict['lang'] = tw['lang'] tw_dict['text'] = tw['text'] tw_dict['entities'] = tw['entities'] tw_dict['favorite_count'] = tw['favorite_count'] tw_dict['ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tweets_features(tweet):\n tweet = remove_stop_words(tweet)\n return {'TWEET': tweet}", "def extract_user_dict_from_tweet( tweet: Tweet ):\n if tweet.other_data and len( tweet.other_data ) > 0:\n # extract the json into a dict\n j = json.loads( tweet.other_data )\n # extract the ...
[ "0.6789574", "0.67805123", "0.6629773", "0.6599947", "0.6406722", "0.6375403", "0.6339529", "0.62415105", "0.62412876", "0.6117636", "0.6082488", "0.605193", "0.60203075", "0.5877773", "0.58547664", "0.5826857", "0.57997686", "0.57727486", "0.5763892", "0.57532144", "0.573178...
0.7178673
0
Set the range of Yaxis for display
def SetYAxisRange(self, lower, upper): self.Y_AXIS_RANGE = (lower, upper)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __draw_yaxis(self):\n self.ax.set_ylim(self.ylims)\n # set y ticks\n yticks = [*range(0, self.ymax, 5)]\n fs = self.settings.rcParams[\"axes.labelsize\"] if self.settings.otherParams[\n \"ylabel.fontsize\"] is None else self.settings.otherParams[\"ylabel.fontsize\"]\n ...
[ "0.7353007", "0.72912204", "0.7056452", "0.7000773", "0.69802177", "0.69701964", "0.69701964", "0.6961962", "0.6933012", "0.6850009", "0.6794499", "0.67578864", "0.67419934", "0.67419934", "0.67362744", "0.67272717", "0.67264444", "0.666699", "0.66562355", "0.6655635", "0.662...
0.8293696
0
The redshift for this distance assuming its physical distance is a luminosity distance.
def compute_z(self, cosmology=None): from ..cosmology import luminosity_distance from scipy import optimize # FIXME: array: need to make this calculation more vector-friendly f = lambda z, d, cos: (luminosity_distance(z, cos).value - d) ** 2 return optimize.brent(f, (self.Mpc, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def luminosity_distance(self, z):\n return self.proper_distance(z) * (1 + z)", "def luminosity_distance(self, z):\n da = self.angular_diameter_distance(z)\n dl = da*(1.+z)**2.\n return(dl)", "def get_luminosity(self):\n\n if self.no_dist is False and self.no_flux is False:\n\...
[ "0.5890186", "0.58678305", "0.5807113", "0.5798565", "0.56901914", "0.5677453", "0.5615042", "0.5581174", "0.5569656", "0.5483461", "0.5445089", "0.52822375", "0.5251608", "0.5222585", "0.5203338", "0.5182899", "0.5171239", "0.5140096", "0.5124801", "0.51096433", "0.510625", ...
0.0
-1
Returns the best individual if the islands converged to an acceptable fitness. Returns
def get_best_individual(self): return self._best_indv
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _best_individual(self):\n return max(self._population, key=attrgetter(\"fitness\"))", "def best_individual(self):\n return self.population.best_individual()", "def get_best(self) -> Chromosome:\n if not (self._best_chromosome is None): # if the best chromosome is unchanged since the l...
[ "0.80649817", "0.75292766", "0.71652573", "0.6961003", "0.6884281", "0.6873114", "0.67495084", "0.66600174", "0.6649065", "0.6631332", "0.6609789", "0.6591238", "0.65880316", "0.6585515", "0.65848273", "0.65382606", "0.65047693", "0.64753777", "0.6447623", "0.6391002", "0.633...
0.76329255
1
Allocate a TransposedConvLayer with shared variable internal parameters.
def __init__(self, input, num_filters, filter_size, stride=(2, 2), padding=(0, 0), activation=rectify): self.input = input self.output = layers.TransposedConv2DLayer(self.input, num_filters, filter_size, stride=stride, crop=padding, W=initialize_parame...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transpose(incoming, conv, nonlinearity, *args, **kwargs):\n return TransposedConv2DLayer(incoming, conv.input_shape[1],\n conv.filter_size, stride=conv.stride,\n crop=conv.pad, W=conv.W,\n flip_filters=not conv.f...
[ "0.63744015", "0.5864105", "0.586131", "0.5837967", "0.5762193", "0.5750853", "0.57461226", "0.57346827", "0.57076824", "0.5697772", "0.56805575", "0.5673117", "0.5603193", "0.5555773", "0.5510417", "0.5501909", "0.5458268", "0.5454152", "0.5436939", "0.54160196", "0.5399038"...
0.61901104
1
Get the name of the API resource.
def resource_name() -> str: return "contactTags"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self):\n return self.raw_resource[\"name\"]", "def name(self):\n\n return self.resource[\"metadata\"][\"name\"]", "def get_resource_name(self):\n return self._resource_name", "def resource_name(self) -> Optional[str]:\n return pulumi.get(self, \"resource_name\")", "def ...
[ "0.7821574", "0.7735648", "0.7670678", "0.7447657", "0.7447657", "0.74427205", "0.7221747", "0.7221747", "0.7221747", "0.7221747", "0.7221747", "0.7201344", "0.7172618", "0.69053936", "0.68893594", "0.68083745", "0.68061125", "0.6781027", "0.6781027", "0.6777424", "0.67408043...
0.0
-1
Initialize this dataset class.
def __init__(self, opt): BaseDataset.__init__(self, opt) self.A_paths = sorted(make_dataset(opt.dataroot, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc self.transform = get_transform(opt, grayscale=(input_nc == 1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.__dataset = None", "def __init__(self, dataset):\n self._dataset = dataset", "def __init__(self, dataset: Dataset):\n self.dataset = dataset", "def __init__(self, config):\n logger.info(f\"{self.__class__.__name__}: Dataset initializing ...\")\n s...
[ "0.816631", "0.81641185", "0.8013762", "0.76137954", "0.7422038", "0.7393049", "0.7352237", "0.73437655", "0.7111143", "0.71019876", "0.7099074", "0.7096382", "0.70223516", "0.696418", "0.6961817", "0.6889772", "0.6879775", "0.68740934", "0.68599087", "0.68520594", "0.6842619...
0.6548279
77
Return a data point and its metadata information.
def __getitem__(self, index): A_path = self.A_paths[index] A_img = np.array(Image.open(A_path).convert('RGB')) A_img = self.stack(A_img) A_img = resize(A_img,(256, 256)) A_img = np.einsum('abc->cab', A_img) # A_img = hsi_loader(A_path) # print(np.max(A_img)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point(self):\n return self.x, self.y, self.z", "def to_data(self):\n point = {\n 'point': [self.pt[0], self.pt[1], self.pt[2]],\n 'layer_height': self.layer_height,\n\n 'mesh_normal': self.mesh_normal.to_data(),\n 'up_vector': self.up_vector.to_data()...
[ "0.66095746", "0.6598914", "0.65769345", "0.6538956", "0.65237606", "0.6339937", "0.62947094", "0.62947094", "0.61600286", "0.61509", "0.6141212", "0.6137378", "0.6118088", "0.6068833", "0.605036", "0.60272974", "0.59920406", "0.5991923", "0.59914654", "0.59783316", "0.596601...
0.0
-1
Set up the SHC switch platform.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: entities: list[NumberEntity] = [] session: SHCSession = hass.data[DOMAIN][config_entry.entry_id][DATA_SESSION] for number in ( session.device_helper.thermosta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_platform(hass, config, add_devices_callback, discovery_info=None):\n add_devices_callback([\n HE853Switch('OviSwitch', STATE_ON),\n HE853Switch('AC', STATE_OFF)\n ])", "def setup_platform(hass, config, add_devices, discovery_info=None) -> None:\n friendly_name = config.get(CONF_F...
[ "0.61745834", "0.6164841", "0.6163982", "0.60993034", "0.6015168", "0.5961966", "0.5939102", "0.59182364", "0.59003484", "0.58913684", "0.58688366", "0.58645135", "0.5812807", "0.5794662", "0.5756036", "0.57241225", "0.57174337", "0.5713566", "0.570899", "0.57045996", "0.5627...
0.0
-1
Return the min value of the number.
def native_min_value(self) -> float: return self._device.min_offset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def minimum(self):\n return min(self.numbers)", "def minimum_number(self):\n return self._minimum_number", "def min(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"min\")", "def min(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"min\")", "def min(self):\n ...
[ "0.8187885", "0.8120689", "0.7916179", "0.7916179", "0.78326535", "0.7700931", "0.7700931", "0.7643324", "0.76173663", "0.76173663", "0.76063895", "0.75760686", "0.7549816", "0.7485435", "0.7461791", "0.7427969", "0.7427969", "0.74131995", "0.73779243", "0.7353689", "0.732778...
0.68672127
52
Return the max value of the number.
def native_max_value(self) -> float: return self._device.max_offset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maximum_number(self):\n return self._maximum_number", "def maximum(self):\n return max(self.numbers)", "def max_value(self) -> int:\n return self.__max_value", "def max():\n return KeeperOfMinOrMax(int.__lt__)", "def get_max(self):\n return self._max", "def max(self...
[ "0.82954454", "0.81974316", "0.7996817", "0.797404", "0.78951424", "0.7878407", "0.7878407", "0.7877468", "0.78691196", "0.7838583", "0.7678307", "0.7661671", "0.7661671", "0.765726", "0.764877", "0.76332706", "0.7630812", "0.76256377", "0.76256377", "0.76157844", "0.7575633"...
0.0
-1
Query memory given an input embedding
def query(self, query, n_neighbours): if self.added_memories == 0: return None # TODO: possibly L2-normalize query vector? # allow single queries as well, not only batches if query.dim() == 1: query.unsqueeze_(0) idx, distances = self.get_nearest_entries_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((vocab_size,embed_dim), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, input_data)\n #print (\"embed_dim: \",embed_dim) # 向量表达维度为 256\n #print (\"input_data.shape: \",input_data.shape) # (50, 5)\n #p...
[ "0.63078344", "0.63063365", "0.5960762", "0.5928939", "0.58945125", "0.58742183", "0.58714825", "0.5823085", "0.5794332", "0.5751944", "0.56750214", "0.5587403", "0.55768526", "0.557125", "0.5565566", "0.5550268", "0.5541789", "0.5470685", "0.5447556", "0.54236406", "0.540829...
0.6070764
3
Query memory given an input embedding
def query(self, query, n_neighbours): if self.added_memories == 0: return None # TODO: possibly L2-normalize query vector? # allow single queries as well, not only batches if query.dim() == 1: query.unsqueeze_(0) idx, distances = self.get_nearest_entries_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((vocab_size,embed_dim), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, input_data)\n #print (\"embed_dim: \",embed_dim) # 向量表达维度为 256\n #print (\"input_data.shape: \",input_data.shape) # (50, 5)\n #p...
[ "0.63078344", "0.63063365", "0.5960762", "0.5928939", "0.58945125", "0.58742183", "0.58714825", "0.5823085", "0.5794332", "0.5751944", "0.56750214", "0.5587403", "0.55768526", "0.557125", "0.5565566", "0.5550268", "0.5541789", "0.5470685", "0.5447556", "0.54236406", "0.540829...
0.6070764
2
Ensure a date with no hours / minutes is retuned as a date.
def test_date(self): from sosbeacon.utils import format_datetime date = datetime(year=2012, month=8, day=30) encoded = format_datetime(date) self.assertEqual('08/30/12', encoded)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insure_date(d):\n if isinstance(d, BeautifulDate):\n return date(year=d.year, month=d.month, day=d.day)\n else:\n return d", "def fake_date_without_day(value):\n return date(year=value[0], month=value[1], day=1)", "def ensure_date(value: Union[Date, Da...
[ "0.70018554", "0.6946764", "0.685827", "0.6737637", "0.6687125", "0.66750145", "0.65934587", "0.64681107", "0.64442796", "0.6383153", "0.6327889", "0.6267114", "0.62509316", "0.6243825", "0.61947256", "0.61693084", "0.6164787", "0.61503243", "0.6149337", "0.6140435", "0.61300...
0.0
-1
Ensure a date with minutes but no hours is retuned as a datetime.
def test_date_with_zero_hours(self): from sosbeacon.utils import format_datetime date = datetime(year=2012, month=8, day=30, hour=0, minute=13) encoded = format_datetime(date) self.assertEqual('08/30/12 00:13', encoded)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_date_with_zero_minutes(self):\n from sosbeacon.utils import format_datetime\n\n date = datetime(year=2012, month=8, day=30, hour=19, minute=0)\n encoded = format_datetime(date)\n self.assertEqual('08/30/12 19:00', encoded)", "def ensure_datetime(ob: AnyDatetime) -> datetime.d...
[ "0.694124", "0.6576329", "0.6497878", "0.63341737", "0.6285057", "0.60327333", "0.59235966", "0.5857965", "0.58377993", "0.5830965", "0.57997185", "0.57975805", "0.575214", "0.5735291", "0.5732054", "0.57108104", "0.5695891", "0.5693779", "0.5690543", "0.5684678", "0.56797", ...
0.64184
3
Ensure a date with hours but no minutes is retuned as a datetime.
def test_date_with_zero_minutes(self): from sosbeacon.utils import format_datetime date = datetime(year=2012, month=8, day=30, hour=19, minute=0) encoded = format_datetime(date) self.assertEqual('08/30/12 19:00', encoded)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_date_with_zero_hours(self):\n from sosbeacon.utils import format_datetime\n\n date = datetime(year=2012, month=8, day=30, hour=0, minute=13)\n encoded = format_datetime(date)\n self.assertEqual('08/30/12 00:13', encoded)", "def ensure_datetime(ob: AnyDatetime) -> datetime.dat...
[ "0.68381727", "0.6782348", "0.6598675", "0.6525046", "0.6244653", "0.6082294", "0.6023994", "0.6016812", "0.6003925", "0.59741217", "0.5968216", "0.5952586", "0.59485435", "0.5870531", "0.586283", "0.5861185", "0.58541614", "0.58484566", "0.58302844", "0.5829411", "0.5792652"...
0.6744739
2
Ensure a missing date returns the empty string.
def test_non_input(self): from sosbeacon.utils import format_datetime encoded = format_datetime(None) self.assertEqual('', encoded)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_date(self, arg, line_number=0):\n try:\n dt = datetime.strptime(arg, \"%d %b %Y\")\n return dt\n except ValueError:\n raise ValueError(f\"US42 - Illegitimate date of {arg}. GEDCOM line: {line_number}\")\n else:\n return 'NA'", "def test_b...
[ "0.66881824", "0.6186882", "0.61217904", "0.61152357", "0.60820913", "0.6069122", "0.6046784", "0.60390896", "0.60354966", "0.602315", "0.59958637", "0.59915537", "0.5989876", "0.59784245", "0.5972851", "0.5956638", "0.5951182", "0.5942427", "0.59409153", "0.59297127", "0.591...
0.69573593
0
Returns the ROS time in seconds
def get_time(cls): now = rospy.Time.now() return now.secs + now.nsecs*(10**-9) # time in seconds
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gettime():\n return libruss.russ_gettime()", "def get_time(self):\n return self.get_timed() / 10.0", "def _current_time_seconds(self):\n return int(round(time.time()))", "def currentTimeSecs():\n return time.time()", "def get_time(self) -> float:\n self.rocket.update()\n ...
[ "0.75012565", "0.72696334", "0.704129", "0.704039", "0.70382655", "0.69805497", "0.6978949", "0.6969247", "0.69403255", "0.69107735", "0.6896041", "0.6878848", "0.685984", "0.67993206", "0.67879426", "0.6787236", "0.67727417", "0.6743631", "0.6704049", "0.6703564", "0.6699629...
0.7948383
0
Calculate the distance in km between two points given in decimal degrees. Uses Haversine formula, i.e. assuming perfectly spherical earth
def Distance(VCoords, SCoords): #Convert to radians lat1,lon1,lat2,lon2 = map(math.radians, VCoords+SCoords) #Apply Haversine formula dlon = lon2-lon1 dlat = lat2-lat1 a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2 c = 2 * math.asin(math.sqrt(a)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def haversine(lat1, lon1, lat2, lon2):\n\t\t # convert decimal degrees to radians \n\t\t lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])\n\t\t # haversine formula \n\t\t dlon = lon2 - lon1 \n\t\t dlat = lat2 - lat1 \n\t\t a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2...
[ "0.7997606", "0.79383963", "0.7895904", "0.78638697", "0.7796029", "0.77701026", "0.77680063", "0.77678233", "0.77571", "0.7750529", "0.7741123", "0.77320206", "0.7727604", "0.7691649", "0.7687481", "0.76833457", "0.7681609", "0.7681609", "0.7670106", "0.7646074", "0.76412785...
0.0
-1
Check if uuid_to_test is a valid UUID.
def is_valid_uuid(uuid_to_test, version=4): try: uuid_obj = UUID(uuid_to_test, version=version) except ValueError: return False return str(uuid_obj) == uuid_to_test
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_uuid(uuid_to_test, version=4):\n\ttry:\n\t\tuuid_obj = UUID(uuid_to_test, version=version)\n\t\treturn True\n\texcept:\n\t\treturn False", "def check_uuid(uuid):\n try:\n converted = UUID(uuid, version=4)\n except ValueError:\n return False\n\n return str(converted) == uuid", ...
[ "0.8684954", "0.8333081", "0.8155957", "0.80367714", "0.8028158", "0.79428333", "0.77374667", "0.7734152", "0.7734152", "0.76239145", "0.7593849", "0.7555792", "0.7149705", "0.71090436", "0.69526494", "0.6922901", "0.66879606", "0.66867393", "0.66619414", "0.6655981", "0.6640...
0.8562131
1
This function tests a board for a winner and returns a value between 0 and 5
def test_winner(state_board): res = 3 #default value is tie game ptsb = 0 #points for the black ptsw = 0 #points for the white #looks in the board if there is an empty case while # counting the number of points for each player for i in state_board: for j in i: if j == 0: res = 0 elif j == 1: pts...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(board):\n winner = 0\n for player in [1, 2]:\n if row_win(board, player) or col_win(board, player) or diag_win(board, player):\n winner = player\n \n if np.all(board != 0) and winner == 0:\n winner = -1\n return winner", "def utility(board):\n win =...
[ "0.8226638", "0.7735134", "0.7697947", "0.7688143", "0.76567584", "0.7635804", "0.7614953", "0.76082647", "0.76045525", "0.7571411", "0.7569988", "0.7560676", "0.7552569", "0.7549131", "0.7542866", "0.75107414", "0.7508619", "0.75054234", "0.7480221", "0.7479761", "0.747914",...
0.76951003
3
Yields pairs from an iterable.
def pairs(iterable): previous = None for item in iterable: current = item if previous is not None: yield previous, current previous = current
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_pairs(iterable):\n if isinstance(iterable, Mapping):\n iterable = iterable.items()\n return iter(iterable)", "def pairs(lst):\r\n\tfor i in range(1, len(lst), 2):\r\n\t\tyield lst[i-1], lst[i]", "def pairwise(iterable):\r\n a = iter(iterable)\r\n return izip(a, a)", "def pairs(lst...
[ "0.81223637", "0.7461575", "0.7307938", "0.7271222", "0.714917", "0.7142806", "0.7133279", "0.7094758", "0.70062834", "0.6977689", "0.6964083", "0.6942506", "0.6933127", "0.6882018", "0.6859719", "0.68461996", "0.6843346", "0.6843346", "0.6843346", "0.6824935", "0.6753879", ...
0.77604663
1
Returns the current date. That means every time the project is deployed, the datestamp will update. Returns a formatted date object, ala "Friday Feb. 20"
def last_update(blank): today = date.today() return today.strftime('%A %B %d')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_date():\n return datetime.datetime.today().strftime(constants.DATE_FORMAT)", "def get_date_today() -> str:\n return datetime.now().strftime(\"%Y-%m-%d\")", "def get_current_date(fmt=\"%Y-%m-%d\"):\n return datetime.datetime.now().strftime(fmt)", "def get_date():\n now = da...
[ "0.7824893", "0.7507471", "0.7391598", "0.73774505", "0.73269105", "0.7283762", "0.72370684", "0.7218445", "0.7215881", "0.71713823", "0.7162151", "0.7127916", "0.7113581", "0.71124613", "0.71002764", "0.70509845", "0.7046391", "0.702825", "0.6980741", "0.69473976", "0.694374...
0.6653718
41
return ngrams as single spaceseparated strings with their occurences
def get(self, n): parts = [' '.join(g) for g in ngrams(self.words, n)] return get_occurences(parts)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _ngrams(self, string_):\n def find_ngrams(input_list, n):\n return zip(*[input_list[i:] for i in range(n)])\n\n ngrams = []\n tokens = string_.split()\n\n for size in range(1, self._ngram_range + 1):\n tuples = find_ngrams(tokens, size)\n concatenate...
[ "0.78278804", "0.76701784", "0.76432234", "0.7412483", "0.7388992", "0.7383285", "0.7343278", "0.7261323", "0.725827", "0.7243522", "0.72036326", "0.7154389", "0.7147983", "0.71211857", "0.71205693", "0.70832944", "0.70656013", "0.70451486", "0.70400804", "0.6991556", "0.6975...
0.64976317
52
lemmatize words in noun_phrases, exclude phrases with `STOPWORDS`
def lemmatized_phrases(self): phrases = [set(lower_words(TextBlob(p).words.lemmatize())) for p in self.blob.noun_phrases] return [' '.join(p) for p in phrases if not STOPWORDS.intersection(p)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lemmatize_verbs(self):\n lemmas = []\n # lemmas = \"\"\n for word in self.words:\n lemma = wn.lemmatize(word, pos='v')\n lemmas.append(lemma)\n # lemmas += f\"{lemma} \"\n self.words = lemmas\n return self", "def lemmatize_nouns(self, words):\n\t\tlemmatizer = WordNetLemma...
[ "0.73897773", "0.73393244", "0.72585356", "0.7244815", "0.71327686", "0.69146174", "0.68672264", "0.68209785", "0.6816726", "0.6812039", "0.6789802", "0.6779173", "0.67476636", "0.6746864", "0.6731405", "0.6731262", "0.67183787", "0.6701651", "0.66856176", "0.66856176", "0.66...
0.8088282
0
Given a ManagedProcess protobuf instance, create the corresponding ProcessNode and insert it into the graph.
def add_node(self, managed_process_pb): node = ProcessNode(managed_process_pb) if node.name not in self.nodes: self.nodes[node.name] = node self.logger.info('Created node for [{}]'.format(node.name)) else: self.logger.error( 'Detected request ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_node_process(name, properties):\n process = NodeProcess(name)\n DB.session.add(process)\n DB.session.commit()\n for p in properties:\n prop = NodeProcessProperty(process.id, p[0], p[1], p[2])\n DB.session.add(prop)\n DB.session.commit()\n return process", "def add_proce...
[ "0.6773554", "0.64495486", "0.60057384", "0.5933061", "0.5871152", "0.58102006", "0.5744983", "0.57229316", "0.5719331", "0.56770027", "0.5667292", "0.5577523", "0.5570289", "0.55650806", "0.55393213", "0.55308384", "0.5441535", "0.5393277", "0.5389408", "0.5335206", "0.52840...
0.7839599
0
Sends a 401 response that enables basic auth
def authenticate(): return Response( 'Could not verify your access level for that URL.\n' 'You have to login with proper credentials', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})", "def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )", "def authenticate():\n return Response(\n 'You have to login with pro...
[ "0.8093736", "0.80926424", "0.7958403", "0.7852648", "0.7843114", "0.7824419", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", ...
0.774767
34