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
Generate and return a random string.
def rand_string(length=32, exclude=None): if exclude is None: exclude = set() else: exclude = set(exclude) # remove lowercase L and uppercase o to avoid confusion with DIGITS lower_case = "abcdefghijkmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNPQRSTUVWXYZ" digits = "0123456789" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))", "def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec", "def __generate_random_string():\n return uuid4().hex[:6].upper()", "def g...
[ "0.8560595", "0.83566606", "0.81820285", "0.8018693", "0.78787684", "0.7789106", "0.77611697", "0.77582854", "0.7732269", "0.7725998", "0.7697216", "0.7693858", "0.7685521", "0.765691", "0.76533073", "0.7641071", "0.76245797", "0.76145595", "0.75938594", "0.75917804", "0.7585...
0.0
-1
retrieve the number of subscribers of a subreddit
def number_of_subscribers(subreddit): url = "https://www.reddit.com/r/{}/about.json".format(subreddit) headers = {"User-Agent": "my-integration/1.2.3"} response = get(url=url, headers=headers) if response.status_code == 200: # print(response.json()) response_json = response.json() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_subscribers(subreddit):\n header = {'User-Agent': 'Chrome/90.0.4430.212 Safari/537.36'}\n req = requests.get('https://www.reddit.com/r/{}/about.json'\n .format(subreddit), allow_redirects=False,\n headers=header)\n if req.status_code == 200:\n ...
[ "0.87893707", "0.87762237", "0.8750274", "0.8747642", "0.87215537", "0.87118036", "0.8690481", "0.86867094", "0.8682486", "0.86785024", "0.86742127", "0.86682785", "0.8634838", "0.8620241", "0.861384", "0.8574577", "0.8554686", "0.8531662", "0.8502006", "0.8491157", "0.837957...
0.86229396
13
Get runid for an experiment.
def get_runid(path): name = Path(path).name if not os.path.exists(Path(path).parent): return '00001' files = os.listdir(Path(path).parent) runid = 0 for f in files: try: id, val = f.split('_', 1) runid = max(runid, int(id)) except: pass ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_run_id(self):\n\t\tif self.have_metadata is False:\n\t\t\tself._get_metadata()\n\t\t\tself.have_metadata = True\n\n\t\ttry:\n\t\t\treturn self.keyinfo['tracking_id'].attrs['run_id']\n\t\texcept:\n\t\t\treturn None", "def run_id(self):\n if self._run_id is not None:\n return self._run_id...
[ "0.7490979", "0.7168973", "0.71110874", "0.7032822", "0.7032498", "0.6945545", "0.6422959", "0.6293841", "0.60468614", "0.6045846", "0.60357565", "0.603554", "0.596559", "0.5948923", "0.5894417", "0.586999", "0.5818017", "0.57944405", "0.5714358", "0.56367105", "0.56298614", ...
0.6122325
8
Fills the feed_dict. If the batch has fewer samples than the placeholder, it is padded with zeros.
def fill_feed_dict(img_batch, lbl_batch, images_ph, labels_ph, keep_prob_ph, is_training, crop): if img_batch.shape[0] < FLAGS.batch_size: # pad the remainder with zeros if is_training: # only pad for evaluation return None else: M = FLAGS.batch_size - img_batch.shape[0] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_feed_dict(self, inputs_batch, mask_batch, length_batch ,labels_batch=None,dropout=1):\n ### YOUR CODE (~6-10 lines)\n feed_dict = {}\n if labels_batch is not None:\n feed_dict[self.labels_placeholder] = labels_batch\n if inputs_batch is not None:\n feed_...
[ "0.6508451", "0.6506305", "0.6477034", "0.63315076", "0.6189684", "0.6050192", "0.6017698", "0.5935921", "0.58827037", "0.58556026", "0.58197844", "0.5800368", "0.5772726", "0.5748977", "0.5730423", "0.562262", "0.56177944", "0.5577941", "0.54708683", "0.54559416", "0.5453391...
0.69885147
0
Standardize input strings by making nonascii spaces be ascii, and by converting treebankstyle brackets/parenthesis be characters once more.
def normalize_string(string): return string.replace("\xa0", " ")\ .replace("\\", "")\ .replace("-LRB-", "(")\ .replace("-RRB-", ")")\ .replace("-LCB-", "{")\ .replace("-RCB-", "}")\ .rep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_string(string):\n return string.replace(u\"\\xa0\", \" \")\\\n .replace(\"\\\\\", \"\")\\\n .replace(\"-LRB-\", \"(\")\\\n .replace(\"-RRB-\", \")\")\\\n .replace(\"-LCB-\", \"{\")\\\n .replace(...
[ "0.6748723", "0.65540516", "0.6457333", "0.6452723", "0.6301455", "0.6299961", "0.62826407", "0.6277174", "0.6239982", "0.62362087", "0.6235443", "0.6213934", "0.61738104", "0.60826814", "0.6039613", "0.60315955", "0.59249365", "0.5903164", "0.5890551", "0.5861797", "0.585742...
0.67233497
1
Standardize input strings by making nonascii spaces be ascii, and by converting treebankstyle brackets/parenthesis be characters once more.
def normalize_string(string): return string.replace(u"\xa0", " ")\ .replace("\\", "")\ .replace("-LRB-", "(")\ .replace("-RRB-", ")")\ .replace("-LCB-", "{")\ .replace("-RCB-", "}")\ .re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_string(string):\n return string.replace(\"\\xa0\", \" \")\\\n .replace(\"\\\\\", \"\")\\\n .replace(\"-LRB-\", \"(\")\\\n .replace(\"-RRB-\", \")\")\\\n .replace(\"-LCB-\", \"{\")\\\n .replace(\...
[ "0.67221195", "0.6556024", "0.6459481", "0.64517695", "0.6303864", "0.63007694", "0.62836707", "0.6279229", "0.6241196", "0.62384444", "0.6237675", "0.62145656", "0.6173789", "0.6082146", "0.603995", "0.60321844", "0.5926097", "0.5902878", "0.5893448", "0.58624965", "0.585981...
0.67476076
0
Test that invalid ensembles raise errors.
def test_invalid_ensemble(ensemble: Any) -> None: mapie = MapieRegressor(ensemble=ensemble) with pytest.raises(ValueError, match=r".*Invalid ensemble.*"): mapie.fit(X_toy, y_toy)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_snmp_invalid_address():\n for command in snmp_commands:\n with pytest.raises(SNMPInvalidAddress) as excinfo:\n command(oid='some-irelevant-oid', community='public',\n ipaddress='invalid-hostname', )\n assert 'does not appear to be a valid' in str(excinfo.valu...
[ "0.7004704", "0.69955474", "0.6849044", "0.68303615", "0.6752097", "0.6744247", "0.6741358", "0.6691716", "0.6662502", "0.6653034", "0.6644101", "0.66314495", "0.66027105", "0.6597587", "0.6586666", "0.65835136", "0.65737927", "0.65631366", "0.65289795", "0.65210193", "0.6518...
0.70037544
1
Test that prediction intervals lower (upper) bounds give consistent results for ordered alphas.
def test_results_for_ordered_alpha(strategy: str) -> None: mapie = MapieRegressor(**STRATEGIES[strategy]) mapie.fit(X, y) y_pred, y_pis = mapie.predict(X, alpha=[0.05, 0.1]) assert (y_pis[:, 0, 0] <= y_pis[:, 0, 1]).all() assert (y_pis[:, 1, 0] >= y_pis[:, 1, 1]).all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def a_test_predict_intervals():\n model = ARIMAX(formula=\"y ~ x1\", data=data, ar=2, ma=2, family=Exponential())\n x = model.fit()\n predictions = model.predict(h=10, oos_data=data_oos, intervals=True)\n\n assert(np.all(predictions['99% Prediction Interval'].values >= predictions['95% Prediction Inter...
[ "0.7008983", "0.6921854", "0.6629614", "0.6628991", "0.6541392", "0.6503705", "0.636226", "0.6283357", "0.6096767", "0.6088294", "0.5940772", "0.5924373", "0.59009564", "0.5830119", "0.58078974", "0.5780239", "0.5753406", "0.5746239", "0.57426304", "0.57033485", "0.56873703",...
0.60601026
10
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes.
def add_header(r): r.headers['Acess-Control-Allow-Origin'] = '*' r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache" r.headers["Expires"] = "0" r.headers['Cache-Control'] = 'public, max-age=0' return r
{ "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.82238686", "0.8223043", "0.8223043", "0.8223043", "0.8223043", "0.81963", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0.81638503", "0....
0.6675408
76
Turns a regular string into a valid (sanatized) string that is safe for use as a file name. Method courtesy of cowlinator on StackOverflow
def get_valid_filename(s): assert(s is not "" or s is not None) s = str(s).strip().replace(' ', '_') return re.sub(r'(?u)[^-\w.]', '', s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_file_name(s: str) -> str:\n global UNICODE_FILENAMES, FILESYSTEM_IS_LINUX\n if FILESYSTEM_IS_LINUX:\n s = fix_linux.sub(\"_\", s)\n else:\n s = fix_windows.sub(\"_\", s)\n s = fix_windows_ending.split(s)[0]\n\n if not UNICODE_FILENAMES:\n s = fix_unicode.sub(\"_\",...
[ "0.76716447", "0.75413036", "0.7540056", "0.7441016", "0.72924304", "0.7285585", "0.72623646", "0.7174796", "0.7174796", "0.7174796", "0.71293354", "0.7114902", "0.7114902", "0.7033923", "0.700631", "0.6984628", "0.6972508", "0.69627804", "0.69307685", "0.6894254", "0.6804197...
0.7424664
4
SpikingNetwork() Constructor for SpikingNetwork class. The SpikingNetwork class contains a collection of neurons, and the connections between those neurons.
def __init__(self): self.neurons = [] self.connections = [] self.t_history = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialise_network(self):\n raise NotImplementedError", "def __init__(self, nodes=None, edges=None):\n self._nodes = []\n self.nodes = nodes\n self._edges = []\n self.edges = edges\n self._create_connections()\n self._sorted_nodes = None\n self._node_wi...
[ "0.58834445", "0.5857751", "0.57161033", "0.5706412", "0.5669589", "0.5645808", "0.563864", "0.5636151", "0.5586804", "0.5579512", "0.55789185", "0.5547211", "0.5533607", "0.55252385", "0.55141115", "0.55023617", "0.5473347", "0.5464233", "0.5445459", "0.5437679", "0.5429262"...
0.5557069
11
Get relative path of given file_path.
def _get_rel_path(self, file_path: Union[str, os.PathLike]) -> Optional[str]: file_path = Path(file_path).absolute() try: # use os.path.relpath instead of Path.relative_to in case file_path is not a child of self.base_path return os.path.relpath(file_path, self.base_path) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relative_path(self, file_path):\n file_path = os.path.abspath(file_path)\n if self.base_dir is not None:\n file_path = file_path.replace(os.path.abspath(self.base_dir), \"\")\n assert file_path[0] == \"/\"\n file_path = file_path[1:]\n return file_path", "def...
[ "0.8520076", "0.8010845", "0.78642064", "0.7803581", "0.77645516", "0.7719742", "0.73517203", "0.73088115", "0.7220092", "0.71953005", "0.71606654", "0.71266824", "0.71025205", "0.7034532", "0.69833493", "0.6972556", "0.6970623", "0.69497347", "0.6899141", "0.68803144", "0.68...
0.7720322
5
Hydrate a dict/set while nicely handling errors.
def _hydrate_handle_errors( self, to_hydrate: typing.Union[dict[str, int], set[str]], categorization: "Categorization", ) -> typing.Union[dict["Category", int], set["Category"]]: try: if isinstance(to_hydrate, dict): return { categoriza...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_set(dset, in_stream):\n dset.wipe()\n dict = to_dict(in_stream)\n dict = harmonize(dict)\n dset.dict = dict", "def _try_set(set_list, index, nested_dict, dict_keys=[]):\n try:\n for dict_key in dict_keys:\n nested_dict = nested_dict.__getitem__(dict_key)\n set_l...
[ "0.5863379", "0.5672946", "0.54328823", "0.54011786", "0.53436315", "0.5334652", "0.53215295", "0.5282999", "0.5265902", "0.5247211", "0.5218455", "0.52056223", "0.5163514", "0.5159744", "0.5148958", "0.513242", "0.51254594", "0.5115584", "0.5100926", "0.50891805", "0.5080949...
0.61847955
0
Returns all rules which involve the given categories.
def relevant_rules( self, categories: set["HierarchicalCategory"], source_categorization: typing.Optional["Categorization"] = None, simple_sums_only: bool = False, ) -> list[ConversionRule]: relevant_rules: list[ConversionRule] = [] if not categories: retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rules_for_category(category):\n\n rules = get_db().execute('SELECT * FROM ruleset WHERE category_id = ?', (category,)).fetchall()\n\n return rules", "def activity_category_rules(self):\n return self._activity_category_rules", "def get_all_rules(self):\n\n rules = set()\n for ...
[ "0.73781073", "0.62699336", "0.6244929", "0.61445254", "0.61245614", "0.61126804", "0.60499126", "0.60048413", "0.5924794", "0.5907226", "0.58856577", "0.5866383", "0.57582927", "0.57435775", "0.5711128", "0.5692245", "0.56867796", "0.5686372", "0.56736314", "0.5668175", "0.5...
0.69138217
1
A usersupplied email address to send case update notifications for. This should only be used in BYOID flows, where we cannot infer the user's email address directly from their EUCs.
def contact_email(self) -> str: return pulumi.get(self, "contact_email")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def email_address() -> str:\n\n return os.environ.get(\"EMAIL_NOTIFICATION\", \"\")", "def get_email(self):\n return self.reference[REF_EMAIL_ADDRESS][REF_VALUE]", "def email_address(self) -> str:\n return self._email_address", "def user_email(self) -> pulumi.Output[str]:\n return pul...
[ "0.6800963", "0.67918104", "0.6675029", "0.6637772", "0.6562847", "0.65611213", "0.65611213", "0.65611213", "0.6551857", "0.6550386", "0.6488691", "0.643121", "0.6427618", "0.640023", "0.640023", "0.640023", "0.640023", "0.6396381", "0.6375035", "0.6374068", "0.63728213", "...
0.6650474
3
Whether the case is currently escalated.
def escalated(self) -> bool: return pulumi.get(self, "escalated")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow_privilege_escalation(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"allow_privilege_escalation\")", "def allow_privilege_escalation(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"allow_privilege_escalation\")", "def should_terminate(self):\n ...
[ "0.6756851", "0.6756851", "0.655456", "0.6466731", "0.6466731", "0.64366317", "0.64095396", "0.63888055", "0.63750374", "0.6334827", "0.6334827", "0.6318662", "0.63014776", "0.62806183", "0.6267026", "0.62587327", "0.6247529", "0.62142515", "0.6177528", "0.6150019", "0.614986...
0.8121611
0
Set the user's full name.
def set_fullname(self, value): raise NotImplementedError('set_fullname')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_full_name(self, user_full_name):\n\n self._user_full_name = user_full_name", "def user_profile_setname(token, name_first, name_last):\n if (len(name_first) > 50 or name_first == \"\"):\n raise error.InputError(description=\"First name is not within 1-50 characters\")\n\n if (len(name...
[ "0.836563", "0.75340545", "0.7514459", "0.74505484", "0.7405372", "0.7405372", "0.7332618", "0.73247784", "0.72957754", "0.72543204", "0.72519", "0.7229117", "0.7208752", "0.71451366", "0.7137475", "0.7065397", "0.70451474", "0.70353705", "0.70353705", "0.7022715", "0.7022705...
0.6964731
22
Get the user's full name.
def get_fullname(self): raise NotImplementedError('get_fullname')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_name(self):\n return self.user.get_full_name() or None", "def get_full_name(self):\n full_name = '%s %s' % (self.user.first_name.strip(), self.user.last_name.strip())\n if len(full_name.strip()) == 0:\n full_name = self.user.username\n return full_name.strip()", ...
[ "0.8865615", "0.8864113", "0.8771539", "0.8744222", "0.87359774", "0.87359774", "0.8711882", "0.86309487", "0.8567367", "0.8471274", "0.8394458", "0.8369933", "0.8216363", "0.8214691", "0.82139677", "0.81876767", "0.81876767", "0.8171172", "0.8169147", "0.81618434", "0.815664...
0.0
-1
Returns true if the user should be automatically logged in.
def get_auto_login(self): raise NotImplementedError('get_auto_login')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logged_in(self):\n return self.auth.get_user_by_session() is not None", "def logged_in():\n\n if current_user.is_authenticated:\n return True\n\n return False", "def isLoggedIn(self):\n session = self.getSession()\n if session is not None:\n return True\n ret...
[ "0.80263686", "0.7900795", "0.77159154", "0.7684851", "0.767902", "0.7595168", "0.7582302", "0.7556779", "0.747085", "0.74536145", "0.74202716", "0.74202716", "0.74202716", "0.74202716", "0.74202716", "0.74202716", "0.74202716", "0.7333102", "0.73288363", "0.72879565", "0.727...
0.0
-1
Set the user's full name.
def set_fullname(self, value): self.fullname = value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_full_name(self, user_full_name):\n\n self._user_full_name = user_full_name", "def user_profile_setname(token, name_first, name_last):\n if (len(name_first) > 50 or name_first == \"\"):\n raise error.InputError(description=\"First name is not within 1-50 characters\")\n\n if (len(name...
[ "0.836563", "0.75340545", "0.74505484", "0.7405372", "0.7405372", "0.7332618", "0.73247784", "0.72957754", "0.72543204", "0.72519", "0.7229117", "0.7208752", "0.71451366", "0.7137475", "0.7065397", "0.70451474", "0.70353705", "0.70353705", "0.7022715", "0.7022705", "0.6990638...
0.7514459
2
Get the user's full name.
def get_fullname(self): if self.controller.oem_config: return 'OEM Configuration (temporary user)' return self.fullname
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_name(self):\n return self.user.get_full_name() or None", "def get_full_name(self):\n full_name = '%s %s' % (self.user.first_name.strip(), self.user.last_name.strip())\n if len(full_name.strip()) == 0:\n full_name = self.user.username\n return full_name.strip()", ...
[ "0.8865615", "0.8864113", "0.8771539", "0.8744222", "0.87359774", "0.87359774", "0.8711882", "0.86309487", "0.8567367", "0.8471274", "0.8394458", "0.8369933", "0.8216363", "0.8214691", "0.82139677", "0.81876767", "0.81876767", "0.8171172", "0.8169147", "0.81618434", "0.815664...
0.0
-1
Initialize an empty item list.
def __init__(self): self.item_list = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self) -> None:\n self._items = []", "def __init__(self) -> None:\n self._items = []", "def __init__(self, items=None):\n\n if items is None:\n self.items = []\n else:\n self.items = items", "def __init__(self):\r\n self._items = [[] for _ ...
[ "0.79313976", "0.79313976", "0.7784088", "0.7686438", "0.74654937", "0.74654937", "0.74654937", "0.74654937", "0.74654937", "0.74654937", "0.74654937", "0.740193", "0.73612344", "0.73095274", "0.7286669", "0.72692627", "0.7160032", "0.71577436", "0.71389014", "0.70649195", "0...
0.76415026
4
Set / Reset scoring window scoring frame
def setup_scores_frame(self): if self.score_window is not None: self.score_window.setup_scores_frame()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_score_window(self, score_window):\r\n self.score_window = score_window", "def reset_score(self):\n self.x_score = 0\n self.o_score = 0", "def reset_score(self):\n self._score = p.params['initial_score']", "def reset_board(self):\n self.board = [0, 0, 0, 0, 0, 0, 0...
[ "0.690555", "0.67795366", "0.669254", "0.64537257", "0.6246636", "0.62142754", "0.61463654", "0.6099305", "0.607451", "0.605702", "0.6043308", "0.60260797", "0.6023362", "0.5991097", "0.59890914", "0.58949155", "0.58801204", "0.5836586", "0.5820534", "0.57899797", "0.57812953...
0.73630786
0
Get current message, if any else returns None
def get_messages(self): return self.messages
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_message(self):\n return self.__message", "def get_message(self):\n return self.msg", "def message(self):\r\n messages = self.q(css='div.peer-grading-tools > div.message-container > p').text\r\n if len(messages) < 1:\r\n return None\r\n else:\r\n ...
[ "0.7713072", "0.7687069", "0.76342", "0.7616347", "0.7616347", "0.7505632", "0.7505632", "0.7427747", "0.73403275", "0.73399115", "0.73140335", "0.7308268", "0.72979844", "0.7284189", "0.72592115", "0.7166144", "0.7166144", "0.7166144", "0.7166144", "0.7166144", "0.70780975",...
0.0
-1
Controller for the app home page.
def home(request): context = {} return render(request, 'trailyzer/home.html', context)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home():\n payload = manager.get_payload()\n return render_template('index.html', payload=payload)", "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def home(self, *args, **kwargs):\n pass", "def home(request):\n\treturn r...
[ "0.78027886", "0.7685395", "0.7654384", "0.7584396", "0.7558254", "0.7547364", "0.7488385", "0.7459023", "0.7447416", "0.73899287", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7383182", ...
0.0
-1
Send a Chat Message to the Sandbox Alerts room
def sendChatMessage(message_text): url = 'https://chat.googleapis.com/v1/spaces/alphanumberCode/messages?key=longAlphnumbericWebhookAddress' bot_message = {'text' : '{}'.format(message_text)} message_headers = { 'Content-Type': 'application/json; charset=UTF-8'} http_obj = Http() response = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sendmessage(user,roomid):\n message = request.form['message']\n channel.send_message(user+roomid,message)", "def send(self, msg):\n self.message('Me', msg)", "def message(self, msg):\n if msg['type'] in ('chat', 'normal'):\n msg.reply(\"Thanks for sending\\n%(body)s\" % msg).send...
[ "0.68811464", "0.6847516", "0.6791102", "0.67856354", "0.6779874", "0.6776946", "0.67617124", "0.670527", "0.66660655", "0.6625642", "0.6602891", "0.65517944", "0.652683", "0.6523102", "0.6522914", "0.6521489", "0.65150696", "0.6459722", "0.64590627", "0.6447592", "0.6439197"...
0.60029906
72
Converts a tensor to tf.float32 only if it is tf.bfloat16.
def bfloat16_to_float32(tensor): if tensor.dtype == tf.bfloat16: return tf.cast(tensor, dtype=tf.float32) else: return tensor
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to_fp32(tensor):\n\n def _convert_to_fp32(tensor):\n return tensor.float()\n\n def _is_fp16_bf16_tensor(tensor):\n return hasattr(tensor, \"dtype\") and tensor.dtype in (torch.float16, torch.bfloat16)\n\n return recursively_apply(_convert_to_fp32, tensor, test_type=_is_fp16_bf16_...
[ "0.7858631", "0.75724304", "0.75203085", "0.6883645", "0.6862339", "0.6683696", "0.64042085", "0.63160515", "0.62945896", "0.6264188", "0.6259981", "0.6140555", "0.6127895", "0.61273074", "0.60588765", "0.60186124", "0.5874811", "0.5841956", "0.58403337", "0.5755291", "0.5749...
0.9267631
0
WilsonMazeGenerator(int,int) > WilsonMazeGenerator Creates a maze generator with specified width and height.
def __init__(self,height,width): self.width = 2*(width//2) + 1 # Make width odd self.height = 2*(height//2) + 1 # Make height odd # grid of cells self.grid = [[0 for j in range(self.width)] for i in range(self.height)] # declare instance variable self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wilsons_maze(width=16, height=16) -> Maze:\n maze = Maze(width=width, height=height, algorithm=None)\n visited = [[False for _ in range(maze.width)] for _ in range(maze.height)]\n\n visited[0][0] = True\n\n def loop_erased_random_walk(x, y):\n \"\"\"\n Take a random walk from unit (sx...
[ "0.6644459", "0.65112656", "0.5469168", "0.5399776", "0.5257867", "0.5198335", "0.5194906", "0.51201385", "0.5075116", "0.50214875", "0.5015187", "0.49965477", "0.4970762", "0.49564216", "0.49316835", "0.49224162", "0.4921961", "0.4919343", "0.4880007", "0.48745543", "0.48710...
0.4761912
30
WilsonMazeGenerator(tuple,int) > boolean Checks if the adjacent cell in the direction specified by dirNum is within the grid
def is_valid_direction(self,cell,dirNum): newCell = self.get_next_cell(cell,dirNum,2) tooSmall = newCell[0] < 0 or newCell[1] < 0 tooBig = newCell[0] >= self.height or newCell[1] >= self.width return not (tooSmall or tooBig)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkAdjacent(self, direction, maze):\n\n y = self.y\n x = self.x\n\n # Shift x or y depending on the given direction.\n if direction in NS:\n y = shift[direction](y)\n elif direction in EW:\n x = shift[direction](x)\n\n # Check new location for o...
[ "0.6736112", "0.6709581", "0.6619374", "0.6578575", "0.6566026", "0.64671594", "0.6303121", "0.62695503", "0.6235794", "0.621208", "0.61807805", "0.6092523", "0.6083636", "0.608271", "0.60804826", "0.6057797", "0.6052561", "0.60356444", "0.6002189", "0.59939617", "0.59804404"...
0.6175531
11
Given an integer n, return the number of trailing zeroes in n!. A simple method is to first calculate factorial of n, then count trailing 0s in the result. But this can cause overflow for a big numbers as the factorial becomes large. Instead consider prime factors, a trailing zero is produced by 2 and 5. It turns out t...
def factorial_trailing_zero(n): count = 0 idx = 5 while(n/idx >= 1): count += math.floor(n/idx) idx *= 5 return count
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial_trailing_zeroes(n):\n zeroes = 0\n for i in range(5, n + 1, 5):\n while i % 5 == 0:\n zeroes += 1\n i /= 5\n return zeroes", "def trailingZeroes(self, n):\n cnt = 0\n while n:\n n /= 5\n cnt += n\n\n return cnt", "de...
[ "0.8461389", "0.7799396", "0.6998401", "0.6924921", "0.66723603", "0.66418034", "0.66046816", "0.6564725", "0.6433274", "0.6424956", "0.63826513", "0.637003", "0.6348722", "0.63473636", "0.63061744", "0.6303286", "0.62940425", "0.62662256", "0.62402827", "0.6230139", "0.62080...
0.8812515
0
Replace URLs found in a text string with nothing
def remove_url(txt): print(txt['fields']['tweet']) return " ".join(re.sub("([^0-9A-Za-z \t])|(\w+:\/\/\S+)", "", txt['fields']['tweet']).split())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_urls(text):\n text = re.sub('(?P<url>https?://[^\\s]+)', 'URL', text)\n return text", "def remove_urls(text):\n pass", "def remove_urls(text):\n text = re.sub('(?P<url>https?://[^\\s]+)', '', text)\n return text", "def remove_urls(self, text):\n return re.sub...
[ "0.82637036", "0.8165166", "0.78912544", "0.78639024", "0.78076977", "0.7626", "0.755376", "0.75102204", "0.74541605", "0.7348094", "0.7279677", "0.7253456", "0.72465414", "0.72315764", "0.72257817", "0.710745", "0.7088032", "0.70726097", "0.70511425", "0.7030343", "0.699819"...
0.6661439
26
Get all base classes of this type.
def get_superclasses(self, t): if isinstance(t, pytd.ClassType): return sum((self.get_superclasses(c) for c in t.cls.bases), [t]) elif isinstance(t, pytd.AnythingType): # All types, even "?", inherit from object. return [pytd.NamedType("builtins.object")] elif isinstance(t, pytd.GenericTyp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bases(self):\n return self.py_class.__bases__", "def get_bases(self):\n # TODO: subclassing\n return (self.py_class,)", "def _get_all_bases(class_or_name: Union[str, Type]) -> List[str]:\n if isinstance(class_or_name, str):\n return [class_or_name]\n\n classes = [class...
[ "0.7940958", "0.7573388", "0.7374689", "0.7188194", "0.7142438", "0.7140361", "0.7122095", "0.70975757", "0.70868087", "0.70792526", "0.70595324", "0.69851553", "0.69754046", "0.6906301", "0.6837811", "0.67866105", "0.67834294", "0.67713517", "0.674705", "0.6719313", "0.67127...
0.7230338
3
Get all classes derived from this type.
def get_subclasses(self, t): if isinstance(t, pytd.ClassType): subclasses = self.direct_subclasses.get(t, []) return sum((self.get_subclasses(pytd.ClassType(c.name, c)) for c in subclasses), [t]) else: raise NotImplementedError(f"Can't extract subclasses from {type(t)}")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_subclasses(cls):\n return cls.__subclasses__() + [g for s in cls.__subclasses__()\n for g in all_subclasses(s)]", "def get_classes(self):\n return self._classes", "def _classes_(cls):\n for base_cls in cls.__bases__:\n # Avoid infinite loop\n if...
[ "0.7483341", "0.7475081", "0.7439304", "0.73830944", "0.7355377", "0.7335772", "0.73074585", "0.72801393", "0.72661585", "0.7258476", "0.72548383", "0.71463203", "0.71250486", "0.71210355", "0.70994705", "0.70031464", "0.7003042", "0.69794565", "0.6977013", "0.69547874", "0.6...
0.66609496
34
Derive a key from `password` and `salt`
def scrypt(salt: bytes, N: int, password: bytes) -> bytes: kdf = Scrypt(salt=salt, length=32, n=N, r=8, p=1, backend=default_backend()) return kdf.derive(password)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def derive_fernet_key(password, salt):\n kdf = pbkdf2.PBKDF2HMAC(\n algorithm=hashes.SHA256(),\n length=32,\n salt=encoding.force_bytes(salt),\n iterations=100000,\n backend=default_backend()\n )\n return base64.urlsafe_b64encode(kdf.derive(\n encoding.force_bytes...
[ "0.7879021", "0.7347333", "0.7035354", "0.7034277", "0.6669516", "0.6650094", "0.662337", "0.6578523", "0.6548199", "0.6518925", "0.6511272", "0.6511211", "0.65002275", "0.64481884", "0.64217824", "0.6402019", "0.63275164", "0.6314866", "0.63141173", "0.62975615", "0.629168",...
0.68373406
4
Set the learning rate at the start of each epoch.
def on_epoch_start(self): self.current_epoch += 1 self.current_lr = self.fn(self.current_epoch) self.model.set_learning_rate(self.current_lr) self.epochs += [self.current_epoch] self.learning_rate += [self.current_lr]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_learning_rate(self):\r\n self.scheduler.step(self.clock.epoch)", "def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)", "def learning_rate(epoch):\n self.lr = self.lr / 1.00000001\n return self.lr", "def adjust_learning_rate(start_lr, optimizer...
[ "0.7705306", "0.7651053", "0.74821275", "0.74701077", "0.74355876", "0.74145925", "0.739972", "0.739972", "0.7354069", "0.7350152", "0.73154724", "0.7294975", "0.7223198", "0.72194284", "0.71722084", "0.7137065", "0.7109468", "0.7095874", "0.7094856", "0.707595", "0.70735395"...
0.76838917
1
Vectorizes the texts as sequence vectors with the prefitted Tokenizer Arguments
def convert_to_sequence(texts, tokenizer, max_length): fitted_tokenizer = tokenizer vectorized_text = fitted_tokenizer.texts_to_sequences(texts) # pad sequences vectorized_text = sequence.pad_sequences(vectorized_text, maxlen=max_length) return vectorized_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vectorize_texts(self, encoder) -> NoReturn:\n self.encoder = encoder\n self.vectorized_texts = [self.encoder.encode(t) for t in self.tokenized_texts]", "def vectorize_text(text):\n\n def remove_punctuation(text):\n \"\"\"Removes special characters from text.\"\"\"\n return re.s...
[ "0.7196426", "0.68583566", "0.68333024", "0.6688538", "0.6643502", "0.65289974", "0.65274346", "0.6515027", "0.65063655", "0.65022886", "0.6400072", "0.6382236", "0.638106", "0.63786596", "0.63733745", "0.63478947", "0.633347", "0.6275407", "0.6274319", "0.62678015", "0.62675...
0.6314076
17
Return file handle of file regardless of zipped or not Text mode enforced for compatibility with python2
def _open_zipped(infile, mode='r', encoding='utf-8'): mode = mode[0] + 't' p2mode = mode if hasattr(infile, 'write'): return infile if isinstance(infile, str): if infile.endswith('.gz'): return _zopen(infile, mode) if infile.endswith('.bz2'): return _bop...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_file_handle(\n filepath,\n mode,\n *,\n compression=None,\n encoding=None,\n errors=None,\n newline=None,\n):\n if compression:\n mode_ = mode.replace(\"b\", \"\").replace(\"t\", \"\")\n if compression == \"gzip\":\n f = gzip.GzipFile(filepath, mode=mode_)\...
[ "0.6709272", "0.66114426", "0.66103846", "0.65045583", "0.644547", "0.643012", "0.63988066", "0.63582563", "0.623052", "0.61340666", "0.61247677", "0.61178184", "0.609582", "0.60492367", "0.60492367", "0.5969478", "0.59637064", "0.5933722", "0.59231985", "0.5922482", "0.58563...
0.6629213
1
Yield successive nsized chunks from l.
def chunks(l, n): for i in range(0, len(l), n): yield l[i:i + n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]", "def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]", "def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]", "def get_chunks(self, ...
[ "0.8038813", "0.79248375", "0.7923423", "0.7885103", "0.78773195", "0.7815877", "0.77655786", "0.77556044", "0.77441615", "0.7731815", "0.77288336", "0.772473", "0.77028215", "0.76889825", "0.76889825", "0.7664208", "0.76570904", "0.7655856", "0.7655856", "0.76458347", "0.764...
0.7448925
68
Return the item at the top of the stack. >>> s = Stack([1, 2, 3]) >>> s.top() 3 >>> s Stack([1, 2, 3])
def top(self) -> Any: try: return self._data[-1] except IndexError: raise IndexError("top from an empty stack") from None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top(self):\n try:\n if self.size() > 0:\n return self.items[len(self.items) - 1]\n else:\n raise IndexError('Cannot get top item, stack is empty.')\n except IndexError as err:\n print(err)\n raise", "def top(self):\n ...
[ "0.8579007", "0.8465018", "0.839501", "0.8369853", "0.82619125", "0.8086473", "0.8052915", "0.8035772", "0.8025528", "0.8012489", "0.7973554", "0.7952454", "0.79396147", "0.78968126", "0.7839041", "0.78040516", "0.775743", "0.77243274", "0.7713983", "0.76433617", "0.76209706"...
0.81543523
5
Return True if the stack is empty, False otherwise. >>> s = Stack() >>> s.is_empty() True >>> s.push(1) >>> s.is_empty() False
def is_empty(self) -> bool: return len(self._data) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty(self):\n return len(self.the_stack) == 0", "def is_empty(self):\n return len(self.stack) == 0", "def is_empty(self): #checks to see if stack is empty or not\n if self.num_items == 0:\n return True\n else:\n return False", "def empt...
[ "0.8432801", "0.8380236", "0.8330348", "0.82722867", "0.8239459", "0.8219531", "0.8204403", "0.8183062", "0.8101043", "0.8101043", "0.8094338", "0.8085751", "0.80774677", "0.80716723", "0.80324346", "0.80225486", "0.7979046", "0.7956233", "0.7956233", "0.7938504", "0.7884105"...
0.0
-1
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): plt.imshow(cm, interpolation='nearest', cmap=cmap) plt.title(title) plt.colorbar() tick_marks = np.arange(len(classes)) ...
{ "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.8194862", "0.80949175", "0.8029915", "0.8019153", "0.79941195", "0.7991258", "0.7980955", "0.7976606", "0.79610753", "0.79590565", "0.79378676", "0.7934962", "0.7934504", "0.79313844", "0.7926313", "0.7924577", "0.79241234", "0.7923211", "0.7923023", "0.7921931", "0.791787...
0.7860299
40
Return a vector from `camera` to `target` in the camera's coordinate space. The camera's lens is assumed to be norm to the ZX plane.
def compute_relative_vector(camera: bpy.types.Camera, target: bpy.types.Object): cam_loc, cam_rot, _ = camera.matrix_world.decompose() target_loc, _, _ = target.matrix_world.decompose() relative_vector = target_loc - cam_loc rotation = cam_rot.to_matrix().transposed() relative_vector.rotate(rotatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simple_camera(camera, target_rect):\n l, t, _, _ = target_rect\n _, _, w, h = camera\n return pygame.Rect(-l+300, -t+300, w, h)", "def complex_camera(camera, target_rect):\n l, t, _, _ = target_rect\n _, _, w, h = camera\n l, t, _, _ = -l+300, -t+300, w, h\n\n l = min(0, l)\n l = max(...
[ "0.63884884", "0.62758213", "0.6245489", "0.5850526", "0.5791176", "0.5715452", "0.56954753", "0.5659828", "0.56392825", "0.5560927", "0.5541822", "0.5462892", "0.5461469", "0.5461048", "0.54369617", "0.54212433", "0.5412418", "0.5388569", "0.53767955", "0.53762454", "0.53468...
0.7434989
0
Return objects for the current authenticated user only
def get_queryset(self): return self.queryset.filter(user=self.request.user).order_by('-name')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\n return super().get_queryset().filter(user=self.request.user)", "def get_queryset(self, request):\n qs = super().get_queryset(request)\n return qs.filter(user=request.user)", "def get_queryset(self, *args, **kwargs):\n qs = super().get_queryset(*args, **kwar...
[ "0.8128217", "0.81258285", "0.7882456", "0.78440523", "0.7745406", "0.7604245", "0.7604245", "0.7497975", "0.7285781", "0.7250722", "0.7198163", "0.71906906", "0.71667135", "0.7160965", "0.7144866", "0.7118433", "0.7115828", "0.7115828", "0.7115828", "0.71137464", "0.71114254...
0.7315406
8
Initialize from session and code_data immutable object. The `code_data` contains serialization information required for msgpackrpc calls. It must be immutable for Buffer equality to work.
def __init__(self, session, code_data): self._session = session self.code_data = code_data self.handle = unpackb(code_data[1]) self.api = RemoteApi(self, self._api_prefix) self.vars = RemoteMap(self, self._api_prefix + 'get_var', self._api_prefix + '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, code, state, message, extra_fields=None):\n self.code = code\n self.state = state\n self.message = message\n self.extra_fields = extra_fields", "def __init__(self, rpcbridge, code, args):\n\n self.rpcbridge = rpcbridge\n self.code = code\n self....
[ "0.5879398", "0.5713123", "0.5527441", "0.5527441", "0.55160934", "0.54913825", "0.5484774", "0.54762274", "0.54057", "0.5375171", "0.5352091", "0.5335564", "0.53135514", "0.5306922", "0.52937436", "0.5292928", "0.5261718", "0.5249401", "0.5246991", "0.5236905", "0.5234419", ...
0.69644886
0
Return True if `self` and `other` are the same object.
def __eq__(self, other): return (hasattr(other, 'code_data') and other.code_data == self.code_data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n # Check that we share the same class as this object\n if not isinstance(other, type(self)):\n return False\n\n return hash(self) == hash(other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n ...
[ "0.8360874", "0.83533716", "0.8286548", "0.8286548", "0.82575476", "0.8253887", "0.82207596", "0.82207596", "0.8142174", "0.8139335", "0.8138741", "0.81255716", "0.80854064", "0.80799276", "0.80784136", "0.8032802", "0.8025345", "0.80130005", "0.80081916", "0.80081916", "0.79...
0.0
-1
Return a map value by key.
def __getitem__(self, key): return self._get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_value(self, key):\n try:\n return self.map[key]\n except KeyError:\n raise KeyError('key is not in map')", "def __getitem__(self, key):\n _, kv_pair = self._lookup(key, self._backing)\n if kv_pair:\n return kv_pair.value\n else:\n ...
[ "0.7851039", "0.70498586", "0.6976407", "0.69453937", "0.68998337", "0.6879719", "0.6847617", "0.6807728", "0.6792951", "0.6746719", "0.6739714", "0.6695614", "0.66093856", "0.6560921", "0.65587354", "0.655258", "0.65507513", "0.65304565", "0.6521069", "0.6485636", "0.6475802...
0.6094206
52
Return a sequence item by index.
def __getitem__(self, idx): if not isinstance(idx, slice): return self._fetch()[idx] return self._fetch()[idx.start:idx.stop]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, index):\n return self.seq[index]", "def __getitem__(self, index):\n # NOTE: this automatically supports slicing :-)\n return self._main._sequence[index]", "def __getitem__(self, index):\n if index < 0 or index >= len(self.sequence):\n raise Exception...
[ "0.82708466", "0.81686413", "0.81345636", "0.80521756", "0.76788133", "0.753526", "0.7529076", "0.75270367", "0.7471223", "0.7463311", "0.7406007", "0.72571605", "0.725005", "0.7242141", "0.7242141", "0.7231405", "0.72278476", "0.7194344", "0.7129053", "0.71186644", "0.711079...
0.6480734
93
Return an iterator for the sequence.
def __iter__(self): items = self._fetch() for item in items: yield item
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n for x in self.seq: yield x", "def from_sequence(self, seq):\n return Iter(self._from_sequence(seq))", "def __iter__(self) -> Generator:\r\n yield from self.sequence", "def __next__(self):\n self._k += 1\n if self._k < len(self._seq):\n retur...
[ "0.7617125", "0.7556803", "0.7320426", "0.6910532", "0.6820452", "0.6820452", "0.6820452", "0.67740774", "0.6766284", "0.6701768", "0.6680752", "0.6672772", "0.6647852", "0.6625429", "0.6616575", "0.66073567", "0.65905553", "0.65311444", "0.6477479", "0.64672935", "0.64602023...
0.6069484
63
Returns the number of vertices in this graph
def v_size(self) -> int: return len(self.Nodes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_num_vertices(self):\n\n return self._graph_state.get_num_vertices()", "def num_vertices(self):\r\n return len(self.__graph_dict.keys())", "def vertexCount(self):\n return self._nVertices", "def num_vertices(self):\n return self._top_exp.number_of_vertices()", "def return...
[ "0.9092417", "0.89516836", "0.8930787", "0.88623077", "0.8826155", "0.88176703", "0.88176703", "0.87426937", "0.8735254", "0.86637056", "0.86382085", "0.86033094", "0.84865", "0.8350979", "0.8237714", "0.8161115", "0.79114026", "0.7854557", "0.77824813", "0.77266026", "0.7521...
0.6837896
55
This method returns the string representation of the object.
def __str__(self) -> str: return f"Graph: | V |= {self.v_size()}, | E |= {self.e_size()}"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_string(self):\r\n return self.__str__()", "def __str__(self):\n return str(self.__dict__['_obj'])", "def __str__(self):\n return str(self.serialize())", "def as_string(self):\n return self.__repr__()", "def __str__(self):\n return str(self.obj)", "def ser...
[ "0.8519109", "0.8448701", "0.84233034", "0.8389341", "0.83585453", "0.82917476", "0.82511103", "0.8228812", "0.82008964", "0.81932896", "0.81932896", "0.81877124", "0.81877124", "0.81877124", "0.81877124", "0.81877124", "0.8177723", "0.8164467", "0.8164467", "0.8164467", "0.8...
0.0
-1
Returns the number of edges in this graph
def e_size(self) -> int: return self.edgesize
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_edges(self) -> int:\n return self.graph.number_of_edges()", "def edge_count(self) -> int:\n return self._n_edges", "def get_num_edges(self):\n\n return self._graph_state.get_num_edges()", "def num_edges(self):\n return sum(1 for _ in self.iteredges())", "def num_ed...
[ "0.9113971", "0.9064937", "0.88517714", "0.8824951", "0.87737626", "0.8768532", "0.8702538", "0.8693012", "0.86387426", "0.8601404", "0.8600074", "0.8576844", "0.8503865", "0.8493038", "0.84049594", "0.8363609", "0.82958615", "0.8288594", "0.8249705", "0.8233358", "0.82291234...
0.7442337
28
Adds an edge to the graph.
def add_edge(self, id1: int, id2: int, weight: float) -> bool: if id1 in self.Nodes and id2 in self.Nodes and id2 not in self.Edges[id1]: if self.Edges[id1] is None: self.Edges[id1] = {} self.Edges[id1][id2] = weight else: self.Edges[id1][i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(self, edge):\n if(self.has_edge(edge) == 0):\n self.__graph_dict[edge[0]].append(edge[1])", "def addEdge(self, edge: Edge):\n self.edges.append(edge)", "def add_edge(self, edge):\n assert edge not in self.edges\n self.edges.append(edge)", "def add_edge(self...
[ "0.841144", "0.83919084", "0.8347221", "0.8330175", "0.82800245", "0.8196861", "0.81965816", "0.81554943", "0.806904", "0.7990693", "0.79418606", "0.79395586", "0.79385245", "0.7935002", "0.7914147", "0.7814346", "0.77845144", "0.7768525", "0.7742754", "0.7682856", "0.7616938...
0.0
-1
Returns value of self.sync_obj
def getSyncObj(self): return self.sync_obj
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sync(self):\n return self._sync", "def get(self):\n # we use the with-statement here to automatically\n # release the lock when we return\n with self.mutex:\n return self.value", "def syncheck(self) :\n\t\ttry :\n\t\t\treturn self._syncheck\n\t\texcept Exception as e:...
[ "0.7532613", "0.71233404", "0.71123767", "0.6571496", "0.6563941", "0.6552352", "0.65381074", "0.65333045", "0.6508759", "0.6446455", "0.6444455", "0.6425047", "0.6403295", "0.639481", "0.6385154", "0.636988", "0.6368808", "0.63551754", "0.6347043", "0.6335957", "0.6303857", ...
0.83968353
0
Create empty linked list
def __init__(self, value = None): self.head = value self.size = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_empty_ll():\n from linked_list import Linked_List\n this_empty_ll = Linked_List()\n return this_empty_ll", "def create_empty_node():\n from linked_list import Node\n return Node()", "def __init__(self):\n node = ListNode(0) # dummy\n self.head = node\n self.tail = n...
[ "0.7901278", "0.7744079", "0.7272829", "0.71973795", "0.7059948", "0.7015057", "0.6970204", "0.69118553", "0.68999165", "0.6865938", "0.6857656", "0.68490404", "0.68490404", "0.67854464", "0.676859", "0.6768357", "0.6763377", "0.6748346", "0.67063236", "0.67008734", "0.670026...
0.0
-1
Set/extend inflow domain to fit LES boundary and update NZ. Values between zMin and min(z) will be duplicated from
def resizeZ(self,zMin=None,zMax=None,shrink=False,dryrun=False): if zMin is None: zMin = self.z[0] if zMax is None: zMax = self.z[-1] if not shrink: if zMin > self.z[0]: print('zMin not changed from',self.z[0],'to',zMin) return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_z_defocus(data, z, w0, c, d, A, B):\n params = [w0, c, d, A, B]\n return fit_function_LS(data, params, z, z_defocus)", "def fit_lattice(self):\n self.lattice = minimize(self._residual_lattice, self.latt_par) \n self.qx = self._q_x()\n self.qz = self._q_z()", "def update_z(self):\n ...
[ "0.56952125", "0.54317564", "0.5310037", "0.52636683", "0.5244745", "0.5213841", "0.51572603", "0.51566625", "0.5150791", "0.5123717", "0.50912863", "0.50665504", "0.5065041", "0.50649047", "0.50616413", "0.5029366", "0.502713", "0.50269115", "0.50213134", "0.50210345", "0.49...
0.52264667
5
Generate a string up to a given length from provided random choices.
def _choice_str(choices, max): return ''.join(map(str, [choice(choices) for _ in range(max)]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))", "def generate_random_string(length = 30):\n\n m_available_chars = ascii_letters + digits\n\n return \"\".join(choice(m_available_chars) for _ in xra...
[ "0.8275436", "0.82353926", "0.822639", "0.82070154", "0.82049847", "0.8105913", "0.7986578", "0.79737765", "0.79495347", "0.7948964", "0.7942402", "0.79421127", "0.79396474", "0.79367024", "0.79305524", "0.7920047", "0.79088324", "0.7858227", "0.784629", "0.78452134", "0.7834...
0.0
-1
Extend the list of prime numbers so that the list contains all prime numbers less than n.
def more_primes(primes, n): a = primes[-1] + 1 b = n - a if b <= 0: return sieve = ([1, 0] if a & 1 else [0, 1]) * (b >> 1) if b & 1: sieve.append(a & 1) prime_iter = iter(primes) next(prime_iter) # drop 2 for p in prime_iter: q = p * p if q > n: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]", "def prime_list(n):\n if n < 2:\n return []\n\n size = n//2\n prime_nums = []\n prime_nums.append(2)\n for i in range(1, size):\n val = i*2 + 1\n index = 0;\n for item in prime_nums:\n ...
[ "0.68559945", "0.6827224", "0.68198514", "0.6744363", "0.67228884", "0.66946733", "0.6675343", "0.6625174", "0.65861523", "0.65768147", "0.6505357", "0.6505357", "0.6502982", "0.6495093", "0.6487174", "0.64756376", "0.6402824", "0.636972", "0.63585246", "0.6344029", "0.633676...
0.60337317
46
Initialize an iterator. First, it generates a list of all prime numbers less than n in ascending order. It includes approximately n / log(n) numbers. Whenever the iterator served all numbers in the list, it extends the list by adding more (also approximately n / log(n)) prime numbers into the list. The least possible v...
def __init__(self, n=10000): if n < 3: raise ValueError('too small n: {0}'.format(n)) self._p = list(generate_primes(n)) self._len = len(self._p) self._i = 0 self._n = n self._a = n
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primes_list(n):\n count = 0\n if n <= 7:\n p_list = [2, 3, 5, 7, 11, 13, 17]\n return p_list[:n]\n else:\n upper_bound = int(n * log(n) + n * log(log(n)))\n return primes(upper_bound)[:n]", "def next_prime(n):\n i = 1\n known_prime = []\n while i < n:\n if...
[ "0.7429786", "0.73354256", "0.7269877", "0.71814346", "0.7150953", "0.7116848", "0.7108565", "0.71050495", "0.703122", "0.69874156", "0.6947654", "0.69446635", "0.6936329", "0.689148", "0.68567795", "0.68297666", "0.68185437", "0.68119967", "0.6810227", "0.67919075", "0.67901...
0.6760034
23
Return True if n passes the MillerRabin primality test, which means n is prime. It never returns False if n is prime. If n is composite, it returns False most of the time, but may return True with the probability p <= 4 k (in the worst case; usually much less than 4 k).
def is_prime(n, k=10): if n == 2 or n == 3: return True if not n & 1 or n < 2: return False m = n - 1 s = 1 d = m >> 1 while not d & 1: s += 1 d >>= 1 for i in range(k): a = randint(2, n - 2) x = expmod(a, d, n) if x == 1 or x == n - 1:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_miller_rabin_prime(n):\n if n <= 1:\n return False\n elif n == 2:\n return True\n elif n % 2 == 0:\n return False\n \n witnesses = get_witnesses(n)\n if witnesses is None:\n msg = 'No definite Miller-Rabin test is available for %d' % n\n raise ValueError(...
[ "0.85286784", "0.85286784", "0.7937584", "0.79067254", "0.7906619", "0.78453547", "0.78311735", "0.7828112", "0.7796062", "0.77727085", "0.77483726", "0.77454257", "0.7738385", "0.771727", "0.77034587", "0.76918703", "0.7673125", "0.7643213", "0.76310176", "0.7600906", "0.759...
0.7738352
13
Calculates energy of the audio segment. Normalised with segment legth.
def energy_calc(signal: np.array, segment_length: int) -> np.array: energy = [] for i in range(int(len(signal)/segment_length)): segment = signal[i*segment_length:(i+1)*segment_length]# try except error ... energy.append(np.sum(np.square(segment)) / segment_length) if energy[-1] < 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calc_energy( self, V_a, eos_d ):\n pass", "def energy_func(self):\n i = self.inl[0].to_flow()\n o = self.outl[0].to_flow()\n\n T_m = (T_mix_ph(i, T0=self.inl[0].T.val_SI) +\n T_mix_ph(o, T0=self.outl[0].T.val_SI)) / 2\n\n return (i[0] * (o[2] - i[2]) -\n ...
[ "0.7181935", "0.6728036", "0.6642471", "0.66202205", "0.65177953", "0.6464615", "0.6448645", "0.64418685", "0.64053833", "0.6401969", "0.63320494", "0.63021743", "0.6294724", "0.625772", "0.6257613", "0.6255947", "0.62381375", "0.61946064", "0.61936855", "0.61935425", "0.6178...
0.6701792
2
Adds a member to the initiative. Errors out if you try to add a member that already belongs.
def add_member(self, user, is_admin=False): # Only add members if they are not already one membership_count = InitiativeMembership.objects.filter(user=user, initiative=self).count() if membership_count > 0: raise SuspiciousOperation("Is already a member") return InitiativeM...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_member():\n client = RequestManager()\n client.set_method(\"POST\")\n client.set_endpoint(\"/accounts/{0}/memberships\".format(CONFIG_DATA['account_id']))\n body = {\"person_id\": CONFIG_DATA['member_id']}\n client.set_body(json.dumps(body))\n client.execute_reques...
[ "0.7963829", "0.78312314", "0.76141727", "0.7491945", "0.74482244", "0.744379", "0.73929566", "0.7258244", "0.71744347", "0.70789397", "0.70768243", "0.6918582", "0.69005156", "0.68394244", "0.67806524", "0.6775479", "0.6715552", "0.6693483", "0.66271746", "0.6606526", "0.655...
0.7236066
8
Return the name, net worth, and industry. of the oldest billionaire under 80 years old AND the youngest billionaire with a valid age.
def forbes(): oldest = {} youngest = {} for entry in data: age = entry['age'] if not oldest or (age > oldest['age']) and (age < 80): oldest.update(entry) if not youngest or (age < youngest['age']) and (age > 0): youngest.update(entry) return """ Oldest: N...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def youngest():\n def get_age(person_list):\n return person_list['age']\n return sorted(PEOPLE_LIST, key = get_age)", "def get_age_fields():\n under_18_fields = CensusFields.get_under_18_fields()\n\n age_18_to_29_fields = [ \n 'B01001_007E', # Male:!!18 and 19 years\...
[ "0.6194519", "0.60957855", "0.58409154", "0.58221006", "0.57615024", "0.57132536", "0.5707365", "0.5706862", "0.5680485", "0.5680485", "0.56279093", "0.56265974", "0.56255025", "0.55993223", "0.55891925", "0.55502397", "0.5494802", "0.54865354", "0.5462849", "0.54381216", "0....
0.7141713
0
Add the bits a[k1], ..., a[0] and b[k1], ..., b[0], return k+1 bits s[0], ... , s[k]
def BitAdd(a, b, bits_to_compute=None): k = len(a) if not bits_to_compute: bits_to_compute = list(range(k)) d = [None] * k for i in range(1,k): t = a[i]*b[i] d[i] = (a[i] + b[i] - 2*t, t) d[0] = (None, a[0]*b[0]) pg = PreOpL(carry, d) c = [pair[1] for pair i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add(self, i, k):\n while i < self._size:\n self._bit[i] += k\n i += lsb(i)", "def _add(a, b):\n\n # Todo: What if numbers have bigger length than 8\n a = _I2B(a, fixed_length=8)\n b = _I2B(b, fixed_length=8)\n return _B2I([i ^ j for i, j in zip(a, b)])", "def andbi...
[ "0.6607465", "0.65649474", "0.6344874", "0.6234201", "0.61811227", "0.61520135", "0.59970796", "0.597277", "0.59676427", "0.59046817", "0.5842317", "0.5782388", "0.5759811", "0.5716185", "0.57040405", "0.5689064", "0.56453186", "0.56194335", "0.561849", "0.5612642", "0.560713...
0.6847354
0
Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
def addAtHead(self, val): new_node = Node(val) new_node.next = self.head self.head = new_node self.length += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(self, val):\n new_node = Node(val)\n new_node.next = self.head\n self.head = new_node", "def addAtHead(self, val):\n node = ListNode(val)\n if self.head == None:\n self.head = node\n else:\n node.next = self.head\n self.head = ...
[ "0.7888693", "0.7811856", "0.7714778", "0.7666559", "0.7633319", "0.7595646", "0.758606", "0.75703543", "0.7493103", "0.74779594", "0.74625516", "0.7428768", "0.7407754", "0.7381638", "0.73484814", "0.73484814", "0.72836316", "0.7247032", "0.72358435", "0.71726114", "0.714572...
0.75016534
8
Append a node of value val to the last element of the linked list.
def addAtTail(self, val): if self.head is None: self.addAtHead(val) else: new_node = Node(val) curr = self.head while (curr.next is not None): curr = curr.next curr.next = new_node new_node.prev = curr s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append(self, val):\n inserted_node = DblNode(val, previous_node=self.tail)\n self.tail.next_node = inserted_node\n self.tail = inserted_node", "def addAtTail(self, val):\n node = ListNode(val)\n if self.head == None:\n self.head = node\n else:\n ...
[ "0.80130863", "0.78928936", "0.7879162", "0.7879162", "0.7856019", "0.7782996", "0.7744707", "0.77368987", "0.7721728", "0.76904315", "0.7632201", "0.76267153", "0.7550089", "0.7530205", "0.7521708", "0.74483246", "0.7416057", "0.73196465", "0.72394246", "0.7223336", "0.72167...
0.79794717
1
Returns maze entrance as property.
def entrance(self): return self.__entrance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_elevation(self):\n return self.elevation", "def get_ee_pose(self):\n self.gazebo.unpauseSim()\n gripper_pose = self.move_fetch_object.ee_pose()\n self.gazebo.pauseSim()\n return gripper_pose", "def get_occupant(self):\n\t\treturn self.occupant", "def properties(self...
[ "0.5915323", "0.5815137", "0.5763461", "0.5750419", "0.5736284", "0.5695879", "0.55980146", "0.5577119", "0.55618167", "0.5551216", "0.55412155", "0.5515444", "0.5512977", "0.5465324", "0.54599327", "0.54415125", "0.5432804", "0.5429483", "0.5426104", "0.54246217", "0.5410291...
0.7022588
0
Returns maze exit as property.
def exit(self): return self.__exit
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_end_node(self) -> MazeCell:\n return self._end_node", "def exits(self):\n return Direction.range(~self._walls)", "def get_entry_exit(self):\r\n return self._player.get_moves()", "def match_exit(self, name):\r\n x = Exit.query(location_id=self.id, name=name).first()\r\n ...
[ "0.6091213", "0.6010197", "0.59296495", "0.5755052", "0.5662816", "0.56532025", "0.56238884", "0.55671835", "0.55571663", "0.549171", "0.54902685", "0.5473447", "0.54495376", "0.53548163", "0.53029996", "0.53004646", "0.5242823", "0.5241459", "0.5234659", "0.5203439", "0.5148...
0.5707558
4
Returns whether the exit is reachable as bool property.
def can_reach_exit(self, position): return self.__verify_exit_path(position)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isReachable(self):\n cmd = \"ping -c 1 %s\" % self.ip\n ping_output = commands.getoutput(cmd)\n logger.debug(cmd)\n logger.debug(ping_output)\n return re.search(\"1[\\s\\w]+received\", ping_output) is not None", "def is_exit(self):\n return self._exit", "def isExit...
[ "0.6836565", "0.6645505", "0.6570112", "0.6554462", "0.6480884", "0.6478273", "0.6407413", "0.6407413", "0.62693983", "0.62350917", "0.62338996", "0.6198799", "0.6179991", "0.6174531", "0.6158552", "0.6158552", "0.6136162", "0.61064017", "0.6104029", "0.6080717", "0.6073656",...
0.62108445
11
Method to get the list of jobs that ended (list of objects) @ In, removeFinished, bool, optional, flag to control if the finished jobs need to be removed from the queue @ In, jobIdentifier, string, optional, if specified, only collects finished runs that start with this text. If not specified collect all. @ In, uniqueH...
def getFinished(self, removeFinished=True, jobIdentifier='', uniqueHandler="any"): # If the user does not specify a jobIdentifier, then set it to the empty # string because every job will match this starting string. if jobIdentifier is None: jobIdentifier = '' with self.__queueLock: finishe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jobs(self):\n return self.get_jobs()", "def get_jobs(self):\n return list(self._jobs.values())", "def get_jobs():\n \n rate_limit()\n command = [\"bjobs\", \"-o\", \"\\\"JOBID\", \"USER\", \"STAT\", \"QUEUE\", \"JOB_NAME\", \\\n \"delimiter=';'\\\"\"]\n command = \" \".join...
[ "0.64502734", "0.6436528", "0.6283521", "0.62269264", "0.62139946", "0.62125504", "0.62100804", "0.61677486", "0.6098955", "0.60787475", "0.60418314", "0.6028198", "0.6018798", "0.6018798", "0.60014904", "0.599979", "0.5957959", "0.59390384", "0.59356517", "0.59039205", "0.58...
0.76263756
0
Returns the number of runs currently running. @ In, None @ Out, activeRuns, int, number of active runs
def numRunning(self): #with self.__queueLock: # The size of the list does not change, only its contents, so I don't # think there should be any conflict if we are reading a variable from # one thread and updating it on the other thread. activeRuns = sum(run is not None for run in self.__running) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numRunningTotal(self):\n activeRuns = sum(run is not None for run in self.__running + self.__clientRunning)\n return activeRuns", "def num_runs(self):\n return len(self._h5[RUNS])", "def count(self):\n return len(self._runs)", "def numRunningProcesses():\n try:\n pro...
[ "0.7591416", "0.68168455", "0.6748966", "0.66708124", "0.6579573", "0.65488505", "0.64417726", "0.6410131", "0.6402467", "0.6376721", "0.6375267", "0.6345022", "0.62130815", "0.6138315", "0.6111627", "0.6095497", "0.6082245", "0.6071853", "0.6024449", "0.60172266", "0.5944273...
0.7716449
0
Returns the number of runs currently running in both lists. @ In, None @ Out, activeRuns, int, number of active runs
def numRunningTotal(self): activeRuns = sum(run is not None for run in self.__running + self.__clientRunning) return activeRuns
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numRunning(self):\n #with self.__queueLock:\n # The size of the list does not change, only its contents, so I don't\n # think there should be any conflict if we are reading a variable from\n # one thread and updating it on the other thread.\n activeRuns = sum(run is not None for run in self.__ru...
[ "0.73742795", "0.60178876", "0.6010247", "0.5858271", "0.5825993", "0.57989913", "0.5703689", "0.5625558", "0.55965495", "0.55326825", "0.5409394", "0.53721184", "0.53633726", "0.5292295", "0.5287816", "0.52436125", "0.5226099", "0.5221762", "0.5189199", "0.5178363", "0.51577...
0.69886774
1
get the 2 least significant bits of x
def get_lsb(self, x, w=32): mask = (1 << w) - 1 return int(x & mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lowest_set_bit(x):\n\n return x & -x", "def get_least_significant_bits(x, n):\n\n return x & ones(n)", "def _find_nearest_power_of_two(x):\n\n return 1 << (x - 1).bit_length()", "def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)", "def get_bit(x, k):\n\n return (x >> k) & 1", ...
[ "0.7873746", "0.7815262", "0.76105624", "0.7444084", "0.72898847", "0.7233955", "0.7032587", "0.70128715", "0.7009639", "0.70032257", "0.69697934", "0.6926626", "0.69237363", "0.689244", "0.6889694", "0.6867963", "0.68511176", "0.67402107", "0.6738769", "0.6728822", "0.672096...
0.6630434
21
Given a password reset token and a known suffix of the plaintext, it returns whether or not the current time is being used as a seed
def is_token_for_current_time(token, known_plaintext, current_time): expected_seed_times = compute_seed_from_known_pt(known_plaintext, token) for expected_time in expected_seed_times: if expected_time == (current_time & 0xFFFF): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recover_password_token(pw_token: bytes):\n current_time = int(time.time())\n for ut in range(current_time - 3700, current_time):\n if generate_password_reset_token(ut) == pw_token:\n return ut", "def check_token(self, user, token):\n\n # Parse the token\n try:\n ...
[ "0.6794901", "0.6129863", "0.60050464", "0.59580564", "0.5915051", "0.5903874", "0.58462745", "0.5814409", "0.5734428", "0.57036936", "0.5616565", "0.56165266", "0.5591911", "0.5549635", "0.5514903", "0.5503133", "0.542504", "0.54153347", "0.53809655", "0.53809655", "0.536677...
0.68625766
0
Figure out the number of commentlines to skip at the start of file `fn`.
def skiprows(fn): for i, line in enumerate(open(fn)): if line.startswith('#'): continue else: break return i
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ingest_c_comment_start(self, line, pos):\n\n if line[pos] == '/' and len(line) > pos + 1:\n if line[pos + 1] == '/':\n return -1\n elif line[pos + 1] == '*':\n self._in_block_comment = True\n return 2\n return 0", "def _count_...
[ "0.6325003", "0.61088085", "0.6048627", "0.5906633", "0.57828575", "0.57642734", "0.57391286", "0.5706694", "0.5703885", "0.57032496", "0.56964415", "0.56922525", "0.56638336", "0.56501114", "0.56063795", "0.55974144", "0.5585904", "0.5530964", "0.55217195", "0.551945", "0.55...
0.7273586
0
Returns a "cleaned" pandas.DataFrame from DESeq results.
def deseq_dataframe(fn, cols=None, db=None, index_col='id'): data = read_table(fn, sep='\t', skiprows=skiprows(fn)) if cols: data = data.ix[:, cols] if db: data = clean_unknown(data, db, index_col=index_col) data = data.set_index(index_col) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seqs_to_df(seqs):\n df_list = []\n names_list = []\n for index in range(len(seqs)):\n names_list.append(seqs[index].id)\n if isinstance(seqs[0], CodonSeq):\n newseqs = [[char for char in str(thisseq)] for thisseq in seqs]\n else:\n newseqs = [[char for char in str(thisseq.se...
[ "0.62880903", "0.60502124", "0.60502124", "0.6034405", "0.6022188", "0.60017467", "0.5998982", "0.59722084", "0.59583956", "0.59332675", "0.5902068", "0.5895687", "0.5866524", "0.58587545", "0.5846698", "0.5840986", "0.5839835", "0.5825371", "0.5811475", "0.58104783", "0.5797...
0.56104684
34
Remove widget from focus order. Called by the base widget.
def remove_widget_order(widget): order = sum(focus_order,()) if widget in order: # Remove from focus_order num = (order.index(widget)-1)/2 del focus_order[num]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop_focus(self):\n self._focus.pop()", "def deselect_selected_widget(self) -> None:\n if self.selected_widget is not None:\n self.handles.remove_selected_widget_handles()\n self.selected_widget = None\n self.attr_frame.update(self.selected_widget)", "def remov...
[ "0.7585213", "0.6783059", "0.67469937", "0.6638362", "0.66199666", "0.6545476", "0.6514593", "0.6440532", "0.6360511", "0.6356924", "0.6286058", "0.62227386", "0.6121271", "0.60427123", "0.60385764", "0.60380757", "0.60250694", "0.60202897", "0.5965557", "0.595393", "0.594826...
0.7259344
1
Initialize layers of the head.
def _init_layers(self): self.relu = nn.ReLU(inplace=True) self.rpn_convs = nn.ModuleList() for i in range(self.stacked_convs): chn = self.in_channels if i == 0 else self.feat_channels self.rpn_convs.append( ConvModule( chn, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_layers(self):\n self._init_predictor()\n if self.use_edge_fusion:\n self._init_edge_module()", "def _init_layers(self) -> None:\n self.self_attn = MultiheadAttention(**self.self_attn_cfg)\n self.cross_attn = MultiheadAttention(**self.cross_attn_cfg)\n self....
[ "0.7565452", "0.73801965", "0.7378758", "0.70826614", "0.70083666", "0.68058515", "0.6793121", "0.6747672", "0.67046845", "0.6699219", "0.6565106", "0.6552534", "0.6548868", "0.6536724", "0.6533556", "0.65013635", "0.64803135", "0.6478405", "0.6438143", "0.6429889", "0.642896...
0.60646474
34
This is a wrapper around the ._init function that creates a new model, so that hardware accelerators can be used as efficiently as possible. Unfortunately there currently are problems with distributed training, meaning that the wrapper has to call the function, without "distributing" the model to a single GPU. Currentl...
def new(self): self._init()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def basic_model_init(model_args, task_infos, tokenizer):\n config = AutoConfig.from_pretrained(\n model_args.model_name_or_path,\n num_labels=task_infos.num_labels,\n cache_dir=model_args.model_cache_dir,\n id2label=task_infos.id2label,\n label2id=task_infos.label2id,\n )\n...
[ "0.7108494", "0.70989704", "0.6982184", "0.69759727", "0.69231486", "0.6811584", "0.6737911", "0.6679192", "0.6632363", "0.6632031", "0.6617071", "0.6600098", "0.659591", "0.6590668", "0.6549994", "0.6499626", "0.64990157", "0.6471851", "0.64557433", "0.6455262", "0.64423114"...
0.0
-1
Computes the Euclidean distance between points x and y given in Cartesian coordinates.
def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float: distance_vector: np.ndarray = x - y distance = compute_norm(distance_vector) return distance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean(x,y): \n\treturn np.sqrt(np.sum((x-y)**2))", "def euclidean(x, y):\n ed = np.sqrt(np.sum((x-y)**2))\n # print ed\n return ed", "def euclidean_distance(x, y):\n x1, y1 = x\n x2, y2 = y\n return sqrt((x1 - x2)**2 + (y1 - y2)**2)", "def euclidean_dist(X, y):\n ret...
[ "0.79997194", "0.7874888", "0.78625673", "0.7853369", "0.7805038", "0.7797386", "0.7751556", "0.770697", "0.74992806", "0.736411", "0.72620714", "0.7228285", "0.7154645", "0.7146776", "0.71164244", "0.71129733", "0.71068466", "0.7067396", "0.70608413", "0.70492226", "0.701014...
0.72297156
11
Apply the Residual layer to the `input_`.
def forward(self, input_): out = self.fc(input_) out = self.bn(out) out = self.relu(out) return torch.cat([out, input_], dim=1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def residual(self, input_layer, net, scale=1.0, activation='RELU'):\n input_size = input_layer.get_shape().as_list()\n num_inputs = input_size[1]\n output_layer = scale*net(self, input_layer)\n output_size = output_layer.get_shape().as_list()\n num_outputs = outpu...
[ "0.73092496", "0.6719339", "0.6124837", "0.6054918", "0.5994632", "0.598588", "0.59193397", "0.5915656", "0.5908799", "0.5894215", "0.5880474", "0.5809454", "0.5787263", "0.573035", "0.5718913", "0.57104665", "0.5687326", "0.5679917", "0.567038", "0.56456417", "0.56440127", ...
0.5036586
86
A fast approximation of the cumulative distribution function of the standard normal.
def approx_standard_normal_cdf(x): return 0.5 * (1.0 + torch.tanh(np.sqrt(2.0 / np.pi) * (x + 0.044715 * torch.pow(x, 3))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cumulative_normal_distribution(z):\n from math import exp\n\n b1 = +0.319381530\n b2 = -0.356563782\n b3 = +1.781477937\n b4 = -1.821255978\n b5 = +1.330274429\n p = +0.2316419\n c = +0.39894228\n\n if z >= 0.0:\n t = 1.0 / (1.0 + p * z)\n return 1.0 - c * exp(-z * z / ...
[ "0.78611887", "0.7343288", "0.7198062", "0.7152584", "0.6901485", "0.68538517", "0.6798808", "0.67920876", "0.6643512", "0.6601391", "0.6601132", "0.6533728", "0.65252787", "0.6494914", "0.63961923", "0.63672835", "0.63424546", "0.63214195", "0.6320946", "0.6288614", "0.62712...
0.7466885
1
Get a predefined beta schedule for the given name. The beta schedule library consists of beta schedules which remain similar in the limit of num_diffusion_timesteps. Beta schedules may be added, but should not be removed or changed once they are committed to maintain backwards compatibility.
def get_named_beta_schedule(schedule_name, num_diffusion_timesteps): if schedule_name == 'linear': scale = 1000 / num_diffusion_timesteps beta_start = scale * 0.0001 beta_end = scale * 0.02 return np.linspace(beta_start, beta_end, num_diffusion_timesteps, dtype=np.float64) elif s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_schedule(self, name):\n return self.__schedules.get(name, None)", "def get_beta(self, epoch, beta_start=None, beta_end=None):\r\n if beta_start is None:\r\n beta_start = self.beta_start\r\n if beta_end is None:\r\n beta_end = self.beta_end\r\n\r\n if epoc...
[ "0.60553104", "0.60200906", "0.52869034", "0.5179134", "0.5165891", "0.51009977", "0.5097478", "0.50822216", "0.5066024", "0.5035433", "0.49954906", "0.49711308", "0.49685678", "0.4915655", "0.49151757", "0.48921287", "0.48621523", "0.48472726", "0.48368165", "0.48064187", "0...
0.8515777
0
Take the mean over all nonbatch dimensions.
def mean_flat(tensor): return tensor.mean(dim=list(range(1, len(tensor.shape))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_allcnnc():\n # TODO implement pre forward hook to adapt to arbitary image size for other data sets than cifar100\n return nn.Sequential(\n nn.AvgPool2d(kernel_size=(6, 6)),\n flatten()\n )", "def ensemble_mean(self):\n return self.mean(dim='mem')", "def mean_flat(tensor):...
[ "0.69110435", "0.6781341", "0.67724854", "0.67624015", "0.6731038", "0.67190164", "0.67012674", "0.66761786", "0.66351634", "0.65871763", "0.65857583", "0.6555452", "0.6552374", "0.6535818", "0.6497036", "0.64801466", "0.6465107", "0.6448588", "0.6445976", "0.64292395", "0.64...
0.67947525
1
Sums all dimensions except the first.
def sum_except_batch(x, num_dims=1): return x.reshape(*x.shape[:num_dims], -1).sum(-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dim_zero_sum(x: Tensor) ->Tensor:\n return torch.sum(x, dim=0)", "def sum(self, axis=None, keepdims=False):\n return F.Sum.apply(self, axis, keepdims)", "def sum_to_0d(x):\n assert_equal(x.ndim, 1)\n return np.squeeze(np.sum(x, keepdims=True))", "def sum(self, axis: int = ...
[ "0.68612945", "0.673936", "0.66360873", "0.65455437", "0.63205636", "0.6302802", "0.62913257", "0.6283977", "0.6270764", "0.6264549", "0.6185366", "0.61743665", "0.6151092", "0.61060256", "0.6092697", "0.6092065", "0.6079816", "0.6053398", "0.6034476", "0.60094094", "0.600939...
0.66587394
2
Get the prior KL term for the variational lowerbound, measured in bitsperdim. This term can't be optimized, as it only depends on the encoder.
def _prior_gaussian(self, x_start): batch_size = x_start.shape[0] t = torch.tensor([self.num_timesteps - 1] * batch_size, device=x_start.device) qt_mean, _, qt_log_variance = self.gaussian_q_mean_variance(x_start, t) kl_prior = normal_kl(mean1=qt_mean, logvar1=qt_log_variance, mean2=0.0,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kl(self):\n weights_logvar = self.weights_logvar\n kld_weights = self.prior_stdv.log() - weights_logvar.mul(0.5) + \\\n (weights_logvar.exp() + (self.weights.pow(2) - self.prior_mean)) / (\n 2 * self.prior_stdv.pow(2)) - 0.5\n kld_bias ...
[ "0.696338", "0.646278", "0.64278895", "0.64149857", "0.64079726", "0.6306587", "0.62923366", "0.62595695", "0.62472725", "0.62327623", "0.6143658", "0.6136483", "0.6135767", "0.61226094", "0.6118728", "0.6108658", "0.6108416", "0.6103524", "0.60923976", "0.608892", "0.608836"...
0.5523525
76
The ReGLU activation function from [1].
def reglu(x: Tensor) ->Tensor: assert x.shape[-1] % 2 == 0 a, b = x.chunk(2, dim=-1) return a * F.relu(b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gelu_activation(inp):\n out = 1 + tf.tanh(np.sqrt(np.pi) * (inp + 0.044715 * tf.pow(inp, 3)))\n out *= 0.5 * inp\n return out", "def gelu_activation(inp):\n out = 1 + tf.tanh(np.sqrt(np.pi) * (inp + 0.044715 * tf.pow(inp, 3)))\n out *= 0.5 * inp\n return out", "def gelu(x):\n return x ...
[ "0.71268797", "0.71268797", "0.6673697", "0.6661231", "0.6644295", "0.64964145", "0.64248437", "0.6390991", "0.63749963", "0.63674015", "0.62990075", "0.62816226", "0.62739545", "0.62688816", "0.626637", "0.6227934", "0.6215054", "0.6212191", "0.6207483", "0.62039685", "0.619...
0.0
-1
The GEGLU activation function from [1].
def geglu(x: Tensor) ->Tensor: assert x.shape[-1] % 2 == 0 a, b = x.chunk(2, dim=-1) return a * F.gelu(b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gelu_activation(inp):\n out = 1 + tf.tanh(np.sqrt(np.pi) * (inp + 0.044715 * tf.pow(inp, 3)))\n out *= 0.5 * inp\n return out", "def gelu_activation(inp):\n out = 1 + tf.tanh(np.sqrt(np.pi) * (inp + 0.044715 * tf.pow(inp, 3)))\n out *= 0.5 * inp\n return out", "def gelu(x):\n return x ...
[ "0.77004826", "0.77004826", "0.74210227", "0.7176632", "0.7140944", "0.7138531", "0.70931953", "0.7090489", "0.7034269", "0.70205075", "0.6986577", "0.6968592", "0.6946415", "0.692014", "0.67789376", "0.6763823", "0.6763823", "0.6763823", "0.6763823", "0.6763823", "0.6763823"...
0.6771344
15
Create a "baseline" `ResNet`.
def make_baseline(cls: Type['ResNet'], *, d_in: int, n_blocks: int, d_main: int, d_hidden: int, dropout_first: float, dropout_second: float, d_out: int) ->'ResNet': return cls(d_in=d_in, n_blocks=n_blocks, d_main=d_main, d_hidden=d_hidden, dropout_first=dropout_first, dropout_second=dropout_second, normalizatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resnet10(**kwargs):\n model = ResNet(BasicBlock, [1, 1, 1, 1], **kwargs)\n return model", "def resnet18(**kwargs):\n model = ResNet(BasicBlock, [2, 2, 2, 2], **kwargs)\n return model", "def resnet18(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [2, 2, 2, 2], **kwargs)\n\n retu...
[ "0.6327897", "0.614722", "0.610232", "0.60412157", "0.5915927", "0.58924466", "0.5845502", "0.5843595", "0.5838634", "0.5825884", "0.580996", "0.5805025", "0.5805025", "0.5805025", "0.5805025", "0.5805025", "0.57855463", "0.5767206", "0.5652836", "0.564936", "0.563801", "0....
0.8212792
0
get "extraction.conv.cfg" and covert to torch.nn
def create_features(self, cfg_path): def parse_cfg(cfg_path): blocks = [] fp = open(cfg_path, 'r') block = None line = fp.readline() while line != '': line = line.rstrip() if line == '' or line[0] == '#': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_conv_layers(self):\n conv = nn.Sequential(\n nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=2, padding=1), # padding=3 so, output is 224.\n nn.LeakyReLU(0.1, inplace=True),\n nn.MaxPool2d(kernel_size=2, stride=2),\n\n nn.Conv2d(64, 192, ...
[ "0.5964775", "0.59544456", "0.59139544", "0.58239293", "0.58188504", "0.581114", "0.5785252", "0.5771443", "0.5764588", "0.5661936", "0.56529933", "0.564753", "0.56391567", "0.5615194", "0.55986565", "0.5581418", "0.5579392", "0.5574774", "0.5546392", "0.55307055", "0.552963"...
0.54590875
27
padding = 3, with BatchNormalization
def _make_conv_layers_bn_padding(self): ## 20 Convs, used for pretrained by IMAGE Net 1000 class conv = nn.Sequential( nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=2, padding=3, bias=False), # padding=3 so, output is 224. nn.BatchNorm2d(64), nn.LeakyReLU(0....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Batch_Size_Normalization(batch, batch_len, pad_token, batch_size):\n max_length = max(batch_len)\n current_batch_len = len(batch)\n need_more = batch_size-current_batch_len\n if need_more==0:\n return batch\n\n padding_array = np.ones(max_length)*pad_token\n for i in range(need_more):\...
[ "0.72193974", "0.64116895", "0.6398286", "0.6278596", "0.6241174", "0.6213583", "0.6205278", "0.6202304", "0.6192254", "0.6165739", "0.61524904", "0.6137434", "0.61371434", "0.6120407", "0.6105012", "0.6102311", "0.6098714", "0.6076373", "0.60317606", "0.6023929", "0.6023887"...
0.6412125
1
padding = 1 and No BatchNormalization like extraction.conv.cfg
def _make_conv_layers(self): conv = nn.Sequential( nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=2, padding=1), # padding=3 so, output is 224. nn.LeakyReLU(0.1, inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(64, 192, 3, padding=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_conv_layers_bn_padding(self): ## 20 Convs, used for pretrained by IMAGE Net 1000 class\n conv = nn.Sequential(\n nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=2, padding=3, bias=False), # padding=3 so, output is 224.\n nn.BatchNorm2d(64),\n nn.Lea...
[ "0.64856136", "0.6292985", "0.62474155", "0.6165389", "0.61221445", "0.6104988", "0.5827737", "0.5827291", "0.5804672", "0.5775932", "0.57418394", "0.5692178", "0.56821215", "0.5674767", "0.56700504", "0.56519413", "0.56416166", "0.56329095", "0.5624907", "0.56231296", "0.560...
0.53688526
63
Set the eval dataloader to use by Trainer. It supports user defined dataloader set as an attribute in the constructor. When the attribute is None, The dataloader is defined using eval_dataset and the `data_loader_engine` specified in Training Arguments.
def get_eval_dataloader(self, eval_dataset=None): if self.eval_dataloader is not None: return self.eval_dataloader if eval_dataset is None and self.eval_dataset is None: raise ValueError("Trainer: evaluation requires an eval_dataset.") eval_dataset = eval_dataset if eval...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_dataloader(self) -> DataLoader:\n return self._custom_data_loader()", "def train_dataloader(self) -> torch.utils.data.DataLoader: \n return torch.utils.data.DataLoader(self.dataset_train, **self.dl_kwargs)", "def eval_loader(self, loader):\r\n\t\treturn predict(model=self.model,...
[ "0.6730854", "0.65946466", "0.6541422", "0.6369222", "0.62790823", "0.62421876", "0.62364036", "0.6206105", "0.62049025", "0.61828923", "0.6165432", "0.6135348", "0.6100907", "0.609356", "0.6048407", "0.60442257", "0.5902834", "0.5896784", "0.5891272", "0.58649844", "0.584214...
0.7311328
0
Changes the current password, needs old password if there is one. Raises PasswordError if not successful.
def change_password(password: str, old_password=None) -> None: logging.debug("called") if not pwd_gate: raise SecretSharingError("No password gate given.") if pwd_gate["pwd"]: if not bcrypt.checkpw(old_password.encode(ENCODING), pwd_gate.get("pwd").encode(ENCODING)): raise Passwo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_password(self, new_password=None):\n\n self.password = generate_password_hash(new_password)\n\n if self.save(verbose=False):\n self.logger.warn('Updated password! %s' % self)\n else:\n raise AttributeError('Password update failed!')", "def change_password(sel...
[ "0.76627755", "0.7602145", "0.7587967", "0.75471175", "0.7457179", "0.74287164", "0.7362081", "0.72914904", "0.7246782", "0.7222607", "0.722055", "0.7194476", "0.7151013", "0.71412134", "0.71380633", "0.71162885", "0.70733696", "0.70523053", "0.7047536", "0.70421386", "0.7038...
0.7177639
12
r"""Sometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers handle data entered by the
def url_fix(s, charset='utf-8'): # First step is to convert backslashes (which are invalid in URLs anyways) # to slashes. This is consistent with what Chrome does. s = s.replace('\\', '/') # For the specific case that we look like a malformed windows URL # we want to fix this up manually: if (...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_url(self, url):\r\n if not self.markdown.safeMode:\r\n # Return immediately bipassing parsing.\r\n return url\r\n \r\n try:\r\n scheme, netloc, path, params, query, fragment = url = urlparse(url)\r\n except ValueError:\r\n # Bad u...
[ "0.7120271", "0.6995937", "0.6967897", "0.68873763", "0.6854298", "0.67028886", "0.65997857", "0.6580614", "0.65133977", "0.65025586", "0.647296", "0.64683425", "0.6365366", "0.6261262", "0.6230753", "0.6191684", "0.61820185", "0.6154851", "0.6109624", "0.6106912", "0.6104100...
0.6234788
14
Retrieve set of tokens from the str definition. Depending on lemm_always parameter, the lemmatization will be applied always or only if the word is not in vocabulary. Words that are not in vocabulary will be dropped.
def get_filtered_set_tokens(self, definition: str) -> Set[str]: doc = self.ppl(definition) if self.lemm_always: tokens = [word.lemma for sent in doc.sentences for word in sent.words] tokens = [t.lower() for t in tokens if t.lower() in self.word_dictionary] tokens = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tokens(sent):\n return word_tokenize(sent)", "def lemmatize_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = None\n if self.lemmatize_method == 'wordnet':\n cleaned_tokens = [self.lemmatizer.lemmatize(token) for token in tokens]\n else:\n ...
[ "0.6536726", "0.65158385", "0.64152455", "0.63985634", "0.63445705", "0.6308339", "0.6304965", "0.62941545", "0.6275843", "0.6274134", "0.6258365", "0.62497556", "0.6247032", "0.61675715", "0.61623174", "0.61409986", "0.61138016", "0.61123854", "0.61095995", "0.61010176", "0....
0.6725453
0
Building edges from the given word. SelfCycles will be dropped if self.drop_self_cycles was set to True
def get_from_word_edges(self, word: str) -> Set[str]: all_edges = set() for def_dict in self.word_dictionary[word]: processed_def = self.get_filtered_set_tokens( definition=def_dict["definition"] ) if self.drop_self_cycles: if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_graph(self):\n\n for i in range(0, self.num_words):\n self.graph.append([])\n\n for word in self.words:\n for pos in range(0, 4):\n for let in range(0, 26):\n temp = ''\n if pos > 0:\n temp = wo...
[ "0.61835706", "0.60803604", "0.6056407", "0.59981906", "0.5982105", "0.5930936", "0.59160554", "0.586869", "0.5850184", "0.58221626", "0.5806796", "0.57887083", "0.5767803", "0.5735497", "0.56786835", "0.5661751", "0.56515664", "0.56486356", "0.5646709", "0.56319726", "0.5620...
0.6158817
1
Take a pretty version of an ethernet address and convert it to a string of bytes.
def ether_atob(pretty): addr = "" for i in 0, 3, 6, 9, 12, 15: addr += "%c" % int(pretty[i:i+2], 16) return addr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ether_btoa(bytes):\n\n pretty = \"\"\n for i in (range(5)):\n pretty += hex(bytes[i])[2:4] # Strip the 0x from the string\n pretty += ':'\n \n pretty += hex(bytes[5])[2:4] # Strip the 0x from the string\n\n return pretty", "def bt_addr_to_str(bt_addr):\n return \":\".join(...
[ "0.71535116", "0.6786328", "0.67225295", "0.6630974", "0.65079457", "0.64472204", "0.6335762", "0.6322627", "0.6316357", "0.61431503", "0.6120108", "0.6077547", "0.6052179", "0.5979265", "0.5979265", "0.5979265", "0.5979265", "0.59479356", "0.5942241", "0.593506", "0.5870557"...
0.77720016
0
Return the current or final job duration.
def duration(self): ended = time.time() if self.ended is None else self.ended return ended - self.started
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duration(self):\n started = self.started_at\n finished = self.finished_at\n if started and finished:\n return str(finished - started)\n else:\n return None # can't compute yet", "def duration(self):\n if not self.started:\n return None\n ...
[ "0.79896915", "0.7687139", "0.7546398", "0.75435925", "0.75260454", "0.74763864", "0.7409453", "0.7365377", "0.7346771", "0.7343953", "0.7314254", "0.72863644", "0.724786", "0.7240286", "0.7240019", "0.72271997", "0.7140382", "0.713773", "0.71223843", "0.70911616", "0.7072825...
0.7381795
7
Get the object attached to the anchor control.
def getAttachment(self): log_func.warning(u'The method of obtaining the object attached to the anchor control is not defined') return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAnchor(self):\n return self.anchor", "def anchor(self):\n return self._anchor", "def anchor_id(self):\n return self.properties.get('AnchorId', None)", "def anchor(self):\n # self.attributes cannot be empty; will cause an error on init.\n return self.attributes[-1]", "def g...
[ "0.7439054", "0.7217367", "0.64824396", "0.6276082", "0.6200907", "0.6162962", "0.60405076", "0.60405076", "0.60405076", "0.6014204", "0.59962475", "0.59792626", "0.5971711", "0.5933764", "0.5852976", "0.5778357", "0.57573456", "0.5713315", "0.5709336", "0.5709336", "0.570933...
0.7144128
2
Calculation of the position of the control point in pixels.
def calcPixPosition(self, svg_position=None): if svg_position is None: svg_position = self._position if self._mnemoscheme is None: log_func.warning(u'Not defined mimic for anchor <%s>' % self.getName()) return 0, 0 # Determine the size of the mimic diagram r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pixel_pos(self):\n\n c = self.get_center()\n\n return Tank.three_by_three(c[0],c[1])", "def get_pos_in_pixels(self):\n pixelpos = Vector(self.pos.x * 32, -self.pos.y * 32)\n return pixelpos + self.offset", "def get_pix_pos(self):\r\n return vec((self.grid_pos[0]*self....
[ "0.7298711", "0.7286304", "0.69999504", "0.682003", "0.6788774", "0.675914", "0.65536654", "0.6481827", "0.6478598", "0.6477979", "0.6470656", "0.6448749", "0.6435703", "0.63991654", "0.639327", "0.6373377", "0.63534117", "0.6279551", "0.62531817", "0.6244868", "0.6232852", ...
0.0
-1