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
Test trydo testing function example with break to normal exit
def test_trydo_break(): assert inspect.isgeneratorfunction(tryDo) assert hasattr(tryDo, "tock") assert hasattr(tryDo, "opts") tymist = tyming.Tymist(tock=0.125) assert tymist.tyme == 0.0 states = [] do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25) assert inspect.isgenerator(d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run_loop_success(self):\n found = False\n pyint = Interpreter(limit=15)\n try:\n pyint.run(code=BF_CODE_LOOP_TWICE)\n except SystemExit: \n found = True\n self.assertFalse(found)", "def test_retry_run(self):\n pass", "def test_main(mock_t...
[ "0.63869816", "0.63265485", "0.63147306", "0.62900674", "0.6242783", "0.61911696", "0.6141206", "0.6111745", "0.60973704", "0.59276676", "0.58884645", "0.5870281", "0.58558637", "0.5848308", "0.5836646", "0.58318436", "0.5809373", "0.5804813", "0.5803023", "0.5759391", "0.575...
0.6423723
0
Test trydo testing function example with close to force exit
def test_trydo_close(): tymist = tyming.Tymist(tock=0.125) assert tymist.tyme == 0.0 states = [] do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25) assert inspect.isgenerator(do) result = do.send(None) assert result == 0 assert states == [State(tyme=0.0, context='enter', feed='D...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_terminate_run(self):\n pass", "def test_close():\n while True:\n yield", "def test_main(mock_timesleep,mock_network,mock_machine_pin):\n with pytest.raises(InterruptedError):\n AppSwitch.main()", "def test_trydoer_close():\n tymist = tyming.Tymist(tock=0.125)\n doer ...
[ "0.6395225", "0.619183", "0.6189198", "0.6176477", "0.6169383", "0.60915303", "0.5879608", "0.5844186", "0.58387417", "0.58095753", "0.5774369", "0.57531786", "0.5726396", "0.5708866", "0.5701388", "0.56967646", "0.56804425", "0.5680095", "0.5647397", "0.56312543", "0.5620959...
0.66664875
0
Test trydo testing function example with throw to force exit
def test_trydo_throw(): tymist = tyming.Tymist(tock=0.125) assert tymist.tyme == 0.0 states = [] do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25) assert inspect.isgenerator(do) result = do.send(None) assert result == 0 assert states == [State(tyme=0.0, context='enter', feed='D...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_retry_run(self):\n pass", "def test_trydo_break():\n assert inspect.isgeneratorfunction(tryDo)\n assert hasattr(tryDo, \"tock\")\n assert hasattr(tryDo, \"opts\")\n\n tymist = tyming.Tymist(tock=0.125)\n assert tymist.tyme == 0.0\n states = []\n\n do = tryDo(tymth=tymist.tyme...
[ "0.6433851", "0.63803047", "0.6284302", "0.62418973", "0.62312156", "0.6203113", "0.6190655", "0.61465496", "0.6130344", "0.6108381", "0.61045945", "0.6095485", "0.60884714", "0.60814196", "0.6035478", "0.60191983", "0.5978732", "0.5939394", "0.5919296", "0.59102464", "0.5907...
0.6895369
0
Test ServerDoer ClientDoer classes
def test_server_client(): tock = 0.03125 ticks = 16 limit = ticks * tock doist = doing.Doist(tock=tock, real=True, limit=limit) assert doist.tyme == 0.0 # on next cycle assert doist.tock == tock == 0.03125 assert doist.real == True assert doist.limit == limit == 0.5 assert doist.do...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_for_client():", "def test_create_client(self):\n pass", "def test_get_client(self):\n pass", "def test_delete_client(self):\n pass", "def test_echo_server_client():\n tock = 0.03125\n ticks = 16\n limit = ticks * tock\n doist = doing.Doist(tock=tock, real=True, li...
[ "0.7513112", "0.69929147", "0.68744075", "0.67281103", "0.66821295", "0.66807735", "0.6652283", "0.65622354", "0.6543381", "0.6526167", "0.64628434", "0.64329016", "0.64329016", "0.64329016", "0.64329016", "0.63859886", "0.63597393", "0.6336899", "0.629655", "0.6293273", "0.6...
0.7207533
1
Test EchoServerDoer ClientDoer classes
def test_echo_server_client(): tock = 0.03125 ticks = 16 limit = ticks * tock doist = doing.Doist(tock=tock, real=True, limit=limit) assert doist.tyme == 0.0 # on next cycle assert doist.tock == tock == 0.03125 assert doist.real == True assert doist.limit == limit == 0.5 assert doi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_for_client():", "def test_server_client():\n tock = 0.03125\n ticks = 16\n limit = ticks * tock\n doist = doing.Doist(tock=tock, real=True, limit=limit)\n assert doist.tyme == 0.0 # on next cycle\n assert doist.tock == tock == 0.03125\n assert doist.real == True\n assert doist....
[ "0.72575915", "0.7249093", "0.66610587", "0.6635919", "0.6635122", "0.65471476", "0.65235204", "0.65007335", "0.64428306", "0.6440027", "0.6419176", "0.64183944", "0.64183944", "0.63425195", "0.6333824", "0.6316979", "0.6309964", "0.63007313", "0.6276703", "0.6199192", "0.619...
0.77605975
0
Test EchoConsoleDoer class Must run in WindIDE with Debug I/O configured as external console
def test_echo_console(): port = os.ctermid() # default to console try: # check to see if running in external console fd = os.open(port, os.O_NONBLOCK | os.O_RDWR | os.O_NOCTTY) except OSError as ex: # maybe complain here return # not in external console else: os.close...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def console():\n start_console()", "def get_console(self):\n\t\treturn None", "def start_console(self):\n return", "def test_console_driver(duthost):\n out = duthost.shell('ls /dev/ttyUSB*', module_ignore_errors=True)['stdout']\n ttys = set(out.split())\n pytest_assert(len(ttys) > 0, \"No ...
[ "0.6557113", "0.6358973", "0.6357349", "0.6250034", "0.62377596", "0.62299806", "0.6129152", "0.612263", "0.60406756", "0.5996627", "0.59710854", "0.59572494", "0.59531933", "0.5940231", "0.5929235", "0.589979", "0.5892514", "0.5865835", "0.58611655", "0.5860659", "0.585572",...
0.74439275
0
Defines the null and alternative hypothesis.
def define_hypothesis(df, statistic, alternative, paired, alpha): paired_text = f"the {statistic} difference" if paired else f"difference in {statistic}" hypothesis = { 'two-sided_H0': f"{paired_text} equal to zero", 'two-sided_H1': f"{paired_text} not equal to zero", 'grea...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_alternative(df, hypothesis, alternative='two-sided', alpha=0.05):\n df['H0'] = hypothesis[alternative + '_H0']\n df['H1'] = hypothesis[alternative + '_H1']\n formatted_alpha = round(alpha*100, 2)\n conclusion = 'There is no evidence' if df['p-val'][0] > alpha else 'There is evi...
[ "0.6455733", "0.61753273", "0.61616707", "0.58870167", "0.58759326", "0.58596665", "0.5715439", "0.5703288", "0.5663849", "0.56625116", "0.56293815", "0.5621157", "0.56145686", "0.5562165", "0.5533882", "0.5483456", "0.54680246", "0.5450762", "0.539382", "0.5374309", "0.53743...
0.6396941
1
Tests the hypothesis using the pvalue and adds the conclusion to the results DataFrame.
def test_alternative(df, hypothesis, alternative='two-sided', alpha=0.05): df['H0'] = hypothesis[alternative + '_H0'] df['H1'] = hypothesis[alternative + '_H1'] formatted_alpha = round(alpha*100, 2) conclusion = 'There is no evidence' if df['p-val'][0] > alpha else 'There is evidence' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_hypothesis(df, statistic, alternative, paired, alpha):\n paired_text = f\"the {statistic} difference\" if paired else f\"difference in {statistic}\"\n hypothesis = {\n 'two-sided_H0': f\"{paired_text} equal to zero\",\n 'two-sided_H1': f\"{paired_text} not equal to zero\"...
[ "0.6139014", "0.59191096", "0.56186587", "0.55141944", "0.55031806", "0.53873", "0.53590375", "0.5266749", "0.5259233", "0.5245075", "0.5224029", "0.52130735", "0.520389", "0.51930904", "0.51885474", "0.51866484", "0.5186087", "0.51756436", "0.5168725", "0.51264113", "0.51248...
0.640209
0
Perform correlation between two variables.
def correlation_test(sample1, sample2, method='pearson', alpha=0.05, alternative='two-sided', show_graph=True, **kwargs): text = 'relationship between the two variables' hypothesis = { 'two-sided_H0': f"there is no {text}", 'two-sided_H1': f"there is a {text}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correlation(self, other):\n dates=self.get_dates(other.get_dates())\n #print(len(self.get_values(dates)))\n #print(len(other.get_values(dates)))\n #print(self.get_values(dates))\n r,p=stats.pearsonr(self.get_values(dates), other.get_values(dates))\n return r", "def C...
[ "0.75207645", "0.74861574", "0.73077905", "0.7302946", "0.7222768", "0.7151656", "0.70080733", "0.6993429", "0.69753855", "0.6928357", "0.6922723", "0.6893102", "0.6852905", "0.6846402", "0.6845538", "0.6818033", "0.67677784", "0.67537844", "0.67537844", "0.67466134", "0.6725...
0.0
-1
Tests the null hypothesis that the data is normally distributed
def normality_test(sample, alpha=0.05, method='shapiro', show_graph=True, **kwargs): hypothesis = { 'two-sided_H0': f"the data is normally distributed", 'two-sided_H1': f"the data is not normally distributed" } sample = np.array(sample) np_types...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_continuous():\n # assert the distribution of the samples is close to the distribution of the data\n # using kstest:\n # - uniform (assert p-value > 0.05)\n # - gaussian (assert p-value > 0.05)\n # - inversely correlated (assert correlation < 0)", "def test_null_from_normal(self):\n ...
[ "0.71112454", "0.7025147", "0.66127676", "0.6552619", "0.64574045", "0.6423659", "0.6406812", "0.6395794", "0.63904554", "0.63602495", "0.63487864", "0.6278788", "0.6221371", "0.6189141", "0.61687404", "0.61294156", "0.61126345", "0.61106765", "0.6099031", "0.6088916", "0.606...
0.0
-1
Perform a Fisher exact test.
def fisher_exact_test(df, sample1, sample2, alpha=0.05, show_graph=True, **kwargs): hypothesis = { 'two-sided_H0': "the samples are independent", 'two-sided_H1': "the samples are dependent", } table = pd.crosstab(df[sample1], df[sample2]) sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fisher(self):\r\n self.assertFloatEqual(fisher([0.073, 0.086, 0.10, 0.080, 0.060]),\r\n 0.0045957946540917905)", "def test_fisher_alpha(self):\n c = array([4,3,4,0,1,0,2])\n obs = fisher_alpha(c)\n self.assertFloatEqual(obs, 2.7823795367398798)", ...
[ "0.74760246", "0.6522067", "0.64530474", "0.6412917", "0.62115204", "0.60252494", "0.5753306", "0.5741627", "0.5709703", "0.5694631", "0.56128263", "0.5588021", "0.5570426", "0.55371743", "0.5528919", "0.54683965", "0.54555136", "0.5447295", "0.5433581", "0.5433376", "0.54263...
0.61430454
5
Chisquared independence test between two categorical variables.
def chi2_test(df, sample1, sample2, correction=True, alpha=0.05, show_graph=True, **kwargs): hypothesis = { 'two-sided_H0': "the samples are independent", 'two-sided_H1': "the samples are dependent" } expected, observed, stats = pg.chi2_independence(df, samp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_categorical():\n # assert the distribution of the samples is close to the distribution of the data\n # using cstest:\n # - uniform (assert p-value > 0.05)\n # - very skewed / biased? (assert p-value > 0.05)\n # - inversely correlated (assert correlation < 0)", "def chi_test_goodness...
[ "0.61919755", "0.6090222", "0.5977698", "0.5950685", "0.59144706", "0.5875124", "0.58437693", "0.57276577", "0.5675882", "0.56587726", "0.56542903", "0.56377614", "0.5602135", "0.559903", "0.5575093", "0.5568508", "0.55496687", "0.5521763", "0.5510721", "0.54972994", "0.54895...
0.51980954
55
Ttest can be paired or not. The paired ttest compares the means of the same group or item under two separate scenarios. The unpaired ttest compares the means of two independent groups.
def t_test(sample1, sample2, paired=False, alpha=0.05, alternative='two-sided', correction='auto', r=0.707, show_graph=True, **kwargs): confidence = 1 - alpha df_result = pg.ttest( sample1, sample2, paired=paired, confidence=c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ttest_2samp(x1, x2, alpha=0.05, paired=False, is_bernoulli=False, two_sided=True, return_tuple=False):\n x = np.asarray(x1)\n y = np.asarray(x2)\n\n # Define test degrees of freedom\n if two_sided:\n quant_order = 1 - (alpha / 2)\n h0 = 'X1_bar = X2_bar'\n h1 = 'X1_bar != X2_ba...
[ "0.6858824", "0.67689383", "0.66971606", "0.6666218", "0.6638158", "0.6576945", "0.6485257", "0.64660966", "0.6455032", "0.64471155", "0.64399266", "0.64118457", "0.6377159", "0.6345801", "0.6295458", "0.6133576", "0.6128303", "0.6061013", "0.60073733", "0.5988047", "0.586850...
0.6669023
3
Confidence interval for differences (nonGaussian unpaired data)
def non_param_unpaired_ci(sample1, sample2, alpha=0.05): n1 = len(sample1) n2 = len(sample2) N = norm.ppf(1 - alpha/2) diffs = sorted([i-j for i in sample1 for j in sample2]) k = np.math.ceil(n1*n2/2 - (N * (n1*n2*(n1+n2+1)/12)**0.5)) CI = (round(diffs[k-1], 3), round(dif...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_confidence_interval(data):\n a = 1.0 * np.array(data)\n m = np.mean(a)\n std = np.std(a)\n pm = 1.96 * (std / np.sqrt(len(a)))\n return m, pm", "def confidence_intervals(data):\r\n\r\n x_bar = np.nanmean(data) # Mean value\r\n s = np.nanstd(data) # Standard deviation\r...
[ "0.7395203", "0.7145817", "0.6741393", "0.66793495", "0.6660753", "0.6656944", "0.663477", "0.65957725", "0.6511848", "0.6493911", "0.6453965", "0.64177084", "0.6402729", "0.63797855", "0.6348145", "0.6324356", "0.62575376", "0.6243653", "0.62149024", "0.6190887", "0.61880887...
0.59291995
32
Confidence interval for differences between the two samples.
def non_param_paired_ci(sample1, sample2, alpha): n = len(sample1) N = norm.ppf(1 - alpha/2) diff_sample = sorted(list(map(operator.sub, sample2, sample1))) averages = sorted([(s1+s2)/2 for i, s1 in enumerate(diff_sample) for _, s2 in enumerate(diff_sample[i:])]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confidenceInterval(start,end,confidence):\n\n\tmean = 0.5*(end+start)\n\tstddev = getStdDev(0.5*(end-start), confidence)\n\n\treturn (mean,stddev)", "def do_mean_cis_differ(mean1, ci1, mean2, ci2):\n\n assert ci1 >= 0.0 and ci2 >= 0.0, 'Found negative confidence interval from bootstrapping.'\n x1 = mea...
[ "0.69878685", "0.69680375", "0.6955768", "0.6875255", "0.6774121", "0.64958274", "0.6471887", "0.6469817", "0.6291839", "0.6264346", "0.61657953", "0.6164545", "0.6094606", "0.60685885", "0.60413724", "0.60233855", "0.5988977", "0.5958142", "0.5919842", "0.5896381", "0.586550...
0.581309
22
DO NOT TOUCH THIS FUNCTION. IT IS USED FOR COMPUTER EVALUATION OF YOUR CODE
def main(): conf_matrix1 = one_vs_all() conf_matrix2 = all_vs_all() results = my_info() + '\t\t' results += np.array_str(np.diagonal(conf_matrix1)) + '\t\t' results += np.array_str(np.diagonal(conf_matrix2)) print results + '\t\t' # sum = 0 # # for i in range(len(conf_matrix1)): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exercise_b2_106():\r\n pass", "def exercise_b2_113():\r\n pass", "def exercise_b2_107():\r\n pass", "def exo2():", "def exercise_b2_53():\r\n pass", "def exercise_b2_69():\r\n pass", "def substantiate():", "def cx():", "def exercise_b2_70():\r\n pass", "def exercise_b2_98():...
[ "0.6566857", "0.6499232", "0.6485341", "0.64318156", "0.6431804", "0.63610214", "0.6329877", "0.6256674", "0.6234512", "0.6231", "0.62212175", "0.6176965", "0.6172292", "0.61367464", "0.6136744", "0.61277723", "0.6112681", "0.6068746", "0.60585713", "0.6025986", "0.59825903",...
0.0
-1
Called from the definition file with the description of the state. Receives a dictionary and populates internal structures based on it. The
def AddState(self, **dic): state = State() state.name = dic['name'] state.external_name = dic['external'] state_transitions = [] for (condition, destination) in dic['transitions']: transition = Transition(condition, state.name, destination) state_transitions.append(transition) se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_states(self, state_dict, start_state):\n self.state_dict = state_dict\n self.state_name = start_state\n self.state = self.state_dict[self.state_name]()", "def load_state(self, dictionary):\n self.log_formatstr = dictionary['log_formatstr']\n self.backend_interval = di...
[ "0.6415245", "0.62513024", "0.62250906", "0.62250906", "0.62250906", "0.6217904", "0.61744905", "0.6153479", "0.6133525", "0.61250806", "0.6079985", "0.6068479", "0.60613006", "0.60173726", "0.6006548", "0.6000775", "0.5996518", "0.5996518", "0.59851617", "0.5963311", "0.5960...
0.0
-1
Called from the definition file with the definition of a condition. Receives the name of the condition and it's expression.
def AddCondition(self, name, expression): self.conditions[name] = expression
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def condition(self) -> global___Expression:", "def condition(self) -> global___Expression:", "def eval_definition(exp, env):\n define_variable(definition_variable(exp), m_eval(definition_value(exp), env), env)\n return quote(\"ok\")", "def condition(self, condition):\n\n self._condition = condit...
[ "0.60299903", "0.60299903", "0.58058965", "0.57567054", "0.5676619", "0.5661788", "0.5585156", "0.55506593", "0.5536422", "0.54914516", "0.54885614", "0.5461103", "0.54198915", "0.54021317", "0.53634095", "0.5359292", "0.53558147", "0.5352741", "0.5310563", "0.53045696", "0.5...
0.73426414
0
Load the state machine definition file. In the definition file, which is based on the python syntax, the following variables and functions are defined.
def Load(self, filename): self.sm['state'] = self.AddState self.sm['condition'] = self.AddCondition exec(open(filename).read(), self.sm) self.name = self.sm['name'] if not self.name.isalnum(): raise Exception("State machine name must consist of only alphanumeric" "charac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_state_machine_definitions(\n def_file: str) -> Tuple[str, YamlInputFile, MachineDefinition]:\n # Determine the data directory ad build the config file's absolute path\n model_definition_path = get_data_dir()\n model_definition_filename = os.path.sep.join(\n [model_definition_path, ...
[ "0.65411615", "0.6423537", "0.60361713", "0.59719336", "0.59658307", "0.58369714", "0.5749073", "0.570999", "0.5671639", "0.5663093", "0.56431085", "0.56079596", "0.558816", "0.5572879", "0.5572879", "0.55678475", "0.55635643", "0.55422217", "0.5507806", "0.5505211", "0.55027...
0.76456934
0
Equivalent to AB or A\B in set theory. Difference/Relative Complement
def difference(a, b): return list(filterfalse(lambda x: x in b, a))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_difference():", "def get_complement(seta):\n\n complement_set = set()\n\n for elem in seta:\n new_elem_tuple = (elem[0], float(D('1.0') - D(str(elem[1]))))\n complement_set.add(new_elem_tuple)\n\n return complement_set", "def commutator(A, B):\n return A @ B - B @ A", "d...
[ "0.6728144", "0.61966085", "0.61682", "0.60336477", "0.59859383", "0.5885711", "0.5876446", "0.5855507", "0.58093464", "0.57327807", "0.5728684", "0.5707002", "0.57048213", "0.56865865", "0.56851715", "0.56820685", "0.5665925", "0.5650496", "0.5631561", "0.56121475", "0.56004...
0.0
-1
Used to get next row of either list of dicts or cursor
def get_next_row(table, names): if isinstance(table, list): if not table: return None, True else: return table.pop(0), False else: row = table.fetchone() if row is None: return None, True else: return dict(zip(names, row)),...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __next__(self) :\n\n data = self.cur.fetchone()\n if not data :\n raise StopIteration\n return RowReference(self.desc, data[1:])", "def next(self, num_rows=10):\n\n start = self._cursor\n stop = start + num_rows\n self._cursor += num_rows\n return s...
[ "0.6931901", "0.64631486", "0.64456135", "0.63371646", "0.6249426", "0.6236442", "0.6208837", "0.6197598", "0.618017", "0.6168919", "0.61328393", "0.6082178", "0.60636836", "0.6054832", "0.6017265", "0.59916645", "0.59916645", "0.598793", "0.5943697", "0.59400916", "0.5934102...
0.67075896
1
Used to group together all rows in a table
def grouped_sql(table, columns): sql = \ " ( " + \ "SELECT " + ",".join(columns) + ", COUNT(*) " + \ "AS COUNT " + \ " FROM " + ",".join(table) + \ " GROUP BY " + ",".join(columns) + \ " ) " return sql
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_by(self, columns):\n\n return self._get(\"group\", columns, Table)", "def generate_table(self, rows):\n ...", "def group(self, j, function=FIRST, key=lambda v: v):\n if not isinstance(function, (tuple, list)):\n function = [function] * self._m\n J = j\n #...
[ "0.6104078", "0.59451896", "0.59261405", "0.59202516", "0.5898231", "0.58725226", "0.5824926", "0.5820556", "0.581354", "0.5757736", "0.5685524", "0.56686515", "0.5659242", "0.5645669", "0.5645669", "0.56298447", "0.56032294", "0.5570632", "0.55481434", "0.55481434", "0.55449...
0.5494387
23
Used to find all rows in one table but not in another, not treating rows as distinct.
def unsorted_not_distinct(table1, table2, subset=False): only_in_table1 = [] if subset: # When subset, a row in table1 is not subset, # if its contains more instances of a row than table2 for row in table1: count1 = table1.count(row) count2 = table2.count(row) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setDifference(self, table2):\n results = set([])\n for rec in self.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n results.add(rec_tuple)\n for rec in table2.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n if rec_tuple...
[ "0.68144566", "0.671206", "0.65324634", "0.649911", "0.6377828", "0.6274883", "0.6272812", "0.6096138", "0.60055655", "0.5998634", "0.59853375", "0.5975118", "0.59444433", "0.59095633", "0.5894284", "0.58582914", "0.58507025", "0.5822497", "0.5753021", "0.5674006", "0.5666055...
0.67386425
1
Used to find all rows in one table but not in another.
def tab_unsorted(table1, table2, where_conditions, dw_rep): sql = \ " SELECT * " + \ " FROM " + table1 + \ " AS table1 " + \ " WHERE NOT EXISTS" \ " ( " + \ " SELECT NULL " + \ " FROM " + table2 + \ " AS table2 " + \ " WHERE " + " AND ".join(w...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setDifference(self, table2):\n results = set([])\n for rec in self.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n results.add(rec_tuple)\n for rec in table2.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n if rec_tuple...
[ "0.6672395", "0.6617561", "0.65095437", "0.6373357", "0.6184577", "0.6165197", "0.59691566", "0.5948662", "0.5894413", "0.58872354", "0.5830431", "0.58233774", "0.5791073", "0.5774153", "0.5673653", "0.56427497", "0.5573534", "0.5549403", "0.55481064", "0.55452496", "0.552260...
0.683357
0
Does a positional comparison of two sorted tables
def sorted_compare(actual, expected): # Get names of attributes names = [t[0] for t in actual.description] result = True actual_empty = False expected_empty = False # Run through both lists as long as we find no errors and no list is empty. while result and not actual_empty and not expecte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __cmp__(self, other_table):\n # __cmp__ functions return -1 if we are less than schema\n # 0 if we are the same as schema\n # 1 if we are greater than schema\n # If our 'compare' method returns anything there are differences\n ...
[ "0.6801732", "0.65068626", "0.6435971", "0.64123297", "0.6186599", "0.617459", "0.6155578", "0.6145169", "0.6141934", "0.6133277", "0.6119683", "0.61114097", "0.609584", "0.6036873", "0.60327053", "0.60302013", "0.60171545", "0.60118", "0.59924406", "0.5973167", "0.5945185", ...
0.0
-1
Does a subset comparison of two sorted tables
def subset_sorted_compare(actual, expected): # Get names of attributes names = [t[0] for t in actual.description] e_row, expected_empty = get_next_row(expected, names) if not expected_empty: result = None not in e_row.values() else: result = False actual_empty = False # Ru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compare_tables(t1, t2):\n assert type(t1)==type(t2)\n assert isinstance(t1,(np.ndarray,DataTable,pd.DataFrame))\n assert np.shape(t1)==np.shape(t2)\n if isinstance(t1,DataTable):\n assert all([np.all(t1.c[i]==t2.c[i]) for i in range(np.shape(t1)[1])])\n else:\n assert np.all(t1==t2...
[ "0.6723325", "0.6639622", "0.6540761", "0.64077485", "0.63627774", "0.6208932", "0.6208834", "0.6191564", "0.6189009", "0.61446047", "0.6110602", "0.60610974", "0.5989919", "0.59587985", "0.59558547", "0.58967036", "0.5894383", "0.58753526", "0.5857242", "0.5827912", "0.58035...
0.685202
0
Compares the two tables and sets their surpluses for reporting.
def run(self, dw_rep): only_in_actual = [] only_in_expected = [] sort_result = False # Gets the actual columns we want to compare on. chosen_columns = self.setup_columns(dw_rep, self.actual_table, self.column_names, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_if_two_tables(table_one, table_two):\n assert left_join(table_one, table_two) == [['fond', 'enamored', 'averse'], ['guide', 'usher', 'follow'], ['diligent', 'employed', 'idle'], ['wrath', 'anger', 'deligth']]", "def __cmp__(self, other_table):\n # __cmp__ functions return -1 if we are less tha...
[ "0.6211615", "0.61949384", "0.6193802", "0.6126203", "0.5857758", "0.5839341", "0.5837315", "0.5801258", "0.57720935", "0.5737858", "0.5735085", "0.5695702", "0.5634066", "0.5577839", "0.5497134", "0.54786825", "0.54720753", "0.5443053", "0.542862", "0.5407728", "0.5389016", ...
0.49782437
65
A view is the representation of a resource. During boottime applications can add resource representation as callables using this API. Since there can be more than one representation of a resource, there can be more than one viewcallable for the same requestURL. In which case the view callable had to be resolved based o...
def add_view( *args, **kwargs ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_view(self, request=None, args=None, kwargs=None, **initkwargs):\n view = self.view_class(**initkwargs)\n view.setup(request, *(args or ()), **(kwargs or {}))\n return view", "def as_view(cls, *class_args, **class_kwargs):\n def view(*args, **kwargs):\n self = view.v...
[ "0.63902235", "0.6374959", "0.6324555", "0.6310613", "0.62657696", "0.6252142", "0.61539096", "0.60092854", "0.6006901", "0.59187603", "0.59163207", "0.59148866", "0.5865454", "0.5859748", "0.5833161", "0.5810865", "0.577921", "0.5751791", "0.5749036", "0.57035476", "0.569929...
0.6325184
2
Resolve ``request`` to viewcallable. For a successful match, populate relevant attributes, like `matchdict` and `view`, in ``request`` plugin. A viewcallable can be a plain python callable that accepts request and context arguments or a plugin implementing
def route( request, c ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _wrapped_view(request, *args, **kwargs):\n return view_func(request, *args, **kwargs)", "def as_view(cls, action_map=None, **initkwargs):\n\n # Needs to re-implement the method but contains all the things the parent does.\n if not action_map: # actions must not be empty\n ...
[ "0.6543802", "0.62480587", "0.6214749", "0.62027234", "0.6197727", "0.6166379", "0.61643225", "0.60714966", "0.6056894", "0.59635854", "0.59240335", "0.58575875", "0.5834903", "0.5803857", "0.5791674", "0.5789351", "0.57790864", "0.56896657", "0.56607234", "0.565373", "0.5647...
0.5111074
59
Generate path, including query and fragment (aka anchor), for ``request`` using positional arguments ``args`` and keyword arguments ``kwargs``. Refer to corresponding router plugin for specific signature for positional and keyword arguments. Returns urlpath string. This does not include SCRIPT_NAME, netlocation and sch...
def urlpath( request, *args, **kwargs ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_url(self, **kwargs):\n\n return build(\n self._request.path,\n self._request.GET,\n self._meta.prefix,\n **kwargs )", "def pathfor( request, *args, **kwargs ):", "def url(self, request_path=\"\"):\n return f\"{self.scheme}://{self.host}/{request...
[ "0.64753556", "0.628129", "0.62777704", "0.62373245", "0.6221489", "0.62195736", "0.6203761", "0.61327916", "0.6034436", "0.6002653", "0.5988426", "0.5972479", "0.5961196", "0.59514344", "0.59143126", "0.5896229", "0.5896229", "0.58924574", "0.5859545", "0.5827251", "0.580974...
0.68177366
0
Callback for asyncrhonous finish(). Means the response is sent and the request is forgotten. Chained call originating from
def onfinish( request ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cb_request_done(result):\n self._current_request = None\n return result", "def done(self):\n ## All done with the request object\n self.closed = True\n self.d.callback('')", "def deferred_response(response, request):\n request.write(simplejson.dumps(response))\...
[ "0.73311496", "0.66925883", "0.66114795", "0.66111887", "0.6592106", "0.65328", "0.6502333", "0.64901215", "0.645132", "0.64137673", "0.63908446", "0.6291713", "0.6274575", "0.6261008", "0.6200714", "0.61751294", "0.6143416", "0.6133714", "0.61082023", "0.6104768", "0.6095540...
0.7034546
2
When the router finds that a resource (typically indicated by the requestURL) has multiple representations, where each representation is called a variant, it has to pick the best representation negotiated by the client. Negotiation is handled through attributes like mediatype, language, charset and contentencoding. ``r...
def negotiate( request, variants ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_negotiation(self, request, environ, mtype_list):\n alist = request.sys_query_options.get(core.SystemQueryOption.format,\n None)\n if alist is None:\n if \"HTTP_ACCEPT\" in environ:\n try:\n alist = m...
[ "0.6388638", "0.58420646", "0.572146", "0.56802297", "0.56731945", "0.56254303", "0.56223434", "0.56139547", "0.55455554", "0.551041", "0.5460923", "0.54406977", "0.5377689", "0.5287527", "0.52641153", "0.5233765", "0.5164498", "0.51348597", "0.5087331", "0.50804424", "0.5079...
0.6252837
1
Resource object to gather necessary data before a request is handled by the view (and templates). Return updated
def __call__( request, c ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh(self):\n self.dto = self.res.get()\n log.debug(f\"Refreshed {self.url}\")", "def prePresent(self, request):", "def _update_from_rest_data(self) -> None:", "def __init__(self):\n super(Resource, self).__init__()\n\n # ____building form class for resources validation____...
[ "0.61961716", "0.6112339", "0.6090412", "0.6077346", "0.60087204", "0.5996591", "0.5987353", "0.58234686", "0.5803258", "0.57999533", "0.57669985", "0.57632554", "0.57432127", "0.57427675", "0.5713234", "0.57062846", "0.57042134", "0.57032424", "0.56993175", "0.5684876", "0.5...
0.0
-1
Use HTTP `headers` dictionary, to parse cookie name/value pairs, along with its metainformation, into Cookie Morsels. Get the cookie string from ``headers`` like,
def parse_cookies( headers ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __extractCookies(self, cookieString):\n parts = cookieString.split(\"; \")\n \n data = {}\n \n for cookie in parts:\n keyValues = cookie.split(\"=\")\n data[keyValues[0]] = keyValues[1]\n \n return data\n #print resultHeadersKv\n...
[ "0.66611415", "0.64269054", "0.6329864", "0.6290737", "0.6235485", "0.6235485", "0.6199424", "0.61779773", "0.61479324", "0.60945964", "0.60757387", "0.59653485", "0.59545845", "0.5939655", "0.5897959", "0.58464956", "0.5736396", "0.56966174", "0.5693424", "0.56601405", "0.56...
0.80582446
0
Update ``cookies`` dictionary with cookie ``name`` and its ``morsel``. Optional Keyword arguments, typically, contain ``domain``, ``expires_days``, ``expires``, ``path``, which are set on the Cookie.Morsel directly. ``cookies``, Dictionary like object mapping cookie name and its morsel. It is updated inplace and return...
def set_cookie( cookies, name, morsel, **kwargs ) :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_cookie(\n self,\n name: str,\n value: str,\n *,\n expires: Optional[str] = None,\n domain: Optional[str] = None,\n max_age: Optional[Union[int, str]] = None,\n path: str = \"/\",\n secure: Optional[bool] = None,\n httponly: Optional[bool...
[ "0.6560919", "0.6371054", "0.61873186", "0.59360474", "0.5889485", "0.58349055", "0.5782738", "0.57371664", "0.5694596", "0.56428206", "0.5622598", "0.55732596", "0.557322", "0.5484455", "0.54833525", "0.54718137", "0.54183614", "0.53668654", "0.5339797", "0.5316583", "0.5278...
0.7567295
0
Encode `name` and `value` string into bytestring using 'utf8' encoding settings, convert value into base64. Return signed value as
def create_signed_value( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_signed_value( name, value ):", "def create_signed_value(self, name, value):\n timestamp = str(int(time.time()))\n value = base64.b64encode(value)\n signature = self._cookie_signature(name, value, timestamp)\n value = \"|\".join([value, timestamp, signature])\n return...
[ "0.74074805", "0.72518563", "0.6848577", "0.68351907", "0.68086785", "0.67794716", "0.6740177", "0.6641136", "0.65297794", "0.6510254", "0.64581174", "0.6431112", "0.63822645", "0.6331633", "0.6327253", "0.63222975", "0.6310317", "0.6296021", "0.62504447", "0.62287617", "0.62...
0.70378983
2
Reverse of `create_signed_value`. Returns orignal value string.
def decode_signed_value( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_signed_value( name, value ):", "def create_signed_value(self, name, value):\n timestamp = str(int(time.time()))\n value = base64.b64encode(value)\n signature = self._cookie_signature(name, value, timestamp)\n value = \"|\".join([value, timestamp, signature])\n return...
[ "0.7920129", "0.7463464", "0.6136986", "0.60241175", "0.58482724", "0.5676598", "0.5675891", "0.5605429", "0.5586185", "0.55268997", "0.5525378", "0.5519846", "0.5481415", "0.5449742", "0.5444262", "0.54402775", "0.54240555", "0.5422352", "0.5415995", "0.5411165", "0.5401655"...
0.65975523
2
Instance of plugin implementing this interface corresponds to a single HTTP request. Note that instantiating this class does not essentially mean the entire request is received. Only when
def __init__( httpconn, method, uri, uriparts, version, headers ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self, request):\n response = self.get_request(request)\n return response", "def __init__( request ):", "def _request(self, *args, **kwargs):\n request = self._make_request(*args, **kwargs)\n\n return self._collect_request(request)", "def req():\n return Request()",...
[ "0.6189991", "0.60930073", "0.6061302", "0.59549767", "0.59143215", "0.5901719", "0.5868419", "0.5847523", "0.58012015", "0.579273", "0.577959", "0.57579935", "0.5743879", "0.57389355", "0.57323503", "0.57314944", "0.57161", "0.5702668", "0.56985885", "0.56957847", "0.5638289...
0.0
-1
Returns True if this request supports HTTP/1.1 semantics
def supports_http_1_1():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_server_should_be_http_1_1(httpbin):\n resp = get_raw_http_response(httpbin.host, httpbin.port, \"/get\")\n assert resp.startswith(b\"HTTP/1.1\")", "def is_supported(self) -> bool:\n\n # TODO logging ?\n # TODO ICMP error if ttl is zero\n return self._version == 4 and self._ihl...
[ "0.63006914", "0.6202393", "0.61148703", "0.61043656", "0.5947065", "0.59074837", "0.5852643", "0.5731418", "0.56117535", "0.5606208", "0.5559672", "0.5547659", "0.55382115", "0.55035686", "0.5499543", "0.5495566", "0.5454329", "0.54527396", "0.54498947", "0.5448252", "0.5395...
0.80598897
0
Returns the client's SSL certificate, if any. To use client certificates, `cert_reqs` configuration value must be set to ssl.CERT_REQUIRED. The return value is a dictionary, see SSLSocket.getpeercert() in the standard library for more details.
def get_ssl_certificate():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def client_certificate_config(self) -> Optional[pulumi.Input['ClientCertificateConfigArgs']]:\n return pulumi.get(self, \"client_certificate_config\")", "def client_certificate(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"client_certificate\")", "def client_certificate(self) ...
[ "0.7112209", "0.70620036", "0.6646048", "0.6646048", "0.6526283", "0.6438687", "0.6353446", "0.61203897", "0.61203897", "0.6104504", "0.609127", "0.609127", "0.6029551", "0.5963813", "0.5963813", "0.595275", "0.5936866", "0.5927882", "0.59048986", "0.58622354", "0.58016706", ...
0.606661
12
Gets the value of the cookie with the given ``name``, else return
def get_cookie( name, default=None ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cookie(self, name):\n return self.cookies.get(name)", "def get_cookie(self, name, value=None):\n try:\n return cherrypy.request.cookie[name].value\n except KeyError:\n return value", "def cookie(self, name, default=None):\r\n return self._get_cookies()....
[ "0.8593456", "0.85346776", "0.8050004", "0.7930324", "0.7896314", "0.77555186", "0.7635223", "0.71214765", "0.70636433", "0.70636433", "0.69677705", "0.6951423", "0.6725989", "0.6701835", "0.65948856", "0.65907526", "0.6511549", "0.6478165", "0.6344316", "0.614494", "0.599972...
0.7946743
3
Returns a signed cookie if it validates, or None. Call to this
def get_secure_cookie( name, value=None ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cookie(self, provided_cookie, decrypt=True):\n\n if 'HTTP_COOKIE' in self.environ:\n grab_cookie = cookies.SimpleCookie(self.environ['HTTP_COOKIE'])\n \n if provided_cookie in grab_cookie:\n if decrypt:\n try:\n ...
[ "0.67511994", "0.64220226", "0.61643136", "0.6157462", "0.6149605", "0.5972794", "0.5919926", "0.5899736", "0.5893973", "0.5885634", "0.5859752", "0.5823456", "0.5812559", "0.5812559", "0.5784276", "0.57393366", "0.5726692", "0.5698617", "0.5693313", "0.5668825", "0.56523204"...
0.6572365
1
Return True if this request is considered finished, which is, when
def has_finished():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished(self):\n return self._state == FINISHED_STATE", "def isFinish(self):\n return self.finish", "def isFinished(self):\n return self.isTimedOut()", "def done(self):\n return self._status != Future.STATUS_STARTED", "def isFinished():", "def isFinished():", "def isFin...
[ "0.7893599", "0.785629", "0.7801624", "0.7791034", "0.77553874", "0.77553874", "0.77553874", "0.7745339", "0.7745339", "0.7745339", "0.7722582", "0.7720691", "0.7706907", "0.76873726", "0.7687296", "0.76775944", "0.7634663", "0.76284164", "0.7626273", "0.75619394", "0.7538805...
0.7938837
0
Returns True if this request is received using `chunked` TransferEncoding.
def ischunked() :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_chunked(self):\r\n cl = 0\r\n data = StringIO.StringIO()\r\n while True:\r\n line = self.rfile.readline().strip().split(\";\", 1)\r\n chunk_size = int(line.pop(0), 16)\r\n if chunk_size <= 0:\r\n break\r\n cl += chunk_size\r...
[ "0.59374046", "0.5720478", "0.5649413", "0.5643323", "0.553375", "0.55225235", "0.5521607", "0.54682434", "0.5453274", "0.53548074", "0.5349224", "0.52951217", "0.5291799", "0.52821094", "0.52617615", "0.5254956", "0.52493757", "0.5239688", "0.5227221", "0.5220763", "0.521872...
0.7465098
0
Callback for asyncrhonous finish(). Means the response is sent and
def onfinish():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished(self, reply):\n pass", "async def _response_handler(self):", "def onfinish( request ):", "def onfinish( request ):", "def done(self):\n ## All done with the request object\n self.closed = True\n self.d.callback('')", "def send_final_request(self):\n with op...
[ "0.72541773", "0.71216404", "0.6963055", "0.6963055", "0.69151807", "0.6638319", "0.651408", "0.64735484", "0.64627695", "0.6455456", "0.6441771", "0.6427784", "0.64124346", "0.64103615", "0.6390289", "0.6389782", "0.63700086", "0.63700086", "0.6349477", "0.63451564", "0.6336...
0.6521918
6
Use request.webapp.urlfor() to generate the url.
def urlfor( name, **matchdict ) :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Url(self) -> str:", "def _make_url(self):\n ...", "def url(self, request_path=\"\"):\n return f\"{self.scheme}://{self.host}/{request_path}\"", "def url():\n ...", "def url(self):\n ...", "def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])", "...
[ "0.7394846", "0.7333615", "0.73251283", "0.7199692", "0.71141917", "0.7086298", "0.7086298", "0.7045094", "0.6963181", "0.6919876", "0.6882282", "0.6875919", "0.687345", "0.68391496", "0.67906547", "0.67739296", "0.67739296", "0.677302", "0.6763877", "0.67542046", "0.67514396...
0.0
-1
Use request.webapp.pathfor() to generate the url.
def pathfor( name, **matchdict ) :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_for(self, path):\n if self.in_canvas:\n return self.get_app_url(path[1:])\n else:\n return '%s%s' % (settings.SITE_URL, path)", "def pathfor( request, *args, **kwargs ):", "def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])", "def bu...
[ "0.7584648", "0.7503941", "0.7469561", "0.7469561", "0.73424727", "0.73424727", "0.7232096", "0.7122197", "0.70774573", "0.7048095", "0.70177126", "0.7001433", "0.6987334", "0.6956988", "0.6916245", "0.68278766", "0.67932373", "0.6748939", "0.6688148", "0.6613891", "0.6579176...
0.0
-1
Generate url for a different webapplication identified by ``instkey``. Typically uses webapp.appurl(). ``instkey``, A tuple of ``(appsec, netpath, configini)`` indexes into platform's `webapps` attribute
def appurl( instkey, name, **matchdict ) :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])", "def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])", "def api_url(self, url_key):\n dic = self.api_endpoints()\n return dic.get(url_key)", "def url(self):\n if not self._...
[ "0.58576363", "0.58576363", "0.5623256", "0.56221247", "0.55988806", "0.5585243", "0.5538256", "0.5424072", "0.53234696", "0.53213304", "0.5307345", "0.5305116", "0.52884024", "0.52879715", "0.5249623", "0.5244203", "0.5239846", "0.5239406", "0.52258646", "0.5224644", "0.5202...
0.72840726
0
Instantiate a response plugin for a corresponding ``request`` plugin. ``request``,
def __init__( request ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, request: Request, response: Response):\n self.request = request\n self.response = response", "def __init__(self, request, legacy_plugin):\n self._request = request\n self._format = legacy_plugin\n\n source = (\n \"<bytes>\"\n if isinstan...
[ "0.62610316", "0.5856815", "0.57992893", "0.5761121", "0.5701808", "0.5666514", "0.56111526", "0.5601704", "0.5554978", "0.5491152", "0.5488582", "0.54775864", "0.54698384", "0.54117626", "0.53446656", "0.5330777", "0.5324699", "0.5299904", "0.5282381", "0.527949", "0.5272502...
0.5541629
9
Set a response status code. By default it will be 200.
def set_status( code ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setResponseCode(code, message=None):", "def setResponseCode(self, code, message=None):\n assert not self.written, \"Response code cannot be set after data has been written: %s.\" % \"@@@@\".join(self.written)\n self.responseCode = code\n self.responseMessage = message", "def status_cod...
[ "0.80714124", "0.7299864", "0.7288931", "0.7265546", "0.7265546", "0.72009724", "0.7186744", "0.7174475", "0.7165363", "0.7111467", "0.70771134", "0.70771134", "0.7026749", "0.69407403", "0.6925514", "0.6722728", "0.6721266", "0.6686304", "0.668352", "0.6621333", "0.6604315",...
0.78074044
1
Sets the given response header ``name`` and ``value``. If there is already a response header by `name` present, it will be overwritten. Returns the new value for header name as bytestring. ``name``, bytestring of header field name, in lower case. ``value``, any type, which can be converted to string.
def set_header( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_header(self, name, value):\n key = name.upper()\n if key not in _RESPONSE_HEADER_DICT:\n key = name\n self._headers[key] = _to_str(value)", "def SetResponseHeader(self, name, value):\n assert name.islower()\n new_headers = []\n new_header_set = False\n for head...
[ "0.83574027", "0.7889172", "0.78625196", "0.778234", "0.73784775", "0.70307523", "0.6647856", "0.6492542", "0.6332594", "0.626928", "0.6144178", "0.60879344", "0.6050496", "0.59921557", "0.59893656", "0.58568585", "0.58544004", "0.583133", "0.5787934", "0.57267344", "0.570350...
0.7097082
5
Similar to set_header() except that, if there is already a response header by ``name`` present, ``value`` will be appended to existing value using ',' seperator. Returns the new value for header name as bytestring. ``name``, bytestring of header field name, in lower case. ``value``, Any type which can be converted to s...
def add_header( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_header(self, name, value):\n name = name.lower()\n if name in self._headers:\n value = self._headers[name] + ',' + value\n\n self._headers[name] = value", "def set_header(self, name, value):\n key = name.upper()\n if key not in _RESPONSE_HEADER_DICT:\n ...
[ "0.7748382", "0.73166865", "0.7067415", "0.7052879", "0.6868", "0.6779429", "0.6656014", "0.65562063", "0.6298724", "0.62592614", "0.6212194", "0.606606", "0.59807533", "0.59497535", "0.58782494", "0.57572806", "0.5731", "0.56437075", "0.56160206", "0.55419695", "0.55385184",...
0.6342504
8
Sets the given chunk trailing header, ``name`` and ``value``. If there is already a trailing header by ``name`` present, it will be overwritten. Returns the new value for header name as bytestring. ``name``, bytestring of header field name, in lower case. ``value``, any type, which can be converted to string.
def set_trailer( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_header(self, name: str, value: str) -> None:\n self.__headers[name.title()] = value # value.lower()", "def set_header(self, name, value):\n\n # NOTE(kgriffs): normalize name by lowercasing it\n self._headers[name.lower()] = value", "def set_header( self, name, value, **params ):\n...
[ "0.65418494", "0.6522374", "0.64762324", "0.6441", "0.6401729", "0.6241801", "0.6101218", "0.60385674", "0.57232356", "0.56232774", "0.5599765", "0.55176854", "0.5413307", "0.536029", "0.5203817", "0.5202332", "0.51658064", "0.5163279", "0.5163279", "0.51523733", "0.5068459",...
0.5543814
11
Similar to set_trailer() except that, if there is already a trailing header by ``name`` present, ``value`` will be appended to existing value using ',' seperator. Returns the new value for header name as bytestring. ``name``, bytestring of header field name, in lower case. ``value``, any type, which can be converted to...
def add_trailer( name, value ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_header(self, name, value):\n name = name.lower()\n if name in self._headers:\n value = self._headers[name] + ',' + value\n\n self._headers[name] = value", "def set_header( self, name, value, **params ):\n self.remove_header( name )\n self[ name ] = params ...
[ "0.6929069", "0.59107393", "0.5822869", "0.5768683", "0.57525563", "0.5595093", "0.5461574", "0.54522544", "0.5451935", "0.5260403", "0.525307", "0.5168981", "0.5065813", "0.5061805", "0.5030817", "0.502269", "0.49991527", "0.49479535", "0.49398062", "0.4846587", "0.48425302"...
0.58077794
3
Set cookie `name`/`value` with optional ``kwargs``. Keyword arguments typically contains, ``domain``, ``expires_days``, ``expires``, ``path``. Additional keyword arguments are set on the Cookie.Morsel directly. By calling this method cookies attribute will be updated inplace. See
def set_cookie( name, value, **kwargs ) :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_cookie( cookies, name, morsel, **kwargs ) :", "def set_cookie(\n self,\n name: str,\n value: str,\n *,\n expires: Optional[str] = None,\n domain: Optional[str] = None,\n max_age: Optional[Union[int, str]] = None,\n path: str = \"/\",\n secure...
[ "0.8420435", "0.79221094", "0.7444182", "0.74370587", "0.7345756", "0.7201238", "0.71946406", "0.7171358", "0.71276164", "0.66001695", "0.6599659", "0.6423538", "0.631609", "0.6207204", "0.61627495", "0.6073698", "0.5977196", "0.5935828", "0.5813138", "0.58102167", "0.5718615...
0.8409126
1
Similar to set_cookie() method, additionally signs and timestamps a cookie value so it cannot be forged. Uses
def set_secure_cookie( name, value, **kwargs ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_cookie( name, value, **kwargs ) :", "def set(self, name, value, timestamp=None, expires_days=30, **kwargs):\n \n timestamp = timestamp and timestamp or str(int(time.time()))\n value = base64.b64encode(value)\n args = (name, value, timestamp)\n signature = _generate_cook...
[ "0.74688053", "0.7455388", "0.72751254", "0.72063357", "0.70475024", "0.6851211", "0.6815025", "0.68128604", "0.66326326", "0.6592273", "0.6509545", "0.6509545", "0.64895", "0.6470476", "0.64571637", "0.6434016", "0.64097345", "0.6322631", "0.63069767", "0.6275352", "0.625296...
0.7734208
0
Deletes all the cookies the user sent with this request.
def clear_all_cookies():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_cookies(self):\n self.base_driver.delete_all_cookies()", "def logout():\n _cookies = ['user', 'pass', 'hash']\n for cookie in _cookies:\n util.web.delete_cookie(cookie)", "def clear_cookies(response):\n for cookie_name in list(flask.request.cookies.keys()):\n ...
[ "0.8314878", "0.79060113", "0.7764054", "0.75879586", "0.74467", "0.73246366", "0.72249746", "0.7155583", "0.7140678", "0.7131695", "0.7051185", "0.69263476", "0.6845432", "0.6812562", "0.6739007", "0.670739", "0.66826046", "0.66742474", "0.6650126", "0.6621511", "0.6612393",...
0.81525165
1
Subscribe a ``callback`` function, to be called when this response is finished.
def set_finish_callback( callback ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_response(self, callback):\n\n self.log.info(\"Received callback for subscription %s\", self.service_id)\n self.log.info(callback)\n\n # handle callbacks\n self.handle_callbacks()", "def subscribe(self, callback: Callable) -> None:\n self.callbacks.add(callback)", "...
[ "0.7337261", "0.72173417", "0.6887395", "0.6764623", "0.6744843", "0.6545311", "0.65448177", "0.65093887", "0.65067255", "0.64918005", "0.6415015", "0.6398242", "0.6356268", "0.6323706", "0.62204206", "0.6189996", "0.61888844", "0.6179687", "0.61578566", "0.61118984", "0.6095...
0.7379709
0
For chunkedencoding, returns a boolean, if True means the response has started and response headers are written.
def isstarted():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ischunked() :", "def ischunked() :", "def respond(self):\r\n response = self.wsgi_app(self.environ, self.start_response)\r\n try:\r\n for chunk in response:\r\n # \"The start_response callable must not actually transmit\r\n # the response headers. Inst...
[ "0.69279814", "0.69279814", "0.6627819", "0.62915945", "0.5882213", "0.5791212", "0.5773702", "0.5644884", "0.5639833", "0.55898815", "0.5584943", "0.55602825", "0.5550169", "0.5530503", "0.5523043", "0.5508481", "0.548411", "0.5482309", "0.54782695", "0.54697645", "0.5438700...
0.0
-1
Returns True if this response is transferred using `chunked` TransferEncoding.
def ischunked() :
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_chunked(self):\r\n cl = 0\r\n data = StringIO.StringIO()\r\n while True:\r\n line = self.rfile.readline().strip().split(\";\", 1)\r\n chunk_size = int(line.pop(0), 16)\r\n if chunk_size <= 0:\r\n break\r\n cl += chunk_size\r...
[ "0.57229114", "0.5549699", "0.5535076", "0.5498817", "0.5495948", "0.54413956", "0.5428297", "0.5392888", "0.53799695", "0.53299", "0.53035134", "0.5299927", "0.5269785", "0.525448", "0.52073103", "0.5202222", "0.5174824", "0.5155284", "0.5124991", "0.5083998", "0.50101703", ...
0.72753114
0
Writes the given chunk to the output buffer. To actually write the output to the network, use the flush() method below. ``data``, bytestring of data to buffer for writing to socket.
def write( data ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, data):\n\t\tself.outputbuffer.write(data)", "def writeChunk(chunk):", "def write(self, chunk):\r\n if not self.started_response:\r\n raise AssertionError(\"WSGI write called before start_response.\")\r\n \r\n if not self.sent_headers:\r\n self.sent_hea...
[ "0.6934015", "0.6678234", "0.6595058", "0.6541228", "0.64646363", "0.6454819", "0.63661104", "0.63642645", "0.63609827", "0.63536644", "0.63479036", "0.6335002", "0.62879336", "0.6281979", "0.6279511", "0.6213749", "0.6124661", "0.61069936", "0.6097744", "0.6094423", "0.60685...
0.55196303
59
Flushes the responseheader (if not written already) to the socket connection. Then flushes the writebuffer to the socket connection. ``finishing``, If True, signifies that data written since the last flush() on this response instance is the last chunk. It will also flush the trailers at the end of the chunked response....
def flush( finishing=False, callback=None ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, chunk, callback=None, read_until_delimiter=CRLF):\n if not self.stream.closed():\n if callback is None:\n callback = functools.partial(self.stream.read_until,\n utf8(read_until_delimiter),\n ...
[ "0.5697157", "0.5237605", "0.52154744", "0.51464176", "0.5056116", "0.5045713", "0.50180554", "0.5014987", "0.49502966", "0.49502966", "0.4899851", "0.4892243", "0.48771352", "0.4832465", "0.48308593", "0.47830316", "0.46727931", "0.4668935", "0.46423793", "0.4630665", "0.462...
0.6894146
0
Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. It is the caller's responsibility to finish...
def httperror( status_code=500, message=b'' ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_error(self, code, message=None):\r\n\r\n headers = []\r\n headers.extend(self.server.global_headers)\r\n configuration = self.server.configuration\r\n docpath = self.server.docpath\r\n\r\n if not hasattr(self, 'headers'):\r\n self.headers = self.MessageClass(s...
[ "0.68092066", "0.67834115", "0.676444", "0.6731622", "0.6619136", "0.6616003", "0.6560771", "0.6518003", "0.6505182", "0.6353635", "0.6325605", "0.6325605", "0.62494993", "0.6215743", "0.61458296", "0.61113197", "0.608032", "0.6079682", "0.60642403", "0.6045984", "0.5998613",...
0.5434301
48
Use the view configuration parameter 'IHTTPRenderer' to invoke the view plugin and apply IHTTPRenderer.render() method with ``request``, ``c``, ``args`` and ``kwargs``.
def render( *args, **kwargs ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(request, *args, **kw):", "def render_view(self, h, *args):\n return self.view(h)", "def render(self, *html, **opt):\n context = self.context\n # add request, response to context implicitly.\n context['request'] = self.request\n context['response'] = self.response\n ...
[ "0.6854912", "0.68063754", "0.6663782", "0.64228576", "0.6422032", "0.63216287", "0.6234819", "0.6158419", "0.6141992", "0.6087013", "0.60797894", "0.60797894", "0.60797894", "0.60797894", "0.60797894", "0.60605824", "0.6056176", "0.6002161", "0.58739036", "0.5868972", "0.586...
0.6417768
5
Return a generator, which, for every iteration will call the ``callback`` function with ``request`` and ``c`` arguments, which are preserved till the iteration is over. The call back should return a a tuple representing a chunk, ``(chunk_size, chunk_ext, chunk_data)`` this will formatted into a response chunk and sent ...
def chunk_generator( callback, request, c ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _request_generator(request, data_handler):\n # First, the request header.\n yield data_handler.request_to_bytes(request)\n\n # Then, for the body. The body can be bytes or an iterator, but that's it.\n # The iterator is the more general case, so let's transform the bytes into\n # an iterator via...
[ "0.62096155", "0.61808133", "0.6032896", "0.5845108", "0.575135", "0.57170826", "0.5671511", "0.5627092", "0.56268936", "0.545666", "0.54119474", "0.54040426", "0.5395256", "0.53291893", "0.53276765", "0.5250885", "0.5200447", "0.5184646", "0.51722205", "0.51582944", "0.51517...
0.8492581
0
Instantiate plugin with `viewname` and `view` attributes.
def __init__( viewname, view ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_plugin(self, **kwargs):\n return self.plugin_class(**kwargs)", "def initialize(self, view, request, *args, **kwargs):\n view.request = request\n view.args = args\n view.kwargs = kwargs\n return view", "def setup_view(view, request=None, *args, **kwargs):\n view....
[ "0.6548358", "0.6006528", "0.5945799", "0.5894253", "0.58324546", "0.5823484", "0.5800297", "0.57579005", "0.57316625", "0.56788945", "0.5655144", "0.5637644", "0.56267685", "0.5609166", "0.56016356", "0.55474275", "0.5512851", "0.549349", "0.5422086", "0.5387782", "0.535329"...
0.6774538
0
In the absence of method specific attributes or if the resolver cannot find an instance attribute to apply the handler call back, the object will simply be called. ``request``,
def __call__( request, c ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self, *args, **kwargs):\n\t\treturn self.handler()(self.request(kwargs))", "def dispatch_request(self, *args, **kwargs):\n self.args = args\n self.kwargs = kwargs\n self.meth = request.method.lower()\n self.resource = current_app.blueprints.get(request.blueprint, None)\n\...
[ "0.7087493", "0.68776214", "0.67371464", "0.66994345", "0.66787934", "0.6633027", "0.66189176", "0.66167516", "0.6572445", "0.650089", "0.6358427", "0.63378036", "0.6337083", "0.61910105", "0.6168588", "0.6121533", "0.6113042", "0.60976046", "0.60976046", "0.60976046", "0.609...
0.56281394
64
Optional callable attribute, if present will be called at the end of a request, after the response has been sent to the client. Note that this is not the same as close callback, which is called when the connection get closed. In this case the connection may or may not remain open. Refer to HTTP/1.1 spec. ``request``,
def onfinish( request ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_request_handle(self, func):\n self.after_request.append(func)\n return func", "def after_request(self, f):\n self.after_request_funcs.append(f)\n return f", "def after_request(self, f):\n self.after_request_handlers.append(f)\n return f", "def after_request...
[ "0.6787434", "0.66382897", "0.65115815", "0.65115815", "0.649444", "0.6303967", "0.6162508", "0.60495746", "0.59780455", "0.59377056", "0.5925452", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692", "0.5879692"...
0.5815968
23
Transform incoming message entity. request will be updated in place. Returns the transformed request data. ``request``,
def transform( request, data, finishing=False ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_RequestEntity_to_Request(request_entity):\n result = ResponseEntity()\n try:\n user = User.objects.get(username=request_entity.username)\n account = Account.objects.get(user=user)\n request = Request.objects.get(id=request_entity.request_id)\n request = copy_field_Requ...
[ "0.68833864", "0.6783613", "0.61958045", "0.59059", "0.58546364", "0.5654744", "0.5643135", "0.56137216", "0.55739105", "0.55085295", "0.5467546", "0.54665387", "0.54277307", "0.5413112", "0.5336769", "0.53211945", "0.5305077", "0.53003657", "0.52656054", "0.5237695", "0.5232...
0.6248069
2
Transform outgoing message entity. ``request.response`` will be updated inplace. ``request``,
def transform( request, data, finishing=False ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_response(self, request, response):\n return response", "def process_response(self, request, response):\n return response", "def apply_response(self, request):\n assert request.response is not None\n response = request.response\n\n other_addr = self.get_other_addre...
[ "0.6281616", "0.6281616", "0.60982984", "0.59114945", "0.5736397", "0.57255626", "0.57255626", "0.56755185", "0.56169486", "0.56157714", "0.56044424", "0.55499613", "0.5543159", "0.5468557", "0.5437959", "0.54259264", "0.54259264", "0.5392236", "0.53907865", "0.53888", "0.538...
0.6202194
2
Handle exception in the context of a HTTP request ``request``. (etype, value, tb) tuple is what is returned by sys.exc_info(). Return a web page, capable of live debuging.
def render( request, etype, value, tb ):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(self, request):\n if self.debug:\n import cgitb\n request.stdout.write('Content-Type: text/html\\r\\n\\r\\n' +\n cgitb.html(sys.exc_info()))\n else:\n errorpage = \"\"\"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<ht...
[ "0.729787", "0.67636645", "0.6706574", "0.66115505", "0.63101536", "0.63044995", "0.6287227", "0.62505925", "0.62089163", "0.6201368", "0.6133693", "0.6084619", "0.6072575", "0.60724205", "0.6067019", "0.5994295", "0.59837675", "0.5959512", "0.5947055", "0.589282", "0.5879489...
0.0
-1
Endpoint for API requests given book isbn
def api(isbn): # Ensure valid isbn-10 format provided if len(isbn) != 10: response = make_response( jsonify("Please provide a valid ISBN-10"), 404) response.headers['X-Error'] = "Please provide a valid ISBN-10" return response # Ensure requested book is in our database ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_book(isbn):\n isbn = Markup.escape(isbn)\n # check if book exist in database\n book_db = db.execute(\n \"SELECT * FROM books WHERE isbn LIKE :isbn\", {\"isbn\": isbn}\n ).fetchone()\n if book_db == None:\n return jsonify({\"error\": \"Invalid isbn or not in our database\"}), 40...
[ "0.7609882", "0.74613976", "0.74272406", "0.7041582", "0.68572766", "0.67950946", "0.67200625", "0.6669115", "0.6622111", "0.6500195", "0.6484592", "0.64041054", "0.6352689", "0.63392377", "0.62087476", "0.61840034", "0.61652505", "0.6151179", "0.61272323", "0.6125678", "0.61...
0.77853644
0
Checks if requested username is available, returns JSON for clientside validation
def check(): username = request.args.get("user_name") users = db.execute("SELECT * FROM users WHERE username = :username", {"username": username}).fetchone() if users is None: return jsonify(True) # Username is taken return jsonify(False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_auth_validate_username():\n form = request.get_json(force=True)\n if \"username\" not in form:\n raise \"username is required\"\n return jsonify(\n userProvider.validate_username(\n form['username'].encode('utf8')\n )\n )", "def checkusername():\n username =...
[ "0.80300266", "0.80275035", "0.8008234", "0.79536533", "0.7858642", "0.78391534", "0.77913445", "0.7707726", "0.76461107", "0.75947815", "0.75256544", "0.7508425", "0.7508425", "0.7473909", "0.7461905", "0.74154615", "0.7298308", "0.72000253", "0.71622324", "0.7120716", "0.70...
0.7834931
6
Log user out, redirect to login
def logout(): session.clear() return redirect("/")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout():\n logout_user()\n return redirect(url_for(\".login\"))", "def log_out():\n if 'name' in session:\n PLAN.logout_user(session['name'])\n session.pop('name', None)\n return redirect(url_for('log_in'))\n return redirect(url_for('log_in'))", "def log_out(request):\n ...
[ "0.8145058", "0.81327146", "0.81260467", "0.8065017", "0.8052337", "0.804527", "0.80425847", "0.80409956", "0.7994507", "0.7976262", "0.7973859", "0.7955485", "0.7954831", "0.7937982", "0.7923433", "0.7919691", "0.7912803", "0.7912725", "0.79120165", "0.7906303", "0.7893122",...
0.7610357
72
Validate and insert a book review
def review(book_id): # User id from current session user_id = session["user_id"] # Form data try: rating = request.form.get('rating') text = request.form.get('review-text') except ValueError: return error('Something went wrong with submission.', 400) # Has user already ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def review():\r\n\r\n # Ensure isbn_number is submitted\r\n if not request.form.get(\"isbn_number\"):\r\n return apology(\"Invalid book\", 403)\r\n\r\n # Ensure review is submitted\r\n if not request.form.get(\"review\"):\r\n return apology(\"Text is not submitted\", 403)\r\n\r\n # Che...
[ "0.755315", "0.6922114", "0.6647781", "0.65656424", "0.6516517", "0.64299977", "0.627836", "0.62092316", "0.61660314", "0.6143327", "0.6090935", "0.6080055", "0.6045912", "0.601442", "0.60058033", "0.59929514", "0.598046", "0.5961186", "0.5902224", "0.5900835", "0.58474195", ...
0.6872112
2
Renders books containing search query
def search(): try: query = request.args.get("q").lower() except AttributeError: query = request.args.get("q") # Adding browse functionality browse = request.args.get("browse") if browse is None: # Select all rows with a column value that includes query results = db....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_book():\n\n title = request.form.get(\"search\")\n books = book_search_results(GR_KEY, title)\n acct = get_current_account(session['acct'])\n search = True\n\n return render_template(\"index.html\", books=books, acct=acct, search=search)", "def genSearch(request):\n \n assert isinst...
[ "0.81691885", "0.7731352", "0.76253176", "0.7623431", "0.7377619", "0.7270599", "0.724567", "0.7031751", "0.7023816", "0.6892736", "0.68789625", "0.68769056", "0.6811817", "0.6783009", "0.673157", "0.67232525", "0.66750485", "0.6574503", "0.6572845", "0.65678513", "0.6564493"...
0.76361454
2
Query for the dates and temperature observations from the past 12 month from 20170823. Convert the query results to a Dictionary using date as the key and tobs as the value. Return the JSON representation of your dictionary
def Tobs_given_day(date): results = session.query(Measurement.date,Measurement.tobs).\ filter(Measurement.date.between(One_yrs_ago,current_time)).\ filter(func.strftime("%Y-%m-%d",Measurement.date)==date).all() results1=[results[i][1] for i in range(len(results))] results={results[0][0]:results1} ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def temperature():\n #Query for the dates and temperature observations from a year from the last data point.\n\n last_temp= session.query(Measurement.date).order_by(Measurement.date.desc()).first()\n year_ago = last_temp - dt.timedelta(days=365)\n dates_and_temps = session.query(Measurement.date, Measu...
[ "0.7571382", "0.7529138", "0.7247193", "0.7234718", "0.7224095", "0.72214264", "0.71914005", "0.71568054", "0.7109943", "0.706894", "0.70655936", "0.70236737", "0.69873875", "0.69621557", "0.688697", "0.6843332", "0.6807451", "0.6785279", "0.67522395", "0.67516905", "0.671827...
0.67368066
20
Return a JSON list of stations from the dataset
def stations(): results = session.query(Station.station,Station.name).all() key=[results[i][0] for i in range(len(results))] values=[results[i][1] for i in range(len(results))] results=dict(zip(key,values)) print(f"Route /api/v1.0/stations is being visited") return jsonify(results)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stationdata():\n # * Return a JSON list of stations from the dataset.\n # as this should be a list, I'm just grabbing the station name\n session = Session(engine)\n results = session.query(Station.name).all()\n session.close()\n\n stations = list(np.ravel(results))\n return jsonify(stati...
[ "0.88667464", "0.8750095", "0.87346923", "0.84793985", "0.84580904", "0.84156215", "0.83818555", "0.83749765", "0.8370349", "0.8341339", "0.8339504", "0.8324717", "0.83166987", "0.83012885", "0.82950824", "0.82848144", "0.82428265", "0.8235163", "0.82350534", "0.82163185", "0...
0.7395977
33
Return a JSON list of Temperature Observations (tobs) for the previous year
def Tobs_past_year(): results = pd.DataFrame(session.query(Measurement.date,Measurement.tobs).\ filter(Measurement.date.between(One_yrs_ago,current_time)).all()); dates_of_last_year=list(results.sort_values(by='date')['date'].unique()) aa1=results.sort_values(by='date').groupby('date') last_year_tob...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prior_year_temp():\n\n tobs_data = session.query(Measurements.tobs).all()\n return jsonify (tobs_data)", "def tobsdata():\n # query for the dates and temperature observations from a year from the last data point.\n # * Return a JSON list of Temperature Observations (tobs) for the previous year....
[ "0.81387526", "0.7823207", "0.7728094", "0.76940525", "0.76278925", "0.7408873", "0.73844993", "0.7356113", "0.73492384", "0.7237004", "0.7091124", "0.70736796", "0.7045663", "0.7042862", "0.6980327", "0.6823793", "0.6811926", "0.6764229", "0.66996694", "0.6654598", "0.656765...
0.66404945
20
This Sigmoid function is used as a threshold function and mapping variables to between 0 and 1.
def sigmoid(inX): if inX < 0: return 1 - 1 / (1 + exp(inX)) else: return 1 / (1 + exp(-inX))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hard_sigmoid(x):\n x = (0.2 * x) + 0.5\n x = F.threshold(-x, -1, -1)\n x = F.threshold(-x, 0, 0)\n return x", "def sigmoid(x):\r\n return 1 / (1 + np.exp(-x))", "def sigmoid(x):\r\n\r\n return 1 / (1 + np.exp(-x))", "def sigmoid(x):\r\n #pred_x = (np.exp(x) - np.exp(-x)) / (np.exp(x)...
[ "0.8308929", "0.82602733", "0.8204889", "0.81876445", "0.81802076", "0.81802076", "0.81802076", "0.81802076", "0.81802076", "0.81802076", "0.8174843", "0.8173835", "0.81575894", "0.8142804", "0.8142804", "0.8138578", "0.81346345", "0.8126009", "0.8078116", "0.8075239", "0.806...
0.7807045
44
This funtion is used to read the training data without any sampling. I tried the performance of this method and because of the negative result I do not use it in the final model.
def loadtrainData(): train_x = [] train_y = [] fileIn = open(PATH + 'traindata_Subtask4.txt') for line in fileIn.readlines(): lineArr = line.strip().split() train_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)]) train_y.append(int(lineArr[-1])) return np.mat(tra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadtrainData_undersampling():\n train = []\n fileIn = open(PATH + 'traindata_Subtask4.txt')\n for line in fileIn.readlines():\n lineArr = line.strip().split()\n train.append([float(lineArr[i]) for i in range(len(lineArr))])\n\n pos = []\n neg = []\n for i in train:\n if ...
[ "0.70705503", "0.685475", "0.6755205", "0.67205465", "0.6707401", "0.66407955", "0.6628733", "0.6578922", "0.65660447", "0.65466577", "0.6519749", "0.65176576", "0.65046763", "0.6502512", "0.6450128", "0.6430068", "0.6429853", "0.64113545", "0.63941485", "0.6373122", "0.63673...
0.6234176
36
This funtion is used to read the training data with over sampling. I tried the performance of this method and because of the negative result I do not use it in the final model.
def loadtrainData_oversampling(): pre_x = [] pre_y = [] fileIn = open(PATH + 'traindata_Subtask4.txt') for line in fileIn.readlines(): lineArr = line.strip().split() pre_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)]) pre_y.append(int(lineArr[-1])) ros = Random...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadtrainData_undersampling():\n train = []\n fileIn = open(PATH + 'traindata_Subtask4.txt')\n for line in fileIn.readlines():\n lineArr = line.strip().split()\n train.append([float(lineArr[i]) for i in range(len(lineArr))])\n\n pos = []\n neg = []\n for i in train:\n if ...
[ "0.74855584", "0.6844487", "0.67235553", "0.6635843", "0.65714896", "0.655013", "0.65257406", "0.65041095", "0.64458853", "0.6431045", "0.6288388", "0.6259542", "0.6254891", "0.6248755", "0.62383735", "0.62307274", "0.62214607", "0.6210643", "0.6210329", "0.62057644", "0.6185...
0.7424427
1
This funtion is used to read the training data with under sampling. In my training set, it including 153 positive samples and 3201 negative samples. By using this function, we can get all the positive samples and the same number of negative samples.
def loadtrainData_undersampling(): train = [] fileIn = open(PATH + 'traindata_Subtask4.txt') for line in fileIn.readlines(): lineArr = line.strip().split() train.append([float(lineArr[i]) for i in range(len(lineArr))]) pos = [] neg = [] for i in train: if i[-1] == 1.0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadtrainData_oversampling():\n pre_x = []\n pre_y = []\n fileIn = open(PATH + 'traindata_Subtask4.txt')\n for line in fileIn.readlines():\n lineArr = line.strip().split()\n pre_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)])\n pre_y.append(int(lineArr[-1]))\n ...
[ "0.7016822", "0.6664856", "0.645917", "0.64384604", "0.64043915", "0.63820744", "0.6264231", "0.625226", "0.62346333", "0.620052", "0.6194809", "0.6153491", "0.61352617", "0.61151683", "0.6104559", "0.6074965", "0.6066834", "0.6033847", "0.60328984", "0.6000171", "0.5999229",...
0.7961876
0
This funtion is used to read the top 10 claims in the dev set.
def loaddevData(): dev_x = [] dev_y = [] fileIn = open(PATH + 'devdata_Subtask4.txt') for line in fileIn.readlines(): lineArr = line.strip().split() dev_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)]) dev_y.append(int(lineArr[-1])) return np.mat(dev_x), np.mat(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_50():\r\n file_read = read_file()\r\n vacabulary_list = []\r\n for key in file_read:\r\n vacabulary_list.extend(file_read[key])\r\n top_50 = Counter(vacabulary_list).most_common(50)\r\n return (top_50)", "def get_all_from_top_ten(title,users,max = 3):\n \"\"\" ten prolific users ...
[ "0.6306631", "0.62041336", "0.5929728", "0.5903256", "0.58970076", "0.58926326", "0.58617526", "0.58617526", "0.5834872", "0.5782117", "0.57493013", "0.5723951", "0.5718185", "0.5674988", "0.5643855", "0.5617703", "0.5616858", "0.56101847", "0.560401", "0.55254406", "0.551209...
0.0
-1
This function is the logistic regresion model with stochastic gradient descent. The input is the train_x, the label 'train_y' and the smooth method. I tried two different method in the model. The output is the weights that using for prediction. I also print the train loss and training time to analyse the effect of lear...
def trainLogRegres(train_x, train_y, opts): startTime = time.time() # calculate training time numSamples, numFeatures = np.shape(train_x) alpha = opts['alpha'] maxIter = opts['maxIter'] weights = np.ones((numFeatures, 1)) for k in range(maxIter): if opts['optimizeType'] == 'stocGradDe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gradient_descent(self, x, y):\n # Initialize weights vector\n self.weights = np.zeros(len(x[0]))\n\n # Storing number of training example in a variable \n n = len(x)\n\n # Initiate variables to keep track of the current and smallest loss recorded\n lowest_loss = sys.fl...
[ "0.70313853", "0.69511914", "0.6924913", "0.6899533", "0.6819347", "0.6808069", "0.6797615", "0.6790879", "0.67861557", "0.6707913", "0.66786504", "0.6632093", "0.65839654", "0.65689814", "0.65687764", "0.6554728", "0.65536284", "0.6550399", "0.6531903", "0.6528379", "0.65280...
0.7041955
0
This function is used to predict the data by the logistice model. The input is the weights of logistics model, the dev_x and the label 'dev_y'. The output is the prediction result.
def testLogRegres(weights, dev_x, dev_y): predict_y = [] numSamples, numFeatures = np.shape(dev_x) for i in range(numSamples): if sigmoid(dev_x[i, :] * weights) > 0.5: label = 1 else: label = 0 predict_y.append(label) print('Congratulations, testing comple...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logistic_predict(weights, data):\n\n # TODO: Finish this function\n\n return y", "def logistic_predict(self, x: np.array) -> np.array:\r\n if self.LogisticModel is None:\r\n print('Logistic Model not trained, please run logistic_fit first!')\r\n return None\r\n else:...
[ "0.69716686", "0.67710924", "0.6762844", "0.6762844", "0.6759554", "0.6738379", "0.67310774", "0.67310774", "0.67310774", "0.6683879", "0.66406286", "0.658558", "0.6546615", "0.6540146", "0.6515744", "0.6444978", "0.6444978", "0.6444978", "0.64326894", "0.64309853", "0.640947...
0.72072643
0
This function is the same as the function for data preprocessing for querylikelihood unigram language model in Subtask3.
def Subtask4_pre_train_1(path): n_dict = {} files = os.listdir(path) for i in files: with open(os.path.join(path, i)) as fp: lines = fp.readlines() for line in lines: text = eval(line)['text'] # extract data from the field of 'text'. words = t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _preprocess(self):\n self.data['sentences'] = self.data['text'].apply(self._tokenize_sent)\n self.data['nouns'] = self.data['sentences'].apply(self._get_nouns)\n # self._get_frequent_features()\n # self._compactness_pruning()\n # self._redundancy_pruning()\n # self._ge...
[ "0.6739814", "0.67387193", "0.65274066", "0.64582485", "0.63389665", "0.62616926", "0.6239441", "0.6239441", "0.6239441", "0.6239334", "0.61333746", "0.60674673", "0.6042711", "0.6042057", "0.6011925", "0.5964625", "0.5963509", "0.59263766", "0.5914043", "0.5899222", "0.58957...
0.0
-1
This function is the same as the function for Laplace Smoothing querylikelihood unigram language model in Subtask3.
def Subtask4_pre_train_2_Laplace(number): alpha = 0.5 train_data = load_dataset_json(PATH + 'data/train.jsonl', instance_num=number) data = np.load(PATH + 'pre_train_1_Subtask4.npy', allow_pickle=True).item() id_list = [] for d in train_data: if d['label'] != 'NOT ENOUGH INFO': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def f(DATA_LINK, DATA_COLUMN_NAME, STOPWORD_CHOICE, STOPWORD_LINK, NGRAM_CHOICE,NGRAM_NUM, TestData,topic_number_user,fetchArray):\r\n data = pd.read_csv(DATA_LINK)\r\n df=data[DATA_COLUMN_NAME]\r\n ######################################################################\r\n if (STOPWORD_CHOICE):\r\n ...
[ "0.6209135", "0.59615684", "0.58722174", "0.5867605", "0.58490914", "0.58312607", "0.5767536", "0.5758057", "0.5740753", "0.5735517", "0.5712564", "0.56631804", "0.56478757", "0.56061924", "0.560608", "0.5568739", "0.55452985", "0.553871", "0.5532431", "0.5531182", "0.5530616...
0.0
-1
The output is a dictionary which the key is the document 'id' that appear in any of the claim's five similar documents and the value is 'lines' in wikipages.
def Subtask4_pre_train_3(): train_data = np.load(PATH + 'pre_train_2_Subtask4.npy', allow_pickle=True).item() evidence = [] for d in train_data.items(): for i in range(5): evidence.append(d[1][i]) files = os.listdir(PATH + 'data/wiki-pages/wiki-pages/') documents = {} for i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def documents(pmid_23982599, civic_aid6_document):\n return [pmid_23982599, civic_aid6_document]", "def get_docs(claim: str, threshold: int = 50):\n with open(WIKI_IDS_PATH, \"rb\") as file:\n ids = pickle.load(file)\n docs = []\n compare_claim = _clean_text(claim)\n for doc_id in ids:\n ...
[ "0.63654256", "0.60081065", "0.5942371", "0.5939073", "0.58724165", "0.5778564", "0.5777038", "0.56986195", "0.5695576", "0.56731904", "0.5648699", "0.56337243", "0.5618151", "0.5604732", "0.55877995", "0.5582474", "0.55180943", "0.54923135", "0.54890287", "0.5477085", "0.546...
0.0
-1
The output is a list which the structure is [claim, evidence document, sentence_number].
def Subtask4_pre_train_4(): evidence_data = load_dataset_json(PATH + 'data/train.jsonl', instance_num=200) evi = [] for i in evidence_data: for j in i['evidence']: evi.append([i['claim'], j[0][2], j[0][3]]) evi_new = [] for e in evi: if e not in evi_new: evi_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def documents(pmid_23982599, civic_aid6_document):\n return [pmid_23982599, civic_aid6_document]", "def collect_sentences(self):\n sentences = []\n for document in self.documents:\n for sentence_token in document.sentences:\n sentences.append(sentence_token)\n re...
[ "0.6318956", "0.6029774", "0.5809859", "0.5809135", "0.57811606", "0.57792497", "0.5717688", "0.56928647", "0.5680044", "0.56697696", "0.5665578", "0.56534964", "0.5587616", "0.5578216", "0.5575649", "0.5569638", "0.5555268", "0.55517393", "0.5528553", "0.5528553", "0.5523985...
0.0
-1
The out put is the embedding result of claim, sentence and the label which is totally 601 dimmensions I use word2vec for embedding and the structure of output for each claim and the sentence is [embedding claim_300 dimmensions, embedding each sentence in 5 documents_300 dimmensions, label] If the sentence is the eviden...
def Subtask4_pre_train_5(): with open(PATH + 'pre_train_4_Subtask4.txt', encoding='utf-8') as fi: evi = eval(fi.read()) train_data = np.load(PATH + 'pre_train_2_Subtask4.npy', allow_pickle=True).item() model = word2vec.KeyedVectors.load_word2vec_format(PATH + "data/GoogleNews-vectors-negative300.bi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, doc):\n out = torch.tensor([]).float().to(self.device)\n\n for i in range(len(doc)):\n sentences_raw = sentencesplit(cleantxt(doc[i]))\n sentences_ready = torch.tensor([]).float().to(self.device)\n for sentence in sentences_raw:\n sent...
[ "0.64397955", "0.6414518", "0.6299152", "0.6277612", "0.6267003", "0.62635463", "0.6263355", "0.62268555", "0.62209713", "0.61678743", "0.61583453", "0.6140113", "0.6101954", "0.6095154", "0.6061823", "0.60469383", "0.6040722", "0.6030668", "0.6017879", "0.6002616", "0.599854...
0.6213321
9
This function is using the plot the ROC curve and print the RMSE, accuracy, AUC and test loss. The input is the prediction result of dev data and the label of dev data
def check_fit(truth, prob): fpr, tpr, _ = roc_curve(truth, prob) # drop_intermediate:(default=True) roc_auc = auc(fpr, tpr) # calculate the AUC plt.figure() plt.plot(fpr, tpr, color='darkorange', lw=2, label='ROC curve (area = %0.2f)' % roc_auc) plt.plot([0, 1], [0, 1], color='navy', lw=2, linesty...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_ROC(model, x_test, y_test, save_folder): \n predicted = model.predict(x_test).ravel()\n actual = y_test.ravel()\n fpr, tpr, thresholds = roc_curve(actual, predicted, pos_label=None)\n roc_auc = auc(fpr, tpr)\n plt.title('Test ROC AUC')\n plt.plot(fpr, tpr, 'b', label='AUC = %0.3f' % roc_...
[ "0.76977634", "0.76429826", "0.74793595", "0.7477506", "0.74698573", "0.7274968", "0.7197911", "0.7181239", "0.71708226", "0.71253717", "0.7118289", "0.71029097", "0.71004033", "0.70788234", "0.70758516", "0.7063369", "0.7044861", "0.70408773", "0.70204055", "0.70175385", "0....
0.650461
45
The y_true is the label of dev data and the y_pred is the prediciton of the model
def precision_score(y_true, y_pred): return ((y_true == 1) * (y_pred == 1)).sum() / (y_pred == 1).sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score(self, y_true, y_pred):\r\n pass", "def _evaluate(self, y_true, y_pred):\n pass", "def __call__(self, y_true: np.ndarray, y_pred: np.ndarray) -> float:", "def call(self, y_true, y_pred):\n y_true = K.switch(tf.shape(y_true)[-1] == self.n_classes, y_true, tf.squeeze(tf.one_hot(tf...
[ "0.75041443", "0.735152", "0.7322074", "0.7288702", "0.6739801", "0.67297107", "0.6712008", "0.6712008", "0.6710879", "0.6695137", "0.6695137", "0.66806996", "0.663322", "0.6627519", "0.6621446", "0.6607797", "0.65789884", "0.6567409", "0.6518728", "0.6517879", "0.6512908", ...
0.0
-1
The y_true is the label of dev data and the y_pred is the prediciton of the model
def recall_score(y_true, y_pred): return ((y_true == 1) * (y_pred == 1)).sum() / (y_true == 1).sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score(self, y_true, y_pred):\r\n pass", "def _evaluate(self, y_true, y_pred):\n pass", "def __call__(self, y_true: np.ndarray, y_pred: np.ndarray) -> float:", "def call(self, y_true, y_pred):\n y_true = K.switch(tf.shape(y_true)[-1] == self.n_classes, y_true, tf.squeeze(tf.one_hot(tf...
[ "0.75036263", "0.73512095", "0.7322297", "0.728788", "0.6739536", "0.67302555", "0.67121196", "0.67121196", "0.6711572", "0.66946733", "0.66946733", "0.66799456", "0.6632211", "0.662807", "0.66207665", "0.6607014", "0.65800023", "0.65667605", "0.65185815", "0.65180475", "0.65...
0.6182279
95
The y_true is the label of dev data and the y_pred is the prediciton of the model
def f1_score(y_true, y_pred): num = 2 * precision_score(y_true, y_pred) * recall_score(y_true, y_pred) deno = (precision_score(y_true, y_pred) + recall_score(y_true, y_pred)) return num / deno
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score(self, y_true, y_pred):\r\n pass", "def _evaluate(self, y_true, y_pred):\n pass", "def __call__(self, y_true: np.ndarray, y_pred: np.ndarray) -> float:", "def call(self, y_true, y_pred):\n y_true = K.switch(tf.shape(y_true)[-1] == self.n_classes, y_true, tf.squeeze(tf.one_hot(tf...
[ "0.7501048", "0.73485255", "0.732088", "0.7285464", "0.6736813", "0.67290515", "0.671074", "0.6710235", "0.6710235", "0.66919374", "0.66919374", "0.66788685", "0.66308594", "0.6625441", "0.6619626", "0.6606853", "0.65785164", "0.6564014", "0.65172786", "0.6516026", "0.6512531...
0.0
-1
Add modelspecific arguments to the parser.
def add_args(cls, parser): dc = getattr(cls, "__dataclass", None) if dc is not None: # do not set defaults so that settings defaults from various architectures still works gen_parser_from_dataclass(parser, dc(), delete_default=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_model_specific_args(parent_parser):\n # MODEL specific\n parser = ArgumentParser(parents=[parent_parser])\n parser.add_argument(\"--learning_rate\", default=0.01, type=float)\n parser.add_argument(\"--batch_size\", default=1, type=int)\n parser.add_argument(\"--depth\", d...
[ "0.78954256", "0.7532234", "0.75214946", "0.7465922", "0.7453896", "0.73522615", "0.7348936", "0.7210105", "0.71993154", "0.7194432", "0.718189", "0.71380925", "0.71294427", "0.70640695", "0.7035811", "0.70225257", "0.70146817", "0.7005652", "0.7005652", "0.7002312", "0.69814...
0.6724837
28
Build a new model instance.
def build_model(cls, args, task): raise NotImplementedError("Model must implement the build_model method")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_model(self):\n raise NotImplementedError", "def build_model(self):\n pass", "def build_model(self):\n pass", "def build_model():", "def _build_model(self, **kwargs):\n pass", "def _build_model(self):\n raise NotImplementedError()", "def build_model(self, **k...
[ "0.8193063", "0.81708336", "0.81708336", "0.8142892", "0.80082697", "0.8007576", "0.7792786", "0.7418838", "0.73600554", "0.73502004", "0.71278006", "0.71252024", "0.7077948", "0.7076256", "0.7055581", "0.7055581", "0.69957775", "0.69957775", "0.69845784", "0.6895667", "0.687...
0.7413572
8
Get targets from either the sample or the net's output.
def get_targets(self, sample, net_output): return sample["target"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_targets(self):\n\t\treturn self.prDoc['inputs']['data'][0]['targets']", "def output_targets(self, input_targets):\n return input_targets", "def output_targets(self) -> Set[str]:\n return {\n out.target\n for out in\n self.outputs\n }", "def output...
[ "0.7546623", "0.71686465", "0.6932078", "0.6811666", "0.6767465", "0.67216605", "0.6592436", "0.65119016", "0.65086675", "0.6496015", "0.6452853", "0.64246523", "0.6375694", "0.63572305", "0.632819", "0.62846535", "0.6282436", "0.6256334", "0.622767", "0.62171936", "0.6214964...
0.883374
0
Get normalized probabilities (or log probs) from a net's output.
def get_normalized_probs( self, net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]], log_probs: bool, sample: Optional[Dict[str, Tensor]] = None, ): return self.get_normalized_probs_scriptable(net_output, log_probs, sample)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_normalized_probs(self, net_output, log_probs, sample=None):\n encoder_out = net_output[\"encoder_out\"]\n if torch.is_tensor(encoder_out):\n logits = encoder_out.float()\n if log_probs:\n return F.log_softmax(logits, dim=-1)\n else:\n ...
[ "0.7654916", "0.762612", "0.7447698", "0.7434408", "0.7308484", "0.72212243", "0.65518427", "0.61370546", "0.61370546", "0.6102418", "0.6070036", "0.60151446", "0.59467596", "0.5924957", "0.58652586", "0.58567977", "0.57644725", "0.5761727", "0.5735097", "0.57293767", "0.5727...
0.78670233
1
Scriptable helper function for get_normalized_probs in ~BaseFairseqModel
def get_normalized_probs_scriptable( self, net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]], log_probs: bool, sample: Optional[Dict[str, Tensor]] = None, ): if hasattr(self, "decoder"): return self.decoder.get_normalized_probs(net_output, log...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_to_prob(inp):\n return (inp + 1)/2", "def get_normalized_probs(\n self,\n net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]],\n log_probs: bool,\n sample: Optional[Dict[str, Tensor]] = None,\n ):\n return self.get_normalized_probs_scripta...
[ "0.660994", "0.6277411", "0.6277411", "0.615602", "0.59609705", "0.5934441", "0.5852608", "0.58386904", "0.5791599", "0.5754615", "0.5637674", "0.5621181", "0.5581037", "0.5580047", "0.5567485", "0.55672115", "0.5557296", "0.5536824", "0.55352044", "0.5490201", "0.5468736", ...
0.60832953
4