query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Attach a user's credentials to a response.
def attach_credentials(response, user): response.set_cookie(_CHIRP_SECURITY_TOKEN_COOKIE, _create_security_token(user))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_credentials():", "def test_credentialsSetResponse(self):\n cred = imap4.PLAINCredentials()\n cred.setResponse(b'\\0testuser\\0secret')\n self.assertEqual(cred.username, b'testuser')\n self.assertEqual(cred.password, b'secret')", "def get_user_details(self, response):\n ...
[ "0.62017906", "0.61743724", "0.5863988", "0.5680074", "0.5572465", "0.55617046", "0.55614007", "0.5557779", "0.5540854", "0.55386317", "0.5523414", "0.5503794", "0.5500769", "0.54540765", "0.5449879", "0.5427805", "0.54111546", "0.54075456", "0.53991103", "0.5397431", "0.5392...
0.77924997
0
Get the current loggedin user's.
def get_current_user(request): cred = None token = request.COOKIES.get(_CHIRP_SECURITY_TOKEN_COOKIE) if token: cred = _parse_security_token(token) # If this is a POST, look for a base64-encoded security token in # the CHIRP_Auth variable. if cred is None and request.method == 'POST': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_users(self):\n active_sessions = Session.objects.filter(expire_date__gte=timezone.now())\n user_id_list = []\n for session in active_sessions:\n data = session.get_decoded()\n user_id_list.append(data.get('_auth_user_id', None))\n # Query all logged...
[ "0.7689059", "0.7354096", "0.73099166", "0.7301284", "0.7278969", "0.7278969", "0.7278969", "0.7278969", "0.7261865", "0.72201365", "0.72056025", "0.71270096", "0.7115699", "0.7099263", "0.705866", "0.705866", "0.705866", "0.70543313", "0.70526934", "0.7051824", "0.7009778", ...
0.0
-1
Returns the URL of a login page that redirects to 'path' on success.
def create_login_url(path): return "/auth/hello?redirect=%s" % path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GET_login(self):\r\n\r\n # dest is the location to redirect to upon completion\r\n dest = request.get.get('dest','') or request.referer or '/'\r\n return LoginPage(dest = dest).render()", "def login_page():\n text = '<a href=\"%s\">Authenticate with Okta</a>'\n return text % create...
[ "0.7192956", "0.6800965", "0.66827124", "0.66450155", "0.65036446", "0.6477103", "0.6422007", "0.63984793", "0.6378266", "0.6354311", "0.6330546", "0.6328878", "0.6328678", "0.63281304", "0.63243735", "0.6307606", "0.62386686", "0.6232495", "0.6208821", "0.62072647", "0.61902...
0.79841524
0
Create an HTTP response that will log a user out. The redirect param can be a relative URL in which case the user will go back to the same page when logging in. This is useful for switching users like on the playlist tracker page.
def logout(redirect=None): # If the user was signed in and has a cookie, clear it. logout_url = _FINAL_LOGOUT_URL if redirect: logout_url = '%s?redirect=%s' % (logout_url, redirect) response = http.HttpResponseRedirect(logout_url) response.set_cookie(_CHIRP_SECURITY_TOKEN_COOKIE, '') ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redirect(self) -> WerkzeugResponse:\n\n _dict = self.unpack_redirect()\n return self.perform_logout(_dict, BINDING_HTTP_REDIRECT)", "def logout_redirect(request):\n logout(request)\n\n # Build the URL\n login_url = furl(login_redirect_url(request, next_url=request.build_absolute_uri())...
[ "0.7326342", "0.73198265", "0.7284289", "0.7238084", "0.71671414", "0.71593136", "0.7151981", "0.71129674", "0.70879936", "0.7079564", "0.7043046", "0.7023484", "0.70197374", "0.7015899", "0.701423", "0.7005902", "0.69992566", "0.69971395", "0.69959456", "0.69959456", "0.6989...
0.77370954
0
A URLsafe token that authenticates a user for a password reset.
def get_password_reset_token(user): return base64.urlsafe_b64encode(_create_security_token(user))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_password_reset_token():\n j = request.get_json(force=True)\n user_requested = j['user'].lower()\n\n # Disabled user accounts can not request for a new password.\n target_user = User.query.filter_by(mail=user_requested).first()\n\n if target_user is None:\n return Errors.UNKNOWN_US...
[ "0.7068343", "0.6979489", "0.6916166", "0.69147855", "0.68065274", "0.6756396", "0.6722973", "0.67225903", "0.6698638", "0.66768074", "0.66731113", "0.66554016", "0.6653242", "0.65514797", "0.6548692", "0.65352726", "0.65276843", "0.65198666", "0.6503898", "0.650001", "0.6499...
0.76141065
0
Extracts an email address from a valid password reset token.
def parse_password_reset_token(token): try: token = base64.urlsafe_b64decode(str(token)) except TypeError: return None cred = _parse_security_token(token) return cred and cred.email
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_password_reset_token(token: str) -> tp.Optional[str]:\n try:\n decoded_token = jwt.decode(token, config.SECRET_KEY,\n algorithms=[ALGORITHM])\n except InvalidTokenError:\n return None\n if decoded_token[\"sub\"] != PASSWORD_RESET_SUBJECT:\n ...
[ "0.7039985", "0.68341273", "0.68253404", "0.679571", "0.67610675", "0.6760937", "0.6741547", "0.6654214", "0.65531987", "0.640023", "0.62692463", "0.6200448", "0.61567795", "0.6123652", "0.60978174", "0.60570717", "0.6042387", "0.60345566", "0.60287344", "0.6026899", "0.60162...
0.80168754
0
Return the phase series object for the scenario.
def __getitem__(self, key): if key in self._tracker_dict: return self._tracker_dict[key].series raise ScenarioNotFoundError(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPhase(phase):", "def GetPhase(self):\n ...", "def phase(self):\r\n\r\n #XXX calcluate this from the standard output, instead of recalculating:\r\n\r\n tseries_length = self.input.data.shape[0]\r\n spectrum_length = self.spectrum.shape[-1]\r\n\r\n phase = np.zeros((tser...
[ "0.68655944", "0.6622455", "0.6455815", "0.6428417", "0.63313764", "0.62835324", "0.6200906", "0.61574143", "0.6050085", "0.59065604", "0.5901168", "0.58883613", "0.58803606", "0.58803606", "0.58803606", "0.58332235", "0.58091795", "0.5807804", "0.57886523", "0.57490265", "0....
0.0
-1
Register a phase series.
def __setitem__(self, key, value): self._tracker_dict[key] = ParamTracker( self._data.records(extras=False), value, area=self.area, tau=self.tau)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_phases(self):\n start_dates, end_dates = self._phase_range(self._change_dates)\n pop_list = [self.pop_dict[date] for date in start_dates]\n phase_series = PhaseSeries(\n self.dates[0], self.dates[-1], self.population, use_0th=self._use_0th\n )\n phase_itr =...
[ "0.5775817", "0.5751883", "0.5649973", "0.54143023", "0.5328758", "0.53215307", "0.5314388", "0.5310776", "0.53023094", "0.529634", "0.5235999", "0.5228771", "0.52222896", "0.5179229", "0.5135855", "0.51105607", "0.5090179", "0.50680315", "0.49861172", "0.49655068", "0.496486...
0.0
-1
Set the range of data and reference date to determine past/future of phases.
def timepoints(self, first_date=None, last_date=None, today=None): self._data.timepoints(first_date=first_date, last_date=last_date, today=today) self._init_trackers()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_date_range(self, start_date, end_date):\n self._validate_date_range(start_date, end_date)\n self.start_date = pd.Timestamp(start_date)\n self.end_date = pd.Timestamp(end_date)", "def set_range(self, start=None, end=None, occurrences=None):\n if start is None:\n if s...
[ "0.60431415", "0.59922713", "0.5831708", "0.5738246", "0.5724847", "0.56485236", "0.55952454", "0.5588354", "0.54657805", "0.5421708", "0.5348214", "0.53387636", "0.5298466", "0.52646214", "0.52533823", "0.5250024", "0.5242356", "0.52234524", "0.5207322", "0.5201655", "0.5200...
0.0
-1
Display or save a line plot of the dataframe.
def line_plot(self, df, show_figure=True, filename=None, **kwargs): if self._interactive and show_figure: return line_plot(df=df, filename=None, **kwargs) if not self._interactive and filename is not None: return line_plot(df=df, filename=filename, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linePlot(self):\n clf()\n plot(self.x,self.averages)\n xlabel('X Label (units)')\n ylabel('Y Label (units)')\n savefig('line.png')", "def graph(df):\n df.plot()\n plt.show()", "def line_graph():\r\n #create the data in an array\r\n xval = np.arange(0,6,(np.pi*...
[ "0.7247399", "0.7064947", "0.7009128", "0.68883586", "0.6884624", "0.6852269", "0.66661745", "0.6652541", "0.66047895", "0.6523031", "0.6508674", "0.6485286", "0.6472643", "0.6460924", "0.6446598", "0.6407095", "0.63918054", "0.6377627", "0.63767356", "0.6328446", "0.628481",...
0.7667313
0
Complement the number of recovered cases, if necessary.
def complement(self, **kwargs): self._data.switch_complement(whether=True, **kwargs) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup(self):\n self.final_params = self.final_params_expected[self.count]\n self.flag = self.flag_expected[self.count]\n self.count += 1\n self.count = self.count % len(self.flag_expected)", "def subSanity(self):\n\t\tself.sanity -= 1\n\t\tif self.sanity < -10:\n\t\t\tself.sanit...
[ "0.5762584", "0.5644065", "0.56118023", "0.55019015", "0.54095125", "0.5408706", "0.5404511", "0.5397213", "0.5393315", "0.53197366", "0.52725595", "0.5261769", "0.52091825", "0.52083826", "0.5206617", "0.51571816", "0.5151571", "0.5134796", "0.5121799", "0.5117648", "0.51032...
0.0
-1
Restore the raw records. Reverse method of covsirphy.Scenario.complement().
def complement_reverse(self): self._data.switch_complement(whether=False) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore(self):\n raise NotImplementedError", "def restore_data(self):\n self.R = self._Ro\n del self._Ro", "def restore(self):\n self.u = self.ub.copy()\n self.w = self.wb.copy()\n self.v = self.vb.copy()\n if self.en_bias: self.b = self.bb.copy()", "def r...
[ "0.65303206", "0.6500232", "0.6468013", "0.64254963", "0.6402042", "0.61993724", "0.6194877", "0.6174157", "0.61449206", "0.61389244", "0.61376435", "0.6097324", "0.6025152", "0.60112494", "0.59458935", "0.5927359", "0.58817554", "0.58671457", "0.5840398", "0.5822324", "0.581...
0.5241369
71
Show the details of complement that was (or will be) performed for the records.
def show_complement(self, **kwargs): self._data.switch_complement(whether=None, **kwargs) return self._data.show_complement()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Complement(self):\n if (self.translated == False):\n for i in range(len(self.alignment)):\n self.alignment[i].seq = self.alignment[i].seq.complement()\n self.Show(self.displayedColumn)\n self.BackupAlignment\n else:\n self.AlertMessage(\"...
[ "0.5775242", "0.5743464", "0.55356264", "0.5504451", "0.5423902", "0.5415966", "0.53729266", "0.536349", "0.5347733", "0.52742505", "0.5256045", "0.5240801", "0.52383417", "0.5233155", "0.5202733", "0.5180749", "0.51699567", "0.5141384", "0.5086646", "0.5080214", "0.5080147",...
0.72387177
0
Convert abbreviated variable names to complete names.
def _convert_variables(self, abbr, candidates): if abbr is None: return [self.CI, self.F, self.R] if abbr == "all": return self._ensure_list(candidates, name="candidates") abbr_dict = {"C": self.C, "I": self.CI, "F": self.F, "R": self.R, } variables = list(abbr) i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertVariableName(variable):\n lowerSplits = [item.lower() for item in variable.split('_')]\n if len(lowerSplits) == 1:\n return lowerSplits[0]\n else:\n return lowerSplits[0] + ''.join([item.capitalize()\n for item in lowerSplits[1:]])", "def ...
[ "0.68976355", "0.6788493", "0.67282575", "0.6605132", "0.66031903", "0.6471281", "0.6463167", "0.63647664", "0.63447404", "0.6326731", "0.6291707", "0.627928", "0.6247765", "0.6219434", "0.6218662", "0.62027025", "0.61862946", "0.60936743", "0.60927546", "0.6065432", "0.60617...
0.59086
32
Return the records as a dataframe.
def records(self, variables=None, **kwargs): # Get necessary data for the variables all_df = self._data.records_all().set_index(self.DATE) variables = self._convert_variables(variables, all_df.columns.tolist()) df = all_df.loc[:, variables] # Figure if self._data.compleme...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataframe(self):\n if not self.all_records:\n print('No rows cached.')\n return\n dict_list = [row.as_dict() for row in self.all_records]\n columns = self.all_records[0].keys\n dataframe = pd.DataFrame(dict_list, columns=columns)\n return dataframe", "...
[ "0.81605434", "0.7689365", "0.7654657", "0.75927025", "0.75107545", "0.75014997", "0.7491799", "0.74763435", "0.74449694", "0.74304926", "0.74304926", "0.74304926", "0.74304926", "0.74304926", "0.73737586", "0.73647803", "0.7351118", "0.73190165", "0.72353095", "0.72085106", ...
0.0
-1
Return the number of daily new cases (the first discreate difference of records).
def records_diff(self, variables=None, window=7, **kwargs): window = self._ensure_natural_int(window, name="window") df = self.records(variables=variables, show_figure=False).set_index(self.DATE) df = df.diff().dropna() df = df.rolling(window=window).mean().dropna().astype(np.int64) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def no_new_cases_count(day: int, month: int, year: int = 2020) -> int:\r\n \r\n # Your code goes here (remove pass)\r", "def get_number_days(self):\r\n return 1", "def _first_good_date(self, day):\n count = 0\n while True:\n try:\n self.data.loc[day - timede...
[ "0.63417804", "0.6153473", "0.60129416", "0.58677965", "0.58234876", "0.578511", "0.5671648", "0.56618786", "0.56148905", "0.56128377", "0.557568", "0.55542594", "0.5486608", "0.5483065", "0.54804957", "0.54483485", "0.54370016", "0.5394437", "0.5359422", "0.5352396", "0.5352...
0.5627104
8
Initialize dictionary of trackers.
def _init_trackers(self): data = copy.deepcopy(self._data) series = ParamTracker.create_series( first_date=data.first_date, last_date=data.today, population=data.population) tracker = ParamTracker( record_df=self._data.records(extras=False), phase_series=series, area=self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, keys_to_track):\r\n self.keys_to_track = keys_to_track\r\n self.tracker = {}\r\n for key_to_track in self.keys_to_track:\r\n self.tracker[key_to_track] = {}", "def __init__(self,max_age=100,min_hits=10):\n self.max_age = max_age\n self.min_hits = m...
[ "0.75012267", "0.6427343", "0.62639487", "0.6080427", "0.6077556", "0.60689676", "0.60171473", "0.59739995", "0.59257585", "0.59130996", "0.59109986", "0.5875346", "0.5845771", "0.58061785", "0.5783098", "0.5781152", "0.57698804", "0.5769008", "0.57673883", "0.57673883", "0.5...
0.78069323
0
Ensure that the phases series is registered. If not registered, copy the template phase series.
def _tracker(self, name, template="Main"): # Registered if name in self._tracker_dict: return self._tracker_dict[name] # Un-registered and create it if template not in self._tracker_dict: raise ScenarioNotFoundError(template) tracker = copy.deepcopy(self._...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_phases(self):\n start_dates, end_dates = self._phase_range(self._change_dates)\n pop_list = [self.pop_dict[date] for date in start_dates]\n phase_series = PhaseSeries(\n self.dates[0], self.dates[-1], self.population, use_0th=self._use_0th\n )\n phase_itr =...
[ "0.5616218", "0.5055248", "0.4934233", "0.48037916", "0.47497964", "0.46875504", "0.46473768", "0.46447363", "0.46103522", "0.45802236", "0.456944", "0.4568185", "0.4544172", "0.45340922", "0.44988102", "0.44769245", "0.44675794", "0.441166", "0.4406575", "0.439608", "0.43933...
0.0
-1
Add a new phase. The start date will be the next date of the last registered phase.
def add(self, name="Main", end_date=None, days=None, population=None, model=None, **kwargs): if end_date is not None: self._ensure_date(end_date, name="end_date") tracker = self._tracker(name) try: tracker.add( end_date=end_date, days=days, population=popu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_phase(self, phase):\n\n if not phase.name in self.phase_dict:\n self.phase_dict[phase.name] = phase\n else:\n if phase.energy < self.phase_dict[phase.name].energy:\n self.phase_dict[phase.name] = phase\n self._phases.append(phase)\n phase.ind...
[ "0.67498213", "0.6707674", "0.6699049", "0.6079348", "0.6043419", "0.5663631", "0.56081426", "0.5521325", "0.54811716", "0.54338104", "0.5369988", "0.53258663", "0.52765054", "0.5261605", "0.52138036", "0.520943", "0.5196618", "0.5185886", "0.5182538", "0.5147707", "0.508339"...
0.0
-1
Delete a scenario or initialise main scenario.
def _delete_series(self, name): if name == self.MAIN: self[self.MAIN] = self._tracker(self.MAIN).delete_all() else: self._tracker_dict.pop(name) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete(self):\n scenario = factories.Scenario(config='', status=Scenario.Status.INACTIVE)\n scenario.delete()\n self.assertEqual(scenario.status, Scenario.Status.INACTIVE)", "def delete_entry(self, scenario_id):\n sql = self.delete(\"id\")\n self.cur.execute(sql, (scen...
[ "0.70573026", "0.627147", "0.5982057", "0.5979097", "0.59688073", "0.590334", "0.5860901", "0.5817632", "0.5726152", "0.56649214", "0.56325996", "0.56311464", "0.5622134", "0.5598066", "0.55954844", "0.54979986", "0.54341084", "0.5432262", "0.5421928", "0.54125845", "0.541217...
0.0
-1
The phases will be disabled and removed from summary.
def disable(self, phases, name="Main"): self[name] = self._tracker(name).disable(phases) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phase(self):\n pass", "def phases(self):\n return self._phases", "def unstudied_skills(self):\n undone = [task for task in self.skills if task not in self.done_skills]\n print(\"Hello \"+ str(self.user_name)+\" :)\\nHere are the skills that are still incomplete: \")\n for...
[ "0.56792605", "0.56478065", "0.5620661", "0.55673957", "0.5443464", "0.54326624", "0.53489864", "0.5344841", "0.5331238", "0.5326407", "0.5294865", "0.52542996", "0.52436554", "0.52221566", "0.52197176", "0.51593006", "0.51584166", "0.50953543", "0.5072874", "0.5055029", "0.5...
0.65539813
0
The phases will be enabled and appear in summary.
def enable(self, phases, name="Main"): self[name] = self._tracker(name).enable(phases) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phases(self):\n return self._phases", "def add_phases(self, phases):\n for phase in phases:\n self.add_phase(phase)", "def GetPhase(self):\n ...", "def phase(self):\n pass", "def __str__(self):\n phases = '|'.join([phase.name for phase in PropertyPhase if s...
[ "0.6695582", "0.6427158", "0.6281006", "0.6096473", "0.6070386", "0.59524006", "0.587657", "0.57588166", "0.5757374", "0.5603253", "0.55110353", "0.5493423", "0.5374328", "0.53662604", "0.5365337", "0.52662754", "0.52411807", "0.5227085", "0.5207862", "0.5207777", "0.5199702"...
0.6186084
3
Combine the sequential phases as one phase. New phase name will be automatically determined.
def combine(self, phases, name="Main", population=None, **kwargs): self[name] = self._tracker(name).combine( phases=phases, population=population, **kwargs) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_phases(self, phases):\n for phase in phases:\n self.add_phase(phase)", "def as_phases(cls, *phase_names):\r\n return map(cls.as_phase, phase_names)", "def combine_phase_data():\n print(\"Combining phase data...\")\n\n # create an empty data frame\n out_df = pd.DataFrame([]...
[ "0.661942", "0.6211742", "0.60045195", "0.5823689", "0.5768203", "0.5760177", "0.5691253", "0.5614826", "0.5538506", "0.55089426", "0.54660183", "0.5461017", "0.545222", "0.53699225", "0.53215224", "0.52598274", "0.52169806", "0.5215779", "0.52015465", "0.5193688", "0.5140901...
0.6169472
2
Create a new phase with the change point. New phase name will be automatically determined.
def separate(self, date, name="Main", population=None, **kwargs): self[name] = self._tracker(name).separate( date=date, population=population, **kwargs) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_phase(cls, phase_name):\r\n return Phase(cls._namespace(phase_name))", "def startPhase(self, phaseName):\n \n pass", "def create_kill_chain_phase(\n kill_chain_name: str, phase_name: str\n) -> stix2.KillChainPhase:\n return stix2.KillChainPhase(kill_chain_name=kill_chain_name, phase_n...
[ "0.6967446", "0.66886157", "0.62629896", "0.61891747", "0.616434", "0.59673655", "0.5775541", "0.5710485", "0.56504726", "0.5559992", "0.55560404", "0.5517846", "0.5464363", "0.5390099", "0.53285253", "0.52982134", "0.5296981", "0.5260513", "0.5247765", "0.50851226", "0.50570...
0.0
-1
Summarize the series of phases and return a dataframe.
def _summary(self, name=None): if name is None: if len(self._tracker_dict.keys()) > 1: dataframes = [] for (_name, tracker) in self._tracker_dict.items(): summary_df = tracker.series.summary() summary_df = summary_df.rename_axis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_phases(self):\n start_dates, end_dates = self._phase_range(self._change_dates)\n pop_list = [self.pop_dict[date] for date in start_dates]\n phase_series = PhaseSeries(\n self.dates[0], self.dates[-1], self.population, use_0th=self._use_0th\n )\n phase_itr =...
[ "0.5927809", "0.5845708", "0.58410937", "0.5779259", "0.570446", "0.56737816", "0.55832416", "0.5576937", "0.5566729", "0.55379295", "0.5534224", "0.55257225", "0.5509939", "0.5498276", "0.54978764", "0.54487824", "0.54207087", "0.5397515", "0.5391885", "0.5317863", "0.526836...
0.5698778
5
Summarize the series of phases and return a dataframe.
def summary(self, columns=None, name=None): df = self._summary(name=name).dropna(how="all", axis=1).fillna(self.UNKNOWN) all_cols = df.columns.tolist() # Columns were specified if columns is not None: self._ensure_list(columns, all_cols, name="columns") return df....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_phases(self):\n start_dates, end_dates = self._phase_range(self._change_dates)\n pop_list = [self.pop_dict[date] for date in start_dates]\n phase_series = PhaseSeries(\n self.dates[0], self.dates[-1], self.population, use_0th=self._use_0th\n )\n phase_itr =...
[ "0.5928529", "0.58456147", "0.5843049", "0.5780569", "0.57045394", "0.56968504", "0.5675235", "0.5583464", "0.55764633", "0.5568089", "0.5538528", "0.55341923", "0.55262", "0.55122906", "0.5499586", "0.54993314", "0.5446855", "0.5420259", "0.5398861", "0.53932065", "0.5318492...
0.0
-1
Perform SR trend analysis and set phases.
def trend(self, min_size=None, force=True, name="Main", show_figure=True, filename=None, **kwargs): # Arguments if "n_points" in kwargs.keys(): raise ValueError( "@n_points argument is un-necessary" " because the number of change points will be automatically d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CLI_trend( RFinfo,var, den, fireyear=False, plot=True, testmethod=\"OLS\"):\n\n\t# warn.warn(\n\t# \t'''\n\t# \tThis is currently only in alpha testing form\n\t# \ti'm going to using a simple trend test without\n\t# \tany consideration of significance. i used cdo\n\t# \tregres on copernicious NDVI data to star...
[ "0.57416147", "0.5710031", "0.56373745", "0.5537419", "0.54530376", "0.54429436", "0.54315424", "0.5397674", "0.5393723", "0.5364632", "0.53535897", "0.5323438", "0.5271401", "0.52627134", "0.5248195", "0.522271", "0.5220586", "0.5207697", "0.52046007", "0.51960284", "0.51750...
0.55154175
4
Perform parameter estimation for each phases.
def estimate(self, model, phases=None, name="Main", n_jobs=-1, **kwargs): if self.TAU in kwargs: raise ValueError( "@tau must be specified when scenario = Scenario(), and cannot be specified here.") self.tau, self[name] = self._tracker(name).estimate( model=model,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self):\n\n with torch.no_grad():\n for group in self.param_groups:\n lr = group[\"lr\"]\n for p in group[\"params\"]:\n\n if p.grad is None:\n continue\n\n lambda_square = self.mf.conf_factor(p, ke...
[ "0.6483096", "0.60225064", "0.59710395", "0.59599286", "0.59426624", "0.59370613", "0.59046566", "0.5887623", "0.5844492", "0.5805915", "0.5800615", "0.5796302", "0.5769528", "0.57484573", "0.5733885", "0.5667784", "0.56673306", "0.56603837", "0.5658184", "0.5651971", "0.5643...
0.5701632
15
Return the estimator of the phase.
def phase_estimator(self, phase, name="Main"): estimator = self._tracker_dict[name].series.unit(phase).estimator if estimator is None: raise UnExecutedError(f'Scenario.estimate(model, phases=["{phase}"], name={name})') return estimator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPhase(phase):", "def get_estimation(self):\n self.calculate_variables()\n if self.validate_preconditions():\n return self.estimate()\n else:\n return None", "def phase(self):\n return self.__phase", "def m_phase(self):\n return self._m_phase", ...
[ "0.6492449", "0.6396096", "0.6245162", "0.6211135", "0.6155881", "0.6117626", "0.59259164", "0.5919323", "0.578341", "0.5782382", "0.5680286", "0.5680286", "0.5680286", "0.5667647", "0.5667647", "0.5618406", "0.5616461", "0.55942184", "0.5574", "0.55632395", "0.55238044", "...
0.7582759
0
Show the history of optimization.
def estimate_history(self, phase, name="Main", **kwargs): estimator = self.phase_estimator(phase=phase, name=name) estimator.history(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_history_log(self):\n self.visual.print_enum(self.visual.history_log)", "def history():", "def print_history(self):\n self.game_started = False\n for state in self.history:\n self.__draw_board(state)", "def history(self):\n alembic.command.history(self.alembic_c...
[ "0.7425332", "0.71183753", "0.6615228", "0.6545977", "0.64348227", "0.6417473", "0.6363705", "0.6331068", "0.6331068", "0.6331068", "0.6302988", "0.6284421", "0.6284421", "0.6253503", "0.61762786", "0.616101", "0.60512143", "0.6035782", "0.60021174", "0.59667826", "0.5963107"...
0.0
-1
Show the accuracy as a figure.
def estimate_accuracy(self, phase, name="Main", **kwargs): estimator = self.phase_estimator(phase=phase, name=name) estimator.accuracy(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_accuracy(self):\r\n return round(accuracy_score(self.actual, self.predicted),2)", "def plot_accuracy(self):\n plot_title, img_title = self.prep_titles(\"\")\n test_legend = ['training data', 'test data']\n\n # Data for plotting x- and y-axis\n x = np.arange(1, CFG.EPOC...
[ "0.77534753", "0.7277765", "0.71191853", "0.70241654", "0.70184475", "0.6948544", "0.6932617", "0.6889967", "0.68846935", "0.67477405", "0.67329997", "0.6720133", "0.66735786", "0.6602087", "0.65589964", "0.65424436", "0.6538231", "0.6513839", "0.6496956", "0.6495127", "0.647...
0.0
-1
Simulate ODE models with set/estimated parameter values and show it as a figure.
def simulate(self, variables=None, phases=None, name="Main", y0_dict=None, **kwargs): tracker = copy.deepcopy(self._tracker(name)) # Select phases if phases is not None: tracker.disable(phases=None) tracker.enable(phases=phases) # Simulation try: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_edo_random():\n # if (__name__ == '__main__'):\n\n DBplot = True\n x = np.random.randn(102)\n x_e = gen_edo(x)\n\n # -------------------------------------------------------------------\n # plot\n # -------------------------------------------------------------------\n if DBplot:\n ...
[ "0.6467573", "0.6445182", "0.63493", "0.62701017", "0.61718446", "0.6158063", "0.6137683", "0.61052775", "0.6049931", "0.6034813", "0.6014029", "0.59745497", "0.5957386", "0.59391916", "0.5928305", "0.5925902", "0.5917189", "0.5912627", "0.59121877", "0.5903403", "0.5875804",...
0.0
-1
Get the parameter value of the phase.
def get(self, param, phase="last", name="Main"): df = self.summary(name=name) if param not in df.columns: raise KeyError(f"@param must be in {', '.join(df.columns)}.") if phase == "last": phase = df.index[-1] return df.loc[phase, param]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValue(self):\n return _libsbml.Parameter_getValue(self)", "def getPhase(phase):", "def phase(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"phase\")", "def phase(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"phase\")", "def phase(self) -> O...
[ "0.71726173", "0.6958654", "0.69486773", "0.69486773", "0.69486773", "0.68258613", "0.67630255", "0.6711935", "0.667737", "0.66741765", "0.66447204", "0.66141695", "0.6555716", "0.65409654", "0.6483767", "0.6476454", "0.6470208", "0.6468714", "0.6460967", "0.64353555", "0.641...
0.60780966
38
Return the subset of summary dataframe to select the target of parameter history.
def _param_history(self, targets, name): series = self._tracker_dict[name].series model_set = {unit.model for unit in series} model_set = model_set - set([None]) parameters = self.flatten([m.PARAMETERS for m in model_set]) day_params = self.flatten([m.DAY_PARAMETERS for m in mode...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_target(self, df, target_name: str):\n \n return self.df[target_name]", "def get_targets(self, df):\n return df.iloc[:, self.target_col]", "def get_feat_and_target(df, target):\n x = df.drop(target, axis = 1)\n y = df[target]\n return x, y", "def _history(self, target, phases=...
[ "0.6120377", "0.5767605", "0.5637257", "0.5635355", "0.55291855", "0.5380826", "0.534724", "0.5300844", "0.52480835", "0.52071494", "0.51738966", "0.51618147", "0.51550215", "0.51391673", "0.49831647", "0.49728945", "0.49236575", "0.49220812", "0.4913259", "0.49054223", "0.49...
0.66820365
0
Return subset of summary and show a figure to show the history.
def param_history(self, targets=None, name="Main", divide_by_first=True, show_figure=True, filename=None, show_box_plot=True, **kwargs): self._tracker(name) # Select target to show df = self._param_history(targets, name) # Divide by the first phase parameters ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def results_summary(log, geolog, show=True):\n fig, axes = plt.subplots(nrows=3, ncols=1, sharex=True)\n okw = {'c':'purple', 'ls':'--', 'lw':1.5}\n mkw = {'c':'C0', 'ls':'-', 'lw':1.5}\n geolog.add_ae_quicklook(plot_obs=True, target=axes[0], val='AU', obs_kwargs=okw,\n add_l...
[ "0.63200307", "0.6019806", "0.59494907", "0.5911857", "0.5827589", "0.580583", "0.58054876", "0.5796425", "0.575747", "0.575252", "0.57473797", "0.57211274", "0.571764", "0.5683871", "0.5652965", "0.5650766", "0.5624043", "0.5621022", "0.5616493", "0.5606518", "0.5578285", ...
0.0
-1
Adjust the last end dates of the registered scenarios, if necessary.
def adjust_end(self): # The current last end dates current_dict = { name: self._ensure_date(tracker.last_end_date()) for (name, tracker) in self._tracker_dict.items()} # Adjusted end date adjusted_str = max(current_dict.values()).strftime(self.DATE_FORMAT) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_list_to_end_date(self):\n if len(self.change_events):\n event_index = len(self.change_events) - 1\n while ((event_index > -1) and (self.change_events[event_index].date_ordinal >\n self.end_date_ordinal)):\n event = self.change_events[event_i...
[ "0.67244375", "0.63298994", "0.6279191", "0.62078863", "0.6186914", "0.61678594", "0.5923968", "0.5894802", "0.58839434", "0.58004695", "0.58004695", "0.58004695", "0.58004695", "0.58004695", "0.58004695", "0.58004695", "0.58004695", "0.5626302", "0.55569535", "0.5550756", "0...
0.7241436
0
Get the history of parameters for the scenario.
def _track_param(self, name): df = self.summary(name=name).replace(self.UNKNOWN, None) # Date range to dates df[self.START] = pd.to_datetime(df[self.START]) df[self.END] = pd.to_datetime(df[self.END]) df[self.DATE] = df[[self.START, self.END]].apply( lambda x: pd.date...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_history(self):\n return self.history", "def get_history(self):\n return self.__history[:]", "def History(self):\n return self.historydict.get('history', [])", "def get_value_history(self):\n return self.value_history", "def get_params_snapshot(self):\n ...", "def hi...
[ "0.6669746", "0.6486813", "0.6419645", "0.63908446", "0.63483167", "0.63360363", "0.6301121", "0.6276203", "0.62529445", "0.6202838", "0.6188639", "0.61855346", "0.6182134", "0.6155728", "0.6150554", "0.6150554", "0.61322916", "0.613136", "0.61156565", "0.60952926", "0.608258...
0.0
-1
Show values of parameters and variables in one dataframe for the scenario.
def _track(self, phases=None, name="Main", y0_dict=None): sim_df = self.simulate(phases=phases, name=name, y0_dict=y0_dict, show_figure=False) param_df = self._track_param(name=name) return pd.merge( sim_df, param_df, how="inner", left_on=self.DATE, right_index=True, sort=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values(self, parameter):\n self.values = self.dataframe[parameter]\n print(self.values)", "def print_info(self):\n\n n_metabolites = len(self.metabolites)\n n_reactions = len(self.reactions)\n n_constraints = len(self.constraints)\n n_variables = len(self.variables)\...
[ "0.65283614", "0.6190751", "0.60253143", "0.59300756", "0.5904161", "0.5842688", "0.5835276", "0.58245564", "0.5805679", "0.5796759", "0.5791026", "0.570495", "0.57009065", "0.5689903", "0.5675194", "0.56727546", "0.5651568", "0.5614041", "0.5581958", "0.55624795", "0.5557544...
0.0
-1
Show values of parameters and variables in one dataframe.
def track(self, phases=None, with_actual=True, y0_dict=None): dataframes = [] append = dataframes.append for name in self._tracker_dict.keys(): df = self._track(phases=phases, name=name, y0_dict=y0_dict) df.insert(0, self.SERIES, name) append(df) if wi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_info(self):\n\n n_metabolites = len(self.metabolites)\n n_reactions = len(self.reactions)\n n_constraints = len(self.constraints)\n n_variables = len(self.variables)\n\n info = pd.DataFrame(columns=['value'])\n info.loc['name'] = self.name\n info.loc['desc...
[ "0.6696075", "0.6677119", "0.6282688", "0.61132765", "0.6078284", "0.59988284", "0.5986452", "0.59587187", "0.5925746", "0.59255815", "0.58896726", "0.5857535", "0.584836", "0.5839311", "0.58278835", "0.5785681", "0.57587534", "0.5720079", "0.5715537", "0.56835276", "0.568344...
0.0
-1
Show the history of variables and parameter values to compare scenarios.
def _history(self, target, phases=None, with_actual=True, y0_dict=None): # Include actual data or not with_actual = with_actual and target in self.VALUE_COLUMNS # Get tracking data df = self.track(phases=phases, with_actual=with_actual, y0_dict=y0_dict) if target not in df.column...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_history_log(self):\n self.visual.print_enum(self.visual.history_log)", "def history():", "def show_variables(self):\r\n\r\n variablelist = [(x_temp,self.variables[x_temp]) for x_temp in sorted(self.variables.keys())]\r\n display.noteprint(('/C/ '+labels.VARIABLES.upper(), EOL.join...
[ "0.66284317", "0.60000753", "0.58660567", "0.5847181", "0.5816811", "0.5788459", "0.57120436", "0.5690894", "0.56844974", "0.56740534", "0.5656841", "0.5607398", "0.5599281", "0.5539353", "0.5526882", "0.5502886", "0.549579", "0.5481899", "0.5479519", "0.5479519", "0.5479519"...
0.5110203
78
Show the history of variables and parameter values to compare scenarios.
def history(self, target, phases=None, with_actual=True, y0_dict=None, **kwargs): df = self._history(target=target, phases=phases, with_actual=with_actual, y0_dict=y0_dict) df.dropna(subset=[col for col in df.columns if col != self.ACTUAL], inplace=True) if target == self.RT: ylabel ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_history_log(self):\n self.visual.print_enum(self.visual.history_log)", "def history():", "def show_variables(self):\r\n\r\n variablelist = [(x_temp,self.variables[x_temp]) for x_temp in sorted(self.variables.keys())]\r\n display.noteprint(('/C/ '+labels.VARIABLES.upper(), EOL.join...
[ "0.66309536", "0.60015976", "0.58661586", "0.5848", "0.58179206", "0.5790615", "0.5713213", "0.5692382", "0.56855243", "0.56744015", "0.5657676", "0.56071436", "0.5599695", "0.554003", "0.55277646", "0.55041164", "0.5496439", "0.5482356", "0.54818606", "0.54818606", "0.548186...
0.0
-1
Show change rates of parameter values in one figure. We can find the parameters which increased/decreased significantly.
def history_rate(self, params=None, name="Main", **kwargs): df = self._track_param(name=name) model = self._tracker(name).last_model cols = list(set(df.columns) & set(model.PARAMETERS)) if params is not None: if not isinstance(params, (list, set)): raise TypeE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_parameters(self, event, gamma='2.4',\n gain=\"scale_default_value\"):\n print(\"gamma={}, gain={}\".format(gamma, gain))\n sys.stdout.flush()\n self.update_draw(gamma, gain)", "def show_parameters(self):\n with np.printoptions(precision=3, suppress=...
[ "0.63222736", "0.60968167", "0.602045", "0.600945", "0.5968336", "0.5863816", "0.5856223", "0.58190936", "0.57916284", "0.5782523", "0.5754305", "0.5710678", "0.5689282", "0.5687477", "0.56859684", "0.5658603", "0.56582314", "0.5644833", "0.5638262", "0.56351125", "0.56246054...
0.64278245
0
Perform retrospective analysis. Compare the actual series of phases (control) and series of phases with specified parameters (target).
def retrospective(self, beginning_date, model, control="Main", target="Target", **kwargs): param_dict = {k: v for (k, v) in kwargs.items() if k in model.PARAMETERS} est_kwargs = dict(kwargs.items() - param_dict.items()) # Control self.clear(name=control, include_past=True) self.t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyse_results(self, \n target_dir, \n param_file = \"TRAINED_PARAMS_END.model\",\n w_norm_file = \"W_NORMS.dat\",\n num_to_test = 100,\n get_means_from = {\n 'N...
[ "0.60408705", "0.58758664", "0.5644826", "0.5543238", "0.54795575", "0.544844", "0.5408462", "0.5391602", "0.53793794", "0.5373309", "0.53686464", "0.53674304", "0.5345663", "0.5332743", "0.53223336", "0.5291442", "0.5291442", "0.52801085", "0.52746636", "0.5273039", "0.52550...
0.6092217
0
Evaluate accuracy of phase setting and parameter estimation of all enabled phases all some past days.
def score(self, variables=None, phases=None, past_days=None, name="Main", y0_dict=None, **kwargs): tracker = self._tracker(name) if past_days is not None: if phases is not None: raise ValueError("@phases and @past_days cannot be specified at the same time.") past_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def estimate_accuracy(self, phase, name=\"Main\", **kwargs):\n estimator = self.phase_estimator(phase=phase, name=name)\n estimator.accuracy(**kwargs)", "def _run_eval_phase(self, statistics, agent_type='active'):\n # Perform the evaluation phase -- no learning.\n self._agent.eval_mode = True...
[ "0.58308494", "0.5690322", "0.55964804", "0.55690634", "0.5507954", "0.5496139", "0.54829794", "0.5474401", "0.5468245", "0.54412717", "0.54111433", "0.5407387", "0.5388276", "0.53425944", "0.53318614", "0.5330115", "0.531091", "0.53101224", "0.530839", "0.530558", "0.5292451...
0.0
-1
Estimate delay period [days], assuming the indicator impact on the target value with delay. The average of representative value (percentile) and will be returned.
def estimate_delay(self, oxcgrt_data=None, indicator="Stringency_index", target="Confirmed", percentile=25, limits=(7, 30), **kwargs): min_size, max_days = limits # Register OxCGRT data if oxcgrt_data is not None: warnings.warn( "Please use Scen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def estimate(values, target):\n\n # next time\n # diff(values)\n\n\n return 1.", "def get_delay(self):\n if self.msg_tn == self.last_msg_tn:\n return\n if not self.delays:\n return\n n = len(self.delays)\n\n mean = sum(self.delays) / n\n std_dev =...
[ "0.61240596", "0.58249533", "0.5736352", "0.5720196", "0.551994", "0.5515488", "0.5515488", "0.5449673", "0.5441243", "0.5343859", "0.52559906", "0.52168494", "0.5213883", "0.5213228", "0.5210776", "0.5206571", "0.5188828", "0.51886564", "0.5151351", "0.514995", "0.51415145",...
0.6570062
0
Fit regressors to predict the parameter values in the future phases, assuming that indicators will impact on ODE parameter values/the number of cases with delay. Please refer to covsirphy.RegressionHander class.
def fit(self, oxcgrt_data=None, name="Main", delay=None, removed_cols=None, metric=None, metrics="R2", **kwargs): metric = metric or metrics # Clear the future phases self.clear(name=name, include_past=False) # Register OxCGRT data if oxcgrt_data is not None: warnings...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit(self, X, treatment, y, p=None):\r\n # Train outcome models\r\n self.model_mu_c.fit(X[treatment == 0], y[treatment == 0])\r\n self.model_mu_t.fit(X[treatment == 1], y[treatment == 1])\r\n\r\n # Calculate variances and treatment effects\r\n if self.is_regressor:\r\n ...
[ "0.612984", "0.61278903", "0.60842425", "0.60745496", "0.6031944", "0.5868699", "0.58676064", "0.5849834", "0.58083665", "0.576466", "0.5755088", "0.57517785", "0.57233256", "0.5709516", "0.56974554", "0.567379", "0.5673005", "0.5670449", "0.56611407", "0.56489986", "0.564248...
0.0
-1
Predict parameter values of the future phases using Elastic Net regression with OxCGRT scores, assuming that OxCGRT scores will impact on ODE parameter values with delay. New future phases will be added (overwritten).
def predict(self, days=None, name="Main"): # Arguments if name not in self._reghandler_dict: raise UnExecutedError(f"Scenario.fit(name={name})") # Prediction with regression model handler = self._reghandler_dict[name] df = handler.predict() # -> end_date/param...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_conditional(self, params):\n params = np.array(params, ndmin=1)\n\n # Prediction is based on:\n # y_t = x_t beta^{(S_t)} +\n # \\phi_1^{(S_t)} (y_{t-1} - x_{t-1} beta^{(S_t-1)}) + ...\n # \\phi_p^{(S_t)} (y_{t-p} - x_{t-p} beta^{(S_t-p)}) + eps_t\n ...
[ "0.617037", "0.61178964", "0.6064572", "0.59373784", "0.5898719", "0.5859526", "0.58379626", "0.5798949", "0.5782605", "0.5697326", "0.5657076", "0.5566286", "0.5468811", "0.5450581", "0.5440786", "0.54234713", "0.54088026", "0.5388653", "0.53765047", "0.5374445", "0.53656775...
0.0
-1
Predict parameter values of the future phases using Elastic Net regression with OxCGRT scores, assuming that OxCGRT scores will impact on ODE parameter values with delay. New future phases will be added (overwritten).
def fit_predict(self, oxcgrt_data=None, name="Main", **kwargs): self.fit(oxcgrt_data=oxcgrt_data, name=name, **find_args(Scenario.fit, **kwargs)) self.predict(name=name, **find_args(Scenario.predict, **kwargs)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_conditional(self, params):\n params = np.array(params, ndmin=1)\n\n # Prediction is based on:\n # y_t = x_t beta^{(S_t)} +\n # \\phi_1^{(S_t)} (y_{t-1} - x_{t-1} beta^{(S_t-1)}) + ...\n # \\phi_p^{(S_t)} (y_{t-p} - x_{t-p} beta^{(S_t-p)}) + eps_t\n ...
[ "0.61692065", "0.6117616", "0.60650826", "0.59379566", "0.5898542", "0.5858027", "0.58376944", "0.57994056", "0.57826334", "0.5697629", "0.5657438", "0.5566829", "0.54680365", "0.54501426", "0.544141", "0.5422653", "0.54094625", "0.53875375", "0.5375797", "0.5373882", "0.5365...
0.0
-1
Read in comments data as dataframe from mysql database
def get_df_from_db(localhost, username, password, dbname, tbname, fields=None, chunksize=None, time_field=None, start_time=None, end_time=None): # con = pymysql.connect(host=localhost, user=username, password=password, database=dbname, charset='utf8', use_unicode=True) connect_string = "mysql+pymysql://{}:{}@{}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_db_data(self, sql_string):\n connection_string = f\"\"\"\n host='{self.host}' \n dbname='{self.db_name}' \n user='{self.user}' \n password='{self.password}' \n port='{self.port}'\n \"\"\"\n\n with psycopg2.connect(connection_string) as connection:\n ...
[ "0.6610287", "0.65699345", "0.6364169", "0.6285126", "0.62495816", "0.6120763", "0.6112718", "0.6107892", "0.605614", "0.59847057", "0.59784424", "0.59216505", "0.5917459", "0.5907499", "0.5883649", "0.58613175", "0.5850069", "0.5832138", "0.5799104", "0.57808924", "0.5768387...
0.5464838
61
Parse html tages in sentences
def parse_html_tag(sentences, html_tag_file): tag_list = file2tuple_list(html_tag_file, ",") for key, value in tag_list: for index in range(len(sentences)): try: sentences[index] = re.sub(key, value, sentences[index]) except Exception, e: logging.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __yahoo_parse_text(self, content):\n text = ''\n # Process all paragraphs.\n paragraphs = content.find_all('p')\n for par in paragraphs:\n text += '<p>' + par.getText(separator=' ') + '</p>'\n # Remove all extra whitespace (single space remains).\n text = ' ...
[ "0.65768903", "0.6414939", "0.6314085", "0.6304649", "0.6183976", "0.61760587", "0.61702543", "0.6127106", "0.6099596", "0.60908455", "0.60301", "0.6008985", "0.6008985", "0.59992546", "0.59763205", "0.5959324", "0.59592533", "0.595774", "0.59353596", "0.59334815", "0.5910679...
0.644006
1
Format the chinese sentences remove unwanted punctuations. Split sentences by each delimiter
def sentence_splitter(sentences): # only accept list/ndarray or string/unicode type try: assert isinstance(sentences, list) or isinstance(sentences, np.ndarray) or isinstance(sentences, str) or isinstance(sentences, unicode) except: logging.error("Split sentences failed! Only list/ndarray or...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess_sentence(raw):\r\n\t\r\n\t# raw = re.sub(r\"[\\x80-\\xff]\",\" \",raw)\r\n\t\r\n\traw = regex_punct.sub(' ',raw)\r\n\traw = raw.strip()\r\n\traw = raw.lower()\r\n\t\r\n\twords = nltk.word_tokenize(raw)\r\n\twords = [replace_punctuation(w) for w in words if not w in stopwords and len(w) > 1]\r\n\t\r\...
[ "0.68802744", "0.673855", "0.66493034", "0.65651876", "0.65555406", "0.6473244", "0.6455792", "0.64497674", "0.64104927", "0.63669884", "0.6339846", "0.63106835", "0.63015205", "0.6296337", "0.62898695", "0.62860185", "0.62840253", "0.6282841", "0.62685126", "0.62685126", "0....
0.0
-1
Replace description after meta updating
def add_meta(self, post, *args, **kwargs): super(Command, self).add_meta(post, *args, **kwargs) post.gen_description = False post.description = description_from_content(post) post.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def description(self, new_description):\r\n self.set({\"description\": new_description})", "def get_meta_description(self):\n md = self.meta_description.replace(\"<title>\", self.title)\n return md.replace(\"<short-text>\", self.short_text)", "def set_description(self, desc: str) -> None:\...
[ "0.7612998", "0.7401941", "0.7334977", "0.722761", "0.7192312", "0.70661885", "0.7027152", "0.6967204", "0.688855", "0.68845445", "0.68065006", "0.6792907", "0.67552644", "0.67239", "0.67174524", "0.67133564", "0.66825515", "0.6681796", "0.66503423", "0.6635033", "0.6635033",...
0.6486738
72
Write data to buffer with buffer protocol
def test_write_bufferprotocol(ctx): data = array('f', [1, 2, 3, 4]) buff = ctx.buffer(data=data) assert buff.read() == data.tobytes()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, data):\n self.buffer.write(data)\n self.offset += len(data)", "def write(self, data):\n\t\tself.outputbuffer.write(data)", "def pack(self,buffer):\n buffer.append(self.data)", "def write(self, data):\n self.buffer.append(data)\n while self.push():\n pass"...
[ "0.77599627", "0.7405367", "0.7294376", "0.71941775", "0.70991886", "0.70991886", "0.70752317", "0.7066335", "0.701389", "0.6976252", "0.6973175", "0.6920095", "0.68100977", "0.67799836", "0.6749012", "0.670543", "0.66522443", "0.664747", "0.66468465", "0.6641118", "0.6630188...
0.77639097
0
Index/home page of the website
def index(): if request.method =='POST': session["place"] = request.form["place"] # Stores "place" input in session return redirect(url_for("nearest")) else: return render_template("index.html")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")", "def home():\r\n return render_template(\r\n 'index.html',\r\n ...
[ "0.87146896", "0.8548914", "0.85075265", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.8418279", "0.83925295", "0.83726525", "0.83699334", "0.83652914", "0.8361378", "0.8359413", "0.8331822", "0.8314265...
0.0
-1
If place has a nearby MBTA, returns the page with that info, else (or if any other errors), returns an error page
def nearest(): try: text = find_stop_near(session["place"]) return render_template("place.html", text = text) except: return render_template('error.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_near_location():\n return render_template(\"location.html\", latitude=None, longitude=None,\n list_stops=None)", "def scrapping():\r\n\r\n data_cust = {}\r\n #token, latitude, longitude, name, place_id, types_places, vicinity = [],[],[],[],[],[], []\r\n\r\n apik = '...
[ "0.5860572", "0.5601886", "0.556867", "0.53483754", "0.534454", "0.5319231", "0.5303751", "0.5295789", "0.52449685", "0.5211668", "0.51778597", "0.51622933", "0.51574767", "0.51421475", "0.51280147", "0.5089487", "0.50833637", "0.5079039", "0.5062072", "0.50607216", "0.502367...
0.64868116
0
Open the editing student window.
def on_edit_students_select(self): edit_window = Students() edit_window.exec_()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mouseDoubleClickEvent(self, e):\n self.win = items.edit.Edit(self)\n self.win.setModal(True)\n self.win.show()", "def edit():", "def edit_user(self):\n from editWindow import EditPlayer\n self.edit = EditPlayer(self.lang, self.result_table.currentItem().text())\n s...
[ "0.6857695", "0.675959", "0.6755998", "0.6650021", "0.6358983", "0.6331608", "0.62601465", "0.62351334", "0.619309", "0.6178386", "0.6118476", "0.61091745", "0.60836834", "0.60471237", "0.6022824", "0.6017019", "0.5987004", "0.5984732", "0.59686553", "0.5962103", "0.5930994",...
0.8309543
0
Update views when the date is changed.
def on_date_change(self): self.date = self.ui.calendarWidget.selectedDate() self.update_views()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _dates_observer(self, state):\n # Update all dates\n self._update_dates_from_history()", "def update_views(self):\n # Get correct date format\n self.date_string = self.date.toString(self.date_format)\n \n # Clear Models\n self.availModel.clear()\n self....
[ "0.6494887", "0.64303577", "0.6425736", "0.63661104", "0.62049454", "0.6182257", "0.6125983", "0.6066578", "0.59537566", "0.5901415", "0.58907646", "0.58669895", "0.5823096", "0.57737094", "0.57707644", "0.57694495", "0.5768196", "0.57058334", "0.56830543", "0.56830543", "0.5...
0.68725854
0
Refresh the students available and attending for the given date.
def update_views(self): # Get correct date format self.date_string = self.date.toString(self.date_format) # Clear Models self.availModel.clear() self.attendModel.clear() for student in self.db.get_attendance_for_date(self.date_string): if stu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, date):\r\n self.date = date", "def _load_student_record(self, student_key, students_attendance_data):\n student = SchoolDB.models.Student.get(db.Key(student_key))\n if (student):\n student.attendance.save_multiple_dates(\n self.dates, students_atten...
[ "0.5911469", "0.55838823", "0.5495462", "0.5478598", "0.54697925", "0.5468061", "0.529754", "0.5211721", "0.5158502", "0.51371205", "0.51294976", "0.51294976", "0.50868255", "0.50607437", "0.50580114", "0.50310814", "0.50108874", "0.4964432", "0.4947712", "0.4947712", "0.4945...
0.65859437
0
Move student from available to attended list.
def on_add_clicked(self): selected_indexes = self.ui.availListView.selectedIndexes() for index in selected_indexes: row = self.availModel.itemFromIndex(index).row() #rowList = self.availModel.takeRow(row) student = self.availModel.item(row, 0).text() sid =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap_students(chambers, allcourses, student_list, schedule, swapcourse = None, sem1 = None, sem2 = None, prac1 = None, prac2 = None, student1 = None, student2 = None):\n\n\tif swapcourse == None:\n\n\t\t# pick course to swap students in\n\t\tswapcourse = random.randint(0, len(allcourses) - 1)\n\n\t\t# pick new...
[ "0.5389811", "0.53782946", "0.5337685", "0.52989775", "0.52790767", "0.5223609", "0.52139056", "0.5191543", "0.518432", "0.5161362", "0.5161182", "0.51304746", "0.50658983", "0.50332844", "0.50159574", "0.5003529", "0.4999005", "0.49856463", "0.49727905", "0.49342826", "0.493...
0.4954204
19
Move student from attended to available list.
def on_remove_clicked(self): selected_indexes = self.ui.attendListView.selectedIndexes() for index in selected_indexes: row = self.attendModel.itemFromIndex(index).row() student = self.attendModel.item(row, 0).text() sid = self.attendModel.item(row, 1).text() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_an_entry(self):\n target_list = self.find_student()\n\n if not len(target_list):\n print('There is no contents to show')\n else:\n print('You selected the list below.')\n self.print_dataframe(target_list)\n opt = self.input_options(['y', '...
[ "0.5481265", "0.53063625", "0.52547395", "0.5241378", "0.5201852", "0.51910436", "0.50918496", "0.5090114", "0.50880194", "0.5077619", "0.50550723", "0.5022331", "0.5001788", "0.49973884", "0.4996648", "0.49769428", "0.49731165", "0.49215776", "0.49120808", "0.48781928", "0.4...
0.54175085
1
Report a time_t as an ISO8601 time format. Defaults to now.
def timet_iso(t=time.time()): return datetime.datetime.now().isoformat()[0:19]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iso_date(self, t=None):\n if t is None:\n t = time.time()\n time_str = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(t))\n\n return time_str", "def formatted_time() -> datetime.datetime:\r\n return datetime.datetime.now()", "def isoformat(self, timespec=\"auto\"):\n...
[ "0.7398466", "0.706633", "0.69513315", "0.68297285", "0.6829152", "0.67798644", "0.67408025", "0.6729839", "0.66987705", "0.6689164", "0.6689164", "0.66699064", "0.6641522", "0.65828717", "0.65425014", "0.6505604", "0.64849293", "0.64819497", "0.6459066", "0.644515", "0.64373...
0.7495122
0
Execute a SQL command and return the the iterator
def execute(self, cmd, *args, debug=False, **kwargs): if self.debug or debug: print(f"execute: {cmd}", file=sys.stderr) t0 = time.time() try: res = self.conn.cursor().execute(cmd, *args, **kwargs) except (sqlite3.Error, pymysql.MySQLError) as e: pr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_sql(self, result_type=MULTI):\r\n try:\r\n sql, params = self.as_sql()\r\n #import pdb; pdb.set_trace()\r\n if not sql:\r\n raise EmptyResultSet\r\n except EmptyResultSet:\r\n if result_type == MULTI:\r\n return ite...
[ "0.7440192", "0.74239373", "0.73914313", "0.722137", "0.7182937", "0.71828544", "0.71723294", "0.7156026", "0.713149", "0.71047634", "0.7044", "0.70278555", "0.70177805", "0.70008665", "0.69808424", "0.69353414", "0.69314957", "0.6915899", "0.6900565", "0.6892338", "0.6850855...
0.0
-1
Create the schema if it doesn't exist.
def create_schema(self, schema, *, debug=False): c = self.conn.cursor() for line in schema.split(";"): line = line.strip() if len(line)>0: if self.debug or debug: print(f"{line};", file=sys.stderr) try: c.exe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_schema(schema): \n\n query = \"CREATE SCHEMA IF NOT EXISTS {}\".format(schema)\n qdb.execute(query)", "def create_schema(self, schema: str):\n return", "def create_schema_if_not_exist(self, schema):\n create_schema_sql = \"\"\"\n CREATE SCHEMA IF NOT EXISTS \"{0}\"...
[ "0.7715596", "0.7518038", "0.7496806", "0.7403349", "0.73665285", "0.7342637", "0.7317907", "0.7250138", "0.7241323", "0.7136049", "0.6929685", "0.6881734", "0.67928004", "0.6728392", "0.67238414", "0.6689868", "0.6688691", "0.66564953", "0.66428924", "0.65727705", "0.6544", ...
0.62192965
45
Execute a SQL query and return the first line
def execselect(self, sql, vals=()): self.conn.ping() c = self.conn.cursor() c.execute(sql, vals) return c.fetchone()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_one(self, sql: str) -> Any:\n with self.connection.cursor() as cursor:\n self.connection.ping(reconnect=True)\n cursor.execute(sql)\n row = cursor.fetchone()\n self.connection.commit()\n return row", "def fetch_one(self, sql):\n curs ...
[ "0.7780869", "0.76390004", "0.7576297", "0.745161", "0.7357494", "0.71004975", "0.7049767", "0.70493615", "0.6992009", "0.69467133", "0.6897321", "0.6816311", "0.68002194", "0.67960036", "0.67857444", "0.67763156", "0.6762942", "0.6745807", "0.6711482", "0.66929317", "0.66208...
0.5899251
65
Loads the bash environment variables specified by 'export NAME=VALUE' into a dictionary and returns it. Take whatever variables not in that file from the Linux environment.
def GetBashEnvFromFile(this, filename): DB_RE = re.compile("export (.+)=(.+)") ret = {} if filename is not None: with open( filename, "r" ) as f: for line in f: m = DB_RE.search(line.strip()) if m: name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_env(env_files):\n env = {}\n for env_file in env_files:\n with open(env_file) as f:\n for line in f:\n if line and line[0] != \"#\":\n try:\n index = line.index(\"=\")\n env[line[:index].strip()] = line...
[ "0.6895845", "0.6810905", "0.6783951", "0.6769671", "0.67103505", "0.6698789", "0.6692306", "0.66548026", "0.6652638", "0.6608575", "0.65690833", "0.6533156", "0.65055305", "0.6478919", "0.6466052", "0.64383376", "0.6395389", "0.6377702", "0.6372465", "0.63347304", "0.6331138...
0.78436303
0
Returns a DBMySQLAuth formed by reading MYSQL_USER, MYSQL_PASSWORD, MYSQL_HOST and MYSQL_DATABASE envrionemnt variables from a bash script. Caches by default
def FromBashEnvFile(this, filename, cache=True): if cache and filename in this.auth_cache: return this.auth_cache[filename] env = DBMySQLAuth.GetBashEnvFromFile(filename) try: auth = DBMySQLAuth(host = env[MYSQL_HOST], user = env[MYSQL_USER]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_db() -> mysql.connector.connection.MySQLConnection:\n username = getenv('PERSONAL_DATA_DB_USERNAME')\n password = getenv('PERSONAL_DATA_DB_PASSWORD')\n host = getenv('PERSONAL_DATA_DB_HOST')\n db = getenv('PERSONAL_DATA_DB_NAME')\n\n conect = mysql.connector.connection.MySQLConnection(\n ...
[ "0.6515381", "0.6305752", "0.59653795", "0.59097266", "0.59001666", "0.5899042", "0.58714527", "0.5821578", "0.58064324", "0.5776066", "0.5764474", "0.57294273", "0.57264", "0.56820935", "0.5681678", "0.5665837", "0.5655249", "0.5650574", "0.56354046", "0.5626327", "0.5606605...
0.68844616
0
Returns from the section of a config file
def FromConfig(section, debug=None): try: return DBMySQLAuth(host = section[MYSQL_HOST], user = section[MYSQL_USER], password = section[MYSQL_PASSWORD], database = section[MYSQL_DATABASE], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_conf_by_section(self, section):\n try:\n return get_conf(self.conf_file)[section]\n except:\n return None", "def get(self, name, section=section_default):\n return self.config[section][name]", "def read_section(self, configuration_file=\"./conf.txt\", section=...
[ "0.7337729", "0.72794765", "0.7240779", "0.72226465", "0.6938679", "0.6937426", "0.686506", "0.6799909", "0.6793152", "0.6790203", "0.67745614", "0.67341024", "0.67144006", "0.66940904", "0.6689701", "0.66669035", "0.6666781", "0.6651995", "0.6640001", "0.6639232", "0.6601666...
0.0
-1
Connect, select, fetchall, and retry as necessary.
def csfr(auth, cmd, vals=None, *, quiet=True, rowcount=None, time_zone=None, setup=None, setup_vals=(), get_column_names=None, asDicts=False, debug=False, dry_run=False, cache=True, nolog=[], ignore=[], autocommit=True): assert isinstance(auth,DBMySQLAuth) debug = (debug or au...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self, num_retry_attempts=1):\n pass", "def _run(self):\n #print(\"try to connect run\")\n while True:\n self._connect()\n while not self.connected and self.auto_retry is not None:\n gevent.sleep(self.auto_retry)\n self._connect(...
[ "0.61837816", "0.60995585", "0.60317314", "0.6020383", "0.59438556", "0.5817676", "0.57564455", "0.57342726", "0.57180727", "0.56888044", "0.56724346", "0.5641959", "0.56327564", "0.5611198", "0.55656093", "0.55427253", "0.5536988", "0.5520223", "0.5510912", "0.54760695", "0....
0.0
-1
Return a dictionary of the schema. This should probably be upgraded to return the ctools schema
def table_columns(auth, table_name): return [row[0] for row in DBMySQL.csfr(auth, "describe " +table_name)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_schema(self) -> dict:", "def schema(self) -> Dict[str, Dict]:\n return self._schema", "def get_schema() -> dict:\n raise NotImplementedError()", "def get_schema(self) -> dict:\n return schemas.get_object_schema(self.schema)", "def get_schema(self):\n response = self.clie...
[ "0.8848745", "0.8477742", "0.820466", "0.80211824", "0.78617096", "0.7629207", "0.76164687", "0.7543112", "0.75428694", "0.7493804", "0.7480004", "0.7475361", "0.7453375", "0.7429547", "0.74257225", "0.72050714", "0.71934015", "0.7161165", "0.71475524", "0.7130015", "0.712852...
0.0
-1
Test the get_usermail function.
def test_get_usermail(m_check): m_check.return_value = b"email\n" assert get_usermail() == "email" m_check.side_effect = subprocess.CalledProcessError(42, "test") assert get_usermail() == ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_user_by_emailuser_email_get(self):\n pass", "def test_email(self):\r\n \r\n self.assertEqual('maryc123@yahoo.com', self.user.email)", "def test_get_email_address(self):\n email_addr = 'test_get_email_addr' + '@' + self.email_dom\n org = 'o=%s' % (self.org_name)\n...
[ "0.75392437", "0.71519345", "0.6814032", "0.67871207", "0.67836803", "0.6677691", "0.6670167", "0.6616136", "0.6537178", "0.6473739", "0.6472649", "0.6373025", "0.63564473", "0.6334709", "0.6324414", "0.6312994", "0.6308379", "0.6306206", "0.6303542", "0.62552875", "0.6248734...
0.7211447
1
Test the get_username function.
def test_get_username(m_check): m_check.return_value = b"name\n" assert get_username() == "name" m_check.side_effect = subprocess.CalledProcessError(42, "test") assert get_username() == ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_users_username_get(self):\n pass", "def test_get_username(self):\r\n user = UserMgr.get(username=u'admin')\r\n self.assertEqual(\r\n user.id,\r\n 1,\r\n \"Should have a user id of 1: \" + str(user.id))\r\n self.assertEqual(\r\n user...
[ "0.88599056", "0.83401185", "0.80678487", "0.7944844", "0.7921077", "0.7810716", "0.75514495", "0.75514495", "0.73188186", "0.72970486", "0.7273818", "0.72350633", "0.72270757", "0.71202826", "0.70958626", "0.7086295", "0.7026864", "0.70158136", "0.701199", "0.6974149", "0.69...
0.7245719
11
Test the clone_repository function.
def test_clone_repository(m_check): m_check.return_value = 0 assert clone_repository("test", "test", "test") == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_clone_repository(koan, assert_cloned_repo_exists):\n koan.shell('')", "def test_clone_scenario(self):\n pass", "def test_clone_system(self):\n pass", "def _mock_git_clone(self, args: List[str]) -> None:\n cloned_repo_root = args[-1]\n\n # Create \"cloned\" directory an...
[ "0.82233465", "0.77650654", "0.7716605", "0.7560499", "0.747564", "0.7309313", "0.7285124", "0.7100823", "0.709299", "0.70320797", "0.69590735", "0.6906271", "0.6862664", "0.6752656", "0.6698426", "0.66245997", "0.6560457", "0.6463911", "0.6458351", "0.64459914", "0.641486", ...
0.8714088
0
The embedding updater model that read and answer questions
def embedding_updater_model(variables, rank, n_slots, init_params=None, n_ents=None, init_noise=0.0, loss=total_loss_logistic, scoring=multilinear, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_extract_document_embedding(self):\n input_ids = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32, name=\"ids\")\n attention_mask = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32, name=\"att\")\n token = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32,...
[ "0.6409485", "0.6324289", "0.6234172", "0.6121499", "0.6103584", "0.6020987", "0.59622705", "0.5899578", "0.5887283", "0.5861236", "0.5821322", "0.5807525", "0.57943153", "0.57827747", "0.5741384", "0.57363474", "0.5726444", "0.5716351", "0.56564707", "0.5654258", "0.5641596"...
0.6931258
0
Create a local index on a list of tuples and updates the global vocabulary
def local_vocabulary(tuples, voc): new_tuples = [] local_voc0 = Indexer() for t, v in tuples: new_t = tuple([local_voc0.string_to_int(w) for w in t]) new_tuples.append((new_t, v)) local_voc = [] for w in local_voc0.index_to_string: local_voc.append(voc(w)) return new_tupl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index(self):\n print(\"Indexing...\")\n # ------------------------------------------------------------------\n # TODO: Create an inverted, positional index.\n # Granted this may not be a linked list as in a proper\n # implementation.\n # This index sh...
[ "0.649561", "0.634331", "0.6276083", "0.62530005", "0.61110073", "0.61029226", "0.60869354", "0.60246015", "0.60092986", "0.598", "0.59775156", "0.5958632", "0.59370226", "0.59205157", "0.58659947", "0.5796124", "0.5771141", "0.5762922", "0.5750373", "0.5747169", "0.570973", ...
0.737797
0
Read a series of data and update the embeddings accordingly
def reader(context: Tuple[tf.Variable, tf.Variable], emb0: tf.Variable, n_slots: None, weights=None, step_size=1.0, scale_prediction=0.0, start_from_zeros=False, loss_grad=loss_quadratic_grad, emb_update=multilinear_grad): if context is None: # empt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _index(self, corpus):\n\n # Transform documents to embeddings vectors\n ids, dimensions, stream = self.embedder.model.index(corpus)\n\n # Load streamed embeddings back to memory\n embeddings = np.empty((len(ids), dimensions), dtype=np.float32)\n with open(stream, \"rb\") as q...
[ "0.6830049", "0.6335608", "0.6126304", "0.6093222", "0.5968234", "0.58916277", "0.584841", "0.5845506", "0.5829189", "0.58058685", "0.5739242", "0.57175463", "0.5702515", "0.568531", "0.56603086", "0.56352186", "0.56337553", "0.56174177", "0.5611823", "0.559303", "0.5573309",...
0.0
-1
Evaluate the score of tuples with embeddings that are specific to every data sample
def answerer(embeddings, tuples: tf.Variable, scoring=multilinear): n_data, n_slots, rank = [d.value for d in embeddings.get_shape()] n_data, n_tuples, order = [d.value for d in tuples.get_shape()] shift_indices = tf.constant(np.reshape( np.outer(range(n_data), np.ones(n_tuples * n_slots)) * n_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_each_score(word_embeddings, each_id_pair): # without weighting scheme\n emb1 = word_embeddings[each_id_pair[0], :]\n emb2 = word_embeddings[each_id_pair[1], :]\n inn = np.inner(emb1, emb2)\n # print('inner product is {}'.format(inn))\n emb1norm = np.sqrt(np.inner(emb1, emb1))\n # prin...
[ "0.65966535", "0.6271696", "0.61693364", "0.6096531", "0.60055155", "0.5940941", "0.5937357", "0.5903399", "0.59002817", "0.58706063", "0.5868112", "0.5857049", "0.5816769", "0.5789659", "0.5776571", "0.57489455", "0.5739431", "0.56953835", "0.5690723", "0.5675375", "0.567082...
0.59834903
5
Rounds to a variable number of decimal places as few as necessary in the range [min,max]
def normalize(amount, min=2, max=4): if not amount: return amount # To Decimal, round to highest desired precision d = round(Decimal(amount), max) s = str(d) # Truncate as many extra zeros as we are allowed to for i in range(max-min): if s[-1] == '0': s = s[:-1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def myround(value, lowerbound, higherbound):\n if value < lowerbound:\n return lowerbound\n if value > higherbound:\n return higherbound\n return value", "def _nice(x, round=False):\n if x <= 0:\n import warnings\n warnings.warn(\"Invalid (negative) range passed to tick in...
[ "0.67505205", "0.66773003", "0.6391557", "0.6360162", "0.63418365", "0.62668586", "0.6142474", "0.61340815", "0.60913086", "0.60783994", "0.60109687", "0.600941", "0.6009051", "0.6005244", "0.5997211", "0.59826225", "0.5977345", "0.5960024", "0.59580517", "0.59387255", "0.591...
0.6193746
6
Removes trailing zeros, keeping at least a specified number.
def drop_trailing(amount, decimals=2): if not amount: return amount s = str(float(amount)).rstrip('0') if decimals == 0: return s.rstrip('.') num_decimals = len(s.split('.')[1]) num_to_add = decimals - num_decimals if num_to_add <= 0: return s return s + '0' * num_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_first_zeros(digit_with_zeros): \n \n digit_without_zeros = \"\"\n\n snap = 1\n \n d = 0\n\n for d in digit_with_zeros:\n\n if d != \"0\":\n snap = 0\n if snap == 0:\n digit_without_zeros +=d\n \n return digit_without_z...
[ "0.74442893", "0.7321218", "0.71703875", "0.6988911", "0.6901619", "0.6722442", "0.66972", "0.6550412", "0.6526725", "0.650372", "0.64469194", "0.631782", "0.62386894", "0.6091823", "0.5994243", "0.5845531", "0.583502", "0.5832329", "0.58009475", "0.5774697", "0.57746726", ...
0.65390474
8
take 1D float array of rewards and compute discounted reward
def discount_rewards(r): discounted_r = np.zeros_like(r) running_add = 0 for t in reversed(range(r.size)): running_add = running_add * gamma + r[t] discounted_r[t] = running_add return discounted_r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discount_rewards(rewards):\r\n discounted_r = np.zeros_like(rewards)\r\n running_add = 0\r\n for t in reversed(range(0, len(rewards))): \r\n running_add = running_add * reward_discount + rewards[t]\r\n discounted_r[t] = running_add\r\n return discounted_r", "def discoun...
[ "0.8100923", "0.78397125", "0.7792625", "0.7742053", "0.7653779", "0.75987715", "0.7583268", "0.75820553", "0.7579539", "0.7519005", "0.75047183", "0.7467692", "0.7456702", "0.7433794", "0.7426565", "0.74062765", "0.73950297", "0.7370545", "0.73564714", "0.7328519", "0.720184...
0.7536054
9
Generate a function which converts a z and step value to an RGB colour, based on three predefined ratios.
def get_colour(self, r1, r2, r3, b1, b2, b3): def colour(z, i): """ Gets the colour of a z and step value. :param complex z: the z value from the mandelbrot set :param int i: the step value :rtype: tuple :return: the three RGB colours ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rgbcolor(h, f):\n # q = 1 - f\n # t = f\n if h == 0:\n return v, f, p\n elif h == 1:\n return 1 - f, v, p\n elif h == 2:\n return p, v, f\n elif h == 3:\n return p, 1 - f, v\n elif h == 4:\n return f, p, v\n elif h == 5:\n return v, p, 1 - f", ...
[ "0.6529024", "0.6498187", "0.6447665", "0.6419169", "0.63274384", "0.6322723", "0.6188783", "0.60802084", "0.6072802", "0.5948455", "0.5910232", "0.5883263", "0.5878698", "0.5863626", "0.5861718", "0.58612084", "0.583371", "0.5806005", "0.57980853", "0.57717776", "0.57256144"...
0.6906919
0
Gets the colour of a z and step value.
def colour(z, i): if abs(z) < self.threshold: return self.background v = np.log2(i + self.threshold - np.log2(np.log2(abs(z)))) / self.threshold if v < 1.0: return v ** b1, v ** b2, v ** b3 # background else: v = max(0, 2 -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th...
[ "0.7341066", "0.72083485", "0.68963253", "0.6640423", "0.65460277", "0.6530589", "0.6423319", "0.62713194", "0.6260205", "0.6229389", "0.62234646", "0.6208068", "0.61786675", "0.6175499", "0.6157222", "0.6157222", "0.6157222", "0.6157222", "0.6140309", "0.6133816", "0.6130664...
0.7172321
2
Generate a function which converts a z and step value to an RGB colour, based on three predefined ratios.
def get_inner_colour(self, r1, r2, r3, b1, b2, b3): def colour(z, i): """ Gets the colour of a z and step value. :param z: the z value from the mandelbrot set :param i: the step value :rtype: list :return: list containing the RGB colours...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th...
[ "0.6905101", "0.6527362", "0.64464974", "0.64188105", "0.63265", "0.63204837", "0.6187181", "0.607829", "0.6072109", "0.594735", "0.5908517", "0.5882771", "0.58766925", "0.5861005", "0.58603394", "0.5859091", "0.5833258", "0.5804042", "0.5797796", "0.57726943", "0.5724473", ...
0.6496655
2
Gets the colour of a z and step value.
def colour(z, i): if abs(z) < self.threshold: return 0, 0, 0 v = np.log2(i + self.threshold - np.log2(np.log2(abs(z)))) / self.threshold if v < 1.0: return v ** b1, v ** b2, v ** b3 # coloured tones else: v = max(0, 2 - v) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th...
[ "0.73403287", "0.7172178", "0.6895486", "0.66384035", "0.654349", "0.65309036", "0.64248663", "0.62704283", "0.6260564", "0.62288976", "0.622155", "0.62071323", "0.6176974", "0.6173576", "0.6155353", "0.6155353", "0.6155353", "0.6155353", "0.613839", "0.61319745", "0.6128805"...
0.7208043
1
Defines the size of the grid on which to draw the mandelbrot set.
def set_grid(self, start_x, end_x, start_y, end_y, resolution_x, resolution_y, threshold): step_x = (end_x - start_x) / resolution_x step_y = (end_y - start_y) / resolution_y real, complex = np.mgrid[start_y:end_y:step_y, start_x:end_x:step_x] self.grid = real + complex * 1j self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grid_size(self):\n return self._grid_size", "def getGridSize(self):\n # This is set by the mosaic module, but other modules need to\n # know the values to take the proper size grid.\n return self.grid_size", "def _grid_hint_size(self) -> int:", "def define_grid(self):\n ...
[ "0.7052928", "0.6872349", "0.6777697", "0.65532494", "0.6459304", "0.6388547", "0.63002", "0.62486094", "0.6168989", "0.611555", "0.60756975", "0.60363597", "0.6002739", "0.59995365", "0.5982655", "0.5964983", "0.5941414", "0.59040725", "0.5903051", "0.5888311", "0.58676386",...
0.0
-1
Colours the grid and returns the image.
def get_coloured_grid(self, r1, r2, r3, b1=4, b2=2.5, b3=1): r, g, b = np.frompyfunc(self.get_colour(r1, r2, r3, b1, b2, b3), 2, 3)(self.end_z, self.end_step) img_array = np.dstack((r, g, b)) return Image.fromarray(np.uint8(img_array * 255))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_grid(self):\n plt.imshow(py.array(\n map(lambda x: map(lambda y: mplc.colorConverter.to_rgb(colord[y]), x), self.create_grid(self.graph))),\n interpolation='nearest')\n plt.show()", "def make_image(self, save=False):\n\n # image_grid = np.full((self.size_x, sel...
[ "0.6998966", "0.65337056", "0.6325635", "0.6285329", "0.6260909", "0.62575686", "0.6254772", "0.62346655", "0.618115", "0.615539", "0.61247164", "0.6097528", "0.6022386", "0.60113466", "0.6007067", "0.59790057", "0.59721226", "0.5971848", "0.59443724", "0.5926389", "0.5913297...
0.72839564
0
Generates the mandelbrot set from the set parameters for a particular number of iterations.
def generate_mandelbrot(self, iterations): if self.grid is None: raise RuntimeError("Grid hasn't been setup - call set_grid first.") # Define the tensorflow variables c = tf.constant(self.grid.astype(np.complex64)) z = tf.Variable(c) n = tf.Variable(tf.zeros_like(c, t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getMandelbrotSet(self):\n\t\t\n\t\t(x_min, x_max, y_min, y_max) = [i for i in self.extent]\n\t\t(rows, columns) = (self.width*self.dpi, self.width*self.dpi)\n\t\tr_real = np.linspace(x_min, x_max, columns)\n\t\tr_imag = np.linspace(y_max, y_min, rows)\n\t\tresult = np.empty((rows, columns))\n\n\t\t# used for s...
[ "0.59489983", "0.56008106", "0.55951405", "0.5593306", "0.55607903", "0.54957503", "0.54919815", "0.5482499", "0.54726803", "0.5471357", "0.54386574", "0.54066265", "0.5402647", "0.5369949", "0.53577334", "0.535206", "0.53520525", "0.5346284", "0.5345355", "0.53447723", "0.52...
0.6835279
0
Generates the julia set from the set parameters for a number of iterations and using a particular value of c.
def generate_julia(self, iterations, c): if self.grid is None: raise RuntimeError("Grid hasn't been setup - call set_grid first.") # Define the tensorflow variables c_val = tf.constant(np.full(shape=self.grid.shape, fill_value=c, dtype=self.grid.dtype)) z = tf.Variable(self.g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def genPowerSet(cvalues, incEmpty=False):\t\t\n\tps = list()\n\tfor cv in cvalues:\n\t\tpse = list()\n\t\tfor s in ps:\n\t\t\tsc = s.copy()\n\t\t\tsc.add(cv)\n\t\t\t#print(sc)\n\t\t\tpse.append(sc)\n\t\tps.extend(pse)\n\t\tes = set()\n\t\tes.add(cv)\n\t\tps.append(es)\n\t\t#print(es)\n\t\n\tif incEmpty:\n\t\tps.ap...
[ "0.6113237", "0.585974", "0.5496323", "0.5448815", "0.5381841", "0.53499573", "0.53280026", "0.5263938", "0.52438045", "0.5203017", "0.51715815", "0.5160977", "0.511507", "0.5103073", "0.50933886", "0.5076919", "0.5047488", "0.5038411", "0.5017469", "0.5008726", "0.5005838", ...
0.6562868
0
Print tabseparated sequence of things to line in file
def tabout(things, file=sys.stdout): print("\t".join([str(x) for x in things]), file=file) file.flush()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tab(self):\n self._write('\\t')", "def output_tab_delimited(s1, s2, i1, i2):\n _out.write(\"%s\\t%s\\t%d\\t%d\\n\" % (s1, s2, i1, i2))\n _out.write(\"%s\\t%s\\t%d\\t%d\\n\" % (s2, s1, i2, i1))", "def print_tsv(data, filename):\n with open(filename, 'wt') as fout:\n writefile = partia...
[ "0.7131929", "0.7020605", "0.66624314", "0.65175635", "0.64840746", "0.64395034", "0.63917106", "0.63775367", "0.63412404", "0.6289037", "0.61846536", "0.6176423", "0.616765", "0.61081123", "0.6081998", "0.6079226", "0.60417503", "0.59935766", "0.5967714", "0.59413093", "0.59...
0.81036395
0
get returns a list of all the users in the system
def get(self): # TODO this endpoint returns null is instead of respoinse message when token is not in the header, read about error handling to solve this issue return get_users()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n return get_all_users()", "def get(self):\n return get_all_users()", "def get(self):\n return get_all_users()", "def get(self):\n return get_all_users()", "def get_all_users():", "def get_users(self):\r\n\t\tlogger.debug(\"Fetch users\")\r\n\t\t\r\n\t\treturn l...
[ "0.8544133", "0.8544133", "0.8544133", "0.8544133", "0.85363835", "0.84463185", "0.84404284", "0.83349496", "0.8291406", "0.80483234", "0.79664856", "0.792892", "0.79038525", "0.7897605", "0.78914654", "0.78914565", "0.78870755", "0.7829862", "0.78199285", "0.7812609", "0.779...
0.7241947
88
patch updates an existing user in the system
def put(self, user_id): data = request.json return update_user(data, user_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user():", "def update_user():\n #TODO user update \n pass", "def update_user(id):\n pass", "def test_patch_user(self):\n pass", "def update(self, user: U) -> None:\n ...", "def test_040_update_user(self):\n\n testflow.step(\"Updating user %s\", TEST_USER2)\n ...
[ "0.8535191", "0.82148325", "0.76160437", "0.76012594", "0.7593992", "0.7471264", "0.7397879", "0.7326105", "0.72308886", "0.7211113", "0.71603566", "0.71422267", "0.70986223", "0.70672417", "0.7060861", "0.7040941", "0.70407265", "0.703698", "0.7034396", "0.6995369", "0.69941...
0.6422292
80
get returns a single user given its unique user_id
def get(self, user_id): user, code = get_user(user_id) if code == 404: api.abort(code=404, message="The User with the user_id doesnt Exist") return user, code
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, user_id):\n return User.get(user_id)", "def get(id):\n return User.query.filter_by(id=id).first()", "def get_user_by_id(user_id):\n return User.query.get(user_id)", "def get_user(self, user_id):\n uri = 'users/' + user_id\n return self.make_request(uri)", "def get_user(...
[ "0.84332645", "0.83980507", "0.8261577", "0.8222736", "0.8221518", "0.8178469", "0.81775814", "0.81763834", "0.8173295", "0.8173295", "0.8173295", "0.8173295", "0.81669915", "0.8094847", "0.80743533", "0.805296", "0.8034785", "0.8032745", "0.80307204", "0.8004", "0.8000615", ...
0.0
-1
delete removes a user from the system
def delete(self, user_id): return delete_user(user_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user():", "def delete_user():\n #TODO user delete\n pass", "def delete_user(id):\n pass", "def delete_user():\r\n raise NotImplementedError()", "def del_user(self, username):\n pass", "def delete_user(self):\n User.user_list.remove(self)", "def delete_user(self):\n ...
[ "0.9304841", "0.90795064", "0.8505418", "0.8406779", "0.831637", "0.82509834", "0.82509834", "0.82509834", "0.82255083", "0.8137962", "0.8115955", "0.80621094", "0.7951598", "0.7948138", "0.7906432", "0.78909653", "0.7843082", "0.7732356", "0.77239", "0.7720622", "0.77185726"...
0.73671967
70
Adds a source (as a string) corresponding to a filename in the cache. The filename can be a true file name, or a fake one, like
def add(self, filename, source): self.cache[filename] = source if os.path.isfile(filename): self.ages[filename] = os.path.getmtime(filename) # modification time
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AddSource (self, name, source, filename):\n self.containments [name] = source, filename, False", "def add_source_file(self, filename):\n self.sources.add(Source.create(filename))", "def cache(self, file_name, content):\n self.files_loaded[file_name] = content", "def put_source(file_p...
[ "0.733794", "0.70201176", "0.6331393", "0.6280567", "0.61927634", "0.6123509", "0.6102532", "0.605147", "0.6028744", "0.601777", "0.5983757", "0.5921107", "0.5879947", "0.58499354", "0.5762012", "0.5749603", "0.57389265", "0.57361263", "0.5717338", "0.57040185", "0.5688251", ...
0.8042132
0
Gets a copy of the entire cache
def get_copy(self): # This is used in avant-idle to pass the content of a cache in # the main process to a second process where an exception has been # raised. return self.cache
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cache(self):\n return self.cache", "def get(self):\n if path.exists(self.cachefile):\n self.invalidion()\n full_cache = self._get_all()\n return full_cache\n else:\n return []", "def getCacheContents(self):\n return self._cache", ...
[ "0.745652", "0.74172235", "0.72680855", "0.7232514", "0.71606326", "0.71606326", "0.71606326", "0.71606326", "0.7018596", "0.7012775", "0.7010496", "0.67941254", "0.67534447", "0.6705078", "0.6684562", "0.6615776", "0.6590172", "0.65279984", "0.6523774", "0.6464215", "0.64473...
0.7468072
0
Replaces the current cache by another
def replace(self, other_cache): # This is used in avant-idle to replace the content of the cache # in a process (where no storage normally takes place) by # that of another where the actual caching of the source is done. self.cache.clear() for key in other_cache: self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testReplaceItem(self):\n\n first = \"Little pig, little pig, let me come in!\"\n second = \"Not by the hair on my chinny-chin-chin!\"\n memcache.set('first', first)\n assert memcache.get('first') == first\n memcache.replace('first', second)\n assert memcache.get('first...
[ "0.67452043", "0.63469607", "0.6275304", "0.6189481", "0.6022924", "0.60033196", "0.59268266", "0.57108635", "0.56714857", "0.5612773", "0.56104547", "0.55959934", "0.5594574", "0.5585767", "0.5527958", "0.5526175", "0.552543", "0.552472", "0.55214816", "0.5506108", "0.548309...
0.84599257
0
Given a filename, returns the corresponding source, either from the cache or from actually opening the file. If the filename corresponds to a true file, and the last time it was modified differs from the recorded value, a fresh copy is retrieved. The contents is stored a a string and returned as a list of lines. If no ...
def get_source(self, filename): # The main reason we care about ensuring we have the latest version # of a given file is for the 'avant-idle' project where we could # 'edit and run' multiple times a given file. We need to ensure that # the content shown by the traceback is accurate. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_file_source(self, filename):\n try:\n with open(filename, encoding=\"utf8\") as f:\n lines = f.readlines()\n source = \"\".join(lines)\n except Exception:\n lines = []\n source = None\n return source, lines", "def get_ou...
[ "0.7092788", "0.6621492", "0.64070714", "0.6370972", "0.6370972", "0.6359992", "0.6252963", "0.6160644", "0.6033081", "0.6021885", "0.599927", "0.59814626", "0.58814996", "0.5880455", "0.57968", "0.57867116", "0.5776293", "0.5770049", "0.5722298", "0.56828374", "0.567691", ...
0.8423813
0
Helper function to retrieve a file
def _get_file_source(self, filename): try: with open(filename, encoding="utf8") as f: lines = f.readlines() source = "".join(lines) except Exception: lines = [] source = None return source, lines
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_file():\n fname = get_var(request, \"fname\")\n return open(fname).read()", "def get_file(self, path):\n file = self.get('data_request?id=file&parameters=%s' % path)\n return file", "def get_file(URI):\n return file_fabric.get_class(URI).get_content(URI)", "def get(self, filena...
[ "0.79854953", "0.789686", "0.75598544", "0.75327295", "0.7512711", "0.7409022", "0.730959", "0.72266984", "0.720062", "0.71793586", "0.71641433", "0.71097845", "0.7107661", "0.7107661", "0.7003901", "0.6984212", "0.6975756", "0.69507647", "0.69283926", "0.688564", "0.6861352"...
0.0
-1
Formats a few lines around a 'bad line', and returns the formatted source as well as the content of the 'bad line'.
def get_formatted_partial_source(self, filename, linenumber, offset): lines = self.get_source(filename) if not lines: return "", "" begin = max(0, linenumber - self.context) partial_source, bad_line = highlight_source( linenumber, linenumber - begin -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_exception_only(etype, value):\n # Gracefully handle (the way Python 2.4 and earlier did) the case of\n # being called with (None, None).\n if etype is None:\n return [_format_final_exc_line(etype, value)]\n\n stype = etype.__name__\n smod = etype.__module__\n if smod not in (\"_...
[ "0.5942906", "0.59109855", "0.5804325", "0.5789683", "0.5765263", "0.5730036", "0.57251096", "0.5659315", "0.5617689", "0.55531806", "0.5530319", "0.54957825", "0.545304", "0.5448972", "0.5432576", "0.54311997", "0.54229766", "0.5407884", "0.5405036", "0.53888756", "0.5380812...
0.70705295
0
Extracts a few relevant lines from a file content given as a list of lines, adding line number information and identifying a particular line. When dealing with a ``SyntaxError`` or its subclasses, offset is an integer normally used by Python to indicate the position of
def highlight_source(linenumber, index, lines, offset=None): # The following if statements are left-over diagnostic # from the hack to integrate into Idle. # they are harmless tests which could potentially be useful. if lines is None: return "", "" if index is None: print("problem in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_lines_from_file(filename, lineno, context_lines):\n\n try:\n source = open(filename).readlines()\n lower_bound = max(0, lineno - context_lines)\n upper_bound = lineno + context_lines\n\n pre_context = \\\n [line.strip('\\n') for line in source[lower_bound:lineno]]...
[ "0.6520461", "0.6438692", "0.6395089", "0.63872284", "0.6351725", "0.6201063", "0.6073642", "0.59459245", "0.5939982", "0.59217393", "0.58799213", "0.58524036", "0.58376163", "0.5836338", "0.58118933", "0.5767493", "0.57534856", "0.572237", "0.571344", "0.56282735", "0.562349...
0.60051537
7
Check if raster contains only h/v adjacent connections Illegal ac ba Legal ab aa
def clusters_connected( self): def check_connected( k, vertices, edges): dads = {} for p in vertices: dads[p] = p def Find( c): while c != dads[c]: c = dads[c] return c def Union( p, q): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_ext(im, i, j):\n neighb = 0\n count = 0\n for a in range(8):\n if (im[i+relpos[a][0], j+relpos[a][1]] and (count == 0)):\n count += 1\n neighb += 1\n else:\n count = 0\n return (neighb < 2)", "def is_inacessible(cell):\n adj, count =...
[ "0.6483187", "0.6258697", "0.6213388", "0.6037331", "0.59586877", "0.5941078", "0.5923148", "0.5912683", "0.5907906", "0.58862484", "0.58592165", "0.5856731", "0.5845715", "0.5740796", "0.5716612", "0.5691044", "0.5684787", "0.56699437", "0.5633153", "0.5612918", "0.5611113",...
0.0
-1