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
Returns all transaction of the account.
def transactions(self): return self._call_account_method( 'transactions' )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transactions(self):\r\n return tx.AccountTransactions(self)", "def transactions(self) -> List[Transaction]:\n return self.session.get_transactions(self.account_id)", "def transactions(self):\n url = f'{self._ynab.api_url}/budgets/{self.budget.id}/accounts/{self.id}/transactions'\n ...
[ "0.83322763", "0.8157989", "0.77802324", "0.76984334", "0.753643", "0.7532989", "0.750693", "0.7451186", "0.7426054", "0.73617077", "0.7297444", "0.72779584", "0.7239408", "0.7174363", "0.7129202", "0.71288365", "0.70906407", "0.70444614", "0.70438075", "0.6977753", "0.691445...
0.8300182
1
Merge two depthone dicts with no conflicts
def test_single_level(self): dict_1 = { 'key_1': 'original_value_1', 'key_2': 'original_value_2' } dict_2 = { 'key_2': 'new_value_2', 'key_3': 'new_value_3' } result = deep_dict_merge(dict_1, dict_2) assert dict_1 == { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_merge(d1, d2):\n for k, v in d1.copy().items():\n if k in d2:\n if all(isinstance(e, MutableMapping) for e in (v, d2[k])):\n d2[k] = ConfigManager.deep_merge(v, d2[k])\n\n if k == \"*\":\n for _k, _v in d2.items():\n ...
[ "0.7789761", "0.7654393", "0.76521575", "0.7609642", "0.76095176", "0.7534293", "0.7507701", "0.7475496", "0.7441581", "0.74275243", "0.74178606", "0.74134773", "0.7403028", "0.7361108", "0.7314981", "0.7313351", "0.7274468", "0.7268576", "0.7255547", "0.7255547", "0.7255547"...
0.735179
14
Merge two depthone dicts with no conflicts
def test_recursive_merge(self): dict_1 = { 'key': { 'deep_key_1': 'original_value_1', 'deep_key_2': 'original_value_2' } } dict_2 = { 'key': { 'deep_key_2': 'new_value_2', 'deep_key_3': 'new_value...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_merge(d1, d2):\n for k, v in d1.copy().items():\n if k in d2:\n if all(isinstance(e, MutableMapping) for e in (v, d2[k])):\n d2[k] = ConfigManager.deep_merge(v, d2[k])\n\n if k == \"*\":\n for _k, _v in d2.items():\n ...
[ "0.77895755", "0.765239", "0.7652366", "0.76102215", "0.7610147", "0.7533907", "0.75053704", "0.74743694", "0.7440982", "0.74259555", "0.7418049", "0.74116147", "0.7402825", "0.73592085", "0.73515284", "0.73148817", "0.73112804", "0.7273905", "0.72662234", "0.72537357", "0.72...
0.7232177
28
Scatter plot with contour over dense regions
def scatter_contour(x, y, levels=10, bins=40, threshold=50, log_counts=False, histogram2d_args={}, plot_args={}, contour_args={}, ax=None): if ax is None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plotit(X,Y=None,clf=None, markers = ('s','o'), hold = False, transform = None):\n eps=1e-6\n minx, maxx = np.min(X[:,0]), np.max(X[:,0])\n miny, maxy = np.min(X[:,1]), np.max(X[:,1])\n \n if clf is not None:\n npts = 150\n x = np.linspace(minx,maxx,npts)\n y = np.linspace(mi...
[ "0.6413699", "0.6402964", "0.6291107", "0.6247415", "0.6247415", "0.6247415", "0.62390184", "0.6211225", "0.62045515", "0.62045515", "0.62045515", "0.62045515", "0.6131246", "0.6105118", "0.6084301", "0.608259", "0.5993672", "0.5981581", "0.5968162", "0.59619623", "0.59405816...
0.56889796
36
computes quantiles from an array
def quantiles(x, qlist=[2.5, 25, 50, 75, 97.5]): # Make a copy of trace x = x.copy() # For multivariate node if x.ndim > 1: # Transpose first, then sort, then transpose back sx = np.transpose(np.sort(np.transpose(x))) else: # Sort univariate node sx = np.sort(x) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantile_ndim(arr, quantiles):\n return pipe(\n zip(arr, quantiles),\n fmap(lambda x: np.quantile(*x, axis=-1, interpolation=\"nearest\").T),\n np.stack,\n )", "def _process_quantiles(x, dim):\r\n x = np.asarray(x, dtype=float)\r\n\r\n if x.ndim == 0:\r\n x = x[np.newa...
[ "0.73162127", "0.7243329", "0.72008586", "0.70955795", "0.70481795", "0.7037941", "0.70182544", "0.6964112", "0.6951001", "0.6951001", "0.6951001", "0.68317634", "0.6771439", "0.67608815", "0.6760826", "0.67263746", "0.67028785", "0.6690526", "0.66813254", "0.6678839", "0.662...
0.6923256
11
Read a text file and create a list containing lines from the file.
def file_to_list(file_name): fr = open(file_name, encoding = 'utf-8') l = [line.strip() for line in fr] fr.close() return l
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_file_into_list(filename):\n with open(filename) as file:\n return file.readlines()", "def read_list(file_name):\n with open(file_name, 'r') as f:\n text = f.read().splitlines()\n return text", "def listfromfilelines(file):\r\n with open(file, 'r') as f:\r\n list = [lin...
[ "0.8016677", "0.7951751", "0.79095143", "0.7868484", "0.78494394", "0.7834517", "0.77421796", "0.77362806", "0.7731668", "0.7718403", "0.769346", "0.76785064", "0.7660208", "0.7607018", "0.7606068", "0.76019204", "0.7597274", "0.75887895", "0.75864637", "0.75766253", "0.75759...
0.79001784
3
Initialise the single year env. Instantiation of SingleYearEnv object which returns reward for each step. In this case, the reward being error metrics.
def __init__(self, solar, onshore, load, solar_df, onshore_df, load_df, n_clusters_dim_1, n_clusters_dim_2, batch_size, year_start): super().__init__(solar, onshore, load, solar_df, onshore_df, load_df) # self.solar = solar # self.onshore = onshore # self.load = load # self.np_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, env):\n\n self.env = env\n self.env_info = env.env_info\n\n self.best_policy = None\n self.best_score = 0\n\n # Time to run the environment for during training and evaluation\n self.max_t = MAX_T\n # Maximum possible reward given the environment\n...
[ "0.61077166", "0.60247886", "0.59458816", "0.5812", "0.57523435", "0.568361", "0.5622885", "0.5593818", "0.5585508", "0.55393314", "0.5494416", "0.5482594", "0.54710716", "0.5432569", "0.5431648", "0.5431091", "0.54144275", "0.53772134", "0.5361995", "0.53412324", "0.5319923"...
0.0
-1
Get a random naughty string
def get_random_naughty_string(): return (random.choice(naughty_string_list)).encode('utf-8').decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random_string(t):\n return t[random.randint(0, len(t)-1)]", "def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec", "def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))", "def get_...
[ "0.7729024", "0.770825", "0.7591874", "0.75557464", "0.74990875", "0.7360135", "0.73158723", "0.72958267", "0.7277025", "0.7239737", "0.7189966", "0.7185455", "0.71660674", "0.71609235", "0.71598786", "0.71211356", "0.71109927", "0.7102652", "0.70774764", "0.707355", "0.70730...
0.8574377
0
Get a random emoji
def get_random_emoji(): return (random.choice(get_emoji_list())).encode('utf-8').decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_rnd_msg() -> str:\n\n char_num = random.randint(8,20)\n i = 0\n s = \"\"\n for n in range(char_num):\n if i == char_num:\n break\n rnd_char = random.randint(0, len(string.ascii_lowercase) - 1)\n s += string.ascii_lowercase[rnd_char]\n i += 1\n\n re...
[ "0.69903463", "0.6594322", "0.6553047", "0.6538175", "0.6531477", "0.6512787", "0.6392046", "0.6346064", "0.63363206", "0.6333219", "0.62904185", "0.6278788", "0.6235721", "0.6155152", "0.615461", "0.6148589", "0.61209637", "0.6118676", "0.6104847", "0.6091219", "0.6088738", ...
0.8843907
0
Get the time elapsed in seconds, nicely formatted by format_duration()
def fsince(self, key=0, max_fields=3): return format_duration(self.since(key), max_fields)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_seconds(duration):\n\treturn stats_utils.format_seconds(duration)", "def elapsed(self):\n return str(datetime.datetime.now() - self.start).split('.')[0]", "def get_formatted_duration(self, prev_time):\n duration = time() - prev_time\n if duration < 60:\n unit = 's'\n ...
[ "0.7748476", "0.76119894", "0.75615484", "0.75254935", "0.7462877", "0.7446534", "0.7417696", "0.7400583", "0.7389618", "0.7376881", "0.7323891", "0.7286666", "0.7286113", "0.72783655", "0.72755474", "0.7234187", "0.7213747", "0.7201873", "0.7187011", "0.71547145", "0.7145967...
0.0
-1
Returns the current time as a string in the format 'YYYY_MM_DD_HH_MM_SS'. Useful for timestamping filenames etc.
def now(): return time.strftime("%Y_%m_%d_%H_%M_%S")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_current_time():\n return strftime(\"%Y_%m_%d_%H_%M_%S_%Z\", gmtime())", "def get_current_datetime_string ( ) :\n return get_current_datetime( ).strftime( \"%Y%m%d-%H%M%S\" )", "def get_current_time():\n return time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.localtime())", "def get_current_timestamp...
[ "0.883562", "0.84312123", "0.8405628", "0.83867073", "0.83295137", "0.821461", "0.80861926", "0.8069823", "0.8068688", "0.806344", "0.79625446", "0.79273516", "0.7926732", "0.79068786", "0.78904295", "0.7850311", "0.78145266", "0.78001124", "0.77937484", "0.76943123", "0.7677...
0.8251835
5
fallback of '+' operator
def __radd__(self, other): if isinstance(other, int): return self.__add__(other) return NotImplemented
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plus(self, a, b):\n return a + b", "def __radd__(self, other):\n if not (isNumeric(other) or isinstance(other, Expression)):\n error_msg = (\n f'Invalid expression during addition to {self}: [{other}]'\n )\n raise excep.biogemeError(error_msg)\n ...
[ "0.7379013", "0.7167448", "0.71051866", "0.71051866", "0.70936185", "0.6990493", "0.6968093", "0.69207066", "0.6886756", "0.6886756", "0.6886756", "0.6886756", "0.6886756", "0.6886756", "0.6863187", "0.6826406", "0.6802572", "0.677709", "0.6770079", "0.6770079", "0.67671776",...
0.65270793
65
Compute misfits from reponses_dict (real_id, values in dataframe) and observation
def calculate_misfits_from_pandas( reponses_dict: Mapping[int, pd.DataFrame], observation: pd.DataFrame, summary_misfits: bool = False, ) -> pd.DataFrame: misfits_dict = {} for realization_index in reponses_dict: misfits_dict[realization_index] = _calculate_misfit( observation["v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_time_series_counts(df_dict: Dict[str, List[Tuple[str, pd.DataFrame]]], state: str) \\\n -> Dict[str, Dict[str, List[Tuple[str, GaussianProcessRegressor]]]]:\n time_regression_dict = {}\n for key in df_dict.keys():\n if key not in time_regression_dict.keys():\n time_regression...
[ "0.5576119", "0.52896106", "0.5272236", "0.52592635", "0.51980996", "0.51555324", "0.5079609", "0.50795454", "0.50437903", "0.5037836", "0.4993045", "0.4980486", "0.49733526", "0.4950174", "0.49142018", "0.490738", "0.49033743", "0.48435432", "0.4841239", "0.48338985", "0.483...
0.7277154
0
r"""Multiply two Pauli words together, and return both their product as a Pauli word and the global phase. Two Pauli operations can be multiplied together by taking the additive OR of their binary symplectic representations. The phase is computed by
def pauli_mult_with_phase(pauli_1, pauli_2, wire_map=None): if wire_map is None: wire_map = _wire_map_from_pauli_pair(pauli_1, pauli_2) # Get the product; use our earlier function pauli_product = pauli_mult(pauli_1, pauli_2, wire_map) # Get the names of the operations; in cases where only one...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pauli_mult(pauli_1, pauli_2, wire_map=None):\n\n if wire_map is None:\n wire_map = _wire_map_from_pauli_pair(pauli_1, pauli_2)\n\n # Check if pauli_1 and pauli_2 are the same; if so, the result is the Identity\n if are_identical_pauli_words(pauli_1, pauli_2):\n first_wire = list(pauli_1....
[ "0.61162484", "0.5924344", "0.58755136", "0.58647066", "0.57278585", "0.5599932", "0.554609", "0.5516311", "0.54801697", "0.54724824", "0.54583263", "0.54274434", "0.54231125", "0.54197645", "0.5384777", "0.5380467", "0.5380467", "0.5379686", "0.5367275", "0.5363706", "0.5340...
0.7214186
0
compute perpatch for each patch
def compute_patch_loss(self, inputs, outputs, next_to_prev_weight = [1.0, 1.0]): bsz, w, h, __ = inputs['input_image'].shape pred_next_image = outputs["next_position"] path_state = inputs['path_state'].reshape(bsz, 1, w, h).float() true_next_image = image_to_tiles(path_state, self.pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch_perimeters(patch_ids, perim):\n\n return np.bincount(patch_ids.reshape((-1,)),\n weights=perim.reshape((-1,)))[1:]", "def _apply_patches(self) -> None:\n first_patch, last_patch = False, False\n patches = {}\n for patch_name, locations in self.patches.items...
[ "0.63990563", "0.6277366", "0.61426204", "0.57987994", "0.57399416", "0.57330805", "0.5637813", "0.560493", "0.5568912", "0.55633616", "0.54916686", "0.5487375", "0.54767793", "0.54637873", "0.54431975", "0.5431589", "0.5428818", "0.5403599", "0.5391965", "0.5376233", "0.5350...
0.5119075
42
Returns the coordinates ('x' or 'y') of edges of a Polygon exterior.
def getGeometryCoords(row, geom, coord_type, shape_type): # Parse the exterior of the coordinate if shape_type == 'polygon': exterior = row[geom].exterior if coord_type == 'x': # Get the x coordinates of the exterior return list( exterior.coords.xy[0] ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_polygon_envelope(polygon, x_pixel_size, y_pixel_size):\n # retrieve polygon points\n poly_pts = list(polygon.exterior.coords)\n # split tuple points into x and y coordinates and convert them to numpy arrays\n xs, ys = [np.array(coords) for coords in zip(*poly_pts)]\n # compute bounding box\n...
[ "0.66501695", "0.65170836", "0.6363739", "0.6358394", "0.6235087", "0.61831164", "0.6146898", "0.6051083", "0.6006026", "0.59681934", "0.5846156", "0.5827838", "0.5804802", "0.58019096", "0.5789799", "0.5775383", "0.5719779", "0.567106", "0.56565374", "0.5651454", "0.5650535"...
0.5686897
17
Compute lstm outputs for sentences i (sentences with index i in text) of current batch.
def body(i,n,los): # extract correct lstm input (i-th sentence from each batch) #es = tf.slice(self.seq_embeddings,[0,i,0,0],[batch_size, 1, sentence_length, self.config.word_embedding_size]) es = tf.slice(self.seq_embeddings,tf.pack([0,i,0,0]),tf.pack([batch_size, 1, sentence_length, self.confi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lstm_infer_vector(lstm_model, txt, stopwords,word_indices, maxlen=10, taillemax=300) :\n \n txt_prep = gensim.utils.simple_preprocess(txt, deacc=True)\n txt_wo_uw = remove_unknown_words(txt_prep, word_indices)\n txt_wo_ws = remove_stopwords(txt_wo_uw, stopwords)\n \n if len(txt_wo_ws)>taillem...
[ "0.6933876", "0.670924", "0.63159287", "0.63015085", "0.6280184", "0.6264368", "0.6256373", "0.62109447", "0.6196833", "0.61919165", "0.6182961", "0.6165134", "0.6153539", "0.6153275", "0.61289626", "0.6098019", "0.6093729", "0.6060236", "0.6057099", "0.6051623", "0.60428655"...
0.72236145
0
creates table for pushups if table does not exist
def _create_table_pushup(cur) -> None: cur.execute(''' CREATE TABLE IF NOT EXISTS pushup ( id INTEGER PRIMARY KEY , date TEXT , time TEXT , dur REAL , qty INTEGER , uid INTEGER , FOREIGN KEY (uid) REFERENCES user (id) ) ''')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate(cls):\n database.cursor.execute(\"\"\"CREATE TABLE IF NOT EXISTS meetups(\n id serial PRIMARY KEY,\n topic varchar,\n happening_date varchar,\n tags varchar,\n location varchar,\n images varchar,\n body varchar\n ...
[ "0.67756426", "0.6715347", "0.67136127", "0.6674527", "0.6628539", "0.6623509", "0.6609472", "0.6600938", "0.6586564", "0.65119374", "0.651168", "0.6469907", "0.64437926", "0.6420419", "0.6416651", "0.6410212", "0.6383321", "0.6382811", "0.63810956", "0.6376543", "0.6354817",...
0.7989284
0
checks if table exists in database, returns boolean
def check_table(cur, table: str) -> bool: table_data = cur.execute(f""" SELECT name FROM sqlite_master WHERE type='table' AND name='{table}' """) table_fetch = table_data.fetchall() if table_fetch: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_table_exists(table_name):\n return table_name in connection.introspection.table_names()", "def db_table_exists(db, table_name):\n query = \"\"\"\n SELECT name FROM sqlite_master\n WHERE type='table' AND name='%s'\"\"\" % table_name\n cursor = db.execute(query)\n results = cursor....
[ "0.8855887", "0.8813139", "0.87166125", "0.86918336", "0.86277765", "0.85318553", "0.85177517", "0.85009074", "0.84633154", "0.8455719", "0.8431545", "0.8394328", "0.8383718", "0.8337121", "0.8318872", "0.828969", "0.8285541", "0.82731766", "0.82228535", "0.8154813", "0.80880...
0.7881405
29
Ensure proper messages are logged when version is invalid.
def test_process_and_log_version(self): import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger("test_version") instance = ClassWithNoVersion() class_properties = instance.get_class_properties() instance_properties = {"version": "1.1.1"} ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_invalid_version_fields(self):\n self.assertRaises(ValueError, versions.Version, version='1234', name='foo')", "def test_check_version_non_release(self):\n with self.assertLogs(\"dakara_feeder.version\", \"DEBUG\") as logger:\n with patch.multiple(\n \"dakara_feede...
[ "0.7247217", "0.70182544", "0.68627435", "0.68395036", "0.6822215", "0.6812243", "0.6728835", "0.6723149", "0.666472", "0.6621475", "0.65737456", "0.65239364", "0.65166855", "0.65080816", "0.64542484", "0.631019", "0.6301201", "0.6266744", "0.6238869", "0.62187195", "0.620411...
0.5754618
55
Sets _webclient if it is defined in the given config.
def _init(config): if not config.cpu_model: logging.warning( "It is strongly recommended to set a CPU model('--cloudCPUModel'). " "Otherwise the used machines and CPU models are undefined." ) if not config.cloud_master: sys.exit("No URL of a VerifierCloud instanc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_client(self, client):\n self.client = client", "def client_setup(self):\n self.client = Client()", "def _require_client(self, client):\n if client is None:\n client = self._client\n return client", "def configure_client(self):\n self.client = self.get_re...
[ "0.55661076", "0.5560395", "0.5478225", "0.5471557", "0.54632884", "0.54625005", "0.5438309", "0.54254025", "0.5319346", "0.5228689", "0.52202547", "0.5133249", "0.5108777", "0.5086545", "0.5062516", "0.5044742", "0.5040028", "0.503687", "0.50339395", "0.5016561", "0.50037706...
0.6176934
0
Sets the account_name of this WebhookV1Details.
def account_name(self, account_name): self._account_name = account_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_name(self, account_name):\n if account_name is None:\n raise ValueError(\"Invalid value for `account_name`, must not be `None`\") # noqa: E501\n\n self._account_name = account_name", "def funding_account_account_name(self, funding_account_account_name):\n\n self._fund...
[ "0.772084", "0.6759548", "0.65338904", "0.6448011", "0.6427493", "0.6216254", "0.61249673", "0.60701615", "0.60701615", "0.60701615", "0.60701615", "0.60146993", "0.60062855", "0.60062855", "0.60062855", "0.60062855", "0.60062855", "0.60062855", "0.58761483", "0.5834222", "0....
0.808228
1
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, WebhookV1Details): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
calculate derivative of sigmoid
def sigmoid_prime(self, s): return s * (1 - s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid_derivative(x):\n return x * (1-x)", "def derivative_sigmoid(x):\n return x * (1 - x)", "def derivative_sigmoid(x):\n return x * (1 - x)", "def sigmoid_derivative(x):\n return x * (1.0 - x)", "def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))", "def sigmoid_der...
[ "0.88152", "0.880703", "0.880703", "0.87443066", "0.86681527", "0.864508", "0.83066857", "0.822768", "0.8067256", "0.80347425", "0.7757273", "0.7756407", "0.77519506", "0.77062905", "0.7677311", "0.7611972", "0.75673646", "0.7540467", "0.7535175", "0.74896514", "0.7483781", ...
0.0
-1
Base RNN Encoder Class
def __init__(self,hidden_size): super(selfatt, self).__init__() self.linear1=torch.nn.Linear(2*hidden_size,hidden_size) self.linear2=torch.nn.Linear(hidden_size,1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n super(BaseRNNEncoder, self).__init__()", "def _define_encoder(self):\n raise NotImplementedError", "def __init__(self, input_size, hidden_size, bidirection, config):\r\n super(Encoder, self).__init__()\r\n\r\n self.config = config\r\n self.input_size = input...
[ "0.8752531", "0.6918208", "0.6881964", "0.664724", "0.6568228", "0.6482072", "0.6438336", "0.64262027", "0.63833475", "0.63457656", "0.63238245", "0.63169205", "0.62887216", "0.6287361", "0.62840176", "0.6243016", "0.6222029", "0.6210399", "0.620946", "0.6170326", "0.616672",...
0.0
-1
Base RNN Encoder Class
def __init__(self,hidden_size): super(mulatt, self).__init__() self.linear1=torch.nn.Linear(hidden_size,hidden_size,bias=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n super(BaseRNNEncoder, self).__init__()", "def _define_encoder(self):\n raise NotImplementedError", "def __init__(self, input_size, hidden_size, bidirection, config):\r\n super(Encoder, self).__init__()\r\n\r\n self.config = config\r\n self.input_size = input...
[ "0.8752531", "0.6918208", "0.6881964", "0.664724", "0.6568228", "0.6482072", "0.6438336", "0.64262027", "0.63833475", "0.63457656", "0.63238245", "0.63169205", "0.62887216", "0.6287361", "0.62840176", "0.6243016", "0.6222029", "0.6210399", "0.620946", "0.6170326", "0.616672",...
0.0
-1
Base RNN Encoder Class
def __init__(self): super(BaseRNNEncoder, self).__init__()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _define_encoder(self):\n raise NotImplementedError", "def __init__(self, input_size, hidden_size, bidirection, config):\r\n super(Encoder, self).__init__()\r\n\r\n self.config = config\r\n self.input_size = input_size\r\n self.hidden_size = hidden_size\r\n self.bidirecti...
[ "0.6918208", "0.6881964", "0.664724", "0.6568228", "0.6482072", "0.6438336", "0.64262027", "0.63833475", "0.63457656", "0.63238245", "0.63169205", "0.62887216", "0.6287361", "0.62840176", "0.6243016", "0.6222029", "0.6210399", "0.620946", "0.6170326", "0.616672", "0.6146954",...
0.8752531
0
Argmax operation. This operation is not differentiable, so use it only when evaluating your model.
def argmax(self, axis=None): return np.argmax(self.data, axis=axis)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def argmax(tensor):\n raise NotImplementedError", "def convert_argmax(node, **kwargs):\n name, input_nodes, attrs = get_inputs(node, kwargs)\n\n axis = int(attrs.get(\"axis\"))\n keepdims = get_boolean_attribute_value(attrs, \"keepdims\")\n\n node = onnx.helper.make_node(\n 'ArgMax',\n ...
[ "0.7682671", "0.67637116", "0.6634946", "0.6548298", "0.6335756", "0.63352156", "0.63348633", "0.62952536", "0.62867504", "0.62736934", "0.62536854", "0.622453", "0.62011564", "0.6190506", "0.61656135", "0.61656135", "0.6121837", "0.61063874", "0.60922486", "0.60658735", "0.6...
0.68460524
1
Convert passed tensor to Tensor if it isn't already.
def _to_tensor(cls, tensor): if isinstance(tensor, Tensor): return tensor return Tensor(data=tensor)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tensor2tensor(tensor, *, device=None):\r\n assert gg.TF_ENABLED, 'Currently tensorflow backend is not enabled.'\r\n if pytorch.is_tensor(tensor):\r\n m = tensoras(tensor)\r\n device = gf.device(device, backend=\"tensorflow\")\r\n return astensor(m, device=device, backend=\"tensorflow...
[ "0.7388358", "0.69628996", "0.68198335", "0.6755679", "0.649428", "0.64924914", "0.63998675", "0.6341806", "0.62480795", "0.62459826", "0.6179512", "0.6156622", "0.61380357", "0.609529", "0.60787064", "0.6067964", "0.60593396", "0.6059108", "0.60321313", "0.59858143", "0.5958...
0.8218513
0
Initializes variables typically needed for problem setup. n = number of points in spatial or time domain = number of points in frequency domain.
def initialize(domain_limit: int, n: int) -> Tuple[List[int], List[int]]: # Time or spatial domain discretization. # Since we have periodic boundary conditions, the first and last points # are the same. So we consider only the first n points in the time domain. t_shifted = np.linspace(-domain_limit, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, dimension, n):\n self.dimension = dimension\n self.n = n\n self.basis = None", "def __init__(self, n):\n self.n = n\n self.w = np.zeros(self.n)\n self.z = np.zeros(self.n)\n self.F = 0\n self.M = 0", "def __initialise_algorithm(self, m,...
[ "0.67745924", "0.6554968", "0.61069405", "0.6096866", "0.6085949", "0.60363257", "0.6033075", "0.6024352", "0.60232955", "0.60053414", "0.5995625", "0.5989366", "0.5976308", "0.59558576", "0.59461653", "0.5945515", "0.59454954", "0.59374344", "0.5933226", "0.5931913", "0.5878...
0.6856761
0
Validates the length of the password as well as the presence of
def validate(self, password, user=None): if user and user.is_staff: self.min_length = self.min_length_admin self.validate_digits(password) self.validate_uppercase(password) self.validate_lowercase(password) if len(password) < self.min_length: raise Valid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_password(password):\n if len(password) < MIN_LENGTH:\n return False\n return True", "def validate_password(password):\n return isinstance(password, str) and len(password) >= 8 and \\\n re.search(r'[A-Z]', password) and re.search(r'[0-9]', password)", "def test01_...
[ "0.8202459", "0.8145444", "0.8110606", "0.81104404", "0.8099719", "0.805752", "0.79376465", "0.79371095", "0.7932934", "0.79264295", "0.79034257", "0.78727835", "0.78663385", "0.78626275", "0.78355235", "0.78279805", "0.78029245", "0.77787846", "0.7759024", "0.77425116", "0.7...
0.7225309
51
Validates the amount of digits present in the password. If the required amount not satisfied, rises an exception. Since an error is raised, returns are not required.
def validate_digits(self, password): digits = sum(c.isdigit() for c in password) if digits < self.min_digits: raise ValidationError( ungettext( "This password must contain %(min_digits)d digit.", "This password must contain %(min_digit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_password_strength_validator_missing_digit(self):\n with self.assertRaises(ValidationError):\n validate_password_strength('abcdefg')", "def test02_password_numeric(self):\n self.set_complexity(length=0, numeric=4, upper=0, lower=0, special=0)\n\n invalid = (\n \...
[ "0.75922745", "0.69964325", "0.691633", "0.69122356", "0.6900738", "0.6872299", "0.6863374", "0.6861973", "0.6848446", "0.6844406", "0.68352103", "0.68062335", "0.6774592", "0.6772326", "0.67547613", "0.6745281", "0.6699284", "0.6690392", "0.6665745", "0.6660251", "0.6648733"...
0.7724263
0
Validates the amount of uppercase letters present in the password. If the required amount not satisfied, rises an exception. Since an error is raised, returns are not required.
def validate_uppercase(self, password): uppercase = len(set(string.ascii_uppercase).intersection(password)) if uppercase < self.min_digits: raise ValidationError( ungettext( "This password must contain %(min_uppercase)d capital letter.", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test03_password_upper(self):\n self.set_complexity(length=0, numeric=0, upper=1, lower=0, special=0)\n\n invalid = (\n \"a\",\n \"!!!!!!!!!!!!\",\n \"password\",\n \"password123!\",\n \"admin\",\n \"1abcd2efghij3\",\n )\n ...
[ "0.76795214", "0.7292038", "0.7089257", "0.7089257", "0.70174074", "0.6946482", "0.68584806", "0.67761594", "0.66371346", "0.6618781", "0.66126066", "0.6583521", "0.6560778", "0.6523087", "0.647073", "0.6466607", "0.64321035", "0.6418995", "0.63941115", "0.6358961", "0.633825...
0.81607705
0
Validates the amount of lowercase letters present in the password. If the required amount not satisfied, rises an exception. Since an error is raised, returns are not required.
def validate_lowercase(self, password): min_lowercase = len(set(string.ascii_lowercase).intersection(password)) if min_lowercase < self.min_lowercase: raise ValidationError( ungettext( "This password must contain %(min_lowercase)d lowercase letter.", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test04_password_lower(self):\n self.set_complexity(length=0, numeric=0, upper=0, lower=3, special=0)\n\n invalid = (\n \"A\",\n \"!!!!!!!!!!!!\",\n \"PASSWORD\",\n \"PASSWORD123!\",\n \"ADMIN\",\n \"A1!B2@C3£D4$E5%F6^G7&\",\n ...
[ "0.75528955", "0.73245144", "0.73245144", "0.73144627", "0.72918993", "0.72500306", "0.7013033", "0.69620454", "0.6937937", "0.67240375", "0.67240375", "0.67172915", "0.67152494", "0.6609776", "0.658527", "0.65802544", "0.6564677", "0.65471005", "0.6539703", "0.6538214", "0.6...
0.8062939
0
Calculates the amount of days a password still is valid.
def password_validity(user): # password change information: delay = constants.USER_PASS_SPAN # default users if user.is_staff: # staff/admins delay = constants.ADMIN_PASS_SPAN # default last pass update, join date of the user date_joined = user.date_joined # last change log last...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remaining_days_in_cycle(self) -> int:\n if not self.expiration:\n return 0\n delta = self.expiration - _today()\n return int(delta.days)", "def login_validity_duration(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"login_validity_duration\")", "def Daysleftv...
[ "0.6639423", "0.6625128", "0.6529403", "0.6409341", "0.6259163", "0.6259163", "0.6138269", "0.6108329", "0.60737604", "0.60196173", "0.5944456", "0.5937556", "0.59244233", "0.59050584", "0.58217734", "0.5782795", "0.5779661", "0.57649934", "0.57480854", "0.57233167", "0.56756...
0.7041956
0
Gets model's learning rate. Computes the model's learning rate for different learning policy. Right now, only "step" and "poly" are supported.
def get_model_learning_rate( learning_policy, base_learning_rate, learning_rate_decay_step, learning_rate_decay_factor, training_number_of_steps, learning_power, slow_start_step, slow_start_learning_rate): global_step = tf.compat.v1.train.get_or_create_global_step() if learning_policy ==...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_learning_rate(self, step):\n rate = 0\n progress = 100 * (step / self.max_steps) # expressed in percent units\n\n if self.policy == \"fixed\":\n rate = self.base_rate\n elif self.policy == \"step\":\n current_step = math.floor(step/self.step_size)\n ...
[ "0.7556861", "0.7552756", "0.7521507", "0.741702", "0.7337567", "0.72320414", "0.7203591", "0.7119905", "0.7095124", "0.70497537", "0.7017169", "0.698815", "0.6821078", "0.6821078", "0.6804581", "0.6800042", "0.67804486", "0.67804486", "0.6758294", "0.67339015", "0.66937643",...
0.76333195
0
Yield individual characters in the file
def __iter__(self,): self.f.seek(self.pos) data = self.f.read(BUFFER_SZ) while data: while self.dataptr < len(data): self.dataptr += 1 yield data[self.dataptr - 1] self.pos = self.f.tell() self.dataptr = 0 data = se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_chars(filename):\n with open(filename, \"r\") as f:\n return list(f.read())", "def __iter__(self):\r\n with open(self.source, 'rb') as fin:\r\n for line in fin:\r\n yield to_unicode(line)", "def _open_file_binary(filename):\n for _byte in open(filename, 'rb...
[ "0.69992894", "0.685351", "0.6539119", "0.6501876", "0.6285198", "0.617998", "0.6158262", "0.6149376", "0.61451423", "0.61328167", "0.61312944", "0.611647", "0.6035658", "0.6023802", "0.6017101", "0.6013453", "0.5998693", "0.59975463", "0.59647536", "0.59602654", "0.59374934"...
0.59989536
16
Change date to string
def check_date(self, flight): for key, value in flight.items(): if isinstance(value, datetime): flight[key] = value.strftime('%Y-%m-%dT%H:%M:%S') return flight
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_to_final_str(date_obj: datetime) -> str:\n return date_obj.strftime(\"%Y-%m-%d\")", "def date_to_string(date) -> str:\n\n return date.strftime('%m/%d/%Y')", "def transform_date(date):\n if type(date) == str:\n return date\n\n formatted_string = date.strftime(\"%d/%m/%Y\")\n\...
[ "0.79543644", "0.7856605", "0.76222426", "0.75452775", "0.75275713", "0.7521758", "0.75098693", "0.74887514", "0.74887514", "0.7471289", "0.7459221", "0.7386809", "0.7302105", "0.72785354", "0.72282577", "0.7223653", "0.7204312", "0.7181065", "0.7141924", "0.71396846", "0.710...
0.0
-1
Check if there is enough time space for flight change.
def change_possible(self, departure_time): if (departure_time >= self.min_departure_time) and (departure_time <= self.max_departure_time): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid(self):\n delta = datetime.datetime.now() - self._last_access\n return ((delta.seconds < 7200) and not self.is_empty()) or \\\n (delta.seconds < 60)", "def check_time():\n times = get_times()\n time_difference = abs((times['local'] - times['target']).total_seconds())\n ...
[ "0.68912625", "0.6793455", "0.6776931", "0.6729147", "0.6644173", "0.64271533", "0.63994557", "0.63416487", "0.62911093", "0.6281896", "0.6275451", "0.6239902", "0.62001413", "0.6191993", "0.61592185", "0.611905", "0.6116258", "0.6107895", "0.6057059", "0.60354793", "0.603097...
0.63998395
6
Create a multiheaded attention layer.
def __init__(self, num_heads: int, size: int, dropout: float = 0.1): super(MultiHeadedAttention, self).__init__() assert size % num_heads == 0 self.head_size = head_size = size // num_heads self.model_size = size self.num_heads = num_heads self.k_layer = nn.Linear(size...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _MultiHeadedAtten(self, name, num_heads=None,\n enable_qkv_proj_in_onestep=False):\n p = self.params\n if num_heads is None:\n num_heads = p.num_heads\n\n atten_p = MultiHeadedAttention.Params().Set(\n name=name,\n input_dim=p.model_dim,\n hidden_dim=p....
[ "0.6830668", "0.67512697", "0.66610235", "0.58259755", "0.5818397", "0.58088636", "0.5796812", "0.57878107", "0.57515967", "0.57481235", "0.5714224", "0.56959355", "0.5645859", "0.5645363", "0.563958", "0.5598113", "0.5582692", "0.5578292", "0.55541396", "0.55452853", "0.5538...
0.61767036
3
Create a multiheaded attention layer.
def __init__(self, num_heads: int, size: int, size_v: int, dropout: float = 0.1): super(ContMultiHeadedAttention, self).__init__() assert size % num_heads == 0 self.head_size = head_size = size // num_heads self.model_size = size self.num_heads = num_heads self.k_layer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _MultiHeadedAtten(self, name, num_heads=None,\n enable_qkv_proj_in_onestep=False):\n p = self.params\n if num_heads is None:\n num_heads = p.num_heads\n\n atten_p = MultiHeadedAttention.Params().Set(\n name=name,\n input_dim=p.model_dim,\n hidden_dim=p....
[ "0.6830668", "0.67512697", "0.66610235", "0.61767036", "0.58259755", "0.5818397", "0.5796812", "0.57878107", "0.57515967", "0.57481235", "0.5714224", "0.56959355", "0.5645859", "0.5645363", "0.563958", "0.5598113", "0.5582692", "0.5578292", "0.55541396", "0.55452853", "0.5538...
0.58088636
6
Forward pass for a single transformer encoder layer. First applies layer norm, then self attention, then dropout with residual connection (adding the input to the result), and then a positionwise feedforward layer.
def forward(self, x: Tensor, mask: Tensor) -> Tensor: x_norm = self.layer_norm(x) h = self.src_src_att(x_norm, x_norm, x_norm, mask) h = self.dropout(h) + x o = self.feed_forward(h) return o
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x, mask):\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n #print('encoder')\n #print(x.shape)\n return self.sublayer[1](x, self.feed_forward)", "def encoder_layer(enc_input, attn_bias, n_head, d_key,\n d_value, d_model, d_inner_h...
[ "0.6818004", "0.6644002", "0.6604981", "0.65594107", "0.6275912", "0.62714034", "0.625358", "0.62461406", "0.62455684", "0.6210142", "0.6189951", "0.6183114", "0.6167052", "0.61632866", "0.6118759", "0.6064869", "0.6061808", "0.6029366", "0.6026097", "0.6001943", "0.6001943",...
0.0
-1
Represents a single Transformer decoder layer. It attends to the source representation and the previous decoder states.
def __init__(self, size: int = 0, ff_size: int = 0, num_heads: int = 0, dropout: float = 0.1, src_trg_att: bool = True): super(TransformerDecoderLayer, self).__init__() self.size = size self.src_trg_att = src_tr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,\r\n unified_encoder,\r\n decoder,\r\n output_layer):\r\n super().__init__()\r\n\r\n self.unified_encoder = unified_encoder\r\n self.decoder = decoder\r\n self.output_layer = output_layer", "def _define_decoder(self):\n...
[ "0.645439", "0.6248505", "0.610214", "0.610214", "0.6036502", "0.59785515", "0.593279", "0.58914083", "0.5867743", "0.58593804", "0.58437186", "0.5821642", "0.58025587", "0.5770026", "0.57408243", "0.573016", "0.5718816", "0.57105434", "0.5683209", "0.56799376", "0.5677243", ...
0.5734862
15
Represents a single Transformer decoder layer. It attends to the source representation and the previous decoder states.
def __init__(self, size: int = 0, bb_size: int = 64, ff_size: int = 0, num_heads: int = 0, dropout: float = 0.1): super(CustomTransformerDecoderLayer, self).__init__() self.size = size self.trg_trg_att = ContMu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,\r\n unified_encoder,\r\n decoder,\r\n output_layer):\r\n super().__init__()\r\n\r\n self.unified_encoder = unified_encoder\r\n self.decoder = decoder\r\n self.output_layer = output_layer", "def _define_decoder(self):\n...
[ "0.645439", "0.6248505", "0.610214", "0.610214", "0.6036502", "0.59785515", "0.593279", "0.58914083", "0.5867743", "0.58593804", "0.58437186", "0.5821642", "0.58025587", "0.5770026", "0.57408243", "0.5734862", "0.573016", "0.5718816", "0.57105434", "0.5683209", "0.56799376", ...
0.5570261
28
Represents a single Transformer decoder layer. It attends to the source representation and the previous decoder states.
def __init__(self, size: int = 0, ff_size: int = 0, num_heads: int = 0, dropout: float = 0.1, sent_length: int = 128,): super(TransformerRefineLayer, self).__init__() self.layer_norm = nn.LayerNorm(size, eps=1e-6) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,\r\n unified_encoder,\r\n decoder,\r\n output_layer):\r\n super().__init__()\r\n\r\n self.unified_encoder = unified_encoder\r\n self.decoder = decoder\r\n self.output_layer = output_layer", "def _define_decoder(self):\n...
[ "0.645439", "0.6248505", "0.610214", "0.610214", "0.6036502", "0.59785515", "0.593279", "0.58914083", "0.5867743", "0.58593804", "0.58437186", "0.5821642", "0.58025587", "0.5770026", "0.57408243", "0.5734862", "0.573016", "0.5718816", "0.57105434", "0.5683209", "0.56799376", ...
0.0
-1
Forward pass for a single transformer encoder layer. First applies layer norm, then self attention, then dropout with residual connection (adding the input to the result), and then a positionwise feedforward layer.
def forward(self, context: Tensor, box: Tensor, mask: Tensor, xy_pdf_score: Tensor) -> Tensor: # print('context:',context.shape) # print('box:',box.shape) context_norm = self.layer_norm(context) # print('context_norm:',context_norm.shape) box_norm = self.box_norm(box) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x, mask):\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n #print('encoder')\n #print(x.shape)\n return self.sublayer[1](x, self.feed_forward)", "def encoder_layer(enc_input, attn_bias, n_head, d_key,\n d_value, d_model, d_inner_h...
[ "0.6819527", "0.6645445", "0.6606152", "0.65602154", "0.62778664", "0.6272793", "0.62541115", "0.6247589", "0.6246928", "0.6212247", "0.6191654", "0.618483", "0.6167691", "0.6164789", "0.61196345", "0.6067385", "0.6062951", "0.60304123", "0.6028004", "0.60035837", "0.60035837...
0.0
-1
Like Django but sets more valid cache disabling headers.
def never_ever_cache(decorated_function): @wraps(decorated_function) def wrapper(*args, **kwargs): response = decorated_function(*args, **kwargs) patch_cache_control( response, no_cache=True, no_store=True, must_revalidate=True, max_age=0) return response re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable_cache(response):\n\n response.headers['Cache-Control'] = 'max-age=0, no-cache, no-store, must-revalidate, private'\n response.headers['Pragma'] = 'no-cache'\n response.headers['Expires'] = '0'\n return response", "def disable_caching(self):\n\n def after_request(r: flask.Response):...
[ "0.7912773", "0.7748608", "0.73450196", "0.73387265", "0.72733325", "0.72570574", "0.7236969", "0.7207599", "0.7199399", "0.7156136", "0.7156136", "0.7153797", "0.70991856", "0.70991856", "0.70991856", "0.70991856", "0.70991856", "0.70991856", "0.70991856", "0.70991856", "0.7...
0.0
-1
Initialize a graph object with an empty dictionary.
def __init__(self): self.vertList = {} self.vertCount = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, graph_dict=None):\r\n if graph_dict == None:\r\n graph_dict = {}\r\n self.__graph_dict = graph_dict", "def __init__(self, graph_dict=None):\n if graph_dict == None:\n graph_dict = {}\n self.__graph_dict = graph_dict", "def __init__(self, grap...
[ "0.8217067", "0.8215162", "0.81920594", "0.8124552", "0.7526083", "0.72547203", "0.72015864", "0.7126566", "0.6956719", "0.69436586", "0.6934398", "0.68819934", "0.6869305", "0.68405473", "0.67379785", "0.66892505", "0.666255", "0.66103375", "0.66103375", "0.65822786", "0.653...
0.0
-1
Add a new vertex object to the graph with its respective key.
def add_vertex(self, key): self.vertCount += 1 addedVertex = vertex.Vertex(key) self.vertList[key] = addedVertex return addedVertex
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_vertex(self, key):\n vertex = Vertex(key)\n self.vertices[key] = vertex", "def add_vertex(self, key):\n if key in self.vertices:\n raise ValueError('Key is already in use')\n \n # Create vertex\n self.vertices[key] = GraphVertex(key=key)", "def add_v...
[ "0.88855225", "0.8645909", "0.8517491", "0.8452246", "0.8390398", "0.83036655", "0.81518126", "0.8072168", "0.8062546", "0.7993649", "0.79840595", "0.79699624", "0.79226506", "0.78633845", "0.78633845", "0.7778371", "0.7776886", "0.7744332", "0.7744332", "0.7741701", "0.76861...
0.8600742
2
Add an edge from vertex f(from) to vertex t (to) with a cost.
def add_edge(self, f, t, cost=1): if f not in self.vertList: self.add_vertex(f) if t not in self.vertList: self.add_vertex(t) self.vertList[f].add_neighbor(self.vertList[t], cost)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(self, from_vert, to_vert, cost=0):\n # if either vertex is not in the graph,\n # add it - or return an error (choice is up to you).\n if from_vert not in self.vert_dict or to_vert not in self.vert_dict:\n raise ValueError('vertexes not in graph')\n # if both vert...
[ "0.81555176", "0.7938907", "0.77647465", "0.74405533", "0.7125969", "0.70987654", "0.68346786", "0.66708326", "0.6610537", "0.6392", "0.6333117", "0.6313288", "0.6265009", "0.62324244", "0.62289715", "0.62094367", "0.61935675", "0.6127964", "0.60952795", "0.60770154", "0.6071...
0.8099589
1
Return all the vertices in the graph.
def get_vertices(self): return self.vertList.keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vertices(self):\n return list(self._graph)", "def vertices(self):\n return list(self.__graph.values())", "def get_vertices(self):\n return self.graph.keys()", "def vertices(self):\n return list(self.graph_dict.keys())", "def vertices(self):\n return list(self.__graph_...
[ "0.8706675", "0.8674397", "0.8478822", "0.840716", "0.8383381", "0.8383381", "0.8383381", "0.8362319", "0.8341675", "0.8071636", "0.7987539", "0.79845595", "0.7951315", "0.79113555", "0.7865437", "0.7835449", "0.78261626", "0.7816375", "0.7802192", "0.7802192", "0.77639514", ...
0.7850983
15
Determine if there is a path between two vertices.
def recursive_dfs(self, start, end, visited=None, path=None): # initialize path list with starting vertice if path is None: path = [start] # initialize empty set for visited vertices if visited is None: visited = set() # add starting vertice to visi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasPath(startVert, endVert, sequencer):\n visited = set()\n sequencer.push(startVert)\n while (not sequencer.empty()):\n current = sequencer.pop()\n visited.add(current)\n print(\"Visting \" + str(current.id))\n for n in current.getConnections():\n if n == endVer...
[ "0.687942", "0.6865227", "0.6710185", "0.6621746", "0.6495376", "0.64039665", "0.63928294", "0.6295403", "0.6287663", "0.62835413", "0.62648916", "0.6257415", "0.6226418", "0.6226382", "0.6219081", "0.6215127", "0.61870575", "0.61768514", "0.6138194", "0.6120575", "0.60924983...
0.55881643
81
Returns true if both objects are equal
def __eq__(self, other): return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.7961088", "0.7961088", "0.79433626", "0.79303336", "0.7926563", "0.7897525", "0.78826123", "0.78826123", "0.78806067", "0.7872423", "0.7868354", "0.78668815", "0.7825702", "0.7819993", "0.78162885", "0.78078854", "0.78068...
0.79670393
35
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
Load data and return Dataset objects for training and validating.
def get_dataset(self, data_path, n_workers=4, dataset_args={}): self.logging.info('loading dataset...') dataset = pd.read_csv(data_path) self.logging.info('preprocessing data...') results = [None] * n_workers with Pool(processes=n_workers) as pool: for i in range(n_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_dataset(self):\n # Get all the files in the directory\n file_list = self.get_file_list()\n\n # Concatenate the data corresponding to a list of files\n data = self.concatenate_file_data(file_list)\n\n # Shuffle the data and create the training and the validation datasets\...
[ "0.8116993", "0.7780721", "0.75597894", "0.75477153", "0.73667055", "0.73014957", "0.72824913", "0.72512954", "0.71787035", "0.71748686", "0.71559614", "0.7153813", "0.7134497", "0.7104953", "0.70674026", "0.70634717", "0.70624524", "0.7053215", "0.7049435", "0.70115674", "0....
0.0
-1
GET request to /api/v2/servers to get all servers
def servers(self): response = self._request("GET", [ROUTE_SERVERS]) return CBWParser().parse_response(CBWServer, response)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_servers():\n (code, message) = rest_api.list_servers(request)\n if (code == 200):\n return message\n else:\n abort(code)", "def get_servers(self) -> dict:\n uri = f\"{self.uri}/servers\"\n\n response = self.request(uri=uri)\n return response.json()", "def ge...
[ "0.832044", "0.8135436", "0.8055369", "0.749047", "0.74896616", "0.74704003", "0.7418067", "0.7289873", "0.7206504", "0.7200865", "0.7195906", "0.7192097", "0.71790075", "0.7141795", "0.709646", "0.7072672", "0.6908644", "0.68852955", "0.67807955", "0.67323905", "0.6666638", ...
0.71263945
14
GET request to /api/v2/server/{server_id} to get all informations about a specific server
def server(self, server_id): response = self._request("GET", [ROUTE_SERVERS, server_id]) if response.status_code != 200: logging.error("Error server id::{}".format(response.text)) return None return CBWParser().parse_response(CBWServer, response)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_server(self, server_id):\n url = '%s/servers/%s' % (self.catalog['compute'], server_id)\n res = self.get(url)\n if res['status'] == 200:\n return json.loads(res['body'])['server']\n else:\n LOG.error('Get server failed: %s %s %s' %\n (r...
[ "0.7405415", "0.7087175", "0.68751466", "0.6661089", "0.6576766", "0.6482438", "0.64481646", "0.64326775", "0.64043695", "0.64033234", "0.6369384", "0.6366731", "0.6296371", "0.6280218", "0.62742716", "0.6261017", "0.6245498", "0.61879706", "0.61651933", "0.60891277", "0.6086...
0.6715954
3
Sets the max allowable participants
def set_max_participants(self, max_part): self.max_participants = max_part
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_players(self, max_players):\n\n self._max_players = max_players", "def setMaxCandidates(self, candidates):\n return self._set(maxCandidates=candidates)", "def setMaxCandidates(self, candidates):\n return self._set(maxCandidates=candidates)", "def setMaxValue(self, max_value):\r\n...
[ "0.7484293", "0.6578943", "0.6578943", "0.6537929", "0.6537929", "0.64257014", "0.6356992", "0.63023955", "0.62820035", "0.62732345", "0.62456214", "0.6225278", "0.6191366", "0.61809814", "0.617582", "0.6083743", "0.60765886", "0.60754573", "0.6060524", "0.6059108", "0.605522...
0.8456677
0
Strip outer quotes from a string. Applies to both single and double quotes.
def strip_quotes(arg): quote_chars = '"' + "'" if len(arg) > 1 and arg[0] == arg[-1] and arg[0] in quote_chars: arg = arg[1:-1] return arg
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Unquote(s):\n if not hasattr(s, 'strip'):\n return s\n # Repeated to handle both \"'foo'\" and '\"foo\"'\n return s.strip(\"\\\"'\")", "def _Unquote(s):\n if not hasattr(s, 'strip'):\n return s\n # Repeated to handle both \"'foo'\" and '\"foo\"'\n return s.strip(\"'\").strip('\"').strip(\"'\")",...
[ "0.79755175", "0.7957222", "0.7662394", "0.75404954", "0.74909854", "0.7336405", "0.72530156", "0.7235366", "0.711229", "0.7094287", "0.696834", "0.6924755", "0.69210017", "0.69210017", "0.69210017", "0.690204", "0.690204", "0.690204", "0.6901022", "0.68979496", "0.6868945", ...
0.6347611
33
Get the contents of the clipboard / paste buffer.
def get_paste_buffer(): pb_str = pyperclip.paste() # If value returned from the clipboard is unicode and this is Python 2, convert to a "normal" Python 2 string first if six.PY2 and not isinstance(pb_str, str): import unicodedata pb_str = unicodedata.normalize('NFKD', pb_str).encode('ascii'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clipboard(self, text = None):\n if text == None:\n response = self._fetch_json('/api/clipboard')\n return response['content']\n else:\n postdata = codecs.encode(json.dumps({ 'content': text }), 'utf-8')\n self._urlopen('/api/clipboard', postdata).read()...
[ "0.7332484", "0.72790986", "0.7133488", "0.7031157", "0.7030076", "0.66709864", "0.65963674", "0.6522888", "0.63931507", "0.63146365", "0.6308649", "0.6210226", "0.61088854", "0.59915024", "0.5963362", "0.5954509", "0.59187514", "0.59008753", "0.5876018", "0.58748734", "0.582...
0.76290387
0
Strip ANSI escape codes from a string.
def strip_ansi(text): return ANSI_ESCAPE_RE.sub('', text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _strip_ansi(s):\n if isinstance(s, str):\n return _ansi_codes.sub(r\"\\4\", s)\n else: # a bytestring\n return _ansi_codes_bytes.sub(r\"\\4\", s)", "def strip_raw_ansi(string, parser=ANSI_PARSER):\n string = string or \"\"\n return parser.strip_raw_codes(string)", "def strip_raw_...
[ "0.8525956", "0.8257456", "0.82143426", "0.82040006", "0.81820434", "0.8049878", "0.8030079", "0.77774423", "0.77300346", "0.74179214", "0.73302376", "0.7270576", "0.7101415", "0.6842106", "0.66740614", "0.66071475", "0.6541381", "0.6536013", "0.6453219", "0.63960695", "0.638...
0.8535748
0
Accessor to get the current script directory from the _script_dir LIFO queue.
def _current_script_dir(self): if self._script_dir: return self._script_dir[-1] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getScriptDirectory():\n\n\treturn os.path.dirname(os.path.realpath(__file__))", "def get_script_directory():\n return os.path.dirname(__file__)", "def GetScriptDirectory() -> str:\n if (hasattr(GetScriptDirectory, \"dir\")):\n return GetScriptDirectory.dir\n module_path: str = GetScriptFile()\n Ge...
[ "0.7152366", "0.712127", "0.7100194", "0.6892438", "0.6779655", "0.6723403", "0.6565851", "0.6562781", "0.652548", "0.65118146", "0.6499957", "0.64529073", "0.6448527", "0.639724", "0.6397051", "0.63914603", "0.6387291", "0.6386536", "0.6361351", "0.6315788", "0.6313391", "...
0.8158665
0
Initializes frame for parameters/buttons
def init_parameters_frame(self, height=400, width=200): self.frames["parameters"] = Frame( master=self.window, width=width, height=height, bg="pink") self.frames["parameters"].pack( anchor="ne", side=RIGHT, expand=False,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,*args, **kwargs):\n tk.Tk.__init__(self, *args, **kwargs)\n self.winfo_toplevel().title(\"ElogQP\")\n self.container = tk.Frame(self)\n self.container.pack(side=\"top\", fill=\"both\", expand=True)\n self.container.grid_rowconfigure(0, weight=1)\n self.co...
[ "0.7462009", "0.7415046", "0.734221", "0.7220271", "0.7160466", "0.7113897", "0.70746833", "0.7073183", "0.70695674", "0.7059481", "0.7052768", "0.70360947", "0.69851327", "0.68332344", "0.67845666", "0.6777233", "0.6764408", "0.6758201", "0.6735228", "0.67245203", "0.6718724...
0.76263756
0
Generates two density queries which are not similar to each other.
def generate_density_queries_pair(similar=False): q1 = generate_random_density_query() if similar: q2 = generate_similar_density_query(q1) else: q2 = generate_not_similar_density_query(q1) return q1, q2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dists_2():\n d1 = Distribution(['0', '1'], [1 / 2, 1 / 2])\n d2 = Distribution(['0', '1'], [1 / 3, 2 / 3])\n d3 = Distribution(['0', '1'], [2 / 5, 3 / 5])\n return d1, d2, d3", "def __generate_queries(self):\n\n for (f, dist) in self.__dists.iteritems():\n if f not in FISHIN...
[ "0.626035", "0.6107668", "0.6008311", "0.5494781", "0.53858054", "0.5263993", "0.5228691", "0.5201325", "0.5159462", "0.51556396", "0.5126433", "0.50790685", "0.5066997", "0.505448", "0.5052287", "0.50179684", "0.50027406", "0.5002614", "0.49961615", "0.49902079", "0.4983114"...
0.732192
0
Generates two density queries which are not similar to each other.
def generate_mobility_queries_pair(similar=False): q1 = generate_random_mobility_query() if similar: q2 = generate_similar_mobility_query(q1) else: q2 = generate_not_similar_mobility_query(q1) return q1, q2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_density_queries_pair(similar=False):\n q1 = generate_random_density_query()\n if similar:\n q2 = generate_similar_density_query(q1)\n else:\n q2 = generate_not_similar_density_query(q1)\n\n return q1, q2", "def get_dists_2():\n d1 = Distribution(['0', '1'], [1 / 2, 1 / 2...
[ "0.7322631", "0.6261157", "0.61063", "0.6007514", "0.5495488", "0.5384312", "0.52653694", "0.52283233", "0.5199834", "0.5158189", "0.5155603", "0.5127584", "0.50780857", "0.50549906", "0.50516164", "0.50188404", "0.5006239", "0.50028616", "0.4995033", "0.49885193", "0.4981024...
0.5068079
13
Generate a random int timestamp between the provided timestamps
def generate_random_timestamp(min_timestamp=Constants.MIN_TIMESTAMP, max_timestamp=Constants.MAX_TIMESTAMP): return random.randint(min_timestamp, max_timestamp)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _random_datetime(since):\n epoch = datetime.fromtimestamp(0)\n lower_delta = since - epoch\n lower = int(lower_delta.total_seconds())\n\n now = datetime.now()\n upper_delta = now - epoch\n upper = int(upper_delta.total_seconds())\n\n seconds = randint(lower, upper)\n return datetime.fro...
[ "0.7029006", "0.69661593", "0.68813145", "0.64893776", "0.6368546", "0.63412136", "0.6341121", "0.6333474", "0.6264837", "0.6177537", "0.6107458", "0.609159", "0.6033067", "0.6023125", "0.60208046", "0.6006706", "0.59331435", "0.59228295", "0.59022355", "0.58906204", "0.58900...
0.7932244
0
Generate a random int timestamp similar to the given timestamp and between the provided timestamps
def generate_similar_timestamp(timestamp, min_timestamp=Constants.MIN_TIMESTAMP, max_timestamp=Constants.MAX_TIMESTAMP): # 60 minutes in second similarity_threshold = 60 * 60 min_timestamp = max(min_timestamp, timestamp - similarity_threshold) max_timestamp = min(max_time...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_random_timestamp(min_timestamp=Constants.MIN_TIMESTAMP, max_timestamp=Constants.MAX_TIMESTAMP):\n return random.randint(min_timestamp, max_timestamp)", "def _random_datetime(since):\n epoch = datetime.fromtimestamp(0)\n lower_delta = since - epoch\n lower = int(lower_delta.total_seconds(...
[ "0.784182", "0.69283235", "0.66820943", "0.6668453", "0.64202344", "0.63527846", "0.6268318", "0.6263775", "0.6223709", "0.60544354", "0.6037402", "0.59691423", "0.5941428", "0.5922643", "0.5902467", "0.5882412", "0.58675396", "0.5858729", "0.58331555", "0.5831302", "0.582064...
0.69605744
1
Compute the Discounted Cumulative Gain of a series of recommended items with rating scores.
def _dcg(scores, discount=np.log2): scores = np.nan_to_num(scores) ranks = np.arange(1, len(scores) + 1) disc = discount(ranks) np.maximum(disc, 1, out=disc) np.reciprocal(disc, out=disc) return np.dot(scores, disc)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discounted_cumulative_gain(ranked_list):\n total_ndcg = 0\n for query in ranked_list:\n relevances = [doc[0] for doc in query[1]]\n dcg = 0\n for i, rel in enumerate(relevances, 1):\n dcg += rel / (math.log(i + 1, 2))\n\n idcg = 0\n for i, rel in enumerate(so...
[ "0.7140949", "0.6682643", "0.63027865", "0.6263653", "0.60823876", "0.6030573", "0.599664", "0.59080356", "0.589579", "0.5892739", "0.5864455", "0.58614224", "0.58057463", "0.5770774", "0.575941", "0.5752604", "0.5738931", "0.5734317", "0.57252234", "0.5686617", "0.567849", ...
0.62211627
4
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.Blues): if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] print("Normalized confusion matrix") el...
{ "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.8194366", "0.8095442", "0.8029135", "0.8019134", "0.7993755", "0.7991176", "0.79808146", "0.79755133", "0.79609716", "0.7956584", "0.79375756", "0.79346216", "0.79343396", "0.7931212", "0.7926087", "0.7924503", "0.7923946", "0.79228765", "0.79227114", "0.7921956", "0.79178...
0.7832058
62
Check to see if there are any overlaps in the index values of the provided catalogs. Search only by looking at the minimum and maximum index values, rather than searching through all the individual values.
def catalog_index_check(catalogs): min_indexes = [] max_indexes = [] for catalog in catalogs: cat = ascii.read(catalog) if 'index' in cat.colnames: # Collect the min and max index values from each catalog min_val = np.min(cat['index']) min_indexes.append(m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overlaps(*objs):\n return set.intersection(*(set(range(*extent(obj))) for obj in objs))", "def overlap(start_idx1, end_idx1, start_idx2, end_idx2):\n head = min(end_idx1, end_idx2)\n tail = max(start_idx1, start_idx2)\n return head >= tail", "def check_overlaps(self, verbose = False):\n ...
[ "0.57202655", "0.5706212", "0.5618981", "0.54261047", "0.5413789", "0.53981864", "0.53752476", "0.53705484", "0.53575766", "0.5348791", "0.5329601", "0.53224546", "0.53055763", "0.53034586", "0.52880293", "0.52752215", "0.5256585", "0.5222712", "0.5217846", "0.5210434", "0.51...
0.76815045
0
Update a `QAction` that was generated by this `MenuAction` instance. This is called by the default implementation of `Build`, and may also be called by the owner of a persistent menu immediately before it is shown. It can be used to update things like the enabled state, text, or even visibility of the given action. The...
def Update(self, action, context): # type: (QtWidgets.QAction, MenuContext) -> None pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Build(self, context):\n # type: (MenuContext) -> Optional[QAction]\n text = self.defaultText\n if text is None:\n text = self.__class__.__name__\n action = QtWidgets.QAction(text, None)\n self.Update(action, context)\n action.triggered.connect(self.Do)\n ...
[ "0.6446167", "0.5951892", "0.5892006", "0.5827871", "0.57709813", "0.5738602", "0.5678311", "0.5654069", "0.5627558", "0.56208146", "0.5489779", "0.54451483", "0.5416908", "0.5384261", "0.5328167", "0.532301", "0.5322236", "0.53034735", "0.53034735", "0.5292444", "0.52739495"...
0.7201854
0
Because we use HTML5 history mode in vuerouter we need to configure our web server to redirect all routes to index.html. Hence the additional route
def index(path): return render_template('index.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def homepage():\n return redirect('index.html')", "def index_file():\n return redirect(\"/\")", "def index():\n return redirect('/client/index.html')", "def home_page():\n return redirect(url_for(_DEFAULT_ROUTE, _external=True))", "def redir_index():\n return redirect(url_for(\"index\"),...
[ "0.6608449", "0.66077024", "0.66024274", "0.6342767", "0.6298567", "0.6155883", "0.61184764", "0.61078304", "0.61075735", "0.59514105", "0.5949693", "0.5937267", "0.59368885", "0.591341", "0.5890894", "0.5888327", "0.5883557", "0.5872738", "0.5852941", "0.5851366", "0.5834782...
0.5622965
44
Add headers to both force latest IE rendering engine or Chrome Frame, and also tell the browser not to cache the rendered page. If we wanted to we could change maxage to 600 seconds which would be 10 minutes.
def add_header(response): response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1' response.headers['Cache-Control'] = 'public, max-age=0' return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response", "def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m...
[ "0.81432986", "0.812109", "0.812109", "0.812109", "0.812109", "0.803714", "0.8035959", "0.8009991", "0.7974017", "0.7764198", "0.77463835", "0.75872964", "0.74564224", "0.73922783", "0.738567", "0.738567", "0.7368146", "0.73529303", "0.73529303", "0.73529303", "0.73529303", ...
0.7994953
21
Converts user parameter dictionary to a string.
def compute_command(self, user_parameters: Optional[Dict[str, Any]]) -> List[str]: command_arr = [] command_arr += self.command extras = compute_command_args(user_parameters) command_arr += extras return command_arr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def param_dict_to_str(data):\n if data is None or not data:\n return \"\"\n pairs = []\n for key, val in data.items():\n if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val):\n pairs.append(str(key) + '=' + ','.join(map(str, val)))\n elif isinstance(val, string_...
[ "0.68020713", "0.6600403", "0.6520624", "0.63801265", "0.6254389", "0.6199523", "0.6151171", "0.5955291", "0.59421694", "0.5890664", "0.5830965", "0.580284", "0.577138", "0.57623863", "0.57369596", "0.5736245", "0.5691579", "0.56601644", "0.56535876", "0.5623264", "0.5622592"...
0.0
-1
Adjust the lower and upper bounds to the yaxis.
def adjust_ylimits(self, ylim1, ylim2): self.axplot.set_ylim(ylim1, ylim2) self.fig.canvas.draw() return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetYAxisRange(self, lower, upper):\n self.Y_AXIS_RANGE = (lower, upper)", "def ylim(self, bottom=None, top=None):\r\n for ax in self._subaxes:\r\n ax.set_ylim(bottom, top)\r\n self.figure.canvas.draw()", "def __draw_yaxis(self):\n self.ax.set_ylim(self.ylims)\n ...
[ "0.8013682", "0.7422078", "0.7388042", "0.7207114", "0.7163399", "0.7000254", "0.69266695", "0.68889093", "0.68231714", "0.67788714", "0.6693616", "0.6666954", "0.6657536", "0.665144", "0.6632028", "0.660464", "0.6594559", "0.65899146", "0.65888214", "0.65694225", "0.6527316"...
0.76034236
1
Checks to see if the user is a staff member.
async def is_staff(ctx): member = ctx.message.author vipRole = discord.utils.get(member.guild.roles, name=ROLE_VIP) staffRole = discord.utils.get(member.guild.roles, name=ROLE_STAFF) return vipRole in member.roles or staffRole in member.roles
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_staff(self):\n # Simplest possible answer: All admins are staff\n return self.is_admin", "def is_staff(self):\n # Simplest possible answer: All admins are staff\n return self.is_admin", "def is_staff(self):\n # Simplest possible answer: All admins are staff\n re...
[ "0.81636894", "0.81636894", "0.81636894", "0.78609914", "0.7858195", "0.778355", "0.7629685", "0.7629685", "0.7559951", "0.75453466", "0.74719906", "0.74719906", "0.7244043", "0.7167727", "0.69918877", "0.6971516", "0.69483817", "0.6911305", "0.68746865", "0.6838627", "0.6775...
0.75449467
10
Checks to see if the user is an administrator, or pepperonipi (for debugging purposes).
async def is_admin(ctx): member = ctx.message.author aRole = discord.utils.get(member.guild.roles, name=ROLE_AD) if aRole in member.roles or member.id == 715048392408956950: return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_admin() -> bool:\n return ctypes.windll.shell32.IsUserAnAdmin() == 1", "def is_admin():\n if platform_is(WINDOWS):\n return windll.shell32.IsUserAnAdmin()\n return os.getuid() == 0", "def is_current_user_admin():\n return (os.environ.get('USER_IS_ADMIN', '0')) == \"1\"", "def i...
[ "0.77826303", "0.77197105", "0.76691693", "0.74429035", "0.743436", "0.7433688", "0.74063915", "0.74010384", "0.7377382", "0.73417443", "0.73129153", "0.724538", "0.7178173", "0.7156049", "0.7130814", "0.71301144", "0.71231866", "0.7115062", "0.7045045", "0.70398754", "0.7036...
0.628323
100
Fetches a local variable.
async def getVariable(ctx, var): if ctx.message.channel.name != "staff": await ctx.send("You can only fetch variables from the staff channel.") else: await ctx.send("Attempting to find variable.") try: variable = globals()[var] await ctx.send(f"Variable value: `{v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Lookup(self, var_name):\n if var_name in self._local_scope.get(\"vars\", {}):\n return self._local_scope[\"vars\"][var_name]\n raise Error(\"Var is not defined: %s\" % var_name)", "def getVariable(self, varName):\n return self[varName]", "def get_variable(self, name):\n if se...
[ "0.6282528", "0.6197359", "0.6158163", "0.60280156", "0.60036874", "0.5961294", "0.5923774", "0.5858673", "0.5858495", "0.58546203", "0.5797934", "0.5786714", "0.5690825", "0.56476367", "0.5575946", "0.555827", "0.55154604", "0.55059695", "0.5460306", "0.5429531", "0.5413694"...
0.63695765
0
Gets a specified rule.
async def rule(ctx, num): if not num.isdigit() or int(num) < 1 or int(num) > 13: # If the rule number is not actually a number return await ctx.send("Please use a valid rule number, from 1 through 13. (Ex: `!rule 7`)") rule = RULES[int(num) - 1] return await ctx.send(f"**Rule {num}:**\n> {ru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self....
[ "0.8234092", "0.8234092", "0.8234092", "0.8163488", "0.8064481", "0.79768854", "0.77808666", "0.77257913", "0.74625707", "0.7350825", "0.7242397", "0.72393745", "0.72393745", "0.72393745", "0.72251916", "0.72251916", "0.72251916", "0.72251916", "0.72251916", "0.72251916", "0....
0.0
-1
Gets information about the Discord server.
async def info(ctx): server = ctx.message.guild name = server.name owner = server.owner creation_date = server.created_at emoji_count = len(server.emojis) icon = server.icon_url_as(format=None, static_format='jpeg') animated_icon = server.is_icon_animated() iden = server.id banner = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def server_info(self, ctx):\n guild = ctx.guild\n id = guild.id\n boost_count = guild.premium_subscription_count\n region = str(guild.region)\n channels = len(guild.channels)\n vc = len(guild.voice_channels)\n text_channels = len(guild.text_channels)\n ...
[ "0.7374063", "0.7349971", "0.73105836", "0.72417825", "0.702675", "0.70220697", "0.70193595", "0.6977229", "0.6934592", "0.6877646", "0.6863981", "0.68049455", "0.67849076", "0.6541167", "0.65392154", "0.6524746", "0.65146196", "0.6500442", "0.64805245", "0.64462525", "0.6435...
0.6317448
25
Nukes (deletes) a specified amount of messages.
async def nuke(ctx, count): global STOPNUKE launcher = await is_launcher(ctx) staff = await is_staff(ctx) if not (staff or (launcher and ctx.message.channel.name == "welcome")): return await ctx.send("APOLOGIES. INSUFFICIENT RANK FOR NUKE.") if STOPNUKE: return await ctx.send("TRANSM...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def prune(self, ctx, n=1):\n n = abs(n)\n if n > Commands.prune_cutoff:\n await ctx.channel.send('You can only delete up to 25 messages at a time.')\n return\n log.debug(f'Purging {n + 1} message(s)...') # Includes the invoking command\n await ctx.message.re...
[ "0.7242481", "0.67458445", "0.67105925", "0.66956913", "0.666256", "0.6656966", "0.6582755", "0.65554804", "0.6535946", "0.64750266", "0.64203185", "0.64002514", "0.6299361", "0.6289064", "0.62514037", "0.6226753", "0.61557156", "0.61544573", "0.61464554", "0.61300427", "0.60...
0.68249834
1
The horizontal space between an entity and the left edge of the page.
def _space_between_left_edge(doc: Document, E: Entity) -> Optional[DocRegion]: page = get_page_for_edge(E, doc) return DocRegion.build(doc, BBox.build( Interval(page.bbox.ix.a, E.bbox.ix.a), _erode_if_possible( E.bbox.iy, IMPINGEMENT_SMALL_INSET * doc.median_line_height())))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPageLeft(self):\n return self.pageLeft", "def _rect_left(self):\n\treturn min(self.x, self.x + self.w)", "def horizontal_spacing(self):\r\n return self.padding[1] + self.padding[3] + self.margin[1] + self.margin[3]", "def content_box_x(self):\n return self.position_x + self.margin...
[ "0.6990067", "0.6796582", "0.6639866", "0.6550536", "0.6547043", "0.643085", "0.643085", "0.64268494", "0.64018106", "0.636391", "0.6330698", "0.6305356", "0.62988096", "0.6279434", "0.62358093", "0.62358093", "0.6171656", "0.6134644", "0.6119471", "0.61188674", "0.6017223", ...
0.66133153
3
The horizontal space between an entity and the right edge of the page.
def _space_between_right_edge(doc: Document, E: Entity) -> Optional[DocRegion]: page = get_page_for_edge(E, doc) return DocRegion.build(doc, BBox.build( Interval(E.bbox.ix.b, page.bbox.width), _erode_if_possible( E.bbox.iy, IMPINGEMENT_SMALL_INSET * doc.median_line_height())))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def right(self):\n return self.left + self.width", "def _rect_right(self):\n\treturn max(self.x, self.x + self.w)", "def getPageRight(self):\n return self.pageRight", "def get_rightmost_edge(self):\n return self.offset + sum(self.get_screen_widths())", "def horizontal_spacing(self):\r\...
[ "0.6572433", "0.6389865", "0.63344884", "0.6279485", "0.6126712", "0.6108872", "0.59996796", "0.59828264", "0.59828264", "0.59766185", "0.59739935", "0.59156734", "0.582312", "0.58110094", "0.57845926", "0.5759085", "0.5740926", "0.5739169", "0.5717295", "0.57119334", "0.5702...
0.6546419
1
Move ball position according to the current direction
def move_ball(): print("Current position: ({},{}). " "Direction: ({},{}). Value: {}".format(shared.ball_yy, shared.ball_xx, shared.direction[0], shared.direction[1], map_data[shared.ball_yy][shared.ball_xx]))...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self):\n if self.ycor() > 280: self.y_dir = -1 # Set vertical movement to down if ball at top of screen\n if self.xcor() > 380: self.x_dir = -1 # Set horizontal movement to left if ball at right of screen\n if self.xcor() < -380: self.x_dir = 1 # Set hori...
[ "0.85741615", "0.8453514", "0.82014763", "0.77658385", "0.7371728", "0.731131", "0.72773653", "0.7249165", "0.72425276", "0.72403663", "0.7158736", "0.71465284", "0.71406645", "0.71365607", "0.71226984", "0.7121108", "0.7103065", "0.7095952", "0.7062961", "0.7048452", "0.6986...
0.8311792
2
Apply layer to tensor x.
def __call__(self, x): if self._padding != 'REFLECT': padding = self._padding else: padding = 'VALID' pad_top = self.w[0] // 2 pad_left = self.w[1] // 2 if (self.w[0] - self._stride[1]) % 2 == 0: pad_bottom = pad_top else: pad_bottom = self.w[0] - self._stride...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, x: tf.Tensor) -> tf.Tensor:\n for layer in self._sublayers:\n x = layer(x)\n\n return x", "def call(self, x: tf.Tensor) -> tf.Tensor:\n\n x = self.embedding(x)\n x = self.rnn(x)\n x = self.linear(x)\n\n return x", "def forward_tensor(self, x):\n pass...
[ "0.750829", "0.69964874", "0.6932584", "0.6869508", "0.68576974", "0.6825599", "0.6764449", "0.6757813", "0.67571294", "0.6749962", "0.67284155", "0.6725965", "0.67200124", "0.6711085", "0.6693324", "0.6673406", "0.666248", "0.66616607", "0.6647635", "0.66247404", "0.65912163...
0.67860824
6
Apply layer to tensor x.
def __call__(self, x): x_shape = x.get_shape().as_list() batch_size = tf.shape(x)[0] stride_x, stride_y = self.stride[1], self.stride[2] output_shape = tf.stack([ batch_size, x_shape[1] * stride_x, x_shape[2] * stride_y, self.nc_out]) y = tf.nn.conv2d_transpose( x, filter=self._weight, o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, x: tf.Tensor) -> tf.Tensor:\n for layer in self._sublayers:\n x = layer(x)\n\n return x", "def call(self, x: tf.Tensor) -> tf.Tensor:\n\n x = self.embedding(x)\n x = self.rnn(x)\n x = self.linear(x)\n\n return x", "def forward_tensor(self, x):\n pass...
[ "0.750829", "0.69964874", "0.6932584", "0.6869508", "0.68576974", "0.6825599", "0.67860824", "0.6764449", "0.6757813", "0.67571294", "0.6749962", "0.67284155", "0.6725965", "0.67200124", "0.6711085", "0.6693324", "0.6673406", "0.666248", "0.66616607", "0.66247404", "0.6591216...
0.6647635
19
Apply layer to tensor x.
def __call__(self, x_init): x = x_init for f in self.blocks: x = f(x) return x + x_init
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, x: tf.Tensor) -> tf.Tensor:\n for layer in self._sublayers:\n x = layer(x)\n\n return x", "def call(self, x: tf.Tensor) -> tf.Tensor:\n\n x = self.embedding(x)\n x = self.rnn(x)\n x = self.linear(x)\n\n return x", "def forward_tensor(self, x):\n pass...
[ "0.750829", "0.69964874", "0.6932584", "0.6869508", "0.68576974", "0.6825599", "0.67860824", "0.6764449", "0.6757813", "0.67571294", "0.6749962", "0.67284155", "0.6725965", "0.67200124", "0.6711085", "0.6693324", "0.6673406", "0.666248", "0.66616607", "0.6647635", "0.66247404...
0.0
-1
Apply layer to tensor x.
def __call__(self, x_init): x1 = x_init x2 = x_init for f in self.path1_blocks: x1 = f(x1) for f in self.path2_blocks: x2 = f(x2) return x1 + x2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, x: tf.Tensor) -> tf.Tensor:\n for layer in self._sublayers:\n x = layer(x)\n\n return x", "def call(self, x: tf.Tensor) -> tf.Tensor:\n\n x = self.embedding(x)\n x = self.rnn(x)\n x = self.linear(x)\n\n return x", "def forward_tensor(self, x):\n pass...
[ "0.750829", "0.69964874", "0.6932584", "0.6869508", "0.68576974", "0.6825599", "0.67860824", "0.6764449", "0.6757813", "0.67571294", "0.6749962", "0.67284155", "0.6725965", "0.67200124", "0.6711085", "0.6693324", "0.6673406", "0.666248", "0.66616607", "0.6647635", "0.66247404...
0.0
-1
Apply layer to tensor x.
def __call__(self, x): return self._pre_scale * tf.matmul(x, self._weight) + self._bias
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, x: tf.Tensor) -> tf.Tensor:\n for layer in self._sublayers:\n x = layer(x)\n\n return x", "def call(self, x: tf.Tensor) -> tf.Tensor:\n\n x = self.embedding(x)\n x = self.rnn(x)\n x = self.linear(x)\n\n return x", "def forward_tensor(self, x):\n pass...
[ "0.750829", "0.69964874", "0.6932584", "0.6869508", "0.68576974", "0.6825599", "0.67860824", "0.6764449", "0.6757813", "0.67571294", "0.6749962", "0.67284155", "0.6725965", "0.6711085", "0.6693324", "0.6673406", "0.666248", "0.66616607", "0.6647635", "0.66247404", "0.65912163...
0.67200124
13
Convert a string to a safe filename.
def str_to_filename(s: str, maxlen=None) -> str: if maxlen is None: maxlen = 255 - 16 # 255 FAT - room for extension s_no_sub = unicodedata.normalize('NFKD', s) s = _re_str_to_filename.sub('_', s_no_sub) if len(s) > maxlen: h = hashlib.sha256(s_no_sub.encode('utf-8')).hexdigest() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_to_filename(input_string: str):\n return slugify(input_string)", "def format_filename(s: str):\n # from: https://gist.github.com/seanh/93666\n\n valid_chars = \"-_.() %s%s\" % (string.ascii_letters, string.digits)\n filename = ''.join(c for c in s if c in valid_chars)\n filename = filename...
[ "0.7832002", "0.77278346", "0.749776", "0.749776", "0.749776", "0.7426424", "0.73734546", "0.733704", "0.71193343", "0.7094417", "0.7044727", "0.70322144", "0.6983099", "0.69826835", "0.6891689", "0.6883865", "0.68706006", "0.6843837", "0.67678", "0.6735116", "0.6731444", "...
0.7671253
2
Converts counts to indices. This is the inverse operation of scatter_count
def scatter_counts_to_indices(input: torch.LongTensor) -> torch.LongTensor: return torch.repeat_interleave(torch.arange(input.size(0), device=input.device), input).long()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_unary_set_mappings(indexing, counts): \n ret = np.zeros_like(indexing)-1\n for vertex,index in enumerate(indexing):\n if counts[index] == 1:\n ret[index] = vertex\n return ret", "def compute_binary_set_mappings(indexing, counts): \n ret = np.zeros_like(indexing)-1\...
[ "0.6258708", "0.6212546", "0.61660045", "0.6080629", "0.60627335", "0.5984984", "0.59512186", "0.59200454", "0.57948714", "0.57655746", "0.57298225", "0.57147497", "0.56837344", "0.5600481", "0.5600481", "0.5592528", "0.557361", "0.55516505", "0.5532562", "0.5529932", "0.5506...
0.75839335
0
Shows the ratio of predictions that achieved a precision greater than the supplied threshold
def precision_threshold(predictions, targets, threshold=0.7): number_of_examples_meeting_threshold = 0 for pred, targ in zip(predictions, targets): total_positive_guesses = sum(pred) correct_positive_guesses = 0 for shift_pred, shift_targ in zip(pred, targ): if shift_pred =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(ground_truth, prediction):\n ground_truth = remove_duplicates(ground_truth)\n prediction = remove_duplicates(prediction)\n precision_score = count_a_in_b_unique(prediction, ground_truth) / float(len(prediction))\n assert 0 <= precision_score <= 1\n return precision_score", "def preci...
[ "0.73713857", "0.7326005", "0.7317521", "0.7254578", "0.72287244", "0.7220914", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7204447", "0.7197789", "0.7197789", "0.7197789", "0.7197789", "0.7197789", "0.7197789", ...
0.77818763
0
This should get all words from the text. This method is responsible for lowercasing all words and stripping them of punctuation.
def extract_words(self): str = self.text.lower() words = re.sub(r'[?|—|:|"|,|\.\n|\.|\s|\n|\t|\v|\f|\r]+', "*", str) self.word_list = words.split("*")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_text(text):\n words = word_tokenize(text)\n return [word.lower() for word in words if word not in string.punctuation]", "def clean_text(self, text):\n words = SPLIT_TEXT.findall(text.lower())\n words = self.rm_stop_words(words)\n words = self.stem_words(words)\n ...
[ "0.81362355", "0.7904954", "0.7810046", "0.7632565", "0.7607024", "0.75972295", "0.7543343", "0.74938256", "0.74501216", "0.74068254", "0.7396362", "0.73946667", "0.73268646", "0.7322516", "0.7310462", "0.7273161", "0.725799", "0.72322935", "0.7209044", "0.71942407", "0.71813...
0.741898
9
Removes all stop words from our word list. Expected to be run after extract_words.
def remove_stop_words(self): self.word_list = [word for word in self.word_list if len(word) > 1 and word not in STOP_WORDS] #The len(word) check is here because there's still one piece of white space I haven't pinned down in each file. I haven't taken the time to figure out a quick way to look at all the white...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)", "def stopword_removal(words):\n stops = set(stopwords.words('englis...
[ "0.8379723", "0.8268291", "0.8241843", "0.8225887", "0.81703335", "0.8129542", "0.8080629", "0.80641884", "0.8052243", "0.8045953", "0.8012266", "0.79979897", "0.79506147", "0.79506147", "0.79506147", "0.79506147", "0.79259765", "0.783701", "0.7822693", "0.7758379", "0.775175...
0.8530158
0
Create a FormattedDate from a datetime.date
def fromdate(cls, date_: date): if date_ is None: return None else: return cls(date_.year, date_.month, date_.day)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_formatted_date(self, date):\n\n formatted_date = date\n\n possible_datetime_formats = [\n \"%Y-%m-%dT%H:%M:%S%z\", # \"2021-10-19T16:46:02Z\"\n \"%a, %d %b %Y %H:%M:%S %z\", # \"Tue, 19 Oct 2021 21:00:13 +0300\"\n \"%a, %d %b %Y %H:%M:%S %Z\", # \"Tue, 19 O...
[ "0.75105226", "0.7335155", "0.7146537", "0.710537", "0.71032494", "0.7077393", "0.69872206", "0.69469094", "0.68488395", "0.6845103", "0.6815851", "0.679711", "0.67231643", "0.664133", "0.6637815", "0.65639555", "0.65451926", "0.65376145", "0.6527653", "0.65274876", "0.652496...
0.0
-1
Convert HSC flux in unit of ADU to AB magnitude.
def flux2Mag(flux, zeropoint=27.0): return -2.5 * np.log10(flux) + zeropoint
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AB_zero_mag(self):\n if self.wavelength_unit is None:\n raise AttributeError('Needs wavelength units')\n\n C1 = (Unit(self.wavelength_unit).to('AA') ** 2 /\n Constants.c.to('AA/s').value)\n c1 = self._lpivot ** 2 * C1\n\n m = 2.5 * np.log10(_drop_units(c1)) +...
[ "0.6325971", "0.6281677", "0.61960226", "0.6106466", "0.59703714", "0.58859956", "0.5879046", "0.5796231", "0.56803733", "0.56138915", "0.5561658", "0.55315495", "0.5528998", "0.55277675", "0.55133957", "0.5505683", "0.5465837", "0.54578924", "0.54525214", "0.54411465", "0.54...
0.5540428
11
Tests to see if tile game is solved.
def test_is_solved(self): p = hw.TilePuzzle([[1, 2], [3, 0]]) self.assertTrue(p.is_solved()) p = hw.TilePuzzle([[0, 1], [3, 2]]) self.assertFalse(p.is_solved())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_solved_when_puzzle_is_solved(self):\n self.assertTrue(self.sudoku.is_solved())", "def solve(self):\n if not self.running or self.state == \"stopping\":\n return False\n\n # Find first empty tile\n target = ()\n for i in range(9**2):\n if self.b...
[ "0.7680891", "0.73812664", "0.70443034", "0.7003503", "0.6975509", "0.69492555", "0.6902538", "0.6874634", "0.6710343", "0.661386", "0.6613593", "0.65717924", "0.656259", "0.6542567", "0.6531184", "0.6529685", "0.6519706", "0.64970666", "0.64829737", "0.64671296", "0.64606315...
0.8077936
0
Returns onehot encoded Variable
def to_categorical(y, num_columns): y_cat = numpy.zeros((y.shape[0], num_columns)) y_cat[range(y.shape[0]), y] = 1.0 return torch.autograd.Variable(torch.cuda.FloatTensor(y_cat))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output", "def one_hot_encode(x, n_classes):\n return np.eye(n_classes)[x]", "def one_hot(y_):\n y_ = y_.reshape(len(y_))\n ...
[ "0.8121293", "0.80437994", "0.80373216", "0.79746693", "0.79646856", "0.79440534", "0.79381895", "0.79274017", "0.78687656", "0.78521234", "0.78004986", "0.77972883", "0.778436", "0.77638763", "0.77571285", "0.7745554", "0.7730836", "0.77264756", "0.77055925", "0.77040774", "...
0.0
-1
Tokenizes a text and maps tokens to tokenids
def tokenize(self, texts: Union[List[str], List[Tuple[str, str]]]): if not isinstance(texts[0], dict): raise AttributeError("Asym. model requires that texts are passed as dicts: {'key': 'text'}") module_key = None for lookup in texts: text_key, text = next(iter(lookup....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ids(cls, text):\n tokens = TokenizerContainer.TOKENIZER.tokenize(text)\n token_ids = TokenizerContainer.TOKENIZER.convert_tokens_to_ids(tokens)\n input_ids = token_ids + [0] * (cls.MAX_LEN-len(token_ids))\n return tokens, input_ids", "def tokenize(text):\n global TOK\n t...
[ "0.7407736", "0.73601663", "0.72941417", "0.7202924", "0.713212", "0.7116175", "0.71030444", "0.7050334", "0.69642794", "0.6955619", "0.69235754", "0.6922563", "0.6842361", "0.68406314", "0.6824744", "0.6798709", "0.6782027", "0.6777919", "0.67726904", "0.67357945", "0.673165...
0.0
-1