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
Returns the two next marks that haven't been used on this space.
def next_marks(self): if self.n != 0: pmax = max(self.marks) else: pmax = 0 p1 = pmax + 1 p2 = pmax + 2 return p1, p2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getNextTerritoryPlaceMarkerno(self):\n \n # if self.max_markerno == 0\n if self.max_markerno == 0:\n return 1\n \n # All markerno's SHOULD be number 1 through total number markers\n # if not, there are some markers that have not yet been assigned markerno\n # go ahead and set m...
[ "0.62585247", "0.6197842", "0.6161695", "0.5964449", "0.5657985", "0.55898744", "0.55055714", "0.54640234", "0.5390226", "0.5383929", "0.531474", "0.52425236", "0.52278495", "0.51669264", "0.5164936", "0.51615626", "0.51525515", "0.51417595", "0.5131687", "0.5094463", "0.5083...
0.7172521
0
Returns the next mark that hasn't been used.
def next_mark(self): if self.n != 0: pmax = max(self.marks) else: pmax = 0 return pmax + 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __get_next_unmarked(self, current):\n while self.__is_multiple(current):\n current += 1\n return current", "def _getNextTerritoryPlaceMarkerno(self):\n \n # if self.max_markerno == 0\n if self.max_markerno == 0:\n return 1\n \n # All markerno's SHOULD be num...
[ "0.7044648", "0.6642172", "0.62489015", "0.62181896", "0.61391634", "0.60871315", "0.60135794", "0.59055674", "0.57508135", "0.5715984", "0.5689493", "0.5670749", "0.5634214", "0.56282294", "0.5622141", "0.5611392", "0.5594197", "0.5570131", "0.5565583", "0.55653036", "0.5558...
0.73365617
0
To catch a common mistake...
def __iter__(self): raise Exception("Don't iterate this! Did you pass this to intersect without putting it in a list?")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unexpected_error(self, exception):", "def unexpectedException(self):", "def handle_err(self):\n pass", "def check_errors(self) -> None:", "def experiment3():\n raise FAKE_ERROR", "def report_unexpected_exception(self, *args, **kwargs):\n pass", "def error(self):\n ...", "...
[ "0.7152382", "0.6912902", "0.65898734", "0.6582553", "0.6582474", "0.6561996", "0.6337797", "0.62926984", "0.62898856", "0.6280134", "0.62704444", "0.6255637", "0.6242657", "0.6204336", "0.6183122", "0.61740494", "0.61206454", "0.6119092", "0.610744", "0.60890114", "0.6026607...
0.0
-1
Returns a dictionary, with keys being the degrees, and values being a list of indexes of classes of the corrsponding degree. This is used by a different function to generate a list of all potentially nonzero monomials. Does not return psi classes, since they are made differently.
def degree_index_dict(self): did = dict() for i,c in enumerate(self.classes): if isinstance(c, lambda_class) or isinstance(c, psi_class) or c == 0: continue try: degree = c.degree except AttributeError: degre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def degree_index_dict_no_red(self):\n did = dict()\n for i,c in enumerate(self.classes):\n if isinstance(c, reducible_boundary) or isinstance(c, psi_class) or c == 0:\n continue \n try:\n degree = c.degree\n except AttributeEr...
[ "0.76682293", "0.60476583", "0.53982973", "0.5278339", "0.526159", "0.52377534", "0.5233555", "0.5195327", "0.5183467", "0.5165781", "0.5156541", "0.5151971", "0.5097595", "0.50944966", "0.50942034", "0.5063305", "0.50598127", "0.50462115", "0.504316", "0.50406444", "0.502819...
0.7501198
1
Returns a dictionary, with keys being the degrees, and values being a list of indexes of classes of the corrsponding degree. This is used by a different function to generate a list of all potentially nonzero monomials. This version does do the lambdas, but no reducible boundaries or psis.
def degree_index_dict_no_red(self): did = dict() for i,c in enumerate(self.classes): if isinstance(c, reducible_boundary) or isinstance(c, psi_class) or c == 0: continue try: degree = c.degree except AttributeError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def degree_index_dict(self):\n did = dict()\n for i,c in enumerate(self.classes):\n if isinstance(c, lambda_class) or isinstance(c, psi_class) or c == 0:\n continue \n try:\n degree = c.degree\n except AttributeError:\n ...
[ "0.72528434", "0.5412844", "0.5394591", "0.53063107", "0.5302103", "0.52735525", "0.526004", "0.5210724", "0.5204059", "0.51863134", "0.51816136", "0.51750946", "0.51374143", "0.5130763", "0.50688875", "0.5054228", "0.5043922", "0.5026027", "0.4983465", "0.49790865", "0.49574...
0.7285419
0
Returns true if there is a forgetful map out of this space.
def not_pushed_down(self): return (self.genus >= 2 and self.n != 0) or (self.genus == 1 and self.n > 1) or (self.genus == 0 and self.n > 3)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkMap(self):\n return True", "def __nonzero__(self):\n\n return not ipset.ipmap_is_empty(self.map)", "def is_empty(self):\n\n return ipset.ipmap_is_empty(self.map)", "def is_unoccupied(self, row, col):\n return self.maze[row][col] is EMPTY", "def is_full(self):\n i...
[ "0.67249465", "0.66899806", "0.66786814", "0.6617099", "0.65594023", "0.6538555", "0.65054786", "0.64949316", "0.6427947", "0.6398569", "0.63808787", "0.6360524", "0.63576496", "0.6355212", "0.6343116", "0.6303801", "0.62969935", "0.62950987", "0.6289435", "0.6248638", "0.619...
0.0
-1
Returns the space obtained by forgeting as many marked points as possible.
def pushed_down(self): if self.genus == 0: return Mgn(0,3) if self.genus == 1: return Mgn(1,1) return Mgn(self.genus,0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forget(self, mark):\n return Mgn(self.genus, self.marks.difference([mark]))", "def remaining(self):\n\t\tmines = sum(1 for _ in self.get_mines())\n\t\tmarked = sum(1 for x in range(self.width)\n\t\t\t\t\t for y in range(self.height) if self.marks[x][y] == FLAG)\n\t\treturn mines - marked", "def ob...
[ "0.6049785", "0.5959044", "0.57731503", "0.55129325", "0.5471895", "0.5466985", "0.5431448", "0.5298027", "0.5284099", "0.5224681", "0.52125984", "0.5202014", "0.5183426", "0.5176836", "0.5156857", "0.5156857", "0.5152435", "0.5124654", "0.50829494", "0.5079855", "0.5060599",...
0.0
-1
Returns a new space with the specified point forgotten.
def forget(self, mark): return Mgn(self.genus, self.marks.difference([mark]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lift(point):\n return gs.copy(point)", "def clone(self):\n return Point(self.x, self.y)", "def clone(self):\n return Point(self.x, self.y)", "def new_position(self, p):\n if self.track:\n self.gnx = p.gnx\n else:\n p = self.get_position()\n\n ...
[ "0.6511328", "0.5885441", "0.5885441", "0.5658703", "0.5657942", "0.5507595", "0.5403226", "0.5349651", "0.5326823", "0.53047156", "0.53036803", "0.52807295", "0.5265675", "0.5237062", "0.5217262", "0.519684", "0.5185227", "0.51527864", "0.5148071", "0.5139145", "0.5123939", ...
0.0
-1
This method must be overridden. Pull this class back to the product M1 x M2, with p1 and p2 being the new marks.
def pullback_red(self, M1p1, M2p2): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mult(diagram1, diagram2):\n raise NotImplementedError", "def product(self):\n raise NotImplementedError", "def mult(self, other):\r\n A = np.dot(self.M, other.M)\r\n B = np.dot(self.M, other.N) + np.dot(self.N, other.M) + \\\r\n self.k*np.dot(self.N, other.N)\r\n ...
[ "0.58971804", "0.5865411", "0.57406694", "0.5660099", "0.5656148", "0.5627505", "0.55751514", "0.55020183", "0.54862946", "0.5451903", "0.54322046", "0.5426278", "0.54229295", "0.53983384", "0.53671396", "0.53667814", "0.53398585", "0.53313184", "0.5314007", "0.53138614", "0....
0.5742735
2
This method must be overridden. Pull back to the irreducible curve, where the class is currently on M, and p1 and p2 are the names of the new marks.
def pullback_irr(self, M, p1, p2): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pullback_red(self, M1p1, M2p2):\n pass", "def oncurve(self, P):\n\t\traise Exception(NotImplemented)", "def GetPoint2(self):\n ...", "def GetPoint2(self):\n ...", "def GetPoint1(self):\n ...", "def GetPoint1(self):\n ...", "def __init__(self, pt1, pt2):\n s...
[ "0.55120814", "0.5377777", "0.5299187", "0.5299187", "0.5174387", "0.5174387", "0.5164251", "0.5075292", "0.5018509", "0.49826714", "0.49812275", "0.49715918", "0.49609345", "0.4957323", "0.495071", "0.49328053", "0.49311933", "0.4910637", "0.48935622", "0.48855036", "0.48817...
0.55004317
1
Returns a tuple that can be used to represent this class in the dictionary. It recieves as a argument a dictionary that tells you how to reindex the marks.
def table_key(self, reindex_dict): reindexed_marks = [] for m in self.component1.marks: new_m = reindex_dict.get(m) if new_m == None: if len(reindex_dict) == 0: new_m = 0 else: new_m = max(reindex_dict.values...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, index):\n if index in self.marks:\n return psi_class(self, index)\n return self.classes[index-1]", "def key(self, x):\r\n return tuple(x)", "def _hashable_content(self) -> Tuple[int]:\n return (self.index,)", "def get_info_in_tuple(self):\r\n ...
[ "0.5695776", "0.553696", "0.5536798", "0.55358136", "0.5507339", "0.5451462", "0.5404659", "0.5376407", "0.5360486", "0.5334526", "0.5330665", "0.53029096", "0.528989", "0.52669483", "0.5261161", "0.5231731", "0.5197029", "0.5193263", "0.51903", "0.515945", "0.51434106", "0...
0.66550064
0
Returns either 1 or 2, depending on the degree of the map from the product space to this reducible boundary. It should be two if there is an automorphism of the graph, and 1 otherwise.
def degree_of_map(self): if 2*self.component1.genus == self.space.genus and self.space.n == 0: return 2 else: return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def degree(self, k):\n one_if_my_all_k = 1 if self.my_alll(k) else 0\n return (2 * self.get_prp_j(k)[0]) + one_if_my_all_k", "def __len__(self):\n # Product function that can handle iterables (np.product can't).\n product = partial(reduce, operator.mul)\n modstr = '%s__' % self...
[ "0.56591105", "0.55599594", "0.55144054", "0.54866827", "0.54248524", "0.5414117", "0.5380749", "0.53456897", "0.5329448", "0.53151715", "0.53136253", "0.5302995", "0.5274688", "0.52355593", "0.52244955", "0.52135247", "0.52087957", "0.5205941", "0.52037925", "0.51970476", "0...
0.7497575
0
Returns the coefficent in formula that coverts chern classes to kappas and psis (formula for chern character in [Yan10]).
def get_coeff(self): return bernoulli(self.degree+1) / factorial(self.degree + 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def estimateCs(y, inp):\n\treturn 1 -(math.tanh(getK1(inp) - (y/getY90(inp)) / (2 * getD0(inp)) + (y/getY90(inp) - 1/3.0)**3 / (3 * getD0(inp))))**2", "def calculate_cci(hunterlab):\n return 1000 * (hunterlab[1]) / (hunterlab[0] * hunterlab[2])", "def cie_lab(self):\n K = Fraction(1, 3) * Fraction(29...
[ "0.6410334", "0.62566257", "0.6107049", "0.60611534", "0.60424066", "0.583772", "0.57275325", "0.57261425", "0.5708629", "0.5658784", "0.56464934", "0.5640204", "0.5634834", "0.5633246", "0.55867624", "0.55810136", "0.55681336", "0.55570865", "0.5538005", "0.5534324", "0.5521...
0.0
-1
Returns the "bad" (Mumford's original) kappa of the same degree.
def get_kappa(self): return kappa_class(self.space, self.degree) - sum((psi_class(self.space, p)**self.degree for p in self.space.marks) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kappa(tol_angle, degrees=True):\n if degrees:\n tol_angle = np.radians(tol_angle)\n return 4/(tol_angle**2)", "def kappa(self):\n a, c, d, b = self.to_ccw()\n p1, q1 = a + b, c + d\n p2, q2 = a + c, b + d\n n = p1 + q1\n\n if n == 0:\n return np.nan\...
[ "0.67796105", "0.6638783", "0.65222853", "0.62173575", "0.61565024", "0.6044664", "0.60339195", "0.5998601", "0.59471756", "0.5932053", "0.5853644", "0.5831035", "0.57836586", "0.5782085", "0.5764921", "0.57372206", "0.57042474", "0.56982696", "0.5663674", "0.5653718", "0.564...
0.70768404
0
See formula for chern character in [Yan10]. This is a generator that yeilds a tuple of data used to compute the sum over the reducible boundary pushforward maps.
def get_red_boundaries_and_psis(self,i): for (M1,p1), (M2, p2) in self.space.red_boundaries_as_spaces(): if M1.n == 1 and M2.n == 1 and M1.genus == M2.genus: degree_of_map = 2 else: degree_of_map = 1 yield (M1, p1), (M2, p2), psi_class(M1, p1) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data(self) -> Generator[Tuple[int, int], None, None]:\n x = self.x_start\n y = self.y_start\n yield x, y\n while True:\n x += self.x_rate\n y += self.y_rate\n yield int(x), int(y)", "def __call__(self,data):\n \n firstkey = True\n ...
[ "0.5973402", "0.5613494", "0.54590005", "0.5422092", "0.5411444", "0.53831804", "0.5371424", "0.53577024", "0.5354976", "0.53450185", "0.52727723", "0.52123487", "0.5203865", "0.51984775", "0.51908404", "0.51864123", "0.51547176", "0.5124034", "0.5121632", "0.51133287", "0.51...
0.0
-1
See formula for chern character in [Yan10]. This returns a tuple of data used to compute the sum over the irreducible boundary pushforward map.
def get_irr_boundary_and_psis(self, i): M, p1, p2 = self.space.irr_boundary_as_space() return (M, p1, p2), psi_class(M, p1) ** i * psi_class(M, p2) ** (self.degree - i - 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addition_homework(data: Iterator[str]) -> int:\n n = final_sum(data)\n return n.magnitude", "def total(self):\n return {\n 'A': self.forward['A'] + self.reverse['A'],\n 'T': self.forward['T'] + self.reverse['T'],\n 'C': self.forward['C'] + self.reverse['C'],\n ...
[ "0.5287051", "0.5171282", "0.5117117", "0.5091768", "0.50772417", "0.5064949", "0.5062615", "0.49961525", "0.4990778", "0.4971184", "0.49267727", "0.49233928", "0.49182367", "0.4904836", "0.4892051", "0.488806", "0.48580143", "0.48555157", "0.48541743", "0.4850237", "0.483265...
0.0
-1
Returns an equivilant expression terms of chern characters.
def as_chern_chars(self): #value = self.as_chern_chars_dict.get(self) if True: #value == None: #print "on space", self.space, "with lambda_", self.degree upto = ceil(self.degree/2.0)+1 S = PowerSeriesRing(SR, "t") f = ( sum( [fact...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_word(word):\r\n\r\n if word.isupper():\r\n terms = [('%s*%s' % (10**i, d)) for (i,d) in enumerate(word[::-1])]\r\n return '(' + '+'.join(terms) + ')'\r\n else:\r\n return word", "def sanitize(formula):\n TR_UNICODE = {u\"·\": u\"*\", u\"−\": u\"-\"}\n return \"\".join...
[ "0.577644", "0.56820256", "0.56617486", "0.5594537", "0.5474107", "0.5408417", "0.539007", "0.5386722", "0.5358573", "0.5320198", "0.53183347", "0.52778924", "0.5266685", "0.52639884", "0.52527505", "0.52509403", "0.5234368", "0.5219025", "0.5209141", "0.5207185", "0.52059174...
0.65786517
0
Handler function for hash join.
def hash_join (planNode): operation_name = planNode.get_attr("Node Type") operation_type = planNode.get_attr("Join Type") cond_msg = planNode.get_attr("Hash Cond") if operation_type != '': operation_type += ' ' if (cond_msg): cond_msg = ' on condition '+cond_msg descrip...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def join(self):\n pass", "def hash_key(self):", "def _hexdigests(self):\n\n for algo in self.algos:\n q = self._queues[algo]\n q.put(b'') # Terminate\n self._threads[algo].join()\n assert q.empty()\n return super(MtHasher, self)._hexdigests()", ...
[ "0.5794422", "0.5703464", "0.5696048", "0.5614501", "0.5572176", "0.5495869", "0.54828334", "0.5481546", "0.54747283", "0.5461832", "0.5442346", "0.5442346", "0.5442346", "0.5412181", "0.5403193", "0.5361309", "0.5354412", "0.5342982", "0.533204", "0.5304427", "0.5287919", ...
0.590912
0
Handler function for nested loop join.
def nested_loop(planNode): node = planNode.get_attr("Node Type") join_type = planNode.get_attr("Join Type") if join_type != '': join_type += ' ' join_filter = planNode.get_attr("Join Filter") filter_msg = '' if (join_filter): filter_msg = ' on join filter '+join_filter ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def join(self):\n pass", "def join(self):\n for t in self.created_list:\n t.join()", "def joiner():\n for th in threads:\n th.join()\n done(process)", "def run(self):\n self.cc_log(\"INFO\", \"Data Processing Join: Started\")\n if self.left_join...
[ "0.6358565", "0.6278032", "0.5571421", "0.5554408", "0.55250555", "0.55180985", "0.5479515", "0.5351793", "0.52703863", "0.52608633", "0.5218109", "0.5128748", "0.51163507", "0.51048696", "0.50975645", "0.50968325", "0.50797707", "0.5073068", "0.4993057", "0.49908677", "0.498...
0.6324225
1
Handler function for merge join.
def merge_join(planNode): cond = planNode.get_attr("Merge Cond") cond_msg = "" if (cond): cond_msg += " on condition {}".format(cond) node = planNode.get_attr("Node Type") join_type = planNode.get_attr("Join Type") if join_type != "": join_type += ' ' description = "{}{...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(): #Status: WIP\r\n pass", "def on_merge(self, to_be_merged, merge_result, context):\n pass", "def testCorrectJoin(self):\n b_tree = OOBTree()\n b_tree.update({1: \"Monkey D. Luffy\", 2: \"Roronoa Zoro\", 3: \"Nami\"})\n failed_counter = 0\n key = 1\n data ...
[ "0.69647384", "0.6865149", "0.68056667", "0.6671668", "0.6515321", "0.6314797", "0.63016045", "0.62063164", "0.6184719", "0.6171167", "0.61051774", "0.6040064", "0.60022736", "0.59989715", "0.597163", "0.5964814", "0.59526324", "0.59026444", "0.58414847", "0.5793461", "0.5786...
0.61107236
10
Handler function for append.
def append(planNode): description = "append operation" return description
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append(self, *args, **kwargs): # real signature unknown\n pass", "def append(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads\n pass", "def append (self, item):\n pass", "def do_append(self, level, msg, *args, **kwargs):\n record = self.log.m...
[ "0.7310906", "0.70278627", "0.6692309", "0.6670054", "0.6380898", "0.63000864", "0.62370366", "0.6151141", "0.61382455", "0.60261387", "0.602149", "0.5980532", "0.59785855", "0.59732884", "0.5956681", "0.59549695", "0.58898133", "0.58898133", "0.5844861", "0.5840962", "0.5820...
0.52638185
95
Shuffle data and labels.
def shuffle_data(data): idx = np.arange(len(data)) np.random.shuffle(idx) return data[idx, ...]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shuffle_data(self):\n images = list(self.train_images)\n labels = list(self.train_labels)\n self.train_images = []\n self.train_labels = []\n\n # create list of permutated index and shuffle data accoding to list\n idx = np.random.permutation(len(labels))\n for i...
[ "0.84921646", "0.84220874", "0.800393", "0.7868807", "0.78123", "0.7764462", "0.7758387", "0.77576107", "0.77576107", "0.77576107", "0.76847744", "0.7454648", "0.74520284", "0.7394949", "0.7394949", "0.73529667", "0.72944164", "0.7293919", "0.7201344", "0.7141838", "0.7098533...
0.6604832
37
Shuffle orders of points in each point cloud changes FPS behavior. Use the same shuffling idx for the entire batch.
def shuffle_points(batch_data): idx = np.arange(batch_data.shape[1]) np.random.shuffle(idx) return batch_data[:, idx, :]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shuffle_points(batch_data):\n idx = np.arange(batch_data.shape[1])\n np.random.shuffle(idx)\n return batch_data[:,idx,:]", "def shuffle_points(mutated_genome,index):\n random.shuffle(mutated_genome[index][2])", "def _shuffle_roidb_idx(self):\n self.perm = np.random.permutation(np.arange(s...
[ "0.72590023", "0.7239251", "0.67538834", "0.6724801", "0.6550845", "0.6484533", "0.6474677", "0.6474677", "0.6458041", "0.6420625", "0.6403558", "0.63890237", "0.6386616", "0.63513637", "0.629727", "0.62965", "0.6291102", "0.6281963", "0.62366074", "0.62181103", "0.6217867", ...
0.7280055
0
Returns the PlotWidget contains in this window
def getPlotWidget(self): return self._plot
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_widget(self):\n return self.imgwin", "def getHistogramWidget(self):\n return self._getToolWindow()", "def get_active_plot(self):\n for plot in list(self.plots.values()):\n canvas = plot.canvas()\n if canvas.hasFocus():\n return plot\n ret...
[ "0.70153105", "0.6961207", "0.6889463", "0.6799132", "0.67330176", "0.65999055", "0.65312165", "0.65188783", "0.6484199", "0.64163965", "0.6361403", "0.6350211", "0.6318388", "0.6266669", "0.62585574", "0.61179197", "0.60474443", "0.6045812", "0.60415775", "0.60415775", "0.60...
0.832208
0
Set or change the database name. If 'modify' is True, then allow modifying the name to make it unique. Return the final name. Raise ValueError if name is invalid or already in use.
def set_name(self, name, modify=False): assert not hasattr(self, "_dbcnx") # Must be done before any write ops. if name == self.db.get("name"): return if not constants.NAME_RX.match(name): raise ValueError("invalid database name") if modify: modified ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_name(name=False):\n if not name:\n name = name_generator()\n return name", "def set_name(self, newname=\"\"):\n self.name = newname", "def name(self, new_name: str) -> None:\n raise NotImplementedError()", "def new_name(self,new_name):\n self.name = new_name", "def...
[ "0.63189477", "0.6314735", "0.6165321", "0.61172503", "0.60988", "0.60660833", "0.6036501", "0.6013789", "0.600955", "0.600955", "0.5947962", "0.59277517", "0.59162265", "0.5903049", "0.5815733", "0.58009654", "0.5748256", "0.5719417", "0.5719417", "0.56806755", "0.5662065", ...
0.8319422
0
Set to 'readonly' (True) or 'readwrite' (False). If 'readonly', then compute the hash values, else remove them.
def set_readonly(self, mode): if self.db["readonly"] == mode: return self.db["readonly"] = self.readonly = mode if mode: hashes = {} for hashname in flask.current_app.config["CONTENT_HASHES"]: hashes[hashname] = hashlib.new(hashname) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readonly(self, readonly):\n\n self._readonly = readonly", "def readonly(self, readonly):\n\n self._readonly = readonly", "def read_only(self, read_only):\n\n self._read_only = read_only", "def read_only(self, read_only):\n\n self._read_only = read_only", "def readonly(self):...
[ "0.6958146", "0.6958146", "0.6554565", "0.6554565", "0.65188134", "0.65188134", "0.63850576", "0.63573664", "0.62068427", "0.61874276", "0.61058474", "0.60293335", "0.5890427", "0.5875915", "0.5808903", "0.5753325", "0.5687405", "0.56783015", "0.567108", "0.56515807", "0.5631...
0.6786981
2
Create and load table from records (lists of data items). Infer table column types and constraints from records contents. Raises ValueError or sqlite3.Error if any problem.
def create_table_load_records(self, tablename, records, has_header=True): # Column names from header, or make up. if has_header: header = records.pop(0) header = [utils.name_cleaned(n) for n in header] if len(header) != len(set(header)): raise ValueErr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(cursor, table, *args, **kwds):\n try:\n records, = args\n columns = None\n except ValueError:\n columns, records = args\n\n default = kwds.pop('default', '')\n if kwds:\n msg = 'load_data() got unexpected keyword argument {0!r}'\n raise TypeError(msg.for...
[ "0.66279644", "0.6479597", "0.6434635", "0.6011159", "0.6007939", "0.5869238", "0.58558583", "0.58282346", "0.57568645", "0.5747565", "0.5666356", "0.555702", "0.5545761", "0.55447066", "0.5540246", "0.5536555", "0.5501205", "0.5488088", "0.54878986", "0.5467272", "0.54550296...
0.762297
0
Create the table in the database and add to the database definition. If 'query' is given, do 'CREATE TABLE AS', and fix up the schema. If 'create' is True, then actually create the table. Raises ValueError if there is a problem with the input schema data. Raises SystemError if the query is interrupted by timeout.
def add_table(self, schema, query=None, create=True): if not constants.NAME_RX.match(schema["name"]): raise ValueError("invalid table name") if utils.name_in_nocase(schema["name"], self.db["tables"]): raise ValueError("name is already in use for a table") if utils.name_in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_sql_table(self, query):\n table_pattern = r\"CREATE TABLE ([\\w_:]+)\"\n match = re.search(table_pattern, query, re.IGNORECASE)\n table_name = match.group(1)\n if \":\" in table_name:\n query = self.clean_table_name(query, table_name)\n\n # Check to see if t...
[ "0.72810155", "0.6941827", "0.65274644", "0.64704907", "0.6371803", "0.63551843", "0.63226044", "0.62900233", "0.6281851", "0.62293935", "0.62046564", "0.61940694", "0.6184373", "0.6161017", "0.6122502", "0.6103641", "0.6048098", "0.60406506", "0.602241", "0.6019121", "0.6005...
0.74015164
0
Add the given column to the table described by the schema. Raise ValueError if there is any problem.
def add_table_column(self, schema, column): if not column["name"] or not constants.NAME_RX.match(column["name"]): raise ValueError("invalid column name") if utils.name_in_nocase(column["name"], [c["name"] for c in schema["columns"]]): raise ValueError("non-unique column name") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_column(self, table_name: str, column) -> None:\n sql = 'ALTER TABLE ' + table_name + ' ADD COLUMN ' + column.to_sql()\n self.cursor.execute(sql)", "def add_column_to_staging_table(cursor,table_schema,table_name,column_name):\n if not check_if_column_exists(cursor, table_schema, table_name,...
[ "0.7461268", "0.70328975", "0.7005947", "0.6832318", "0.6706952", "0.6699322", "0.66819566", "0.66518646", "0.66147494", "0.6606529", "0.6585268", "0.6562195", "0.6534154", "0.64950705", "0.64822", "0.64128786", "0.6389013", "0.6368527", "0.62607074", "0.6210972", "0.6156823"...
0.8124627
0
Create a view in the database and add to the database definition. If 'create' is True, then actually create the view. Raises ValueError if there is a problem with the input schema data.
def add_view(self, schema, create=True): if not constants.NAME_RX.match(schema["name"]): raise ValueError("invalid view name") if utils.name_in_nocase(schema["name"], self.db["tables"]): raise ValueError("name is already in use for a table") if utils.name_in_nocase(schema...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_view(self, repo, view, sql):\n return self.user_con.create_view(\n repo=repo, view=view, sql=sql)", "def creates_view(self):\n return self.statements[0].creates_view()", "def create_view(self, start: int = 0, stop: int = 0):\n stmt = f\"\"\"create or replace view {sel...
[ "0.7217368", "0.656495", "0.63287896", "0.6194457", "0.6177249", "0.6164981", "0.60936546", "0.6083409", "0.606832", "0.5918686", "0.5900394", "0.57855225", "0.57373005", "0.5719429", "0.5673319", "0.5611739", "0.55860096", "0.5470929", "0.5427602", "0.5407982", "0.5404273", ...
0.7786582
0
Check the validity of the metadata for the database. Return False if no metadata (i.e. not a DbShare file), else True. Raises ValueError or sqlite3.Error if any problem.
def check_metadata(self): sql = f"SELECT COUNT(*) FROM {constants.TABLES}" if self.dbcnx.execute(sql).fetchone()[0] == 0: return False # No metadata; skip. sql = f"SELECT name FROM {constants.TABLES}" tables1 = [r[0] for r in self.dbcnx.execute(sql)] sql = "SELECT na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self):\n # validate contents still to do - for now just check if it exists\n return os.path.exists(self.getDefaultDatabaseConnectionParameter()['path'])", "def db_exists(self, db):\n # HDF5 is file based\n return os.path.isfile(db)", "def _metadata_is_consistent(metadata):...
[ "0.6685639", "0.66693676", "0.6632217", "0.6471173", "0.6443462", "0.63612366", "0.6281263", "0.6280908", "0.62710387", "0.62230617", "0.6158644", "0.614975", "0.6114387", "0.60799456", "0.6042524", "0.60312736", "0.59899956", "0.59632313", "0.59618896", "0.5924156", "0.59134...
0.81981516
0
Return the database metadata for the given name. Return None if no such database.
def get_db(name, complete=False): cursor = flask.g.syscnx.cursor() sql = ( "SELECT owner, title, description, public, readonly," " created, modified FROM dbs WHERE name=?" ) cursor.execute(sql, (name,)) rows = cursor.fetchall() if len(rows) != 1: return None # 'rowcount'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_database(self, name):\n try:\n return [db for db in self.list_databases()\n if db.name == name][0]\n except IndexError:\n raise exc.NoSuchDatabase(\"No database by the name '%s' exists.\" %\n name)", "def get_database(self, instanc...
[ "0.7327657", "0.722267", "0.7001932", "0.6679206", "0.6602514", "0.63183403", "0.6302966", "0.6268658", "0.6256726", "0.6192925", "0.618651", "0.6170439", "0.61583745", "0.6127866", "0.61237854", "0.6119", "0.60515904", "0.60427445", "0.6033482", "0.6029815", "0.6027621", "...
0.6671863
4
Get the schema of the table or view. Add a member 'type' denoting which it is. Raise ValueError if no such table or view.
def get_schema(db, sourcename): try: schema = db["tables"][sourcename] schema["type"] = constants.TABLE except KeyError: try: schema = db["views"][sourcename] schema["type"] = constants.VIEW except KeyError: raise ValueError("no such table/view...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _schema_type(self) -> Optional[type]:\n return IndexSchema", "def _schema_type(self) -> Optional[type]:\n pass", "def _schema_type(self) -> Optional[type]:\n return PanelSchema", "def _schema_type(self) -> Optional[type]:\n return MovieSchema", "def _schema_type(self) -> Opt...
[ "0.67394197", "0.64360523", "0.642696", "0.6404674", "0.63924086", "0.6387125", "0.63536716", "0.6310814", "0.62644035", "0.6218083", "0.6200075", "0.61655676", "0.6131771", "0.6125235", "0.601341", "0.59711987", "0.5944062", "0.58982587", "0.5890849", "0.5876796", "0.587585"...
0.7271602
0
Return SQL to create a table given by its schema. Raise ValueError if any problem.
def get_sql_create_table(schema, if_not_exists=False): if not schema.get("name"): raise ValueError("no table name defined") if not schema.get("columns"): raise ValueError("no columns defined") names = set() for column in schema["columns"]: if utils.name_in_nocase(column["name"], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_table(self, schema, table):\n fields = \", \".join([\" \".join(t) for t in zip(self.schemas[schema][table][0], self.schemas[schema][table][1])])\n sql = f'set role {self.write_role}; ' \\\n + f'CREATE TABLE IF NOT EXISTS {schema}.{table} ( {fields} );'\n return sql", "...
[ "0.7396332", "0.7222839", "0.7214331", "0.719338", "0.7181155", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7175187", "0.7173953", "0...
0.77022225
0
Return SQL to create an index given by its schema. Raise ValueError if any problem.
def get_sql_create_index(tablename, schema, if_not_exists=False): if not schema.get("columns"): raise ValueError("no columns defined") if len(schema["columns"]) != len(set(schema["columns"])): raise ValueError("same column given more than once") sql = ["CREATE"] if schema.get("unique"): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_sql(self, model, schema_editor, using='', **kwargs):\n include = [model._meta.get_field(field_name).column for field_name in self.include]\n condition = self._get_condition_sql(model, schema_editor)\n if self.expressions:\n index_expressions = []\n for expressi...
[ "0.72072047", "0.706101", "0.6861405", "0.64765775", "0.64105004", "0.63790756", "0.6371936", "0.6313902", "0.6216902", "0.61960846", "0.61543465", "0.61295676", "0.6011166", "0.600814", "0.5993174", "0.5950828", "0.5849119", "0.5826671", "0.5727391", "0.56642616", "0.5639990...
0.7434653
0
Get the connection for the database given by name.
def get_cnx(dbname, write=False): try: if write == flask.g.dbwrite: return flask.g.dbcnx else: flask.g.dbcnx.close() except AttributeError: pass flask.g.dbcnx = utils.get_cnx(dbname, write=write) flask.g.dbname = dbname flask.g.dbwrite = write retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_database(conn, name):\n\n if conn.hasDatabase(name) is False:\n return conn.createDatabase(name)\n\n return conn[name]", "def connection(self, name=None):\n if not name:\n name = threading.currentThread().getName()\n if name in self:\n return self[name]\n self[name] = self...
[ "0.79389775", "0.75319666", "0.7517848", "0.72717863", "0.7117428", "0.70957136", "0.7020149", "0.69911426", "0.6988056", "0.698185", "0.6891314", "0.68769324", "0.68455476", "0.6843064", "0.6816855", "0.67779374", "0.6772218", "0.67668045", "0.67563635", "0.67541003", "0.672...
0.0
-1
Get the database and check that the current user has read access. Optionally add nrows for each table and view. Raise KeyError if no such database. Raise ValueError if may not access.
def get_check_read(dbname, nrows=False, complete=True): db = get_db(dbname, complete=complete) if db is None: raise KeyError("no such database") if not has_read_access(db): raise ValueError("may not read the database") set_nrows(db, targets=nrows) return db
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_read(self, db, randomize_access=False):\n self.db = db\n self.randomize_access = randomize_access\n self.can_read = True", "def db_for_read(self, model, **hints):\n if self.isAdminApp(model):\n return 'auth_db'\n return None", "def raise_for_access(\n ...
[ "0.61900944", "0.5673167", "0.5670762", "0.56600416", "0.5628751", "0.56280935", "0.5595738", "0.55469775", "0.545015", "0.53966767", "0.5375409", "0.53170985", "0.5258059", "0.5160819", "0.5094779", "0.5073889", "0.5005565", "0.49983191", "0.49965835", "0.4994591", "0.496552...
0.7279948
0
Get the database and check that the current user has write access. Optionally add nrows for each table and view. Raise KeyError if no such database. Raise ValueError if may not access.
def get_check_write(dbname, check_mode=True, nrows=False, complete=True): db = get_db(dbname, complete=complete) if db is None: raise KeyError("no such database") if not has_write_access(db, check_mode=check_mode): raise ValueError("may not write to the database") set_nrows(db, targets=n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_check_read(dbname, nrows=False, complete=True):\n db = get_db(dbname, complete=complete)\n if db is None:\n raise KeyError(\"no such database\")\n if not has_read_access(db):\n raise ValueError(\"may not read the database\")\n set_nrows(db, targets=nrows)\n return db", "def _...
[ "0.62008744", "0.5717889", "0.5461007", "0.54139274", "0.5394495", "0.53823745", "0.5362482", "0.53576916", "0.5351964", "0.5261355", "0.51136035", "0.4998261", "0.4941331", "0.4937972", "0.49325716", "0.48510417", "0.4825769", "0.48031938", "0.47883636", "0.47742996", "0.476...
0.6900375
0
Add the Sqlite3 database file present in the given open file object. If the database has the metadata of a DbShare Sqlite3 database, check it. Else if the database appears to be a plain Sqlite3 database, infer the DbShare metadata from it by inspection. 'size' is the size of the database file. Return the database dicti...
def add_sqlite3_database(dbname, infile, size): try: check_quota(size=size) with DbSaver() as saver: dbname = saver.set_name(dbname, modify=True) with open(utils.get_dbpath(dbname), "wb") as outfile: outfile.write(infile.read()) saver.initialize() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(self):\n if not self.filename:\n raise ValueError(\"Can only open on-disk databases\")\n self.db = dbm.open(self.filename, \"w\") #raises anydbm.error\n try:\n if self.db[\"--Reserved--type\"] != self.type:\n raise ValueError(\"Not a %s database\" ...
[ "0.5955714", "0.5953158", "0.59470034", "0.5555061", "0.54738444", "0.54535043", "0.54270566", "0.54080987", "0.53994936", "0.53630704", "0.5354894", "0.53220826", "0.5319659", "0.5310338", "0.528904", "0.52802867", "0.52757585", "0.52705204", "0.5266127", "0.52581644", "0.52...
0.7196136
0
Add the XLSX file workbook as a database. The worksheets are loaded as tables. 'size' is the size of the XLSX file. Return the database dictionary. Raise ValueError if any problem.
def add_xlsx_database(dbname, infile, size): tmp = tempfile.NamedTemporaryFile(suffix=".xlsx") tmp.write(infile.read()) tmp.seek(0) try: wb = openpyxl.load_workbook(tmp.name) check_quota(size=size) with DbSaver() as saver: dbname = saver.set_name(dbname) s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_xl2db(xlfilepath, sheetname, header_cols, insfunc, start_row=0):\n def is_header(row):\n hText = ('!!'.join(header_cols)).lower()\n rText = ('!!'.join([str(r) for r in row[:len(header_cols)]])).lower()\n return hText == rText\n \n #load sheet & file header\n sheet = XlShee...
[ "0.58233666", "0.5794", "0.54771256", "0.5370337", "0.5314483", "0.52456737", "0.5185944", "0.5175234", "0.5072808", "0.50604826", "0.5035717", "0.5033447", "0.50137645", "0.50020313", "0.49190697", "0.49113122", "0.4905969", "0.48963267", "0.48790076", "0.48784056", "0.48197...
0.77125597
0
Computes the value of the Cross Entropy loss function.
def loss(self, y_true, score, pos_label=_NoValue): if pos_label is not _NoValue: raise ValueError("`pos_label` not supported") score = score.atleast_2d() # Working with 2-D arrays only p = CSoftmax().softmax(score) # SoftMax function # find-like indexing (list of lists) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(self):\n return self._cross_entropy_func", "def cross_entropy_loss():\n return nn.CrossEntropyLoss()", "def CE():\n def CE_loss(input,target):\n return nn.CrossEntropyLoss()(input.squeeze(), target)\n\n return CE_loss", "def crossentropy_fn(args: StepFunctionArgs) ->...
[ "0.7596708", "0.7409889", "0.7297439", "0.7185734", "0.7045178", "0.68566203", "0.68134034", "0.6808913", "0.6760362", "0.6733593", "0.6732217", "0.6728744", "0.6717958", "0.6706692", "0.6689043", "0.6683191", "0.66703624", "0.6636742", "0.66352695", "0.6622109", "0.6614492",...
0.0
-1
Computes gradient of the Cross Entropy loss w.r.t.the classifier decision function corresponding to class label pos_label.
def dloss(self, y_true, score, pos_label=None): score = score.atleast_2d() # Working with 2-D arrays only grad = CSoftmax().softmax(score) # we subtract -1 only to the elements equal to y_true grad[[list(range(score.shape[0])), y_true.tolist()]] -= 1.0 # find-like indexing (l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_gradient(self,ex,pos,neg,examples):\n\n k = 2\n imposters = []\n\n distances = {}\n for other_ex in examples:\n\n #skip same example\n if ex == other_ex:\n continue\n\n #add other class to imposters\n if other_ex in ...
[ "0.6929106", "0.66003597", "0.6548047", "0.6475285", "0.63980824", "0.63309544", "0.63119125", "0.6297976", "0.6247121", "0.62257177", "0.62192774", "0.6212148", "0.6199504", "0.6187455", "0.6170391", "0.6168697", "0.6167525", "0.61656535", "0.61628205", "0.61556435", "0.6115...
0.6393577
5
Check if the authenticated user has 'admin' or 'attendant' role If 'admin' authorize, else if 'attendant' deny access
def post(self): data = ProductsResource.parser.parse_args() for user in User.users: if user.role == 'attendant' and user.username == auth.username(): return {'message': 'Not authorised to access '}, 401 if user.role == 'admin' and user.username == auth.username()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_auth():\n if not current_user.is_authenticated:\n return render_template('401.html', base_template=appbuilder.base_template, appbuilder=appbuilder), 401\n for role in current_user.roles:\n if appbuilder.get_app.config['AUTH_ROLE_ADMIN'] == role.name:\n return None\n retu...
[ "0.7119449", "0.68774784", "0.6872807", "0.6872807", "0.6767177", "0.6740289", "0.67216414", "0.6694622", "0.66614085", "0.65831244", "0.6548067", "0.6539639", "0.6518462", "0.651116", "0.6498799", "0.64806175", "0.64806175", "0.6465556", "0.6463639", "0.6463639", "0.6443175"...
0.0
-1
Count the English words in the text.
def stats_text_en(text): text1 = text.replace(',','').replace('.','').replace('--','').replace('*','').replace('!','') # Remove the non-English characters in the text. text2 = text1.split() # Convert the string type to the list type. dict = {x: text2.count(x) for x in text2} # Count the times of each word i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_words(text, words):\n count = 0\n for word in words: # probably should make words lowercase too\n if word in text.lower():\n count += 1\n return count", "def words(text):\n text = \" \".join(text) if text else 'We are the knights who say \"NI\"!'\n xml.words(text)\n ...
[ "0.756502", "0.7395247", "0.732852", "0.7287503", "0.7223627", "0.72082", "0.7154964", "0.7138416", "0.7136877", "0.7136265", "0.7134452", "0.709624", "0.70858365", "0.70343", "0.7027962", "0.70045686", "0.68842417", "0.68763244", "0.68743664", "0.6860438", "0.6851171", "0....
0.6403258
63
Count the Chinese characters in the text.
def stats_text_cn(text): text1 = text.replace(',','').replace('.','').replace('--','').replace('*','').replace('!','') # Remove the non-Chinese characters in the text. text2 = list(text1) # Convert the string type to the list type. dict = {x: text2.count(x) for x in text2} # Count the times of each characte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(text):\n return len(text)", "def test_character_count(self):\n\t\tself.assertEqual(analyse_text(self.filename)[1], 133)", "def getWordCharCount(w):\r\n rus = len(re.findall(r\"[а-я]\",w))\r\n eng = len(re.findall(r\"[a-z]\",w))\r\n c = len(w) \r\n return c, rus, eng", "def test_ch...
[ "0.67015", "0.6607649", "0.6606629", "0.6590809", "0.65797144", "0.6475554", "0.6430852", "0.61501974", "0.6050413", "0.60285336", "0.6015077", "0.59781206", "0.5967439", "0.5922929", "0.5896226", "0.58794916", "0.585383", "0.58402056", "0.5804242", "0.57875055", "0.5774597",...
0.6177398
7
Load movie details and ranking from csv file to database.
def load_movies_details(): data = pd.read_csv(CSV_PATH + MOVIES_DETAILS_CSV_NAME).T.to_dict() #Insert directors to database for i in range(len(data)): director_name = data[i]['Director'] director_exist = Director.query.filter(Director.name == director_name).first() if not director_ex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_ratings_data(connection, csvfile):\n insert_sql = 'insert into ratings (userId, movieId, rating, timestamp) ' \\\n 'values (%s, %s, %s, %s)'\n load_data(connection, insert_sql, get_data_from_file(csvfile))", "def load_records():\n\n with open('seed_data/records.csv', 'rb') as cs...
[ "0.7449447", "0.7045075", "0.697231", "0.6925202", "0.6890127", "0.6758247", "0.6721577", "0.66272926", "0.6552087", "0.65332365", "0.6506688", "0.6401783", "0.6366583", "0.6349926", "0.6347025", "0.6312729", "0.624575", "0.6232512", "0.6219035", "0.62042195", "0.62028986", ...
0.77248156
0
Load movie cast from csv file to database
def load_movies_cast(): data = pd.read_csv(CSV_PATH + MOVIES_CAST_CSV_NAME).T.to_dict() for i in range(len(data)): name = data[i]['Cast'] cast_exist = Cast.query.filter(Cast.name == name).first() if not cast_exist: db.session.add(Cast(name=name)) db.session.commit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_ratings_data(connection, csvfile):\n insert_sql = 'insert into ratings (userId, movieId, rating, timestamp) ' \\\n 'values (%s, %s, %s, %s)'\n load_data(connection, insert_sql, get_data_from_file(csvfile))", "def load_movies():\n filepath = \"./seed_data/u.item\"\n movies = o...
[ "0.6801924", "0.67638457", "0.6730367", "0.65531254", "0.6460458", "0.6447328", "0.64101523", "0.6394198", "0.63643944", "0.6338704", "0.629535", "0.6241045", "0.624032", "0.6213262", "0.6189707", "0.60986936", "0.6065023", "0.60348296", "0.59879386", "0.5985728", "0.5954525"...
0.74498796
0
Load movie reviews to database
def load_movies_reviews(): data = pd.read_csv(CSV_PATH + MOVIES_REVIEWS_CSV_NAME).T.to_dict() for i in range(len(data)): movie_id = Movies.query.filter(Movies.title == data[i]['Title'].strip()).first().id review = data[i]['Reviews'].strip() rating = float(data[i]['Rating'])*100000 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_movies():\n print \"Movies\"\n\n # Delete all rows in table, so if we need to run this a second time,\n # we won't be trying to add duplicate users\n Movie.query.delete()\n\n # Read u.item file and insert data\n for row in open(\"seed_data/u.item\"):\n row =row.rstrip()\n\n ...
[ "0.67932075", "0.67891663", "0.6626961", "0.65537125", "0.64071196", "0.63042593", "0.6298705", "0.62060344", "0.618357", "0.6129251", "0.6100108", "0.6071276", "0.5998696", "0.5919214", "0.59152097", "0.58447194", "0.5771323", "0.5766531", "0.575739", "0.5706212", "0.5703885...
0.8098433
0
Set path to csv files and run load functions
def run_load(rootpath): global CSV_PATH CSV_PATH = rootpath+'/csv_files/' load_movies_details() load_movies_cast() load_movies_reviews()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadCSV(input_file):", "def runs_loader(path):\n files = sorted(glob.glob(f\"{path}/*_runs.csv\"))\n df_lis = list(range(len(files)))\n for i, f in enumerate(files):\n try:\n df_lis[i] = pd.read_csv(f, sep=\",\", header=0)\n print('Read runs.csv\\n', f, df_lis[i].shape,\...
[ "0.69244933", "0.67308754", "0.67234784", "0.6704039", "0.6694249", "0.66542995", "0.66303647", "0.6621924", "0.66083246", "0.6604463", "0.6528164", "0.64278746", "0.6407914", "0.6399219", "0.63922846", "0.63281393", "0.631288", "0.62899953", "0.6281878", "0.6277048", "0.6274...
0.79588497
0
Retorna un diccionario con los datasets preprocesados con los datos y dimensiones que se usaron para el entrenamiento
def get_datasets(self): d = { "X_train": self._X_train, "Y_train": self._Y_train, "X_test": self._X_test, "Y_test": self._Y_test } return d
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datasets(self):\n return [Dataset.GWAS_CATALOG, Dataset.CLINVAR, Dataset.EFO]", "def datasets(self):\n pass", "def _make_data(self):\n pdf_datasets_all = make_pdf_datasets(self.pdf_list, self.xlims, self.ylims, self.tlims, self.dims, 9)\n self.pdf_dataset = np.concatenate(pdf_datase...
[ "0.6671411", "0.6404104", "0.6264915", "0.62294483", "0.622176", "0.62013185", "0.617189", "0.61432046", "0.6141271", "0.6138427", "0.6115273", "0.60832447", "0.607213", "0.60291106", "0.5988424", "0.5970424", "0.59659386", "0.59249663", "0.5911525", "0.5902017", "0.5898007",...
0.6099431
11
Test generation of plot with no data.
def test_none(self): arr = np.empty(0) out = ternary(arr) self.assertTrue(hasattr(out, "tax")) self.assertEqual( type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_arguments(self):\n fig = plt.figure()\n ax = fig.add_subplot(projection='ternary')\n lines = ax.plot()\n assert lines == []", "def createBlankPlot(self):\n\n fig = plt.figure(figsize=(8,6),dpi=80)\n fig.set_facecolor('#ededed')\n \n # Fo...
[ "0.7609084", "0.6816808", "0.66936296", "0.66777843", "0.6663347", "0.65976924", "0.6582688", "0.6567662", "0.6511319", "0.64886546", "0.64844465", "0.64685977", "0.64488363", "0.64084977", "0.63887763", "0.63578564", "0.62796795", "0.6261779", "0.62349313", "0.61744386", "0....
0.6133566
22
Test generation of plot with one record.
def test_one(self): arr = self.arr[0, :] out = ternary(arr) self.assertTrue(hasattr(out, "tax")) self.assertEqual( type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_arguments(self):\n fig = plt.figure()\n ax = fig.add_subplot(projection='ternary')\n lines = ax.plot()\n assert lines == []", "def test_simple(make_plots=False):\n # Define the example you want to investigate:\n r1 = GeneralRandom(np.arange(10), np.ones(10), 100)\n ...
[ "0.6329359", "0.61672544", "0.61622024", "0.61364275", "0.60747933", "0.6057145", "0.6053245", "0.6022652", "0.6009944", "0.5995569", "0.5983206", "0.59383214", "0.5913021", "0.5901215", "0.58947605", "0.5890802", "0.5870688", "0.58670944", "0.5838515", "0.58308023", "0.57880...
0.0
-1
Test generation of plot with multiple records.
def test_multiple(self): arr = self.arr out = ternary(arr) self.assertTrue(hasattr(out, "tax")) self.assertEqual( type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_plots(self):\n args = [\"L1\", 1126259446, 1126259478]\n pesummary_data = StrainData.fetch_open_data(*args)\n fig = pesummary_data.plot(type=\"td\")\n assert isinstance(fig, matplotlib.figure.Figure)\n fig = pesummary_data.plot(type=\"fd\")\n assert isinstance(fig...
[ "0.6692694", "0.65136224", "0.6225085", "0.6177012", "0.61736137", "0.6115239", "0.6057502", "0.60464275", "0.600434", "0.59977597", "0.5966004", "0.5965175", "0.59394974", "0.5924932", "0.5902497", "0.5889018", "0.5888861", "0.5861486", "0.5843025", "0.58387065", "0.5828392"...
0.0
-1
Test use of the plot for multiple rounds of plotting.
def test_overplotting(self): arr = self.arr out = ternary(arr) self.assertTrue(hasattr(out, "tax")) out2 = ternary(arr, ax=out) self.assertTrue(out.tax is out2.tax) # hasn't added a new ternary axis
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_arguments(self):\n fig = plt.figure()\n ax = fig.add_subplot(projection='ternary')\n lines = ax.plot()\n assert lines == []", "def testPlots(self):\n\t\tself.watcher.analyze(layers=[67], plot=True, randomize=True)", "def is_plot(session_id, test_name):\n return Plot.i...
[ "0.7026185", "0.6984847", "0.6861085", "0.68187106", "0.66684294", "0.66039294", "0.6592579", "0.6585846", "0.6579815", "0.6548062", "0.652497", "0.65162027", "0.6512265", "0.6506942", "0.6480511", "0.6476601", "0.642403", "0.6379334", "0.6376706", "0.6374267", "0.63410354", ...
0.0
-1
Check than array of values specified using `c` can be used for a colormap.
def test_color_cmap_c_combination(self): arr = self.arr out = ternary(arr, c=np.linspace(0, 10, 10), cmap="viridis") self.assertTrue(hasattr(out, "tax")) self.assertEqual( type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_color(c):\n\n c = asarray(c)\n if c.ndim == 1:\n c = c.flatten()\n c = c[newaxis, :]\n if c.shape[1] != 3:\n raise Exception(\"Color must have three values per point\")\n elif c.ndim == 2:\n if c.shape[1] != 3:\n raise Exception(\"Color array mus...
[ "0.7522997", "0.6399244", "0.6233486", "0.61515546", "0.5972068", "0.5734837", "0.5714697", "0.57047075", "0.56964606", "0.5671895", "0.5666058", "0.5661867", "0.5612082", "0.5578248", "0.5551499", "0.5532785", "0.5467735", "0.5461801", "0.54509157", "0.5412546", "0.5403892",...
0.6554897
1
Open the browser with a given url
def start(self): self.get(self.url)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(url):\r\n webbrowser.open(url)", "def openurl(url):\n\n # Open the URL\n webbrowser.open(url)", "def open_browser(url):\n import webbrowser\n webbrowser.open_new(url)", "def run(self, url=''):\n if url:\n webbrowser.open(url)", "def open_web_browser(url: str):\n ...
[ "0.8814151", "0.8780776", "0.8645748", "0.8425063", "0.840312", "0.82957417", "0.8293585", "0.8202446", "0.8182634", "0.807317", "0.80227995", "0.7954883", "0.7889085", "0.7871735", "0.78659695", "0.7851398", "0.7782722", "0.7771363", "0.7704575", "0.76670724", "0.76348335", ...
0.0
-1
Close the browser application if teardown is True once the program is done
def __exit__(self, *args): if self.teardown: super().__exit__(*args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _shutdown_browser(self):\n if self.browser:\n self.browser.close()", "def teardown(self):\n self.log.info('Close browser')\n self.driver.quit()", "def shutdown(self):\n self._shutdown_browser()", "def quit_browser(self):\n if self.browser is not None:\n ...
[ "0.76976466", "0.7533014", "0.7384081", "0.7353654", "0.722786", "0.7147601", "0.71396065", "0.7132546", "0.7085328", "0.70720464", "0.7060217", "0.7022492", "0.7019638", "0.699221", "0.6963776", "0.69455135", "0.694225", "0.6910812", "0.6864789", "0.6861963", "0.68549687", ...
0.0
-1
This method searching for the body html element, sends it to the Scraper class to find potencials popups and finally close them
def ads_breaker(self): try: self.find_element_by_xpath('/html/body').send_keys(Keys.ESCAPE) return except: pass html_element = self.find_element_by_xpath( '/html/body').get_attribute('outerHTML') soup = Scraper(html_element) targe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_popup_windows(chrome_driver, close_ele_class_names):\r\n\r\n for class_name in close_ele_class_names:\r\n close_ele = check_and_get_ele_by_class_name(chrome_driver, class_name) \r\n if close_ele:\r\n try:\r\n close_ele.click()\r\n time.sleep(1)\r\...
[ "0.5855956", "0.5506015", "0.5407686", "0.5332533", "0.53205526", "0.52699345", "0.5266626", "0.52550715", "0.5238747", "0.52184844", "0.51588637", "0.50889885", "0.50163907", "0.49882764", "0.4971992", "0.49317858", "0.49307364", "0.49163505", "0.48968342", "0.4895865", "0.4...
0.5718086
1
This method find and press the button that let interact with the placeholder input
def enable_search(self): html_element = self.find_element_by_xpath( '/html/body').get_attribute('outerHTML') soup = Scraper(html_element) elms_obj = soup.find_search_enable_btn() for tag, target in elms_obj.items(): if len(target) > 0: for elem i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def click_button(self):\n self.q(css='div#fixture input').first.click()", "def click_button(self):\n self.widgets.get('button').click()", "def click_button(self):\n self.q(css='div#fixture button').first.click()", "def OnButtonClick(self):\n self.choice()", "def click_search_but...
[ "0.734838", "0.67888856", "0.6648583", "0.6455985", "0.63376254", "0.6274271", "0.62640727", "0.62444234", "0.6182181", "0.6180678", "0.61756253", "0.6131169", "0.612632", "0.6001559", "0.59794873", "0.59794873", "0.59244543", "0.59162563", "0.58898365", "0.5882348", "0.58800...
0.0
-1
This method writes into the placelholder input and perform the searching depends on the KeyWord
def perform_search(self): self.implicitly_wait(5) html_element = self.find_element_by_xpath( '/html/body').get_attribute('outerHTML') soup = Scraper(html_element) target = soup.find_search_field() for elem in target: for attr, value in elem.items(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(self, word):", "def search(self, term):", "def search(self, search):\n raise NotImplementedError", "def search(self, key, headers=Headers()):", "def linear_search(key, my_list):\n key = word.upper()\n my_list = dictionary_list\n if key in my_list:\n ...
[ "0.61128235", "0.5776612", "0.5620736", "0.55137074", "0.54994845", "0.54782635", "0.5416303", "0.54147106", "0.54119146", "0.53961605", "0.5377432", "0.5369058", "0.5353079", "0.5327034", "0.53183806", "0.5302928", "0.52938366", "0.52867705", "0.5276512", "0.52595335", "0.52...
0.5663161
2
Forward method of GBasicBlock.
def forward(self, input): x = self.conv(input) x = self.bn(x) out = self.act(x) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self)->None:", "def forward_pass(self):", "def forward_graph(self):\n raise NotImplementedError", "def instructions(self):\n yield self.inst\n for inst in self.arguments[:]:\n yield inst\n for basic_block in self.basic_blocks[:]:\n if basic_block....
[ "0.5774737", "0.555397", "0.5548297", "0.5543329", "0.5361891", "0.5327962", "0.53224826", "0.53224826", "0.5233983", "0.5172225", "0.51550925", "0.51550925", "0.51550925", "0.51463526", "0.512089", "0.51039046", "0.5099798", "0.50980735", "0.50952184", "0.5092311", "0.504874...
0.0
-1
Forward method of DBlock.
def forward(self, x): x = self.conv(x) x = self.bn(x) x = self.act(x) return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self)->None:", "def forward_pass(self):", "def forward(self):\n raise NotImplemented", "def forward(self):\n raise NotImplemented", "def forward(self):\n raise NotImplemented", "def forward(self):\n pass", "def forward(self):\n pass", "def forward(self, ...
[ "0.65997905", "0.64111036", "0.6355572", "0.6355572", "0.6355572", "0.62218034", "0.62218034", "0.6202959", "0.59588075", "0.5919142", "0.5917902", "0.5877505", "0.5862478", "0.58489037", "0.58304656", "0.58129233", "0.58129233", "0.5806567", "0.57908845", "0.5771873", "0.571...
0.0
-1
Forward method of DBlock.
def forward(self, x): x = self.conv(x) x = self.bn(x) x = self.act(x) return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self)->None:", "def forward_pass(self):", "def forward(self):\n raise NotImplemented", "def forward(self):\n raise NotImplemented", "def forward(self):\n raise NotImplemented", "def forward(self):\n pass", "def forward(self):\n pass", "def forward(self, ...
[ "0.6604327", "0.6416254", "0.6361237", "0.6361237", "0.6361237", "0.6227416", "0.6227416", "0.62045956", "0.59616256", "0.59166807", "0.5916587", "0.5883928", "0.5860926", "0.5845776", "0.58363473", "0.5818138", "0.5818138", "0.58091307", "0.5787437", "0.57739675", "0.5714933...
0.0
-1
Return a list with 3 values, mean, var and standard deviation based on the input. The input is a list of lists and each list contains the value of a variable x and it's probability P(x).
def stats_disc_distr(ll): out = sanitize_input(ll) if out: return out avg = mean([l[0] for l in ll]) variance = sum([(l[0] - avg) ** 2 * l[1] for l in ll]) stddev = sqrt(variance) return [avg, variance, stddev]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def varlist(data):\n \n Bxm=data[\"Bx\"].mean()\n Bym=data[\"By\"].mean()\n Bzm=data[\"Bz\"].mean()\n Bxsqm=(data[\"Bx\"]**2).mean()\n Bysqm=(data[\"By\"]**2).mean()\n Bzsqm=(data[\"Bz\"]**2).mean()\n Bxym=(data[\"Bx\"]*data[\"By\"]).mean()\n Bxzm=(data[\"Bx\"]*data[\"Bz\"]).mean()\n ...
[ "0.6871232", "0.6794376", "0.6588522", "0.65758127", "0.6561726", "0.6561726", "0.64889044", "0.64831394", "0.6480755", "0.6479906", "0.64087665", "0.6356098", "0.62918633", "0.6272482", "0.6234549", "0.62317985", "0.61967415", "0.6176716", "0.6155198", "0.6139157", "0.613164...
0.5667719
67
Return an alert based on issues with dataset. Return None if no issue.
def sanitize_input(ll): p = sum([l[1] for l in ll]) if not all([l[0] == int(l[0]) for l in ll]): if round(p, 5) != 1: return "It's not a valid distribution and furthermore, one or more variable value are not integers" else: return "All the variable values should be intege...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alerts(self) -> 'outputs.DataConnectorDataTypeCommonResponse':\n return pulumi.get(self, \"alerts\")", "def alerts(self) -> 'outputs.DataConnectorDataTypeCommonResponse':\n return pulumi.get(self, \"alerts\")", "def alert(self, msg):\n raise DatacheckException(msg)", "def test_get_al...
[ "0.5836452", "0.5836452", "0.57839143", "0.5517184", "0.550835", "0.5453221", "0.5443088", "0.5355255", "0.531749", "0.52588034", "0.5253947", "0.5220902", "0.51864874", "0.5159308", "0.51587635", "0.5145311", "0.5140701", "0.51140285", "0.51136297", "0.50931454", "0.5091789"...
0.0
-1
Initializes the `ImageSearcher` object.
def __init__(self, options: ImageSearcherOptions, cpp_searcher: _CppImageSearcher) -> None: # Creates the object of C++ ImageSearcher class. self._options = options self._searcher = cpp_searcher
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initImages(self):\n pass", "def initImages(self):\n pass", "def initImages(self):\n pass", "def initialize(self):\n for path in self._paths:\n for root, dirnames, filenames in os.walk(os.path.expanduser(path)):\n if self._is_in_excluded_patterns(root)...
[ "0.6192012", "0.6192012", "0.6192012", "0.5984795", "0.59554297", "0.5908261", "0.58379114", "0.5573122", "0.54988146", "0.54773754", "0.5456339", "0.54226214", "0.5420283", "0.5420283", "0.5420283", "0.54042417", "0.5379169", "0.5376522", "0.53504145", "0.53011996", "0.52807...
0.7267351
0
Creates the `ImageSearcher` object from a TensorFlow Lite model.
def create_from_file( cls, model_file_path: str, index_file_path: Optional[str] = None) -> "ImageSearcher": options = ImageSearcherOptions( base_options=_BaseOptions(file_name=model_file_path), search_options=_SearchOptions(index_file_name=index_file_path)) return cls.create_fr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_from_model_path(cls, model_path: str) -> 'FaceDetector':\n base_options = _BaseOptions(model_asset_path=model_path)\n options = FaceDetectorOptions(\n base_options=base_options, running_mode=_RunningMode.IMAGE\n )\n return cls.create_from_options(options)", "def from_pretrained(\n ...
[ "0.58416957", "0.57176334", "0.5706374", "0.54603827", "0.54595345", "0.5452045", "0.5437048", "0.5412006", "0.53853303", "0.5357966", "0.53444433", "0.53190815", "0.53147674", "0.5314517", "0.53105253", "0.5305688", "0.5271952", "0.51935625", "0.5188544", "0.51859486", "0.51...
0.5662296
3
Creates the `ImageSearcher` object from image searcher options.
def create_from_options(cls, options: ImageSearcherOptions) -> "ImageSearcher": searcher = _CppImageSearcher.create_from_options( options.base_options.to_pb2(), options.embedding_options.to_pb2(), options.search_options.to_pb2()) return cls(options, searcher)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, options: ImageSearcherOptions,\n cpp_searcher: _CppImageSearcher) -> None:\n # Creates the object of C++ ImageSearcher class.\n self._options = options\n self._searcher = cpp_searcher", "def create_search_agent(opt):\n logging.info('Initializing the search engine API....
[ "0.78471154", "0.6055885", "0.57526535", "0.5699698", "0.5563751", "0.54936445", "0.5071097", "0.49560168", "0.49559525", "0.49472928", "0.48358572", "0.48286322", "0.48202154", "0.4785771", "0.47675824", "0.4759022", "0.4755689", "0.47328192", "0.47293845", "0.4693368", "0.4...
0.86626315
0
Search for image with similar semantic meaning. This method performs actual feature extraction on the provided image input, followed by nearestneighbor search in the index.
def search( self, image: tensor_image.TensorImage, bounding_box: Optional[bounding_box_pb2.BoundingBox] = None ) -> search_result_pb2.SearchResult: image_data = image_utils.ImageData(image.buffer) if bounding_box is None: search_result = self._searcher.search(image_data) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(image):\n keypoint, description = describe(image)\n # load keypoints, descriptions from mongodb\n\n bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)\n\n best_match_size = float(\"inf\")\n best_match_index = -1\n match_index = 0\n best_matches = 0\n\n for desc in descriptions:\n matches = b...
[ "0.6451769", "0.62518466", "0.57253426", "0.56970763", "0.5691431", "0.5681311", "0.5668041", "0.5659972", "0.5595712", "0.5579953", "0.5579004", "0.55647737", "0.55389416", "0.55309933", "0.549853", "0.5484147", "0.54750353", "0.5473008", "0.5466614", "0.5465689", "0.5465529...
0.54816175
16
Gets the user info stored in the index file.
def get_user_info(self) -> str: return self._searcher.get_user_info()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_info(self):\n response = self.query('user_info')\n return response", "def userinfo(self):\n return self._userinfo", "def get_users_info(): \n \n data = user_obj.get_users_info()\n return data", "def getUserInfo(self):\r\n userJson = self.httpGet(ReaderUrl.USER_IN...
[ "0.7138062", "0.6822024", "0.67177176", "0.66358757", "0.6631659", "0.6545722", "0.6526983", "0.64795595", "0.6454526", "0.6445177", "0.64245903", "0.6411693", "0.63946784", "0.6389253", "0.63816994", "0.63520616", "0.63245225", "0.6322499", "0.63019735", "0.6295263", "0.6294...
0.73406935
0
Parse individual XML node of tenhou mjlog.
def parse_node(tag, attrib): attrib = _ensure_unicode(attrib) _LG.debug('Input: %s: %s', tag, attrib) if tag == 'GO': data = _parse_go(attrib) elif tag == 'UN': if len(attrib) == 1: # Disconnected player has returned data = _parse_resume(attrib) tag = 'RESUME' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_mjlog(root_node, tags=None):\n parsed = []\n for node in root_node:\n if tags is None or node.tag in tags:\n parsed.append(parse_node(node.tag, node.attrib))\n if tags is None:\n return _structure_parsed_result(parsed)\n return parsed", "def parse_data(self):\n\n ...
[ "0.63436925", "0.5991037", "0.589507", "0.58766764", "0.557865", "0.5562476", "0.5479781", "0.5442065", "0.5360911", "0.535035", "0.535035", "0.5342198", "0.53344345", "0.5331019", "0.5309822", "0.5304942", "0.52802145", "0.5252274", "0.524329", "0.52382", "0.51949924", "0....
0.0
-1
Add structure to parsed log data
def _structure_parsed_result(parsed): round_ = None game = {'meta': {}, 'rounds': []} for item in parsed: tag, data = item['tag'], item['data'] if tag in ['SHUFFLE', 'GO', 'UN', 'TAIKYOKU']: game['meta'][tag] = data elif tag == 'INIT': if round_ is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self):\n i = 0\n while i < len(self.__lines):\n line = self.__lines[i]\n dt = re.match(r\"(\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{1,2}:\\d{1,2}:\\d{1,2})\", line)\n if not dt:\n i += 1\n continue\n log = {\n \"...
[ "0.6610051", "0.63896686", "0.62429035", "0.62339944", "0.59618556", "0.5932174", "0.5882088", "0.58768266", "0.5844139", "0.5838278", "0.58178926", "0.58111024", "0.57485765", "0.56898296", "0.5678948", "0.55919254", "0.5583621", "0.5563657", "0.5561133", "0.55542564", "0.55...
0.0
-1
Convert mjlog XML node into JSON
def parse_mjlog(root_node, tags=None): parsed = [] for node in root_node: if tags is None or node.tag in tags: parsed.append(parse_node(node.tag, node.attrib)) if tags is None: return _structure_parsed_result(parsed) return parsed
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xml_to_json(xml_doc) -> str:\n\n json_doc = \"\"\n return json.dumps(json_doc)", "def _to_json(content):\n\t\treturn json.loads(json.dumps(xmltodict.parse(content)))", "def xml_to_json(xml):\n\n logging.debug(\"-> xml_to_json()\")\n\n xml_as_dict = xmltodict.parse(xml)\n xml_as_json = json.d...
[ "0.6393545", "0.6216957", "0.6147134", "0.59435886", "0.55668646", "0.54777443", "0.54198986", "0.52458364", "0.5229408", "0.5208654", "0.51894504", "0.5185886", "0.5169987", "0.516828", "0.51137316", "0.508911", "0.5042797", "0.50369984", "0.5031812", "0.5017571", "0.4979799...
0.5099465
15
Read and retrieve all genuine files from evalution key.
def eval_genuine(path): out = [] with open(path, 'r') as fp: for line in fp: fields = line.rstrip().split() ii, tt = fields[:2] if tt == 'genuine': out.append(ii[2:-4]) # remove 'D_' and '.wav' return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_file_contents(self, key):\n f = open( os.path.join(self.file_path, '%s.xoj' % key))\n data = f.read()\n f.close()\n return data", "def _ReadEntries(self):\n scope = {}\n filename = os.path.join(self._root_dir, self._options.entries_filename)\n if not os.path.exists(fi...
[ "0.6407927", "0.62431353", "0.6014391", "0.5953875", "0.5945899", "0.5917298", "0.5885158", "0.58205056", "0.5795418", "0.5773138", "0.5768724", "0.57207376", "0.5699629", "0.56914234", "0.56907296", "0.5624163", "0.5620057", "0.5610694", "0.55591106", "0.555816", "0.5552543"...
0.5241684
63
Return True if `path` is pointing to a genuine audio. `evalkey` must not be empty if path points to an evaluation file.
def is_genuine(path, evalkey=None): iid = os.path.basename(path)[:-4] tt, ii = iid.split('_') if tt == 'T': # training return (int(ii) <= 1001508) elif tt == 'D': # development return (int(ii) <= 1000760) elif tt == 'E': # evaluation return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def good_filepath(path):\n return str(path).endswith(\".wav\") and (not str(path).startswith(\".\"))", "def is_valid(path):\n return (\n bool(path)\n and os.path.isabs(path)\n and os.path.exists(path)\n and (not is_apple() or path.endswith(\".dylib\"))\n )", "def Valida...
[ "0.558747", "0.52809876", "0.52377313", "0.50975066", "0.50592226", "0.5046655", "0.50263387", "0.49985436", "0.49946505", "0.49753332", "0.4958943", "0.4958355", "0.48810974", "0.4860872", "0.48376176", "0.4824684", "0.481506", "0.4802418", "0.4767467", "0.4759725", "0.47442...
0.7245087
0
Instantiate an ASVspoof dataset.
def __init__(self, root, partition, filt=None, read=None, transform=None): self._evalkey = None if partition == 'train': root = os.path.join(root, 'ASVspoof2017_V2_train') elif partition == 'valid': root = os.path.join(root, 'ASVspoof2017_V2_dev') elif partition =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, dataset):\n self._dataset = dataset", "def __init__(self, dataset: Dataset):\n self.dataset = dataset", "def __init__(self, data, v1, v2):\n self.data = data\n self.v1 = v1\n self.v2 = v2", "def _create_dataset(source=''):\n return ExperimentalData...
[ "0.56661063", "0.5572199", "0.55397993", "0.5510062", "0.54108816", "0.53719366", "0.5366002", "0.5346476", "0.5346476", "0.5341396", "0.5331791", "0.5322447", "0.53083295", "0.53056693", "0.5285903", "0.52816117", "0.52505565", "0.5217569", "0.5214454", "0.5191689", "0.51868...
0.5287663
14
Print out a summary of instantiated dataset.
def __str__(self): genuine, replay = 0, 0, for pp in self._filepaths: if self.is_genuine(pp, self._evalkey): genuine += 1 else: replay += 1 report = """ +++++ Summary for [{}] partition [{}] +++++ Total [{}] valid fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataset_statistics(dataset):\n print (dataset.describe())", "def dataset_statistics(dataset):\n print(dataset.describe())", "def dataset_statistics(dataset):\n print(dataset.describe())", "def print_summary(self):\n self.model.summary()", "def printSummary(self):\n pass", "def ...
[ "0.7620119", "0.7570994", "0.7570994", "0.75312674", "0.73672444", "0.7157839", "0.7076454", "0.7031242", "0.701747", "0.69912547", "0.69862425", "0.687568", "0.68725806", "0.6824253", "0.68016654", "0.6780475", "0.6779421", "0.67729473", "0.67296386", "0.6724442", "0.6701536...
0.0
-1
Return a list of (start, end) tuples.
def parse_regions(text): _regions = [] region_pairs = text.strip().split(",") for region_pair in region_pairs: split_pair = region_pair.split("..") start = split_pair[0] end = split_pair[1] _regions.append([start, end]) return _regions
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range(self):\n return (self._start, self._end)", "def endpoint(self):\n return (self._start, self._end)", "def getRange (start, stop, step=1):\r\n result = [n for n in range(start, stop, step)]\r\n return result", "def get_items(self):\n return (self._start._value, self...
[ "0.78692144", "0.72173995", "0.6941367", "0.69413435", "0.69286436", "0.6818113", "0.6817595", "0.6778776", "0.676874", "0.6727795", "0.6668462", "0.6638845", "0.6610449", "0.66077703", "0.6581024", "0.6579434", "0.65579057", "0.65369064", "0.6501064", "0.64417356", "0.642692...
0.0
-1
Loads a configuration from an environment variable pointing to a configuration file. This is basically just a shortcut with nicer
def from_envvar(self, variable_name, silent=False): rv = os.environ.get(variable_name) if not rv: if silent: return False raise RuntimeError('The environment variable %r is not set ' 'and as such configuration could not be ' 'loaded. Set this variable and make it ' 'point to...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_config(env_file_path: str) -> None:\n if os.path.isfile(env_file_path):\n load_dotenv(dotenv_path=env_file_path)\n else:\n logger.info(f\".env file does not exist on {env_file_path}. Loading environment variable from the machine\")", "def load_settings(env=\"prod\"):\n global conf...
[ "0.74765843", "0.74600065", "0.74470395", "0.7430562", "0.7397101", "0.7353322", "0.72494924", "0.7222283", "0.7202781", "0.71942145", "0.70727456", "0.6914294", "0.6894895", "0.68913084", "0.68873185", "0.68520534", "0.6797871", "0.6778612", "0.6776017", "0.67610717", "0.675...
0.7465972
1
Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the
def from_pyfile(self, filename, silent=False): d = imp.new_module('config') d.__file__ = filename try: with open(filename) as config_file: exec(compile(config_file.read(), filename, 'exec'), d.__dict__) except IOError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return False e.s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_from_file(self):\n config_path = os.environ.get('MINDINSIGHT_CONFIG', '')\n if not config_path:\n return\n\n config_module = None\n\n # python:full.path.for.config.module\n if config_path.startswith('python:'):\n config_module = import_module(conf...
[ "0.7930393", "0.6657532", "0.62681234", "0.6265737", "0.6235369", "0.6214324", "0.61882865", "0.61763245", "0.6150934", "0.6121705", "0.61105233", "0.6064256", "0.6056257", "0.60427046", "0.5996634", "0.59717363", "0.59664863", "0.59571403", "0.59542716", "0.5950885", "0.5936...
0.6150592
9
Updates the values from the given object. Objects are usually either modules or classes. Just the uppercase variables in that object are stored in the config.
def from_object(self, obj): for key in dir(obj): if key.isupper(): self[key] = getattr(obj, key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, obj):\n\n self.cfg.update(obj)", "def from_object(self, obj):\n\t\tif isinstance(obj, str):\n\t\t\tobj = import_string(obj)\n\t\tfor key in dir(obj):\n\t\t\tif key.isupper():\n\t\t\t\tself[key] = getattr(obj, key)", "def update(self, env_obj):\n if env_obj:\n if isinst...
[ "0.6770962", "0.67110604", "0.6181471", "0.61151075", "0.58846617", "0.5866331", "0.576626", "0.5695668", "0.56116134", "0.56006634", "0.5585324", "0.5553532", "0.5518967", "0.5508411", "0.5482127", "0.5482127", "0.53774625", "0.5366863", "0.5363507", "0.5338579", "0.53357744...
0.63983315
2
Updates the values in the config from a JSON file. This function behaves as if the JSON object was a dictionary and passed ot the
def from_json(self, filename, silent=False): try: with open(filename) as json_file: obj = json.loads(json_file.read()) except IOError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return False e.strerror = 'Unable to load configuration file (%s)' % e.strerror raise for key in o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_from_json(self, filename):\n with open(filename, 'r') as f:\n config = json.load(f)\n config = self._process_config_imports(config)\n self.config.update(config)", "def update(self, json_path):\n with open(json_path) as f:\n params = json.load(f)\n ...
[ "0.76795405", "0.75639147", "0.75639147", "0.75639147", "0.75639147", "0.75639147", "0.75639147", "0.72586745", "0.6951214", "0.69304234", "0.6862702", "0.67505485", "0.67290086", "0.6702236", "0.66978353", "0.66320515", "0.6591957", "0.65346813", "0.6519624", "0.65131783", "...
0.6561453
17
Function to to import data into customer table and return success and error count for inserts
def import_customers(input_data): error_count = 0 insert_count = 0 LOGGER.info('Starting Customer import') for onecust in input_data: try: Customer(onecust['user_id'], onecust['first_name'], onecust['last_name'], onecust['address'], onecust['phone_number'], onecu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import(self):\n\n database.delete_database()\n\n #Fully successful import\n actual_tuples1 = database.import_data('csvs', 'product_data.csv', 'customer_data.csv',\n 'rentals_data.csv')\n expected_tuples1 = ((1, 1, 1), (0, 0, 0))\n ...
[ "0.6880175", "0.6587729", "0.6475325", "0.63756824", "0.635704", "0.61101794", "0.59374183", "0.59222734", "0.584351", "0.57974064", "0.5794389", "0.5749154", "0.5666902", "0.56425035", "0.56202424", "0.5606056", "0.5592512", "0.5570438", "0.5553956", "0.5546706", "0.5538326"...
0.78119606
0
Function to to import data into products table and return success and error count for inserts
def import_products(input_data): error_count = 0 insert_count = 0 LOGGER.info('Starting product import') for oneprod in input_data: try: Product(oneprod['product_id'], oneprod['description'], oneprod['product_type'], oneprod['quantity']).save(full_clean=True, forc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import(self):\n\n database.delete_database()\n\n #Fully successful import\n actual_tuples1 = database.import_data('csvs', 'product_data.csv', 'customer_data.csv',\n 'rentals_data.csv')\n expected_tuples1 = ((1, 1, 1), (0, 0, 0))\n ...
[ "0.7205454", "0.6843036", "0.6732004", "0.6323785", "0.625654", "0.62170696", "0.6186297", "0.61729926", "0.61049217", "0.6082726", "0.60693866", "0.6066227", "0.6065975", "0.6064503", "0.60631615", "0.5999859", "0.5967927", "0.5964014", "0.59577274", "0.5945393", "0.59418017...
0.79316103
0
Function to to import data into rental table and return success and error count for inserts
def import_rentals(input_data): error_count = 0 insert_count = 0 LOGGER.info('Starting rental import') for onerent in input_data: try: Rental(onerent['rental_id'], onerent['user_id'], onerent['product_id']).save(full_clean=True, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import(self):\n\n database.delete_database()\n\n #Fully successful import\n actual_tuples1 = database.import_data('csvs', 'product_data.csv', 'customer_data.csv',\n 'rentals_data.csv')\n expected_tuples1 = ((1, 1, 1), (0, 0, 0))\n ...
[ "0.62678164", "0.62354636", "0.62039506", "0.61935264", "0.6193359", "0.6156778", "0.6081947", "0.5987708", "0.59412384", "0.57262313", "0.5705593", "0.5682023", "0.5644518", "0.562816", "0.5627879", "0.56163913", "0.55966115", "0.55852526", "0.5581225", "0.5578956", "0.55618...
0.7651243
0
Reads a csv file and return a list of dictionary objects from the file
def read_csv_file(in_file): out_list = [] with open(in_file, 'r', newline='') as p_file: file_list = csv.DictReader(p_file, delimiter=',') for row in file_list: out_list.append(row) return out_list #thequeue.put(out_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_csv(path: str) -> list[dict[str, str]]:\n with open(path, 'r') as f:\n return list(csv.DictReader(f))", "def _read_csv_to_dictionary_list(file_name):\n catalog_list = []\n with open(file_name) as csvfile:\n reader = csv.DictReader(csvfile)\n for item in reader:\n catal...
[ "0.8055223", "0.7994276", "0.7939735", "0.77738434", "0.769351", "0.766648", "0.76644385", "0.76583725", "0.7640625", "0.7617462", "0.75656545", "0.75031126", "0.74916476", "0.7490433", "0.74514294", "0.7429478", "0.7425645", "0.7415221", "0.7412361", "0.7407528", "0.74033254...
0.65221894
96
This function takes a directory name three csv files as input, one with product data, one with customer data and the third one with rentals data and creates and populates a
def import_data(directory_name, product_file, customer_file, rentals_file): start = time.time() prdt_file = os.path.join(directory_name, product_file) cust_file = os.path.join(directory_name, customer_file) rent_file = os.path.join(directory_name, rentals_file) csvfiles = [prdt_file, cust_file, ren...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_data(dir_name, product_file, customer_file, rentals_file):\n client = MongoDBConnection()\n with client:\n LOGGER.info('Create A MongoDB database')\n hp_norton_db = client.connection.rental\n hp_norton_db.products.drop()\n hp_norton_db.customers.drop()\n hp_norto...
[ "0.737858", "0.7335672", "0.7120314", "0.70489734", "0.6846601", "0.67960274", "0.6598609", "0.6519752", "0.64735085", "0.6414777", "0.6379199", "0.61592174", "0.602735", "0.5910841", "0.5905573", "0.58653945", "0.58278537", "0.5777576", "0.5713795", "0.5705191", "0.5682086",...
0.6151677
12
Transforms a code block into another one to show the connections
def transform_code(self, start, end, mat, highlight=True): def elms(item, coord): return item[coord[0]][coord[1]] if isinstance(coord, tuple) else item[coord] for entry in mat: if highlight: instantiate_highlight = SurroundingRectangle(elms(start, entry[0][0]), bu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code():", "def _wrap_code(self, inner):\r\n yield 0, \"<code>\"\r\n for tup in inner:\r\n yield tup\r\n yield 0, \"</code>\"", "def block_code(self, code, lang=None):\n code = code.rstrip('\\n')\n return [\"<code>\"] + code", "...
[ "0.59630436", "0.58044785", "0.56429017", "0.5612836", "0.55475295", "0.55050194", "0.54975176", "0.5452256", "0.5361068", "0.5346683", "0.5345057", "0.53445274", "0.5304266", "0.5297774", "0.52917486", "0.5278755", "0.5259864", "0.5249564", "0.52428204", "0.51822656", "0.517...
0.0
-1
Performs the forward pass for the arms of the Siamese Neural Network.
def forward_once(self, inputs, inputs_lens = None): # Determination of batch size batch_size = inputs.size(0) # Initialisation of hidden states h0 = self.initialise_hidden(batch_size) if self._embedding_dimensions is not None: embedded_inputs = self.embeddin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, xs):\n\n xs = torch.split(xs, self.channel, -1)# list of batch, node, featdim\n xs = torch.stack(xs,2)#[batch, nodes, num_layers, num_channels]\n shape = xs.shape\n x = xs.reshape((-1,shape[2],shape[3])) # [ngraph * num_nodes , num_layers, num_channels]\n alpha...
[ "0.5942198", "0.59067345", "0.5743013", "0.57251894", "0.57186717", "0.57123905", "0.57045513", "0.56750274", "0.56567764", "0.5613595", "0.5606602", "0.560122", "0.55987453", "0.5574207", "0.55480045", "0.55472565", "0.5543803", "0.5511937", "0.5505923", "0.55036813", "0.550...
0.0
-1
Performs the computation of the last hidden states of the two inputs in parallel.
def forward(self, inputs1, inputs2, inputs1_lens = None, inputs2_lens = None, labels = None, predict = False): if self._is_mlp: output1 = self.mlp(inputs1.float()) output2 = self.mlp(inputs2.float()) else: output1 = self.forward_once(inputs1, inputs1_lens) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, inputs, states):\r\n (out_prev, Vm_prev) = states\r\n\r\n #Vm = Vm_prev * (1.0 - out_prev)\r\n #Lateral inhibition logic:\r\n Vm = Vm_prev * (1.0 - tf.reduce_max(out_prev))\r\n\r\n Vm = Vm * self.decay\r\n Vm = Vm + tf.matmul(inputs, self.kernel)\r\n ...
[ "0.6570047", "0.61648476", "0.6162371", "0.6110056", "0.60850364", "0.6008825", "0.60084426", "0.5984341", "0.59347737", "0.5924735", "0.5818022", "0.58157426", "0.5800721", "0.5784431", "0.57624656", "0.57527184", "0.5741885", "0.5721153", "0.56869733", "0.5669856", "0.56659...
0.0
-1
Energy function. Estimates the distance between the two outputs of the Siamese Neural Network according to a given distance metric.
def distance_layer(self, output1, output2, distance): # Check definition in http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf # Redefined with L1 as per http://yann.lecun.com/exdb/publis/pdf/chopra-05.pdf if self._loss == 'contrastive loss': distance = 'l1' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def energy_func(self):\n return (\n self.inl[0].m.val_SI * (\n self.outl[0].h.val_SI - self.inl[0].h.val_SI) +\n self.inl[1].m.val_SI * (\n self.outl[1].h.val_SI - self.inl[1].h.val_SI))", "def energy_func(self):\n i = self.inl[0].to_flow()\n ...
[ "0.6702598", "0.6482071", "0.63231647", "0.6280572", "0.6242269", "0.6224302", "0.6212535", "0.618072", "0.61790943", "0.6144905", "0.6110105", "0.60883135", "0.6077008", "0.6064307", "0.59443134", "0.59062725", "0.58995855", "0.5882233", "0.586689", "0.58543587", "0.58452326...
0.58075607
24
Computes the specified loss function.
def get_loss(self, outputs, labels): try: assert self._loss in ['mse','mae','l1','l2','huber','logcosh','bce','contrastive'], 'Specify correct loss function' except AssertionError as msg: sys.exit(msg) if self._loss == 'mse' or self._loss == 'l2': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loss_fn(self, targets, outputs, model):", "def loss(self, x, y):\n\n return self.loss_fn(x, y)", "def compute_loss(self, **kwargs):\n raise NotImplementedError", "def compute_loss(self, *args, **kwargs):\n raise NotImplementedError", "def compute_loss(self, features, mode, params, ...
[ "0.76312494", "0.75961566", "0.75804543", "0.7543746", "0.7502086", "0.74650234", "0.7456467", "0.74020696", "0.7317796", "0.72831196", "0.72803336", "0.727307", "0.7231247", "0.7183014", "0.71535593", "0.713331", "0.708863", "0.70281285", "0.7025106", "0.70209706", "0.701319...
0.66546535
65
Initialisation of hidden states and cell states of LSTM to zero. Creation of two new tensors with sizes n_layers x batch_size x n_hidden.
def initialise_hidden(self, batch_size): weight = next(self.parameters()).data hidden = (weight.new(self._n_layers*self.directions, batch_size, self._hidden_size).zero_().to(self.device), weight.new(self._n_layers*self.directions, batch_size, self._hidden_size).zero_().to(self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_hidden(self):\n # TODO ========================\n # initialize the hidden states to zero\n\n initial_hidden = torch.zeros(self.num_layers, self.batch_size, self.hidden_size)\n return initial_hidden # a parameter tensor of shape (self.num_layers, self.batch_size, self.hidden_si...
[ "0.7726967", "0.76643664", "0.75588065", "0.7465409", "0.7465409", "0.7406703", "0.7388381", "0.7388381", "0.72557503", "0.72025776", "0.71975034", "0.7117093", "0.7048171", "0.70436203", "0.7036615", "0.69667935", "0.69302434", "0.68985224", "0.68985224", "0.68985224", "0.68...
0.6283871
48
Initialisation of weights and biases for the embedding layer and the RNN layers.
def initialise_weights(self): def initialise_process(param): """ Initialises weights of a given parameter following either Xavier or Kaiming uniform or normal processes. : param (torch.Tensor): """ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_weight(self):\n init_layer(self.conv1)\n init_layer(self.conv2)\n init_bn(self.norm1)\n init_bn(self.norm2)", "def instantiate_weights(self):\n with tf.variable_scope(\"embedding_projection\"), tf.device('/cpu:0'): # embedding matrix\n self.Embedding = tf.g...
[ "0.77943677", "0.7777627", "0.76114255", "0.76029295", "0.7508789", "0.7387998", "0.73835915", "0.73677576", "0.73591816", "0.73591816", "0.73591816", "0.73556024", "0.73530215", "0.72580236", "0.72257406", "0.71798956", "0.71372914", "0.71090186", "0.7084901", "0.70644426", ...
0.66120446
67
Initialises weights of a given parameter following either Xavier or Kaiming uniform or normal processes.
def initialise_process(param): if self._initialisation_process == 'xavier_uniform': tnni.xavier_uniform_(param.data) elif self._initialisation_process == 'xavier_normal': tnni.xavier_normal_(param.data) elif self._initialisation_process ==...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_weight(self):\r\n xavier_init(self.output_proj, distribution='uniform', bias=0.)", "def init_weights_(self):\n raise NotImplementedError", "def initialise_weights(self): \n \n def initialise_process(param):\n \n \"\"\"\n Initialises weight...
[ "0.75284606", "0.7397868", "0.7371006", "0.7275698", "0.72356653", "0.7192996", "0.7187742", "0.71090496", "0.7088423", "0.7076657", "0.7066805", "0.70589423", "0.70522285", "0.70522285", "0.6999897", "0.69886106", "0.6960581", "0.69561607", "0.69436896", "0.6931591", "0.6925...
0.65751314
54
Generates matrixes and layers to implement internal processing.
def build(self): # Defining the layers self.w1 = nn.Linear(self._hidden_size*2, self._expansion_size, bias = False).to(self.device) self.tanh = nn.Tanh() self.w2 = nn.Linear(self._expansion_size, self._attention_layers, bias = False).to(self.device) self.softmax = nn.Sof...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assembleMatrices(self):\n # All nodes informations\n self.aircraftNodesPoints = []\n self.aircraftMassPoints = []\n self.aircraftMassDistances = []\n self.aircraftSegmentsLengths = []\n self.aircraftNodesNames = []\n self.aircraftInitNodesAreas = []\n sel...
[ "0.6531163", "0.6477542", "0.6408404", "0.6279157", "0.6247964", "0.6191774", "0.61850005", "0.61850005", "0.61787516", "0.6170357", "0.61396635", "0.6123712", "0.60545397", "0.60288393", "0.5991115", "0.5973127", "0.5918543", "0.5913769", "0.5901594", "0.5899731", "0.5898971...
0.0
-1
Forward pass of the bidirectional hidden states.
def forward(self, output): hidden_states = self.extract_hidden_states(output) # Obtaining the attention weights weighted_states = self.w1(hidden_states) activated_states = self.tanh(weighted_states) score_weights = self.w2(activated_states) attention_wei...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _bridge_bidirectional_hidden(self, hidden):\n num_layers = hidden.size(0) // 2\n _, batch_size, hidden_size = hidden.size()\n return hidden.view(num_layers, 2, batch_size, hidden_size)\\\n .transpose(1, 2).contiguous().view(num_layers, batch_size, hidden_size * 2)", "def forwa...
[ "0.69670856", "0.6397652", "0.6265983", "0.6238433", "0.61677355", "0.61020136", "0.60459715", "0.60427034", "0.6039696", "0.5999765", "0.5988221", "0.598384", "0.5973033", "0.5929639", "0.591734", "0.5909836", "0.5899876", "0.58930695", "0.58797956", "0.5878488", "0.58754236...
0.0
-1
Extracts last hidden states from both directions.
def extract_hidden_states(self, output): # Extracting the forward and backward hidden states from the last BiLSTM layer # output (batch_size, sequence length, 2 * hidden dim) output_fw = output[:,:,0:self._hidden_size] output_bw = output[:,:,self._hidden_size:] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_hidden_states(self, output):\n # Intermediate hidden states\n output_fw_intermediate = output[:,:-1,0:self._hidden_size]\n output_bw_intermediate = output[:,1:,self._hidden_size:] \n \n # Last hidden states\n output_fw = output[:,-1,0:self._hidden_size]\n ...
[ "0.7700957", "0.73588395", "0.6921017", "0.6706472", "0.6245193", "0.6230705", "0.61972374", "0.6155109", "0.6091971", "0.60544163", "0.6048018", "0.59658885", "0.584702", "0.58091694", "0.58073974", "0.57948864", "0.5786997", "0.5783306", "0.5776817", "0.57515407", "0.575154...
0.758297
1
Generates matrixes and layers to implement internal processing.
def build(self, weight = 0.5): self.weight = weight # Defining weighting matrixes self.processing_fw = torch.randn((self._hidden_size, self._expansion_size), requires_grad = True).to(self.device) self.processing_bw = torch.randn((self._hidden_size, self._expansion_size)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assembleMatrices(self):\n # All nodes informations\n self.aircraftNodesPoints = []\n self.aircraftMassPoints = []\n self.aircraftMassDistances = []\n self.aircraftSegmentsLengths = []\n self.aircraftNodesNames = []\n self.aircraftInitNodesAreas = []\n sel...
[ "0.6533795", "0.6478307", "0.6406922", "0.62815374", "0.6245266", "0.6195874", "0.6190174", "0.6190174", "0.61767757", "0.61684704", "0.6142635", "0.61235183", "0.60565335", "0.60293376", "0.5989289", "0.59723383", "0.5916607", "0.59163237", "0.59031653", "0.59013414", "0.589...
0.5499406
80
Forward pass of the bidirectional hidden states.
def forward(self, output): last_ht, output_fw_intermediate, output_bw_intermediate = self.extract_hidden_states(output) # Intermediate hidden state internal processing output_reduced_fw = self.implement_processing(output_fw_intermediate, self.processing_fw) output_reduc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _bridge_bidirectional_hidden(self, hidden):\n num_layers = hidden.size(0) // 2\n _, batch_size, hidden_size = hidden.size()\n return hidden.view(num_layers, 2, batch_size, hidden_size)\\\n .transpose(1, 2).contiguous().view(num_layers, batch_size, hidden_size * 2)", "def forwa...
[ "0.69670856", "0.6397652", "0.6265983", "0.6238433", "0.61677355", "0.61020136", "0.60459715", "0.60427034", "0.6039696", "0.5999765", "0.5988221", "0.598384", "0.5973033", "0.5929639", "0.591734", "0.5909836", "0.5899876", "0.58930695", "0.58797956", "0.5878488", "0.58754236...
0.0
-1